SJWard
SJWard

Reputation: 3739

Expanding directories in variables with make

I have a makefile (below) for a project where I've been given a folder of "Raw Data" - a set of files from a colleague, and I've made an R script that does an analysis on some of those files. What I want to do with a the makefile then is assign the directory to a variable RAWDIR, and then use that variable in specifying the make dependencies of the R script, and as a command line argument for the script. Usually in the shell, directories with spaces are expanded when using double quotes and curly braces, but I do not know if this is also correct for make files, as with the following makefile I get the message make: *** No rule to make target""../Raw', needed by pulls'. Stop. So I do not think my file path assigned to RAWDIR is being expanded properly.

Thanks.

RAWDIR="../Raw Data/Fc Project Raw Data"

.PHONY: dirs

pulls: dirs "${RAWDIR}/pm_fc_dnds_cleandata.csv" "${RAWDIR}/fc1_seqs.fasta" "${RAWDIR}/fc2_seqs.fasta" "${RAWDIR}/pm1_seqs.fasta" "${RAWDIR}/pm2_seqs.fasta"
    Rscript Allele_Pulling.R "${RAWDIR}/" "${RAWDIR}/pm_fc_dnds_cleandata.csv"

dirs: 
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/FC
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/PM
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/Both
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/FC1PM1
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/FC1PM2
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/FC2PM1
    mkdir -p -v Pulled_Allelic_Pairs/Unaligned/FC2PM2
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/FC
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/PM
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/Both
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/FC1PM1
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/FC1PM2
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/FC2PM1
    mkdir -p -v Pulled_Allelic_Pairs/Aligned/FC2PM2

Upvotes: 1

Views: 146

Answers (1)

sgibb
sgibb

Reputation: 25736

In general spaces in pathnames are not well supported by make. At least some functions in GNU make could handle spaces that are escaped by \.

The following should work in your use case:

RAWDIR="../Raw\ Data/Fc\ Project\ Raw\ Data"

Upvotes: 1

Related Questions