include: reduce default stack size
[minix.git] / share / mk / bsd.man.mk
blobcc1b037cde23af99147c4dc22b1043d84f7c25f8
1 # $NetBSD: bsd.man.mk,v 1.109 2011/09/10 16:57:35 apb Exp $
2 # @(#)bsd.man.mk 8.1 (Berkeley) 6/8/93
4 .include <bsd.init.mk>
6 ##### Basic targets
7 .PHONY: catinstall maninstall catpages manpages catlinks manlinks
8 .PHONY: htmlinstall htmlpages htmllinks
9 .PHONY: lintmanpages
10 realinstall: ${MANINSTALL}
12 ##### Default values
13 .if ${USETOOLS} == "yes"
14 TMACDEPDIR?= ${TOOLDIR}/share/groff/tmac
15 .else
16 TMACDEPDIR?= /usr/share/tmac
17 .endif
19 HTMLDIR?= ${DESTDIR}${MANDIR}
20 CATDEPS?= ${TMACDEPDIR}/andoc.tmac \
21 ${TMACDEPDIR}/doc.tmac \
22 ${TMACDEPDIR}/mdoc/doc-common \
23 ${TMACDEPDIR}/mdoc/doc-ditroff \
24 ${TMACDEPDIR}/mdoc/doc-nroff \
25 ${TMACDEPDIR}/mdoc/doc-syms
26 MANTARGET?= cat
28 MAN?=
29 MLINKS?=
30 _MNUMBERS= 1 2 3 4 5 6 7 8 9
31 .SUFFIXES: ${_MNUMBERS:@N@.$N@}
33 .if ${MKMANZ} == "no"
34 MANCOMPRESS?=
35 MANSUFFIX?=
36 .else
37 MANCOMPRESS?= ${TOOL_GZIP} -ncf
38 MANSUFFIX?= .gz
39 .endif
41 # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
42 .if !empty(MANCOMPRESS)
43 MANCOMPRESS:= | ${MANCOMPRESS}
44 .endif
46 __installpage: .USE
47 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
48 (${_MKSHMSG_INSTALL} ${.TARGET}; \
49 ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
50 ${.ALLSRC} ${.TARGET}" && \
51 ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
52 ${.ALLSRC} ${.TARGET})
54 # XXX consider including bsd.links.mk and using __linkinstall instead
55 __linkinstallpage: .USE
56 ${_MKSHMSG_INSTALL} ${.TARGET}; \
57 ${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
58 ${.ALLSRC} ${.TARGET}" && \
59 ${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
60 ${.ALLSRC} ${.TARGET}
62 ##### Build and install rules (source form pages)
64 .if ${MKMAN} != "no"
65 maninstall: manpages manlinks
66 manpages:: # ensure target exists
67 MANPAGES= ${MAN:C/.$/&${MANSUFFIX}/}
69 realall: ${MANPAGES}
70 .if !empty(MANSUFFIX)
71 .NOPATH: ${MANPAGES}
72 .SUFFIXES: ${_MNUMBERS:@N@.$N${MANSUFFIX}@}
74 ${_MNUMBERS:@N@.$N.$N${MANSUFFIX}@}: # build rule
75 ${_MKTARGET_FORMAT}
76 cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
77 .endif # !empty(MANSUFFIX)
79 .for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u}
80 _F:= ${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX}
82 .if ${MKUPDATE} == "no"
83 ${_F}! ${F}${MANSUFFIX} __installpage # install rule
84 .if !defined(BUILD) && !make(all) && !make(${F})
85 ${_F}! .MADE # no build at install
86 .endif
87 .else
88 ${_F}: ${F}${MANSUFFIX} __installpage # install rule
89 .if !defined(BUILD) && !make(all) && !make(${F})
90 ${_F}: .MADE # no build at install
91 .endif
92 .endif
94 manpages:: ${_F}
95 .PRECIOUS: ${_F} # keep if install fails
96 .endfor
98 manlinks:: # link install
100 .for _src _dst in ${MLINKS}
101 _l:=${DESTDIR}${MANDIR}/man${_src:T:E}${MANSUBDIR}/${_src}${MANSUFFIX}
102 _t:=${DESTDIR}${MANDIR}/man${_dst:T:E}${MANSUBDIR}/${_dst}${MANSUFFIX}
104 # Handle case conflicts carefully, when _dst occurs
105 # more than once after case flattening
106 .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
107 ${_t}! ${_l} __linkinstallpage
108 .else
109 ${_t}: ${_l} __linkinstallpage
110 .endif
112 manlinks:: ${_t}
113 .PRECIOUS: ${_t}
114 .endfor
115 .endif # ${MKMAN} != "no"
117 ##### Build and install rules (plaintext pages)
119 .if (${MKCATPAGES} != "no") && (${MKMAN} != "no")
120 catinstall: catpages catlinks
121 catpages:: # ensure target exists
122 CATPAGES= ${MAN:C/\.([1-9])$/.cat\1${MANSUFFIX}/}
124 realall: ${CATPAGES}
125 .NOPATH: ${CATPAGES}
126 .SUFFIXES: ${_MNUMBERS:@N@.cat$N${MANSUFFIX}@}
127 .MADE: ${CATDEPS}
129 ${_MNUMBERS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS} # build rule
130 ${_MKTARGET_FORMAT}
131 .if ${MKMANDOC} == yes && !defined(NOMANDOC)
132 if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
133 ${TOOL_MANDOC_ASCII} ${.IMPSRC} ${MANCOMPRESS} \
134 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \
135 else \
136 ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
137 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \
139 .elif defined(USETBL)
140 ${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_ASCII} -mandoc ${MANCOMPRESS} \
141 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
142 .else
143 ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
144 > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
145 .endif
147 .for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u}
148 _F:= ${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX}
150 .if ${MKUPDATE} == "no"
151 ${_F}! ${F}${MANSUFFIX} __installpage # install rule
152 .if !defined(BUILD) && !make(all) && !make(${F})
153 ${_F}! .MADE # no build at install
154 .endif
155 .else
156 ${_F}: ${F}${MANSUFFIX} __installpage # install rule
157 .if !defined(BUILD) && !make(all) && !make(${F})
158 ${_F}: .MADE # no build at install
159 .endif
160 .endif
162 catpages:: ${_F}
163 .PRECIOUS: ${_F} # keep if install fails
164 .endfor
166 catlinks:: # link install
168 .for _src _dst in ${MLINKS}
169 _l:=${DESTDIR}${MANDIR}/cat${_src:T:E}${MANSUBDIR}/${_src:R}.0${MANSUFFIX}
170 _t:=${DESTDIR}${MANDIR}/cat${_dst:T:E}${MANSUBDIR}/${_dst:R}.0${MANSUFFIX}
172 # Handle case conflicts carefully, when _dst occurs
173 # more than once after case flattening
174 .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
175 ${_t}! ${_l} __linkinstallpage
176 .else
177 ${_t}: ${_l} __linkinstallpage
178 .endif
180 catlinks:: ${_t}
181 .PRECIOUS: ${_t}
182 .endfor
183 .endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
185 ##### Build and install rules (HTML pages)
187 .if (${MKHTML} != "no") && (${MKMAN} != "no") # {
188 htmlinstall: htmlpages htmllinks
189 htmlpages:: # ensure target exists
190 HTMLPAGES= ${MAN:C/\.([1-9])$/.html\1/}
192 HTMLLINKS= ${MANSUBDIR:?../:}../html%S/%N.html
193 HTMLSTYLE= ${MANSUBDIR:?../:}../style.css
195 realall: ${HTMLPAGES}
196 .NOPATH: ${HTMLPAGES}
197 .SUFFIXES: ${_MNUMBERS:@N@.html$N@}
199 ${_MNUMBERS:@N@.$N.html$N@}: # build rule
200 ${_MKTARGET_FORMAT}
201 ${TOOL_MANDOC_HTML} -Oman=${HTMLLINKS} -Ostyle=${HTMLSTYLE} \
202 ${.IMPSRC} > ${.TARGET}.tmp && \
203 mv ${.TARGET}.tmp ${.TARGET}
205 .for F in ${HTMLPAGES:O:u}
206 # construct installed path
207 _F:= ${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html
209 .if ${MKUPDATE} == "no"
210 ${_F}! ${F} __installpage # install rule
211 .if !defined(BUILD) && !make(all) && !make(${F})
212 ${_F}! .MADE # no build at install
213 .endif
214 .else
215 ${_F}: ${F} __installpage # install rule
216 .if !defined(BUILD) && !make(all) && !make(${F})
217 ${_F}: .MADE # no build at install
218 .endif
219 .endif
221 htmlpages:: ${_F}
222 .PRECIOUS: ${_F} # keep if install fails
223 .endfor
225 htmllinks:: # link install
227 .for _src _dst in ${MLINKS}
228 _l:=${HTMLDIR}/html${_src:T:E}${MANSUBDIR}/${_src:R:S-/index$-/x&-}.html
229 _t:=${HTMLDIR}/html${_dst:T:E}${MANSUBDIR}/${_dst:R:S-/index$-/x&-}.html
231 # Handle case conflicts carefully, when _dst occurs
232 # more than once after case flattening
233 .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
234 ${_t}! ${_l} __linkinstallpage
235 .else
236 ${_t}: ${_l} __linkinstallpage
237 .endif
239 htmllinks:: ${_t}
240 .PRECIOUS: ${_t}
241 .endfor
243 .endif # }
245 ##### Clean rules
246 .undef _F
248 .if !empty(MAN) && (${MKMAN} != "no")
249 .if (${MKCATPAGES} != "no")
250 CLEANDIRFILES+= ${CATPAGES}
251 .endif
252 .if !empty(MANSUFFIX)
253 CLEANDIRFILES+= ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//}
254 .endif
255 .if ${MKHTML} != "no"
256 CLEANDIRFILES+= ${HTMLPAGES}
257 .endif
258 .endif
259 # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
261 .if !empty(MANPAGES)
262 lintmanpages: ${MANPAGES}
263 ${TOOL_MANDOC_LINT} -Tlint -fstrict -Wall,stop ${.ALLSRC}
264 .endif
266 ##### Pull in related .mk logic
267 .include <bsd.obj.mk>
268 .include <bsd.files.mk>
269 .include <bsd.sys.mk>
270 .include <bsd.clean.mk>
272 ${TARGETS} catinstall maninstall htmlinstall: # ensure existence