# Exmaple: # make -k A=20070112 B=20070123 # A, B are make (or env) variables giving the ConTeXt versions to compare. ifneq (,$(wildcard .svn/)) $(error This is your repo! 'svn export' elsewhere to run $(MAKE)) endif # for >& redirection SHELL := /bin/bash # default dates, so that "make -k" should be all you need A ?= 20070112 B ?= 20070123 # you might want to change these texexec options # Don't use --timeout for now, since it can confuse the exit code. # Pass -file-line-error first, since it's the more important one (texexec # only honors the first --passon word, it seems) texexec := texexec --pdf --nonstopmode --passon="-file-line-error -recorder" run-it := $(abspath utils/run-it.py) # in seconds timeout := 30 maxkb := 1000 versiondb := utils/versions.d yyyymmdd := [12][0-9][0-9][0-9][0-9][0-9][0-9][0-9] testbase := test-[0-9][0-9][0-9] # report files all end like this rsuffix := -$(A)-$(B).report # which format file to look for to verify installation of new tree; # checks metafun.mem since it doesn't go in an (unknown) engine subdir tocheck := metafun.mem format := web2c/$(tocheck) alltexs := $(shell find -name '$(testbase).tex') allbases := $(basename $(alltexs)) allreports := $(addsuffix $(rsuffix), $(allbases)) allsummaries := $(addsuffix .summary, $(allreports)) # don't use := for these variables! tlog = $(basename $@).tlog basetlog = $(notdir $(tlog)) # get extra texexec arguments for this testfile (e.g. test-001.extraargs) eargs = $(shell cat $*.extraargs 2> /dev/null) # change to directory, then run texexec (allows -j parallelism) remake = cd $(dir $<) && $(run-it) $(timeout) $(basetlog) $(maxkb) $(texexec) $(eargs) $(notdir $<) >& $(basetlog) < /dev/null || echo " ERROR [exit code $$?] building $@ ; see $(tlog)" # for one-shot tempfiles temp = $(shell mktemp) # so that those scripts are not run. I guess the texmf.cnf has them # on by default. (BTW: How to make generating missfont.log # re-entrant? Somehow serialize runs in each directory?) export MKTEXTEX := 0 export MKTEXPK := 0 export MKTEXMF := 0 export MKTEXTFM := 0 export MKTEXFMT := 0 export MKOCP := 0 export MKOFM := 0 # reset TEXMFVAR, rather than TEXMFLOCAL, because it comes early # enough in TEXMF (see /etc/texmf/texmf.cnf) to shadow the system # paths (e.g. TEXMFSYSVAR). If you get rid of the mostly redundant # settings of TEXFORMATS, be sure to mkdir $(Apath)/web2c before # running texexec with these variables, else it'll discard it as not # writeable, then write somewhere that you probably don't want Apath := $(abspath ctxtrees/$(A)) Aformat := ctxtrees/$(A)/$(format) $(Aformat) %-$(A).pdf: export TEXMFVAR := $(Apath) $(Aformat) %-$(A).pdf: export TEXFORMATS := $(Apath)/web2c/{$$engine,} Bpath := $(abspath ctxtrees/$(B)) Bformat := ctxtrees/$(B)/$(format) $(Bformat) %-$(B).pdf: export TEXMFVAR := $(Bpath) $(Bformat) %-$(B).pdf: export TEXFORMATS := $(Bpath)/web2c/{$$engine,} .PRECIOUS: %/$(format) %-$(A).pdf %-$(B).pdf %-$(A).tex %-$(B).tex .PRECIOUS: %$(rsuffix) %.zip .PHONY: def clean summaries veryclean def summaries: $(allsummaries) %.summary: % @if [ -s $< ]; then echo " WARN: $<" ; awk '{print " " $$0}' < $<; fi @true # example of this target: # tex/context/base/unic-004.tex/test-001-20070112-20070123.report %$(rsuffix): %-$(A).pdf %-$(B).pdf @echo COMPARING: $@ @utils/compare-pdfs.sh $^ >& $@ @true # use separate A, B rules, else make thinks the command updates both targets %-$(B).tex: %.tex @cp $< $@ %-$(A).tex: %.tex @cp $< $@ %-$(A).pdf: %-$(A).tex $(Aformat) @$(remake) %-$(B).pdf: %-$(B).tex $(Bformat) @$(remake) # get context tree from the museum, renaming it from a temp location # to avoid partial zip files if download is interrupted %.zip: mkdir -p $(@D) t=$(temp) && grep "https.*cont-tmf-$(@F)" $(versiondb) | awk '{print $$2}' | wget -q --no-check-certificate -nc -O $$t -i - && mv $$t $@ # unpack tree, remake formats %/$(format): %.zip mkdir -p $(@D) cd $* && unzip -q $(abspath $<) texexec --make --all >& $(temp) mktexlsr $* >> $(temp) 2>&1 kpsewhich $(tocheck) | grep $@ clean: ctxtools --purgefiles --all --recurse > /dev/null @find -type f -name '$(testbase)*.report' | xargs rm -f @find -type f -name '$(testbase)-$(yyyymmdd)*' | xargs rm -f veryclean: clean rm -fr ctxtrees/