2023-11-13 23:54:16 -06:00
|
|
|
all: examples all_tex tidy
|
2023-08-02 16:20:29 -05:00
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
# set a fake time in pdf generation to prevent unnecessary differences in output
|
|
|
|
FAKETIME := TZ='Z' faketime -f '2022-01-01 00:00:00 x0,001'
|
2023-08-02 16:20:29 -05:00
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
# find all code example makefiles
|
|
|
|
.PHONY: examples
|
|
|
|
CODE_EXAMPLES := ../code_examples/*/Makefile
|
|
|
|
examples: $(CODE_EXAMPLES)
|
2022-11-15 05:55:22 -06:00
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
# target to convert specified dot file(s)
|
|
|
|
.PHONY: convert
|
|
|
|
TARG_DOT ?=
|
|
|
|
convert: $(TARG_DOT:.dot=.pdf) $(TARG_DOT:.dot=.svg)
|
2022-11-15 05:55:22 -06:00
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
# use empty FORCE target because .PHONY ignores % expansion, using find allows
|
|
|
|
# us to generate everything in one pass, since we don't know all of the possible
|
|
|
|
# outputs until the sub-makes run
|
|
|
|
FORCE:
|
|
|
|
../%/Makefile: FORCE
|
|
|
|
@make -C $(@D) dots
|
|
|
|
@mkdir -p $*
|
|
|
|
@find $(@D) -name *.dot -exec cp -u {} -t $* \;
|
|
|
|
@find $* -name *.dot -printf "%p " | xargs -i make --no-print-directory convert TARG_DOT="{}"
|
2022-11-15 05:55:22 -06:00
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
# find and build all tex files
|
|
|
|
.PHONY: all_tex
|
|
|
|
TEX_FILES := $(wildcard **/*.tex)
|
|
|
|
all_tex: $(TEX_FILES:.tex=.pdf) $(TEX_FILES:.tex=.svg)
|
2023-08-02 16:20:29 -05:00
|
|
|
|
2023-11-13 23:54:16 -06:00
|
|
|
%.pdf: %.dot
|
|
|
|
$(FAKETIME) dot -Tpdf -o $@ $<
|
2022-11-15 05:55:22 -06:00
|
|
|
|
|
|
|
%.pdf: %.tex
|
2023-11-13 23:54:16 -06:00
|
|
|
cd $(@D) && $(FAKETIME) pdflatex $(<F) --interaction=nonstopmode
|
2022-11-15 05:55:22 -06:00
|
|
|
|
|
|
|
%.svg: %.pdf
|
|
|
|
pdf2svg $< $@
|
|
|
|
|
|
|
|
.PHONY: clean tidy
|
|
|
|
tidy:
|
2023-11-13 23:54:16 -06:00
|
|
|
rm -f **/*.log **/*.aux
|
|
|
|
|
2022-11-15 05:55:22 -06:00
|
|
|
clean: tidy
|
2023-11-13 23:54:16 -06:00
|
|
|
rm -rf code_examples
|
|
|
|
rm -f **/*.pdf **/*.svg
|