mirror_zfs/config/Substfiles.am
Benda Xu 162cc80b81
etc/init.d: decide which variant to use at build time.
Let Debian use the sysv-rc variant of the script, even when OpenRC is
installed. Unlike on Gentoo, OpenRC on Debian consumes both the
sysv-rc scripts and OpenRC ones. ZFS initscripts on Debian should be
the sysv-rc version to provide most compatibility and to integrate
with the rest of initscripts for dependency tracking.

Restrict the substitution in the Makefile to the dedicated list.

This construct is inspired by Mo Zhou's detection of the execution
shell and follows the strategy of Peter in 6ef28c526b.

As of 2024, the initscripts are mostly relevant on Debian, Gentoo and
their derivatives.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Benda Xu <orv@debian.org>
Issue #8063
Issue #8204
Issue #8359
Closes #15977
2024-04-08 16:52:24 -07:00

48 lines
1.5 KiB
Plaintext

subst_sed_cmd = \
-e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@bindir[@]|$(bindir)|g' \
-e 's|@datadir[@]|$(datadir)|g' \
-e 's|@initconfdir[@]|$(initconfdir)|g' \
-e 's|@initdir[@]|$(initdir)|g' \
-e 's|@mounthelperdir[@]|$(mounthelperdir)|g' \
-e 's|@pammoduledir[@]|$(pammoduledir)|g' \
-e 's|@runstatedir[@]|$(runstatedir)|g' \
-e 's|@sbindir[@]|$(sbindir)|g' \
-e 's|@sysconfdir[@]|$(sysconfdir)|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|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \
-e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \
-e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \
-e 's|@IS_SYSV_RC[@]|$(IS_SYSV_RC)|g' \
-e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \
-e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \
-e 's|@PYTHON[@]|$(PYTHON)|g' \
-e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \
-e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' \
-e 's|@VERSION[@]|$(VERSION)|g'
define SUBST
$(1) : $(2)$(1).in Makefile;
$$(AM_V_GEN)set -e; \
$$(MKDIR_P) $$(@D); \
$$(RM) $$@~; \
$$(SED) $$(subst_sed_cmd) $$< >$$@~; \
if grep -E '@[a-zA-Z0-9_]+@' $$@~ >&2; then \
echo "Undefined substitution" >&2; \
exit 1; \
fi; \
[ -x $$< ] && chmod +x $$@~; \
mv -f $$@~ $$@
endef
SUBSTFILES =
CLEANFILES += $(SUBSTFILES)
dist_noinst_DATA += $(SUBSTFILES:=.in)
$(call SUBST,%,)