xref: /freebsd/share/mk/bsd.files.mk (revision 7b821f55)
1af2dc868SRuslan Ermilov# $FreeBSD$
2af2dc868SRuslan Ermilov
3af2dc868SRuslan Ermilov.if !target(__<bsd.init.mk>__)
4af2dc868SRuslan Ermilov.error bsd.files.mk cannot be included directly.
5af2dc868SRuslan Ermilov.endif
6af2dc868SRuslan Ermilov
7ada17d7bSJulio Merino.if !target(__<bsd.files.mk>__)
87b821f55SBrad Davis.if target(__<bsd.dirs.mk>__)
97b821f55SBrad Davis.error bsd.dirs.mk must be included after bsd.files.mk.
107b821f55SBrad Davis.endif
117b821f55SBrad Davis
12ada17d7bSJulio Merino__<bsd.files.mk>__:
13ada17d7bSJulio Merino
14af2dc868SRuslan ErmilovFILESGROUPS?=	FILES
15af2dc868SRuslan Ermilov
16d7d0effeSBryan Drewery.for group in ${FILESGROUPS}
1766d0a2d5SWarner Losh# Add in foo.yes and remove duplicates from all the groups
1866d0a2d5SWarner Losh${${group}}:= ${${group}} ${${group}.yes}
1966d0a2d5SWarner Losh${${group}}:= ${${group}:O:u}
20af2dc868SRuslan Ermilovbuildfiles: ${${group}}
21af2dc868SRuslan Ermilov.endfor
22af2dc868SRuslan Ermilov
23db74470bSBryan Drewery.if !defined(_SKIP_BUILD)
24af2dc868SRuslan Ermilovall: buildfiles
25db74470bSBryan Drewery.endif
26af2dc868SRuslan Ermilov
27d7d0effeSBryan Drewery.for group in ${FILESGROUPS}
28af2dc868SRuslan Ermilov.if defined(${group}) && !empty(${group})
29cb56d4a8SRui Pauloinstallfiles: installfiles-${group}
30af2dc868SRuslan Ermilov
31af2dc868SRuslan Ermilov${group}OWN?=	${SHAREOWN}
32af2dc868SRuslan Ermilov${group}GRP?=	${SHAREGRP}
339ef60181SBryan Drewery.if ${MK_INSTALL_AS_USER} == "yes"
349ef60181SBryan Drewery${group}OWN=	${SHAREOWN}
359ef60181SBryan Drewery${group}GRP=	${SHAREGRP}
369ef60181SBryan Drewery.endif
37af2dc868SRuslan Ermilov${group}MODE?=	${SHAREMODE}
387b821f55SBrad Davis${group}DIR?=	BINDIR
39eba4cc15SBryan DrewerySTAGE_SETS+=	${group:C,[/*],_,g}
40eba4cc15SBryan DrewerySTAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${group}DIR}
41af2dc868SRuslan Ermilov
42144c4421SBaptiste Daroussin.if defined(NO_ROOT)
43144c4421SBaptiste Daroussin.if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
44144c4421SBaptiste Daroussin${group}TAGS+=		package=${${group}PACKAGE:Uruntime}
45144c4421SBaptiste Daroussin.endif
46144c4421SBaptiste Daroussin${group}TAG_ARGS=	-T ${${group}TAGS:[*]:S/ /,/g}
47144c4421SBaptiste Daroussin.endif
48144c4421SBaptiste Daroussin
49144c4421SBaptiste Daroussin
507b821f55SBrad Davis.if ${${group}DIR:S/^\///} == ${${group}DIR}
517b821f55SBrad Davis# ${group}DIR specifies a variable that specifies a path
527b821f55SBrad DavisDIRS+=	${${group}DIR}
537b821f55SBrad Davis_${group}DIR=	${${group}DIR}
547b821f55SBrad Davis.else
557b821f55SBrad Davis# ${group}DIR specifies a path
567b821f55SBrad DavisDIRS+=	${group}DIR
577b821f55SBrad Davis_${group}DIR=	${group}DIR
587b821f55SBrad Davis.endif
597b821f55SBrad Davis
607b821f55SBrad Davis
61af2dc868SRuslan Ermilov.for file in ${${group}}
627b821f55SBrad Davis${group}OWN_${file}?=	${${group}OWN}
637b821f55SBrad Davis${group}GRP_${file}?=	${${group}GRP}
649ef60181SBryan Drewery.if ${MK_INSTALL_AS_USER} == "yes"
657b821f55SBrad Davis${group}OWN_${file}=	${SHAREOWN}
667b821f55SBrad Davis${group}GRP_${file}=	${SHAREGRP}
677b821f55SBrad Davis.endif # ${MK_INSTALL_AS_USER} == "yes"
687b821f55SBrad Davis${group}MODE_${file}?=	${${group}MODE}
697b821f55SBrad Davis
707b821f55SBrad Davis# Determine the directory for the current file.  Default to the parent group
717b821f55SBrad Davis# DIR, then check to see how to pass that variable on below.
727b821f55SBrad Davis${group}DIR_${file}?=	${${group}DIR}
737b821f55SBrad Davis.if ${${group}DIR_${file}:S/^\///} == ${${group}DIR_${file}}
747b821f55SBrad Davis# DIR specifies a variable that specifies a path
757b821f55SBrad Davis_${group}DIR_${file}=	${${group}DIR_${file}}
76af2dc868SRuslan Ermilov.else
777b821f55SBrad Davis# DIR directly specifies a path
787b821f55SBrad Davis_${group}DIR_${file}=	${group}DIR_${file}
79af2dc868SRuslan Ermilov.endif
807b821f55SBrad Davis${group}PREFIX_${file}=	${DESTDIR}${${_${group}DIR_${file}}}
817b821f55SBrad Davis
827b821f55SBrad Davis# Append DIR to DIRS if not already in place -- DIRS is already filtered, so
837b821f55SBrad Davis# this is primarily to ease inspection.
847b821f55SBrad Davis.for d in ${DIRS}
857b821f55SBrad Davis_DIRS+=	${${d}}
867b821f55SBrad Davis.endfor
877b821f55SBrad Davis.if ${DIRS:M${_${group}DIR_${file}}} == ""
887b821f55SBrad Davis.if ${_DIRS:M${${_${group}DIR_${file}}}} == ""
897b821f55SBrad DavisDIRS+=	${_${group}DIR_${file}}
907b821f55SBrad Davis.else
917b821f55SBrad Davis_${group}DIR_${file}=	${group}DIR
927b821f55SBrad Davis.endif
937b821f55SBrad Davis.endif
947b821f55SBrad Davis
957b821f55SBrad Davis.if defined(${group}NAME)
967b821f55SBrad Davis${group}NAME_${file}?=	${${group}NAME}
977b821f55SBrad Davis.else
987b821f55SBrad Davis${group}NAME_${file}?=	${file:T}
997b821f55SBrad Davis.endif # defined(${group}NAME)
1007b821f55SBrad DavisSTAGE_AS_SETS+=	${file}
1017b821f55SBrad DavisSTAGE_AS_${file}= ${${group}NAME_${file}}
102509301d9SBryan Drewery# XXX {group}OWN,GRP,MODE
1037b821f55SBrad DavisSTAGE_DIR.${file}= ${STAGE_OBJTOP}${${group}DIR_${file}}
1047b821f55SBrad Davisstage_as.${file}: ${file}
1057750ad47SMarcel Moolenaar
1067b821f55SBrad Davisinstallfiles-${group}: _${group}INS1_${file}
1077b821f55SBrad Davis_${group}INS1_${file}: installdirs-${_${group}DIR_${file}} _${group}INS_${file}
1087b821f55SBrad Davis_${group}INS_${file}: ${file}
1097b821f55SBrad Davis	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${file}} \
1107b821f55SBrad Davis	    -g ${${group}GRP_${file}} -m ${${group}MODE_${file}} \
1117b821f55SBrad Davis	    ${.ALLSRC} ${${group}PREFIX_${file}}/${${group}NAME_${file}}
1127b821f55SBrad Davis.endfor # file in ${${group}}
113af2dc868SRuslan Ermilov
11484aac273SHartmut Brandt.endif # defined(${group}) && !empty(${group})
1157b821f55SBrad Davis.endfor # .for group in ${FILESGROUPS}
116af2dc868SRuslan Ermilov
117af2dc868SRuslan Ermilovrealinstall: installfiles
118badb7c1cSRuslan Ermilov.ORDER: beforeinstall installfiles
119ada17d7bSJulio Merino
1207750ad47SMarcel Moolenaar.if ${MK_STAGING} != "no"
1217750ad47SMarcel Moolenaar.if !empty(STAGE_SETS)
1227750ad47SMarcel Moolenaarbuildfiles: stage_files
1237750ad47SMarcel Moolenaar.if !empty(STAGE_AS_SETS)
1247750ad47SMarcel Moolenaarbuildfiles: stage_as
1257750ad47SMarcel Moolenaar.endif
1267750ad47SMarcel Moolenaar.endif
1277750ad47SMarcel Moolenaar.endif
128ee7b0571SSimon J. Gerraty
1298f958ba9SBrad Davis.include <bsd.dirs.mk>
1308f958ba9SBrad Davis
131ada17d7bSJulio Merino.endif # !target(__<bsd.files.mk>__)
132