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