xref: /dragonfly/share/mk/bsd.incs.mk (revision 0db87cb7)
1# $FreeBSD: src/share/mk/bsd.incs.mk,v 1.3.2.1 2002/07/22 14:21:51 ru Exp $
2# $DragonFly: src/share/mk/bsd.incs.mk,v 1.6 2005/07/07 11:49:56 corecode Exp $
3
4.if !target(__<bsd.init.mk>__)
5.error bsd.incs.mk cannot be included directly.
6.endif
7
8INCSGROUPS?=	INCS
9
10.if !target(buildincludes)
11.for group in ${INCSGROUPS}
12buildincludes: ${${group}}
13.endfor
14.endif
15
16all: buildincludes
17
18.if !target(installincludes)
19.for group in ${INCSGROUPS}
20.if defined(${group}) && !empty(${group})
21
22${group}OWN?=	${BINOWN}
23${group}GRP?=	${BINGRP}
24${group}MODE?=	${NOBINMODE}
25${group}DIR?=	${INCLUDEDIR}
26
27_${group}INCS=
28.for header in ${${group}}
29.if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \
30    defined(${group}MODE_${header:T}) || defined(${group}DIR_${header:T}) || \
31    defined(${group}NAME_${header:T})
32${group}OWN_${header:T}?=	${${group}OWN}
33${group}GRP_${header:T}?=	${${group}GRP}
34${group}MODE_${header:T}?=	${${group}MODE}
35${group}DIR_${header:T}?=	${${group}DIR}
36.if defined(${group}NAME)
37${group}NAME_${header:T}?=	${${group}NAME}
38.else
39${group}NAME_${header:T}?=	${header:T}
40.endif
41installincludes: _${group}INS_${header:T}
42_${group}INS_${header:T}: ${header}
43	${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
44	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
45	    ${.ALLSRC} \
46	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
47.else
48_${group}INCS+= ${header}
49.endif
50.endfor
51.if !empty(_${group}INCS)
52installincludes: _${group}INS
53_${group}INS: ${_${group}INCS}
54.if defined(${group}NAME)
55	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
56	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
57.else
58	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
59	    ${.ALLSRC} ${DESTDIR}${${group}DIR}
60.endif
61.endif
62
63.endif # defined(${group}) && !empty(${group})
64.endfor
65
66.if defined(INCSLINKS) && !empty(INCSLINKS)
67installincludes:
68	@set ${INCSLINKS}; \
69	while test $$# -ge 2; do \
70		l=$$1; \
71		shift; \
72		t=${DESTDIR}$$1; \
73		shift; \
74		${ECHO} $$t -\> $$l; \
75		${LN} -fhs $$l $$t; \
76	done; true
77.endif
78.endif # !target(installincludes)
79
80# include files are not installed when building bootstrap programs
81#
82.if !defined(BOOTSTRAPPING)
83realinstall: installincludes
84.ORDER: beforeinstall installincludes
85.endif
86