diff options
author | Arvind Sankar <[email protected]> | 2020-07-11 19:35:58 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-07-14 17:33:44 -0700 |
commit | 38e2e9ce8327284b2d516874308300aa96102fe9 (patch) | |
tree | 0761f7f696e4da7888a0c99ffb3a91a63ecefdd4 /config | |
parent | bdb518c13abb9eca8d6f8f1d9e2096dc5163a9e7 (diff) |
Centralize variable substitution
A bunch of places need to edit files to incorporate the configured paths
i.e. bindir, sbindir etc. Move this logic into a common file.
Create arc_summary by copying arc_summary[23] as appropriate at build
time instead of install time.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Arvind Sankar <[email protected]>
Closes #10559
Diffstat (limited to 'config')
-rw-r--r-- | config/Substfiles.am | 34 | ||||
-rw-r--r-- | config/always-python.m4 | 4 | ||||
-rw-r--r-- | config/zfs-build.m4 | 58 |
3 files changed, 77 insertions, 19 deletions
diff --git a/config/Substfiles.am b/config/Substfiles.am new file mode 100644 index 000000000..63697bfa2 --- /dev/null +++ b/config/Substfiles.am @@ -0,0 +1,34 @@ +subst_sed_cmd = \ + -e 's|@bindir[@]|$(bindir)|g' \ + -e 's|@sbindir[@]|$(sbindir)|g' \ + -e 's|@datadir[@]|$(datadir)|g' \ + -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ + -e 's|@runstatedir[@]|$(runstatedir)|g' \ + -e 's|@initconfdir[@]|$(initconfdir)|g' \ + -e 's|@initdir[@]|$(initdir)|g' \ + -e 's|@mounthelperdir[@]|$(mounthelperdir)|g' \ + -e 's|@systemdgeneratordir[@]|$(systemdgeneratordir)|g' \ + -e 's|@systemdunitdir[@]|$(systemdunitdir)|g' \ + -e 's|@udevdir[@]|$(udevdir)|g' \ + -e 's|@udevruledir[@]|$(udevruledir)|g' \ + -e 's|@zfsexecdir[@]|$(zfsexecdir)|g' \ + -e 's|@PYTHON[@]|$(PYTHON)|g' \ + -e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \ + -e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \ + -e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' + +SUBSTFILES = +CLEANFILES = $(SUBSTFILES) +EXTRA_DIST = $(SUBSTFILES:=.in) + +$(SUBSTFILES):%:%.in Makefile + $(AM_V_GEN)set -e; \ + $(MKDIR_P) $$(dirname $@); \ + $(RM) $@~; \ + $(SED) $(subst_sed_cmd) $< >$@~; \ + if grep -E '@[a-zA-Z0-9_]+@' $@~ >&2; then \ + echo "Undefined substitution" >&2; \ + exit 1; \ + else test $$? -eq 1; fi; \ + test -x $< && chmod +x $@~; \ + mv -f $@~ $@ diff --git a/config/always-python.m4 b/config/always-python.m4 index c1c07597e..c01e631a8 100644 --- a/config/always-python.m4 +++ b/config/always-python.m4 @@ -49,6 +49,10 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYTHON], [ AM_CONDITIONAL([USING_PYTHON_2], [test "x${PYTHON_VERSION%%\.*}" = x2]) AM_CONDITIONAL([USING_PYTHON_3], [test "x${PYTHON_VERSION%%\.*}" = x3]) + AM_COND_IF([USING_PYTHON_2], + [AC_SUBST([PYTHON_SHEBANG], [python2])], + [AC_SUBST([PYTHON_SHEBANG], [python3])]) + dnl # dnl # Request that packages be built for a specific Python version. dnl # diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index dea3f6137..54b61de09 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -266,7 +266,7 @@ AC_DEFUN([ZFS_AC_RPM], [ RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(DEBUG_KMEM_TRACKING_ZFS) 1"' RPM_DEFINE_COMMON=${RPM_DEFINE_COMMON}' --define "$(ASAN_ZFS) 1"' - RPM_DEFINE_UTIL=' --define "_initconfdir $(DEFAULT_INITCONF_DIR)"' + RPM_DEFINE_UTIL=' --define "_initconfdir $(initconfdir)"' dnl # Make the next three RPM_DEFINE_UTIL additions conditional, since dnl # their values may not be set when running: @@ -469,13 +469,13 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ AC_MSG_CHECKING([default init directory]) case "$VENDOR" in - freebsd) DEFAULT_INIT_DIR=$sysconfdir/rc.d ;; - *) DEFAULT_INIT_DIR=$sysconfdir/init.d;; + freebsd) initdir=$sysconfdir/rc.d ;; + *) initdir=$sysconfdir/init.d;; esac - AC_MSG_RESULT([$DEFAULT_INIT_DIR]) - AC_SUBST(DEFAULT_INIT_DIR) + AC_MSG_RESULT([$initdir]) + AC_SUBST(initdir) - AC_MSG_CHECKING([default init script type]) + AC_MSG_CHECKING([default init script type and shell]) case "$VENDOR" in toss) DEFAULT_INIT_SCRIPT=redhat ;; redhat) DEFAULT_INIT_SCRIPT=redhat ;; @@ -491,24 +491,44 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ freebsd) DEFAULT_INIT_SCRIPT=freebsd;; *) DEFAULT_INIT_SCRIPT=lsb ;; esac - AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT]) + + # On gentoo, it's possible that OpenRC isn't installed. Check if + # /sbin/openrc-run exists, and if not, fall back to generic defaults. + + DEFAULT_INIT_SHELL="/bin/sh" + AS_IF([test "$DEFAULT_INIT_SCRIPT" = "openrc"], [ + AS_IF([test -x "/sbin/openrc-run"], + [DEFAULT_INIT_SHELL="/sbin/openrc-run"], + [DEFAULT_INIT_SCRIPT=lsb]) + ]) + + AC_MSG_RESULT([$DEFAULT_INIT_SCRIPT:$DEFAULT_INIT_SHELL]) AC_SUBST(DEFAULT_INIT_SCRIPT) + AC_SUBST(DEFAULT_INIT_SHELL) + + AC_MSG_CHECKING([default nfs server init script]) + AS_IF([test "$VENDOR" = "debian"], + [DEFAULT_INIT_NFS_SERVER="nfs-kernel-server"], + [DEFAULT_INIT_NFS_SERVER="nfs"] + ) + AC_MSG_RESULT([$DEFAULT_INIT_NFS_SERVER]) + AC_SUBST(DEFAULT_INIT_NFS_SERVER) AC_MSG_CHECKING([default init config directory]) case "$VENDOR" in - alpine) DEFAULT_INITCONF_DIR=/etc/conf.d ;; - gentoo) DEFAULT_INITCONF_DIR=/etc/conf.d ;; - toss) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; - redhat) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; - fedora) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; - sles) DEFAULT_INITCONF_DIR=/etc/sysconfig ;; - ubuntu) DEFAULT_INITCONF_DIR=/etc/default ;; - debian) DEFAULT_INITCONF_DIR=/etc/default ;; - freebsd) DEFAULT_INITCONF_DIR=$sysconfdir/rc.conf.d;; - *) DEFAULT_INITCONF_DIR=/etc/default ;; + alpine) initconfdir=/etc/conf.d ;; + gentoo) initconfdir=/etc/conf.d ;; + toss) initconfdir=/etc/sysconfig ;; + redhat) initconfdir=/etc/sysconfig ;; + fedora) initconfdir=/etc/sysconfig ;; + sles) initconfdir=/etc/sysconfig ;; + ubuntu) initconfdir=/etc/default ;; + debian) initconfdir=/etc/default ;; + freebsd) initconfdir=$sysconfdir/rc.conf.d;; + *) initconfdir=/etc/default ;; esac - AC_MSG_RESULT([$DEFAULT_INITCONF_DIR]) - AC_SUBST(DEFAULT_INITCONF_DIR) + AC_MSG_RESULT([$initconfdir]) + AC_SUBST(initconfdir) AC_MSG_CHECKING([whether initramfs-tools is available]) if test -d /usr/share/initramfs-tools ; then |