bsd.man.mk revision 1.59 1 # $NetBSD: bsd.man.mk,v 1.59 2001/03/05 14:17:06 tron 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 ${MINSTALL} ${.ALLSRC} ${.TARGET}
92 .endif
93
94
95 # Rules for cat'ed man page installation
96 .if defined(CATPAGES) && !empty(CATPAGES) && ${MKCATPAGES} != "no"
97 catpages:: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
98 .PRECIOUS: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
99 .if !defined(UPDATE)
100 .PHONY: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
101 .endif
102
103 . for P in ${CATPAGES}
104 . if !defined(BUILD) && !make(all) && !make(${P})
105 ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: .MADE
106 . endif
107 ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: ${P} __installpage
108 . endfor
109 .else
110 catpages::
111 .endif
112
113 # Rules for source page installation
114 .if defined(MANPAGES) && !empty(MANPAGES)
115 manpages:: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
116 .PRECIOUS: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
117 .if !defined(UPDATE)
118 .PHONY: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
119 .endif
120
121 . for P in ${MANPAGES}
122 ${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}: ${P} __installpage
123 . endfor
124 .else
125 manpages::
126 .endif
127
128 .if ${MKCATPAGES} != "no"
129 catlinks: catpages
130 .if defined(MLINKS) && !empty(MLINKS)
131 @set ${MLINKS}; \
132 while test $$# -ge 2; do \
133 name=$$1; \
134 shift; \
135 dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
136 l=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \
137 name=$$1; \
138 shift; \
139 dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
140 t=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \
141 if test $$l -nt $$t -o ! -f $$t; then \
142 echo $$t -\> $$l; \
143 ln -f $$l $$t; \
144 fi; \
145 done
146 .endif
147 .else
148 catlinks:
149 .endif
150
151 manlinks: manpages
152 .if defined(MLINKS) && !empty(MLINKS)
153 @set ${MLINKS}; \
154 while test $$# -ge 2; do \
155 name=$$1; \
156 shift; \
157 dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
158 l=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \
159 name=$$1; \
160 shift; \
161 dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
162 t=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \
163 if test $$l -nt $$t -o ! -f $$t; then \
164 echo $$t -\> $$l; \
165 ln -f $$l $$t; \
166 fi; \
167 done
168 .endif
169
170 # Html rules
171 html: ${HTMLPAGES}
172
173 .if defined(HTMLPAGES) && !empty(HTMLPAGES)
174 .for P in ${HTMLPAGES}
175 ${HTMLDIR}/${P:T:E}/${P:T:R}.html: ${P}
176 ${MINSTALL} ${.ALLSRC} ${.TARGET}
177 .endfor
178 .endif
179 installhtml: ${HTMLPAGES:@P@${HTMLDIR}/${P:T:E}/${P:T:R}.html@}
180
181 cleanhtml:
182 .if defined(HTMLPAGES) && !empty(HTMLPAGES)
183 rm -f ${HTMLPAGES}
184 .endif
185
186
187 .if defined(CATPAGES)
188 .if ${MKCATPAGES} != "no" && ${MKMAN} != "no"
189 realall: ${CATPAGES}
190 .else
191 realall:
192 .endif
193
194 cleanman:
195 rm -f ${CATPAGES}
196 .else
197 cleanman:
198 .endif
199
200 # Make sure all of the standard targets are defined, even if they do nothing.
201 clean depend includes lint regress tags:
202