xref: /freebsd/sys/contrib/openzfs/config/Substfiles.am (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \
22	-e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \
23	-e 's|@PYTHON[@]|$(PYTHON)|g' \
24	-e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \
25	-e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' \
26	-e 's|@VERSION[@]|$(VERSION)|g'
27
28define SUBST
29$(1) : $(2)$(1).in Makefile;
30	$$(AM_V_GEN)set -e; \
31	$$(MKDIR_P) $$(@D); \
32	$$(RM) $$@~; \
33	$$(SED) $$(subst_sed_cmd) $$< >$$@~; \
34	if grep -E '@[a-zA-Z0-9_]+@' $$@~ >&2; then \
35		echo "Undefined substitution" >&2; \
36		exit 1; \
37	fi; \
38	[ -x $$< ] && chmod +x $$@~; \
39	mv -f $$@~ $$@
40endef
41
42SUBSTFILES =
43CLEANFILES += $(SUBSTFILES)
44dist_noinst_DATA += $(SUBSTFILES:=.in)
45
46$(call SUBST,%,)
47