Try to explain what is going on, simplify
[libresoc-isa-manual.git] / powerpc-add / build / Makefile
index 2354fb3a6fcbd4c7308b7504f72489c4ebb0f0f1..b2040246d8786f456a0fcf71a1d049e051384b2e 100644 (file)
@@ -1,6 +1,6 @@
-#=======================================================================
+# =======================================================================
 # Makefile for generating LaTeX documents
-#-----------------------------------------------------------------------
+# -----------------------------------------------------------------------
 #
 # This is a simple makefile for generating LaTeX documents. It will
 # run bibtex, generate eps from xfig figures, and make pdfs. The
@@ -29,6 +29,8 @@ srcdir    = src
 # Relative to output:
 relsrcdir = ../$(srcdir)
 
+doc_target = power-spec
+
 docs_with_bib = power-spec
 docs_without_bib =
 
@@ -40,8 +42,10 @@ bibs = $(srcdir)/power-spec.bib
 # You shouldn't need to change anything below this
 #=======================================================================
 
+# : needed after ../src/ in TEXINPUTS so that it looks in standard places
 PDFLATEX := TEXINPUTS=$(relsrcdir): pdflatex -interaction=nonstopmode -halt-on-error
 BIBTEX := BIBINPUTS=$(relsrcdir): bibtex
+GLOSSARIES := makeglossaries
 
 default : $(outdir) pdf
 
@@ -50,7 +54,7 @@ default : $(outdir) pdf
 
 pdfs_with_bib = $(addsuffix .pdf, $(docs_with_bib))
 pdfs_without_bib = $(addsuffix .pdf, $(docs_without_bib))
-pdfs = $(pdfs_with_bib) $(pdfs_without_bib)
+pdfs = $(pdfs_with_bib)
 
 Makefile:      build/Makefile
        ln -s $^ .
@@ -64,15 +68,21 @@ $(outdir):
 open: $(pdfs)
        open $(pdfs)
 
+# This is not nice. To generate the glossary you need a .aux file,
+# .aux is generated by pdflatex - which complains as there are undefined names
+# Also if \gls are used in glossary.tex before they are defined - there are
+# similar problems, so makeglossaries needs to be run twice.
 $(pdfs_with_bib): %.pdf: $(srcdir)/%.tex $(srcs) $(figs) $(bibs)
-       cd $(outdir); $(PDFLATEX) $*
-       cd $(outdir); $(BIBTEX) $*
-       cd $(outdir); $(PDFLATEX) $*
-       cd $(outdir); $(PDFLATEX) $*
+       cd $(outdir); $(PDFLATEX) $(doc_target)
+       cd $(outdir); $(BIBTEX) $(doc_target)
+       cd $(outdir); $(GLOSSARIES) $(doc_target)
+       cd $(outdir); $(PDFLATEX) $(doc_target)
+       cd $(outdir); $(GLOSSARIES) $(doc_target)
 
 $(pdfs_without_bib): %.pdf: $(srcdir)/%.tex $(srcs) $(figs)
-       cd $(outdir); $(PDFLATEX) $*
-       cd $(outdir); $(PDFLATEX) $*
+       cd $(outdir); $(PDFLATEX) $* || true
+       cd $(outdir); makeglossaries $* || true
+       cd $(outdir); $(PDFLATEX) $* || true
 
 junk += *.aux *.log *.bbl *.blg *.toc *.out