1 # $NetBSD: bsd.man.mk,v 1.117 2014/12/19 22:25:39 christos Exp $
2 # @(#)bsd.man.mk 8.1 (Berkeley) 6/8/93
7 .PHONY
: catinstall maninstall catpages manpages catlinks manlinks
8 .PHONY
: htmlinstall htmlpages htmllinks
10 realinstall
: ${MANINSTALL}
12 # If our install destination is case-preserving, but case-insensitive
13 # then we do filesystem comparisons in lower case to make sure that
14 # we always refresh the target when needed. In general we don't
15 # want to do this, otherwise things like _exit.2 -> _Exit.2 get
16 # installed on each build even when they don't need to. Note that
17 # the CASE_INSENSITIVE_DEST macro is currently not defined anywhere,
18 # and the expansion does not really work because of make(1).
19 .if defined
(CASE_INSENSITIVE_DEST
)
24 .if
${USETOOLS} == "yes"
25 TMACDEPDIR?
= ${TOOLDIR}/share
/groff
/tmac
27 TMACDEPDIR?
= /usr
/share
/tmac
30 HTMLDIR?
= ${DESTDIR}${MANDIR}
31 .if
${MKMANDOC} == yes
&& !defined
(NOMANDOC
)
34 CATDEPS?
= ${TMACDEPDIR}/andoc.tmac \
35 ${TMACDEPDIR}/doc.tmac \
36 ${TMACDEPDIR}/mdoc
/doc-common \
37 ${TMACDEPDIR}/mdoc
/doc-ditroff \
38 ${TMACDEPDIR}/mdoc
/doc-nroff \
39 ${TMACDEPDIR}/mdoc
/doc-syms
45 _MSECTIONS
= 1 2 3 4 5 6 7 8 9
46 _MSECTIONS
+= 3lua
9lua
47 _MSECTIONREGEX
= ${_MSECTIONS
:ts|
} # e.g. 1|2|3|...
48 .SUFFIXES
: ${_MSECTIONS
:@N@.
$N@
}
54 MANCOMPRESS?
= ${TOOL_GZIP_N} -cf
58 # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
59 .if
!empty
(MANCOMPRESS
)
60 MANCOMPRESS
:= |
${MANCOMPRESS}
64 @cmp
-s
${.ALLSRC
} ${.TARGET
} > /dev
/null
2>&1 || \
65 (${_MKSHMSG_INSTALL} ${.TARGET
}; \
66 ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
67 ${.ALLSRC} ${.TARGET}" && \
68 ${INSTALL_FILE} -o
${MANOWN} -g
${MANGRP} -m
${MANMODE} \
69 ${.ALLSRC
} ${.TARGET
})
71 # XXX consider including bsd.links.mk and using __linkinstall instead
72 __linkinstallpage
: .USE
73 ${_MKSHMSG_INSTALL} ${.TARGET
}; \
74 ${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
75 ${.ALLSRC} ${.TARGET}" && \
76 ${INSTALL_LINK} -o
${MANOWN} -g
${MANGRP} -m
${MANMODE} \
79 ##### Build and install rules (source form pages)
82 maninstall
: manpages manlinks
83 manpages
:: # ensure target exists
84 MANPAGES
= ${MAN
:C
/.
$/&${MANSUFFIX}/}
89 .SUFFIXES
: ${_MSECTIONS
:@N@.
$N${MANSUFFIX}@
}
91 ${_MSECTIONS
:@N@.
$N.
$N${MANSUFFIX}@
}: # build rule
93 cat
${.IMPSRC
} ${MANCOMPRESS} > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
94 .
endif # !empty(MANSUFFIX)
96 .for F in
${MANPAGES
:S
/${MANSUFFIX}$//:O
:u
}
97 _F
:= ${DESTDIR}${MANDIR}/man
${F
:T
:E
}${MANSUBDIR}/${F}${MANSUFFIX}
99 .if
${MKUPDATE} == "no"
100 ${_F}! ${F}${MANSUFFIX} __installpage
# install rule
101 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
102 ${_F}! .MADE
# no build at install
105 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
106 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
107 ${_F}: .MADE
# no build at install
112 .PRECIOUS
: ${_F} # keep if install fails
115 manlinks
:: # link install
117 .for _src _dst in
${MLINKS}
118 _l
:=${DESTDIR}${MANDIR}/man
${_src
:T
:E
}${MANSUBDIR}/${_src}${MANSUFFIX}
119 _t
:=${DESTDIR}${MANDIR}/man
${_dst
:T
:E
}${MANSUBDIR}/${_dst}${MANSUFFIX}
121 # Handle case conflicts carefully, when _dst occurs
122 # more than once after case flattening
123 .if
${MKUPDATE} == "no" ||
${MLINKS
:${_FLATTEN}M
${_dst
:${_FLATTEN}Q
}:[\
#]} > 1
124 ${_t}! ${_l} __linkinstallpage
126 ${_t}: ${_l} __linkinstallpage
132 .
endif # ${MKMAN} != "no"
134 ##### Build and install rules (plaintext pages)
136 .if
(${MKCATPAGES} != "no") && (${MKMAN} != "no")
137 catinstall
: catpages catlinks
138 catpages
:: # ensure target exists
139 CATPAGES
= ${MAN
:C
/\.
(${_MSECTIONREGEX})\
$/.cat\
1${MANSUFFIX}/}
143 .SUFFIXES
: ${_MSECTIONS
:@N@.cat
$N${MANSUFFIX}@
}
146 ${_MSECTIONS
:@N@.
$N.cat
$N${MANSUFFIX}@
}: ${CATDEPS} # build rule
148 .if
${MKMANDOC} == yes
&& !defined
(NOMANDOC
)
149 if
test ""${NOMANDOC.
${.IMPSRC
:T
}:tl
:Q
} != "yes"; then \
150 ${TOOL_MANDOC_ASCII} ${.IMPSRC
} ${MANCOMPRESS} \
151 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}; \
153 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
154 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}; \
156 .elif defined
(USETBL
)
157 ${TOOL_TBL} ${.IMPSRC
} |
${TOOL_ROFF_ASCII} -mandoc
${MANCOMPRESS} \
158 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
160 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
161 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
164 .for F in
${CATPAGES
:S
/${MANSUFFIX}$//:O
:u
}
165 _F
:= ${DESTDIR}${MANDIR}/${F
:T
:E
}${MANSUBDIR}/${F
:R
}.0${MANSUFFIX}
167 .if
${MKUPDATE} == "no"
168 ${_F}! ${F}${MANSUFFIX} __installpage
# install rule
169 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
170 ${_F}! .MADE
# no build at install
173 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
174 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
175 ${_F}: .MADE
# no build at install
180 .PRECIOUS
: ${_F} # keep if install fails
183 catlinks
:: # link install
185 .for _src _dst in
${MLINKS}
186 _l
:=${DESTDIR}${MANDIR}/cat
${_src
:T
:E
}${MANSUBDIR}/${_src
:R
}.0${MANSUFFIX}
187 _t
:=${DESTDIR}${MANDIR}/cat
${_dst
:T
:E
}${MANSUBDIR}/${_dst
:R
}.0${MANSUFFIX}
189 # Handle case conflicts carefully, when _dst occurs
190 # more than once after case flattening
191 .if
${MKUPDATE} == "no" ||
${MLINKS
:${_FLATTEN}M
${_dst
:${_FLATTEN}Q
}:[\
#]} > 1
192 ${_t}! ${_l} __linkinstallpage
194 ${_t}: ${_l} __linkinstallpage
200 .
endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
202 ##### Build and install rules (HTML pages)
204 .if
(${MKHTML} != "no") && (${MKMAN} != "no") # {
205 htmlinstall
: htmlpages htmllinks
206 htmlpages
:: # ensure target exists
207 HTMLPAGES
= ${MAN
:C
/\.
(${_MSECTIONREGEX})\
$/.html\
1/}
209 HTMLLINKS
= ${MANSUBDIR
:?..
/:}..
/html
%S
/%N.html
210 HTMLSTYLE
= ${MANSUBDIR
:?..
/:}..
/style.css
212 realall
: ${HTMLPAGES}
213 .NOPATH
: ${HTMLPAGES}
214 .SUFFIXES
: ${_MSECTIONS
:@N@.html
$N@
}
216 ${_MSECTIONS
:@N@.
$N.html
$N@
}: # build rule
218 .if
${MKMANDOC} == yes
&& !defined
(NOMANDOC
)
219 if
test ""${NOMANDOC.
${.IMPSRC
:T
}:tl
:Q
} != "yes"; then \
220 ${TOOL_MANDOC_HTML} -Oman
=${HTMLLINKS} -Ostyle
=${HTMLSTYLE} \
221 ${.IMPSRC
} > ${.TARGET
}.tmp
&& \
222 mv
${.TARGET
}.tmp
${.TARGET
}; \
224 ${TOOL_ROFF_HTML} ${.IMPSRC
} ${MANCOMPRESS} \
225 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}; \
227 .elif defined
(USETBL
)
228 ${TOOL_TBL} ${.IMPSRC
} |
${TOOL_ROFF_HTML} ${MANCOMPRESS} \
229 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
231 ${TOOL_ROFF_HTML} ${.IMPSRC
} ${MANCOMPRESS} \
232 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
235 .for F in
${HTMLPAGES
:O
:u
}
236 # construct installed path
237 _F
:= ${HTMLDIR}/${F
:T
:E
}${MANSUBDIR}/${F
:R
:S-
/index
$-/x
&-}.html
239 .if
${MKUPDATE} == "no"
240 ${_F}! ${F} __installpage
# install rule
241 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
242 ${_F}! .MADE
# no build at install
245 ${_F}: ${F} __installpage
# install rule
246 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
247 ${_F}: .MADE
# no build at install
252 .PRECIOUS
: ${_F} # keep if install fails
255 htmllinks
:: # link install
257 .for _src _dst in
${MLINKS}
258 _l
:=${HTMLDIR}/html
${_src
:T
:E
}${MANSUBDIR}/${_src
:R
:S-
/index
$-/x
&-}.html
259 _t
:=${HTMLDIR}/html
${_dst
:T
:E
}${MANSUBDIR}/${_dst
:R
:S-
/index
$-/x
&-}.html
261 # Handle case conflicts carefully, when _dst occurs
262 # more than once after case flattening
263 .if
${MKUPDATE} == "no" ||
${MLINKS
:${_FLATTEN}M
${_dst
:${_FLATTEN}Q
}:[\
#]} > 1
264 ${_t}! ${_l} __linkinstallpage
266 ${_t}: ${_l} __linkinstallpage
278 .if
!empty
(MAN
) && (${MKMAN} != "no")
279 .if
(${MKCATPAGES} != "no")
280 CLEANDIRFILES
+= ${CATPAGES}
282 .if
!empty
(MANSUFFIX
)
283 CLEANDIRFILES
+= ${MANPAGES} ${CATPAGES
:S
/${MANSUFFIX}$//}
285 .if
${MKHTML} != "no"
286 CLEANDIRFILES
+= ${HTMLPAGES}
289 # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
292 lintmanpages
: ${MANPAGES}
293 ${TOOL_MANDOC_LINT} -Tlint
-fstrict
-Wall
,stop
${.ALLSRC
}
296 ##### Pull in related .mk logic
297 .
include <bsd.obj.mk
>
298 .
include <bsd.files.mk
>
299 .
include <bsd.sys.mk
>
300 .
include <bsd.
clean.mk
>
302 ${TARGETS} catinstall maninstall htmlinstall
: # ensure existence