xref: /freebsd/share/mk/bsd.man.mk (revision 0c43d89a0d8e976ca494d4837f4c1f3734d2c300)
1#	from: @(#)bsd.man.mk	5.2 (Berkeley) 5/11/90
2#	$Id: bsd.man.mk,v 1.6 1994/06/05 20:42:39 csgr Exp $
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8INSTALL?=	install
9MANGRP?=	bin
10MANOWN?=	bin
11MANMODE?=	444
12
13MANDIR?=	/usr/share/man/man
14MANSRC?=	${.CURDIR}
15MINSTALL=	${INSTALL}  ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
16
17MCOMPRESS=	gzip -f
18BASENAME=	basename
19ZEXTENSION=	.gz
20.if !defined(NOMANCOMPRESS)
21ZEXT=		${ZEXTENSION}
22.else
23ZEXT=
24.endif
25
26MANALL=		${MAN1} ${MAN2} ${MAN3} ${MAN3F} ${MAN4} ${MAN5}	\
27		${MAN6} ${MAN7} ${MAN8}
28
29maninstall: ${MANDEPEND}
30.if defined(MAN1) && !empty(MAN1)
31	(cd ${MANSRC}; ${MINSTALL} ${MAN1} ${DESTDIR}${MANDIR}1${MANSUBDIR})
32.endif
33.if defined(MAN2) && !empty(MAN2)
34	(cd ${MANSRC}; ${MINSTALL} ${MAN2} ${DESTDIR}${MANDIR}2${MANSUBDIR})
35.endif
36.if defined(MAN3) && !empty(MAN3)
37	(cd ${MANSRC}; ${MINSTALL} ${MAN3} ${DESTDIR}${MANDIR}3${MANSUBDIR})
38.endif
39.if defined(MAN3F) && !empty(MAN3F)
40	(cd ${MANSRC}; ${MINSTALL} ${MAN3F} ${DESTDIR}${MANDIR}3f${MANSUBDIR})
41.endif
42.if defined(MAN4) && !empty(MAN4)
43	(cd ${MANSRC}; ${MINSTALL} ${MAN4} ${DESTDIR}${MANDIR}4${MANSUBDIR})
44.endif
45.if defined(MAN5) && !empty(MAN5)
46	(cd ${MANSRC}; ${MINSTALL} ${MAN5} ${DESTDIR}${MANDIR}5${MANSUBDIR})
47.endif
48.if defined(MAN6) && !empty(MAN6)
49	(cd ${MANSRC}; ${MINSTALL} ${MAN6} ${DESTDIR}${MANDIR}6${MANSUBDIR})
50.endif
51.if defined(MAN7) && !empty(MAN7)
52	(cd ${MANSRC}; ${MINSTALL} ${MAN7} ${DESTDIR}${MANDIR}7${MANSUBDIR})
53.endif
54.if defined(MAN8) && !empty(MAN8)
55	(cd ${MANSRC}; ${MINSTALL} ${MAN8} ${DESTDIR}${MANDIR}8${MANSUBDIR})
56.endif
57
58# by default all pages are compressed
59# we don't handle .so's yet
60.if !empty(MANALL:S/ //g)
61.if !defined(NOMANCOMPRESS)
62	@set ${MANALL} ;						\
63	while test $$# -ge 1; do					\
64		name=`${BASENAME} $$1`;					\
65		sect=`expr $$name : '.*\.\([^.]*\)'`;			\
66		echo "compressing in"					\
67			"${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}:"	\
68			"$$name -> $${name}${ZEXT}";			\
69		${MCOMPRESS} ${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name ; \
70		shift ;							\
71	done ; true
72.else
73# we are installing uncompressed pages, so nuke any compressed pages
74	@set ${MANALL} ;						\
75	while test $$# -ge 1; do					\
76		name=`${BASENAME} $$1`;					\
77		sect=`expr $$name : '.*\.\([^.]*\)'`;			\
78		rm -f ${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name${ZEXTENSION};\
79		shift ;							\
80	done ; true
81.endif
82.endif
83
84.if defined(MLINKS) && !empty(MLINKS)
85	@set ${MLINKS}; \
86	while test $$# -ge 2; do \
87		name=$$1; \
88		shift; \
89		sect=`expr $$name : '.*\.\([^.]*\)'`; \
90		dir=${DESTDIR}${MANDIR}$$sect; \
91		l=$${dir}${MANSUBDIR}/$$name; \
92		name=$$1; \
93		shift; \
94		sect=`expr $$name : '.*\.\([^.]*\)'`; \
95		dir=${DESTDIR}${MANDIR}$$sect; \
96		t=$${dir}${MANSUBDIR}/$$name; \
97		echo $${t}${ZEXT} -\> $${l}${ZEXT}; \
98		rm -f $${t}${ZEXTENSION}; \
99		rm -f $${t}; \
100		ln $${l}${ZEXT} $${t}${ZEXT}; \
101	done; true
102.endif
103