turns printfs back on
[freebsd-src/fkvm-freebsd.git] / share / mk / bsd.man.mk
blob8602b55f21792bb6ab2a82cac08730bd976809c7
1 # $FreeBSD$
3 # The include file <bsd.man.mk> handles installing manual pages and
4 # their links.
7 # +++ variables +++
9 # DESTDIR Change the tree where the man pages gets installed. [not set]
11 # MANDIR Base path for manual installation. [${SHAREDIR}/man/man]
13 # MANOWN Manual owner. [${SHAREOWN}]
15 # MANGRP Manual group. [${SHAREGRP}]
17 # MANMODE Manual mode. [${NOBINMODE}]
19 # MANSUBDIR Subdirectory under the manual page section, i.e. "/i386"
20 # or "/tahoe" for machine specific manual pages.
22 # MAN The manual pages to be installed. For sections see
23 # variable ${SECTIONS}
25 # MCOMPRESS_CMD Program to compress man pages. Output is to
26 # stdout. [${COMPRESS_CMD}]
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.
33 # NO_MANCOMPRESS If you do not want unformatted manual pages to be
34 # compressed when they are installed. [not set]
36 # NO_MLINKS If you do not want install manual page links. [not set]
38 # MANFILTER command to pipe the raw man page through before compressing
39 # or installing. Can be used to do sed substitution.
41 # MANBUILDCAT create preformatted manual pages in addition to normal
42 # pages. [not set]
44 # MROFF_CMD command and flags to create preformatted pages
46 # +++ targets +++
48 # maninstall:
49 # Install the manual pages and their links.
52 .if !target(__<bsd.init.mk>__)
53 .error bsd.man.mk cannot be included directly.
54 .endif
56 MINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
58 CATDIR= ${MANDIR:H:S/$/\/cat/}
59 CATEXT= .cat
60 MROFF_CMD?= groff -Tascii -mtty-char -man -t
62 MCOMPRESS_CMD?= ${COMPRESS_CMD}
63 MCOMPRESS_EXT?= ${COMPRESS_EXT}
65 SECTIONS= 1 1aout 2 3 4 5 6 7 8 9
66 .SUFFIXES: ${SECTIONS:S/^/./g}
68 # Backwards compatibility.
69 .if !defined(MAN)
70 .for __sect in ${SECTIONS}
71 .if defined(MAN${__sect}) && !empty(MAN${__sect})
72 MAN+= ${MAN${__sect}}
73 .endif
74 .endfor
75 .endif
77 _manpages:
78 all-man: _manpages
80 .if defined(NO_MANCOMPRESS)
82 # Make special arrangements to filter to a temporary file at build time
83 # for NO_MANCOMPRESS.
84 .if defined(MANFILTER)
85 FILTEXTENSION= .filt
86 .else
87 FILTEXTENSION=
88 .endif
90 ZEXT=
92 .if defined(MANFILTER)
93 .if defined(MAN) && !empty(MAN)
94 CLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g}
95 CLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g}
96 .for __page in ${MAN}
97 .for __target in ${__page:T:S/$/${FILTEXTENSION}/g}
98 _manpages: ${__target}
99 ${__target}: ${__page}
100 ${MANFILTER} < ${.ALLSRC} > ${.TARGET}
101 .endfor
102 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
103 .for __target in ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g}
104 _manpages: ${__target}
105 ${__target}: ${__page}
106 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET}
107 .endfor
108 .endif
109 .endfor
110 .endif
111 .else
112 .if defined(MAN) && !empty(MAN)
113 CLEANFILES+= ${MAN:T:S/$/${CATEXT}/g}
114 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
115 .for __page in ${MAN}
116 .for __target in ${__page:T:S/$/${CATEXT}/g}
117 _manpages: ${__target}
118 ${__target}: ${__page}
119 ${MROFF_CMD} ${.ALLSRC} > ${.TARGET}
120 .endfor
121 .endfor
122 .else
123 _manpages: ${MAN}
124 .endif
125 .endif
126 .endif
128 .else
130 ZEXT= ${MCOMPRESS_EXT}
132 .if defined(MAN) && !empty(MAN)
133 CLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g}
134 CLEANFILES+= ${MAN:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g}
135 .for __page in ${MAN}
136 .for __target in ${__page:T:S/$/${MCOMPRESS_EXT}/}
137 _manpages: ${__target}
138 ${__target}: ${__page}
139 .if defined(MANFILTER)
140 ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
141 .else
142 ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
143 .endif
144 .endfor
145 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
146 .for __target in ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/}
147 _manpages: ${__target}
148 ${__target}: ${__page}
149 .if defined(MANFILTER)
150 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET}
151 .else
152 ${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
153 .endif
154 .endfor
155 .endif
156 .endfor
157 .endif
159 .endif
161 maninstall: _maninstall
162 _maninstall:
163 .if defined(MAN) && !empty(MAN)
164 _maninstall: ${MAN}
165 .if defined(NO_MANCOMPRESS)
166 .if defined(MANFILTER)
167 .for __page in ${MAN}
168 ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \
169 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page}
170 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
171 ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
172 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
173 .endif
174 .endfor
175 .else
176 @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \
177 while : ; do \
178 case $$# in \
179 0) break;; \
180 1) echo "warn: missing extension: $$1"; break;; \
181 esac; \
182 page=$$1; shift; sect=$$1; shift; \
183 d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
184 ${ECHO} ${MINSTALL} $${page} $${d}; \
185 ${MINSTALL} $${page} $${d}; \
186 done
187 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
188 .for __page in ${MAN}
189 ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
190 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
191 .endfor
192 .endif
193 .endif
194 .else
195 .for __page in ${MAN}
196 ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
197 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}
198 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
199 ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
200 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
201 .endif
202 .endfor
203 .endif
204 .endif
206 .if !defined(NO_MLINKS) && defined(MLINKS) && !empty(MLINKS)
207 @set ${MLINKS:C/\.([^.]*)$/.\1 \1/}; \
208 while : ; do \
209 case $$# in \
210 0) break;; \
211 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
212 esac; \
213 name=$$1; shift; sect=$$1; shift; \
214 l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
215 name=$$1; shift; sect=$$1; shift; \
216 t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
217 ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
218 rm -f $${t} $${t}${MCOMPRESS_EXT}; \
219 ln $${l}${ZEXT} $${t}${ZEXT}; \
220 done
221 .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
222 @set ${MLINKS:C/\.([^.]*)$/.\1 \1/}; \
223 while : ; do \
224 case $$# in \
225 0) break;; \
226 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
227 esac; \
228 name=$$1; shift; sect=$$1; shift; \
229 l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
230 name=$$1; shift; sect=$$1; shift; \
231 t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
232 ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
233 rm -f $${t} $${t}${MCOMPRESS_EXT}; \
234 ln $${l}${ZEXT} $${t}${ZEXT}; \
235 done
236 .endif
237 .endif
239 manlint:
240 .if defined(MAN) && !empty(MAN)
241 .for __page in ${MAN}
242 manlint: ${__page}lint
243 ${__page}lint: ${__page}
244 .if defined(MANFILTER)
245 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} -ww -z
246 .else
247 ${MROFF_CMD} -ww -z ${.ALLSRC}
248 .endif
249 .endfor
250 .endif