xref: /freebsd/sys/contrib/openzfs/config/Substfiles.am (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1subst_sed_cmd = \
2	-e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
3	-e 's|@bindir[@]|$(bindir)|g' \
4	-e 's|@datadir[@]|$(datadir)|g' \
5	-e 's|@initconfdir[@]|$(initconfdir)|g' \
6	-e 's|@initdir[@]|$(initdir)|g' \
7	-e 's|@mounthelperdir[@]|$(mounthelperdir)|g' \
8	-e 's|@pammoduledir[@]|$(pammoduledir)|g' \
9	-e 's|@runstatedir[@]|$(runstatedir)|g' \
10	-e 's|@sbindir[@]|$(sbindir)|g' \
11	-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
12	-e 's|@systemdgeneratordir[@]|$(systemdgeneratordir)|g' \
13	-e 's|@systemdunitdir[@]|$(systemdunitdir)|g' \
14	-e 's|@udevdir[@]|$(udevdir)|g' \
15	-e 's|@udevruledir[@]|$(udevruledir)|g' \
16	-e 's|@zfsexecdir[@]|$(zfsexecdir)|g' \
17	\
18	-e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \
19	-e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \
20	-e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \
21	-e 's|@IS_SYSV_RC[@]|$(IS_SYSV_RC)|g' \
22	-e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \
23	-e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \
24	-e 's|@PYTHON[@]|$(PYTHON)|g' \
25	-e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \
26	-e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' \
27	-e 's|@VERSION[@]|$(VERSION)|g'
28
29define SUBST
30$(1) : $(2)$(1).in Makefile;
31	$$(AM_V_GEN)set -e; \
32	$$(MKDIR_P) $$(@D); \
33	$$(RM) $$@~; \
34	$$(SED) $$(subst_sed_cmd) $$< >$$@~; \
35	if grep -E '@[a-zA-Z0-9_]+@' $$@~ >&2; then \
36		echo "Undefined substitution" >&2; \
37		exit 1; \
38	fi; \
39	[ -x $$< ] && chmod +x $$@~; \
40	mv -f $$@~ $$@
41endef
42
43SUBSTFILES =
44CLEANFILES += $(SUBSTFILES)
45dist_noinst_DATA += $(SUBSTFILES:=.in)
46
47$(SUBSTFILES): $(call SUBST,%,)
48