1 # $NetBSD: bsd.man.mk,v 1.101 2009/10/23 22:14:37 joerg Exp $
2 # @(#)bsd.man.mk 8.1 (Berkeley) 6/8/93
7 .PHONY
: catinstall maninstall catpages manpages catlinks manlinks
8 .PHONY
: htmlinstall htmlpages htmllinks
9 .if
${MKMANDOC} == "yes"
12 realinstall
: ${MANINSTALL}
15 .if
${USETOOLS} == "yes"
16 TMACDEPDIR?
= ${TOOLDIR}/share
/groff
/tmac
18 TMACDEPDIR?
= /usr
/share
/tmac
21 HTMLDIR?
= ${DESTDIR}${MANDIR}
22 CATDEPS?
= ${TMACDEPDIR}/andoc.tmac \
23 ${TMACDEPDIR}/doc.tmac \
24 ${TMACDEPDIR}/mdoc
/doc-common \
25 ${TMACDEPDIR}/mdoc
/doc-ditroff \
26 ${TMACDEPDIR}/mdoc
/doc-nroff \
27 ${TMACDEPDIR}/mdoc
/doc-syms
28 HTMLDEPS?
= ${TMACDEPDIR}/doc2html.tmac
33 _MNUMBERS
= 1 2 3 4 5 6 7 8 9
34 .SUFFIXES
: ${_MNUMBERS
:@N@.
$N@
}
40 MANCOMPRESS?
= gzip
-ncf
44 # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
45 .if
!empty
(MANCOMPRESS
)
46 MANCOMPRESS
:= |
${MANCOMPRESS}
50 @cmp
-s
${.ALLSRC
} ${.TARGET
} > /dev
/null
2>&1 || \
51 (${_MKSHMSG_INSTALL} ${.TARGET
}; \
52 ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
53 ${.ALLSRC} ${.TARGET}" && \
54 ${INSTALL_FILE} -o
${MANOWN} -g
${MANGRP} -m
${MANMODE} \
55 ${.ALLSRC
} ${.TARGET
})
57 # XXX consider including bsd.links.mk and using __linkinstall instead
58 __linkinstallpage
: .USE
59 ${_MKSHMSG_INSTALL} ${.TARGET
}; \
60 ${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
61 ${.ALLSRC} ${.TARGET}" && \
62 ${INSTALL_LINK} -o
${MANOWN} -g
${MANGRP} -m
${MANMODE} \
65 ##### Build and install rules (source form pages)
68 maninstall
: manpages manlinks
69 manpages
:: # ensure target exists
70 MANPAGES
= ${MAN
:C
/.
$/&${MANSUFFIX}/}
75 .SUFFIXES
: ${_MNUMBERS
:@N@.
$N${MANSUFFIX}@
}
77 ${_MNUMBERS
:@N@.
$N.
$N${MANSUFFIX}@
}: # build rule
79 cat
${.IMPSRC
} ${MANCOMPRESS} > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
80 .
endif # !empty(MANSUFFIX)
82 .for F in
${MANPAGES
:S
/${MANSUFFIX}$//:O
:u
}
83 _F
:= ${DESTDIR}${MANDIR}/man
${F
:T
:E
}${MANSUBDIR}/${F}${MANSUFFIX}
85 .if
${MKUPDATE} == "no"
86 ${_F}! ${F}${MANSUFFIX} __installpage
# install rule
87 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
88 ${_F}! .MADE
# no build at install
91 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
92 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
93 ${_F}: .MADE
# no build at install
98 .PRECIOUS
: ${_F} # keep if install fails
101 manlinks
:: # link install
103 .for _src _dst in
${MLINKS}
104 _l
:=${DESTDIR}${MANDIR}/man
${_src
:T
:E
}${MANSUBDIR}/${_src}${MANSUFFIX}
105 _t
:=${DESTDIR}${MANDIR}/man
${_dst
:T
:E
}${MANSUBDIR}/${_dst}${MANSUFFIX}
107 # Handle case conflicts carefully, when _dst occurs
108 # more than once after case flattening
109 .if
${MKUPDATE} == "no" ||
${MLINKS
:tl
:M
${_dst
:tl
:Q
}:[\
#]} > 1
110 ${_t}! ${_l} __linkinstallpage
112 ${_t}: ${_l} __linkinstallpage
118 .
endif # ${MKMAN} != "no"
120 ##### Build and install rules (plaintext pages)
122 .if
(${MKCATPAGES} != "no") && (${MKMAN} != "no")
123 catinstall
: catpages catlinks
124 catpages
:: # ensure target exists
125 CATPAGES
= ${MAN
:C
/\.
([1-9])$/.cat\
1${MANSUFFIX}/}
129 .SUFFIXES
: ${_MNUMBERS
:@N@.cat
$N${MANSUFFIX}@
}
132 ${_MNUMBERS
:@N@.
$N.cat
$N${MANSUFFIX}@
}: ${CATDEPS} # build rule
135 ${TOOL_TBL} ${.IMPSRC
} |
${TOOL_ROFF_ASCII} -mandoc
${MANCOMPRESS} \
136 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
137 .elif
${MKMANDOC} == yes
&& !defined
(NOMANDOC
)
138 if
test ""${NOMANDOC.
${.IMPSRC
:T
}:tl
:Q
} != "yes"; then \
139 ${TOOL_MANDOC_ASCII} ${.IMPSRC
} ${MANCOMPRESS} \
140 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}; \
142 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
143 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}; \
146 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
147 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
150 .for F in
${CATPAGES
:S
/${MANSUFFIX}$//:O
:u
}
151 _F
:= ${DESTDIR}${MANDIR}/${F
:T
:E
}${MANSUBDIR}/${F
:R
}.0${MANSUFFIX}
153 .if
${MKUPDATE} == "no"
154 ${_F}! ${F}${MANSUFFIX} __installpage
# install rule
155 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
156 ${_F}! .MADE
# no build at install
159 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
160 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
161 ${_F}: .MADE
# no build at install
166 .PRECIOUS
: ${_F} # keep if install fails
169 catlinks
:: # link install
171 .for _src _dst in
${MLINKS}
172 _l
:=${DESTDIR}${MANDIR}/cat
${_src
:T
:E
}${MANSUBDIR}/${_src
:R
}.0${MANSUFFIX}
173 _t
:=${DESTDIR}${MANDIR}/cat
${_dst
:T
:E
}${MANSUBDIR}/${_dst
:R
}.0${MANSUFFIX}
175 # Handle case conflicts carefully, when _dst occurs
176 # more than once after case flattening
177 .if
${MKUPDATE} == "no" ||
${MLINKS
:tl
:M
${_dst
:tl
:Q
}:[\
#]} > 1
178 ${_t}! ${_l} __linkinstallpage
180 ${_t}: ${_l} __linkinstallpage
186 .
endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
188 ##### Build and install rules (HTML pages)
190 .if
(${MKHTML} != "no") && (${MKMAN} != "no") # {
191 htmlinstall
: htmlpages htmllinks
192 htmlpages
:: # ensure target exists
193 HTMLPAGES
= ${MAN
:C
/\.
([1-9])$/.html\
1/}
195 realall
: ${HTMLPAGES}
196 .NOPATH
: ${HTMLPAGES}
197 .SUFFIXES
: ${_MNUMBERS
:@N@.html
$N@
}
200 ${_MNUMBERS
:@N@.
$N.html
$N@
}: ${HTMLDEPS} # build rule
202 .if
${MKMANDOC} == "yes" && !defined
(NOMANDOC
)
203 if
test ""${NOMANDOC.
${.IMPSRC
:T
}:tl
:Q
} != "yes"; then \
204 ${TOOL_MANDOC_HTML} ${.IMPSRC
} > ${.TARGET
}.tmp
&& \
205 mv
${.TARGET
}.tmp
${.TARGET
}; \
207 ${TOOL_ROFF_HTML} ${.IMPSRC
} > ${.TARGET
}.tmp
&& \
208 mv
${.TARGET
}.tmp
${.TARGET
}; \
211 ${TOOL_ROFF_HTML} ${.IMPSRC
} > ${.TARGET
}.tmp
&& \
212 mv
${.TARGET
}.tmp
${.TARGET
}
215 .for F in
${HTMLPAGES
:O
:u
}
216 # construct installed path
217 _F
:= ${HTMLDIR}/${F
:T
:E
}${MANSUBDIR}/${F
:R
:S-
/index
$-/x
&-}.html
219 .if
${MKUPDATE} == "no"
220 ${_F}! ${F} __installpage
# install rule
221 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
222 ${_F}! .MADE
# no build at install
225 ${_F}: ${F} __installpage
# install rule
226 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
227 ${_F}: .MADE
# no build at install
232 .PRECIOUS
: ${_F} # keep if install fails
235 htmllinks
:: # link install
237 .for _src _dst in
${MLINKS}
238 _l
:=${HTMLDIR}/html
${_src
:T
:E
}${MANSUBDIR}/${_src
:R
:S-
/index
$-/x
&-}.html
239 _t
:=${HTMLDIR}/html
${_dst
:T
:E
}${MANSUBDIR}/${_dst
:R
:S-
/index
$-/x
&-}.html
241 # Handle case conflicts carefully, when _dst occurs
242 # more than once after case flattening
243 .if
${MKUPDATE} == "no" ||
${MLINKS
:tl
:M
${_dst
:tl
:Q
}:[\
#]} > 1
244 ${_t}! ${_l} __linkinstallpage
246 ${_t}: ${_l} __linkinstallpage
259 .if
!empty
(CLEANFILES
)
264 .if
!empty
(MAN
) && (${MKMAN} != "no")
265 .if
(${MKCATPAGES} != "no")
268 .if
!empty
(MANSUFFIX
)
269 rm -f
${MANPAGES} ${CATPAGES
:S
/${MANSUFFIX}$//}
271 .if
${MKHTML} != "no"
275 # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
277 .if
${MKMANDOC} == "yes" && !empty
(MANPAGES
)
278 lintmanpages
: ${MANPAGES}
279 ${TOOL_MANDOC_LINT} -Tlint
-fstrict
${.ALLSRC
}
282 ##### Pull in related .mk logic
283 .
include <bsd.obj.mk
>
284 .
include <bsd.files.mk
>
285 .
include <bsd.sys.mk
>
287 ${TARGETS} catinstall maninstall htmlinstall
: # ensure existence