3 # Adjust post-install permissions settings. This rule works off two
4 # specially-formatted variables, INSTALLPERMS_exec and INSTALLPERMS_data.
5 # Each is a whitespace-separated list of commands, all of which are either
6 # a variable assignment or a filename. Three variables are available:
8 # - dest= sets the destination directory to e.g., $(sbindir)
9 # - chown= controls changes in ownership; value is first argument to chown
10 # - chmod= controls changes in permissions; value is first argument to chmod
12 # As a special case, chown=amanda is taken as equivalent to
13 # chown=$(BINARY_OWNER):$(SETUID_GROUP), which may otherwise have problems with
14 # whitespace in the user/group names.
16 # when a filename is seen, the currently active variables are applied.
18 # Note that scripts are data, not executables!
22 # sbin_PROGRAMS = foo bar bing
23 # libexec_PROGRAMS = pro gram
24 # sbin_SCRIPTS = sk ript
25 # INSTALLPERMS_exec = \
26 # dest=$(sbindir) chown=amanda chmod= \
30 # dest=$(libexecdir) chmod= \
32 # INSTALLPERMS_data = \
33 # dest=$(sbindir) chown=amanda chmod= \
36 # This whole operation is not required when making builds for packaging,
37 # and can be disabled with --disable-installperms, via the WANT_INSTALLPERMS
40 # sed expression to strip leading directories from a filename; this converts e.g.,
41 # src/foo/bar.so to bar.so.
42 strip_leading_dirs=s|^.*/||
46 @installperms="$(INSTALLPERMS_exec)"; \
47 test -n "$$installperms" && echo "Setting installation permissions on executables"; \
48 dest=; chown=; chmod=; \
49 for cmd in $$installperms; do \
52 echo " ($$cmd)"; chown="$(BINARY_OWNER):$(SETUID_GROUP)";; \
53 dest=*|chown=*|chmod=*) \
54 echo " ($$cmd)"; eval $$cmd;; \
55 *) pa="$(DESTDIR)$$dest"/`echo "$$cmd"|sed '$(strip_leading_dirs)'|sed '$(transform)'`; \
56 if test -n "$$chown"; then \
57 echo chown "$$chown" "$$pa"; \
58 chown "$$chown" "$$pa" || exit 1; \
60 if test -n "$$chmod"; then \
61 echo chmod "$$chmod" "$$pa"; \
62 chmod "$$chmod" "$$pa" || exit 1; \
68 @installperms="$(INSTALLPERMS_data)"; \
69 test -n "$$installperms" && echo "Setting installation permissions on data"; \
70 dest=; chown=; chmod=; \
71 for cmd in $$installperms; do \
74 echo " ($$cmd)"; chown="$(BINARY_OWNER):$(SETUID_GROUP)";; \
75 dest=*|chown=*|chmod=*) \
76 echo " ($$cmd)"; eval $$cmd;; \
77 *) pa="$(DESTDIR)$$dest"/`echo "$$cmd"|sed '$(strip_leading_dirs)'|sed '$(transform)'`; \
78 if test -n "$$chown"; then \
79 echo chown "$$chown" "$$pa"; \
80 chown "$$chown" "$$pa" || exit 1; \
82 if test -n "$$chmod"; then \
83 echo chmod "$$chmod" "$$pa"; \
84 chmod "$$chmod" "$$pa" || exit 1; \
89 install-exec-hook: installperms-exec
90 install-data-hook: installperms-data