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