I am a Makefile novice and I want to use it to render Rmarkdown files when they have altered timestamps, to produce the corresponding .pdf
files. The file data_prep_1.Rmd
is rendered to .pdf
and additionally produces the output file all_sample_data.csv
. When data_prep_1.Rmd
is changed (or its timestamp is altered), it should be re-rendered, as should ../bioinformatics/Reads_by_sample.Rmd
and distance_matrices.Rmd
because they depend on the .csv
file. If the timestamp of ../bioinformatics/Reads_by_sample.Rmd
is changed relative to its .pdf
, only this .Rmd
file should be re-rendered.
Putting the all : and the .pdf
and .csv
file in the first line will lead both blocks to run each time make is called.
I have:
../../data/all_sample_data.csv : data_prep_1.Rmd
Rscript -e "rmarkdown::render('data_prep_1.Rmd')"
Rscript -e "rmarkdown::render('../bioinformatics/Reads_by_sample.Rmd')"
Rscript -e "rmarkdown::render('distance_matrices.Rmd')"
../bioinformatics/Reads_by_sample.pdf : ../bioinformatics/Reads_by_sample.Rmd
Rscript -e "rmarkdown::render('../bioinformatics/Reads_by_sample.Rmd')"
If I do touch data_prep_1.Rmd
, then make
, the first block runs as desired.
But if I do touch ../bioinformatics/Reads_by_sample.Rmd
, then make
I get make: '../../data/all_sample_data.csv is up to date'
.
I know this is clumsy use of Makefile, but how can I get the behavior I want in a single Makefile?