1# 2# The include file <bsd.man.mk> handles installing manual pages and 3# their links. 4# 5# 6# +++ variables +++ 7# 8# DESTDIR Change the tree where the man pages gets installed. [not set] 9# 10# MANDIR Base path for manual installation. [${SHAREDIR}/man/man] 11# 12# MANOWN Manual owner. [${SHAREOWN}] 13# 14# MANGRP Manual group. [${SHAREGRP}] 15# 16# MANMODE Manual mode. [${NOBINMODE}] 17# 18# MANSUBDIR Subdirectory under the manual page section, i.e. "/i386" 19# or "/tahoe" for machine specific manual pages. 20# 21# MAN The manual pages to be installed. For sections see 22# variable ${SECTIONS} 23# 24# MCOMPRESS_CMD Program to compress man pages. Output is to 25# stdout. [${COMPRESS_CMD}] 26# 27# MLINKS List of manual page links (using a suffix). The 28# linked-to file must come first, the linked file 29# second, and there may be multiple pairs. The files 30# are hard-linked. 31# 32# NO_MLINKS If you do not want install manual page links. [not set] 33# 34# MANFILTER command to pipe the raw man page through before compressing 35# or installing. Can be used to do sed substitution. 36# 37# MANBUILDCAT create preformatted manual pages in addition to normal 38# pages. [not set] 39# 40# MANDOC_CMD command and flags to create preformatted pages 41# 42# +++ targets +++ 43# 44# maninstall: 45# Install the manual pages and their links. 46# 47 48.if !target(__<bsd.init.mk>__) 49.error bsd.man.mk cannot be included directly. 50.endif 51 52.if ${MK_MANSPLITPKG} == "no" 53MINSTALL?= ${INSTALL} ${TAG_ARGS} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 54.else 55MINSTALL?= ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},man} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 56.endif 57 58CATDIR= ${MANDIR:H:S/$/\/cat/} 59CATEXT= .cat 60MANDOC_CMD?= mandoc -Tascii 61 62MCOMPRESS_CMD?= ${COMPRESS_CMD} 63MCOMPRESS_EXT?= ${COMPRESS_EXT} 64 65SECTIONS= 1 2 3 4 5 6 7 8 9 66.SUFFIXES: ${SECTIONS:S/^/./g} 67 68 69# Backwards compatibility. 70.if !defined(MAN) 71.for __sect in ${SECTIONS} 72.if defined(MAN${__sect}) && !empty(MAN${__sect}) 73MAN+= ${MAN${__sect}} 74.endif 75.endfor 76.endif 77 78all-man: 79 80.if ${MK_MANCOMPRESS} == "no" 81 82# Make special arrangements to filter to a temporary file at build time 83# for MK_MANCOMPRESS == no. 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} 98all-man: ${__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} 104all-man: ${__target} 105${__target}: ${__page} 106 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} > ${.TARGET} 107.endfor 108.endif 109.endfor 110.endif # !empty(MAN) 111.else # !defined(MANFILTER) 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} 117all-man: ${__target} 118${__target}: ${__page} 119 ${MANDOC_CMD} ${.ALLSRC} > ${.TARGET} 120.endfor 121.endfor 122.else 123all-man: ${MAN} 124.endif 125.endif 126.endif # defined(MANFILTER) 127 128.else # ${MK_MANCOMPRESS} == "yes" 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}/} 137all-man: ${__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}/} 147all-man: ${__target} 148${__target}: ${__page} 149.if defined(MANFILTER) 150 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} 151.else 152 ${MANDOC_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 153.endif 154.endfor 155.endif 156.endfor 157.endif 158 159.endif # ${MK_MANCOMPRESS} == "no" 160 161.if !defined(NO_MLINKS) && defined(MLINKS) && !empty(MLINKS) 162.for _oname _osect _dname _dsect in ${MLINKS:C/\.([^.]*)$/.\1 \1/} 163_MANLINKS+= ${MANDIR}${_osect}${MANSUBDIR}/${_oname} \ 164 ${MANDIR}${_dsect}${MANSUBDIR}/${_dname} 165.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 166_MANLINKS+= ${CATDIR}${_osect}${MANSUBDIR}/${_oname} \ 167 ${CATDIR}${_dsect}${MANSUBDIR}/${_dname} 168.endif 169.endfor 170.endif 171 172.if defined(MAN) && !empty(MAN) 173.if ${MK_STAGING_MAN} == "yes" 174STAGE_TARGETS+= stage_files 175_mansets:= ${MAN:E:O:u:M*[1-9]:@s@man$s@} 176STAGE_SETS+= ${_mansets} 177.for _page in ${MAN} 178stage_files.man${_page:T:E}: ${_page} 179.if target(${_page}${MCOMPRESS_EXT}) 180stage_files.man${_page:T:E}: ${_page}${MCOMPRESS_EXT} 181.endif 182STAGE_DIR.man${_page:T:E}?= ${STAGE_OBJTOP}${MANDIR}${_page:T:E}${MANSUBDIR} 183.endfor 184.if !defined(NO_MLINKS) && !empty(MLINKS) 185STAGE_SETS+= mlinks 186STAGE_TARGETS+= stage_links 187STAGE_LINKS.mlinks:= ${MLINKS:M*.[1-9]:@f@${f:S,^,${MANDIR}${f:E}${MANSUBDIR}/,}@} 188stage_links.mlinks: ${_mansets:@s@stage_files.$s@} 189.endif 190.endif 191.endif 192 193maninstall: 194.if defined(MAN) && !empty(MAN) 195maninstall: ${MAN} 196.if ${MK_MANCOMPRESS} == "no" 197.if defined(MANFILTER) 198.for __page in ${MAN} 199 ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \ 200 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page} 201.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 202 ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ 203 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page} 204.endif 205.endfor 206.else # !defined(MANFILTER) 207 @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \ 208 while : ; do \ 209 case $$# in \ 210 0) break;; \ 211 1) echo "warn: missing extension: $$1"; break;; \ 212 esac; \ 213 page=$$1; shift; sect=$$1; shift; \ 214 d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ 215 ${ECHO} ${MINSTALL} $${page} $${d}; \ 216 ${MINSTALL} $${page} $${d}; \ 217 done 218.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 219.for __page in ${MAN} 220 ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \ 221 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T} 222.endfor 223.endif 224.endif # defined(MANFILTER) 225.else # ${MK_MANCOMPRESS} == "yes" 226.for __page in ${MAN} 227 ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \ 228 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/ 229.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 230 ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ 231 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/} 232.endif 233.endfor 234.endif # ${MK_MANCOMPRESS} == "no" 235.endif 236.for l t in ${_MANLINKS} 237.if ${MK_MANSPLITPKG} == "no" 238 rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \ 239 ${INSTALL_MANLINK} ${TAG_ARGS} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} 240.else 241 rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \ 242 ${INSTALL_MANLINK} ${TAG_ARGS:D${TAG_ARGS},man} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} 243.endif 244.endfor 245 246manlint: 247.if defined(MAN) && !empty(MAN) 248.for __page in ${MAN} 249manlint: ${__page}lint 250${__page}lint: ${__page} 251.if defined(MANFILTER) 252 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint 253.else 254 ${MANDOC_CMD} -Tlint ${.ALLSRC} 255.endif 256.endfor 257.endif 258