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