3 AONROOTREL := ../../../../..
4 AONROOTDIR = $(realpath $(AONROOTREL))
5 INSTALLDIR := ../FINAL/
6 # Relative location of the XML files
7 RELXMLDIR := $(AONROOTDIR)/$(LANG)/xml/
8 XMLFILE=$(patsubst %.tex,$(RELXMLDIR)/%.xml,$(SOURCE))
9 # Relative location of the scripts
10 RELSCRIPT := $(AONROOTDIR)/common/scripts
12 XML2LATEX = $(RELSCRIPT)/gbtolatex.pl
14 LATEXXSL = $(AONROOTDIR)/common/xsl/latex.xsl
15 #LATEXXSL = $(AONROOTDIR)/common/xsl/latex-komascript.xsl
19 SOURCE=$(BASENAME).tex
21 EXTRAFILES=souvenir.sty
23 EXTRAFILES=ac1.tex crtneg.tex ac2.tex crtpos.tex random.tex ac3.tex \
24 souvenir.sty souverbt.sty
28 # Generate the LaTeX file from the XML file
29 $(SOURCE): $(XMLFILE) $(XML2LATEX) $(LATEXXSL) tweak.diff
30 AONPATH="$(AONROOTDIR)" perl $(XML2LATEX) $(BASENAME) $(LANG) $@
31 @if ! test -s $(SOURCE) ; then \
32 echo "ERROR: Empty file $(SOURCE), check for errors above." >&2 ; \
36 @cp $(SOURCE) $(BASENAME)-untweaked.tex
37 @if test -f tweak.diff; then \
38 patch $(SOURCE) <tweak.diff ; \
41 # Extra TeX files needed for the PDFs
43 # This is for english content:
55 # This is for other translated content:
57 ln -s ../../shared/$(LANG)/$@
59 ln -s ../../shared/$(LANG)/$@
61 ln -s ../../shared/$(LANG)/$@
63 ln -s ../../shared/$(LANG)/$@
65 ln -s ../../shared/$(LANG)/$@
67 # Shared across all languages
74 # Create empty tweak.diff if it does not exist
78 # Symlink the images needed for the PDF; unused images and HTML-specific images are ignored
80 @[ -n "$(SERIES)" ] || { echo "Error: SERIES variable not defined. Hint: Review the Makefile"; exit 1; }
81 @[ -n "$(SUBSERIES)" ] || { echo "Error: SUBSERIES variable not defined. Hint: Review the Makefile"; exit 1; }
82 @[ -n "$(BASENAME)" ] || { echo "Error: BASENAME variable not defined. Hint: Review the Makefile"; exit 1; }
83 @echo "Linking images for the book to working directory"
85 @for images in jpeg png ; do \
86 [ ! -d "$(AONROOTREL)/en/$$images/$(SERIES)/$(BASENAME)/" ] || find $(AONROOTREL)/en/$$images/$(SERIES)/$(BASENAME)/ \( -name "*.jpg" -o -name "*.png" \) | \
87 while read file ; do \
88 [ -e "`basename $$file`" ] || \
89 case "`basename $$file`" in \
90 back*|bckgrnd*|brdr*|forward*|left*|right*|title*|toc*) ;; \
91 ac*|crt*|random*) ;; \
92 *) ln -s $$file . ;; \
96 @[ ! -d "$(AONROOTREL)/en/pdf/$(SERIES)/$(SUBSERIES)" ] || find $(AONROOTREL)/en/pdf/$(SERIES)/$(SUBSERIES)/ -name "*.pdf" | \
97 while read file ; do \
98 [ -e "`basename $$file`" ] || ln -s $$file . ; \
101 @[ -n "$(ORIGSERIES)" ] || { echo "Error: ORIGSERIES variable not defined. Hint: Review the Makefile"; exit 1; }
102 @[ -n "$(ORIGBASENAME)" ] || { echo "Error: ORIGBASENAME variable not defined. Hint: Review the Makefile"; exit 1; }
103 @for images in jpeg png ; do \
104 [ ! -d "$(AONROOTREL)/$(LANG)/$$images/$(SERIES)/$(BASENAME)/" ] || find $(AONROOTREL)/$(LANG)/$$images/$(SERIES)/$(BASENAME)/ \( -name "*.jpg" -o -name "*.png" \) | \
105 while read file ; do \
106 [ -e "`basename $$file`" ] || ln -s $$file . ; \
108 [ ! -d "$(AONROOTREL)/en/$$images/$(ORIGSERIES)/$(ORIGBASENAME)/" ] || find $(AONROOTREL)/en/$$images/$(ORIGSERIES)/$(ORIGBASENAME)/ \( -name "*.jpg" -o -name "*.png" \) | \
109 while read file ; do \
110 rootname=`basename $$file | sed -e 's/\..*//'`; \
111 [ -e "$$rootname.jpg" ] || [ -e "$$rootname.png" ] || ln -s $$file . ; \
114 @[ ! -d "$(AONROOTREL)/$(LANG)/pdf/$(SERIES)/$(SUBSERIES)" ] || find $(AONROOTREL)/$(LANG)/pdf/$(SERIES)/$(SUBSERIES)/ -name "*.pdf" | \
115 while read file ; do \
116 [ -e "`basename $$file`" ] || ln -s $$file . ; \
118 @[ ! -d "$(AONROOTREL)/en/pdf/$(ORIGSERIES)/$(SUBSERIES)" ] || find $(AONROOTREL)/en/pdf/$(ORIGSERIES)/$(SUBSERIES)/ -name "*.pdf" | \
119 while read file ; do \
120 [ -e "`basename $$file`" ] || ln -s $$file . ; \
125 # Convert them using the appropiate script
126 convert-images: link-images
127 @echo "Converting images to PDF format"
128 @sh ../../convert-images.sh
132 install: $(INSTALLDIR) all
133 @echo "Copying $(BASENAME).pdf to $(INSTALLDIR)"
134 @cp $(BASENAME).pdf $(INSTALLDIR)
141 %.dvi: %.tex $(EXTRAFILES)
143 latex -interaction batch $<
144 # Regenerate Contents
154 %.pdf: %.tex $(EXTRAFILES) convert-images
155 # # Remove old PDF bookmarks file (.out file)
156 -rm -f $(BASENAME).out
157 # # Use pdflatex for generation:
158 -pdflatex -interaction batchmode $<
159 # # Remove everything except for chapter entries from the toc file
160 @[ -e "$(BASENAME).toc" ] || { echo "ERROR: Generated file does not include table of contents file, please review $(BASENAME).log" ; false ; }
161 @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc
162 # # Run pdflatex a second time to get correct page numbers in the toc
163 -pdflatex -interaction batchmode $<
164 # # Remove everything except for chapter entries from the toc file
165 @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc
166 # # Tweak the PDF bookmarks file
167 @[ -e "$(BASENAME).out" ] || { echo "ERROR: Required file $(BASENAME).out does not exist, please review $(BASENAME).log" ; false ; }
168 @sed 's/\\ellipsis@one =,//' $(BASENAME).out >temp.out && \
169 echo '\let\WriteBookmarks\relax' >>temp.out && \
170 mv -f temp.out $(BASENAME).out
171 # # Run pdflatex a third time to get correct PDF bookmarks
172 -pdflatex -interaction batchmode $<
173 # # Check if the PDF file exists
174 @[ -e "$(BASENAME).pdf" ] || { echo "ERROR: Did not generate $(BASENAME).pdf , please review $(BASENAME).log" ; false ; }
177 -rm -f $(BASENAME).pdf $(BASENAME).ps
178 -rm -f *.aux *.toc *.log *.lof *.dvi *.ps *.bbl *.blg *.lot *.out
181 -rm -f $(BASENAME).tex $(BASENAME)-untweaked.tex
183 -rm -f ac1.tex ac2.tex ac3.tex crtneg.tex crtpos.tex random.tex souvenir.sty souverbt.sty
184 @for gif in *.gif ; do [ -e $$gif ] && [ -L $$gif ] && rm -f $$gif ; done || true
185 # Remove tweak file if empty
186 @test -z tweak.diff || rm -f tweak.diff
190 -rm -f *.png *.jpeg *.jpg *.pdf
191 -rm -f convert-images link-images
193 # Update tweak.diff with the current difference between untweaked and tweaked tex file
195 @if [ -e $(BASENAME)-untweaked.tex -a -e $(BASENAME).tex ] ; then \
196 if ! diff -q $(BASENAME)-untweaked.tex $(BASENAME).tex; then \
197 diff -u $(BASENAME)-untweaked.tex $(BASENAME).tex >tweak.diff || echo Updated tweak.diff; \
199 echo "Tweak file not updated, no changes"; \
202 echo "Tweak file not updated, missing files"; \