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# MANGROUPS A list of groups, each of which should be a variable containing 43# a list of manual pages in that group. By default one group is 44# defined called "MAN". 45# 46# For each group, group-specific options may be set: 47# <group>OWN, <group>GRP, <group>MODE and <group>PACKAGE. 48# 49# +++ targets +++ 50# 51# maninstall: 52# Install the manual pages and their links. 53# 54 55.if !target(__<bsd.init.mk>__) 56.error bsd.man.mk cannot be included directly. 57.endif 58 59MANGROUPS?= MAN 60 61# Backwards compatibility. 62MINSTALL?= ${MANINSTALL} 63 64CATDIR= ${MANDIR:H:S/$/\/cat/} 65CATEXT= .cat 66MANDOC_CMD?= mandoc -Tascii 67 68MCOMPRESS_CMD?= ${COMPRESS_CMD} 69MCOMPRESS_EXT?= ${COMPRESS_EXT} 70 71SECTIONS= 1 2 3 4 5 6 7 8 9 72.SUFFIXES: ${SECTIONS:S/^/./g} 73 74# Backwards compatibility. 75.if !defined(MAN) 76.for __sect in ${SECTIONS} 77MANGROUPS+= MAN${__sect} 78.endfor 79.endif 80 81# Following the conventions of MANGROUPS, manpage links should be defined 82# as ${group}LINKS, which means the default groups' links would be called 83# MANLINKS. However it's actually called MLINKS, so for compatibility, 84# use ${MLINKS} as the default group's links if it's set. 85.if defined(MLINKS) 86MANLINKS= ${MLINKS} 87.endif 88 89maninstall: realmaninstall manlinksinstall .PHONY 90# Make sure all manpages are installed before we try to link any. 91.ORDER: realmaninstall manlinksinstall 92realmaninstall: .PHONY 93manlinksinstall: .PHONY 94 95all-man: 96 97.for __group in ${MANGROUPS} 98 99realmaninstall: realmaninstall-${__group} 100manlinksinstall: manlinksinstall-${__group} 101 102${__group}OWN?= ${MANOWN} 103${__group}GRP?= ${MANGRP} 104${__group}MODE?= ${MANMODE} 105 106# Tag processing is only done for NO_ROOT installs. 107.if defined(NO_ROOT) 108 109.if !defined(${__group}TAGS) || ! ${${__group}TAGS:Mpackage=*} 110.if ${MK_MANSPLITPKG} == "no" 111${__group}TAGS+= package=${${__group}PACKAGE:U${PACKAGE:Uutilities}} 112.else 113${__group}TAGS+= package=${${__group}PACKAGE:U${PACKAGE:Uutilities}}-man 114.endif 115.endif 116 117${__group}TAG_ARGS= -T ${${__group}TAGS:ts,:[*]} 118.endif # defined(NO_ROOT) 119 120${__group}INSTALL?= ${INSTALL} ${${__group}TAG_ARGS} \ 121 -o ${${__group}OWN} -g ${${__group}GRP} -m ${${__group}MODE} 122 123.if ${MK_MANCOMPRESS} == "no" 124 125# Make special arrangements to filter to a temporary file at build time 126# for MK_MANCOMPRESS == no. 127.if defined(MANFILTER) 128FILTEXTENSION= .filt 129.else 130FILTEXTENSION= 131.endif 132 133ZEXT= 134 135.if defined(MANFILTER) 136.if defined(${__group}) && !empty(${__group}) 137CLEANFILES+= ${${__group}:T:S/$/${FILTEXTENSION}/g} 138CLEANFILES+= ${${__group}:T:S/$/${CATEXT}${FILTEXTENSION}/g} 139.for __page in ${${__group}} 140# Escape colons in target names to support manual pages whose 141# filenames contain colons. 142.for __target in ${__page:T:S/:/\:/g:S/$/${FILTEXTENSION}/g} 143all-man: ${__target} 144${__target}: ${__page} 145 ${MANFILTER} < ${.ALLSRC} > ${.TARGET} 146.endfor 147.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 148.for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}${FILTEXTENSION}/g} 149all-man: ${__target} 150${__target}: ${__page} 151 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} > ${.TARGET} 152.endfor 153.endif 154.endfor 155.endif # !empty(${__group}) 156.else # !defined(MANFILTER) 157.if defined(${__group}) && !empty(${__group}) 158CLEANFILES+= ${${__group}:T:S/$/${CATEXT}/g} 159.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 160.for __page in ${${__group}} 161.for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}/g} 162all-man: ${__target} 163${__target}: ${__page} 164 ${MANDOC_CMD} ${.ALLSRC} > ${.TARGET} 165.endfor 166.endfor 167.else 168all-man: ${${__group}} 169.endif 170.endif 171.endif # defined(MANFILTER) 172 173.else # ${MK_MANCOMPRESS} == "yes" 174 175ZEXT= ${MCOMPRESS_EXT} 176 177.if defined(${__group}) && !empty(${__group}) 178CLEANFILES+= ${${__group}:T:S/$/${MCOMPRESS_EXT}/g} 179CLEANFILES+= ${${__group}:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} 180.for __page in ${${__group}} 181.for __target in ${__page:T:S/:/\:/g:S/$/${MCOMPRESS_EXT}/} 182all-man: ${__target} 183${__target}: ${__page} 184.if defined(MANFILTER) 185 ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 186.else 187 ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} 188.endif 189.endfor 190.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 191.for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}${MCOMPRESS_EXT}/} 192all-man: ${__target} 193${__target}: ${__page} 194.if defined(MANFILTER) 195 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} 196.else 197 ${MANDOC_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 198.endif 199.endfor 200.endif 201.endfor 202.endif 203 204.endif # ${MK_MANCOMPRESS} == "no" 205 206_MANLINKS= 207.if !defined(NO_MLINKS) && defined(${__group}LINKS) && !empty(${__group}LINKS) 208.for _oname _osect _dname _dsect in ${${__group}LINKS:C/\.([^.]*)$/.\1 \1/} 209_MANLINKS+= ${MANDIR}${_osect}${MANSUBDIR}/${_oname} \ 210 ${MANDIR}${_dsect}${MANSUBDIR}/${_dname} 211.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 212_MANLINKS+= ${CATDIR}${_osect}${MANSUBDIR}/${_oname} \ 213 ${CATDIR}${_dsect}${MANSUBDIR}/${_dname} 214.endif 215.endfor 216.endif 217 218.if defined(${__group}) && !empty(${__group}) 219.if ${MK_STAGING_MAN} == "yes" 220STAGE_TARGETS+= stage_files.${__group} 221_mansets.${__group}:= ${${__group}:E:O:u:M*[1-9]:@s@man$s@} 222STAGE_SETS+= ${_mansets.${__group}} 223.for _page in ${${__group}} 224stage_files.${__group}.man${_page:T:E}: ${_page} 225.if target(${_page}${MCOMPRESS_EXT}) 226stage_files.${__group}.man${_page:T:E}: ${_page}${MCOMPRESS_EXT} 227.endif 228STAGE_DIR.${__group}.man${_page:T:E}?= ${STAGE_OBJTOP}${MANDIR}${_page:T:E}${MANSUBDIR} 229.endfor 230.if !defined(NO_MLINKS) && !empty(${__group}LINKS) 231STAGE_SETS+= mlinks.${__group} 232STAGE_TARGETS+= stage_links.${__group} 233STAGE_LINKS.mlinks.${__group}:= ${${__group}LINKS:M*.[1-9]:@f@${f:S,^,${MANDIR}${f:E}${MANSUBDIR}/,}@} 234stage_links.mlinks.${__group}: ${_mansets.${__group}:@s@stage_files.${__group}.$s@} 235.endif 236.endif 237.endif 238 239realmaninstall-${__group}: 240.if defined(${__group}) && !empty(${__group}) 241realmaninstall-${__group}: ${${__group}} 242.if ${MK_MANCOMPRESS} == "no" 243.if defined(MANFILTER) 244.for __page in ${${__group}} 245 ${${__group}INSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \ 246 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page} 247.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 248 ${${__group}INSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ 249 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page} 250.endif 251.endfor 252.else # !defined(MANFILTER) 253 @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \ 254 while : ; do \ 255 case $$# in \ 256 0) break;; \ 257 1) echo "warn: missing extension: $$1"; break;; \ 258 esac; \ 259 page=$$1; shift; sect=$$1; shift; \ 260 d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ 261 ${ECHO} ${${__group}INSTALL} $${page} $${d}; \ 262 ${${__group}INSTALL} $${page} $${d}; \ 263 done 264.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 265.for __page in ${${__group}} 266 ${${__group}INSTALL} ${__page:T:S/$/${CATEXT}/} \ 267 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T} 268.endfor 269.endif 270.endif # defined(MANFILTER) 271.else # ${MK_MANCOMPRESS} == "yes" 272.for __page in ${${__group}} 273 ${${__group}INSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \ 274 ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/ 275.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 276 ${${__group}INSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ 277 ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/} 278.endif 279.endfor 280.endif # ${MK_MANCOMPRESS} == "no" 281.endif 282 283manlinksinstall-${__group}: 284.for l t in ${_MANLINKS} 285# On MacOS, assume case folding FS, and don't install links from foo.x to FOO.x. 286.if ${.MAKE.OS} != "Darwin" || ${l:tu} != ${t:tu} 287 ${INSTALL_MANLINK} ${${__group}TAG_ARGS} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} 288.endif 289.endfor 290 291manlint: 292.if defined(${__group}) && !empty(${__group}) 293.for __page in ${${__group}} 294manlint: ${__page:S/:/\:/g}lint 295${__page:S/:/\:/g}lint: ${__page} 296.if defined(MANFILTER) 297 ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint 298.else 299 ${MANDOC_CMD} -Tlint ${.ALLSRC} 300.endif 301.endfor 302.endif 303 304.endfor # __group in ${MANGROUPS} 305