1# $FreeBSD$ 2 3.if !target(__<bsd.init.mk>__) 4.error bsd.files.mk cannot be included directly. 5.endif 6 7.if !target(__<bsd.files.mk>__) 8.if target(__<bsd.dirs.mk>__) 9.error bsd.dirs.mk must be included after bsd.files.mk. 10.endif 11 12__<bsd.files.mk>__: 13 14FILESGROUPS?= FILES 15 16.for group in ${FILESGROUPS} 17# Add in foo.yes and remove duplicates from all the groups 18${${group}}:= ${${group}} ${${group}.yes} 19${${group}}:= ${${group}:O:u} 20buildfiles: ${${group}} 21.endfor 22 23.if !defined(_SKIP_BUILD) 24all: buildfiles 25.endif 26 27.for group in ${FILESGROUPS} 28.if defined(${group}) && !empty(${group}) 29installfiles: installfiles-${group} 30 31${group}OWN?= ${SHAREOWN} 32${group}GRP?= ${SHAREGRP} 33.if ${MK_INSTALL_AS_USER} == "yes" 34${group}OWN= ${SHAREOWN} 35${group}GRP= ${SHAREGRP} 36.endif 37${group}MODE?= ${SHAREMODE} 38${group}DIR?= BINDIR 39STAGE_SETS+= ${group:C,[/*],_,g} 40 41.if ${group} == "FILES" 42FILESPACKAGE= ${PACKAGE:Uutilities} 43.endif 44 45.if defined(NO_ROOT) 46.if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*} 47${group}TAGS+= package=${${group}PACKAGE:Uutilities} 48.endif 49${group}TAG_ARGS= -T ${${group}TAGS:[*]:S/ /,/g} 50.endif 51 52 53.if ${${group}DIR:S/^\///} == ${${group}DIR} 54# ${group}DIR specifies a variable that specifies a path 55DIRS+= ${${group}DIR} 56_${group}DIR= ${${group}DIR} 57.else 58# ${group}DIR specifies a path 59DIRS+= ${group}DIR 60_${group}DIR= ${group}DIR 61.endif 62 63STAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR}} 64 65.for file in ${${group}} 66${group}OWN_${file}?= ${${group}OWN} 67${group}GRP_${file}?= ${${group}GRP} 68.if ${MK_INSTALL_AS_USER} == "yes" 69${group}OWN_${file}= ${SHAREOWN} 70${group}GRP_${file}= ${SHAREGRP} 71.endif # ${MK_INSTALL_AS_USER} == "yes" 72${group}MODE_${file}?= ${${group}MODE} 73 74# Determine the directory for the current file. Default to the parent group 75# DIR, then check to see how to pass that variable on below. 76${group}DIR_${file}?= ${${group}DIR} 77.if ${${group}DIR_${file}:S/^\///} == ${${group}DIR_${file}} 78# DIR specifies a variable that specifies a path 79_${group}DIR_${file}= ${${group}DIR_${file}} 80.else 81# DIR directly specifies a path 82_${group}DIR_${file}= ${group}DIR_${file} 83.endif 84${group}PREFIX_${file}= ${DESTDIR}${${_${group}DIR_${file}}} 85 86# Append DIR to DIRS if not already in place -- DIRS is already filtered, so 87# this is primarily to ease inspection. 88.for d in ${DIRS} 89_DIRS+= ${${d}} 90.endfor 91.if ${DIRS:M${_${group}DIR_${file}}} == "" 92.if ${_DIRS:M${${_${group}DIR_${file}}}} == "" 93DIRS+= ${_${group}DIR_${file}} 94.else 95_${group}DIR_${file}= ${group}DIR 96.endif 97.endif 98 99.if defined(${group}NAME) 100${group}NAME_${file}?= ${${group}NAME} 101.else 102${group}NAME_${file}?= ${file:T} 103.endif # defined(${group}NAME) 104STAGE_AS_${file}= ${${group}NAME_${file}} 105# we cannot use file safely as a set name 106# since we cannot? apply :T 107# but we can use the ${group}DIR_${file} 108# as a set - meta.stage.mk will :O:u for us 109# we need to expand ${group}DIR_${file} and replace 110# all '/' and '*' with '_' to make a safe target name. 111STAGE_AS_SETS+= ${${_${group}DIR_${file}}:C,[/*],_,g} 112STAGE_DIR.${${_${group}DIR_${file}}:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR_${file}}} 113stage_as.${${_${group}DIR_${file}}:C,[/*],_,g}: ${file} 114 115installfiles-${group}: _${group}INS_${file} 116_${group}INS_${file}: ${file} installdirs-${_${group}DIR_${file}} 117 ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${file}} \ 118 -g ${${group}GRP_${file}} -m ${${group}MODE_${file}} \ 119 ${.ALLSRC:Ninstalldirs-*} ${${group}PREFIX_${file}}/${${group}NAME_${file}} 120.endfor # file in ${${group}} 121 122.endif # defined(${group}) && !empty(${group}) 123.endfor # .for group in ${FILESGROUPS} 124 125realinstall: installfiles 126.ORDER: beforeinstall installfiles 127 128.if ${MK_STAGING} != "no" 129.if ${FILESGROUPS:@g@${$g}@} != "" 130.if !empty(STAGE_SETS) 131buildfiles: stage_files 132STAGE_TARGETS+= stage_files 133stage_files: 134.if !empty(STAGE_AS_SETS) 135buildfiles: stage_as 136STAGE_TARGETS+= stage_as 137stage_as: 138.endif 139.endif 140.endif 141.endif 142 143.include <bsd.dirs.mk> 144 145.endif # !target(__<bsd.files.mk>__) 146