xref: /freebsd/share/mk/bsd.incs.mk (revision 6ae1554a5d9b318f8ad53ccc39fa5a961403da73)
1# $FreeBSD$
2
3.if !target(__<bsd.init.mk>__)
4.error bsd.incs.mk cannot be included directly.
5.endif
6
7.if ${MK_INCLUDES} != "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}${PRIVATELIB:D/private/${LIB}}
27STAGE_SETS+=	${group}
28STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
29STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP}
30
31_${group}INCS=
32.for header in ${${group}}
33.if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \
34    defined(${group}MODE_${header:T}) || defined(${group}DIR_${header:T}) || \
35    defined(${group}NAME_${header:T}) || defined(${group}NAME)
36${group}OWN_${header:T}?=	${${group}OWN}
37${group}GRP_${header:T}?=	${${group}GRP}
38${group}MODE_${header:T}?=	${${group}MODE}
39${group}DIR_${header:T}?=	${${group}DIR}
40.if defined(${group}NAME)
41${group}NAME_${header:T}?=	${${group}NAME}
42.else
43${group}NAME_${header:T}?=	${header:T}
44.endif
45STAGE_AS_SETS+= ${header:T}
46STAGE_AS_${header:T}= ${${group}NAME_${header:T}}
47# XXX {group}OWN,GRP,MODE
48STAGE_DIR.${header:T}= ${STAGE_OBJTOP}${${group}DIR_${header:T}}
49stage_as.${header:T}: ${header}
50stage_includes: stage_as.${header:T}
51
52installincludes: _${group}INS_${header:T}
53_${group}INS_${header:T}: ${header}
54	${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
55	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
56	    ${.ALLSRC} \
57	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
58.else
59_${group}INCS+= ${header}
60.endif
61.endfor
62.if !empty(_${group}INCS)
63stage_files.${group}: ${_${group}INCS}
64stage_includes: stage_files.${group}
65
66installincludes: _${group}INS
67_${group}INS: ${_${group}INCS}
68.if defined(${group}NAME)
69	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
70	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
71.else
72	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
73	    ${.ALLSRC} ${DESTDIR}${${group}DIR}
74.endif
75.endif
76
77.endif # defined(${group}) && !empty(${group})
78.endfor
79
80.if defined(INCSLINKS) && !empty(INCSLINKS)
81installincludes:
82.for s t in ${INCSLINKS}
83	@${ECHO} "$t -> $s" ; \
84	${INSTALL_SYMLINK} $s ${DESTDIR}$t
85.endfor
86.endif
87.endif # !target(installincludes)
88
89realinstall: installincludes
90.ORDER: beforeinstall installincludes
91
92.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD)
93.if !defined(NO_STAGE_INCLUDES)
94staging: stage_includes
95.if !empty(INCSLINKS)
96staging: stage_symlinks
97STAGE_SYMLINKS.INCS= ${INCSLINKS}
98.endif
99.endif
100.endif
101
102.endif # ${MK_TOOLCHAIN} != "no"
103