xref: /freebsd/share/mk/bsd.incs.mk (revision acc1a9ef8333c798c210fa94be6af4d5fe2dd794)
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_INCSGROUPS=	${INCSGROUPS:C,[/*],_,g}
12
13.if !target(buildincludes)
14.for group in ${_INCSGROUPS}
15buildincludes: ${${group}}
16.endfor
17.endif
18
19.if !defined(_SKIP_BUILD)
20all: buildincludes
21.endif
22
23.if !target(installincludes)
24.for group in ${_INCSGROUPS}
25.if defined(${group}) && !empty(${group})
26
27${group}OWN?=	${BINOWN}
28${group}GRP?=	${BINGRP}
29${group}MODE?=	${NOBINMODE}
30${group}DIR?=	${INCLUDEDIR}${PRIVATELIB:D/private/${LIB}}
31STAGE_SETS+=	${group}
32STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
33STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP}
34
35_${group}INCS=
36.for header in ${${group}}
37.if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \
38    defined(${group}MODE_${header:T}) || defined(${group}DIR_${header:T}) || \
39    defined(${group}NAME_${header:T}) || defined(${group}NAME)
40${group}OWN_${header:T}?=	${${group}OWN}
41${group}GRP_${header:T}?=	${${group}GRP}
42${group}MODE_${header:T}?=	${${group}MODE}
43${group}DIR_${header:T}?=	${${group}DIR}
44.if defined(${group}NAME)
45${group}NAME_${header:T}?=	${${group}NAME}
46.else
47${group}NAME_${header:T}?=	${header:T}
48.endif
49STAGE_AS_SETS+= ${header:T}
50STAGE_AS_${header:T}= ${${group}NAME_${header:T}}
51# XXX {group}OWN,GRP,MODE
52STAGE_DIR.${header:T}= ${STAGE_OBJTOP}${${group}DIR_${header:T}}
53stage_as.${header:T}: ${header}
54stage_includes: stage_as.${header:T}
55
56installincludes: _${group}INS_${header:T}
57_${group}INS_${header:T}: ${header}
58	${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \
59	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
60	    ${.ALLSRC} \
61	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
62.else
63_${group}INCS+= ${header}
64.endif
65.endfor
66.if !empty(_${group}INCS)
67stage_files.${group}: ${_${group}INCS}
68stage_includes: stage_files.${group}
69
70installincludes: _${group}INS
71_${group}INS: ${_${group}INCS}
72.if defined(${group}NAME)
73	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
74	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
75.else
76	${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
77	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/
78.endif
79.endif
80
81.endif # defined(${group}) && !empty(${group})
82.endfor
83
84.if defined(INCSLINKS) && !empty(INCSLINKS)
85installincludes:
86.for s t in ${INCSLINKS}
87	${INSTALL_SYMLINK} ${s} ${DESTDIR}${t}
88.endfor
89.endif
90.endif # !target(installincludes)
91
92realinstall: installincludes
93.ORDER: beforeinstall installincludes
94
95.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD)
96.if !defined(NO_STAGE_INCLUDES)
97STAGE_TARGETS+= stage_includes
98.if !empty(INCSLINKS)
99STAGE_TARGETS+= stage_symlinks
100STAGE_SYMLINKS.INCS= ${INCSLINKS}
101.endif
102.endif
103.endif
104
105.endif # ${MK_INCLUDES} != "no"
106