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