1#
2# Copyright (c) 2004-2007 Hypertriton, Inc. <http://hypertriton.com/>
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23# USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25#
26# Build PostScript/PDF documents from nroff+{eqn,pic,tbl,refer} source.
27#
28
29DOCPS?=		untitled.ps
30DOCPDF?=	untitled.pdf
31DOCSRC?=
32
33ROFF?=		nroff
34ROFFFLAGS?=
35MACROS?=
36EQN?=		eqn
37EQNFLAGS?=
38PIC?=		pic
39PICFLAGS?=
40TBL?=		tbl
41TBLFLAGS?=
42REFER?=		refer
43REFERFLAGS?=
44REFERDB?=
45PS2PDF?=	ps2pdf13
46PS2PDFFLAGS?=
47
48CLEANFILES?=
49
50all: all-subdir ${DOCPS} ${DOCPDF}
51install: install-doc-dirs install-doc install-subdir
52deinstall: deinstall-subdir
53clean: clean-doc clean-subdir
54cleandir: clean-doc clean-subdir cleandir-subdir
55regress: regress-subdir
56depend: depend-subdir
57
58${DOCPS}: ${DOCSRC} ${REFERDB}
59	@if [ "${REFERDB}" = "" ]; then \
60		echo "cat ${DOCSRC} | ${PIC} ${PICFLAGS}| ${EQN} ${EQNFLAGS}|\
61		    ${TBL} ${TBLFLAGS} | ${REFER} ${REFERFLAGS} |\
62		    ${ROFF} ${ROFFFLAGS} -Tps ${MACROS} > $@"; \
63		(cat ${DOCSRC} | ${PIC} ${PICFLAGS}| ${EQN} ${EQNFLAGS}|\
64		    ${TBL} ${TBLFLAGS} | ${REFER} ${REFERFLAGS} |\
65		    ${ROFF} ${ROFFFLAGS} -Tps ${MACROS} > $@) || \
66		    (rm -f $@; true); \
67	else \
68		echo "cat ${DOCSRC} | ${PIC} ${PICFLAGS}| ${EQN} ${EQNFLAGS}|\
69		    ${TBL} ${TBLFLAGS} | ${REFER} ${REFERFLAGS} -p${REFERDB} |\
70		    ${ROFF} ${ROFFFLAGS} -Tps ${MACROS} > $@"; \
71		(cat ${DOCSRC} | ${PIC} ${PICFLAGS}| ${EQN} ${EQNFLAGS}|\
72		    ${TBL} ${TBLFLAGS} | ${REFER} ${REFERFLAGS} -p${REFERDB} |\
73		    ${ROFF} ${ROFFFLAGS} -Tps ${MACROS} > $@) || \
74		    (rm -f $@; true); \
75	fi
76
77${DOCPDF}: ${DOCPS}
78	(${PS2PDF} ${PS2PDFFLAGS} ${DOCPS} > ${DOCPDF}) || (rm -f $@; true)
79
80clean-doc:
81	rm -f ${DOCPS} ${DOCPDF}
82	@if [ "${CLEANFILES}" != "" ]; then \
83	    echo "rm -f ${CLEANFILES}"; \
84	    rm -f ${CLEANFILES}; \
85	fi
86
87.PHONY: install deinstall clean cleandir regress depend
88.PHONY: clean-doc
89
90include ${TOP}/mk/build.subdir.mk
91include ${TOP}/mk/build.common.mk
92