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