# 
# $Id: Makefile,v 1.33 2003/10/01 16:35:21 rgb Exp $
#
#======================================================================
# THIS IS A "GENERIC" MAKEFILE FOR LATEX PROJECTS
#
# make          alone makes only the $(DVI) file, running latex twice
# so that all references and toc's are correct.
#
# make ps       makes $(PS) (and $(DVI) if necessary)
# make pdf      makes $(PDF) (and $(PS) and $(DVI) as necessary)
# make html     makes $(HTML) via latex2html, I hope...
# make clean    deletes all transient build files and output formats.
# make tar      makes $(TAR) from >>all<< the sources
# make gz       makes $(TARGZ) from >>all<< the sources
# make commit   does a cvs commit and creates the timestamp $(CVS)
# make sync     does a cvs commit and runs synccvs to list of
#               CVSROOT hosts
# 
# Feel free to add your own!  rgb  3/5/90
#=======================================================================
# This is the main source file, which should have the same base name
# as the project (CVS and build directory).
SOURCE = beowulf_book.tex
VERSION_MAJOR=0
VERSION_MINOR=2.1
RELEASE=1

# The list of includes are things required for the build to work.  Examples
# might be included .tex or .sty files, embedded .eps files, and so forth.
# Naturally, anything on this list should be in the CVS tree.
INCLUDE = OPL.tex \
          preface.tex \
          introduction.tex beowulf_diagram.eps cluster_diagram.eps \
          beowulf_design.tex \
          book_organization.tex \
          amdahls_law.tex bscaling.Tis10.eps bscaling.Tis0.eps \
            bscaling.Tis1.eps bscaling.Tis1.Psq.eps \
          bottlenecks.tex \
          IPCs_and_Barriers.tex \
          profiling.tex neural.eps pvm_neural.eps \
          specific_parallel_models.tex \
          node_hardware.tex \
          net_hardware.tex \
          building_a_beowulf.tex \
          tools_and_tricks.tex \
          recycling_your_beowulf.tex \
          turnkey_vendors.tex \
          beowulfs_in_business.tex \
          beowulfs_in_schools.tex \
          beowulfs_in_government.tex \
          beowulfs_in_developing_countries.tex \
          beowulfs_at_home.tex \
          justifying_a_beowulf.tex \
          portable_beowulfs.tex \
          conclusions.tex \
          appendix.tex \
          bibliography.tex \
          scaling.sm 

# All sources (tex and ps)
SOURCES = $(SOURCE) $(INCLUDE)
DIR = $(SOURCE:.tex=)
DVI = $(SOURCE:.tex=.dvi)
HTML = $(SOURCE)/index.html
AUX = $(SOURCE:.tex=.aux)
LOG = $(SOURCE:.tex=.log)
TOC = $(SOURCE:.tex=.toc)
ERR = $(SOURCE:.tex=.err)
PS = $(SOURCE:.tex=.ps)
PDF = $(SOURCE:.tex=.pdf)
A4PS = $(SOURCE:.tex=.a4.ps)
A4PDF = $(SOURCE:.tex=.a4.pdf)
TAR = $(SOURCE:.tex=.tar)
ABS = $(DIR).abs
PHP = $(DIR).php
TGZ = $(SOURCE:.tex=)-$(VERSION).$(RELEASE).tgz
CVS = $(SOURCE:.tex=.cvs.time)

# Build targets (from rules)
all:	$(DVI)
ps:	$(DVI) $(PS)
pdf:	$(DVI) $(PS) $(PDF)
a4ps:	$(DVI) $(A4PS)
a4pdf:	$(DVI) $(A4PS) $(A4PDF)
tar:	$(TAR)
tgz:	$(TGZ)

# Build targets (from commands)
html:	$(SOURCES)
	latex2html -local_icons $(SOURCE)

$(TAR):	$(SOURCES)
	rm -f $(DVI) $(AUX) $(LOG) $(ERR) $(PS) $(PDF) $(TOC)
	tar -cvpf $(TAR) -C .. $(DIR)

$(TGZ):	$(SOURCES) $(TAR)
	gzip $(TAR)
	mv $(TAR).$(VERSION_MAJOR).$(VERSION_MINOR)-$(RELEASE).gz $(TGZ)

cvs:
	touch $(CVS)		# Will force a commit!
	cvs commit .		# doesn't sync (yet).

sync:
	touch $(CVS)		# Will force a commit!
	cvs commit .		# Do the commit
	synccvs $(DIR) ganesh.phy.duke.edu
	synccvs $(DIR) 209.42.212.5

# Clean up all the junk build files and output formats to save space.
clean:
	rm -f $(DVI) $(AUX) $(LOG) $(ERR) $(PS) $(PDF) $(TOC)

install: $(DIR) $(PS) $(PDF) $(A4PS) $(A4PDF) $(ABS) $(PHP)
	(make html;\
	rsync -avz $(DIR) ganesh.phy.duke.edu:public_html/Beowulf/$(DIR)/;\
	rsync -avz $(PDF) ganesh.phy.duke.edu:public_html/Beowulf/$(DIR)/;\
	rsync -avz $(PS) ganesh.phy.duke.edu:public_html/Beowulf/$(DIR)/;\
	rsync -avz $(A4PDF) ganesh.phy.duke.edu:public_html/Beowulf/$(DIR)/;\
	rsync -avz $(A4PS) ganesh.phy.duke.edu:public_html/Beowulf/$(DIR)/;\
	rsync -avz $(ABS) ganesh.phy.duke.edu:public_html/Beowulf/$(DIR)/;\
	rsync -avz $(PHP) ganesh.phy.duke.edu:public_html/Beowulf/;\
	rsync -avz $(DIR) ganesh.phy.duke.edu:public_html/brahma/Resources/$(DIR)/;\
	rsync -avz $(PDF) ganesh.phy.duke.edu:public_html/brahma/Resources/$(DIR)/;\
	rsync -avz $(PS) ganesh.phy.duke.edu:public_html/brahma/Resources/$(DIR)/;\
	rsync -avz $(A4PDF) ganesh.phy.duke.edu:public_html/brahma/Resources/$(DIR)/;\
	rsync -avz $(A4PS) ganesh.phy.duke.edu:public_html/brahma/Resources/$(DIR)/;\
	rsync -avz $(ABS) ganesh.phy.duke.edu:public_html/brahma/Resources/$(DIR)/;\
	rsync -avz $(PHP) ganesh.phy.duke.edu:public_html/brahma/Resources/)

# Rule for making dvi out of tex.  Do it twice to build table of contents
# and resolve forward references.
%.dvi:%.tex	 $(SOURCES)
	latex $< $@
	latex $< $@

# Rule for making postscript image
%.ps:%.dvi
	dvips -Pamz -Pcmz -o $@ $<

# Rule for making pdf image
%.pdf:%.ps
	ps2pdf $<

# Rule for making postscript image
%.a4.ps:%.dvi
	dvips -Pamz -Pcmz -t A4 -o $@ $<

# Rule for making pdf image
%.a4.pdf:%.a4.ps
	ps2pdf $<

