Newer
Older
trm / makefile
# Build a release of 'trm' using 'make'
# Requires a modern 'make' like GNU.

# Uncomment One Of The Following For Early Releases

#EARLY     = -Alpha
#EARLY     = -Beta
#EARLY     = -RC1
VERSION    = $(shell cat version)${EARLY}


#####
# Definitions Relevant To This Program
#####

PROGNAME  = trm
PROGMAIN  = trm.sh

PROGFILES = ${PROGMAIN}
PROGDOCS  = ${PROGMAIN}.ps

DOCS      = ${PROGNAME}.1.gz        \
            ${PROGNAME}.html        \
            ${PROGNAME}.pdf         \
            ${PROGNAME}.ps          \
            ${PROGNAME}.rst         \
            ${PROGNAME}.txt         \

SUPPORT   = ${PROGNAME}-license.txt \
            CHANGELOG.txt           \
            WHATSNEW.txt


#####
# Nothing Should Need To Change Below This Line
#####


DIR          = ${PROGNAME}-${VERSION}
HEADER1      = "WHATSNEW For '${PROGNAME}' ${VERSION}    (`date`)"
HEADER2      = "----------------------------------------------------------------------"
RELEASES     = "Releases"
TARBALL      = ${DIR}.tar.gz
TMPFILE      = tmpfile


#####
# Pattern Rules
#####

###
# Document Production
###

# Some Docutils installations keep the ".py" suffix for the various
# frontend programs, and some do not.  It's even possible there are
# links from one to the other.  Since the project can be checked out
# on any platform, we have to check for this every time we run the
# 'make'.  This is irritating.

2HTML    = $(shell which rst2html.py  rst2html  | tr '\012' ' ' | awk '{print $$1}')  --no-compact-lists
2LATEX   = $(shell which rst2latex.py rst2latex | tr '\012' ' ' | awk '{print $$1}')  --stylesheet=parskip --latex-preamble="\usepackage{fullpage}"
2ODT     = $(shell which rst2odt.py   rst2odt   2>/dev/null | head -n 1)
2MAN     = $(shell which rst2man.py   rst2man   2>/dev/null | head -n 1)

# TeX/LaTeX Processing

DVIPS    = dvips
PDFLATEX = pdflatex
LATEX    = latex

%.dvi : %.latex
	${LATEX} $*.latex

%.html : %.rst
	${2HTML} <$*.rst >$*.html

%.latex : %.rst
	${2LATEX} $*.rst >$*.latex

%.1 : %.rst
	${2MAN} <$*.rst >$*.1

%.1.gz: %.1
	@gzip -c <$*.1 >$*.1.gz

%.odt : %.rst
	${2ODT} <$*.rst >$*.odt

%.pdf : %.latex
	${PDFLATEX} $*.latex
	${PDFLATEX} $*.latex
	${PDFLATEX} $*.latex

%.ps : %.dvi
	${DVIPS} $*.dvi

%.txt: %.1
	@groff -man -Tascii $< | col -xb >$@

###
# Pretty Print Programs & Scripts
###

%.pl.ps: %.pl
	@enscript -Eperl --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $<

%.py.ps: %.py
	@enscript -Epython --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $<

%.sh.ps: %.sh
	@enscript -Esh --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $<


#####
# Actual Build Rules
#####

FORCE:

CHANGELOG.txt: FORCE
	@git log --pretty=format:"%h%x20%an%x20%ad%x20%s" ${PROGMAIN} >CHANGELOG.txt

WHATSNEW.txt: FORCE
	@printf "%s\n%s\n\n" ${HEADER1} ${HEADER2} | cat - $@ >${TMPFILE}
	@mv ${TMPFILE} $@
	@emacs -nw $@
	@git add $@

docs: ${DOCS} ${PROGDOCS} ${SUPPORT}
	@chmod 644 ${DOCS} ${PROGDOCS}
	@chmod 644 *.gz *.txt

fixrev: FORCE
	@sed -i "s/^GITID.*/GITID=\'$(shell git log --pretty=format:"%h%x20%an%x20%ad"\' | head -n1)/" ${PROGNAME}.sh
	@sed -i "s/^VERSION.*/VERSION=\'${VERSION}'/" ${PROGNAME}.sh
	@sed -i "s/Id:.*/Id: \'$(shell git log --pretty=format:"%h%x20%an%x20%ad"\' | head -n1)/" ${PROGNAME}.rst
	@git add ${PROGNAME}.sh ${PROGNAME}.rst

release: docs fixrev ${PROGFILES}
	@git commit -m${HEADER1}
	@git push
	@mkdir -p ${DIR}/Docs
	-@mkdir -p ${RELEASES} 2>&1 >/dev/null
	@cp -pv ${DOCS} ${PROGDOCS} ${DIR}/Docs
	@cp -pv ${SUPPORT} ${PROGFILES} ${DIR}/
	@tar -czvf ${TARBALL} --exclude CVS ${DIR}
	@rm -rf ${DIR}
	@mv ${DIR}.tar.gz ${RELEASES}


#####
# Housekeeping
#####

clean: FORCE
	@rm -rf  ${PROGNAME}.txt CHANGELOG.txt *~ *.1 *.1.gz *.aux *.core *.dvi *.gz *html *.latex *.log *.out *.pdf *.ps tmpfile *.toc

version: FORCE
	@echo ${VERSION}