# --------------------------------------------------------------------------- # # Dave Richerby's wonderful LaTeX makefile # # --------------------------------------------------------------------------- # # This makefile is in the public domain. Do whatever you want with it # but be aware that it is provided ``as is'' without any express or # implied warranty. # # Please mail comments or suggestions to davidr@chiark.greenend.org.uk # # Examples of usage: # ``make foo.ps'': compile foo.tex to PostScript # ``make foo'': compile foo.tex to PostScript and view it # ``make foo.ps.gz'': compile foo.tex to PostScript and compress it # # Warning: don't cut and paste this file from your browser as it will # probably convert all the tabs to spaces. The make program needs # them to be tabs. # # Changes: # # 2000-10-18: Added PDF output (thanks to chrisw@chiark.greenend.org.uk) # 2000-10-12: Original version # # Set this to your PostScript viewer # VIEWER=xdvi # # If you want a default action, put it here. E.g. ``default: foo.ps'' # will cause make to produce foo.ps when run without arguments # DOCUMENT1=sudo default: $(DOCUMENT1).pdf $(DOCUMENT1).dvi # $(DOCUMENT1)-solns.dvi \ # $(DOCUMENT1)-solns.pdf publish # # If you have any documents which include other files, list them here, e.g. # # sample.dvi: sample.tex diagram.eps # # If you need to continue onto a second line, end the first with a '\' # character # figures = chainsaw.gif epsfigs = $(figures:.gif=.eps) pdffigs = $(figures:.gif=.pdf) $(DOCUMENT1).dvi: $(epsfigs) $(DOCUMENT1).pdf: $(pdffigs) # --------------------------------------------------------------------------- # # You shouldn't need to change anything below this point unless you're # # extending the functionality of the makefile. # # --------------------------------------------------------------------------- # tidy: rm -f *.log *.ps *.toc *.aux *.eepic *.bak *.lg *~ clean: tidy rm -f *.dvi *.pdf %-solns.tex: %.tex @echo @echo \* @echo \* Converting $< to $@ @echo \* sed 's/^\\documentclass{ictlab}/\\documentclass[solutions]{ictlab}\% DO NOT EDIT---WILL BE OVERWRITTEN/' $< > $@ %.dvi: %.tex @echo @echo \* @echo \* Compiling $< @echo \* latex $< @while ( grep "Rerun to get cross-references" \ $(subst .tex,.log,$<) >/dev/null ); do \ echo '** Re-running LaTeX **'; \ latex $<; \ done %.pdf: %.tex @echo @echo \* @echo \* Compiling $< @echo \* pdflatex $< @while ( grep "Rerun to get cross-references" \ $(subst .tex,.log,$<) >/dev/null ); do \ echo '** Re-running LaTeX **'; \ pdflatex $<; \ done # DON'T Cancel the built in rule that uses tex to produce dvi files: # %.dvi: %.tex # See http://freshmeat.net/articles/view/667/ # 1. latex file.tex # 2. dvips -Ppdf -G0 file.dvi -o file.ps # 3. ps2pdf13 -dPDFsettings=/prepress file.ps file.pdf # Two points to note: # * The -G0 parameter passed to dvips is used to get around a # bug in GhostScript which converts the "f" character to a # pound sign in the final PDF. # * The -dPDFsettings parameter for ps2pdf13 is used to prevent # downsampling of EPS images when they are converted to PDF. # Without this switch, EPS graphics in the final PDF look # very fuzzy, especially when viewed with a projector. %.lg: %.tex @echo @echo \* @echo \* running lgrind on $< @echo \* lgrind -e -lCC $< > $@ %.ps: %.dvi @echo @echo \* @echo \* Converting $< to PostScript @echo \* dvips -Ppdf -G0 -o $@ $< %.pdf: %.ps @echo @echo \* @echo \* Converting $< to PDF @echo \* ps2pdf13 -dPDFsettings=/prepress $< $@ %-4up.ps: %.ps @echo @echo \* @echo \* Converting $< to 4up, ready for printing @echo \* psnup -m12mm -b-2mm -pa4 -4 -l $< > $@ lpr: $(DOCUMENT)-4up.ps @echo @echo \* @echo \* Printing $< @echo \* lpr $< # %.pdf: %.dvi # @echo # @echo \* # @echo \* Converting $< to PDF # @echo \* # dvips -o - -Ppdf $< | ps2pdf13 - $@ %: %.dvi @echo @echo \* @echo \* Spawning viewer for $< @echo \* $(VIEWER) $< %.tex: %.c @echo @echo \* @echo \* Formatting C program $< to $@ @echo \* c2lt $< > $@ %.gz: % @echo @echo \* @echo \* Compressing $< @echo \* gzip $< %.eps: %.obj @echo @echo \* @echo \* Producing Encapsulated PostScript for $< @echo \* tgif -print -eps -color $< %.eepic: %.fig @echo @echo \* @echo \* Producing EEPIC for $< @echo \* fig2dev -L eepic $< $@ %.eps: %.fig @echo @echo \* @echo \* Producing EPS from $< @echo \* fig2dev -L eps $< $@ %.eps: %.gif @echo @echo \* @echo \* Producing EPS from $< @echo \* convert $< $@ %.pdf: %.gif @echo @echo \* @echo \* Producing PDF from $< @echo \* convert $< $@ %.pdf: %.eps @echo @echo \* @echo \* Producing EPS from $< @echo \* epstopdf $< publish: publish-snm # Stop GNU make from overzealous deletion of intermediate files .PRECIOUS: %.ps %.dvi %.eps %.lg