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${sect} The manual pages to be installed. For sections see 23# variable ${SECTIONS} 24# 25# _MANPAGES List of all man pages to be installed. 26# (``_MANPAGES=$MAN1 $MAN2 ... $MANn'') 27# 28# MCOMPRESS_CMD Program to compress man pages. Output is to 29# stdout. [${COMPRESS_CMD}] 30# 31# MLINKS List of manual page links (using a suffix). The 32# linked-to file must come first, the linked file 33# second, and there may be multiple pairs. The files 34# are hard-linked. 35# 36# NOMANCOMPRESS If you do not want unformatted manual pages to be 37# compressed when they are installed. [not set] 38# 39# NOMLINKS If you do not want install manual page links. [not set] 40# 41# MANFILTER command to pipe the raw man page though before compressing 42# or installing. Can be used to do sed substitution. 43# 44# MANBUILDCAT create preformatted manual pages in addition to normal 45# pages. [not set] 46# 47# MROFF_CMD command and flags to create preformatted pages 48# 49# +++ targets +++ 50# 51# maninstall: 52# Install the manual pages and their links. 53# 54 55MANSRC?= ${.CURDIR} 56MINSTALL= ${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 57 58CATDIR= ${MANDIR:H:S/$/\/cat/} 59CATEXT= .cat 60MROFF_CMD?= groff -Tascii -man 61 62MCOMPRESS_CMD?= ${COMPRESS_CMD} 63MCOMPRESS_EXT?= ${COMPRESS_EXT} 64 65SECTIONS= 1 1aout 2 3 4 5 6 7 8 9 n 66 67.undef _MANPAGES 68.for sect in ${SECTIONS} 69.if defined(MAN${sect}) && !empty(MAN${sect}) 70.SUFFIXES: .${sect} 71.PATH.${sect}: ${MANSRC} 72_MANPAGES+= ${MAN${sect}} 73.endif 74.endfor 75 76# XXX MANDEPEND is only used for groff, man/man, man/manpath, at and atrun. 77# It should be named more generally. 78all-man: ${MANDEPEND} 79 80.if defined(NOMANCOMPRESS) 81 82COPY= -c 83 84# Make special arrangements to filter to a temporary file at build time 85# for NOMANCOMPRESS. 86.if defined(MANFILTER) 87FILTEXTENSION= .filt 88.else 89FILTEXTENSION= 90.endif 91 92ZEXT= 93 94.if defined(MANFILTER) 95.for sect in ${SECTIONS} 96.if defined(MAN${sect}) && !empty(MAN${sect}) 97CLEANFILES+= ${MAN${sect}:T:S/$/${FILTEXTENSION}/g} 98CLEANFILES+= ${MAN${sect}:T:S/$/${CATEXT}${FILTEXTENSION}/g} 99.for page in ${MAN${sect}} 100.for target in ${page:T:S/$/${FILTEXTENSION}/g} 101all-man: ${target} 102${target}: ${page} 103 ${MANFILTER} < ${.ALLSRC} > ${.TARGET} 104.endfor 105.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 106.for target in ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} 107all-man: ${target} 108${target}: ${page} 109 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET} 110.endfor 111.endif 112.endfor 113.endif 114.endfor 115.else 116.for sect in ${SECTIONS} 117.if defined(MAN${sect}) && !empty(MAN${sect}) 118CLEANFILES+= ${MAN${sect}:T:S/$/${CATEXT}/g} 119.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 120.for page in ${MAN${sect}} 121.for target in ${page:T:S/$/${CATEXT}/g} 122all-man: ${target} 123${target}: ${page} 124 ${MROFF_CMD} ${.ALLSRC} > ${.TARGET} 125.endfor 126.endfor 127.endif 128.endif 129.endfor 130.endif 131 132.else 133 134ZEXT= ${MCOMPRESS_EXT} 135 136.for sect in ${SECTIONS} 137.if defined(MAN${sect}) && !empty(MAN${sect}) 138CLEANFILES+= ${MAN${sect}:T:S/$/${MCOMPRESS_EXT}/g} 139CLEANFILES+= ${MAN${sect}:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} 140.for page in ${MAN${sect}} 141.for target in ${page:T:S/$/${MCOMPRESS_EXT}/} 142all-man: ${target} 143${target}: ${page} 144.if defined(MANFILTER) 145 ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 146.else 147 ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} 148.endif 149.endfor 150.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 151.for target in ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/} 152all-man: ${target} 153${target}: ${page} 154.if defined(MANFILTER) 155 ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} 156.else 157 ${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 158.endif 159.endfor 160.endif 161.endfor 162.endif 163.endfor 164 165.endif 166 167maninstall:: 168.for sect in ${SECTIONS} 169.if defined(MAN${sect}) && !empty(MAN${sect}) 170maninstall:: ${MAN${sect}} 171.if defined(NOMANCOMPRESS) 172.if defined(MANFILTER) 173.for page in ${MAN${sect}} 174 ${MINSTALL} ${page:T:S/$/${FILTEXTENSION}/g} \ 175 ${DESTDIR}${MANDIR}${sect}${MANSUBDIR}/${page} 176.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 177 ${MINSTALL} ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ 178 ${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page} 179.endif 180.endfor 181.else 182 ${MINSTALL} ${.ALLSRC} ${DESTDIR}${MANDIR}${sect}${MANSUBDIR} 183.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 184.for page in ${MAN${sect}} 185 ${MINSTALL} ${page:T:S/$/${CATEXT}/} \ 186 ${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page:T} 187.endfor 188.endif 189.endif 190.else 191 ${MINSTALL} ${.ALLSRC:T:S/$/${MCOMPRESS_EXT}/g} \ 192 ${DESTDIR}${MANDIR}${sect}${MANSUBDIR} 193.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 194.for page in ${MAN${sect}} 195 ${MINSTALL} ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ 196 ${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/} 197.endfor 198.endif 199.endif 200.endif 201.endfor 202 203.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS) 204 @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 205 while : ; do \ 206 case $$# in \ 207 0) break;; \ 208 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ 209 esac; \ 210 name=$$1; shift; sect=$$1; shift; \ 211 l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ 212 name=$$1; shift; sect=$$1; shift; \ 213 t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ 214 ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ 215 rm -f $${t} $${t}${MCOMPRESS_EXT}; \ 216 ln $${l}${ZEXT} $${t}${ZEXT}; \ 217 done 218.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 219 @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 220 while : ; do \ 221 case $$# in \ 222 0) break;; \ 223 [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ 224 esac; \ 225 name=$$1; shift; sect=$$1; shift; \ 226 l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ 227 name=$$1; shift; sect=$$1; shift; \ 228 t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ 229 ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ 230 rm -f $${t} $${t}${MCOMPRESS_EXT}; \ 231 ln $${l}${ZEXT} $${t}${ZEXT}; \ 232 done 233.endif 234.endif 235