b2040246d8786f456a0fcf71a1d049e051384b2e
[libresoc-isa-manual.git] / powerpc-add / build / Makefile
1 # =======================================================================
2 # Makefile for generating LaTeX documents
3 # -----------------------------------------------------------------------
4 #
5 # This is a simple makefile for generating LaTeX documents. It will
6 # run bibtex, generate eps from xfig figures, and make pdfs. The
7 # makefile supports builds in non-source directories: just make a
8 # build directory, copy the makefile there, and change the srcdir
9 # variable accordingly.
10 #
11 # Note that the makefile assumes that the default dvips/ps2pdfwr
12 # commands "do the right thing" for fonts in pdfs. This is true on
13 # Athena/Linux and Fedora Core but is not true for older redhat installs ...
14 #
15 # At a minimum you should just change the main variable to be
16 # the basename of your toplevel tex file. If you use a bibliography
17 # then you should set the bibfile variable to be the name of your
18 # .bib file (assumed to be in the source directory).
19 #
20
21 # Targets:
22 # (none) makes PDFs in output/
23 # clean removed everything except PDFs in output/
24 # clean-all removed everything in output/
25
26 # Directories relative to the top level:
27 outdir = output
28 srcdir = src
29 # Relative to output:
30 relsrcdir = ../$(srcdir)
31
32 doc_target = power-spec
33
34 docs_with_bib = power-spec
35 docs_without_bib =
36
37 srcs = $(wildcard $(srcdir)/*.tex)
38 figs = $(wildcard $(srcdir)/figs/*)
39 bibs = $(srcdir)/power-spec.bib
40
41 #=======================================================================
42 # You shouldn't need to change anything below this
43 #=======================================================================
44
45 # : needed after ../src/ in TEXINPUTS so that it looks in standard places
46 PDFLATEX := TEXINPUTS=$(relsrcdir): pdflatex -interaction=nonstopmode -halt-on-error
47 BIBTEX := BIBINPUTS=$(relsrcdir): bibtex
48 GLOSSARIES := makeglossaries
49
50 default : $(outdir) pdf
51
52 #------------------------------------------------------------
53 # PDF
54
55 pdfs_with_bib = $(addsuffix .pdf, $(docs_with_bib))
56 pdfs_without_bib = $(addsuffix .pdf, $(docs_without_bib))
57 pdfs = $(pdfs_with_bib)
58
59 Makefile: build/Makefile
60 ln -s $^ .
61
62 pdf : $(pdfs) Makefile
63 .PHONY: pdf open
64
65 $(outdir):
66 mkdir $@
67
68 open: $(pdfs)
69 open $(pdfs)
70
71 # This is not nice. To generate the glossary you need a .aux file,
72 # .aux is generated by pdflatex - which complains as there are undefined names
73 # Also if \gls are used in glossary.tex before they are defined - there are
74 # similar problems, so makeglossaries needs to be run twice.
75 $(pdfs_with_bib): %.pdf: $(srcdir)/%.tex $(srcs) $(figs) $(bibs)
76 cd $(outdir); $(PDFLATEX) $(doc_target)
77 cd $(outdir); $(BIBTEX) $(doc_target)
78 cd $(outdir); $(GLOSSARIES) $(doc_target)
79 cd $(outdir); $(PDFLATEX) $(doc_target)
80 cd $(outdir); $(GLOSSARIES) $(doc_target)
81
82 $(pdfs_without_bib): %.pdf: $(srcdir)/%.tex $(srcs) $(figs)
83 cd $(outdir); $(PDFLATEX) $* || true
84 cd $(outdir); makeglossaries $* || true
85 cd $(outdir); $(PDFLATEX) $* || true
86
87 junk += *.aux *.log *.bbl *.blg *.toc *.out
88
89 #------------------------------------------------------------
90 # Other Targets
91
92 clean :
93 rm -rf $(addprefix $(outdir)/, $(junk))
94
95 clean-all: clean
96 rm -rf $(addprefix $(outdir)/, $(pdfs))