catala/examples/Makefile.common.mk

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
2.7 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
CURR_DIR=examples/$(shell basename $(shell pwd))/
CATALA=cd ../../; _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
PLUGIN_DIR=_build/default/compiler/plugins
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)
@$(CATALA) Makefile $(CURR_DIR)$<
2021-03-19 19:36:09 +03:00
$(CATALA) \
2021-01-28 02:28:28 +03:00
OCaml \
$(CURR_DIR)$<
2021-01-28 02:28:28 +03:00
2022-07-22 18:42:24 +03:00
#> <target_file>_api_web.ml : Compiles the file to OCaml + generates the API web
%_api_web.ml: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $(CURR_DIR)$<
$(CATALA) \
api_web \
--plugin-dir=$(PLUGIN_DIR) \
$(CURR_DIR)$<
#> SCOPE=<ScopeName> <target_file>_api_web.ml : Generates the JSON schema
%_schema.json: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $(CURR_DIR)$<
$(CATALA) \
json_schema \
--plugin-dir=$(PLUGIN_DIR) \
-s $(SCOPE) \
$(CURR_DIR)$<
#> <target_file>.py : Compiles the file to Python
%.py: %.catala_$(CATALA_LANG)
@$(CATALA) Makefile $(CURR_DIR)$<
$(CATALA) \
Python \
$(CURR_DIR)$<
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 $(CURR_DIR)$<
2020-04-20 10:05:40 +03:00
$(CATALA) \
2020-04-29 10:55:49 +03:00
--wrap \
LaTeX \
$(CURR_DIR)$<
2022-05-05 15:00:24 +03:00
#> <target_file>.pdf : Weaves the file to PDF (via XeLaTeX)
2021-03-19 19:36:09 +03:00
%.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 $(CURR_DIR)$<
2020-04-29 10:55:49 +03:00
$(CATALA) \
--wrap \
HTML \
$(CURR_DIR)$<
2020-04-29 10:55:49 +03:00
%.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) \
$(SRC:.catala_$(CATALA_LANG)=_api_web.ml) \
$(SRC:.catala_$(CATALA_LANG)=_schema.json)
include $(wildcard $(SRC:.catala_$(CATALA_LANG)=.d))
2020-04-20 20:37:16 +03:00
.SECONDARY: