Newer
Older
reStructuredText / makefile
@tundra tundra on 24 Mar 2015 2 KB Added Word .doc conversion rule.
# Produce Various Output Formats From A Restructured Text Source Document
# $Id: makefile,v 1.105 2015/03/24 18:53:53 tundra Exp $


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

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

# List all the output files

1:     ${PROJECT}.1

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



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

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 .log .out \~
DOCFILES = .1 .doc .dvi .html .latex .odt .pdf .ps .txt

# Conversion Rules

%.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}.*


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

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

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