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
10 .PHONY
: catinstall maninstall catpages manpages catlinks manlinks
11 .PHONY
: htmlinstall htmlpages htmllinks
12 .if
${MKMANDOC} == "yes"
15 realinstall
: ${MANINSTALL}
18 .if
${USETOOLS} == "yes"
19 TMACDEPDIR?
= ${TOOLDIR}/share
/groff
/tmac
21 TMACDEPDIR?
= /usr
/share
/tmac
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
36 _MNUMBERS
= 1 2 3 4 5 6 7 8 9
37 .SUFFIXES
: ${_MNUMBERS
:@N@.
$N@
}
43 MANCOMPRESS?
= gzip
-ncf
47 # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
48 .if
!empty
(MANCOMPRESS
)
49 MANCOMPRESS
:= |
${MANCOMPRESS}
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} \
68 ##### Build and install rules (source form pages)
71 maninstall
: manpages manlinks
72 manpages
:: # ensure target exists
73 MANPAGES
= ${MAN
:C
/.
$/&${MANSUFFIX}/}
78 .SUFFIXES
: ${_MNUMBERS
:@N@.
$N${MANSUFFIX}@
}
80 ${_MNUMBERS
:@N@.
$N.
$N${MANSUFFIX}@
}: # build rule
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
94 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
95 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
96 ${_F}: .MADE
# no build at install
101 .PRECIOUS
: ${_F} # keep if install fails
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
115 ${_t}: ${_l} __linkinstallpage
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}/}
132 .SUFFIXES
: ${_MNUMBERS
:@N@.cat
$N${MANSUFFIX}@
}
135 ${_MNUMBERS
:@N@.
$N.cat
$N${MANSUFFIX}@
}: ${CATDEPS} # build rule
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
}; \
145 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
146 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}; \
149 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
150 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
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
162 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
163 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
164 ${_F}: .MADE
# no build at install
169 .PRECIOUS
: ${_F} # keep if install fails
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
183 ${_t}: ${_l} __linkinstallpage
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@
}
203 ${_MNUMBERS
:@N@.
$N.html
$N@
}: ${HTMLDEPS} # build rule
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
}; \
210 ${TOOL_ROFF_HTML} ${.IMPSRC
} > ${.TARGET
}.tmp
&& \
211 mv
${.TARGET
}.tmp
${.TARGET
}; \
214 ${TOOL_ROFF_HTML} ${.IMPSRC
} > ${.TARGET
}.tmp
&& \
215 mv
${.TARGET
}.tmp
${.TARGET
}
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
228 ${_F}: ${F} __installpage
# install rule
229 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
230 ${_F}: .MADE
# no build at install
235 .PRECIOUS
: ${_F} # keep if install fails
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
249 ${_t}: ${_l} __linkinstallpage
262 .if
!empty
(CLEANFILES
)
267 .if
!empty
(MAN
) && (${MKMAN} != "no")
268 .if
(${MKCATPAGES} != "no")
271 .if
!empty
(MANSUFFIX
)
272 rm -f
${MANPAGES} ${CATPAGES
:S
/${MANSUFFIX}$//}
274 .if
${MKHTML} != "no"
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
}
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