# Copyright (C) 2000-2006 Greg Collecutt, Joseph Hope, Paul Cochrane and
# others
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# $Id: Makefile 1884 2008-03-18 13:52:53Z paultcochrane $

.PHONY: clean realclean figures help

MAIN = xmds_doc
TEXFILES = \
	$(MAIN).tex \
	abstract.tex \
	develAndProgStructure.tex \
	extraFeatures.tex \
	functionality.tex \
	gpl.tex \
	intro.tex \
	languageReference.tex \
	loadxsil.tex \
	misc_defs.tex \
	moreExamples.tex \
	numModellingTheory.tex \
	outlook.tex \
	stochasticSimsAndMPI.tex \
	titlepage.tex \
	tutFromScratch.tex \
	tutTemplateStart.tex \
	workedExample.tex \
	xmds_defs.tex \
	xmds_doc.bib \
	xsil.tex \
	xsil2graphics.tex

STYFILES = \
	apsrev.bst \
	book.cls \
	ccaption.sty \
	fancyhdr.sty \
	html.sty \
	listings.sty \
	listings.cfg \
	lstdoc.sty \
	lstlang1.sty \
	lstlang2.sty \
	lstlang3.sty \
	lstmisc.sty \
	lstpatch.sty \
	quotchap.sty

EPSFIGS = figures/*.eps

default: pdf

all: figures pdf html dist

# print out usage information
help:
	@echo ""
	@echo "Possible targets:"
	@echo "To build the documentation:"
	@echo "    pdf: build the documentation as pdf (default target)"
	@echo "    html: build the html documentation"
	@echo "To distribute the documentation source:"
	@echo "    dist: build a tarball of the tex sources"
	@echo "To view the documentation:"
	@echo "    view: view the documentation with Acrobat Reader"

# generate the figures
figures:
	$(MAKE) --directory=$@

# generate pdf output of the sources
pdf: figures $(MAIN).pdf

$(MAIN).pdf: $(TEXFILES) $(STYFILES)
	pdflatex $<
	makeindex $(MAIN)
	bibtex $(MAIN)
	makeindex $(MAIN)
	pdflatex $<
	pdflatex $<

# build the html documentation
html: pdf $(MAIN).html
$(MAIN).html: $(TEXFILES) $(STYFILES)
	mkdir -p html
	latex2html $<

# build a distribution of the tex source
DOCDIR = xmds_doc
FIGSDIR = $(DOCDIR)/figures
dist: $(MAIN).tar.gz

$(MAIN).tar.gz: $(TEXFILES) $(STYFILES) $(EPSFIGS)
	mkdir -p $(DOCDIR)
	cp $(TEXFILES) $(STYFILES) $(DOCDIR)
	mkdir -p $(FIGSDIR)
	cp $(EPSFIGS) $(FIGSDIR)
	cp Makefile $(DOCDIR)
	cp figures/Makefile $(FIGSDIR)
	tar -cvzf $(MAIN).tar.gz $(DOCDIR)
	rm -rf $(DOCDIR)

# view the output
view: figures pdf
	acroread $(MAIN).pdf

# clean up
clean:
	-rm -f *.mpx *.log *.aux *.blg *.toc *.out *.bbl *.idx *.lof *.lot \
	*.ilg *.ind $(MAIN).pdf $(MAIN).html $(MAIN).tar.gz

SUBDIRS = figures
realclean: clean
	for dir in $(SUBDIRS);                 \
	do                                     \
	     $(MAKE) --directory=$$dir clean;  \
	done;                                  \
	rm -rf html

# vim: shiftwidth=4:
