xref: /freebsd/share/mk/bsd.incs.mk (revision 23541160bb3e58f5deb04a299eda60fc80b731bc)
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	${INSTALL_SYMLINK} ${s} ${DESTDIR}${t}
84.endfor
85.endif
86.endif # !target(installincludes)
87
88realinstall: installincludes
89.ORDER: beforeinstall installincludes
90
91.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD)
92.if !defined(NO_STAGE_INCLUDES)
93STAGE_TARGETS+= stage_includes
94.if !empty(INCSLINKS)
95STAGE_TARGETS+= stage_symlinks
96STAGE_SYMLINKS.INCS= ${INCSLINKS}
97.endif
98.endif
99.endif
100
101.endif # ${MK_INCLUDES} != "no"
102