xref: /freebsd/share/mk/bsd.man.mk (revision 53996faddbf2002a1d0b1da9fc89951800e41780)
153996fadSWolfram Schneider#	$Id: bsd.man.mk,v 1.11 1996/05/25 21:50:54 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#
2953996fadSWolfram Schneider# MCOMPRESS	Program to compress man pages. Output is to
3053996fadSWolfram Schneider#		stdout. [gzip -c]
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#
4053996fadSWolfram Schneider#
4153996fadSWolfram Schneider# +++ targets +++
4253996fadSWolfram Schneider#
4353996fadSWolfram Schneider#	maninstall:
4453996fadSWolfram Schneider#		Install the manual pages and their links.
4553996fadSWolfram Schneider#
4653996fadSWolfram Schneider
47e8f9a073SBruce Evans
48e8f9a073SBruce Evans.if exists(${.CURDIR}/../Makefile.inc)
49e8f9a073SBruce Evans.include "${.CURDIR}/../Makefile.inc"
50e8f9a073SBruce Evans.endif
51afe61c15SRodney W. Grimes
523585b293SGarrett WollmanMANSRC?=	${.CURDIR}
533585b293SGarrett WollmanMINSTALL=	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
54afe61c15SRodney W. Grimes
55e8f9a073SBruce EvansMCOMPRESS=	gzip -c
563585b293SGarrett WollmanZEXTENSION=	.gz
57afe61c15SRodney W. Grimes
58429544bbSBruce EvansSECTIONS=	1 2 3 3f 4 5 6 7 8 9
593585b293SGarrett Wollman
60bd063a9dSWolfram Schneider.undef _MANPAGES
61eb896871SBruce Evans.for sect in ${SECTIONS}
62eb896871SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
63eb896871SBruce Evans.SUFFIXES: .${sect}
64eb896871SBruce Evans.PATH.${sect}: ${MANSRC}
65bd063a9dSWolfram Schneider_MANPAGES+= ${MAN${sect}}
66eb896871SBruce Evans.endif
67eb896871SBruce Evans.endfor
68eb896871SBruce Evans
69973f098aSGarrett Wollmanall-man: ${MANDEPEND}
70e8f9a073SBruce Evans
71e8f9a073SBruce Evans.if defined(NOMANCOMPRESS)
72e8f9a073SBruce Evans
73eb896871SBruce EvansCOPY=		-c
74e8f9a073SBruce EvansZEXT=
75e8f9a073SBruce Evans
76e8f9a073SBruce Evans.else
77e8f9a073SBruce Evans
78e8f9a073SBruce EvansZEXT=		${ZEXTENSION}
79e8f9a073SBruce Evans
80e8f9a073SBruce Evans.for sect in ${SECTIONS}
81e8f9a073SBruce Evans.if defined(MAN${sect}) && !empty(MAN${sect})
82e8f9a073SBruce EvansCLEANFILES+=	${MAN${sect}:T:S/$/${ZEXTENSION}/g}
83e8f9a073SBruce Evans.for page in ${MAN${sect}}
84e8f9a073SBruce Evans.for target in ${page:T:S/$/${ZEXTENSION}/}
85e8f9a073SBruce Evansall-man: ${target}
86e8f9a073SBruce Evans${target}: ${page}
87e8f9a073SBruce Evans	${MCOMPRESS} ${.ALLSRC} > ${.TARGET}
88e8f9a073SBruce Evans.endfor
89e8f9a073SBruce Evans.endfor
90e8f9a073SBruce Evans.endif
91e8f9a073SBruce Evans.endfor
92e8f9a073SBruce Evans
933585b293SGarrett Wollman.endif
943585b293SGarrett Wollman
95eb896871SBruce Evansmaninstall::
96e8f9a073SBruce Evans.for sect in ${SECTIONS}
97973f098aSGarrett Wollman.if defined(MAN${sect}) && !empty(MAN${sect})
98eb896871SBruce Evansmaninstall:: ${MAN${sect}}
99973f098aSGarrett Wollman.if defined(NOMANCOMPRESS)
100eb896871SBruce Evans	${MINSTALL} ${.ALLSRC} ${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
101973f098aSGarrett Wollman.else
102eb896871SBruce Evans	${MINSTALL} ${.ALLSRC:T:S/$/${ZEXTENSION}/g} \
103e8f9a073SBruce Evans		${DESTDIR}${MANDIR}${sect}${MANSUBDIR}
104973f098aSGarrett Wollman.endif
105973f098aSGarrett Wollman.endif
106973f098aSGarrett Wollman.endfor
107e8f9a073SBruce Evans
108afe61c15SRodney W. Grimes.if defined(MLINKS) && !empty(MLINKS)
109d8982a6aSWolfram Schneider	@set `echo ${MLINKS} " " | sed 's/\.\([^.]*\) /.\1 \1 /g'`; \
110d8982a6aSWolfram Schneider	while : ; do \
111d8982a6aSWolfram Schneider		case $$# in \
112d8982a6aSWolfram Schneider			0) break;; \
113d8982a6aSWolfram Schneider			[123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \
114d8982a6aSWolfram Schneider		esac; \
115d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
116d8982a6aSWolfram Schneider		l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
117d8982a6aSWolfram Schneider		name=$$1; shift; sect=$$1; shift; \
118d8982a6aSWolfram Schneider		t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \
11980c02d59SBruce Evans		${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \
120e8f9a073SBruce Evans		rm -f $${t} $${t}${ZEXTENSION}; \
1213585b293SGarrett Wollman		ln $${l}${ZEXT} $${t}${ZEXT}; \
122d8982a6aSWolfram Schneider	done
123afe61c15SRodney W. Grimes.endif
124