xref: /freebsd/share/mk/bsd.man.mk (revision 7c0c241dea37a9924227b0c6cc2db3b3a338ddaf)
17c0c241dSBruce Evans#	$Id: bsd.man.mk,v 1.21 1997/03/08 23:46:55 wosch Exp $
253996fadSWolfram Schneider#
353996fadSWolfram Schneider# The include file <bsd.man.mk> handles installing manual pages and
453996fadSWolfram Schneider# their links. <bsd.man.mk> includes the file named "../Makefile.inc"
553996fadSWolfram Schneider# if it exists.
653996fadSWolfram Schneider#
753996fadSWolfram Schneider#
853996fadSWolfram Schneider# +++ variables +++
953996fadSWolfram Schneider#
1053996fadSWolfram Schneider# DESTDIR	Change the tree where the man pages gets installed. [not set]
1153996fadSWolfram Schneider#
1253996fadSWolfram Schneider# MANDIR	Base path for manual installation. [${SHAREDIR}/man/man]
1353996fadSWolfram Schneider#
1453996fadSWolfram Schneider# MANOWN	Manual owner. [${SHAREOWN}]
1553996fadSWolfram Schneider#
1653996fadSWolfram Schneider# MANGRP	Manual group. [${SHAREGRP}]
1753996fadSWolfram Schneider#
1853996fadSWolfram Schneider# MANMODE	Manual mode. [${NOBINMODE}]
1953996fadSWolfram Schneider#
2053996fadSWolfram Schneider# MANSUBDIR	Subdirectory under the manual page section, i.e. "/i386"
2153996fadSWolfram Schneider#		or "/tahoe" for machine specific manual pages.
2253996fadSWolfram Schneider#
2353996fadSWolfram Schneider# MAN${sect}	The manual pages to be installed. For sections see
2453996fadSWolfram Schneider#		variable ${SECTIONS}
2553996fadSWolfram Schneider#
2653996fadSWolfram Schneider# _MANPAGES	List of all man pages to be installed.
2753996fadSWolfram Schneider#		(``_MANPAGES=$MAN1 $MAN2 ... $MANn'')
2853996fadSWolfram Schneider#
29f7ea12a0SWolfram Schneider# MCOMPRESS_CMD	Program to compress man pages. Output is to
30f7ea12a0SWolfram Schneider#		stdout. [${COMPRESS_CMD}]
3153996fadSWolfram Schneider#
3253996fadSWolfram Schneider# MLINKS	List of manual page links (using a suffix). The
3353996fadSWolfram Schneider#		linked-to file must come first, the linked file
3453996fadSWolfram Schneider#		second, and there may be multiple pairs. The files
3553996fadSWolfram Schneider#		are hard-linked.
3653996fadSWolfram Schneider#
3753996fadSWolfram Schneider# NOMANCOMPRESS	If you do not want unformatted manual pages to be
3853996fadSWolfram Schneider#		compressed when they are installed. [not set]
3953996fadSWolfram Schneider#
40236fc12aSWolfram Schneider# NOMLINKS	If you do not want install manual page links. [not set]
41236fc12aSWolfram Schneider#
42d5dcd8e6SPeter Wemm# MANFILTER	command to pipe the raw man page though before compressing
43d5dcd8e6SPeter Wemm#		or installing.  Can be used to do sed substitution.
4453996fadSWolfram Schneider#
4553996fadSWolfram Schneider# +++ targets +++
4653996fadSWolfram Schneider#
4753996fadSWolfram Schneider#	maninstall:
4853996fadSWolfram Schneider#		Install the manual pages and their links.
4953996fadSWolfram Schneider#
5053996fadSWolfram Schneider
51e8f9a073SBruce Evans
52e8f9a073SBruce Evans.if exists(${.CURDIR}/../Makefile.inc)
53e8f9a073SBruce Evans.include "${.CURDIR}/../Makefile.inc"
54e8f9a073SBruce Evans.endif
55afe61c15SRodney W. Grimes
563585b293SGarrett WollmanMANSRC?=	${.CURDIR}
573585b293SGarrett WollmanMINSTALL=	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
58afe61c15SRodney W. Grimes
59f7ea12a0SWolfram SchneiderMCOMPRESS_CMD?=	${COMPRESS_CMD}
60f7ea12a0SWolfram SchneiderMCOMPRESS_EXT?=	${COMPRESS_EXT}
61afe61c15SRodney W. Grimes
62d4be2259SWolfram SchneiderSECTIONS=	1 2 3 4 5 6 7 8 9 n
633585b293SGarrett Wollman
64bd063a9dSWolfram Schneider.undef _MANPAGES
65eb896871SBruce Evans.for sect in ${SECTIONS}
66eb896871SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
67eb896871SBruce Evans.SUFFIXES: .${sect}
68eb896871SBruce Evans.PATH.${sect}: ${MANSRC}
69bd063a9dSWolfram Schneider_MANPAGES+= ${MAN${sect}}
70eb896871SBruce Evans.endif
71eb896871SBruce Evans.endfor
72eb896871SBruce Evans
737c0c241dSBruce Evans# XXX MANDEPEND is only used for groff, man/man, man/manpath, at and atrun.
747c0c241dSBruce Evans# It should be named more generally.
75973f098aSGarrett Wollmanall-man: ${MANDEPEND}
76e8f9a073SBruce Evans
77e8f9a073SBruce Evans.if defined(NOMANCOMPRESS)
78e8f9a073SBruce Evans
79eb896871SBruce EvansCOPY=		-c
80eb0085f4SPeter Wemm
81eb0085f4SPeter Wemm# Make special arrangements to filter to a temporary file at build time
82eb0085f4SPeter Wemm# for NOMANCOMPRESS.
83eb0085f4SPeter Wemm.if defined(MANFILTER)
84eb0085f4SPeter WemmFILTEXTENSION=		.filt
85eb0085f4SPeter Wemm.else
86eb0085f4SPeter WemmFILTEXTENSION=
87eb0085f4SPeter Wemm.endif
88eb0085f4SPeter Wemm
89e8f9a073SBruce EvansZEXT=
90e8f9a073SBruce Evans
91d5dcd8e6SPeter Wemm.if defined(MANFILTER)
92d5dcd8e6SPeter Wemm.for sect in ${SECTIONS}
93d5dcd8e6SPeter Wemm.if defined(MAN${sect}) && !empty(MAN${sect})
94eb0085f4SPeter WemmCLEANFILES+=	${MAN${sect}:T:S/$/${FILTEXTENSION}/g}
95d5dcd8e6SPeter Wemm.for page in ${MAN${sect}}
96eb0085f4SPeter Wemm.for target in ${page:T:S/$/${FILTEXTENSION}/g}
97d5dcd8e6SPeter Wemmall-man: ${target}
98d5dcd8e6SPeter Wemm${target}: ${page}
995e7d3affSPeter Wemm	${MANFILTER} < ${.ALLSRC} > ${.TARGET}
100d5dcd8e6SPeter Wemm.endfor
101d5dcd8e6SPeter Wemm.endfor
102d5dcd8e6SPeter Wemm.endif
103d5dcd8e6SPeter Wemm.endfor
104d5dcd8e6SPeter Wemm.endif
105d5dcd8e6SPeter Wemm
106e8f9a073SBruce Evans.else
107e8f9a073SBruce Evans
108f7ea12a0SWolfram SchneiderZEXT=		${MCOMPRESS_EXT}
109e8f9a073SBruce Evans
110e8f9a073SBruce Evans.for sect in ${SECTIONS}
111e8f9a073SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
112f7ea12a0SWolfram SchneiderCLEANFILES+=	${MAN${sect}:T:S/$/${MCOMPRESS_EXT}/g}
113e8f9a073SBruce Evans.for page in ${MAN${sect}}
114f7ea12a0SWolfram Schneider.for target in ${page:T:S/$/${MCOMPRESS_EXT}/}
115e8f9a073SBruce Evansall-man: ${target}
116e8f9a073SBruce Evans${target}: ${page}
1175e7d3affSPeter Wemm.if defined(MANFILTER)
118f7ea12a0SWolfram Schneider	${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
119d5dcd8e6SPeter Wemm.else
120f7ea12a0SWolfram Schneider	${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
121d5dcd8e6SPeter Wemm.endif
122e8f9a073SBruce Evans.endfor
123e8f9a073SBruce Evans.endfor
124e8f9a073SBruce Evans.endif
125e8f9a073SBruce Evans.endfor
126e8f9a073SBruce Evans
1273585b293SGarrett Wollman.endif
1283585b293SGarrett Wollman
129eb896871SBruce Evansmaninstall::
130e8f9a073SBruce Evans.for sect in ${SECTIONS}
131973f098aSGarrett Wollman.if defined(MAN${sect}) && !empty(MAN${sect})
132eb896871SBruce Evansmaninstall:: ${MAN${sect}}
133973f098aSGarrett Wollman.if defined(NOMANCOMPRESS)
134eb0085f4SPeter Wemm.if defined(MANFILTER)
135eb0085f4SPeter Wemm.for page in ${MAN${sect}}
136eb0085f4SPeter Wemm	${MINSTALL} ${page:T:S/$/${FILTEXTENSION}/g} ${DESTDIR}${MANDIR}${sect}${MANSUBDIR}/${page}
137eb0085f4SPeter Wemm.endfor
138eb0085f4SPeter Wemm.else
139eb896871SBruce Evans	${MINSTALL} ${.ALLSRC} ${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
140eb0085f4SPeter Wemm.endif
141973f098aSGarrett Wollman.else
142f7ea12a0SWolfram Schneider	${MINSTALL} ${.ALLSRC:T:S/$/${MCOMPRESS_EXT}/g} \
143e8f9a073SBruce Evans		${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
144973f098aSGarrett Wollman.endif
145973f098aSGarrett Wollman.endif
146973f098aSGarrett Wollman.endfor
147e8f9a073SBruce Evans
148236fc12aSWolfram Schneider.if !defined(NOMLINKS) && defined(MLINKS) && !empty(MLINKS)
149d8982a6aSWolfram Schneider	@set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
150d8982a6aSWolfram Schneider	while : ; do \
151d8982a6aSWolfram Schneider		case $$# in \
152d8982a6aSWolfram Schneider			0) break;; \
153d8982a6aSWolfram Schneider			[123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
154d8982a6aSWolfram Schneider		esac; \
155d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
156d8982a6aSWolfram Schneider		l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
157d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
158d8982a6aSWolfram Schneider		t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
15980c02d59SBruce Evans		${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
160f7ea12a0SWolfram Schneider		rm -f $${t} $${t}${MCOMPRESS_EXT}; \
1613585b293SGarrett Wollman		ln $${l}${ZEXT} $${t}${ZEXT}; \
162d8982a6aSWolfram Schneider	done
163afe61c15SRodney W. Grimes.endif
164