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