bsd.man.mk: change `mandiff' from groff to nroff
[dragonfly.git] / share / mk / bsd.man.mk
CommitLineData
984263bc
MD
1# $FreeBSD: src/share/mk/bsd.man.mk,v 1.31.2.11 2002/12/19 13:48:33 ru Exp $
2#
3# The include file <bsd.man.mk> handles installing manual pages and
4# their links.
5#
6#
7# +++ variables +++
8#
9# DESTDIR Change the tree where the man pages gets installed. [not set]
10#
11# MANDIR Base path for manual installation. [${SHAREDIR}/man/man]
12#
13# MANOWN Manual owner. [${SHAREOWN}]
14#
15# MANGRP Manual group. [${SHAREGRP}]
16#
17# MANMODE Manual mode. [${NOBINMODE}]
18#
19# MANSUBDIR Subdirectory under the manual page section, i.e. "/i386"
20# or "/tahoe" for machine specific manual pages.
21#
22# MAN The manual pages to be installed. For sections see
23# variable ${SECTIONS}
24#
25# MCOMPRESS_CMD Program to compress man pages. Output is to
26# stdout. [${COMPRESS_CMD}]
27#
28# MLINKS List of manual page links (using a suffix). The
29# linked-to file must come first, the linked file
30# second, and there may be multiple pairs. The files
31# are hard-linked.
32#
33# NOMANCOMPRESS If you do not want unformatted manual pages to be
34# compressed when they are installed. [not set]
35#
36# NOMLINKS If you do not want install manual page links. [not set]
37#
38# MANFILTER command to pipe the raw man page through before compressing
39# or installing. Can be used to do sed substitution.
40#
41# MANBUILDCAT create preformatted manual pages in addition to normal
42# pages. [not set]
43#
44# MROFF_CMD command and flags to create preformatted pages
45#
46# +++ targets +++
47#
48# maninstall:
49# Install the manual pages and their links.
50#
51
52.if !target(__<bsd.init.mk>__)
53.error bsd.man.mk cannot be included directly.
54.endif
55
541c6cb6 56_MANINSTALLFLAGS:= ${MANINSTALLFLAGS}
660232a7
MD
57
58MINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
59 ${_MANINSTALLFLAGS}
984263bc
MD
60
61CATDIR= ${MANDIR:H:S/$/\/cat/}
62CATEXT= .cat
63MROFF_CMD?= groff -Tascii -mtty-char -man -t
64
65MCOMPRESS_CMD?= ${COMPRESS_CMD}
66MCOMPRESS_EXT?= ${COMPRESS_EXT}
67
0bfa4a9b 68SECTIONS= 1 2 3 4 5 6 7 8 9
984263bc
MD
69.SUFFIXES: ${SECTIONS:S/^/./g}
70
71# Backwards compatibility.
72.if !defined(MAN)
73.for sect in ${SECTIONS}
74.if defined(MAN${sect}) && !empty(MAN${sect})
75MAN+= ${MAN${sect}}
76.endif
77.endfor
78.endif
79
80_manpages:
81all-man: _manpages
82
83.if defined(NOMANCOMPRESS)
84
85# Make special arrangements to filter to a temporary file at build time
86# for NOMANCOMPRESS.
87.if defined(MANFILTER)
88FILTEXTENSION= .filt
89.else
90FILTEXTENSION=
91.endif
92
93ZEXT=
94
95.if defined(MANFILTER)
96.if defined(MAN) && !empty(MAN)
97CLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g}
98CLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g}
99.for page in ${MAN}
100.for target in ${page:T:S/$/${FILTEXTENSION}/g}
101_manpages: ${target}
102${target}: ${page}
103 ${MANFILTER} < ${.ALLSRC} > ${.TARGET}
104.endfor
105.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
106.for target in ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g}
107_manpages: ${target}
108${target}: ${page}
109 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET}
110.endfor
111.endif
112.endfor
113.endif
114.else
115.if defined(MAN) && !empty(MAN)
116CLEANFILES+= ${MAN:T:S/$/${CATEXT}/g}
117.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
118.for page in ${MAN}
119.for target in ${page:T:S/$/${CATEXT}/g}
120_manpages: ${target}
121${target}: ${page}
122 ${MROFF_CMD} ${.ALLSRC} > ${.TARGET}
123.endfor
124.endfor
125.else
126_manpages: ${MAN}
127.endif
128.endif
129.endif
130
131.else
132
133ZEXT= ${MCOMPRESS_EXT}
134
135.if defined(MAN) && !empty(MAN)
136CLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g}
137CLEANFILES+= ${MAN:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g}
138.for page in ${MAN}
139.for target in ${page:T:S/$/${MCOMPRESS_EXT}/}
140_manpages: ${target}
141${target}: ${page}
142.if defined(MANFILTER)
143 ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
144.else
145 ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
146.endif
147.endfor
148.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
149.for target in ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/}
150_manpages: ${target}
151${target}: ${page}
152.if defined(MANFILTER)
153 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET}
154.else
155 ${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
156.endif
157.endfor
158.endif
159.endfor
160.endif
161
162.endif
163
164maninstall: _maninstall
165_maninstall:
166.if defined(MAN) && !empty(MAN)
167_maninstall: ${MAN}
168.if defined(NOMANCOMPRESS)
169.if defined(MANFILTER)
170.for page in ${MAN}
171 ${MINSTALL} ${page:T:S/$/${FILTEXTENSION}/g} \
172 ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page}
173.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
174 ${MINSTALL} ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
175 ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page}
176.endif
177.endfor
178.else
179 @set `echo ${.ALLSRC} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
180 while : ; do \
181 case $$# in \
182 0) break;; \
183 1) echo "warn: missing extension: $$1"; break;; \
184 esac; \
185 page=$$1; shift; sect=$$1; shift; \
186 d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
187 ${ECHO} ${MINSTALL} $${page} $${d}; \
188 ${MINSTALL} $${page} $${d}; \
189 done
190.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
191.for page in ${MAN}
192 ${MINSTALL} ${page:T:S/$/${CATEXT}/} \
193 ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T}
194.endfor
195.endif
196.endif
197.else
198.for page in ${MAN}
199 ${MINSTALL} ${page:T:S/$/${MCOMPRESS_EXT}/g} \
200 ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}
201.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
202 ${MINSTALL} ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
203 ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/}
204.endif
205.endfor
206.endif
207.endif
208
209.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS)
210 @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
211 while : ; do \
212 case $$# in \
213 0) break;; \
214 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
215 esac; \
216 name=$$1; shift; sect=$$1; shift; \
217 l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
218 name=$$1; shift; sect=$$1; shift; \
219 t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
220 ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
221 rm -f $${t} $${t}${MCOMPRESS_EXT}; \
062db326 222 ${LN} $${l}${ZEXT} $${t}${ZEXT}; \
984263bc
MD
223 done
224.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
225 @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
226 while : ; do \
227 case $$# in \
228 0) break;; \
229 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
230 esac; \
231 name=$$1; shift; sect=$$1; shift; \
232 l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
233 name=$$1; shift; sect=$$1; shift; \
234 t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
235 ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
236 rm -f $${t} $${t}${MCOMPRESS_EXT}; \
062db326 237 ${LN} $${l}${ZEXT} $${t}${ZEXT}; \
984263bc
MD
238 done
239.endif
240.endif
241
242manlint:
18cdb849 243mandiff:
984263bc
MD
244.if defined(MAN) && !empty(MAN)
245.for page in ${MAN}
246manlint: ${page}lint
18cdb849 247mandiff: ${page}diff
984263bc
MD
248${page}lint: ${page}
249.if defined(MANFILTER)
7a4f6f2e 250 @${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} -ww -z
74f1ddfc 251 @-${MANFILTER} < ${.ALLSRC} | mandoc -Tlint
984263bc 252.else
7a4f6f2e 253 @${MROFF_CMD} -ww -z ${.ALLSRC}
74f1ddfc 254 @-mandoc -Tlint ${.ALLSRC}
984263bc 255.endif
18cdb849 256${page}.out.groff: ${page}
4f2a280c 257 @-nroff -man -t ${.ALLSRC} 2>&1 > ${.TARGET}
18cdb849
FF
258${page}.out.mandoc: ${page}
259 @-mandoc -Werror ${.ALLSRC} 2>&1 > ${.TARGET}
260${page}diff: ${page}.out.groff ${page}.out.mandoc
261 @-diff -au ${.ALLSRC}
262 @rm ${.ALLSRC}
984263bc
MD
263.endfor
264.endif