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