| 1 | # Configuration variables
|
|---|
| 2 |
|
|---|
| 3 | Build = build
|
|---|
| 4 |
|
|---|
| 5 | Benchmarks = benchmarks
|
|---|
| 6 | Pictures = pictures
|
|---|
| 7 | Plots = plots
|
|---|
| 8 | Programs = programs
|
|---|
| 9 |
|
|---|
| 10 | LaTMac = ../../LaTeXmacros
|
|---|
| 11 | BibRep = ../../bibliography
|
|---|
| 12 |
|
|---|
| 13 | strip-top-dir = $(foreach p,$1,$(patsubst %/,%,$(subst $(firstword $(subst /, ,$(p)))/,, $(p))))
|
|---|
| 14 |
|
|---|
| 15 | .SUFFIXES: # disable make built-in rules
|
|---|
| 16 |
|
|---|
| 17 | TeXSRC = ${wildcard *.tex}
|
|---|
| 18 | PicSRC = ${notdir ${wildcard ${Pictures}/*.png}} ${notdir ${wildcard ${Pictures}/*.fig}}
|
|---|
| 19 | PicSRC := ${PicSRC:.fig=.pdf} # substitute ".fig" with ".pdf"
|
|---|
| 20 | PlotSRC = ${notdir ${wildcard ${Plots}/*.gp}}
|
|---|
| 21 | PlotSRC := ${addprefix ${Build}/plot-,${PlotSRC:.gp=.pdf}} # substitute ".gp" with ".pdf"
|
|---|
| 22 | DemoPgmSRC = ${notdir ${wildcard ${Programs}/*-demo.cfa}}
|
|---|
| 23 | PgmSRC = ${notdir ${wildcard ${Programs}/*}}
|
|---|
| 24 | RunPgmSRC = ${notdir ${wildcard ${Programs}/*.run.*}}
|
|---|
| 25 | NondemoPgmSRC = ${call strip-top-dir,${wildcard ${Programs}/*/*.c*}}
|
|---|
| 26 | BibSRC = ${wildcard *.bib}
|
|---|
| 27 |
|
|---|
| 28 | TeXLIB = .:${LaTMac}:${Build}: # common latex macros
|
|---|
| 29 | BibLIB = .:${BibRep}: # common citation repository
|
|---|
| 30 |
|
|---|
| 31 | #MAKEFLAGS = --no-print-directory # --silent
|
|---|
| 32 | VPATH = ${Build} ${Pictures} ${Programs} # extra search path for file names used in document
|
|---|
| 33 |
|
|---|
| 34 | DOCUMENT = uw-ethesis.pdf
|
|---|
| 35 | BASE = ${basename ${DOCUMENT}} # remove suffix
|
|---|
| 36 |
|
|---|
| 37 | RunPgmExe = ${addprefix ${Build}/,${basename ${basename ${RunPgmSRC}}}}
|
|---|
| 38 | RunPgmOut = ${RunPgmExe:%=%.out}
|
|---|
| 39 | DemoPgmExe = ${addprefix ${Build}/,${basename ${basename ${DemoPgmSRC}}}}
|
|---|
| 40 | DemoPgmOut = ${DemoPgmExe:%=%.out}
|
|---|
| 41 |
|
|---|
| 42 | # Commands
|
|---|
| 43 |
|
|---|
| 44 | LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && pdflatex -halt-on-error -output-directory=${Build}
|
|---|
| 45 | BibTeX = BIBINPUTS=${BibLIB} && export BIBINPUTS && bibtex
|
|---|
| 46 | CFA = cfa -O0 -g
|
|---|
| 47 | CC = gcc -O0 -g
|
|---|
| 48 | CXX = g++-11 --std=c++20 -O0 -g
|
|---|
| 49 |
|
|---|
| 50 | # Rules and Recipes
|
|---|
| 51 |
|
|---|
| 52 | .PHONY : all clean # not file names
|
|---|
| 53 | .SECONDARY:
|
|---|
| 54 | #.PRECIOUS : ${Build}/% # don't delete intermediates
|
|---|
| 55 | .ONESHELL :
|
|---|
| 56 |
|
|---|
| 57 | all : ${DOCUMENT}
|
|---|
| 58 |
|
|---|
| 59 | clean :
|
|---|
| 60 | @rm -frv ${DOCUMENT} ${Build}
|
|---|
| 61 |
|
|---|
| 62 | # File Dependencies
|
|---|
| 63 |
|
|---|
| 64 | ${DOCUMENT}: ${TeXSRC} $(RunPgmOut) ${DemoPgmOut} ${NondemoPgmSRC} ${PlotSRC} ${PicSRC} ${BibSRC} ${BibRep}/pl.bib ${LaTMac}/common.tex Makefile | ${Build}
|
|---|
| 65 | echo ${PicSRC}
|
|---|
| 66 | echo ${GraphSRC_OLD}
|
|---|
| 67 | ${LaTeX} ${BASE}
|
|---|
| 68 | ${BibTeX} ${Build}/${BASE}
|
|---|
| 69 | ${LaTeX} ${BASE}
|
|---|
| 70 | # if needed, run latex again to get citations
|
|---|
| 71 | if fgrep -s "LaTeX Warning: Citation" ${basename $@}.log ; then ${LaTeX} ${BASE} ; fi
|
|---|
| 72 | # ${Glossary} ${Build}/${BASE}
|
|---|
| 73 | # ${LaTeX} ${BASE}
|
|---|
| 74 | cp ${Build}/$@ $@
|
|---|
| 75 |
|
|---|
| 76 | ${Build}:
|
|---|
| 77 | mkdir -p $@
|
|---|
| 78 |
|
|---|
| 79 | ${Build}/%-demo: ${Programs}/%-demo.cfa | ${Build}
|
|---|
| 80 | ${CFA} $< -o $@
|
|---|
| 81 |
|
|---|
| 82 | ${Build}/%: ${Programs}/%-demo.cfa | ${Build}
|
|---|
| 83 | ${CFA} $< -o $@
|
|---|
| 84 |
|
|---|
| 85 | ${Build}/%: ${Programs}/%.run.cfa | ${Build} # cfa cannot handle pipe
|
|---|
| 86 | sed -f ${Programs}/sedcmd $< > ${Build}/tmp.cfa; ${CFA} ${Build}/tmp.cfa -o $@
|
|---|
| 87 |
|
|---|
| 88 | ${Build}/%: ${Programs}/%.run.c | ${Build}
|
|---|
| 89 | sed -f ${Programs}/sedcmd $< | ${CC} -x c -I ${Programs} -o $@ -
|
|---|
| 90 |
|
|---|
| 91 | ${Build}/%: ${Programs}/%.run.cpp | ${Build}
|
|---|
| 92 | sed -f ${Programs}/sedcmd $< | ${CXX} -x c++ -I ${Programs} -o $@ -
|
|---|
| 93 |
|
|---|
| 94 | ${Build}/%.out: ${Build}/% | ${Build}
|
|---|
| 95 | $< > $@
|
|---|
| 96 |
|
|---|
| 97 | %.pdf: %.fig | ${Build}
|
|---|
| 98 | fig2dev -L pdf $< > ${Build}/$@
|
|---|
| 99 |
|
|---|
| 100 | -include $(Plots)/*.d
|
|---|
| 101 |
|
|---|
| 102 | ${Build}/plot-%.dat: ${Plots}/%.py ${Plots}/common.py ${Plots}/ListCommon.py ${Plots}/%.py.INPUTS | ${Build}
|
|---|
| 103 | python3 $< > $@
|
|---|
| 104 |
|
|---|
| 105 | ${Build}/plot-%.pdf: ${Plots}/%.gp ${Plots}/%.gp.INPUTS | ${Build}
|
|---|
| 106 | gnuplot $<
|
|---|
| 107 |
|
|---|
| 108 | #-include ${Build}/*.d
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 | # troubleshooting, e.g. `make echo_DEMOS` runs `echo $(DEMOS)`
|
|---|
| 112 | echo_% :
|
|---|
| 113 | @echo '$($(@:echo_%=%))'
|
|---|
| 114 |
|
|---|