3 AONROOTREL := ../../../../..
4 AONROOTDIR = $(realpath $(AONROOTREL))
5 INSTALLDIR := ../FINAL/
6 # Relative location of the XML files
7 RELXMLDIR := $(AONROOTDIR)/$(BLANG)/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
16 # Define ORIGSERIES unless defined
17 ORIGSERIES ?= $(SERIES)
19 # Define ILLUSTRATOR if not defined with a sane default
20 ILLUSTRATOR ?= williams
24 SOURCE=$(BASENAME).tex
26 EXTRAFILES=souvenir.sty
28 EXTRAFILES=ac1.tex crtneg.tex ac2.tex crtpos.tex random.tex ac3.tex \
29 souvenir.sty souverbt.sty
33 # Generate the LaTeX file from the XML file
34 $(SOURCE): $(XMLFILE) $(XML2LATEX) $(LATEXXSL) tweak.diff
35 AONPATH="$(AONROOTDIR)" perl $(XML2LATEX) $(BASENAME) $(BLANG) $@
36 @if ! test -s $(SOURCE) ; then \
37 echo "ERROR: Empty file $(SOURCE), check for errors above." >&2 ; \
41 @cp $(SOURCE) $(BASENAME)-untweaked.tex
42 @if test -f tweak.diff; then \
43 patch $(SOURCE) <tweak.diff ; \
46 # Extra TeX files needed for the PDFs
48 # This is for english content:
60 # This is for other translated content:
62 ln -s ../../shared/$(BLANG)/$@
64 ln -s ../../shared/$(BLANG)/$@
66 ln -s ../../shared/$(BLANG)/$@
68 ln -s ../../shared/$(BLANG)/$@
70 ln -s ../../shared/$(BLANG)/$@
72 # Shared across all languages
79 # Create empty tweak.diff if it does not exist
83 # Symlink the images needed for the PDF; unused images and HTML-specific images are ignored
85 @[ -n "$(SERIES)" ] || { echo "Error: SERIES variable not defined. Hint: Review the Makefile"; exit 1; }
86 @[ -n "$(SUBSERIES)" ] || { echo "Error: SUBSERIES variable not defined. Hint: Review the Makefile"; exit 1; }
87 @[ -n "$(BASENAME)" ] || { echo "Error: BASENAME variable not defined. Hint: Review the Makefile"; exit 1; }
88 @echo "Linking images for the book to working directory"
89 @[ -n "$(ILLUSTRATOR)" ] || { echo "Warning: ILLUSTRATOR variable not defined. Some illustrations might be missing. Hint: Review the Makefile"; }
90 @[ ! -n "$(ILLUSTRATOR)" ] || [ -d "$(AONROOTREL)/common/pdf/$(ORIGSERIES)/common/ill/$(ILLUSTRATOR)" ] || \
91 { echo "Warning: Folder $(AONROOTREL)/common/pdf/$(ORIGSERIES)/common/ill/$(ILLUSTRATOR) not found. Some illustrations might be missing."; }
92 @[ ! -n "$(ILLUSTRATOR)" ] || [ ! -d "$(AONROOTREL)/common/pdf/$(ORIGSERIES)/common/ill/$(ILLUSTRATOR)" ] || \
93 find $(AONROOTREL)/common/pdf/$(ORIGSERIES)/common/ill/$(ILLUSTRATOR)/ -name "*.pdf" | \
94 while read file ; do \
95 [ -e "`basename $$file`" ] || ln -s $$file . ; \
98 @for images in jpeg png ; do \
99 [ ! -d "$(AONROOTREL)/en/$$images/$(SERIES)/$(BASENAME)/" ] || find $(AONROOTREL)/en/$$images/$(SERIES)/$(BASENAME)/ \( -name "*.jpg" -o -name "*.png" \) | \
100 while read file ; do \
101 [ -e "`basename $$file`" ] || \
102 case "`basename $$file`" in \
103 back*|bckgrnd*|brdr*|forward*|left*|right*|title*|toc*) ;; \
104 ac*|crt*|random*) ;; \
105 *) ln -s $$file . ;; \
109 @[ ! -d "$(AONROOTREL)/en/pdf/$(SERIES)/$(SUBSERIES)" ] || find $(AONROOTREL)/en/pdf/$(SERIES)/$(SUBSERIES)/ -name "*.pdf" | \
110 while read file ; do \
111 [ -e "`basename $$file`" ] || ln -s $$file . ; \
114 @[ -n "$(ORIGSERIES)" ] || { echo "Error: ORIGSERIES variable not defined. Hint: Review the Makefile"; exit 1; }
115 @[ -n "$(ORIGBASENAME)" ] || { echo "Error: ORIGBASENAME variable not defined. Hint: Review the Makefile"; exit 1; }
116 @for images in jpeg png ; do \
117 [ ! -d "$(AONROOTREL)/$(BLANG)/$$images/$(SERIES)/$(BASENAME)/" ] || find $(AONROOTREL)/$(BLANG)/$$images/$(SERIES)/$(BASENAME)/ \( -name "*.jpg" -o -name "*.png" \) | \
118 while read file ; do \
119 [ -e "`basename $$file`" ] || ln -s $$file . ; \
121 [ ! -d "$(AONROOTREL)/en/$$images/$(ORIGSERIES)/$(ORIGBASENAME)/" ] || find $(AONROOTREL)/en/$$images/$(ORIGSERIES)/$(ORIGBASENAME)/ \( -name "*.jpg" -o -name "*.png" \) | \
122 while read file ; do \
123 rootname=`basename $$file | sed -e 's/\..*//'`; \
124 [ -e "$$rootname.jpg" ] || [ -e "$$rootname.png" ] || ln -s $$file . ; \
127 @[ ! -d "$(AONROOTREL)/$(BLANG)/pdf/$(SERIES)/$(SUBSERIES)" ] || find $(AONROOTREL)/$(BLANG)/pdf/$(SERIES)/$(SUBSERIES)/ -name "*.pdf" | \
128 while read file ; do \
129 [ -e "`basename $$file`" ] || ln -s $$file . ; \
131 @[ ! -d "$(AONROOTREL)/en/pdf/$(ORIGSERIES)/$(SUBSERIES)" ] || find $(AONROOTREL)/en/pdf/$(ORIGSERIES)/$(SUBSERIES)/ -name "*.pdf" | \
132 while read file ; do \
133 [ -e "`basename $$file`" ] || ln -s $$file . ; \
138 # Convert them using the appropiate script
139 convert-images: link-images
140 @echo "Converting images to PDF format"
141 @sh ../../convert-images.sh
145 install: $(INSTALLDIR) all
146 @echo "Copying $(BASENAME).pdf to $(INSTALLDIR)"
147 @cp $(BASENAME).pdf $(INSTALLDIR)
154 %.dvi: %.tex $(EXTRAFILES)
156 latex -interaction batch $<
157 # Regenerate Contents
167 %.pdf: %.tex $(EXTRAFILES) convert-images
168 # Convert to UTF-8 if required
169 @if file $< | grep -q ISO-8859 ; then \
170 echo "WARNING: $< is encoded in ISO-8859-1, converting to UTF-8" ; \
172 iconv -f latin1 -t utf-8 < $<.lat1 >$<; \
174 -xelatex -interaction batchmode $<
175 # # Remove everything except for chapter entries from the toc file
176 @[ -e "$(BASENAME).toc" ] || { echo "ERROR: Generated file does not include table of contents file, please review $(BASENAME).log" ; false ; }
177 @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc
178 # # Run xelatex a second time to get correct page numbers in the toc
179 -xelatex -interaction batchmode $<
180 # # Remove everything except for chapter entries from the toc file
181 @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc
182 # # Tweak the PDF bookmarks file
183 @[ -e "$(BASENAME).out" ] || { echo "ERROR: Required file $(BASENAME).out does not exist, please review $(BASENAME).log" ; false ; }
184 @sed 's/\\ellipsis@one =,//' $(BASENAME).out >temp.out && \
185 echo '\let\WriteBookmarks\relax' >>temp.out && \
186 mv -f temp.out $(BASENAME).out
187 # # Run xelatex a third time to get correct PDF bookmarks
188 -xelatex -interaction batchmode $<
189 # Restore the original ISO-8859-1 file if we used iconf
190 @[ -e "$<.lat1" ] && mv $<.lat1 $<
192 pdflatex: $(BASENAME).tex $(EXTRAFILES) convert-images
193 # # Remove old PDF bookmarks file (.out file)
194 -rm -f $(BASENAME).out
195 # # Use pdflatex for generation:
196 -pdflatex -interaction batchmode $<
197 # # Remove everything except for chapter entries from the toc file
198 @[ -e "$(BASENAME).toc" ] || { echo "ERROR: Generated file does not include table of contents file, please review $(BASENAME).log" ; false ; }
199 @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc
200 # # Run pdflatex a second time to get correct page numbers in the toc
201 -pdflatex -interaction batchmode $<
202 # # Remove everything except for chapter entries from the toc file
203 @grep '{chapter}' $(BASENAME).toc >temp.toc && mv -f temp.toc $(BASENAME).toc
204 # # Tweak the PDF bookmarks file
205 @[ -e "$(BASENAME).out" ] || { echo "ERROR: Required file $(BASENAME).out does not exist, please review $(BASENAME).log" ; false ; }
206 @sed 's/\\ellipsis@one =,//' $(BASENAME).out >temp.out && \
207 echo '\let\WriteBookmarks\relax' >>temp.out && \
208 mv -f temp.out $(BASENAME).out
209 # # Run pdflatex a third time to get correct PDF bookmarks
210 -pdflatex -interaction batchmode $<
213 -rm -f $(BASENAME).pdf $(BASENAME).ps
214 -rm -f *.aux *.toc *.log *.lof *.dvi *.ps *.bbl *.blg *.lot *.out
217 -rm -f $(BASENAME).tex $(BASENAME)-untweaked.tex $(BASENAME).tex.orig $(BASENAME).tex.lat1 $(BASENAME).tex.rej
219 -rm -f ac1.tex ac2.tex ac3.tex crtneg.tex crtpos.tex random.tex souvenir.sty souverbt.sty
220 @for gif in *.gif ; do [ -e $$gif ] && [ -L $$gif ] && rm -f $$gif ; done || true
221 # Remove tweak file if empty
222 @test -s tweak.diff || rm -f tweak.diff
226 -rm -f *.png *.jpeg *.jpg *.pdf
227 -rm -f convert-images link-images
229 # Update tweak.diff with the current difference between untweaked and tweaked tex file
231 @if [ -e $(BASENAME)-untweaked.tex -a -e $(BASENAME).tex ] ; then \
232 if ! diff -q $(BASENAME)-untweaked.tex $(BASENAME).tex; then \
233 diff -u $(BASENAME)-untweaked.tex $(BASENAME).tex >tweak.diff || echo Updated tweak.diff; \
235 echo "Tweak file not updated, no changes"; \
238 echo "Tweak file not updated, missing files"; \