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# NO_MLINKS If you do not want install manual page links. [not set] 34# 35# MANFILTER command to pipe the raw man page through before compressing 36# or installing. Can be used to do sed substitution. 37# 38# MANBUILDCAT create preformatted manual pages in addition to normal 39# pages. [not set] 40# 41# MANDOC_CMD command and flags to create preformatted pages 42# 43# +++ targets +++ 44# 45# maninstall: 46# Install the manual pages and their links. 47# 48 49.if !target(__<bsd.init.mk>__) 50.error bsd.man.mk cannot be included directly. 51.endif 52 53MINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 54 55CATDIR= ${MANDIR:H:S/$/\/cat/} 56CATEXT= .cat 57MANDOC_CMD?= mandoc -Tascii 58 59MCOMPRESS_CMD?= ${COMPRESS_CMD} 60MCOMPRESS_EXT?= ${COMPRESS_EXT} 61 62SECTIONS= 1 2 3 4 5 6 7 8 9 63.SUFFIXES: ${SECTIONS:S/^/./g} 64 65# Backwards compatibility. 66.if !defined(MAN) 67.for __sect in ${SECTIONS} 68.if defined(MAN${__sect}) && !empty(MAN${__sect}) 69MAN+= ${MAN${__sect}} 70.endif 71.endfor 72.endif 73 74_manpages: 75all-man: _manpages 76 77.if ${MK_MANCOMPRESS} == "no" 78 79# Make special arrangements to filter to a temporary file at build time 80# for MK_MANCOMPRESS == no. 81.if defined(MANFILTER) 82FILTEXTENSION= .filt 83.else 84FILTEXTENSION= 85.endif 86 87ZEXT= 88 89.if defined(MANFILTER) 90.if defined(MAN) && !empty(MAN) 91CLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g} 92CLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g} 93.for __page in ${MAN} 94.for __target in ${__page:T:S/$/${FILTEXTENSION}/g} 95_manpages: ${__target} 96${__target}: ${__page} 97 ${MANFILTER} < ${.ALLSRC} > ${.TARGET} 98.endfor 99.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 100.for __target in ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} 101_manpages: ${__target} 102${__target}: ${__page} 103 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} > ${.TARGET} 104.endfor 105.endif 106.endfor 107.endif # !empty(MAN) 108.else # !defined(MANFILTER) 109.if defined(MAN) && !empty(MAN) 110CLEANFILES+= ${MAN:T:S/$/${CATEXT}/g} 111.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 112.for __page in ${MAN} 113.for __target in ${__page:T:S/$/${CATEXT}/g} 114_manpages: ${__target} 115${__target}: ${__page} 116 ${MANDOC_CMD} ${.ALLSRC} > ${.TARGET} 117.endfor 118.endfor 119.else 120_manpages: ${MAN} 121.endif 122.endif 123.endif # defined(MANFILTER) 124 125.else # ${MK_MANCOMPRESS} == "yes" 126 127ZEXT= ${MCOMPRESS_EXT} 128 129.if defined(MAN) && !empty(MAN) 130.if ${MK_STAGING_MAN} == "yes" 131STAGE_TARGETS+= stage_files 132_mansets:= ${MAN:E:O:u:M*[1-9]:@s@man$s@} 133STAGE_SETS+= ${_mansets} 134.for _page in ${MAN} 135stage_files.man${_page:T:E}: ${_page} 136STAGE_DIR.man${_page:T:E}?= ${STAGE_OBJTOP}${MANDIR}${_page:T:E}${MANSUBDIR} 137.endfor 138.if !empty(MLINKS) 139STAGE_SETS+= mlinks 140STAGE_TARGETS+= stage_links 141STAGE_LINKS.mlinks:= ${MLINKS:@f@${f:S,^,${MANDIR}${f:E}${MANSUBDIR}/,}@} 142stage_links.mlinks: ${_mansets:@s@stage_files.$s@} 143.endif 144.endif 145 146CLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g} 147CLEANFILES+= ${MAN:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} 148.for __page in ${MAN} 149.for __target in ${__page:T:S/$/${MCOMPRESS_EXT}/} 150_manpages: ${__target} 151${__target}: ${__page} 152.if defined(MANFILTER) 153 ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 154.else 155 ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} 156.endif 157.endfor 158.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 159.for __target in ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/} 160_manpages: ${__target} 161${__target}: ${__page} 162.if defined(MANFILTER) 163 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} 164.else 165 ${MANDOC_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 166.endif 167.endfor 168.endif 169.endfor 170.endif 171 172.endif # ${MK_MANCOMPRESS} == "no" 173 174.if !defined(NO_MLINKS) && defined(MLINKS) && !empty(MLINKS) 175.for _oname _osect _dname _dsect in ${MLINKS:C/\.([^.]*)$/.\1 \1/} 176_MANLINKS+= ${MANDIR}${_osect}${MANSUBDIR}/${_oname} \ 177 ${MANDIR}${_dsect}${MANSUBDIR}/${_dname} 178.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 179_MANLINKS+= ${CATDIR}${_osect}${MANSUBDIR}/${_oname} \ 180 ${CATDIR}${_dsect}${MANSUBDIR}/${_dname} 181.endif 182.endfor 183.endif 184 185maninstall: _maninstall 186_maninstall: 187.if defined(MAN) && !empty(MAN) 188_maninstall: ${MAN} 189.if ${MK_MANCOMPRESS} == "no" 190.if defined(MANFILTER) 191.for __page in ${MAN} 192 ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \ 193 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page} 194.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 195 ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ 196 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page} 197.endif 198.endfor 199.else # !defined(MANFILTER) 200 @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \ 201 while : ; do \ 202 case $$# in \ 203 0) break;; \ 204 1) echo "warn: missing extension: $$1"; break;; \ 205 esac; \ 206 page=$$1; shift; sect=$$1; shift; \ 207 d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ 208 ${ECHO} ${MINSTALL} $${page} $${d}; \ 209 ${MINSTALL} $${page} $${d}; \ 210 done 211.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 212.for __page in ${MAN} 213 ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \ 214 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T} 215.endfor 216.endif 217.endif # defined(MANFILTER) 218.else # ${MK_MANCOMPRESS} == "yes" 219.for __page in ${MAN} 220 ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \ 221 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/ 222.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 223 ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ 224 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/} 225.endif 226.endfor 227.endif # ${MK_MANCOMPRESS} == "no" 228.endif 229.for l t in ${_MANLINKS} 230 rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \ 231 ${INSTALL_LINK} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} 232.endfor 233 234manlint: 235.if defined(MAN) && !empty(MAN) 236.for __page in ${MAN} 237manlint: ${__page}lint 238${__page}lint: ${__page} 239.if defined(MANFILTER) 240 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint 241.else 242 ${MANDOC_CMD} -Tlint ${.ALLSRC} 243.endif 244.endfor 245.endif 246