xref: /freebsd/share/mk/bsd.doc.mk (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1#	from: @(#)bsd.doc.mk	5.3 (Berkeley) 1/2/91
2#
3# The include file <bsd.doc.mk> handles installing BSD troff documents.
4#
5#
6# +++ variables +++
7#
8# DCOMPRESS_CMD	Program to compress troff documents.  Output is to stdout.
9#		[${COMPRESS_CMD}]
10#
11# DESTDIR	Change the tree where the documents get installed.  [not set]
12#
13# DOC		Document name.  [paper]
14#
15# EXTRA		Extra files (not SRCS) that make up the document.  [not set]
16#
17# LPR		Printer command.  [lpr]
18#
19# MACROS	Macro packages used to build the document.  [not set]
20#
21# WITHOUT_DOCCOMPRESS If you do not want formatted troff documents to be
22#		compressed when they are installed.  [not set]
23#
24# PRINTERDEVICE	Indicates which output formats will be generated
25#		(ascii, ps, html).  [ascii]
26#
27# SRCDIR	Directory where source files live.  [${.CURDIR}]
28#
29# SRCS		List of source files.  [not set]
30#
31# TRFLAGS	Additional flags to groff(1).  [not set]
32#
33# USE_EQN	If set, preprocess with eqn(1).  [not set]
34#
35# USE_PIC	If set, preprocess with pic(1).  [not set]
36#
37# USE_REFER	If set, preprocess with refer(1).  [not set]
38#
39# USE_SOELIM	If set, preprocess with soelim(1).  [not set]
40#
41# USE_TBL	If set, preprocess with tbl(1).  [not set]
42#
43# VOLUME	Volume the document belongs to.  [not set]
44
45.include <bsd.init.mk>
46
47PRINTERDEVICE?=	ascii
48
49BIB?=		bib
50GREMLIN?=	grn
51GRIND?=		vgrind -f
52INDXBIB?=	indxbib
53PIC?=		pic
54REFER?=		refer
55.for _dev in ${PRINTERDEVICE:Mascii}
56ROFF.ascii?=	groff -Tascii -P-c ${TRFLAGS} -mtty-char ${MACROS} ${PAGES:C/^/-o/1}
57.endfor
58.for _dev in ${PRINTERDEVICE:Nascii}
59ROFF.${_dev}?=	groff -T${_dev} ${TRFLAGS} ${MACROS} ${PAGES:C/^/-o/1}
60.endfor
61SOELIM?=	soelim
62TBL?=		tbl
63
64DOC?=		paper
65LPR?=		lpr
66
67.if defined(USE_EQN)
68TRFLAGS+=	-e
69.endif
70.if defined(USE_PIC)
71TRFLAGS+=	-p
72.endif
73.if defined(USE_REFER)
74TRFLAGS+=	-R
75.endif
76.if defined(USE_SOELIM)
77TRFLAGS+=	-I${.CURDIR}
78.endif
79.if defined(USE_TBL)
80TRFLAGS+=	-t
81.endif
82
83.if defined(NO_ROOT)
84.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
85TAGS+=		package=${PACKAGE:Uutilities}
86.endif
87TAG_ARGS=	-T ${TAGS:[*]:S/ /,/g}
88.endif
89
90DCOMPRESS_EXT?=	${COMPRESS_EXT}
91DCOMPRESS_CMD?=	${COMPRESS_CMD}
92.for _dev in ${PRINTERDEVICE:Mhtml}
93DFILE.html=	${DOC}.html
94.endfor
95.for _dev in ${PRINTERDEVICE:Nhtml}
96.if ${MK_DOCCOMPRESS} == "no"
97DFILE.${_dev}=	${DOC}.${_dev}
98.else
99DFILE.${_dev}=	${DOC}.${_dev}${DCOMPRESS_EXT}
100.endif
101.endfor
102
103UNROFF?=	unroff
104HTML_SPLIT?=	yes
105UNROFFFLAGS?=	-fhtml
106.if ${HTML_SPLIT} == "yes"
107UNROFFFLAGS+=	split=1
108.endif
109
110# Compatibility mode flag for groff.  Use this when formatting documents with
111# Berkeley me macros (orig_me(7)).
112COMPAT?=	-C
113
114.PATH: ${.CURDIR} ${SRCDIR}
115
116.if !defined(_SKIP_BUILD)
117.for _dev in ${PRINTERDEVICE}
118all: ${DFILE.${_dev}}
119.endfor
120.endif
121
122.if !target(print)
123.for _dev in ${PRINTERDEVICE}
124print: ${DFILE.${_dev}}
125.endfor
126print:
127.for _dev in ${PRINTERDEVICE}
128.if ${MK_DOCCOMPRESS} == "no"
129	${LPR} ${DFILE.${_dev}}
130.else
131	${DCOMPRESS_CMD} -d ${DFILE.${_dev}} | ${LPR}
132.endif
133.endfor
134.endif
135
136.for _dev in ${PRINTERDEVICE:Nascii:Nps:Nhtml}
137CLEANFILES+=	${DOC}.${_dev} ${DOC}.${_dev}${DCOMPRESS_EXT}
138.endfor
139CLEANFILES+=	${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
140		${DOC}.ps ${DOC}.ps${DCOMPRESS_EXT} \
141		${DOC}.html ${DOC}-*.html
142
143realinstall:
144.if ${PRINTERDEVICE:Mhtml}
145	cd ${SRCDIR}; \
146	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
147	    ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}/
148.endif
149.for _dev in ${PRINTERDEVICE:Nhtml}
150	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
151	    ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}/
152.endfor
153
154spell: ${SRCS}
155	(cd ${.CURDIR}; spell ${SRCS} ) | sort | \
156		comm -23 - ${.CURDIR}/spell.ok > ${DOC}.spell
157
158BINDIR?=	/usr/share/doc
159BINMODE=	444
160
161SRCDIR?=	${.CURDIR}
162
163.if defined(EXTRA) && !empty(EXTRA)
164_stamp.extra: ${EXTRA}
165	touch ${.TARGET}
166.endif
167
168CLEANFILES+=	_stamp.extra
169.for _dev in ${PRINTERDEVICE:Nhtml}
170.if !target(${DFILE.${_dev}})
171.if target(_stamp.extra)
172${DFILE.${_dev}}: _stamp.extra
173.endif
174${DFILE.${_dev}}: ${SRCS}
175.if ${MK_DOCCOMPRESS} == "no"
176	${ROFF.${_dev}} ${.ALLSRC:N_stamp.extra} > ${.TARGET}
177.else
178	${ROFF.${_dev}} ${.ALLSRC:N_stamp.extra} | ${DCOMPRESS_CMD} > ${.TARGET}
179.endif
180.endif
181.endfor
182
183.for _dev in ${PRINTERDEVICE:Mhtml}
184.if !target(${DFILE.html})
185.if target(_stamp.extra)
186${DFILE.html}: _stamp.extra
187.endif
188${DFILE.html}: ${SRCS}
189.if defined(MACROS) && !empty(MACROS)
190	cd ${SRCDIR}; ${UNROFF} ${MACROS} ${UNROFFFLAGS} \
191	    document=${DOC} ${SRCS}
192.else # unroff(1) requires a macro package as an argument
193	cd ${SRCDIR}; ${UNROFF} -ms ${UNROFFFLAGS} \
194	    document=${DOC} ${SRCS}
195.endif
196.endif
197.endfor
198
199DISTRIBUTION?=	doc
200
201.include <bsd.obj.mk>
202