1# $FreeBSD$ 2# 3# The include file <bsd.man.mk> handles installing manual pages and 4# their links. 5# 6# 7# +++ variables +++ 8# 9# DESTDIR Change the tree where the man pages gets installed. [not set] 10# 11# MANDIR Base path for manual installation. [${SHAREDIR}/man/man] 12# 13# MANOWN Manual owner. [${SHAREOWN}] 14# 15# MANGRP Manual group. [${SHAREGRP}] 16# 17# MANMODE Manual mode. [${NOBINMODE}] 18# 19# MANSUBDIR Subdirectory under the manual page section, i.e. "/i386" 20# or "/tahoe" for machine specific manual pages. 21# 22# MAN The manual pages to be installed. For sections see 23# variable ${SECTIONS} 24# 25# MCOMPRESS_CMD Program to compress man pages. Output is to 26# stdout. [${COMPRESS_CMD}] 27# 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 31# are hard-linked. 32# 33# NOMANCOMPRESS If you do not want unformatted manual pages to be 34# compressed when they are installed. [not set] 35# 36# NOMLINKS If you do not want install manual page links. [not set] 37# 38# MANFILTER command to pipe the raw man page through before compressing 39# or installing. Can be used to do sed substitution. 40# 41# MANBUILDCAT create preformatted manual pages in addition to normal 42# pages. [not set] 43# 44# MROFF_CMD command and flags to create preformatted pages 45# 46# +++ targets +++ 47# 48# maninstall: 49# Install the manual pages and their links. 50# 51 52.if !target(__<bsd.init.mk>__) 53.error bsd.man.mk cannot be included directly. 54.endif 55 56MINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 57 58CATDIR= ${MANDIR:H:S/$/\/cat/} 59CATEXT= .cat 60MROFF_CMD?= groff -Tascii -mtty-char -man -t 61 62MCOMPRESS_CMD?= ${COMPRESS_CMD} 63MCOMPRESS_EXT?= ${COMPRESS_EXT} 64 65SECTIONS= 1 1aout 2 3 4 5 6 7 8 9 66.SUFFIXES: ${SECTIONS:S/^/./g} 67 68# Backwards compatibility. 69.if !defined(MAN) 70.for sect in ${SECTIONS} 71.if defined(MAN${sect}) && !empty(MAN${sect}) 72MAN+= ${MAN${sect}} 73.endif 74.endfor 75.endif 76 77_manpages: 78all-man: _manpages 79 80.if defined(NOMANCOMPRESS) 81 82# Make special arrangements to filter to a temporary file at build time 83# for NOMANCOMPRESS. 84.if defined(MANFILTER) 85FILTEXTENSION= .filt 86.else 87FILTEXTENSION= 88.endif 89 90ZEXT= 91 92.if defined(MANFILTER) 93.if defined(MAN) && !empty(MAN) 94CLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g} 95CLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g} 96.for page in ${MAN} 97.for target in ${page:T:S/$/${FILTEXTENSION}/g} 98_manpages: ${target} 99${target}: ${page} 100 ${MANFILTER} < ${.ALLSRC} > ${.TARGET} 101.endfor 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} 107.endfor 108.endif 109.endfor 110.endif 111.else 112.if defined(MAN) && !empty(MAN) 113CLEANFILES+= ${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} 120.endfor 121.endfor 122.else 123_manpages: ${MAN} 124.endif 125.endif 126.endif 127 128.else 129 130ZEXT= ${MCOMPRESS_EXT} 131 132.if defined(MAN) && !empty(MAN) 133CLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g} 134CLEANFILES+= ${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} 141.else 142 ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} 143.endif 144.endfor 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} 151.else 152 ${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 153.endif 154.endfor 155.endif 156.endfor 157.endif 158 159.endif 160 161maninstall: _maninstall 162_maninstall: 163.if defined(MAN) && !empty(MAN) 164_maninstall: ${MAN} 165.if defined(NOMANCOMPRESS) 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} 173.endif 174.endfor 175.else 176 @set `echo ${.ALLSRC} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 177 while : ; do \ 178 case $$# in \ 179 0) break;; \ 180 1) echo "warn: missing extension: $$1"; break;; \ 181 esac; \ 182 page=$$1; shift; sect=$$1; shift; \ 183 d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ 184 ${ECHO} ${MINSTALL} $${page} $${d}; \ 185 ${MINSTALL} $${page} $${d}; \ 186 done 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} 191.endfor 192.endif 193.endif 194.else 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}/} 201.endif 202.endfor 203.endif 204.endif 205 206.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS) 207 @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 208 while : ; do \ 209 case $$# in \ 210 0) break;; \ 211 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ 212 esac; \ 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}; \ 220 done 221.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 222 @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 223 while : ; do \ 224 case $$# in \ 225 0) break;; \ 226 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ 227 esac; \ 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}; \ 235 done 236.endif 237.endif 238 239manlint: 240.if defined(MAN) && !empty(MAN) 241.for page in ${MAN} 242manlint: ${page}lint 243${page}lint: ${page} 244.if defined(MANFILTER) 245 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} -ww -z 246.else 247 ${MROFF_CMD} -ww -z ${.ALLSRC} 248.endif 249.endfor 250.endif 251