1 | # Configuration variables |
---|
2 | |
---|
3 | Build = build |
---|
4 | Pictures = pictures |
---|
5 | Programs = programs |
---|
6 | |
---|
7 | TeXSRC = ${wildcard *.tex} |
---|
8 | PicSRC = ${notdir ${wildcard ${Pictures}/*.png}} |
---|
9 | DemoSRC = ${notdir ${wildcard ${Programs}/*-demo.cfa}} |
---|
10 | PgmSRC = ${notdir ${wildcard ${Programs}/*}} |
---|
11 | RunPgmSRC = ${notdir ${wildcard ${Programs}/*.run.*}} |
---|
12 | BibSRC = ${wildcard *.bib} |
---|
13 | |
---|
14 | TeXLIB = .:../../LaTeXmacros:${Build}: # common latex macros |
---|
15 | BibLIB = .:../../bibliography # common citation repository |
---|
16 | |
---|
17 | #MAKEFLAGS = --no-print-directory # --silent |
---|
18 | VPATH = ${Build} ${Pictures} ${Programs} # extra search path for file names used in document |
---|
19 | |
---|
20 | DOCUMENT = uw-ethesis.pdf |
---|
21 | BASE = ${basename ${DOCUMENT}} # remove suffix |
---|
22 | |
---|
23 | DemoTex = ${DemoSRC:%.cfa=${Build}/%.tex} |
---|
24 | RunPgmExe = ${addprefix ${Build}/,${basename ${basename ${RunPgmSRC}}}} |
---|
25 | RunPgmOut = ${RunPgmExe:%=%.out} |
---|
26 | |
---|
27 | # Commands |
---|
28 | |
---|
29 | LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && pdflatex -halt-on-error -output-directory=${Build} |
---|
30 | BibTeX = BIBINPUTS=${BibLIB} && export BIBINPUTS && bibtex |
---|
31 | CFA = cfa -O0 -g |
---|
32 | CC = gcc -O0 -g |
---|
33 | CXX = g++-11 --std=c++20 -O0 -g |
---|
34 | |
---|
35 | # Rules and Recipes |
---|
36 | |
---|
37 | .PHONY : all fragments_ran clean # not file names |
---|
38 | .PRECIOUS : ${Build}/% ${Build}/%-demo # don't delete intermediates |
---|
39 | .ONESHELL : |
---|
40 | |
---|
41 | all : fragments_ran ${DOCUMENT} |
---|
42 | |
---|
43 | fragments_ran : $(RunPgmOut) |
---|
44 | |
---|
45 | clean : |
---|
46 | @rm -frv ${DOCUMENT} ${Build} |
---|
47 | |
---|
48 | # File Dependencies |
---|
49 | |
---|
50 | %.pdf : ${TeXSRC} ${DemoTex} ${PicSRC} ${PgmSRC} ${BibSRC} Makefile | ${Build} |
---|
51 | ${LaTeX} ${BASE} |
---|
52 | ${BibTeX} ${Build}/${BASE} |
---|
53 | ${LaTeX} ${BASE} |
---|
54 | # if needed, run latex again to get citations |
---|
55 | if fgrep -s "LaTeX Warning: Citation" ${basename $@}.log ; then ${LaTeX} ${BASE} ; fi |
---|
56 | # ${Glossary} ${Build}/${BASE} |
---|
57 | # ${LaTeX} ${BASE} |
---|
58 | cp ${Build}/$@ $@ |
---|
59 | |
---|
60 | ${Build}: |
---|
61 | mkdir -p $@ |
---|
62 | |
---|
63 | %-demo.tex: %-demo | ${Build} |
---|
64 | $< > $@ |
---|
65 | |
---|
66 | ${Build}/%-demo: ${Programs}/%-demo.cfa | ${Build} |
---|
67 | ${CFA} $< -o $@ |
---|
68 | |
---|
69 | ${Build}/%: ${Programs}/%.run.cfa | ${Build} # cfa cannot handle pipe |
---|
70 | sed -f ${Programs}/sedcmd $< > ${Build}/tmp.cfa; ${CFA} ${Build}/tmp.cfa -o $@ |
---|
71 | |
---|
72 | ${Build}/%: ${Programs}/%.run.c | ${Build} |
---|
73 | sed -f ${Programs}/sedcmd $< | ${CC} -x c -I ${Programs} -o $@ - |
---|
74 | |
---|
75 | ${Build}/%: ${Programs}/%.run.cpp | ${Build} |
---|
76 | sed -f ${Programs}/sedcmd $< | ${CXX} -x c++ -I ${Programs} -o $@ - |
---|
77 | |
---|
78 | ${Build}/%.out: ${Build}/% | ${Build} |
---|
79 | $< > $@ |
---|
80 | |
---|
81 | -include ${Build}/*.d |
---|