bsd.man.mk revision 1.60 1 # $NetBSD: bsd.man.mk,v 1.60 2001/03/21 04:04:15 simonb Exp $
2 # @(#)bsd.man.mk 8.1 (Berkeley) 6/8/93
3
4 .if !target(__initialized__)
5 __initialized__:
6 .if exists(${.CURDIR}/../Makefile.inc)
7 .include "${.CURDIR}/../Makefile.inc"
8 .endif
9 .include <bsd.own.mk>
10 .include <bsd.obj.mk>
11 .include <bsd.depall.mk>
12 .MAIN: all
13 .endif
14
15 .PHONY: catinstall maninstall catpages manpages catlinks manlinks cleanman html installhtml cleanhtml
16 .if ${MKMAN} != "no"
17 realinstall: ${MANINSTALL}
18 .endif
19 cleandir distclean: cleanman
20
21 TMACDIR?= ${DESTDIR}/usr/share/tmac
22 HTMLDIR?= ${DESTDIR}/usr/share/man
23 CATDEPS?= ${TMACDIR}/tmac.andoc \
24 ${TMACDIR}/tmac.doc \
25 ${TMACDIR}/tmac.doc-ditroff \
26 ${TMACDIR}/tmac.doc-common \
27 ${TMACDIR}/tmac.doc-nroff \
28 ${TMACDIR}/tmac.doc-syms
29 MANTARGET?= cat
30 NROFF?= nroff -Tascii
31 GROFF?= groff -Tascii
32 TBL?= tbl
33
34
35 .SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 \
36 .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 .cat7 .cat8 .cat9 \
37 .html1 .html2 .html3 .html4 .html5 .html6 .html7 .html8 .html9
38
39 .9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1: \
40 ${CATDEPS}
41 .if !defined(USETBL)
42 @echo "${NROFF} -mandoc ${.IMPSRC} > ${.TARGET}"
43 @${NROFF} -mandoc ${.IMPSRC} > ${.TARGET} || \
44 (rm -f ${.TARGET}; false)
45 .else
46 @echo "${TBL} ${.IMPSRC} | ${NROFF} -mandoc > ${.TARGET}"
47 @${TBL} ${.IMPSRC} | ${NROFF} -mandoc > ${.TARGET} || \
48 (rm -f ${.TARGET}; false)
49 .endif
50
51 .9.html9 .8.html8 .7.html7 .6.html6 .5.html5 .4.html4 .3.html3 .2.html2 .1.html1: \
52 ${CATDEPS}
53 .if !defined(USETBL)
54 @echo "${GROFF} -mdoc2html -P-b -P-u -P-o ${.IMPSRC} > ${.TARGET}"
55 @${GROFF} -mdoc2html -P-b -P-u -P-o ${.IMPSRC} > ${.TARGET} || \
56 (rm -f ${.TARGET}; false)
57 .else
58 @echo "${TBL} ${.IMPSRC} | ${GROFF} -mdoc2html -P-b -P-u -P-o > ${.TARGET}"
59 @cat ${.IMPSRC} | ${GROFF} -mdoc2html -P-b -P-u -P-o > ${.TARGET} || \
60 (rm -f ${.TARGET}; false)
61 .endif
62
63 .if defined(MAN) && !empty(MAN)
64 MANPAGES= ${MAN}
65 CATPAGES= ${MANPAGES:C/(.*).([1-9])/\1.cat\2/}
66 .NOPATH: ${CATPAGES}
67 .if !defined(NOHTML)
68 HTMLPAGES= ${MANPAGES:C/(.*).([1-9])/\1.html\2/}
69 .endif
70 .endif
71
72 MINSTALL= ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \
73 -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
74
75 .if defined(MANZ)
76 # chown and chmod are done afterward automatically
77 MCOMPRESS= gzip -cf
78 MCOMPRESSSUFFIX= .gz
79 .endif
80
81 catinstall: catlinks
82 maninstall: manlinks
83
84 __installpage: .USE
85 .if defined(MCOMPRESS) && !empty(MCOMPRESS)
86 @rm -f ${.TARGET}
87 ${MCOMPRESS} ${.ALLSRC} > ${.TARGET}
88 @chown ${MANOWN}:${MANGRP} ${.TARGET}
89 @chmod ${MANMODE} ${.TARGET}
90 .else
91 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
92 (echo "${MINSTALL} ${.ALLSRC} ${.TARGET}" && \
93 ${MINSTALL} ${.ALLSRC} ${.TARGET})
94 .endif
95
96
97 # Rules for cat'ed man page installation
98 .if defined(CATPAGES) && !empty(CATPAGES) && ${MKCATPAGES} != "no"
99 catpages:: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
100 .PRECIOUS: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
101 .if !defined(UPDATE)
102 .PHONY: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
103 .endif
104
105 . for P in ${CATPAGES}
106 . if !defined(BUILD) && !make(all) && !make(${P})
107 ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: .MADE
108 . endif
109 ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: ${P} __installpage
110 . endfor
111 .else
112 catpages::
113 .endif
114
115 # Rules for source page installation
116 .if defined(MANPAGES) && !empty(MANPAGES)
117 manpages:: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
118 .PRECIOUS: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
119 .if !defined(UPDATE)
120 .PHONY: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
121 .endif
122
123 . for P in ${MANPAGES}
124 ${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}: ${P} __installpage
125 . endfor
126 .else
127 manpages::
128 .endif
129
130 .if ${MKCATPAGES} != "no"
131 catlinks: catpages
132 .if defined(MLINKS) && !empty(MLINKS)
133 @set ${MLINKS}; \
134 while test $$# -ge 2; do \
135 name=$$1; \
136 shift; \
137 dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
138 l=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \
139 name=$$1; \
140 shift; \
141 dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
142 t=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \
143 if test $$l -nt $$t -o ! -f $$t; then \
144 echo $$t -\> $$l; \
145 ln -f $$l $$t; \
146 fi; \
147 done
148 .endif
149 .else
150 catlinks:
151 .endif
152
153 manlinks: manpages
154 .if defined(MLINKS) && !empty(MLINKS)
155 @set ${MLINKS}; \
156 while test $$# -ge 2; do \
157 name=$$1; \
158 shift; \
159 dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
160 l=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \
161 name=$$1; \
162 shift; \
163 dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
164 t=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \
165 if test $$l -nt $$t -o ! -f $$t; then \
166 echo $$t -\> $$l; \
167 ln -f $$l $$t; \
168 fi; \
169 done
170 .endif
171
172 # Html rules
173 html: ${HTMLPAGES}
174
175 .if defined(HTMLPAGES) && !empty(HTMLPAGES)
176 .for P in ${HTMLPAGES}
177 ${HTMLDIR}/${P:T:E}/${P:T:R}.html: ${P}
178 ${MINSTALL} ${.ALLSRC} ${.TARGET}
179 .endfor
180 .endif
181 installhtml: ${HTMLPAGES:@P@${HTMLDIR}/${P:T:E}/${P:T:R}.html@}
182
183 cleanhtml:
184 .if defined(HTMLPAGES) && !empty(HTMLPAGES)
185 rm -f ${HTMLPAGES}
186 .endif
187
188
189 .if defined(CATPAGES)
190 .if ${MKCATPAGES} != "no" && ${MKMAN} != "no"
191 realall: ${CATPAGES}
192 .else
193 realall:
194 .endif
195
196 cleanman:
197 rm -f ${CATPAGES}
198 .else
199 cleanman:
200 .endif
201
202 # Make sure all of the standard targets are defined, even if they do nothing.
203 clean depend includes lint regress tags:
204