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
7 .PHONY
: catinstall maninstall catpages manpages catlinks manlinks
8 .PHONY
: htmlinstall htmlpages htmllinks
10 realinstall
: ${MANINSTALL}
13 .if
${USETOOLS} == "yes"
14 TMACDEPDIR?
= ${TOOLDIR}/share
/groff
/tmac
16 TMACDEPDIR?
= /usr
/share
/tmac
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
30 _MNUMBERS
= 1 2 3 4 5 6 7 8 9
31 .SUFFIXES
: ${_MNUMBERS
:@N@.
$N@
}
37 MANCOMPRESS?
= ${TOOL_GZIP} -ncf
41 # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
42 .if
!empty
(MANCOMPRESS
)
43 MANCOMPRESS
:= |
${MANCOMPRESS}
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} \
62 ##### Build and install rules (source form pages)
65 maninstall
: manpages manlinks
66 manpages
:: # ensure target exists
67 MANPAGES
= ${MAN
:C
/.
$/&${MANSUFFIX}/}
72 .SUFFIXES
: ${_MNUMBERS
:@N@.
$N${MANSUFFIX}@
}
74 ${_MNUMBERS
:@N@.
$N.
$N${MANSUFFIX}@
}: # build rule
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
88 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
89 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
90 ${_F}: .MADE
# no build at install
95 .PRECIOUS
: ${_F} # keep if install fails
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
109 ${_t}: ${_l} __linkinstallpage
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}/}
126 .SUFFIXES
: ${_MNUMBERS
:@N@.cat
$N${MANSUFFIX}@
}
129 ${_MNUMBERS
:@N@.
$N.cat
$N${MANSUFFIX}@
}: ${CATDEPS} # build rule
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
}; \
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
}
143 ${TOOL_ROFF_ASCII} -mandoc
${.IMPSRC
} ${MANCOMPRESS} \
144 > ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
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
156 ${_F}: ${F}${MANSUFFIX} __installpage
# install rule
157 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
158 ${_F}: .MADE
# no build at install
163 .PRECIOUS
: ${_F} # keep if install fails
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
177 ${_t}: ${_l} __linkinstallpage
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
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
215 ${_F}: ${F} __installpage
# install rule
216 .if
!defined
(BUILD
) && !make
(all) && !make
(${F})
217 ${_F}: .MADE
# no build at install
222 .PRECIOUS
: ${_F} # keep if install fails
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
236 ${_t}: ${_l} __linkinstallpage
248 .if
!empty
(MAN
) && (${MKMAN} != "no")
249 .if
(${MKCATPAGES} != "no")
250 CLEANDIRFILES
+= ${CATPAGES}
252 .if
!empty
(MANSUFFIX
)
253 CLEANDIRFILES
+= ${MANPAGES} ${CATPAGES
:S
/${MANSUFFIX}$//}
255 .if
${MKHTML} != "no"
256 CLEANDIRFILES
+= ${HTMLPAGES}
259 # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
262 lintmanpages
: ${MANPAGES}
263 ${TOOL_MANDOC_LINT} -Tlint
-fstrict
-Wall
,stop
${.ALLSRC
}
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