bsd.man.mk revision 74806
11556Srgrimes# $FreeBSD: head/share/mk/bsd.man.mk 74806 2001-03-26 08:04:11Z ru $ 21556Srgrimes# 31556Srgrimes# The include file <bsd.man.mk> handles installing manual pages and 41556Srgrimes# their links. 51556Srgrimes# 61556Srgrimes# 71556Srgrimes# +++ variables +++ 81556Srgrimes# 91556Srgrimes# DESTDIR Change the tree where the man pages gets installed. [not set] 101556Srgrimes# 111556Srgrimes# MANDIR Base path for manual installation. [${SHAREDIR}/man/man] 121556Srgrimes# 131556Srgrimes# MANOWN Manual owner. [${SHAREOWN}] 141556Srgrimes# 151556Srgrimes# MANGRP Manual group. [${SHAREGRP}] 161556Srgrimes# 171556Srgrimes# MANMODE Manual mode. [${NOBINMODE}] 181556Srgrimes# 191556Srgrimes# MANSUBDIR Subdirectory under the manual page section, i.e. "/i386" 201556Srgrimes# or "/tahoe" for machine specific manual pages. 211556Srgrimes# 221556Srgrimes# MAN The manual pages to be installed. For sections see 231556Srgrimes# variable ${SECTIONS} 241556Srgrimes# 251556Srgrimes# MCOMPRESS_CMD Program to compress man pages. Output is to 261556Srgrimes# stdout. [${COMPRESS_CMD}] 271556Srgrimes# 281556Srgrimes# MLINKS List of manual page links (using a suffix). The 291556Srgrimes# linked-to file must come first, the linked file 301556Srgrimes# second, and there may be multiple pairs. The files 311556Srgrimes# are hard-linked. 321556Srgrimes# 331556Srgrimes# NOMANCOMPRESS If you do not want unformatted manual pages to be 341556Srgrimes# compressed when they are installed. [not set] 351556Srgrimes# 361556Srgrimes# NOMLINKS If you do not want install manual page links. [not set] 371556Srgrimes# 3836150Scharnier# MANFILTER command to pipe the raw man page through before compressing 3936150Scharnier# or installing. Can be used to do sed substitution. 4036150Scharnier# 4136150Scharnier# MANBUILDCAT create preformatted manual pages in addition to normal 4239049Scracauer# pages. [not set] 431556Srgrimes# 441556Srgrimes# MROFF_CMD command and flags to create preformatted pages 451556Srgrimes# 461556Srgrimes# +++ targets +++ 471556Srgrimes# 481556Srgrimes# maninstall: 491556Srgrimes# Install the manual pages and their links. 501556Srgrimes# 5139049Scracauer 5217987SpeterMINSTALL= ${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 5317987Speter 541556SrgrimesCATDIR= ${MANDIR:H:S/$/\/cat/} 551556SrgrimesCATEXT= .cat 561556SrgrimesMROFF_CMD?= groff -Tascii -man 571556Srgrimes 581556SrgrimesMCOMPRESS_CMD?= ${COMPRESS_CMD} 591556SrgrimesMCOMPRESS_EXT?= ${COMPRESS_EXT} 6020425Ssteve 6117987SpeterSECTIONS= 1 1aout 2 3 4 5 6 7 8 9 n 6217987Speter 6325222Ssteve.for sect in ${SECTIONS} 641556Srgrimes.SUFFIXES: .${sect} 651556Srgrimes 661556Srgrimes# Backwards compatibility. 671556Srgrimes.if defined(MAN${sect}) && !empty(MAN${sect}) 681556SrgrimesMAN+= ${MAN${sect}} 691556Srgrimes.endif 701556Srgrimes 711556Srgrimes.endfor 721556Srgrimes 731556Srgrimesall-man: 741556Srgrimes 751556Srgrimes.if defined(NOMANCOMPRESS) 761556Srgrimes 7725222SsteveCOPY= -c 7817987Speter 7917987Speter# Make special arrangements to filter to a temporary file at build time 801556Srgrimes# for NOMANCOMPRESS. 811556Srgrimes.if defined(MANFILTER) 821556SrgrimesFILTEXTENSION= .filt 831556Srgrimes.else 841556SrgrimesFILTEXTENSION= 851556Srgrimes.endif 861556Srgrimes 871556SrgrimesZEXT= 881556Srgrimes 891556Srgrimes.if defined(MANFILTER) 901556Srgrimes.if defined(MAN) && !empty(MAN) 911556SrgrimesCLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g} 921556SrgrimesCLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g} 931556Srgrimes.for page in ${MAN} 941556Srgrimes.for target in ${page:T:S/$/${FILTEXTENSION}/g} 9525222Ssteveall-man: ${target} 961556Srgrimes${target}: ${page} 971556Srgrimes ${MANFILTER} < ${.ALLSRC} > ${.TARGET} 981556Srgrimes.endfor 991556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1001556Srgrimes.for target in ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} 1011556Srgrimesall-man: ${target} 1021556Srgrimes${target}: ${page} 1031556Srgrimes ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET} 1041556Srgrimes.endfor 1051556Srgrimes.endif 1061556Srgrimes.endfor 1071556Srgrimes.endif 1081556Srgrimes.else 1091556Srgrimes.if defined(MAN) && !empty(MAN) 1101556SrgrimesCLEANFILES+= ${MAN:T:S/$/${CATEXT}/g} 1111556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1121556Srgrimes.for page in ${MAN} 1131556Srgrimes.for target in ${page:T:S/$/${CATEXT}/g} 1141556Srgrimesall-man: ${target} 1151556Srgrimes${target}: ${page} 1161556Srgrimes ${MROFF_CMD} ${.ALLSRC} > ${.TARGET} 1171556Srgrimes.endfor 1181556Srgrimes.endfor 1191556Srgrimes.endif 1201556Srgrimes.endif 1211556Srgrimes.endif 1221556Srgrimes 1231556Srgrimes.else 1241556Srgrimes 1251556SrgrimesZEXT= ${MCOMPRESS_EXT} 1261556Srgrimes 1271556Srgrimes.if defined(MAN) && !empty(MAN) 1281556SrgrimesCLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g} 1291556SrgrimesCLEANFILES+= ${MAN:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} 13020425Ssteve.for page in ${MAN} 13117987Speter.for target in ${page:T:S/$/${MCOMPRESS_EXT}/} 13217987Speterall-man: ${target} 13325222Ssteve${target}: ${page} 1341556Srgrimes.if defined(MANFILTER) 1351556Srgrimes ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 1361556Srgrimes.else 1371556Srgrimes ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} 1381556Srgrimes.endif 1391556Srgrimes.endfor 1401556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1411556Srgrimes.for target in ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/} 1421556Srgrimesall-man: ${target} 1431556Srgrimes${target}: ${page} 1441556Srgrimes.if defined(MANFILTER) 1451556Srgrimes ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} 1461556Srgrimes.else 1471556Srgrimes ${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} 1481556Srgrimes.endif 1491556Srgrimes.endfor 1501556Srgrimes.endif 1511556Srgrimes.endfor 1521556Srgrimes.endif 1531556Srgrimes 1541556Srgrimes.endif 1551556Srgrimes 1561556Srgrimesmaninstall:: 1571556Srgrimes.if defined(MAN) && !empty(MAN) 1581556Srgrimesmaninstall:: ${MAN} 1591556Srgrimes.if defined(NOMANCOMPRESS) 1601556Srgrimes.if defined(MANFILTER) 1611556Srgrimes.for page in ${MAN} 1621556Srgrimes ${MINSTALL} ${page:T:S/$/${FILTEXTENSION}/g} \ 1631556Srgrimes ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR}/${page} 1641556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1651556Srgrimes ${MINSTALL} ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ 1661556Srgrimes ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page} 1671556Srgrimes.endif 1681556Srgrimes.endfor 1691556Srgrimes.else 1701556Srgrimes @set `echo ${.ALLSRC} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 1711556Srgrimes while : ; do \ 1721556Srgrimes case $$# in \ 1731556Srgrimes 0) break;; \ 1741556Srgrimes 1) echo "warn: missing extension: $$1"; break;; \ 1751556Srgrimes esac; \ 1761556Srgrimes page=$$1; shift; sect=$$1; shift; \ 1771556Srgrimes d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ 1781556Srgrimes ${ECHO} ${MINSTALL} $${page} $${d}; \ 1791556Srgrimes ${MINSTALL} $${page} $${d}; \ 1801556Srgrimes done 1811556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1821556Srgrimes.for page in ${MAN} 1831556Srgrimes ${MINSTALL} ${page:T:S/$/${CATEXT}/} \ 1841556Srgrimes ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T} 1851556Srgrimes.endfor 1861556Srgrimes.endif 1871556Srgrimes.endif 1881556Srgrimes.else 1891556Srgrimes.for page in ${MAN} 1901556Srgrimes ${MINSTALL} ${page:T:S/$/${MCOMPRESS_EXT}/g} \ 1911556Srgrimes ${DESTDIR}${MANDIR}${page:E}${MANSUBDIR} 1921556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 1931556Srgrimes ${MINSTALL} ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ 1941556Srgrimes ${DESTDIR}${CATDIR}${page:E}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/} 1951556Srgrimes.endif 1961556Srgrimes.endfor 1971556Srgrimes.endif 1981556Srgrimes.endif 1991556Srgrimes 2001556Srgrimes.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS) 2011556Srgrimes @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 2021556Srgrimes while : ; do \ 2031556Srgrimes case $$# in \ 2041556Srgrimes 0) break;; \ 2051556Srgrimes [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ 2061556Srgrimes esac; \ 2071556Srgrimes name=$$1; shift; sect=$$1; shift; \ 2081556Srgrimes l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ 2091556Srgrimes name=$$1; shift; sect=$$1; shift; \ 2101556Srgrimes t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ 2111556Srgrimes ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ 2121556Srgrimes rm -f $${t} $${t}${MCOMPRESS_EXT}; \ 21318018Speter ln $${l}${ZEXT} $${t}${ZEXT}; \ 2141556Srgrimes done 2151556Srgrimes.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) 2161556Srgrimes @set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \ 2171556Srgrimes while : ; do \ 2181556Srgrimes case $$# in \ 2191556Srgrimes 0) break;; \ 2201556Srgrimes [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ 2211556Srgrimes esac; \ 2221556Srgrimes name=$$1; shift; sect=$$1; shift; \ 2231556Srgrimes l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ 2241556Srgrimes name=$$1; shift; sect=$$1; shift; \ 2251556Srgrimes t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ 2261556Srgrimes ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ 2271556Srgrimes rm -f $${t} $${t}${MCOMPRESS_EXT}; \ 2281556Srgrimes ln $${l}${ZEXT} $${t}${ZEXT}; \ 2291556Srgrimes done 23017987Speter.endif 2311556Srgrimes.endif 23218018Speter