From 21fa6df366cd6c6abf6d7e65fafb7382d463f1b6 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 13 Sep 2004 13:53:02 +0000 Subject: [PATCH] . [SVN r25039] --- doc/GNUmakefile | 239 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 228 insertions(+), 11 deletions(-) diff --git a/doc/GNUmakefile b/doc/GNUmakefile index 85917f7..6960680 100755 --- a/doc/GNUmakefile +++ b/doc/GNUmakefile @@ -1,15 +1,232 @@ -# Copyright David Abrahams 2004. Distributed under the Boost -# Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# GNUmakefile for postprocessing PDF files +# +# © 2000 IBM Corporation. +# Licensed under the GNU GPL. +######################################################################## +# Make sure that the following macros are correct for your setup +######################################################################## +# ... System utilities +RMRF = /bin/rm -rf +MV = /bin/mv +EGREP = /bin/egrep ECHO = /bin/echo +PERL = /usr/bin/perl +PYTHON = python +CAT = /bin/cat +TOUCH = /bin/touch +ZIP = /usr/bin/zip -all: - @${ECHO} "/libs/iterator/doc/GNUmakefile should be replaced by" - @${ECHO} - @${ECHO} " http://www.boost-consulting.com/writing/GNUmakefile," - @${ECHO} - @${ECHO} "before proceeding. That file is not included in the Boost" - @${ECHO} "distribution because it is licensed under the GPL, which violates" - @${ECHO} "Boost license requirements." +# ... TeX & postprocessors +PPOWER4 = ppower4 +PDFLATEX = pdflatex +METAPOST = mpost +FIG2DEV = fig2dev +BIBTEX = bibtex +FOLIAGECUTTER = foliageCutter --verbose +RST2LATEX = rst2latex +RST2HTML = rst2html +TEX = latex +export TEX +######################################################################## +# End of user servicable parts; don't fiddle with the remainder of this +# makefile unless you know what you do. +# +# You have been warned ;=) +######################################################################## + +# ... Variables +TEXFILES = $(strip $(wildcard *.tex)) +RSTFILES = $(strip $(wildcard *.rst)) +-include GNUmakefile.local +TEXSTEMS = $(strip $(patsubst %.tex,%,${TEXFILES})) +RSTSTEMS = $(strip $(patsubst %.rst,%,${RSTFILES})) +CUTFOILS = $(strip $(patsubst %,%---toc.tex,${TEXSTEMS})) +PDFFILES = $(strip $(patsubst %.tex,%.pdf,${TEXFILES})) +PRINTS = $(patsubst %.pdf,%-print.pdf,${PDFFILES}) +PRINTZIP = prints.zip +SLIDEZIP = slides.zip + +# ... Depend +DEPENDFILES = .depend +GENFILE = .generated + +# ... List of extensions and files generated +texcrap = *.mpx *.log *.aux *.blg *-print.brf *-print.tex *.out + +mpxcrap = mpxerr.tex mpxerr.pdf + +generated = *.out *.[0-9] *.[0-9][0-9] *.bbl *.brf \ + *.mp *.mmp *.pdf *.ps TMP-*.pdf *.ftoc\ + ${PRINTZIP} ${SLIDEZIP} ${GENFILE} ${DEPENDFILES} \ + ${texcrap} ${mpxcrap} ${CUTFOILS} $(strip $(wildcard *---*.tex)) + + +# ... canned command to run PDFLaTeX +define run-pdflatex +@${ECHO} "" +@${ECHO} "---- Running PDFLaTeX on $<" && ${PDFLATEX} $< +@${ECHO} "---- Running PDFLaTeX on $< again" && ${PDFLATEX} $< +-@(${EGREP} -qi 'Rerun to get' $*.log && \ + ${ECHO} "---- Rerunning PDFLaTeX on $* to get cross-refs right" && \ + ${PDFLATEX} $<) || \ + ${ECHO} "---- No cross-refs correcting PDFLaTeX rerun required for $*" +-@(${EGREP} -qi $*.ftoc $*.log && \ + ${ECHO} "---- Rerunning PDFLaTeX on $* for FTOC" && \ + ${PDFLATEX} $<) || \ + ${ECHO} "---- No FTOC PDFLaTeX run required for $*" +-@(${EGREP} -qi 'Warning: Citation' $*.log && \ + ${ECHO} "---- Running BIBTeX on $*" && \ + ${BIBTEX} $* && \ + ${ECHO} "---- Running PDFLaTeX on $<" && \ + ${PDFLATEX} $<) || \ + ${ECHO} "---- No BIBTeX run required for $*" +-@(${EGREP} -qi 'Warning: .+undefined references' $*.log && \ + ${ECHO} "---- Running PDFLaTeX on $<" && \ + ${PDFLATEX} $<) || \ + ${ECHO} "---- No further PDFLaTex run required for $<" +@${ECHO} "Generated: $@ {$<}" >> ${GENFILE} +@${RMRF} ${texcrap} +endef + +# ... canned command to run PDFLaTeX for printable versions +define run-pdflatex-for-print +@${ECHO} "" +@${ECHO} "---- Running PDFLaTeX on $*-print.tex" && ${PDFLATEX} $*-print.tex +@${ECHO} "---- Running PDFLaTeX on $< again" && ${PDFLATEX} $< +-@(${EGREP} -qi 'Warning: Citation' $*-print.log && \ + ${ECHO} "---- Running BIBTeX on $*-print" && \ + ${BIBTEX} $*-print && \ + ${ECHO} "---- Running PDFLaTeX on $*-print.tex" && \ + ${PDFLATEX} $*-print.tex) || \ + ${ECHO} "---- No BIBTeX run required for $*" +-@(${EGREP} -qi 'Warning: .+undefined references' $*-print.log && \ + ${ECHO} "---- Running PDFLaTeX on $*-print" && \ + ${PDFLATEX} $*-print.tex) || \ + ${ECHO} "---- No further PDFLaTex run required for $*-print" +@${ECHO} "Generated: $@ {$<}" >> ${GENFILE} +@${RMRF} ${texcrap} +endef + +# DWA begin modifications +# ... Rule: How to generate TeX from ReST +%.tex: %.txt + @${ECHO} "---- Running rst2latex on $<" + ${RST2LATEX} $< $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} + +# ... Rule: How to generate TeX from ReST +%.tex: %.rst + @${ECHO} "---- Running rst2latex on $<" + ${RST2LATEX} $< $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} + +# ... Rule: How to generate HTML from ReST +%.html: %.txt + @${ECHO} "---- Running rst2html on $<" + ${RST2HTML} $< $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} + +# ... Rule: How to generate HTML from ReST +%.html: %.rst + @${ECHO} "---- Running rst2html on $<" + ${RST2HTML} $< $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} +# DWA end modifications + +# ... Rule: How to generate PDF from TeX +%.pdf: %.tex + $(run-pdflatex) + @${MV} $@ TMP-$@ + @${ECHO} "---- Running PPower4 on $*" + ${PPOWER4} -v TMP-$@ $@ + @${RMRF} TMP-$@ + @${ECHO} "Postprocessed: $*.pdf {$*.pdf}" >> ${GENFILE} + +# ... Rule: How to generate printable PDF from TeX +%-print.pdf: %.tex + ${PERL} -pe 's/^\\documentclass\[(.*?)\]/\\documentclass\[$$1,prints\]/;' < $< > $*-print.tex + $(run-pdflatex-for-print) + @${ECHO} "Generated: $*-print.pdf {$*.pdf}" >> ${GENFILE} + +# ... Rule: How to generate cut foils from TeX master +%---toc.tex: %.tex + ${FOLIAGECUTTER} --prefix=$* $< + +# ... Rule: How to generate MetaPost from FIG +%.mp: %.fig + @${ECHO} "---- Running Fig2Dev (mp) on $<" + ${FIG2DEV} -L mp $< $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} + +# ... Rule: How to generate MultiMetaPost from FIG +%.mmp: %.fig + @${ECHO} "---- Running Fig2Dev (mmp) on $<" + ${FIG2DEV} -L mmp $< $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} + +# ... Rule: How to generate includable PS from FIG via MetaPost +%.mps: %.fig + @${ECHO} "---- Running Fig2Dev (mps) on $<" + ${FIG2DEV} -L mp $< $*.mps.mp + @${RMRF} $*.mps.[0-9] + ${METAPOST} $*.mps.mp + @${MV} $*.mps.0 $@ + @${ECHO} "Generated: $@ {$<}" >> ${GENFILE} + +# ... Rule: How to generate includable PS files from MultiMetaPost +%.0: %.mmp + @${ECHO} "---- Running MetaPost on $<" + @${RMRF} $*.[0-9] $*.[0-9][0-9] + ${METAPOST} $< + @${ECHO} "Generated: $*.0{...} {$<}" >> ${GENFILE} + +cleanup-crap: + @${RMRF} ${mpxcrap} + +# ... Target: all +all: cleanup-crap ${DEPENDFILES} ${PDFFILES} ${PRINTS} ${PRINTZIP} ${SLIDEZIP} + @${ECHO} "" + @${TOUCH} ${GENFILE} + @${CAT} ${GENFILE} + @${RMRF} ${GENFILE} + +# ... Target: ZIP files +zip zips: ${PRINTZIP} ${SLIDEZIP} + +# ... Target: ZIP file containing printable versions of slides +${PRINTZIP}: .depend ${PDFFILES} + @${RMRF} ${PRINTZIP} + ${ZIP} -r ${PRINTZIP} ${PRINTS} + @${ECHO} "Generated: ${PRINTZIP}" >> ${GENFILE} + +# ... Target: ZIP file containing screen versions of slides + ${SLIDEZIP}: .depend ${PDFFILES} + @${RMRF} ${SLIDEZIP} + ${ZIP} -r ${SLIDEZIP} ${PDFFILES} + @${ECHO} "Generated: ${SLIDEZIP}" >> ${GENFILE} + +# ... Target: clean up +clean: + ${RMRF} ${generated} + +# ... Target: create dependencies +depend: .depend + +# ... Target: dependency file (parse TEXFILES for multiinclude and includegraphics) +# .depend: GNUmakefile ${TEXFILES} +# ${RMRF} $@ +# @for t in ${TEXSTEMS} ; do \ +# ${ECHO} "Scanning $$t.tex"; \ +# ${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /\\multiinclude(\[.*?\])?{(.*?)}/ && print "$$target: $$2.0\n";}' $$t.pdf < $$t.tex >> $@; \ +# ${PERL} -e 'my $$target = shift @ARGV;' -e 'while (<>) { /\\includegraphics(\[.*?\])?{(.*?)\.(.*?)}/ && print "$$target: $$2.$$3\n";}' $$t.pdf < $$t.tex >> $@; \ +# done + +.depend: GNUmakefile ${RSTFILES} + ${RMRF} $@ + ${PYTHON} scanrst.py ${RSTFILES} > $@ + +# ... include dependency files +# -include .depend +-include .depend