]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.dirs.mk
bhyvectl(8): Normalize the man page date
[FreeBSD/FreeBSD.git] / share / mk / bsd.dirs.mk
1 # $FreeBSD$
2 #
3 # Directory permissions management.
4
5 .if !target(__<bsd.dirs.mk>__)
6 __<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.
10 DIRS?=
11
12 .  for dir in ${DIRS:O:u}
13 .    if defined(${dir}) && !empty(${dir})
14 # Set default permissions for a directory
15 ${dir}_MODE?=   0755
16 ${dir}_OWN?=    root
17 ${dir}_GRP?=    wheel
18 .      if defined(${dir}_FLAGS) && !empty(${dir}_FLAGS)
19 ${dir}_FLAG=    -f ${${dir}_FLAGS}
20 .      endif
21
22 .      if defined(NO_ROOT)
23 .        if !defined(${dir}TAGS) || ! ${${dir}TAGS:Mpackage=*}
24 ${dir}TAGS+=            package=${${dir}PACKAGE:Uutilities}
25 .        endif
26 ${dir}TAG_ARGS= -T ${${dir}TAGS:[*]:S/ /,/g}
27 .      endif
28
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}}
38 .      else
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}}
47 .          endif
48 .        endfor
49 .      endif    # !defined(_uniquedirs_${${dir}})
50 .    endif      # defined(${dir}) && !empty(${dir})
51 .  endfor
52
53 realinstall: installdirs
54
55 .endif