17f3dea24SPeter Wemm# $FreeBSD$ 253996fadSWolfram Schneider# 353996fadSWolfram Schneider# The include file <bsd.man.mk> handles installing manual pages and 470e244f8SWolfram Schneider# their links. 553996fadSWolfram Schneider# 653996fadSWolfram Schneider# 753996fadSWolfram Schneider# +++ variables +++ 853996fadSWolfram Schneider# 953996fadSWolfram Schneider# DESTDIR Change the tree where the man pages gets installed. [not set] 1053996fadSWolfram Schneider# 1153996fadSWolfram Schneider# MANDIR Base path for manual installation. [${SHAREDIR}/man/man] 1253996fadSWolfram Schneider# 1353996fadSWolfram Schneider# MANOWN Manual owner. [${SHAREOWN}] 1453996fadSWolfram Schneider# 1553996fadSWolfram Schneider# MANGRP Manual group. [${SHAREGRP}] 1653996fadSWolfram Schneider# 1753996fadSWolfram Schneider# MANMODE Manual mode. [${NOBINMODE}] 1853996fadSWolfram Schneider# 1953996fadSWolfram Schneider# MANSUBDIR Subdirectory under the manual page section, i.e. "/i386" 2053996fadSWolfram Schneider# or "/tahoe" for machine specific manual pages. 2153996fadSWolfram Schneider# 22862d3deaSRuslan Ermilov# MAN The manual pages to be installed. For sections see 2353996fadSWolfram Schneider# variable ${SECTIONS} 2453996fadSWolfram Schneider# 25f7ea12a0SWolfram Schneider# MCOMPRESS_CMD Program to compress man pages. Output is to 26f7ea12a0SWolfram Schneider# stdout. [${COMPRESS_CMD}] 2753996fadSWolfram Schneider# 2853996fadSWolfram Schneider# MLINKS List of manual page links (using a suffix). The 2953996fadSWolfram Schneider# linked-to file must come first, the linked file 3053996fadSWolfram Schneider# second, and there may be multiple pairs. The files 3153996fadSWolfram Schneider# are hard-linked. 3253996fadSWolfram Schneider# 339a9bc31fSRuslan Ermilov# NO_MLINKS If you do not want install manual page links. [not set] 34236fc12aSWolfram Schneider# 351663ea58STim Vanderhoek# MANFILTER command to pipe the raw man page through before compressing 36d5dcd8e6SPeter Wemm# or installing. Can be used to do sed substitution. 3753996fadSWolfram Schneider# 385191ded8SPaul Traina# MANBUILDCAT create preformatted manual pages in addition to normal 395191ded8SPaul Traina# pages. [not set] 405191ded8SPaul Traina# 410df7827eSBaptiste Daroussin# MANDOC_CMD command and flags to create preformatted pages 425191ded8SPaul Traina# 4353996fadSWolfram Schneider# +++ targets +++ 4453996fadSWolfram Schneider# 4553996fadSWolfram Schneider# maninstall: 4653996fadSWolfram Schneider# Install the manual pages and their links. 4753996fadSWolfram Schneider# 4853996fadSWolfram Schneider 492bdaf7e8SRuslan Ermilov.if !target(__<bsd.init.mk>__) 502bdaf7e8SRuslan Ermilov.error bsd.man.mk cannot be included directly. 512bdaf7e8SRuslan Ermilov.endif 522bdaf7e8SRuslan Ermilov 5381c06103SRuslan ErmilovMINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 54afe61c15SRodney W. Grimes 555191ded8SPaul TrainaCATDIR= ${MANDIR:H:S/$/\/cat/} 565191ded8SPaul TrainaCATEXT= .cat 570df7827eSBaptiste DaroussinMANDOC_CMD?= mandoc -Tascii 585191ded8SPaul Traina 59f7ea12a0SWolfram SchneiderMCOMPRESS_CMD?= ${COMPRESS_CMD} 60f7ea12a0SWolfram SchneiderMCOMPRESS_EXT?= ${COMPRESS_EXT} 61afe61c15SRodney W. Grimes 628b4f1f91SBrooks DavisSECTIONS= 1 2 3 4 5 6 7 8 9 6309fa52f8SRuslan Ermilov.SUFFIXES: ${SECTIONS:S/^/./g} 64862d3deaSRuslan Ermilov 65862d3deaSRuslan Ermilov# Backwards compatibility. 6609fa52f8SRuslan Ermilov.if !defined(MAN) 675b83a06cSRuslan Ermilov.for __sect in ${SECTIONS} 685b83a06cSRuslan Ermilov.if defined(MAN${__sect}) && !empty(MAN${__sect}) 695b83a06cSRuslan ErmilovMAN+= ${MAN${__sect}} 70eb896871SBruce Evans.endif 71eb896871SBruce Evans.endfor 7209fa52f8SRuslan Ermilov.endif 73eb896871SBruce Evans 74afeaaa84SRuslan Ermilov_manpages: 75afeaaa84SRuslan Ermilovall-man: _manpages 76e8f9a073SBruce Evans 770abe2561SWarner Losh.if ${MK_MANCOMPRESS} == "no" 78e8f9a073SBruce Evans 79eb0085f4SPeter Wemm# Make special arrangements to filter to a temporary file at build time 800abe2561SWarner Losh# for MK_MANCOMPRESS == no. 81eb0085f4SPeter Wemm.if defined(MANFILTER) 82eb0085f4SPeter WemmFILTEXTENSION= .filt 83eb0085f4SPeter Wemm.else 84eb0085f4SPeter WemmFILTEXTENSION= 85eb0085f4SPeter Wemm.endif 86eb0085f4SPeter Wemm 87e8f9a073SBruce EvansZEXT= 88e8f9a073SBruce Evans 89d5dcd8e6SPeter Wemm.if defined(MANFILTER) 90862d3deaSRuslan Ermilov.if defined(MAN) && !empty(MAN) 91862d3deaSRuslan ErmilovCLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g} 92862d3deaSRuslan ErmilovCLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g} 935b83a06cSRuslan Ermilov.for __page in ${MAN} 945b83a06cSRuslan Ermilov.for __target in ${__page:T:S/$/${FILTEXTENSION}/g} 955b83a06cSRuslan Ermilov_manpages: ${__target} 965b83a06cSRuslan Ermilov${__target}: ${__page} 975e7d3affSPeter Wemm ${MANFILTER} < ${.ALLSRC} > ${.TARGET} 98d5dcd8e6SPeter Wemm.endfor 995d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1005b83a06cSRuslan Ermilov.for __target in ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} 1015b83a06cSRuslan Ermilov_manpages: ${__target} 1025b83a06cSRuslan Ermilov${__target}: ${__page} 1030df7827eSBaptiste Daroussin ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} > ${.TARGET} 104d5dcd8e6SPeter Wemm.endfor 105d5dcd8e6SPeter Wemm.endif 106d5dcd8e6SPeter Wemm.endfor 107c22afe52SBryan Drewery.endif # !empty(MAN) 108c22afe52SBryan Drewery.else # !defined(MANFILTER) 109862d3deaSRuslan Ermilov.if defined(MAN) && !empty(MAN) 110862d3deaSRuslan ErmilovCLEANFILES+= ${MAN:T:S/$/${CATEXT}/g} 1115d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1125b83a06cSRuslan Ermilov.for __page in ${MAN} 1135b83a06cSRuslan Ermilov.for __target in ${__page:T:S/$/${CATEXT}/g} 1145b83a06cSRuslan Ermilov_manpages: ${__target} 1155b83a06cSRuslan Ermilov${__target}: ${__page} 1160df7827eSBaptiste Daroussin ${MANDOC_CMD} ${.ALLSRC} > ${.TARGET} 1175191ded8SPaul Traina.endfor 1185191ded8SPaul Traina.endfor 1198f08b6b2SRuslan Ermilov.else 1208f08b6b2SRuslan Ermilov_manpages: ${MAN} 1215191ded8SPaul Traina.endif 1225191ded8SPaul Traina.endif 123c22afe52SBryan Drewery.endif # defined(MANFILTER) 124d5dcd8e6SPeter Wemm 125c22afe52SBryan Drewery.else # ${MK_MANCOMPRESS} == "yes" 126e8f9a073SBruce Evans 127f7ea12a0SWolfram SchneiderZEXT= ${MCOMPRESS_EXT} 128e8f9a073SBruce Evans 129862d3deaSRuslan Ermilov.if defined(MAN) && !empty(MAN) 1301e344376SSimon J. Gerraty.if ${MK_STAGING_MAN} == "yes" 131eef72759SSimon J. GerratySTAGE_TARGETS+= stage_files 132924b88f6SSimon J. Gerraty_mansets:= ${MAN:E:O:u:M*[1-9]:@s@man$s@} 13309cdd180SSimon J. GerratySTAGE_SETS+= ${_mansets} 13409cdd180SSimon J. Gerraty.for _page in ${MAN} 13509cdd180SSimon J. Gerratystage_files.man${_page:T:E}: ${_page} 13609cdd180SSimon J. GerratySTAGE_DIR.man${_page:T:E}?= ${STAGE_OBJTOP}${MANDIR}${_page:T:E}${MANSUBDIR} 13709cdd180SSimon J. Gerraty.endfor 13809cdd180SSimon J. Gerraty.if !empty(MLINKS) 1391e344376SSimon J. GerratySTAGE_SETS+= mlinks 140eef72759SSimon J. GerratySTAGE_TARGETS+= stage_links 1411e344376SSimon J. GerratySTAGE_LINKS.mlinks:= ${MLINKS:@f@${f:S,^,${MANDIR}${f:E}${MANSUBDIR}/,}@} 1421e344376SSimon J. Gerratystage_links.mlinks: ${_mansets:@s@stage_files.$s@} 14309cdd180SSimon J. Gerraty.endif 14409cdd180SSimon J. Gerraty.endif 14509cdd180SSimon J. Gerraty 146862d3deaSRuslan ErmilovCLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g} 147862d3deaSRuslan ErmilovCLEANFILES+= ${MAN:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} 1485b83a06cSRuslan Ermilov.for __page in ${MAN} 1495b83a06cSRuslan Ermilov.for __target in ${__page:T:S/$/${MCOMPRESS_EXT}/} 1505b83a06cSRuslan Ermilov_manpages: ${__target} 1515b83a06cSRuslan Ermilov${__target}: ${__page} 1525e7d3affSPeter Wemm.if defined(MANFILTER) 153f7ea12a0SWolfram Schneider ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 154d5dcd8e6SPeter Wemm.else 155f7ea12a0SWolfram Schneider ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} 156d5dcd8e6SPeter Wemm.endif 157e8f9a073SBruce Evans.endfor 1585d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1595b83a06cSRuslan Ermilov.for __target in ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/} 1605b83a06cSRuslan Ermilov_manpages: ${__target} 1615b83a06cSRuslan Ermilov${__target}: ${__page} 1625191ded8SPaul Traina.if defined(MANFILTER) 1630df7827eSBaptiste Daroussin ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} 1645191ded8SPaul Traina.else 1650df7827eSBaptiste Daroussin ${MANDOC_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 1665191ded8SPaul Traina.endif 1675191ded8SPaul Traina.endfor 1685191ded8SPaul Traina.endif 169e8f9a073SBruce Evans.endfor 170e8f9a073SBruce Evans.endif 171e8f9a073SBruce Evans 172c22afe52SBryan Drewery.endif # ${MK_MANCOMPRESS} == "no" 1733585b293SGarrett Wollman 174*5f3a77a5SBryan Drewery.if !defined(NO_MLINKS) && defined(MLINKS) && !empty(MLINKS) 175*5f3a77a5SBryan Drewery.for _oname _osect _dname _dsect in ${MLINKS:C/\.([^.]*)$/.\1 \1/} 176*5f3a77a5SBryan Drewery_MANLINKS+= ${MANDIR}${_osect}${MANSUBDIR}/${_oname} \ 177*5f3a77a5SBryan Drewery ${MANDIR}${_dsect}${MANSUBDIR}/${_dname} 178*5f3a77a5SBryan Drewery.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 179*5f3a77a5SBryan Drewery_MANLINKS+= ${CATDIR}${_osect}${MANSUBDIR}/${_oname} \ 180*5f3a77a5SBryan Drewery ${CATDIR}${_dsect}${MANSUBDIR}/${_dname} 181*5f3a77a5SBryan Drewery.endif 182*5f3a77a5SBryan Drewery.endfor 183*5f3a77a5SBryan Drewery.endif 184*5f3a77a5SBryan Drewery 185afeaaa84SRuslan Ermilovmaninstall: _maninstall 186afeaaa84SRuslan Ermilov_maninstall: 187862d3deaSRuslan Ermilov.if defined(MAN) && !empty(MAN) 188afeaaa84SRuslan Ermilov_maninstall: ${MAN} 1890abe2561SWarner Losh.if ${MK_MANCOMPRESS} == "no" 190eb0085f4SPeter Wemm.if defined(MANFILTER) 1915b83a06cSRuslan Ermilov.for __page in ${MAN} 1925b83a06cSRuslan Ermilov ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \ 1935b83a06cSRuslan Ermilov ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page} 1945d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1955b83a06cSRuslan Ermilov ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ 1965b83a06cSRuslan Ermilov ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page} 1975191ded8SPaul Traina.endif 198eb0085f4SPeter Wemm.endfor 199c22afe52SBryan Drewery.else # !defined(MANFILTER) 200c22afe52SBryan Drewery @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \ 201c22afe52SBryan Drewery while : ; do \ 202c22afe52SBryan Drewery case $$# in \ 203c22afe52SBryan Drewery 0) break;; \ 204c22afe52SBryan Drewery 1) echo "warn: missing extension: $$1"; break;; \ 205c22afe52SBryan Drewery esac; \ 206c22afe52SBryan Drewery page=$$1; shift; sect=$$1; shift; \ 207c22afe52SBryan Drewery d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ 208c22afe52SBryan Drewery ${ECHO} ${MINSTALL} $${page} $${d}; \ 209c22afe52SBryan Drewery ${MINSTALL} $${page} $${d}; \ 210c22afe52SBryan Drewery done 2115d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 2125b83a06cSRuslan Ermilov.for __page in ${MAN} 2135b83a06cSRuslan Ermilov ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \ 2145b83a06cSRuslan Ermilov ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T} 2155191ded8SPaul Traina.endfor 2165191ded8SPaul Traina.endif 217c22afe52SBryan Drewery.endif # defined(MANFILTER) 218c22afe52SBryan Drewery.else # ${MK_MANCOMPRESS} == "yes" 2195b83a06cSRuslan Ermilov.for __page in ${MAN} 2205b83a06cSRuslan Ermilov ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \ 22161c20fc7SBryan Drewery ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/ 2225d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 2235b83a06cSRuslan Ermilov ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ 2245b83a06cSRuslan Ermilov ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/} 225973f098aSGarrett Wollman.endif 226973f098aSGarrett Wollman.endfor 227c22afe52SBryan Drewery.endif # ${MK_MANCOMPRESS} == "no" 228862d3deaSRuslan Ermilov.endif 229*5f3a77a5SBryan Drewery.for l t in ${_MANLINKS} 230*5f3a77a5SBryan Drewery rm -f ${DESTDIR}${t} ${DESTDIR}${t}${MCOMPRESS_EXT}; \ 231*5f3a77a5SBryan Drewery ${INSTALL_LINK} ${DESTDIR}${l}${ZEXT} ${DESTDIR}${t}${ZEXT} 232a82117a6SBaptiste Daroussin.endfor 23359e44d72SRuslan Ermilov 23459e44d72SRuslan Ermilovmanlint: 23559e44d72SRuslan Ermilov.if defined(MAN) && !empty(MAN) 2365b83a06cSRuslan Ermilov.for __page in ${MAN} 2375b83a06cSRuslan Ermilovmanlint: ${__page}lint 2385b83a06cSRuslan Ermilov${__page}lint: ${__page} 23959e44d72SRuslan Ermilov.if defined(MANFILTER) 2402f335df9SBaptiste Daroussin ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint 24159e44d72SRuslan Ermilov.else 2422f335df9SBaptiste Daroussin ${MANDOC_CMD} -Tlint ${.ALLSRC} 24359e44d72SRuslan Ermilov.endif 24459e44d72SRuslan Ermilov.endfor 24559e44d72SRuslan Ermilov.endif 246