Files

51 lines
1.2 KiB
Makefile
Raw Permalink Normal View History

all: examples all_tex
2023-08-03 09:20:29 +12:00
2023-11-14 18:54:16 +13: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-03 09:20:29 +12:00
ifneq ($(shell :; command -v rsync),)
RSYNC_CP ?= rsync -t
else
RSYNC_CP ?= cp -a
endif
2023-11-14 18:54:16 +13:00
# find all code example makefiles
.PHONY: examples
CODE_EXAMPLES := ../code_examples/*/Makefile
examples: $(CODE_EXAMPLES)
2022-11-16 00:55:22 +13:00
2024-08-23 12:52:15 +12:00
# target to convert all dot files
# needs to be run *after* examples, otherwise no dot files will be found
2023-11-14 18:54:16 +13:00
.PHONY: convert
2024-08-23 12:52:15 +12:00
DOT_FILES := $(shell find . -name *.dot)
convert: $(DOT_FILES:.dot=.pdf) $(DOT_FILES:.dot=.svg)
2022-11-16 00:55:22 +13:00
2024-08-23 12:52:15 +12:00
# use empty FORCE target because .PHONY ignores % expansion
2023-11-14 18:54:16 +13:00
FORCE:
../%/Makefile: FORCE
@make -C $(@D) dots
@mkdir -p $*
@find $(@D) -name *.dot -exec $(RSYNC_CP) {} $* \;
2022-11-16 00:55:22 +13:00
2023-11-14 18:54:16 +13:00
# find and build all tex files
.PHONY: all_tex
2024-08-23 12:52:15 +12:00
TEX_FILES := $(shell find . -name *.tex)
2023-11-14 18:54:16 +13:00
all_tex: $(TEX_FILES:.tex=.pdf) $(TEX_FILES:.tex=.svg)
2023-08-03 09:20:29 +12:00
2023-11-14 18:54:16 +13:00
%.pdf: %.dot
$(FAKETIME) dot -Tpdf -o $@ $<
2022-11-16 00:55:22 +13:00
%.pdf: %.tex
2023-11-14 18:54:16 +13:00
cd $(@D) && $(FAKETIME) pdflatex $(<F) --interaction=nonstopmode
2022-11-16 00:55:22 +13:00
%.svg: %.pdf
pdf2svg $< $@
.PHONY: clean tidy
tidy:
2023-11-14 18:54:16 +13:00
rm -f **/*.log **/*.aux
2022-11-16 00:55:22 +13:00
clean: tidy
2023-11-14 18:54:16 +13:00
rm -rf code_examples
rm -f **/*.pdf **/*.svg