| 1 | # Makefile for pdflatex documents |
|---|
| 2 | # Author: Christian Stueble <stueble@acm.org> |
|---|
| 3 | # Version: $Id: Makefile,v 1.12 2002/06/28 12:47:21 steiner Exp $ |
|---|
| 4 | # |
|---|
| 5 | PRIMTARGET = tpmmanager |
|---|
| 6 | |
|---|
| 7 | # Path to templates of Sirrix AG. I suggest to set an absolut path using an |
|---|
| 8 | # environment variable using 'export SIRRIXTEMPLATES=...'. |
|---|
| 9 | ifndef SIRRIXTEMPLATES |
|---|
| 10 | SIRRIXTEMPLATES = /home/anoosheh/projects/templates/templates |
|---|
| 11 | endif |
|---|
| 12 | |
|---|
| 13 | # site specific variables |
|---|
| 14 | PDFLATEX=pdflatex |
|---|
| 15 | BIBTEX=bibtex -min-crossrefs=5 |
|---|
| 16 | MAKEINDEX=makeindex -s ${SIRRIXTEMPLATES}/latex/styles/ignoreat.ist |
|---|
| 17 | MAKEGLOSSARY=makeglos.pl |
|---|
| 18 | # we need xfig/transfig >= 3.2.3c to prevent bug with psfrag |
|---|
| 19 | RM=rm -f |
|---|
| 20 | CP=cp -f |
|---|
| 21 | ED=ed |
|---|
| 22 | DIFF=diff |
|---|
| 23 | ENV=env |
|---|
| 24 | TOUCH=touch |
|---|
| 25 | DIRSEP=/ |
|---|
| 26 | PATHSEP=: |
|---|
| 27 | ifdef PWD |
|---|
| 28 | # note that we put already here the DIRSEP so we later don't have to add it .. |
|---|
| 29 | TOPDIR=${PWD}${DIRSEP} |
|---|
| 30 | else |
|---|
| 31 | # .. and can tolerate a relative path if PWD doesn't exist |
|---|
| 32 | TOPDIR= |
|---|
| 33 | endif |
|---|
| 34 | |
|---|
| 35 | ## Local configuration file 'make.loc' |
|---|
| 36 | ## |
|---|
| 37 | ## Either the Makefile in the package or the optional make.loc file can redefine above |
|---|
| 38 | ## you might also like define TEXINPUTS there ... |
|---|
| 39 | ## |
|---|
| 40 | ## Windows users |
|---|
| 41 | ## In particular Windows users probably will have to define 'PATHSEP=\;' and 'VIEWDVI=yap'. |
|---|
| 42 | ## (for MiKTeX. it also seems that the MiKTeX's 'bibtex' doesn't understand 'BIBINPUTS'; |
|---|
| 43 | ## you might have to edit your tex .ini file and add the directory ....\bibtex to your path ... |
|---|
| 44 | ## you might have to define TOPDIR |
|---|
| 45 | -include make.loc |
|---|
| 46 | |
|---|
| 47 | # You shouldn't need to change anything below this. |
|---|
| 48 | # If you did, the change probably needs to be reflected in all such files. |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | # various standard definitions |
|---|
| 52 | #------------------------------ |
|---|
| 53 | # various directories |
|---|
| 54 | SRCDIR = ${TOPDIR}src |
|---|
| 55 | STYLEDIR = ${TOPDIR}styles |
|---|
| 56 | BIBDIR = ${TOPDIR}bibtex |
|---|
| 57 | FONTDIR = ${TOPDIR}fonts |
|---|
| 58 | IMAGEDIR = ${TOPDIR}images |
|---|
| 59 | |
|---|
| 60 | # fix latex and bibtex invocation to match the paths ... |
|---|
| 61 | TEXINPUTS := .$(PATHSEP)$(SRCDIR)$(PATHSEP)$(STYLEDIR)$(PATHSEP)$(IMAGEDIR)$(PATHSEP)$(BIBDIR)$(PATHSEP)$(PATHSEP)$(TEXINPUTS)$(PATHSEP)$(SIRRIXTEMPLATES)//$(PATHSEP) |
|---|
| 62 | MFINPUTS := $(FONTDIR)$(DIRSEP)$(DIRSEP)$(PATHSEP)$(MFINPUTS) |
|---|
| 63 | PDFLATEX := $(ENV) MFINPUTS=$(MFINPUTS) TEXINPUTS=$(TEXINPUTS) $(PDFLATEX) |
|---|
| 64 | |
|---|
| 65 | GLOSSBIBTEX :=$(ENV) BSTINPUTS=$(GLOSSBSTINPUTS) BIBINPUTS=$(GLOSSBIBINPUTS) $(BIBTEX) |
|---|
| 66 | |
|---|
| 67 | BIBINPUTS:=$(BIBDIR)$(PATHSEP)$(BIBINPUTS)$(PATHSEP)$(SIRRIXTEMPLATES)/latex/bibtex |
|---|
| 68 | BSTINPUTS:=$(BIBDIR)$(PATHSEP)$(BSTINPUTS) |
|---|
| 69 | BIBTEX :=$(ENV) BIBINPUTS=$(BIBINPUTS) BSTINPUTS=$(BSTINPUTS) $(BIBTEX) |
|---|
| 70 | # all modified environments |
|---|
| 71 | NEWENVDEF = \ |
|---|
| 72 | BSTINPUTS=$(GLOSSBSTINPUTS)\ |
|---|
| 73 | BIBINPUTS=$(GLOSSBIBINPUTS)$(PATHSEP)$(BIBINPUTS)\ |
|---|
| 74 | MFINPUTS=$(MFINPUTS) TEXINPUTS=$(TEXINPUTS) |
|---|
| 75 | |
|---|
| 76 | # the prime source/target |
|---|
| 77 | ifdef PRIMSOURCE |
|---|
| 78 | # PRIMTARGET is in the default case defined but maybe somebody might have a non-standard |
|---|
| 79 | # locations for PRIMSOURCE and has defined PRIMSOURCE instead of PRIMTARGET |
|---|
| 80 | PRIMTARGET= $(notdir $(PRIMSOURCE:%.tex=%)) |
|---|
| 81 | endif |
|---|
| 82 | ifndef PRIMSOURCE |
|---|
| 83 | # somebody might have defined it for non-standard locations of PRIMSOURCE |
|---|
| 84 | PRIMSOURCE = $(SRCDIR)$(DIRSEP)$(PRIMTARGET).tex |
|---|
| 85 | endif |
|---|
| 86 | |
|---|
| 87 | # common sources |
|---|
| 88 | STYLESOURCES= $(wildcard $(STYLEDIR)$(DIRSEP)*.sty) |
|---|
| 89 | TEXSOURCES = $(wildcard $(SRCDIR)$(DIRSEP)*.tex) |
|---|
| 90 | BIBSOURCES = $(wildcard $(BIBDIR)$(DIRSEP)*.bib) |
|---|
| 91 | |
|---|
| 92 | # common targets based on primtarget |
|---|
| 93 | PDFTARGET = $(PRIMTARGET).pdf |
|---|
| 94 | BIBTARGET = $(PRIMTARGET).bbl |
|---|
| 95 | INDEXTARGET = $(PRIMTARGET).ind |
|---|
| 96 | GLOSSARYTARGET = $(PRIMTARGET).gls |
|---|
| 97 | ACRONYMTARGET = $(PRIMTARGET).acn |
|---|
| 98 | |
|---|
| 99 | # fixpoint temp-file |
|---|
| 100 | PRIMFIXPOINT= $(PRIMTARGET).fpt |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | # the 'exported' target-rules |
|---|
| 104 | # ------------------------------------- |
|---|
| 105 | # Our primary goal is to make the final DVI file |
|---|
| 106 | all:: $(PDFTARGET) |
|---|
| 107 | |
|---|
| 108 | # clean up temp file |
|---|
| 109 | clean:: |
|---|
| 110 | $(RM) *.aux *.toc *.lof *.lot *.blg *.bbl *.cb *.idx *.ilg *.ind *.ent \ |
|---|
| 111 | *.dvi *~ *.log err *.fpt head.tmp body.tmp *.out *.brf *.glo *.gls \ |
|---|
| 112 | *.ist *.glg *.acr *.alg *.acn $(PRIMTARGET).pdf |
|---|
| 113 | |
|---|
| 114 | # clean up also "final" generated files |
|---|
| 115 | veryclean:: clean |
|---|
| 116 | $(RM) $(PDFTARGET) |
|---|
| 117 | |
|---|
| 118 | # clean up all generatable files, regardless of target |
|---|
| 119 | distclean:: veryclean |
|---|
| 120 | $(RM) *.ps *.dvi feymr10.* |
|---|
| 121 | |
|---|
| 122 | # the 'hidden' rules |
|---|
| 123 | # ------------------------------------- |
|---|
| 124 | |
|---|
| 125 | # BIBTEX specific targets |
|---|
| 126 | # biboutput depends on the bib-sources as well as the tex-files |
|---|
| 127 | # as this target is after the main dvi target latex should have been run already once so |
|---|
| 128 | # aux file should exist (unfortunatly we cannot make a target on .aux or otherwise we will |
|---|
| 129 | # never consider everything done |
|---|
| 130 | # Ideally bibtex should only be run if texsources changed bib-references. But this seems |
|---|
| 131 | # rather involved to figure out (e.g. diff of aux-files before/after and grep for |
|---|
| 132 | # 'citation|bibcite|bibdata|bibstyle' ...) |
|---|
| 133 | $(BIBTARGET):: $(BIBSOURCES) $(TEXSOURCES) |
|---|
| 134 | $(BIBTEX) $(PRIMTARGET) || ( $(RM) $@; $(RM) $(PRIMFIXPOINT); exit -1) |
|---|
| 135 | $(RM) $(PRIMFIXPOINT) # we have to start 'fixpoint calculation' from scratch |
|---|
| 136 | |
|---|
| 137 | # if you just would like to run bibtex once (e.g for debugging) |
|---|
| 138 | Bibtex: |
|---|
| 139 | $(BIBTEX) $(PRIMTARGET) |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | # INDEX specific target |
|---|
| 143 | # index depends only texsource (again the usual thing about not being able to target *.idx) |
|---|
| 144 | # Ideally makeindex should only be run only if texsources changed index related stuff. |
|---|
| 145 | # But this seems rather involved to figure out (e.g. diff of $(PRIMTARGET).idx file) |
|---|
| 146 | Makeindex: |
|---|
| 147 | # fix some index problems |
|---|
| 148 | # ed/vi replace expressions are |
|---|
| 149 | # - '1,$s/\(see{.*\)!/\1, /g' # newabbrev (see thesis-common.sty for more information) |
|---|
| 150 | # - '1,$s/\([^"]\)\("0[0-9]*\)/\1"\2/g' # Math accent signs |
|---|
| 151 | # - '1,$s/\([^"]\)\(!}\)\)/\1"\2/g' # some !'s |
|---|
| 152 | -echo -e '1,$$s/\(see{.*\)!/\\1, /g\n1,$$s/\([^"]\)\("0[0-9]*\)/\\1"\\2/g\n1,$$s/\([^"]\)\(!}\)/\\1"\\2/g\nw\nq' | $(ED) $(PRIMTARGET).idx |
|---|
| 153 | $(MAKEINDEX) $(PRIMTARGET) |
|---|
| 154 | |
|---|
| 155 | $(INDEXTARGET):: $(TEXSOURCES) |
|---|
| 156 | # fix some index problems (see above) |
|---|
| 157 | -echo -e '1,$$s/\(see{.*\)!/\\1, /g\n1,$$s/\([^"]\)\("0[0-9]*\)/\\1"\\2/g\n1,$$s/\([^"]\)\(!}\)/\\1"\\2/g\nw\nq' | $(ED) $(PRIMTARGET).idx |
|---|
| 158 | $(MAKEINDEX) $(PRIMTARGET) |
|---|
| 159 | $(RM) $(PRIMFIXPOINT) # we have to start 'fixpoint calculation' from scratch |
|---|
| 160 | |
|---|
| 161 | $(GLOSSARYTARGET):: $(TEXSOURCES) |
|---|
| 162 | $(MAKEGLOSSARY) $(PRIMTARGET) |
|---|
| 163 | |
|---|
| 164 | $(ACRONYMTARGET):: $(TEXSOURCES) |
|---|
| 165 | $(MAKEGLOSSARY) $(PRIMTARGET) |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | # pdflatex version |
|---|
| 169 | # make in sure that we always run pfdlatex (for fixpoint!) |
|---|
| 170 | # primarily .pdf file depends on the main tex source files plus all other tex-files we find |
|---|
| 171 | $(PDFTARGET):: $(PRIMSOURCE) $(TEXSOURCES) $(STYLESOURCES) |
|---|
| 172 | $(PDFLATEX) $(PRIMSOURCE) || ($(RM) $@; exit -1) |
|---|
| 173 | |
|---|
| 174 | # additionaly it depends on bibliography, glossary and index. keep this target separate so |
|---|
| 175 | # the first latex is run before this target is resolved |
|---|
| 176 | $(PDFTARGET):: $(BIBTARGET) $(INDEXTARGET) |
|---|
| 177 | |
|---|
| 178 | $(PDFTARGET):: $(GLOSSARYTARGET) |
|---|
| 179 | |
|---|
| 180 | $(PDFTARGET):: $(ACRONYMTARGET) |
|---|
| 181 | |
|---|
| 182 | # and we also depend on the fixpoint |
|---|
| 183 | # '$(PDFLATEXTARGET):: $(PRIMFIXPOINT)' does not work as we have to make sure that |
|---|
| 184 | # the fixpoint is calculated with pdflatex and not latex! |
|---|
| 185 | $(PDFTARGET):: |
|---|
| 186 | $(MAKE) LATEX="$(PDFLATEX)" $(PRIMFIXPOINT) |
|---|
| 187 | |
|---|
| 188 | # if you just would like to run pdflatex once (e.g for debugging) |
|---|
| 189 | Pdflatex: |
|---|
| 190 | $(PDFLATEX) $(PRIMSOURCE) |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | # FIXPOINT targets |
|---|
| 194 | # after we have run bibtex we have to run latex again. as one latex run might not be |
|---|
| 195 | # enough to correctly resolve all references we run latex after bibtex until .aux file |
|---|
| 196 | # stays constant. |
|---|
| 197 | # This is not optimal as we might run latex one time too often but at least all references should |
|---|
| 198 | # be resolved afterwards (at least as much as possible) |
|---|
| 199 | $(PRIMFIXPOINT): |
|---|
| 200 | # Save old aux-file state (Note that we cannot only do it for the PRIMTARGET |
|---|
| 201 | # as there might be \includes with separate aux-files!) |
|---|
| 202 | # Unfortunatly the make-functions are evaluated only the first time when |
|---|
| 203 | # potentially the aux-files don't exist. So make sure that at least |
|---|
| 204 | # $(PRIMTARGET).aux (which has to exist!) is there. Almost definitly |
|---|
| 205 | # the diff will fail and in the following recursion all aux-files will |
|---|
| 206 | # then be found ... |
|---|
| 207 | for file in $(PRIMTARGET) $(patsubst %.aux,%,$(wildcard *.aux)); do \ |
|---|
| 208 | $(CP) $$file.aux $$file.fpt; \ |
|---|
| 209 | done |
|---|
| 210 | $(LATEX) $(PRIMSOURCE) || ($(RM) $@; exit -1) # run latex |
|---|
| 211 | # if aux-files changed we have to recurse |
|---|
| 212 | for file in $(PRIMTARGET) $(patsubst %.aux,%,$(wildcard *.aux)); do \ |
|---|
| 213 | $(DIFF) -q $$file.aux $$file.fpt || \ |
|---|
| 214 | ($(RM) $(PRIMFIXPOINT); $(MAKE) $(PRIMFIXPOINT)); \ |
|---|
| 215 | done |
|---|
| 216 | |
|---|
| 217 | # create empty aux-files. usefull to be able to run with \includeonly |
|---|
| 218 | # selected parts. |
|---|
| 219 | aux: $(notdir $(TEXSOURCES:%.tex=%.aux)) |
|---|
| 220 | |
|---|
| 221 | %.aux: |
|---|
| 222 | $(TOUCH) $@ |
|---|