catala/examples/Makefile.common.mk

82 lines
2.0 KiB
Makefile
Raw Normal View History

2020-05-13 15:17:19 +03:00
##########################################
# Variables
##########################################
2021-03-19 19:36:09 +03:00
LATEXMK?=latexmk
2021-06-21 12:39:06 +03:00
CATALA=../../_build/default/compiler/catala.exe \
2021-02-01 22:09:16 +03:00
$(CATALA_OPTS) --language=$(CATALA_LANG)
2020-04-20 20:37:16 +03:00
2021-03-19 19:36:09 +03:00
help : ../Makefile.common.mk
@sed -n 's/^#> //p' $<
2020-05-13 15:17:19 +03:00
##########################################
# Targets
##########################################
2021-03-19 19:36:09 +03:00
#> SCOPE=<ScopeName> <target_file>.run : Runs the interpeter for the scope of the file
2021-02-01 22:09:16 +03:00
%.run: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
2021-03-19 19:36:09 +03:00
$(CATALA) \
2020-12-03 20:59:14 +03:00
Interpret \
-s $(SCOPE) \
$<
2021-03-19 19:36:09 +03:00
#> <target_file>.ml : Compiles the file to OCaml
2021-02-01 22:09:16 +03:00
%.ml: %.catala_$(CATALA_LANG)
2021-01-28 02:28:28 +03:00
@$(CATALA) Makefile $<
2021-03-19 19:36:09 +03:00
$(CATALA) \
2021-01-28 02:28:28 +03:00
OCaml \
$<
#> <target_file>.py : Compiles the file to Python
%.py: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
$(CATALA) \
Python \
$<
2021-03-19 19:36:09 +03:00
#> <target_file>.tex : Weaves the file to LaTeX
2021-02-01 22:09:16 +03:00
%.tex: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
2020-04-20 10:05:40 +03:00
$(CATALA) \
2020-04-29 10:55:49 +03:00
--wrap \
LaTeX \
$<
2021-03-19 19:36:09 +03:00
#> <target_file>.pdf : Weaves the file to PDF (via LaTeX)
%.pdf: %.tex
cd $(@D) && $(LATEXMK) -g -xelatex -halt-on-error -shell-escape $(%F)
2021-03-19 19:36:09 +03:00
#> <target_file>.html : Weaves the file to HTML
%.html: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $<
2020-04-29 10:55:49 +03:00
$(CATALA) \
--wrap \
HTML \
$<
%.spellok: %.catala_$(CATALA_LANG) ../whitelist.$(CATALA_LANG)
aspell list --lang=$(CATALA_LANG) --mode=markdown --camel-case --add-wordlists=../whitelist.$(CATALA_LANG) <$< | tee "$<".errors
@# list of mispelled words must be empty
@test ! -s "$<".errors
@touch $@
2020-05-13 15:17:19 +03:00
##########################################
# Misceallenous
##########################################
2021-03-19 19:36:09 +03:00
#> 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) \
$(SRC:.catala_$(CATALA_LANG)=.ml) \
include $(wildcard $(SRC:.catala_$(CATALA_LANG)=.d))
2020-04-20 20:37:16 +03:00
.SECONDARY: