xref: /freebsd/share/mk/bsd.incs.mk (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1c7b111cbSRuslan Ermilov
2c7b111cbSRuslan Ermilov.if !target(__<bsd.init.mk>__)
3c7b111cbSRuslan Ermilov.error bsd.incs.mk cannot be included directly.
4c7b111cbSRuslan Ermilov.endif
5c7b111cbSRuslan Ermilov
6590461a4SWarner Losh.if ${MK_INCLUDES} != "no"
7b8435aa8SRuslan Ermilov
8c7b111cbSRuslan ErmilovINCSGROUPS?=	INCS
9c7b111cbSRuslan Ermilov
105d862037SRuslan Ermilov.if !target(buildincludes)
11d7d0effeSBryan Drewery.for group in ${INCSGROUPS}
125d862037SRuslan Ermilovbuildincludes: ${${group}}
13c7b111cbSRuslan Ermilov.endfor
14c7b111cbSRuslan Ermilov.endif
15c7b111cbSRuslan Ermilov
16db74470bSBryan Drewery.if !defined(_SKIP_BUILD)
175d862037SRuslan Ermilovall: buildincludes
18db74470bSBryan Drewery.endif
19c7b111cbSRuslan Ermilov
205d862037SRuslan Ermilov.if !target(installincludes)
21d7d0effeSBryan Drewery.for group in ${INCSGROUPS}
22c7b111cbSRuslan Ermilov.if defined(${group}) && !empty(${group})
23c7b111cbSRuslan Ermilov
24c7b111cbSRuslan Ermilov${group}OWN?=	${BINOWN}
25c7b111cbSRuslan Ermilov${group}GRP?=	${BINGRP}
26c7b111cbSRuslan Ermilov${group}MODE?=	${NOBINMODE}
275551c573SBaptiste Daroussin${group}DIR?=	${INCLUDEDIR}${PRIVATELIB:D/private/${LIB}}
28eba4cc15SBryan DrewerySTAGE_SETS+=	${group:C,[/*],_,g}
29eba4cc15SBryan DrewerySTAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${group}DIR}
30eba4cc15SBryan DrewerySTAGE_SYMLINKS_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}
31c7b111cbSRuslan Ermilov
32*53a27d89SEmmanuel Vadot.if defined(NO_ROOT)
33*53a27d89SEmmanuel Vadot.if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
34*53a27d89SEmmanuel Vadot.if defined(${group}PACKAGE)
35*53a27d89SEmmanuel Vadot${group}TAGS+=		package=${${group}PACKAGE:Uutilities},dev
36*53a27d89SEmmanuel Vadot.else
37*53a27d89SEmmanuel Vadot${group}TAGS+=		package=${PACKAGE:Uutilities},dev
38*53a27d89SEmmanuel Vadot.endif
39*53a27d89SEmmanuel Vadot.endif
40*53a27d89SEmmanuel Vadot${group}TAG_ARGS=	-T ${${group}TAGS:[*]:S/ /,/g}
41*53a27d89SEmmanuel Vadot.endif
42*53a27d89SEmmanuel Vadot
43c7b111cbSRuslan Ermilov_${group}INCS=
44c7b111cbSRuslan Ermilov.for header in ${${group}}
45c7b111cbSRuslan Ermilov.if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \
46c7b111cbSRuslan Ermilov    defined(${group}MODE_${header:T}) || defined(${group}DIR_${header:T}) || \
476427a5d4SSimon J. Gerraty    defined(${group}NAME_${header:T}) || defined(${group}NAME)
48c7b111cbSRuslan Ermilov${group}OWN_${header:T}?=	${${group}OWN}
49c7b111cbSRuslan Ermilov${group}GRP_${header:T}?=	${${group}GRP}
50c7b111cbSRuslan Ermilov${group}MODE_${header:T}?=	${${group}MODE}
51c7b111cbSRuslan Ermilov${group}DIR_${header:T}?=	${${group}DIR}
52c7b111cbSRuslan Ermilov.if defined(${group}NAME)
53c7b111cbSRuslan Ermilov${group}NAME_${header:T}?=	${${group}NAME}
54c7b111cbSRuslan Ermilov.else
55c7b111cbSRuslan Ermilov${group}NAME_${header:T}?=	${header:T}
56c7b111cbSRuslan Ermilov.endif
57509301d9SBryan DrewerySTAGE_AS_SETS+= ${header:T}
587750ad47SMarcel MoolenaarSTAGE_AS_${header:T}= ${${group}NAME_${header:T}}
59509301d9SBryan Drewery# XXX {group}OWN,GRP,MODE
60509301d9SBryan DrewerySTAGE_DIR.${header:T}= ${STAGE_OBJTOP}${${group}DIR_${header:T}}
61509301d9SBryan Drewerystage_as.${header:T}: ${header}
62509301d9SBryan Drewerystage_includes: stage_as.${header:T}
637750ad47SMarcel Moolenaar
645d862037SRuslan Ermilovinstallincludes: _${group}INS_${header:T}
65c7b111cbSRuslan Ermilov_${group}INS_${header:T}: ${header}
66697b271dSEd Maste	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -C -o ${${group}OWN_${.ALLSRC:T}} \
67c7b111cbSRuslan Ermilov	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
68c7b111cbSRuslan Ermilov	    ${.ALLSRC} \
69c7b111cbSRuslan Ermilov	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
70c7b111cbSRuslan Ermilov.else
71c7b111cbSRuslan Ermilov_${group}INCS+= ${header}
72c7b111cbSRuslan Ermilov.endif
73*53a27d89SEmmanuel Vadot.endfor # header in ${${group}}
74c7b111cbSRuslan Ermilov.if !empty(_${group}INCS)
757750ad47SMarcel Moolenaarstage_files.${group}: ${_${group}INCS}
761a682d2cSSimon J. Gerratystage_includes: stage_files.${group}
777750ad47SMarcel Moolenaar
785d862037SRuslan Ermilovinstallincludes: _${group}INS
79c7b111cbSRuslan Ermilov_${group}INS: ${_${group}INCS}
80c7b111cbSRuslan Ermilov.if defined(${group}NAME)
81*53a27d89SEmmanuel Vadot	${INSTALL} ${${group}TAG_ARGS} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
82c7b111cbSRuslan Ermilov	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME}
83c7b111cbSRuslan Ermilov.else
84*53a27d89SEmmanuel Vadot	${INSTALL} ${${group}TAG_ARGS} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \
8561c20fc7SBryan Drewery	    ${.ALLSRC} ${DESTDIR}${${group}DIR}/
86c7b111cbSRuslan Ermilov.endif
87*53a27d89SEmmanuel Vadot.endif # !empty(_${group}INCS)
88c7b111cbSRuslan Ermilov
8984aac273SHartmut Brandt.endif # defined(${group}) && !empty(${group})
90*53a27d89SEmmanuel Vadot.endfor # group in ${INCSGROUPS}
91c7b111cbSRuslan Ermilov
92c7b111cbSRuslan Ermilov.if defined(INCSLINKS) && !empty(INCSLINKS)
935d862037SRuslan Ermilovinstallincludes:
945428abe1SBaptiste Daroussin.for s t in ${INCSLINKS}
95697b271dSEd Maste	${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},dev} ${s} ${DESTDIR}${t}
965428abe1SBaptiste Daroussin.endfor
97c7b111cbSRuslan Ermilov.endif
9884aac273SHartmut Brandt.endif # !target(installincludes)
995d862037SRuslan Ermilov
1005d862037SRuslan Ermilovrealinstall: installincludes
101badb7c1cSRuslan Ermilov.ORDER: beforeinstall installincludes
102b8435aa8SRuslan Ermilov
1036427a5d4SSimon J. Gerraty.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD)
1041a682d2cSSimon J. Gerraty.if !defined(NO_STAGE_INCLUDES)
105eef72759SSimon J. GerratySTAGE_TARGETS+= stage_includes
1066427a5d4SSimon J. Gerraty.if !empty(INCSLINKS)
107eef72759SSimon J. GerratySTAGE_TARGETS+= stage_symlinks
1085ac3e457SSimon J. GerratySTAGE_SYMLINKS.INCS= ${INCSLINKS}
1097750ad47SMarcel Moolenaar.endif
1107750ad47SMarcel Moolenaar.endif
1117750ad47SMarcel Moolenaar.endif
1127750ad47SMarcel Moolenaar
11316927922SBryan Drewery.endif # ${MK_INCLUDES} != "no"
114