xref: /freebsd/share/mk/bsd.dirs.mk (revision c8e7055577942f62c35b38e995708418197c7497)
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.
10DIRS?=
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:Uruntime}
25.        endif
26${dir}TAG_ARGS=	-T ${${dir}TAGS:[*]:S/ /,/g}
27.      endif
28
29installdirs: installdirs-${dir}
30
31installdirs-${dir}: installdirs-${DESTDIR}${${dir}}
32
33.      if !target(installdirs-${DESTDIR}${${dir}})
34installdirs-${DESTDIR}${${dir}}:
35	@${ECHO} installing DIRS ${dir}
36	${INSTALL} ${${dir}TAG_ARGS} -d -m ${${dir}_MODE} -o ${${dir}_OWN} \
37		-g ${${dir}_GRP} ${${dir}_FLAG} ${DESTDIR}${${dir}}
38.      endif
39.    endif
40
41realinstall: installdirs-${dir}
42.  endfor
43
44.endif
45