Newer
Older
reStructuredText / makefile
# Produce Various Output Formats From A Restructured Text Source Document


#####
# Setup The Project Here
#####

# PROJECT  = NAMEOFPROJECT
# This is setup in the makefile that includes us

# List all the output files

1:       ${PROJECT}.1

beamer:  ${PROJECT}.beamer

doc:     ${PROJECT}.doc

dvi:     ${PROJECT}.dvi

html:    ${PROJECT}.html

latex:   ${PROJECT}.latex

odt:     ${PROJECT}.odt

pdf:     ${PROJECT}.pdf

ps:      ${PROJECT}.ps

txt:     ${PROJECT}.txt


#####
# Things That May Have To Be Changed, Depending On System
#####


########################################################################
#          Nothing Below This Line Should Need To Be Changed           #
########################################################################


#####
# Revision Support
#####

DATE = $(shell date)
REVISION = $(shell git log --pretty=format:"%h%x20%an%x20%ad%x20%s" -1 | cut -f1 -d" ")


###
# Document Production
###

# RST Filter And Needed Program Locations

# 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.

2BEAMER  = $(shell which rst2beamer.py  rst2beamer | tr '\012' ' ' | awk '{print $$1}')  --theme=Warsaw --stylesheet=parskip
2DOC     = soffice --headless --convert-to doc
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   | tr '\012' ' ' | awk '{print $$1}')
2MAN     = $(shell which rst2man.py   rst2man   | tr '\012' ' ' | awk '{print $$1}')

DVIPS    = dvips
PDFLATEX = pdflatex
LATEX    = latex
NROFF    = nroff -c -man

# File Types

CLEAN    = \~ .aux .beamer .log .nav .out .snm .toc .vrb
DOCFILES = .1 .doc .dvi .html .latex .odt .pdf .ps .txt

# Conversion Rules

%.beamer : %.rst
	${2BEAMER} $*.rst >$*.beamer
	${PDFLATEX} $*.beamer

%.doc : %.odt
	${2DOC} $*.odt

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

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

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

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

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

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

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

%.txt : %.1
	${NROFF} $*.1 >$*.txt


#####
# Packaging
#####

all: 1 doc dvi html latex odt pdf ps

pkg: all clean
	tar -czvf ${PROJECT}-docs.tar.gz ${PROJECT}.*

release:
	sed "s/__DATE__/${DATE}/" <${PROJECT}.rst >tmp.rst
	sed "s/__REVISION__/${REVISION}/" <tmp.rst >${PROJECT}.rst
	make html pdf
	pdfshrink.sh ${PROJECT}.pdf
	rm tmp.rst
	git checkout ${PROJECT}.rst


#####
# Cleanup stanzas
#####

clean:
	-@for type in ${CLEAN};\
     do\
         rm -v *$$type;\
     done

scrub: clean
	-@for type in ${DOCFILES};\
     do\
         rm -v *$$type;\
     done