1af2dc868SRuslan Ermilov 2af2dc868SRuslan Ermilov.if !target(__<bsd.init.mk>__) 3af2dc868SRuslan Ermilov.error bsd.files.mk cannot be included directly. 4af2dc868SRuslan Ermilov.endif 5af2dc868SRuslan Ermilov 6ada17d7bSJulio Merino.if !target(__<bsd.files.mk>__) 77b821f55SBrad Davis.if target(__<bsd.dirs.mk>__) 87b821f55SBrad Davis.error bsd.dirs.mk must be included after bsd.files.mk. 97b821f55SBrad Davis.endif 107b821f55SBrad Davis 11ada17d7bSJulio Merino__<bsd.files.mk>__: 12ada17d7bSJulio Merino 13af2dc868SRuslan ErmilovFILESGROUPS?= FILES 14af2dc868SRuslan Ermilov 15d7d0effeSBryan Drewery.for group in ${FILESGROUPS} 1666d0a2d5SWarner Losh# Add in foo.yes and remove duplicates from all the groups 1766d0a2d5SWarner Losh${${group}}:= ${${group}} ${${group}.yes} 1866d0a2d5SWarner Losh${${group}}:= ${${group}:O:u} 19af2dc868SRuslan Ermilovbuildfiles: ${${group}} 20af2dc868SRuslan Ermilov.endfor 21af2dc868SRuslan Ermilov 22db74470bSBryan Drewery.if !defined(_SKIP_BUILD) 23af2dc868SRuslan Ermilovall: buildfiles 24db74470bSBryan Drewery.endif 25af2dc868SRuslan Ermilov 26d7d0effeSBryan Drewery.for group in ${FILESGROUPS} 27af2dc868SRuslan Ermilov.if defined(${group}) && !empty(${group}) 28cb56d4a8SRui Pauloinstallfiles: installfiles-${group} 29af2dc868SRuslan Ermilov 30af2dc868SRuslan Ermilov${group}OWN?= ${SHAREOWN} 31af2dc868SRuslan Ermilov${group}GRP?= ${SHAREGRP} 329ef60181SBryan Drewery.if ${MK_INSTALL_AS_USER} == "yes" 339ef60181SBryan Drewery${group}OWN= ${SHAREOWN} 349ef60181SBryan Drewery${group}GRP= ${SHAREGRP} 359ef60181SBryan Drewery.endif 36af2dc868SRuslan Ermilov${group}MODE?= ${SHAREMODE} 377b821f55SBrad Davis${group}DIR?= BINDIR 38eba4cc15SBryan DrewerySTAGE_SETS+= ${group:C,[/*],_,g} 39af2dc868SRuslan Ermilov 405112cfa0SEmmanuel Vadot.if ${group} == "FILES" 410b8a2c74SEmmanuel VadotFILESPACKAGE?= ${PACKAGE:Uutilities} 425112cfa0SEmmanuel Vadot.endif 435112cfa0SEmmanuel Vadot 44144c4421SBaptiste Daroussin.if defined(NO_ROOT) 45144c4421SBaptiste Daroussin.if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*} 464c1a82ceSEmmanuel Vadot${group}TAGS+= package=${${group}PACKAGE:Uutilities} 47144c4421SBaptiste Daroussin.endif 48144c4421SBaptiste Daroussin${group}TAG_ARGS= -T ${${group}TAGS:[*]:S/ /,/g} 49144c4421SBaptiste Daroussin.endif 50144c4421SBaptiste Daroussin 51144c4421SBaptiste Daroussin 527b821f55SBrad Davis.if ${${group}DIR:S/^\///} == ${${group}DIR} 537b821f55SBrad Davis# ${group}DIR specifies a variable that specifies a path 547b821f55SBrad DavisDIRS+= ${${group}DIR} 55735a585eSEmmanuel Vadot${group}DIRTAGS= ${group}TAGS 567b821f55SBrad Davis_${group}DIR= ${${group}DIR} 577b821f55SBrad Davis.else 587b821f55SBrad Davis# ${group}DIR specifies a path 597b821f55SBrad DavisDIRS+= ${group}DIR 60735a585eSEmmanuel Vadot${group}DIRTAGS= ${${group}TAGS} 617b821f55SBrad Davis_${group}DIR= ${group}DIR 627b821f55SBrad Davis.endif 637b821f55SBrad Davis 64fe868b9bSSimon J. GerratySTAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR}} 657b821f55SBrad Davis 66af2dc868SRuslan Ermilov.for file in ${${group}} 677b821f55SBrad Davis${group}OWN_${file}?= ${${group}OWN} 687b821f55SBrad Davis${group}GRP_${file}?= ${${group}GRP} 699ef60181SBryan Drewery.if ${MK_INSTALL_AS_USER} == "yes" 707b821f55SBrad Davis${group}OWN_${file}= ${SHAREOWN} 717b821f55SBrad Davis${group}GRP_${file}= ${SHAREGRP} 727b821f55SBrad Davis.endif # ${MK_INSTALL_AS_USER} == "yes" 737b821f55SBrad Davis${group}MODE_${file}?= ${${group}MODE} 747b821f55SBrad Davis 757b821f55SBrad Davis# Determine the directory for the current file. Default to the parent group 767b821f55SBrad Davis# DIR, then check to see how to pass that variable on below. 777b821f55SBrad Davis${group}DIR_${file}?= ${${group}DIR} 787b821f55SBrad Davis.if ${${group}DIR_${file}:S/^\///} == ${${group}DIR_${file}} 797b821f55SBrad Davis# DIR specifies a variable that specifies a path 807b821f55SBrad Davis_${group}DIR_${file}= ${${group}DIR_${file}} 81af2dc868SRuslan Ermilov.else 827b821f55SBrad Davis# DIR directly specifies a path 837b821f55SBrad Davis_${group}DIR_${file}= ${group}DIR_${file} 84af2dc868SRuslan Ermilov.endif 857b821f55SBrad Davis${group}PREFIX_${file}= ${DESTDIR}${${_${group}DIR_${file}}} 867b821f55SBrad Davis 877b821f55SBrad Davis# Append DIR to DIRS if not already in place -- DIRS is already filtered, so 887b821f55SBrad Davis# this is primarily to ease inspection. 897b821f55SBrad Davis.for d in ${DIRS} 907b821f55SBrad Davis_DIRS+= ${${d}} 917b821f55SBrad Davis.endfor 927b821f55SBrad Davis.if ${DIRS:M${_${group}DIR_${file}}} == "" 937b821f55SBrad Davis.if ${_DIRS:M${${_${group}DIR_${file}}}} == "" 947b821f55SBrad DavisDIRS+= ${_${group}DIR_${file}} 957b821f55SBrad Davis.else 967b821f55SBrad Davis_${group}DIR_${file}= ${group}DIR 977b821f55SBrad Davis.endif 987b821f55SBrad Davis.endif 997b821f55SBrad Davis 1007b821f55SBrad Davis.if defined(${group}NAME) 1017b821f55SBrad Davis${group}NAME_${file}?= ${${group}NAME} 1027b821f55SBrad Davis.else 1037b821f55SBrad Davis${group}NAME_${file}?= ${file:T} 1047b821f55SBrad Davis.endif # defined(${group}NAME) 1057b821f55SBrad DavisSTAGE_AS_${file}= ${${group}NAME_${file}} 106f18ca7f3SSimon J. Gerraty# we cannot use file safely as a set name 107f18ca7f3SSimon J. Gerraty# since we cannot? apply :T 108f18ca7f3SSimon J. Gerraty# but we can use the ${group}DIR_${file} 109f18ca7f3SSimon J. Gerraty# as a set - meta.stage.mk will :O:u for us 110f18ca7f3SSimon J. Gerraty# we need to expand ${group}DIR_${file} and replace 111f18ca7f3SSimon J. Gerraty# all '/' and '*' with '_' to make a safe target name. 112f18ca7f3SSimon J. GerratySTAGE_AS_SETS+= ${${_${group}DIR_${file}}:C,[/*],_,g} 113911651d5SSimon J. GerratySTAGE_DIR.${${_${group}DIR_${file}}:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR_${file}}} 114f18ca7f3SSimon J. Gerratystage_as.${${_${group}DIR_${file}}:C,[/*],_,g}: ${file} 1157750ad47SMarcel Moolenaar 116310399acSAlex Richardsoninstallfiles-${group}: _${group}INS_${file} 117310399acSAlex Richardson_${group}INS_${file}: ${file} installdirs-${_${group}DIR_${file}} 118da6620e4SVal Packett ${INSTALL} -C ${${group}TAG_ARGS} -o ${${group}OWN_${file}} \ 1197b821f55SBrad Davis -g ${${group}GRP_${file}} -m ${${group}MODE_${file}} \ 1202719bb7eSAlex Richardson ${.ALLSRC:Ninstalldirs-*} ${${group}PREFIX_${file}}/${${group}NAME_${file}} 1217b821f55SBrad Davis.endfor # file in ${${group}} 122af2dc868SRuslan Ermilov 12384aac273SHartmut Brandt.endif # defined(${group}) && !empty(${group}) 1247b821f55SBrad Davis.endfor # .for group in ${FILESGROUPS} 125af2dc868SRuslan Ermilov 126af2dc868SRuslan Ermilovrealinstall: installfiles 127badb7c1cSRuslan Ermilov.ORDER: beforeinstall installfiles 128ada17d7bSJulio Merino 1297750ad47SMarcel Moolenaar.if ${MK_STAGING} != "no" 130f18ca7f3SSimon J. Gerraty.if ${FILESGROUPS:@g@${$g}@} != "" 1317750ad47SMarcel Moolenaar.if !empty(STAGE_SETS) 1327750ad47SMarcel Moolenaarbuildfiles: stage_files 133a6589ab7SSimon J. GerratySTAGE_TARGETS+= stage_files 134f18ca7f3SSimon J. Gerratystage_files: 1357750ad47SMarcel Moolenaar.if !empty(STAGE_AS_SETS) 1367750ad47SMarcel Moolenaarbuildfiles: stage_as 137a6589ab7SSimon J. GerratySTAGE_TARGETS+= stage_as 138f18ca7f3SSimon J. Gerratystage_as: 139f18ca7f3SSimon J. Gerraty.endif 1407750ad47SMarcel Moolenaar.endif 1417750ad47SMarcel Moolenaar.endif 1427750ad47SMarcel Moolenaar.endif 143ee7b0571SSimon J. Gerraty 1448f958ba9SBrad Davis.include <bsd.dirs.mk> 1458f958ba9SBrad Davis 146ada17d7bSJulio Merino.endif # !target(__<bsd.files.mk>__) 147