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