1# 2# Directory permissions management. 3 4.if !target(__<bsd.dirs.mk>__) 5__<bsd.dirs.mk>__: 6# List of directory variable names to install. Each variable name's value 7# must be a full path. If non-default permissions are desired, <DIR>_MODE, 8# <DIR>_OWN, and <DIR>_GRP may be specified. 9DIRS?= 10 11. for dir in ${DIRS:O:u} 12. if defined(${dir}) && !empty(${dir}) 13# Set default permissions for a directory 14${dir}_MODE?= 0755 15${dir}_OWN?= root 16${dir}_GRP?= wheel 17. if defined(${dir}_FLAGS) && !empty(${dir}_FLAGS) 18${dir}_FLAG= -f ${${dir}_FLAGS} 19. endif 20 21. if defined(NO_ROOT) 22. if !defined(${dir}TAGS) || ! ${${dir}TAGS:Mpackage=*} 23${dir}TAGS+= package=${${dir}PACKAGE:Uutilities} 24. endif 25${dir}TAG_ARGS= -T ${${dir}TAGS:[*]:S/ /,/g} 26. endif 27 28installdirs: installdirs-${dir} 29# Coalesce duplicate destdirs 30. if !defined(_uniquedirs_${${dir}}) 31_uniquedirs_${${dir}}= ${dir} 32_alldirs_${dir}= ${dir} 33installdirs-${dir}: .PHONY 34 @${ECHO} installing DIRS ${_alldirs_${dir}} 35 ${INSTALL} ${${dir}TAG_ARGS} -d -m ${${dir}_MODE} -o ${${dir}_OWN} \ 36 -g ${${dir}_GRP} ${${dir}_FLAG} ${DESTDIR}${${dir}} 37. else 38_uniquedir:= ${_uniquedirs_${${dir}}} 39_alldirs_${_uniquedir}+=${dir} 40# Connect to the single target 41installdirs-${dir}: installdirs-${_uniquedir} 42# Validate that duplicate dirs have the same metadata. 43. for v in TAG_ARGS _MODE _OWN _GRP _FLAG 44. if ${${dir}${v}:Uunset} != ${${_uniquedir}${v}:Uunset} 45. warning ${RELDIR}: ${dir}${v} (${${dir}${v}:U}) does not match ${_uniquedir}${v} (${${_uniquedir}${v}:U}) but both install to ${${dir}} 46. endif 47. endfor 48. endif # !defined(_uniquedirs_${${dir}}) 49. endif # defined(${dir}) && !empty(${dir}) 50. endfor 51 52realinstall: installdirs 53 54.endif 55