3 # The include file <bsd.man.mk> handles installing manual pages and
9 # DESTDIR Change the tree where the man pages gets installed. [not set]
11 # MANDIR Base path for manual installation. [${SHAREDIR}/man/man]
13 # MANOWN Manual owner. [${SHAREOWN}]
15 # MANGRP Manual group. [${SHAREGRP}]
17 # MANMODE Manual mode. [${NOBINMODE}]
19 # MANSUBDIR Subdirectory under the manual page section, i.e. "/i386"
20 # or "/tahoe" for machine specific manual pages.
22 # MAN The manual pages to be installed. For sections see
23 # variable ${SECTIONS}
25 # MCOMPRESS_CMD Program to compress man pages. Output is to
26 # stdout. [${COMPRESS_CMD}]
28 # MLINKS List of manual page links (using a suffix). The
29 # linked-to file must come first, the linked file
30 # second, and there may be multiple pairs. The files
33 # NO_MANCOMPRESS If you do not want unformatted manual pages to be
34 # compressed when they are installed. [not set]
36 # NO_MLINKS If you do not want install manual page links. [not set]
38 # MANFILTER command to pipe the raw man page through before compressing
39 # or installing. Can be used to do sed substitution.
41 # MANBUILDCAT create preformatted manual pages in addition to normal
44 # MROFF_CMD command and flags to create preformatted pages
49 # Install the manual pages and their links.
52 .if
!target
(__
<bsd.init.mk
>__
)
53 .error bsd.man.mk cannot be included directly.
56 MINSTALL?
= ${INSTALL} -o
${MANOWN} -g
${MANGRP} -m
${MANMODE}
58 CATDIR
= ${MANDIR
:H
:S
/$/\
/cat
/}
60 MROFF_CMD?
= groff
-Tascii
-mtty-char
-man
-t
62 MCOMPRESS_CMD?
= ${COMPRESS_CMD}
63 MCOMPRESS_EXT?
= ${COMPRESS_EXT}
65 SECTIONS
= 1 1aout
2 3 4 5 6 7 8 9
66 .SUFFIXES
: ${SECTIONS
:S
/^
/.
/g
}
68 # Backwards compatibility.
70 .for __sect in
${SECTIONS}
71 .if defined
(MAN
${__sect}) && !empty
(MAN
${__sect})
80 .if defined
(NO_MANCOMPRESS
)
82 # Make special arrangements to filter to a temporary file at build time
84 .if defined
(MANFILTER
)
92 .if defined
(MANFILTER
)
93 .if defined
(MAN
) && !empty
(MAN
)
94 CLEANFILES
+= ${MAN
:T
:S
/$/${FILTEXTENSION}/g
}
95 CLEANFILES
+= ${MAN
:T
:S
/$/${CATEXT}${FILTEXTENSION}/g
}
97 .for __target in
${__page
:T
:S
/$/${FILTEXTENSION}/g
}
98 _manpages
: ${__target}
99 ${__target}: ${__page}
100 ${MANFILTER} < ${.ALLSRC
} > ${.TARGET
}
102 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
103 .for __target in
${__page
:T
:S
/$/${CATEXT}${FILTEXTENSION}/g
}
104 _manpages
: ${__target}
105 ${__target}: ${__page}
106 ${MANFILTER} < ${.ALLSRC
} |
${MROFF_CMD} > ${.TARGET
}
112 .if defined
(MAN
) && !empty
(MAN
)
113 CLEANFILES
+= ${MAN
:T
:S
/$/${CATEXT}/g
}
114 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
115 .for __page in
${MAN}
116 .for __target in
${__page
:T
:S
/$/${CATEXT}/g
}
117 _manpages
: ${__target}
118 ${__target}: ${__page}
119 ${MROFF_CMD} ${.ALLSRC
} > ${.TARGET
}
130 ZEXT
= ${MCOMPRESS_EXT}
132 .if defined
(MAN
) && !empty
(MAN
)
133 CLEANFILES
+= ${MAN
:T
:S
/$/${MCOMPRESS_EXT}/g
}
134 CLEANFILES
+= ${MAN
:T
:S
/$/${CATEXT}${MCOMPRESS_EXT}/g
}
135 .for __page in
${MAN}
136 .for __target in
${__page
:T
:S
/$/${MCOMPRESS_EXT}/}
137 _manpages
: ${__target}
138 ${__target}: ${__page}
139 .if defined
(MANFILTER
)
140 ${MANFILTER} < ${.ALLSRC
} |
${MCOMPRESS_CMD} > ${.TARGET
}
142 ${MCOMPRESS_CMD} ${.ALLSRC
} > ${.TARGET
}
145 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
146 .for __target in
${__page
:T
:S
/$/${CATEXT}${MCOMPRESS_EXT}/}
147 _manpages
: ${__target}
148 ${__target}: ${__page}
149 .if defined
(MANFILTER
)
150 ${MANFILTER} < ${.ALLSRC
} |
${MROFF_CMD} |
${MCOMPRESS_CMD} > ${.TARGET
}
152 ${MROFF_CMD} ${.ALLSRC
} |
${MCOMPRESS_CMD} > ${.TARGET
}
161 maninstall
: _maninstall
163 .if defined
(MAN
) && !empty
(MAN
)
165 .if defined
(NO_MANCOMPRESS
)
166 .if defined
(MANFILTER
)
167 .for __page in
${MAN}
168 ${MINSTALL} ${__page
:T
:S
/$/${FILTEXTENSION}/g
} \
169 ${DESTDIR}${MANDIR}${__page
:E
}${MANSUBDIR}/${__page}
170 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
171 ${MINSTALL} ${__page
:T
:S
/$/${CATEXT}${FILTEXTENSION}/g
} \
172 ${DESTDIR}${CATDIR}${__page
:E
}${MANSUBDIR}/${__page}
176 @set
${.ALLSRC
:C
/\.
([^.
]*)$/.\
1 \
1/}; \
180 1) echo
"warn: missing extension: $$1"; break
;; \
182 page
=$$1; shift
; sect
=$$1; shift
; \
183 d
=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
184 ${ECHO} ${MINSTALL} $${page} $${d}; \
185 ${MINSTALL} $${page} $${d}; \
187 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
188 .for __page in
${MAN}
189 ${MINSTALL} ${__page
:T
:S
/$/${CATEXT}/} \
190 ${DESTDIR}${CATDIR}${__page
:E
}${MANSUBDIR}/${__page
:T
}
195 .for __page in
${MAN}
196 ${MINSTALL} ${__page
:T
:S
/$/${MCOMPRESS_EXT}/g
} \
197 ${DESTDIR}${MANDIR}${__page
:E
}${MANSUBDIR}
198 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
199 ${MINSTALL} ${__page
:T
:S
/$/${CATEXT}${MCOMPRESS_EXT}/g
} \
200 ${DESTDIR}${CATDIR}${__page
:E
}${MANSUBDIR}/${__page
:T
:S
/$/${MCOMPRESS_EXT}/}
206 .if
!defined
(NO_MLINKS
) && defined
(MLINKS
) && !empty
(MLINKS
)
207 @set
${MLINKS
:C
/\.
([^.
]*)$/.\
1 \
1/}; \
211 [123]) echo
"warn: empty MLINK: $$1 $$2 $$3"; break
;; \
213 name
=$$1; shift
; sect
=$$1; shift
; \
214 l
=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
215 name
=$$1; shift
; sect
=$$1; shift
; \
216 t
=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
217 ${ECHO} $${t}${ZEXT} -\
> $${l}${ZEXT}; \
218 rm -f
$${t} $${t}${MCOMPRESS_EXT}; \
219 ln
$${l}${ZEXT} $${t}${ZEXT}; \
221 .if defined
(MANBUILDCAT
) && !empty
(MANBUILDCAT
)
222 @set
${MLINKS
:C
/\.
([^.
]*)$/.\
1 \
1/}; \
226 [123]) echo
"warn: empty MLINK: $$1 $$2 $$3"; break
;; \
228 name
=$$1; shift
; sect
=$$1; shift
; \
229 l
=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
230 name
=$$1; shift
; sect
=$$1; shift
; \
231 t
=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
232 ${ECHO} $${t}${ZEXT} -\
> $${l}${ZEXT}; \
233 rm -f
$${t} $${t}${MCOMPRESS_EXT}; \
234 ln
$${l}${ZEXT} $${t}${ZEXT}; \
240 .if defined
(MAN
) && !empty
(MAN
)
241 .for __page in
${MAN}
242 manlint
: ${__page}lint
243 ${__page}lint
: ${__page}
244 .if defined
(MANFILTER
)
245 ${MANFILTER} < ${.ALLSRC
} |
${MROFF_CMD} -ww
-z
247 ${MROFF_CMD} -ww
-z
${.ALLSRC
}