xref: /freebsd/share/mk/bsd.man.mk (revision c908270ee3bfdf2b2dad29956338117aa704a030)
1c908270eSJohn Birrell#	$Id: bsd.man.mk,v 1.28 1998/08/08 07:02:08 peter Exp $
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
55e0301e5dSPeter Wemm.if !target(__initialized__)
56e0301e5dSPeter Wemm__initialized__:
57e0301e5dSPeter Wemm.if exists(${.CURDIR}/../Makefile.inc)
58e0301e5dSPeter Wemm.include "${.CURDIR}/../Makefile.inc"
59e0301e5dSPeter Wemm.endif
60e0301e5dSPeter Wemm.endif
61e0301e5dSPeter Wemm
623585b293SGarrett WollmanMANSRC?=	${.CURDIR}
633585b293SGarrett WollmanMINSTALL=	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
64afe61c15SRodney W. Grimes
655191ded8SPaul TrainaCATDIR=		${MANDIR:H:S/$/\/cat/}
665191ded8SPaul TrainaCATEXT=		.cat
675191ded8SPaul TrainaMROFF_CMD?=	groff -Tascii -man
685191ded8SPaul Traina
69f7ea12a0SWolfram SchneiderMCOMPRESS_CMD?=	${COMPRESS_CMD}
70f7ea12a0SWolfram SchneiderMCOMPRESS_EXT?=	${COMPRESS_EXT}
71afe61c15SRodney W. Grimes
72c908270eSJohn BirrellSECTIONS=	1 1aout 2 3 4 5 6 7 8 9 n
733585b293SGarrett Wollman
74bd063a9dSWolfram Schneider.undef _MANPAGES
75eb896871SBruce Evans.for sect in ${SECTIONS}
76eb896871SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
77eb896871SBruce Evans.SUFFIXES: .${sect}
78eb896871SBruce Evans.PATH.${sect}: ${MANSRC}
79bd063a9dSWolfram Schneider_MANPAGES+= ${MAN${sect}}
80eb896871SBruce Evans.endif
81eb896871SBruce Evans.endfor
82eb896871SBruce Evans
837c0c241dSBruce Evans# XXX MANDEPEND is only used for groff, man/man, man/manpath, at and atrun.
847c0c241dSBruce Evans# It should be named more generally.
85973f098aSGarrett Wollmanall-man: ${MANDEPEND}
86e8f9a073SBruce Evans
87e8f9a073SBruce Evans.if defined(NOMANCOMPRESS)
88e8f9a073SBruce Evans
89eb896871SBruce EvansCOPY=		-c
90eb0085f4SPeter Wemm
91eb0085f4SPeter Wemm# Make special arrangements to filter to a temporary file at build time
92eb0085f4SPeter Wemm# for NOMANCOMPRESS.
93eb0085f4SPeter Wemm.if defined(MANFILTER)
94eb0085f4SPeter WemmFILTEXTENSION=		.filt
95eb0085f4SPeter Wemm.else
96eb0085f4SPeter WemmFILTEXTENSION=
97eb0085f4SPeter Wemm.endif
98eb0085f4SPeter Wemm
99e8f9a073SBruce EvansZEXT=
100e8f9a073SBruce Evans
101d5dcd8e6SPeter Wemm.if defined(MANFILTER)
102d5dcd8e6SPeter Wemm.for sect in ${SECTIONS}
103d5dcd8e6SPeter Wemm.if defined(MAN${sect}) && !empty(MAN${sect})
104eb0085f4SPeter WemmCLEANFILES+=	${MAN${sect}:T:S/$/${FILTEXTENSION}/g}
1055191ded8SPaul TrainaCLEANFILES+=	${MAN${sect}:T:S/$/${CATEXT}${FILTEXTENSION}/g}
106d5dcd8e6SPeter Wemm.for page in ${MAN${sect}}
107eb0085f4SPeter Wemm.for target in ${page:T:S/$/${FILTEXTENSION}/g}
108d5dcd8e6SPeter Wemmall-man: ${target}
109d5dcd8e6SPeter Wemm${target}: ${page}
1105e7d3affSPeter Wemm	${MANFILTER} < ${.ALLSRC} > ${.TARGET}
111d5dcd8e6SPeter Wemm.endfor
1125d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1135191ded8SPaul Traina.for target in ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g}
1145191ded8SPaul Trainaall-man: ${target}
1155191ded8SPaul Traina${target}: ${page}
1165191ded8SPaul Traina	${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET}
117d5dcd8e6SPeter Wemm.endfor
118d5dcd8e6SPeter Wemm.endif
119d5dcd8e6SPeter Wemm.endfor
120d5dcd8e6SPeter Wemm.endif
1215191ded8SPaul Traina.endfor
1225191ded8SPaul Traina.else
1235191ded8SPaul Traina.for sect in ${SECTIONS}
1245191ded8SPaul Traina.if defined(MAN${sect}) && !empty(MAN${sect})
1255191ded8SPaul TrainaCLEANFILES+=	${MAN${sect}:T:S/$/${CATEXT}/g}
1265d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1275191ded8SPaul Traina.for page in ${MAN${sect}}
1285191ded8SPaul Traina.for target in ${page:T:S/$/${CATEXT}/g}
1295191ded8SPaul Trainaall-man: ${target}
1305191ded8SPaul Traina${target}: ${page}
1315191ded8SPaul Traina	${MROFF_CMD} ${.ALLSRC} > ${.TARGET}
1325191ded8SPaul Traina.endfor
1335191ded8SPaul Traina.endfor
1345191ded8SPaul Traina.endif
1355191ded8SPaul Traina.endif
1365191ded8SPaul Traina.endfor
1375191ded8SPaul Traina.endif
138d5dcd8e6SPeter Wemm
139e8f9a073SBruce Evans.else
140e8f9a073SBruce Evans
141f7ea12a0SWolfram SchneiderZEXT=		${MCOMPRESS_EXT}
142e8f9a073SBruce Evans
143e8f9a073SBruce Evans.for sect in ${SECTIONS}
144e8f9a073SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
145f7ea12a0SWolfram SchneiderCLEANFILES+=	${MAN${sect}:T:S/$/${MCOMPRESS_EXT}/g}
1465191ded8SPaul TrainaCLEANFILES+=	${MAN${sect}:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g}
147e8f9a073SBruce Evans.for page in ${MAN${sect}}
148f7ea12a0SWolfram Schneider.for target in ${page:T:S/$/${MCOMPRESS_EXT}/}
149e8f9a073SBruce Evansall-man: ${target}
150e8f9a073SBruce Evans${target}: ${page}
1515e7d3affSPeter Wemm.if defined(MANFILTER)
152f7ea12a0SWolfram Schneider	${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
153d5dcd8e6SPeter Wemm.else
154f7ea12a0SWolfram Schneider	${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
155d5dcd8e6SPeter Wemm.endif
156e8f9a073SBruce Evans.endfor
1575d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1585191ded8SPaul Traina.for target in ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/}
1595191ded8SPaul Trainaall-man: ${target}
1605191ded8SPaul Traina${target}: ${page}
1615191ded8SPaul Traina.if defined(MANFILTER)
1625191ded8SPaul Traina	${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET}
1635191ded8SPaul Traina.else
1645191ded8SPaul Traina	${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
1655191ded8SPaul Traina.endif
1665191ded8SPaul Traina.endfor
1675191ded8SPaul Traina.endif
168e8f9a073SBruce Evans.endfor
169e8f9a073SBruce Evans.endif
170e8f9a073SBruce Evans.endfor
171e8f9a073SBruce Evans
1723585b293SGarrett Wollman.endif
1733585b293SGarrett Wollman
174eb896871SBruce Evansmaninstall::
175e8f9a073SBruce Evans.for sect in ${SECTIONS}
176973f098aSGarrett Wollman.if defined(MAN${sect}) && !empty(MAN${sect})
177eb896871SBruce Evansmaninstall:: ${MAN${sect}}
178973f098aSGarrett Wollman.if defined(NOMANCOMPRESS)
179eb0085f4SPeter Wemm.if defined(MANFILTER)
180eb0085f4SPeter Wemm.for page in ${MAN${sect}}
1815191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${FILTEXTENSION}/g} \
1825191ded8SPaul Traina		${DESTDIR}${MANDIR}${sect}${MANSUBDIR}/${page}
1835d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1845191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \
1855191ded8SPaul Traina		${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page}
1865191ded8SPaul Traina.endif
187eb0085f4SPeter Wemm.endfor
188eb0085f4SPeter Wemm.else
189eb896871SBruce Evans	${MINSTALL} ${.ALLSRC} ${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
1905d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
1915191ded8SPaul Traina.for page in ${MAN${sect}}
1925191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${CATEXT}/} \
1935191ded8SPaul Traina		${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page:T}
1945191ded8SPaul Traina.endfor
1955191ded8SPaul Traina.endif
196eb0085f4SPeter Wemm.endif
197973f098aSGarrett Wollman.else
198f7ea12a0SWolfram Schneider	${MINSTALL} ${.ALLSRC:T:S/$/${MCOMPRESS_EXT}/g} \
199e8f9a073SBruce Evans		${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
2005d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
2015191ded8SPaul Traina.for page in ${MAN${sect}}
2025191ded8SPaul Traina	${MINSTALL} ${page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \
2035191ded8SPaul Traina		${DESTDIR}${CATDIR}${sect}${MANSUBDIR}/${page:T:S/$/${MCOMPRESS_EXT}/}
2045191ded8SPaul Traina.endfor
2055191ded8SPaul Traina.endif
206973f098aSGarrett Wollman.endif
207973f098aSGarrett Wollman.endif
208973f098aSGarrett Wollman.endfor
209e8f9a073SBruce Evans
210236fc12aSWolfram Schneider.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS)
211d8982a6aSWolfram Schneider	@set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
212d8982a6aSWolfram Schneider	while : ; do \
213d8982a6aSWolfram Schneider		case $$# in \
214d8982a6aSWolfram Schneider			0) break;; \
215d8982a6aSWolfram Schneider			[123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
216d8982a6aSWolfram Schneider		esac; \
217d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
218d8982a6aSWolfram Schneider		l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
219d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
220d8982a6aSWolfram Schneider		t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
22180c02d59SBruce Evans		${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
222f7ea12a0SWolfram Schneider		rm -f $${t} $${t}${MCOMPRESS_EXT}; \
2233585b293SGarrett Wollman		ln $${l}${ZEXT} $${t}${ZEXT}; \
224d8982a6aSWolfram Schneider	done
2255d08f311SBruce Evans.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
2265191ded8SPaul Traina	@set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
2275191ded8SPaul Traina	while : ; do \
2285191ded8SPaul Traina		case $$# in \
2295191ded8SPaul Traina			0) break;; \
2305191ded8SPaul Traina			[123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
2315191ded8SPaul Traina		esac; \
2325191ded8SPaul Traina		name=$$1; shift; sect=$$1; shift; \
2335191ded8SPaul Traina		l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
2345191ded8SPaul Traina		name=$$1; shift; sect=$$1; shift; \
2355191ded8SPaul Traina		t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \
2365191ded8SPaul Traina		${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
2375191ded8SPaul Traina		rm -f $${t} $${t}${MCOMPRESS_EXT}; \
2385191ded8SPaul Traina		ln $${l}${ZEXT} $${t}${ZEXT}; \
2395191ded8SPaul Traina	done
2405191ded8SPaul Traina.endif
241afe61c15SRodney W. Grimes.endif
242