\$\begingroup\$
\$\endgroup\$
2
This is my first shot at writing a makefile for a document generation system. Please identify any more ways to refine it. Some pointers on how it works:
- The INPUT files initially are templates to be edited and are copied to the "src" directory upon first execution only.
- The code at the beginning tests for an environment variable equal to the directory path containing the input templates.
- The desired files will be in the "output" directory
- The file formats used include mustache templates for asciidoctor (.mst.adoc), asciidoctor (.adoc), HTML, and PDF. One adoc file uses asciidoctor-reveal.js, an HTML slide generator.
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
check_defined = \
$(strip $(foreach 1,1,ドル \
$(call __check_defined,1,ドル$(strip $(value 2)))))
__check_defined = \
$(if $(value 1ドル),, \
$(error Undefined 1ドル$(if 2,ドル (2ドル))))
#TEST ENVIRONMENT VARIABLES
$(call check_defined, TEACH_PROJ)
#DIRECTORIES:
PRJ=$(TEACH_PROJ)
OUT=../output/
BLD=../build/
ADC=asciidoctor
MST=mustache
#OUTPUT
HTM_NOT=$(OUT)notes.html
HTM_PRS=$(OUT)presentation.html
HTM_VOC=$(OUT)vocabulary.html
PDF_PRS=$(OUT)presentation.pdf
#INTERMEDIATE
ADC_PRS=$(BLD)presentation.adoc
ADC_VOC=$(BLD)vocabulary.adoc
#INPUT
YML_VOC=vocabulary.yml
FIL_GEM=Gemfile
MST_PRS=presentation.mst.adoc
MST_VOC=vocabulary.mst.adoc
#RECIPES
RCP_COPY=cp -an $(PRJ)$@
RCP_MKD=mkdir -p $@
RCP_ADC=$(ADC) $< -o $@
RCP_RJS=bundle exec $(ADC)-revealjs -o $@ $<
RCP_PDF=$(RCP_ADC) -r $(ADC)-pdf -b pdf -a pdf-stylesdir=$(PRJ) -a pdf-style=compact
RCP_MST=$(MST) $(YML_VOC) $< > $@
all: $(HTM_PRS) $(HTM_NOT) $(PDF_PRS) $(HTM_VOC)
$(HTM_PRS): $(ADC_PRS) $(FIL_GEM)|$(OUT); $(RCP_RJS)
$(PDF_PRS): $(ADC_PRS)|$(OUT); $(RCP_PDF)
TARGETS=$(HTM_NOT) $(HTM_VOC)
$(HTM_NOT): $(ADC_PRS)|$(OUT)
$(HTM_VOC): $(ADC_VOC)|$(OUT)
$(TARGETS): ;$(RCP_ADC)
#build:
TARGETS=$(ADC_PRS) $(ADC_VOC)
$(ADC_PRS): $(MST_PRS) $(YML_VOC)|$(BLD)
$(ADC_VOC): $(MST_VOC) $(YML_VOC)|$(BLD)
$(TARGETS): ;$(RCP_MST)
#input
$(YML_VOC) $(MST_VOC) $(MST_PRS) $(FIL_GEM): ; $(RCP_COPY) .
$(OUT) $(BLD): ; $(RCP_MKD)
clean: ; rm -rf $(BLD) $(OUT)
```
200_success
146k22 gold badges190 silver badges479 bronze badges
asked May 4, 2019 at 15:22
default
.yaml
since 2006. It is unclear if you intended to useYAML_VOC=vocabulary.yaml
or that you really use YML and is that tag yaml incorrect. \$\endgroup\$