# --------------------------------------------------------------------------- # # 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=evince # # 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 # DOCUMENT=processes-slides default: $(DOCUMENT)-no-c.pdf $(DOCUMENT)-no-c.ps \ $(DOCUMENT)-no-c-handout.ps $(DOCUMENT)-no-c-handout.pdf \ $(DOCUMENT)-no-c-4up.ps $(DOCUMENT)-no-c-4up.pdf \ $(DOCUMENT)-no-c-8up.ps $(DOCUMENT)-no-c-8up.pdf \ $(DOCUMENT).pdf $(DOCUMENT).ps \ $(DOCUMENT)-handout.ps $(DOCUMENT)-handout.pdf \ $(DOCUMENT)-4up.ps $(DOCUMENT)-4up.pdf \ $(DOCUMENT)-8up.ps $(DOCUMENT)-8up.pdf # default: $(DOCUMENT)-4up.ps $(DOCUMENT).pdf $(DOCUMENT)-4up.pdf # # 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 # texfigures = win-call-print.tex print.tex win-hello.tex call-print.tex \ fork-simple.tex fork-example-1.tex fork-example-2.tex execve.tex \ simplesh-a.tex CreateProcess-syntax.tex fork-pseudocode.tex \ semaphore-example.tex mutex0.tex mutex1.tex mutex2.tex figures = linux-process-states.fig multitasking.fig process-states.fig \ process-control-blocks.fig epsfigs = $(figures:.fig=.eps) pdffigs = $(figures:.fig=.pdf) $(DOCUMENT).dvi: $(epsfigs) $(texfigures) Makefile $(DOCUMENT)-handout-a5.tex: $(DOCUMENT).tex $(epsfigs) $(texfigures) Makefile $(DOCUMENT)-vsimple.tex: $(DOCUMENT).tex $(epsfigs) $(texfigures) Makefile $(DOCUMENT).pdf: $(epsfigs) $(texfigures) Makefile $(DOCUMENT)-no-c.dvi: $(epsfigs) $(texfigures) Makefile $(DOCUMENT)-no-c.tex $(DOCUMENT)-no-c-handout-a5.tex: $(DOCUMENT).tex $(epsfigs) $(texfigures) \ Makefile $(DOCUMENT)-no-c.tex $(DOCUMENT)-no-c-vsimple.tex: $(DOCUMENT).tex $(epsfigs) $(texfigures) \ Makefile $(DOCUMENT)-no-c.tex $(DOCUMENT)-no-c.pdf: $(epsfigs) $(texfigures) Makefile $(DOCUMENT)-no-c.tex mutex0.tex: mutex0.c c2lt $< > mutex0.tex perl -pi.back -e 's/(pthread\\_mutex\\_t\s+mutex;)/{\\red{}\1}/' mutex0.tex perl -pi -e 's/(PTHREAD\\_MUTEX\\_INITIALIZER)/{\\red{}\1}/' mutex0.tex mutex1.tex: mutex1.c c2lt $< > mutex1.tex perl -pi.back -e 's/(pthread\\_mutex\\_(?:un)?lock)/{\\red{}\1}/' mutex1.tex # --------------------------------------------------------------------------- # # You shouldn't need to change anything below this point unless you're # # extending the functionality of the makefile. # # --------------------------------------------------------------------------- # clean: rm -f *.log *.dvi *.ps *.toc *.aux *.eepic *.bak %.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 # See http://freshmeat.net/articles/view/667/ # 1. latex file.tex # 2. dvips -Ppdf -G0 file.dvi -o file.ps # 3. ps2pdf -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 ps2pdf 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. %.ps: %.dvi @echo @echo \* @echo \* Converting $< to PostScript @echo \* dvips -t a4 -Ppdf -G0 -o $@ $< %.pdf: %.ps @echo @echo \* @echo \* Converting $< to PDF @echo \* GS_OPTIONS="-sPAPERSIZE=a4" ps2pdf -dPDFsettings=/prepress $< $@ %-4up.ps: %-vsimple.ps @echo @echo \* @echo \* Converting $< to 4up, ready for printing @echo \* psnup -m12mm -b-2mm -pa4 -4 -l $< > $@ %-8up.ps: %-vsimple.ps @echo @echo \* @echo \* Converting $< to 8up, ready for printing @echo \* psnup -m10mm -b-2mm -pa4 -8 -l $< > $@ %-no-c.tex: %.tex @echo @echo \* @echo \* Converting $< to $@ @echo \* sed 's/^\\includeversion{canUnderstandC}/\\excludeversion{canUnderstandC}\% DO NOT EDIT---WILL BE OVERWRITTEN/; s/^\\excludeversion{Cchallenged}/\\includeversion{Cchallenged}\% DO NOT EDIT---WILL BE OVERWRITTEN/; s/^\\usepackage\[canUnderstandC\]{optional}/\\usepackage[Cchallenged]{optional}\% DO NOT EDIT---WILL BE OVERWRITTEN/' $< > $@ %-handout-a5.tex: %.tex @echo @echo \* @echo \* Converting $< to $@ @echo \* sed 's/^\\documentclass\[total,pdf\]{prosper}/\\documentclass[nopagebreak,ps,10pt,a5paper]{ppr-prv}\% DO NOT EDIT---WILL BE OVERWRITTEN\n\\geometry{margin=10mm}\% DO NOT EDIT---WILL BE OVERWRITTEN/' $< > $@ #sed 's/^\\documentclass\[total,\(.*\)\]{prosper}/\\documentclass[ps,\1]{ppr-prv}\% DO NOT EDIT---WILL BE OVERWRITTEN/' $< > $@ %-handout.ps: %-handout-a5.ps @echo @echo \* @echo \* Converting $< to $@ @echo \* psnup -Pa5 -pa4 -2 $< $@ %-vsimple.tex: %.tex @echo @echo \* @echo \* Converting $< to $@ @echo \* sed 's/^\\usepackage\[toc,highlight,Tycja\]{HA-prosper}/\\usepackage[toc,highlight,vsimple]{HA-prosper}\% DO NOT EDIT---WILL BE OVERWRITTEN/' $< > $@ lpr: $(DOCUMENT)-4up.ps @echo @echo \* @echo \* Printing $< @echo \* lpr $< # %.pdf: %.dvi # @echo # @echo \* # @echo \* Converting $< to PDF # @echo \* # dvips -o - -Ppdf $< | ps2pdf - $@ %: %-4up.ps @echo @echo \* @echo \* Spawning viewer for $< @echo \* $(VIEWER) -landscape $< %.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 for $< @echo \* fig2dev -L eps $< $@ # Stop GNU make from overzealous deletion of intermediate files .PRECIOUS: %.dvi %.eps