catala/examples/Makefile.common.mk
2021-03-19 17:36:09 +01:00

68 lines
1.5 KiB
Makefile

##########################################
# Variables
##########################################
LATEXMK?=latexmk
CATALA=dune exec --no-print-director ../../src/catala/catala.exe -- \
$(CATALA_OPTS) --language=$(CATALA_LANG)
help : ../Makefile.common.mk
@sed -n 's/^#> //p' $<
##########################################
# Targets
##########################################
#> SCOPE=<ScopeName> <target_file>.run : Runs the interpeter for the scope of the file
%.run: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
$(CATALA) \
Interpret \
-s $(SCOPE) \
$<
#> <target_file>.ml : Compiles the file to OCaml
%.ml: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
$(CATALA) \
OCaml \
$<
#> <target_file>.tex : Weaves the file to LaTeX
%.tex: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
$(CATALA) \
--wrap \
LaTeX \
$<
#> <target_file>.pdf : Weaves the file to PDF (via LaTeX)
%.pdf: %.tex
cd $(@D) && $(LATEXMK) -g -pdf -halt-on-error -shell-escape $(%F)
#> <target_file>.html : Weaves the file to HTML
%.html: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
$(CATALA) \
--wrap \
HTML \
$<
##########################################
# Misceallenous
##########################################
#> clean : Removes intermediate files
clean:
$(LATEXMK) -f -C $(SRC:.catala_$(CATALA_LANG)=.tex)
rm -rf $(SRC:.catala_$(CATALA_LANG)=.tex) \
$(SRC:.catala_$(CATALA_LANG)=.d) \
_minted-$(SRC:.catala_$(CATALA_LANG)=) \
$(SRC:.catala_$(CATALA_LANG)=.html)
include $(wildcard $(SRC:.catala_$(CATALA_LANG)=.d))
.SECONDARY: