xref: /freebsd/share/mk/bsd.man.mk (revision 7f3dea244c40159a41ab22da77a434d7c5b5e85a)
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#
2253996fadSWolfram Schneider# MAN${sect}	The manual pages to be installed. For sections see
2353996fadSWolfram Schneider#		variable ${SECTIONS}
2453996fadSWolfram Schneider#
2553996fadSWolfram Schneider# _MANPAGES	List of all man pages to be installed.
2653996fadSWolfram Schneider#		(``_MANPAGES=$MAN1 $MAN2 ... $MANn'')
2753996fadSWolfram Schneider#
28f7ea12a0SWolfram Schneider# MCOMPRESS_CMD	Program to compress man pages. Output is to
29f7ea12a0SWolfram Schneider#		stdout. [${COMPRESS_CMD}]
3053996fadSWolfram Schneider#
3153996fadSWolfram Schneider# MLINKS	List of manual page links (using a suffix). The
3253996fadSWolfram Schneider#		linked-to file must come first, the linked file
3353996fadSWolfram Schneider#		second, and there may be multiple pairs. The files
3453996fadSWolfram Schneider#		are hard-linked.
3553996fadSWolfram Schneider#
3653996fadSWolfram Schneider# NOMANCOMPRESS	If you do not want unformatted manual pages to be
3753996fadSWolfram Schneider#		compressed when they are installed. [not set]
3853996fadSWolfram Schneider#
39236fc12aSWolfram Schneider# NOMLINKS	If you do not want install manual page links. [not set]
40236fc12aSWolfram Schneider#
41d5dcd8e6SPeter Wemm# MANFILTER	command to pipe the raw man page though before compressing
42d5dcd8e6SPeter Wemm#		or installing.  Can be used to do sed substitution.
4353996fadSWolfram Schneider#
445191ded8SPaul Traina# MANBUILDCAT	create preformatted manual pages in addition to normal
455191ded8SPaul Traina#		pages. [not set]
465191ded8SPaul Traina#
475191ded8SPaul Traina# MROFF_CMD	command and flags to create preformatted pages
485191ded8SPaul Traina#
4953996fadSWolfram Schneider# +++ targets +++
5053996fadSWolfram Schneider#
5153996fadSWolfram Schneider#	maninstall:
5253996fadSWolfram Schneider#		Install the manual pages and their links.
5353996fadSWolfram Schneider#
5453996fadSWolfram Schneider
553585b293SGarrett WollmanMANSRC?=	${.CURDIR}
563585b293SGarrett WollmanMINSTALL=	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
57afe61c15SRodney W. Grimes
585191ded8SPaul TrainaCATDIR=		${MANDIR:H:S/$/\/cat/}
595191ded8SPaul TrainaCATEXT=		.cat
605191ded8SPaul TrainaMROFF_CMD?=	groff -Tascii -man
615191ded8SPaul Traina
62f7ea12a0SWolfram SchneiderMCOMPRESS_CMD?=	${COMPRESS_CMD}
63f7ea12a0SWolfram SchneiderMCOMPRESS_EXT?=	${COMPRESS_EXT}
64afe61c15SRodney W. Grimes
65c908270eSJohn BirrellSECTIONS=	1 1aout 2 3 4 5 6 7 8 9 n
663585b293SGarrett Wollman
67bd063a9dSWolfram Schneider.undef _MANPAGES
68eb896871SBruce Evans.for sect in ${SECTIONS}
69eb896871SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
70eb896871SBruce Evans.SUFFIXES: .${sect}
71eb896871SBruce Evans.PATH.${sect}: ${MANSRC}
72bd063a9dSWolfram Schneider_MANPAGES+= ${MAN${sect}}
73eb896871SBruce Evans.endif
74eb896871SBruce Evans.endfor
75eb896871SBruce Evans
767c0c241dSBruce Evans# XXX MANDEPEND is only used for groff, man/man, man/manpath, at and atrun.
777c0c241dSBruce Evans# It should be named more generally.
78973f098aSGarrett Wollmanall-man: ${MANDEPEND}
79e8f9a073SBruce Evans
80e8f9a073SBruce Evans.if defined(NOMANCOMPRESS)
81e8f9a073SBruce Evans
82eb896871SBruce EvansCOPY=		-c
83eb0085f4SPeter Wemm
84eb0085f4SPeter Wemm# Make special arrangements to filter to a temporary file at build time
85eb0085f4SPeter Wemm# for NOMANCOMPRESS.
86eb0085f4SPeter Wemm.if defined(MANFILTER)
87eb0085f4SPeter WemmFILTEXTENSION=		.filt
88eb0085f4SPeter Wemm.else
89eb0085f4SPeter WemmFILTEXTENSION=
90eb0085f4SPeter Wemm.endif
91eb0085f4SPeter Wemm
92e8f9a073SBruce EvansZEXT=
93e8f9a073SBruce Evans
94d5dcd8e6SPeter Wemm.if defined(MANFILTER)
95d5dcd8e6SPeter Wemm.for sect in ${SECTIONS}
96d5dcd8e6SPeter Wemm.if defined(MAN${sect}) && !empty(MAN${sect})
97eb0085f4SPeter WemmCLEANFILES+=	${MAN${sect}:T:S/$/${FILTEXTENSION}/g}
985191ded8SPaul TrainaCLEANFILES+=	${MAN${sect}:T:S/$/${CATEXT}${FILTEXTENSION}/g}
99d5dcd8e6SPeter Wemm.for page in ${MAN${sect}}
100eb0085f4SPeter Wemm.for target in ${page:T:S/$/${FILTEXTENSION}/g}
101d5dcd8e6SPeter Wemmall-man: ${target}
102d5dcd8e6SPeter Wemm${target}: ${page}
1035e7d3affSPeter Wemm	${MANFILTER} < ${.ALLSRC} > ${.TARGET}
104d5dcd8e6SPeter Wemm.endfor
1055d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1065191ded8SPaul Traina.for target in ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g}
1075191ded8SPaul Trainaall-man: ${target}
1085191ded8SPaul Traina${target}: ${page}
1095191ded8SPaul Traina	${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET}
110d5dcd8e6SPeter Wemm.endfor
111d5dcd8e6SPeter Wemm.endif
112d5dcd8e6SPeter Wemm.endfor
113d5dcd8e6SPeter Wemm.endif
1145191ded8SPaul Traina.endfor
1155191ded8SPaul Traina.else
1165191ded8SPaul Traina.for sect in ${SECTIONS}
1175191ded8SPaul Traina.if defined(MAN${sect}) && !empty(MAN${sect})
1185191ded8SPaul TrainaCLEANFILES+=	${MAN${sect}:T:S/$/${CATEXT}/g}
1195d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1205191ded8SPaul Traina.for page in ${MAN${sect}}
1215191ded8SPaul Traina.for target in ${page:T:S/$/${CATEXT}/g}
1225191ded8SPaul Trainaall-man: ${target}
1235191ded8SPaul Traina${target}: ${page}
1245191ded8SPaul Traina	${MROFF_CMD} ${.ALLSRC} > ${.TARGET}
1255191ded8SPaul Traina.endfor
1265191ded8SPaul Traina.endfor
1275191ded8SPaul Traina.endif
1285191ded8SPaul Traina.endif
1295191ded8SPaul Traina.endfor
1305191ded8SPaul Traina.endif
131d5dcd8e6SPeter Wemm
132e8f9a073SBruce Evans.else
133e8f9a073SBruce Evans
134f7ea12a0SWolfram SchneiderZEXT=		${MCOMPRESS_EXT}
135e8f9a073SBruce Evans
136e8f9a073SBruce Evans.for sect in ${SECTIONS}
137e8f9a073SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
138f7ea12a0SWolfram SchneiderCLEANFILES+=	${MAN${sect}:T:S/$/${MCOMPRESS_EXT}/g}
1395191ded8SPaul TrainaCLEANFILES+=	${MAN${sect}:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g}
140e8f9a073SBruce Evans.for page in ${MAN${sect}}
141f7ea12a0SWolfram Schneider.for target in ${page:T:S/$/${MCOMPRESS_EXT}/}
142e8f9a073SBruce Evansall-man: ${target}
143e8f9a073SBruce Evans${target}: ${page}
1445e7d3affSPeter Wemm.if defined(MANFILTER)
145f7ea12a0SWolfram Schneider	${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
146d5dcd8e6SPeter Wemm.else
147f7ea12a0SWolfram Schneider	${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
148d5dcd8e6SPeter Wemm.endif
149e8f9a073SBruce Evans.endfor
1505d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1515191ded8SPaul Traina.for target in ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/}
1525191ded8SPaul Trainaall-man: ${target}
1535191ded8SPaul Traina${target}: ${page}
1545191ded8SPaul Traina.if defined(MANFILTER)
1555191ded8SPaul Traina	${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET}
1565191ded8SPaul Traina.else
1575191ded8SPaul Traina	${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
1585191ded8SPaul Traina.endif
1595191ded8SPaul Traina.endfor
1605191ded8SPaul Traina.endif
161e8f9a073SBruce Evans.endfor
162e8f9a073SBruce Evans.endif
163e8f9a073SBruce Evans.endfor
164e8f9a073SBruce Evans
1653585b293SGarrett Wollman.endif
1663585b293SGarrett Wollman
167eb896871SBruce Evansmaninstall::
168e8f9a073SBruce Evans.for sect in ${SECTIONS}
169973f098aSGarrett Wollman.if defined(MAN${sect}) && !empty(MAN${sect})
170eb896871SBruce Evansmaninstall:: ${MAN${sect}}
171973f098aSGarrett Wollman.if defined(NOMANCOMPRESS)
172eb0085f4SPeter Wemm.if defined(MANFILTER)
173eb0085f4SPeter Wemm.for page in ${MAN${sect}}
1745191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${FILTEXTENSION}/g} \
1755191ded8SPaul Traina		${DESTDIR}${MANDIR}${sect}${MANSUBDIR}/${page}
1765d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1775191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
1785191ded8SPaul Traina		${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page}
1795191ded8SPaul Traina.endif
180eb0085f4SPeter Wemm.endfor
181eb0085f4SPeter Wemm.else
182eb896871SBruce Evans	${MINSTALL} ${.ALLSRC} ${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
1835d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1845191ded8SPaul Traina.for page in ${MAN${sect}}
1855191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${CATEXT}/} \
1865191ded8SPaul Traina		${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page:T}
1875191ded8SPaul Traina.endfor
1885191ded8SPaul Traina.endif
189eb0085f4SPeter Wemm.endif
190973f098aSGarrett Wollman.else
191f7ea12a0SWolfram Schneider	${MINSTALL} ${.ALLSRC:T:S/$/${MCOMPRESS_EXT}/g} \
192e8f9a073SBruce Evans		${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
1935d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1945191ded8SPaul Traina.for page in ${MAN${sect}}
1955191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
1965191ded8SPaul Traina		${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/}
1975191ded8SPaul Traina.endfor
1985191ded8SPaul Traina.endif
199973f098aSGarrett Wollman.endif
200973f098aSGarrett Wollman.endif
201973f098aSGarrett Wollman.endfor
202e8f9a073SBruce Evans
203236fc12aSWolfram Schneider.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS)
204d8982a6aSWolfram Schneider	@set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
205d8982a6aSWolfram Schneider	while : ; do \
206d8982a6aSWolfram Schneider		case $$# in \
207d8982a6aSWolfram Schneider			0) break;; \
208d8982a6aSWolfram Schneider			[123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
209d8982a6aSWolfram Schneider		esac; \
210d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
211d8982a6aSWolfram Schneider		l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
212d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
213d8982a6aSWolfram Schneider		t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
21480c02d59SBruce Evans		${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
215f7ea12a0SWolfram Schneider		rm -f $${t} $${t}${MCOMPRESS_EXT}; \
2163585b293SGarrett Wollman		ln $${l}${ZEXT} $${t}${ZEXT}; \
217d8982a6aSWolfram Schneider	done
2185d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
2195191ded8SPaul Traina	@set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
2205191ded8SPaul Traina	while : ; do \
2215191ded8SPaul Traina		case $$# in \
2225191ded8SPaul Traina			0) break;; \
2235191ded8SPaul Traina			[123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
2245191ded8SPaul Traina		esac; \
2255191ded8SPaul Traina		name=$$1; shift; sect=$$1; shift; \
2265191ded8SPaul Traina		l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
2275191ded8SPaul Traina		name=$$1; shift; sect=$$1; shift; \
2285191ded8SPaul Traina		t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
2295191ded8SPaul Traina		${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
2305191ded8SPaul Traina		rm -f $${t} $${t}${MCOMPRESS_EXT}; \
2315191ded8SPaul Traina		ln $${l}${ZEXT} $${t}${ZEXT}; \
2325191ded8SPaul Traina	done
2335191ded8SPaul Traina.endif
234afe61c15SRodney W. Grimes.endif
235