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