1 # Produce html, pdf, and dvi output from latex source
2 # W. Trevor King, 2008, version 0.2
3 # This file is in the public domain.
6 # all : generate each of the outputs (pdf, html, dvi) and call view
7 # view : call '$(PDF_VIEWER) main.pdf &' to see the pdf file
8 # install : call install_% for pdf, html, dvi, and dist
9 # clean : semi-clean and remove the $(GENERATED_FILES) as well
10 # semi-clean : remove all intermediate $(TEMP_FILES) used during generation
12 # pdf : generate the pdf file (Portable Document Format)
13 # install_pdf : install the dvi file (currently no action)
14 # html : generate html directory ready for posting
15 # install_html : scp the html directory to $(INSTALL_HTML)
16 # dvi : generate main.dvi (DeVice Independent file)
17 # install_dvi : install the dvi file (currently no action)
18 # dist : gen. $(DOC_NAME)-$(VERSION).tar.gz containing $(DIST_FILES)
19 # install_dist : install the dist file (currently no action)
21 # images : call for generation of all images in $(IMAGES)
23 DOC_NAME = chem_inventory
26 # I like to keep my images in seperate directories, where any processing
27 # they may need woln't clutter up the base directory with temp files.
28 # To control these, this Makefile calls the Makefiles in the IMAGE_DIRS,
29 # so make sure they exist, and have the following targets:
30 # clean : remove all generated files
31 # semi-clean : remove all intermediate files
32 # for each image in IMAGE, you must have a rule that generates it,
33 # see 'image generation rules' below
37 # Non image source files
38 SOURCE_FILES = main.tex *.tex
39 # And anything else you'd like to distribute
40 OTHER_FILES = README Makefile
42 DIST_FILES = $(SOURCE_FILES) $(OTHER_FILES) $(IMAGE_DIRS)
44 # Select where to put things when you call the dist and install targets
45 DIST_DIR = $(DOC_NAME)-$(VERSION)
46 DIST_NAME = $(DOC_NAME)-$(VERSION).tar.gz
47 INSTALL_PDF = $(HOME)/rsrch/notes
49 INSTALL_HTML = einstein:./public_html/rsrch/papers/$(DOC_NAME)
50 # interpreted as latex by latex2html, so escape the '~' to '\~{}'
52 CSS_PATH = "/$(TILDE)wking/shared/style_l2h.css"
54 # Files removed on clean or semi-clean
55 TEMP_FILES = *[.]aux *[.]log *[.]out *[.]bak \
57 # Files removed only on clean
58 GENERATED_FILES = $(DIST_NAME) \
59 rm -f main.pdf main.dvi html *.pdf
61 PDF_VIEWER = xpdf # you can also try evince, acroread, 'xpdf -view H', etc.
63 ## image generation rules, to handle the images in $(IMAGES)
70 ### The remaining rules shouldn't need to be changed
72 # pdf, dvi, and html depend on images
77 all : pdf html dvi view
80 $(PDF_VIEWER) main.pdf &
82 install : install_pdf install_html install_dvi install_dist
84 clean : semi-clean $(IMAGE_DIRS:%=%_clean)
85 rm -rf $(GENERATED_FILES)
87 semi-clean : $(IMAGE_DIRS:%=%_semi-clean)
91 ## Mid-level indirection targets
93 # indirection, so we can have short names like 'pdf'
94 # without rebuilding when it's not neccessary
100 ## Installation targets
103 install_html : html clean_html_image_dirs
104 scp -r html $(INSTALL_HTML)
109 ## The meat of the generation
111 # generate the pdf output directly with pdflatex
112 main.pdf : main.aux $(SOURCE_FILE) images
115 # generate html files, including the DIST_FILES in a subdir.
116 # latex2html requires main.aux to generate figure numbers
117 # main.pdf is for the '$(DOC_NAME).pdf' link in the footer
118 # (see ~/.latex2html-init)
119 html : $(SOURCE_FILES) main.aux main.pdf
120 latex2html -split 1 -white -notransparent -html_version 3.2 \
121 -t $(DOC_NAME) -dir html -mkdir \
122 -noshort_extn -top_navigation -bottom_navigation \
123 -up_url '../' -up_title 'Papers' \
124 -show_section_numbers \
126 main.tex # generate the html
127 if [ ! -d html/src ]; then mkdir html/src ; fi # mk src if it doesn't exist yet
128 cp -r $(DIST_FILES) html/src/ # move the source files into html/src
129 cp main.pdf html/$(DOC_NAME).pdf # move the pdf in so we can link to it
131 # generate the .aux file which contains labels for referencing
132 # needed to correctly number references in the pdf and html output.
133 # (Clash between latex and pdflatex's .aux files? semi-clean fixes)
134 # -draftmode makes pdflatex ignore images and not make a pdf (faster)
135 main.aux : *.tex images
136 pdflatex -draftmode main.tex
138 # to stretch our .tex files a bit more, make a dvi as well :p
139 # run twice to straighten out and TOC or references issues
140 main.dvi : $(SOURCE_FILES) images
144 # generate a gzipped tar file containing the DIST_FILES
145 $(DIST_NAME) : $(DIST_FILES)
147 cp $(DIST_FILES) $(DIST_DIR)
148 tar -chozf $(DIST_NAME) $(DIST_DIR)
152 ## IMAGE_DIR handling rules
154 # call clean for any image directory
158 # call semi-clean for any image directory
160 $(MAKE) -C $< semi-clean
162 # clean and junk that was in the working image directories
163 clean_html_image_dirs : $(IMAGE_DIRS:%=%_html_dir_clean)
165 # call clean for any image directory in the html/src directory
167 $(MAKE) -C html/src/$< clean