|
| 1 | +# Building the docs on osx will require to install Jinja2 and BeautifulSoup: |
| 2 | +# $ pip install Jinja2 BeautifulSoup |
| 3 | +# and the different tools for text to pdf: |
| 4 | +# $ port install texlive-latex-extra texlive-latex-recommended \ |
| 5 | +# texlive-htmlxml ImageMagick |
| 6 | +# |
| 7 | +# For building on Ubuntu 14.04 LTS, the following packages should be |
| 8 | +# installed with "apt-get install": |
| 9 | +# python-bs4 imagemagick source-highlight tex4ht texlive-latex-base \ |
| 10 | +# texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended \ |
| 11 | +# texlive-fonts-extra |
| 12 | + |
| 13 | +PDFLATEX := pdflatex |
| 14 | +WWW_PAGES := |
| 15 | +WWW_EXTRA := |
| 16 | + |
| 17 | +# The following subdirectories build documentation correctly. |
| 18 | +PDF_DIRS := tutorial |
| 19 | +# Define a function to map PDF_DIRS to a PDF base name. |
| 20 | +# Basically, every directory is the base name of the pdf except for dac12-talk. |
| 21 | +pdf_base_name_from_dir = $(subst talks/dac12,dac12-talk,$(1)) |
| 22 | +# Define a map function to apply a function to multiple arguments. |
| 23 | +map = $(foreach arg,$(2),$(call $(1),$(arg))) |
| 24 | + |
| 25 | +PDFS := $(addsuffix .pdf,$(addprefix chisel-,$(call map,pdf_base_name_from_dir,$(PDF_DIRS)))) |
| 26 | + |
| 27 | +# Suffixes for tex temporary files we'll clean |
| 28 | +TEX_SUFFIXES := 4ct 4tc aux css dvi html idv lg log out tmp xref |
| 29 | +TEX_TEMP_FILES := $(foreach dir,$(PDF_DIRS),$(foreach suffix,$(TEX_SUFFIXES),$(dir)/$(call pdf_base_name_from_dir,$(dir)).$(suffix))) |
| 30 | +STY_TEMP_FILES := $(foreach dir,$(PDF_DIRS),$(dir)/$(call pdf_base_name_from_dir,$(dir))_date.sty) |
| 31 | + |
| 32 | +LATEX2MAN := latex2man |
| 33 | +MAN_PAGES := chisel.man |
| 34 | + |
| 35 | +srcDir := . |
| 36 | +installTop:= ../www |
| 37 | + |
| 38 | +vpath %.tex $(addprefix $(srcDir)/,$(PDF_DIRS)) |
| 39 | + |
| 40 | +vpath %.mtt $(addprefix $(srcDir)/,$(PDF_DIRS)) |
| 41 | + |
| 42 | +all: $(WWW_PAGES) $(WWW_EXTRA) $(PDFS) |
| 43 | + |
| 44 | +extra: $(WWW_EXTRA) |
| 45 | + |
| 46 | +html: $(WWW_PAGES) |
| 47 | + |
| 48 | +pdf: $(PDFS) |
| 49 | + |
| 50 | +install: all |
| 51 | + |
| 52 | +# NOTE: We follow the recommended practice of running the *latex tools twice |
| 53 | +# so references (citations and figures) are correctly handled. |
| 54 | +# NOTE: There are problems with running pdflatex after htlatex due to the |
| 55 | +# manual.aux file left over by the latter. We see: |
| 56 | +# ./manual.tex:113: Undefined control sequence. |
| 57 | +# <argument> ...tring :autoref\endcsname {\@captype |
| 58 | +# }1 |
| 59 | +# l.113 Figure~\ref{fig:node-hierarchy} |
| 60 | +# This was reported at: |
| 61 | +# http://tex.stackexchange.com/questions/117802/running-pdflatex-after-htlatex-causes-hyperref-error-undefined-control-sequence |
| 62 | +# but apparently went away after upgrading to texlive 2013. |
| 63 | +# It fails on ubuntu 14.04 LTS and texlive-latex-recommended 2013.20140215-1 |
| 64 | +# if we don't remove the manual.aux file |
| 65 | +chisel-%.pdf: %.tex %_date.sty |
| 66 | + rm -f $(subst .tex,.aux,$<) |
| 67 | + cd $(dir $<) && for c in 0 1; do pdflatex -file-line-error -interaction nonstopmode -output-directory $(PWD) $(notdir $<) ; done |
| 68 | + mv $(subst .tex,.pdf,$(notdir $<)) $@ |
| 69 | + |
| 70 | +%.html: %.tex %_date.sty |
| 71 | + cd $(dir $<) && for c in 0 1; do htlatex $(notdir $<) $(PWD)/$(srcDir)/html.cfg "" -d/$(PWD)/ ; done |
| 72 | + mv $(subst .tex,.html,$(notdir $<)) $@~ |
| 73 | + $(srcDir)/../bin/tex2html.py $@~ $@ |
| 74 | + |
| 75 | +%.man: %.mtt |
| 76 | + # cd into the directory containing the .tex file and massage it |
| 77 | + cd $(dir $<) && \ |
| 78 | + sed -e "s/@VERSION@/$(RELEASE_TAG)/" -e "s/@DATE@/$(RELEASE_DATE)/" $(notdir $<) > $(basename $@).ttex ;\ |
| 79 | + latex2man $(basename $@).ttex $@ |
| 80 | + |
| 81 | +%.html: $(srcDir)/templates/%.html $(srcDir)/templates/base.html |
| 82 | + $(srcDir)/../bin/jinja2html.py $(notdir $<) $@ |
| 83 | + |
| 84 | +clean: |
| 85 | + -rm -f $(TEX_TEMP_FILES) |
| 86 | + -rm -f $(STY_TEMP_FILES) |
| 87 | + # Remove any .{png,graffle} files that are created from pdfs |
| 88 | + -rm -f $(foreach gext,png graffle,$(subst .pdf,.$(gext),$(wildcard tutorial/figs/*.pdf))) |
| 89 | + -rm -f $(WWW_PAGES) $(PDFS) $(WWW_EXTRA) $(addsuffix .1,$(WWW_EXTRA)) $(patsubst %.html,%.css,$(WWW_EXTRA)) |
| 90 | + -rm -f *~ *.aux *.log *.nav *.out *.snm *.toc *.vrb |
| 91 | + -rm -f *.jpg *.png |
| 92 | + |
| 93 | +# Generate a date (optional) for the document based on the latest |
| 94 | +# git commit of any of its (obvious) constituent parts. |
| 95 | +%_date.sty: %.tex |
| 96 | + for f in $(wildcard $(dir $<)*.tex); do git log -n 1 --format="%at" -- $$f; done | sort -nr | head -1 | gawk '{print "\\date{",strftime("%B %e, %Y", $$1),"}"}' > $@ |
| 97 | + cmp $@ $(dir $<)$@ || cp $@ $(dir $<) |
0 commit comments