photobook/Makefile
Alex A. Naanou 9c822ed499 moved cls2tex.sh script to the stripts directory...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2021-11-13 13:23:21 +03:00

106 lines
2.4 KiB
Makefile

#----------------------------------------------------------------------
ARGS :=
# NOTE: need to run latex two times to build index, the simpler way to
# go is to use latexmk...
#TEX := lualatex $(ARGS)
TEX := latexmk -lualatex $(ARGS)
#----------------------------------------------------------------------
# Generate docs from latex package/class...
#
# - keep lines starting with \def\<module-name>@[A-Z]\+
# - keep lines starting with '%%'
# - %%%%% Text -> \subsection(Text)
# - %%%% Text -> \section(Text)
# - %% >> code -> \begin{verbatim}code\end{verbatim}
#
# NOTE: the idea of keeping latex docs in a latex file is far similar
# than all the stuff crammed into .dtx, at least for my needs:
# - keep the code readable
# - keep the docs readable
# in both the repo and in installed form.
# NOTE: this is evolving as need arises, when this gets too complicated
# we'll split it out into it's own script.
#
# XXX BUG: for some odd reason this produces different results when called
# from 'bash' and 'bash --login -i', mainly the egrep rule seems
# to be broken...
# ...also appears to be broken under termux...
# .....seems that moving this out to a script would be the simplest way
# to solve this odd instability...
texToDoc = \
@echo "texToDoc: $1 -> $2"; \
./scripts/cls2tex.sh $1 $2 $3
#----------------------------------------------------------------------
%.pdf: %.tex
$(TEX) $< > /dev/null
# NOTE: .sty and .cls are essentially the same in terms of documentation
# generation...
%.tex: %.sty %-meta.tex
$(call texToDoc,$<,$@,%)
%.tex: %.cls %-meta.tex
$(call texToDoc,$<,$@,%)
# NOTE: this is a bit ugly, but allot less so than trying to push \verb
# into a LaTeX macro/env and then getting it out again in one pice...
%-meta.tex: %.sty
$(call texToDoc,$<,$@,M)
%-meta.tex: %.cls
$(call texToDoc,$<,$@,M)
#----------------------------------------------------------------------
.PHONY: doc
doc: photobook.pdf
.PHONY: all
all: doc sweep
# XXX
.PHONY: dist
dist: all
# XXX install... (see: ./tmp/Makefile)
# - local
# - root
.PHONY: install
install: dist
#----------------------------------------------------------------------
.PHONY: sweep
sweep:
rm -f *.{aux,fls,glo,gls,hd,idx,ilg,ind,ins,log,out,toc,fdb_latexmk}
.PHONY: clean
clean: sweep
rm -f *.pdf
#----------------------------------------------------------------------
# vim:set ts=4 sw=4 :