X-Git-Url: http://git.projectaon.org/?p=project-aon.git;a=blobdiff_plain;f=common%2Fpdf%2Fbuild%2Flw%2FMakefile.common;fp=common%2Fpdf%2Fbuild%2Flw%2FMakefile.common;h=4709e54fc65a8001220e5221093ce3be2a451750;hp=0000000000000000000000000000000000000000;hb=f4bdee5083ca9a72713637e1e979aa183e06faea;hpb=97545603aea8298f1eceb604ff65085cc7adfced diff --git a/common/pdf/build/lw/Makefile.common b/common/pdf/build/lw/Makefile.common new file mode 100644 index 0000000..4709e54 --- /dev/null +++ b/common/pdf/build/lw/Makefile.common @@ -0,0 +1,241 @@ + +# Root directory +AONROOTREL := ../../../../.. +AONROOTDIR = $(realpath $(AONROOTREL)) +INSTALLDIR := ../FINAL/ +# Relative location of the XML files +RELXMLDIR := $(AONROOTDIR)/$(BLANG)/xml/ +XMLFILE=$(patsubst %.tex,$(RELXMLDIR)/%.xml,$(SOURCE)) +# Relative location of the scripts +RELSCRIPT := $(AONROOTDIR)/common/scripts +# Convert Script +XML2LATEX = $(RELSCRIPT)/gbtolatex.pl +# LaTeX stylesheet +LATEXXSL = $(AONROOTDIR)/common/xsl/latex.xsl + +# Define ORIGSERIES unless defined +ORIGSERIES ?= $(SERIES) + +# Define ILLUSTRATOR if not defined with a sane default +ILLUSTRATOR ?= williams + +all: $(BASENAME).pdf + +SOURCE=$(BASENAME).tex +ifeq "$(BLANG)" "en" +EXTRAFILES=souvenir.sty +else +EXTRAFILES=ac1.tex crtneg.tex ac2.tex crtpos.tex random.tex ac3.tex \ + souvenir.sty souverbt.sty +endif + + +# Generate the LaTeX file from the XML file +$(SOURCE): $(XMLFILE) $(XML2LATEX) $(LATEXXSL) tweak.diff + AONPATH="$(AONROOTDIR)" perl $(XML2LATEX) $(BASENAME) $(BLANG) $@ + @if ! test -s $(SOURCE) ; then \ + echo "ERROR: Empty file $(SOURCE), check for errors above." >&2 ; \ + rm -f $(SOURCE) ; \ + exit 1 ; \ + fi + @cp $(SOURCE) $(BASENAME)-untweaked.tex + @if test -f tweak.diff; then \ + patch $(SOURCE) $<; \ + fi + -xelatex -interaction batchmode $< +# # Remove everything except for chapter entries from the toc file + @[ -e "$(BASENAME).toc" ] || { echo "ERROR: Generated file does not include table of contents file, please review $(BASENAME).log" ; false ; } + @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc +# # Run xelatex a second time to get correct page numbers in the toc + -xelatex -interaction batchmode $< +# # Remove everything except for chapter entries from the toc file + @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc +# # Tweak the PDF bookmarks file + @[ -e "$(BASENAME).out" ] || { echo "ERROR: Required file $(BASENAME).out does not exist, please review $(BASENAME).log" ; false ; } + @sed 's/\\ellipsis@one =,//' $(BASENAME).out >temp.out && \ + echo '\let\WriteBookmarks\relax' >>temp.out && \ + mv -f temp.out $(BASENAME).out +# # Run xelatex a third time to get correct PDF bookmarks + -xelatex -interaction batchmode $< +# Restore the original ISO-8859-1 file if we used iconf + @[ -e "$<.lat1" ] && mv $<.lat1 $< + +pdflatex: $(BASENAME).tex $(EXTRAFILES) convert-images +# # Remove old PDF bookmarks file (.out file) + -rm -f $(BASENAME).out +# # Use pdflatex for generation: + -pdflatex -interaction batchmode $< +# # Remove everything except for chapter entries from the toc file + @[ -e "$(BASENAME).toc" ] || { echo "ERROR: Generated file does not include table of contents file, please review $(BASENAME).log" ; false ; } + @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc +# # Run pdflatex a second time to get correct page numbers in the toc + -pdflatex -interaction batchmode $< +# # Remove everything except for chapter entries from the toc file + @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc +# # Tweak the PDF bookmarks file + @[ -e "$(BASENAME).out" ] || { echo "ERROR: Required file $(BASENAME).out does not exist, please review $(BASENAME).log" ; false ; } + @sed 's/\\ellipsis@one =,//' $(BASENAME).out >temp.out && \ + echo '\let\WriteBookmarks\relax' >>temp.out && \ + mv -f temp.out $(BASENAME).out +# # Run pdflatex a third time to get correct PDF bookmarks + -pdflatex -interaction batchmode $< + +clean: clean-images + -rm -f $(BASENAME).pdf $(BASENAME).ps + -rm -f *.aux *.toc *.log *.lof *.dvi *.ps *.bbl *.blg *.lot *.out + +distclean: clean + -rm -f $(BASENAME).tex $(BASENAME)-untweaked.tex $(BASENAME).tex.orig $(BASENAME).tex.lat1 +# Clean symlinks + -rm -f ac1.tex ac2.tex ac3.tex crtneg.tex crtpos.tex random.tex souvenir.sty souverbt.sty + @for gif in *.gif ; do [ -e $$gif ] && [ -L $$gif ] && rm -f $$gif ; done || true +# Remove tweak file if empty + @test -s tweak.diff || rm -f tweak.diff + +# Clean all images +clean-images: + -rm -f *.png *.jpeg *.jpg *.pdf + -rm -f convert-images link-images + +# Update tweak.diff with the current difference between untweaked and tweaked tex file +update-tweakfile: + @if [ -e $(BASENAME)-untweaked.tex -a -e $(BASENAME).tex ] ; then \ + if ! diff -q $(BASENAME)-untweaked.tex $(BASENAME).tex; then \ + diff -u $(BASENAME)-untweaked.tex $(BASENAME).tex >tweak.diff || echo Updated tweak.diff; \ + else \ + echo "Tweak file not updated, no changes"; \ + fi; \ + else \ + echo "Tweak file not updated, missing files"; \ + fi + +