1a9e8c5c4SBrad Davis# 2a9e8c5c4SBrad Davis# Directory permissions management. 3a9e8c5c4SBrad Davis 4a9e8c5c4SBrad Davis.if !target(__<bsd.dirs.mk>__) 5a9e8c5c4SBrad Davis__<bsd.dirs.mk>__: 6a9e8c5c4SBrad Davis# List of directory variable names to install. Each variable name's value 7a9e8c5c4SBrad Davis# must be a full path. If non-default permissions are desired, <DIR>_MODE, 8a9e8c5c4SBrad Davis# <DIR>_OWN, and <DIR>_GRP may be specified. 9a9e8c5c4SBrad DavisDIRS?= 10a9e8c5c4SBrad Davis 11a9e8c5c4SBrad Davis. for dir in ${DIRS:O:u} 12a9e8c5c4SBrad Davis. if defined(${dir}) && !empty(${dir}) 13a9e8c5c4SBrad Davis# Set default permissions for a directory 14a9e8c5c4SBrad Davis${dir}_MODE?= 0755 15a9e8c5c4SBrad Davis${dir}_OWN?= root 16a9e8c5c4SBrad Davis${dir}_GRP?= wheel 17a9e8c5c4SBrad Davis. if defined(${dir}_FLAGS) && !empty(${dir}_FLAGS) 18a9e8c5c4SBrad Davis${dir}_FLAG= -f ${${dir}_FLAGS} 19a9e8c5c4SBrad Davis. endif 20a9e8c5c4SBrad Davis 21a9e8c5c4SBrad Davis. if defined(NO_ROOT) 22a9e8c5c4SBrad Davis. if !defined(${dir}TAGS) || ! ${${dir}TAGS:Mpackage=*} 23*4c1a82ceSEmmanuel Vadot${dir}TAGS+= package=${${dir}PACKAGE:Uutilities} 24a9e8c5c4SBrad Davis. endif 25a9e8c5c4SBrad Davis${dir}TAG_ARGS= -T ${${dir}TAGS:[*]:S/ /,/g} 26a9e8c5c4SBrad Davis. endif 27a9e8c5c4SBrad Davis 28a9e8c5c4SBrad Davisinstalldirs: installdirs-${dir} 294be52feeSBryan Drewery# Coalesce duplicate destdirs 304be52feeSBryan Drewery. if !defined(_uniquedirs_${${dir}}) 314be52feeSBryan Drewery_uniquedirs_${${dir}}= ${dir} 324be52feeSBryan Drewery_alldirs_${dir}= ${dir} 334be52feeSBryan Dreweryinstalldirs-${dir}: .PHONY 344be52feeSBryan Drewery @${ECHO} installing DIRS ${_alldirs_${dir}} 35a9e8c5c4SBrad Davis ${INSTALL} ${${dir}TAG_ARGS} -d -m ${${dir}_MODE} -o ${${dir}_OWN} \ 36a9e8c5c4SBrad Davis -g ${${dir}_GRP} ${${dir}_FLAG} ${DESTDIR}${${dir}} 374be52feeSBryan Drewery. else 384be52feeSBryan Drewery_uniquedir:= ${_uniquedirs_${${dir}}} 394be52feeSBryan Drewery_alldirs_${_uniquedir}+=${dir} 404be52feeSBryan Drewery# Connect to the single target 414be52feeSBryan Dreweryinstalldirs-${dir}: installdirs-${_uniquedir} 424be52feeSBryan Drewery# Validate that duplicate dirs have the same metadata. 434be52feeSBryan Drewery. for v in TAG_ARGS _MODE _OWN _GRP _FLAG 444be52feeSBryan Drewery. if ${${dir}${v}:Uunset} != ${${_uniquedir}${v}:Uunset} 454be52feeSBryan Drewery. warning ${RELDIR}: ${dir}${v} (${${dir}${v}:U}) does not match ${_uniquedir}${v} (${${_uniquedir}${v}:U}) but both install to ${${dir}} 46a9e8c5c4SBrad Davis. endif 47a9e8c5c4SBrad Davis. endfor 484be52feeSBryan Drewery. endif # !defined(_uniquedirs_${${dir}}) 494be52feeSBryan Drewery. endif # defined(${dir}) && !empty(${dir}) 504be52feeSBryan Drewery. endfor 514be52feeSBryan Drewery 524be52feeSBryan Dreweryrealinstall: installdirs 53a9e8c5c4SBrad Davis 54a9e8c5c4SBrad Davis.endif 55