Created
April 17, 2015 19:19
-
-
Save tschaume/a28fdf3522b81a7a4674 to your computer and use it in GitHub Desktop.
A single Makefile to generate thesis/webpage/etc. from AsciiDoc source files (see https://github.com/tschaume/wp-pdf)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# filelist (needs to be in order!) | |
FILELIST= physics/part_title.txt \ | |
physics/intro.txt \ | |
physics/ana/chapter_title.txt \ | |
physics/ana/exp.txt \ | |
physics/ana/dsets_evttrk.txt \ | |
physics/ana/evtplane.txt \ | |
physics/ana/pid.txt \ | |
physics/ana/pairrec.txt \ | |
physics/effcorr.txt \ | |
physics/sim.txt \ | |
physics/results.txt \ | |
physics/summary.txt \ | |
software/part_title.txt \ | |
software/star/chapter_title.txt \ | |
software/star/stv0tofcorr.txt \ | |
software/star/stbadrdosdb.txt \ | |
software/star/strunideventsdb.txt \ | |
software/cvs2git.txt \ | |
software/public/chapter_title.txt \ | |
software/public/ckon.txt \ | |
software/public/ccsgp.txt \ | |
software/public/wp-pdf.txt \ | |
software/public/rmrg.txt \ | |
hardware/part_title.txt \ | |
hardware/vuvlamp.txt \ | |
appendix/part_title.txt \ | |
appendix/physics/chapter_title.txt \ | |
appendix/physics/faq.txt \ | |
appendix/physics/bad_runs.txt \ | |
appendix/physics/runqa.txt \ | |
appendix/physics/pid.txt \ | |
appendix/physics/sim.txt \ | |
appendix/physics/effcorr/tables.txt \ | |
appendix/physics/effcorr/dettrackqual_short.txt \ | |
appendix/physics/effcorr/tofmatchtotal_short.txt \ | |
appendix/physics/effcorr/tofmatch_extra.txt \ | |
appendix/physics/effcorr/tpcselect.txt \ | |
appendix/physics/effcorr/pair.txt \ | |
appendix/physics/effcorr/figures.txt \ | |
appendix/software/chapter_title.txt \ | |
appendix/software/stbadrdos_dbfiles.txt \ | |
appendix/software/cvs2git_source.txt \ | |
appendix/software/ckon_source.txt \ | |
appendix/software/wp-pdf_source.txt | |
FILELISTSI= appendix/part_title.txt \ | |
appendix/physics/chapter_title.txt \ | |
appendix/physics/effcorr/tables.txt \ | |
appendix/physics/effcorr/dettrackqual.txt \ | |
appendix/physics/effcorr/tofmatchtotal.txt \ | |
appendix/software/chapter_title.txt \ | |
appendix/software/stv0tofcorr_source.txt \ | |
appendix/software/stbadrdosdb_source.txt \ | |
appendix/software/strunideventsdb_source.txt \ | |
appendix/software/rmrg_source.txt | |
# symbolic links | |
LINKLIST = images docs #blogpost.py | |
# variables | |
DOCOUT=thesis | |
DOCINFO=docinfo.xml | |
DOCINFOREV=$(DOCOUT)-$(DOCINFO) | |
TAGLIST=$(shell git tag -l | tr '\n' ' ') | |
LASTTAG=$(shell git tag -l | tail -1) | |
FILENAME=$(DOCOUT)-$(LASTTAG) | |
# blogpost command | |
BPCMD=blogpost.py -p post | |
# phony takes target always as out-of-date | |
.PHONY: all docinfo check clean thesis info | |
REVNR=$(shell git log -1 HEAD --format=%h --date=short) | |
REVDATE=$(shell git log -1 HEAD --format=%ad --date=short) | |
# define directive for single revision entry | |
# argument: tagname | |
define REVCMD | |
echo '<revision>' >> $(DOCINFOREV) | |
echo ' <revnumber>'$(1)'</revnumber>' >> $(DOCINFOREV) | |
echo ' <date>'$(shell git log -1 $(1) --format=%ad --date=short)'</date>' >> $(DOCINFOREV) | |
echo ' <authorinitials>PH</authorinitials>' >> $(DOCINFOREV) | |
echo ' <revremark>'$(shell git log -1 $(1) --format=%B)'</revremark>' >> $(DOCINFOREV) | |
echo '</revision>' >> $(DOCINFOREV) | |
endef | |
# default target, make version and upload current version (tag) | |
all: thesis info backup | |
mv -v $(DOCOUT)-ref.pdf hp/$(FILENAME).pdf | |
mv -v $(DOCOUT)-ref.txt hp/$(FILENAME).txt | |
mv -v $(DOCOUT)SI-ref.pdf hp/$(FILENAME)_SI.pdf | |
mv -v $(DOCOUT)SI-ref.txt hp/$(FILENAME)_SI.txt | |
echo "- $(REVDATE): link:hp/$(FILENAME).pdf[$(FILENAME).pdf], link:hp/$(FILENAME).txt[$(FILENAME).txt], link:hp/$(FILENAME)_SI.pdf[$(FILENAME)_SI.pdf], link:hp/$(FILENAME)_SI.txt[$(FILENAME)_SI.txt]" >> downloads.txt | |
$(BPCMD) downloads.txt | |
git add downloads.txt downloads.blogpost | |
git commit -m "downloads: add $(DOCOUT)-$(LASTTAG).pdf/txt" | |
# check whether required symbolic links exist | |
# abort otherwise | |
define TESTDEF | |
$$(if $$(wildcard $(1)),$$(info symlink $(1) ok),$$(error symlink $(1) NOT found)) | |
endef | |
check: | |
$(foreach link, $(LINKLIST), $(eval $(call TESTDEF,$(link)))) | |
# generate $(DOCOUT)-docinfo.xml | |
docinfo: | |
cp $(DOCINFO) $(DOCINFOREV) | |
$(foreach tag, $(TAGLIST), $(call REVCMD,$(tag))) | |
echo '</revhistory>' >> $(DOCINFOREV) | |
# thesis | |
thesis: check | |
cp preamb.txt $(DOCOUT).txt | |
@$(foreach file, $(FILELIST), cat $(file) >> $(DOCOUT).txt; ) | |
asciidoc-bib --numeric-appearance-order -n -s acm-sigchi-proceedings $(DOCOUT).txt | |
asciidoc -b docbook -a latexmath $(DOCOUT)-ref.txt | |
dblatex -x '--maxvars 100000' -T db2latex_huck $(DOCOUT)-ref.xml # -d keep build dir | |
# supporting information | |
info: check | |
cp preamb.txt $(DOCOUT)SI.txt | |
@$(foreach file, $(FILELISTSI), cat $(file) >> $(DOCOUT)SI.txt; ) | |
asciidoc-bib --numeric-appearance-order -n -s acm-sigchi-proceedings $(DOCOUT)SI.txt | |
asciidoc -b docbook -a latexmath $(DOCOUT)SI-ref.txt | |
dblatex -x '--maxvars 100000' -T db2latex_huck $(DOCOUT)SI-ref.xml # -d keep build dir | |
# make a single pdf (note the file extension! provide a xsl!) | |
FORCE: | |
%.asc: FORCE | |
asciidoc-bib -s acm-sigchi-proceedings $*.asc | |
asciidoc -b docbook -a latexmath $*-ref.asc | |
dblatex -T db2latex -p $*.xsl $*-ref.xml | |
rm -v $*-ref.xml $*-ref.asc | |
backup: | |
git commit -m "safety backup" $(DOCOUT).txt $(DOCOUT)SI.txt | |
git push | |
# push a single asciidoc to wordpress | |
# and generate pdf | |
FORCE: | |
%.txt: FORCE | |
$(BPCMD) $*.txt | |
# clean up | |
clean: | |
@if [ -e $(DOCOUT)-ref.pdf ]; then rm -v $(DOCOUT)-ref.pdf; fi | |
@if [ -e $(DOCOUT)-ref.xml ]; then rm -v $(DOCOUT)-ref.xml; fi | |
@if [ -e $(DOCOUT)-ref.txt ]; then rm -v $(DOCOUT)-ref.txt; fi | |
@if [ -e $(DOCOUT)SI-ref.pdf ]; then rm -v $(DOCOUT)SI-ref.pdf; fi | |
@if [ -e $(DOCOUT)SI-ref.xml ]; then rm -v $(DOCOUT)SI-ref.xml; fi | |
@if [ -e $(DOCOUT)SI-ref.txt ]; then rm -v $(DOCOUT)SI-ref.txt; fi | |
@if [ -e $(DOCINFOREV) ]; then rm -v $(DOCINFOREV); fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment