mkfs: drop support for zone != block
[minix.git] / share / mk / bsd.man.mk
blobcda2dcf22abead4754a001022ab33fd404dac39f
1 # $NetBSD: bsd.man.mk,v 1.102 2009/10/23 23:12:10 joerg Exp $
2 # @(#)bsd.man.mk 8.1 (Berkeley) 6/8/93
4 .include <bsd.init.mk>
6 MKCATPAGES := no
7 MKHTML := no
9 ##### Basic targets
10 .PHONY: catinstall maninstall catpages manpages catlinks manlinks
11 .PHONY: htmlinstall htmlpages htmllinks
12 .if ${MKMANDOC} == "yes"
13 .PHONY: lintmanpages
14 .endif
15 realinstall: ${MANINSTALL}
17 ##### Default values
18 .if ${USETOOLS} == "yes"
19 TMACDEPDIR?= ${TOOLDIR}/share/groff/tmac
20 .else
21 TMACDEPDIR?= /usr/share/tmac
22 .endif
24 HTMLDIR?= ${DESTDIR}${MANDIR}
25 CATDEPS?= ${TMACDEPDIR}/andoc.tmac \
26 ${TMACDEPDIR}/doc.tmac \
27 ${TMACDEPDIR}/mdoc/doc-common \
28 ${TMACDEPDIR}/mdoc/doc-ditroff \
29 ${TMACDEPDIR}/mdoc/doc-nroff \
30 ${TMACDEPDIR}/mdoc/doc-syms
31 HTMLDEPS?= ${TMACDEPDIR}/doc2html.tmac
32 MANTARGET?= cat
34 MAN?=
35 MLINKS?=
36 _MNUMBERS= 1 2 3 4 5 6 7 8 9
37 .SUFFIXES: ${_MNUMBERS:@N@.$N@}
39 .if ${MKMANZ} == "no"
40 MANCOMPRESS?=
41 MANSUFFIX?=
42 .else
43 MANCOMPRESS?= gzip -ncf
44 MANSUFFIX?= .gz
45 .endif
47 # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
48 .if !empty(MANCOMPRESS)
49 MANCOMPRESS:= | ${MANCOMPRESS}
50 .endif
52 __installpage: .USE
53 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
54 (${_MKSHMSG_INSTALL} ${.TARGET}; \
55 ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
56 ${.ALLSRC} ${.TARGET}" && \
57 ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
58 ${.ALLSRC} ${.TARGET})
60 # XXX consider including bsd.links.mk and using __linkinstall instead
61 __linkinstallpage: .USE
62 ${_MKSHMSG_INSTALL} ${.TARGET}; \
63 ${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
64 ${.ALLSRC} ${.TARGET}" && \
65 ${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
66 ${.ALLSRC} ${.TARGET}
68 ##### Build and install rules (source form pages)
70 .if ${MKMAN} != "no"
71 maninstall: manpages manlinks
72 manpages:: # ensure target exists
73 MANPAGES= ${MAN:C/.$/&${MANSUFFIX}/}
75 realall: ${MANPAGES}
76 .if !empty(MANSUFFIX)
77 .NOPATH: ${MANPAGES}
78 .SUFFIXES: ${_MNUMBERS:@N@.$N${MANSUFFIX}@}
80 ${_MNUMBERS:@N@.$N.$N${MANSUFFIX}@}: # build rule
81 ${_MKTARGET_FORMAT}
82 cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
83 .endif # !empty(MANSUFFIX)
85 .for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u}
86 _F:= ${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX}
88 .if ${MKUPDATE} == "no"
89 ${_F}! ${F}${MANSUFFIX} __installpage # install rule
90 .if !defined(BUILD) && !make(all) && !make(${F})
91 ${_F}! .MADE # no build at install
92 .endif
93 .else
94 ${_F}: ${F}${MANSUFFIX} __installpage # install rule
95 .if !defined(BUILD) && !make(all) && !make(${F})
96 ${_F}: .MADE # no build at install
97 .endif
98 .endif
100 manpages:: ${_F}
101 .PRECIOUS: ${_F} # keep if install fails
102 .endfor
104 manlinks:: # link install
106 .for _src _dst in ${MLINKS}
107 _l:=${DESTDIR}${MANDIR}/man${_src:T:E}${MANSUBDIR}/${_src}${MANSUFFIX}
108 _t:=${DESTDIR}${MANDIR}/man${_dst:T:E}${MANSUBDIR}/${_dst}${MANSUFFIX}
110 # Handle case conflicts carefully, when _dst occurs
111 # more than once after case flattening
112 .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
113 ${_t}! ${_l} __linkinstallpage
114 .else
115 ${_t}: ${_l} __linkinstallpage
116 .endif
118 manlinks:: ${_t}
119 .PRECIOUS: ${_t}
120 .endfor
121 .endif # ${MKMAN} != "no"
123 ##### Build and install rules (plaintext pages)
125 .if (${MKCATPAGES} != "no") && (${MKMAN} != "no")
126 catinstall: catpages catlinks
127 catpages:: # ensure target exists
128 CATPAGES= ${MAN:C/\.([1-9])$/.cat\1${MANSUFFIX}/}
130 realall: ${CATPAGES}
131 .NOPATH: ${CATPAGES}
132 .SUFFIXES: ${_MNUMBERS:@N@.cat$N${MANSUFFIX}@}
133 .MADE: ${CATDEPS}
135 ${_MNUMBERS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS} # build rule
136 ${_MKTARGET_FORMAT}
137 .if defined(USETBL)
138 ${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_ASCII} -mandoc ${MANCOMPRESS} \
139 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
140 .elif ${MKMANDOC} == yes && !defined(NOMANDOC)
141 if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
142 ${TOOL_MANDOC_ASCII} ${.IMPSRC} ${MANCOMPRESS} \
143 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \
144 else \
145 ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
146 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \
148 .else
149 ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
150 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
151 .endif
153 .for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u}
154 _F:= ${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX}
156 .if ${MKUPDATE} == "no"
157 ${_F}! ${F}${MANSUFFIX} __installpage # install rule
158 .if !defined(BUILD) && !make(all) && !make(${F})
159 ${_F}! .MADE # no build at install
160 .endif
161 .else
162 ${_F}: ${F}${MANSUFFIX} __installpage # install rule
163 .if !defined(BUILD) && !make(all) && !make(${F})
164 ${_F}: .MADE # no build at install
165 .endif
166 .endif
168 catpages:: ${_F}
169 .PRECIOUS: ${_F} # keep if install fails
170 .endfor
172 catlinks:: # link install
174 .for _src _dst in ${MLINKS}
175 _l:=${DESTDIR}${MANDIR}/cat${_src:T:E}${MANSUBDIR}/${_src:R}.0${MANSUFFIX}
176 _t:=${DESTDIR}${MANDIR}/cat${_dst:T:E}${MANSUBDIR}/${_dst:R}.0${MANSUFFIX}
178 # Handle case conflicts carefully, when _dst occurs
179 # more than once after case flattening
180 .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
181 ${_t}! ${_l} __linkinstallpage
182 .else
183 ${_t}: ${_l} __linkinstallpage
184 .endif
186 catlinks:: ${_t}
187 .PRECIOUS: ${_t}
188 .endfor
189 .endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
191 ##### Build and install rules (HTML pages)
193 .if (${MKHTML} != "no") && (${MKMAN} != "no") # {
194 htmlinstall: htmlpages htmllinks
195 htmlpages:: # ensure target exists
196 HTMLPAGES= ${MAN:C/\.([1-9])$/.html\1/}
198 realall: ${HTMLPAGES}
199 .NOPATH: ${HTMLPAGES}
200 .SUFFIXES: ${_MNUMBERS:@N@.html$N@}
201 .MADE: ${HTMLDEPS}
203 ${_MNUMBERS:@N@.$N.html$N@}: ${HTMLDEPS} # build rule
204 ${_MKTARGET_FORMAT}
205 .if ${MKMANDOC} == "yes" && !defined(NOMANDOC)
206 if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
207 ${TOOL_MANDOC_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \
208 mv ${.TARGET}.tmp ${.TARGET}; \
209 else \
210 ${TOOL_ROFF_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \
211 mv ${.TARGET}.tmp ${.TARGET}; \
213 .else
214 ${TOOL_ROFF_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \
215 mv ${.TARGET}.tmp ${.TARGET}
216 .endif
218 .for F in ${HTMLPAGES:O:u}
219 # construct installed path
220 _F:= ${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html
222 .if ${MKUPDATE} == "no"
223 ${_F}! ${F} __installpage # install rule
224 .if !defined(BUILD) && !make(all) && !make(${F})
225 ${_F}! .MADE # no build at install
226 .endif
227 .else
228 ${_F}: ${F} __installpage # install rule
229 .if !defined(BUILD) && !make(all) && !make(${F})
230 ${_F}: .MADE # no build at install
231 .endif
232 .endif
234 htmlpages:: ${_F}
235 .PRECIOUS: ${_F} # keep if install fails
236 .endfor
238 htmllinks:: # link install
240 .for _src _dst in ${MLINKS}
241 _l:=${HTMLDIR}/html${_src:T:E}${MANSUBDIR}/${_src:R:S-/index$-/x&-}.html
242 _t:=${HTMLDIR}/html${_dst:T:E}${MANSUBDIR}/${_dst:R:S-/index$-/x&-}.html
244 # Handle case conflicts carefully, when _dst occurs
245 # more than once after case flattening
246 .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
247 ${_t}! ${_l} __linkinstallpage
248 .else
249 ${_t}: ${_l} __linkinstallpage
250 .endif
252 htmllinks:: ${_t}
253 .PRECIOUS: ${_t}
254 .endfor
256 .endif # }
258 ##### Clean rules
259 .undef _F
261 cleandir: cleanman
262 .if !empty(CLEANFILES)
263 rm -f ${CLEANFILES}
264 .endif
266 cleanman: .PHONY
267 .if !empty(MAN) && (${MKMAN} != "no")
268 .if (${MKCATPAGES} != "no")
269 rm -f ${CATPAGES}
270 .endif
271 .if !empty(MANSUFFIX)
272 rm -f ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//}
273 .endif
274 .if ${MKHTML} != "no"
275 rm -f ${HTMLPAGES}
276 .endif
277 .endif
278 # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
280 .if ${MKMANDOC} == "yes" && !empty(MANPAGES)
281 lintmanpages: ${MANPAGES}
282 ${TOOL_MANDOC_LINT} -Tlint -fstrict ${.ALLSRC}
283 .endif
285 ##### Pull in related .mk logic
286 .include <bsd.obj.mk>
287 .include <bsd.files.mk>
288 .include <bsd.sys.mk>
290 ${TARGETS} catinstall maninstall htmlinstall: # ensure existence