# 
# $Id: Makefile,v 1.5 2003/09/23 13:53:49 rgb Exp $
#
#======================================================================
# THIS IS A "GENERIC" MAKEFILE FOR SGML PROJECTS
#
# make		Will make the thml
#
# make dvi      makes dvi file via sgml2latex
# 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 cvs      does a cvs commit and creates the timestamp $(CVS)
# make sync     does a cvs commit and runs synccvs to list of
#               CVSROOT hosts
# 
#=======================================================================
# This is the main source file, which should have the same base name
# as the project (CVS and build directory).
DIR =  yum_ftp
SOURCE = $(DIR).sgml
VERSION = 0.1
RELEASE = 1

# All sources (tex and ps)
TEX = $(SOURCE:.sgml=.tex)
DVI = $(SOURCE:.sgml=.dvi)
HTML = $(SOURCE:.sgml=.html)
AUX = $(SOURCE:.sgml=.aux)
LOG = $(SOURCE:.sgml=.log)
ERR = $(SOURCE:.sgml=.err)
PS = $(SOURCE:.sgml=.ps)
PDF = $(SOURCE:.sgml=.pdf)
PHP = $(SOURCE:.sgml=.php)
ABS = $(SOURCE:.sgml=.abs)
TAR = $(DIR).tar
TGZ = $(DIR).tgz
CVS = $(DIR).cvs.time

# Build targets (from rules)
all:	$(HTML) # install

# Build targets (from commands)
html:	$(HTML)

$(HTML):	$(SOURCE)
	sgml2html $(SOURCE)
	cp $(HTML) index.html

txt:	$(SOURCE)
	sgml2txt $(SOURCE)

dvi:	$(DVI)

$(DVI):	$(SOURCE)
	sgml2latex $(SOURCE)
	latex $(TEX)

ps:	$(PS)

$(PS):	$(DVI)
	dvips -o $(PS) $(DVI)

pdf:	$(PDF)

$(PDF):	$(DVI) $(PS)
	ps2pdf $(PS)

tar:	$(TAR)

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

#========================================================================
# This is a complicated target, but VERY USEFUL.  It makes a .tgz tarball
# of the exact form preferred for an RPM.  Eventually I'll add a sed script
# that automatically fixes the accompanying rpm spec file to correspond
# right before building the tgz to really automate this, so that I can just
# move the spec to SPEC, move the source tgz to SOURCE and do an
# rpm -ba blah.spec.
#========================================================================
tgz:	$(SOURCES)
	rm -f .$(DIR)
	mkdir -p .$(DIR)
	cp -a * .$(DIR)
	mv .$(DIR) $(DIR)
	# Exclude any cruft/development directories and CVS stuff.  Add
	# lines as needed.
	tar -cvpf $(TAR) \
            --exclude=CVS \
            --exclude=CRUFT \
            --exclude=$(TAR) \
            --exclude=$(TGZ) \
            --exclude=*.html \
            --exclude=*.txt \
            ./$(DIR)
	gzip $(TAR)
	mv $(TAR).gz $(TGZ)
	rm -rf $(DIR)

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
	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)

install: $(PHP) $(ABS) $(HTML)
	(make html;\
	make tgz;\
	mkdir $(DIR);\
	rsync -avz $(DIR) ganesh.phy.duke.edu:public_html/General/;\
	rsync -avz $(DIR) ganesh.phy.duke.edu:public_html/General/$(DIR);\
	rsync -avz *.html ganesh.phy.duke.edu:public_html/General/$(DIR)/$(DIR);\
	rsync -avz $(TGZ) ganesh.phy.duke.edu:public_html/General/$(DIR)/;\
	rsync -avz $(ABS) ganesh.phy.duke.edu:public_html/General/$(DIR)/;\
	rsync -avz $(PHP) ganesh.phy.duke.edu:public_html/General/;\
	rmdir $(DIR))

