1 dnl Copyright © 2012, 2021, 2023-2024 Nick Bowler
3 dnl Definitions to help maintain compatibility with multiple Automake versions.
5 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
6 dnl This is free software: you are free to do what the fuck you want to.
7 dnl There is NO WARRANTY, to the extent permitted by law.
11 dnl Provides definitions to help maintain compatibility with older versions of
12 dnl Automake. Currently, this means:
14 dnl - Automake 1.15 includes an install-sh that depends on a "better" shell
15 dnl environment. However, even if such a shell is available and found by
16 dnl configure, the script includes #!/bin/sh so it won't work if /bin/sh
17 dnl is deficient. This problem is worked around by patching MKDIR_P
18 dnl and INSTALL to include $SHELL.
20 dnl - AM_V and AM_DEFAULT_V (new in Automake 1.12) are defined and AC_SUBSTed
21 dnl if Automake did not already, in a manner compatible with silent-rules
22 dnl support from previous versions.
24 dnl - A make variable DX_ALIGN_V is defined which contain printf alignment
25 dnl flags for silent-rules output, since the alignment changed between
26 dnl Automake 1.11 and 1.12. It is intended to be used like this:
28 dnl MYGEN_V = $(MYGEN_V@AM_V@)
29 dnl MYGEN_V_ = $(MYGEN_V_@AM_DEFAULT_V)
30 dnl MYGEN_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'MYGEN ' $@
32 dnl The spacing after MYGEN should be defined so that the silent-rules
33 dnl alignment is correct for the latest version of Automake if DX_ALIGN_V
34 dnl is empty (that way, this definition provides only backwards
35 dnl compatibility). However, it is irrelevant when DX_ALIGN_V is defined
36 dnl by this macro, as the spacing will always be correct. This feature
37 dnl maintains alignment by truncating the argument, so it will only work
38 dnl properly if your string can actually be aligned in all versions of
39 dnl Automake being targeted (this means you are limited to 6 characters
40 dnl in Automake 1.11).
42 AC_DEFUN_ONCE([DX_AUTOMAKE_COMPAT],
43 [AC_REQUIRE([DX_INIT])dnl
44 AC_REQUIRE([_DX_AUTOMAKE_COMPAT_PATCH_CC])dnl
45 AC_REQUIRE([_DX_AUTOMAKE_COMPAT_PATCH_AR])dnl
46 AC_CONFIG_COMMANDS_PRE([# Patch install-sh references to include $SHELL
47 AS_CASE([$MKDIR_P], ["$ac_install_sh"*], [MKDIR_P="$SHELL $MKDIR_P"])
48 AS_CASE([$INSTALL], ["$ac_install_sh"*], [INSTALL="$SHELL $INSTALL"])
50 # Substitute AM_V/AM_DEFAULT_V for compatibility with <automake-1.12
51 AS_VAR_SET_IF([AM_V], [], [AC_SUBST([AM_V], ['$(V)'])])
52 AS_VAR_SET_IF([AM_DEFAULT_V], [],
53 [AC_SUBST([AM_DEFAULT_V], ['$(AM_DEFAULT_VERBOSITY)'])])])dnl
55 # This will only work if there is a Makefile.in generated at the top srcdir.
56 AC_CACHE_CHECK([for alignment of silent-rules output], [dx_cv_align_v], [dnl
57 cat >conftest.sed <<'EOF'
59 s/@<:@^"@:>@*" \(GEN *\).*/\1/
64 if sed -nf conftest.sed "$srcdir/Makefile.in" >conftest.out 2>/dev/null; then
65 read dx_genline <conftest.out
66 dx_cv_align_v=`expr "$dx_genline" : '.*'`
67 test $dx_cv_align_v -eq 0 && dx_cv_align_v=unknown
69 : "${dx_cv_align_v:=unknown}"
73 AS_IF([test x"$dx_cv_align_v" != x"unknown"],
74 [AC_SUBST([DX_ALIGN_V], [-$dx_cv_align_v.$dx_cv_align_v])])
76 AC_CACHE_CHECK([for depfiles generation method], [dx_cv_am_depfiles],
77 [AS_IF([grep '^am--depfiles:' "$srcdir/Makefile.in" >/dev/null ||
78 grep '[[$]](am__maybe_remake_depfiles)' "$srcdir/Makefile.in" >/dev/null],
79 [dx_cv_am_depfiles='make am--depfiles'],
80 [dx_cv_am_depfiles='config.status'])])
81 AS_CASE([$dx_cv_am_depfiles],
82 ['make am--depfiles'], [dx_include_marker=' @%:@ am--include-marker'],
83 [dx_include_marker=''])
84 AC_SUBST([dx_depfiles_target], [am--depfiles])
85 AC_SUBST([dx_include_marker])
86 AM_SUBST_NOTMAKE([dx_depfiles_target])
87 AM_SUBST_NOTMAKE([dx_include_marker])])
89 AC_DEFUN_ONCE([_DX_AUTOMAKE_COMPAT_PATCH_CC],
90 [AC_BEFORE([$0], [_AM_PROG_CC_C_O])dnl
91 DX_PATCH_MACRO([_AM_PROG_CC_C_O],
92 ["[$]am_aux_dir/compile],
93 ["$SHELL $am_aux_dir/compile])])
95 AC_DEFUN_ONCE([_DX_AUTOMAKE_COMPAT_PATCH_AR],
96 [AC_BEFORE([$0], [AM_PROG_AR])dnl
97 DX_PATCH_MACRO([AM_PROG_AR],
98 ["[$]am_aux_dir/ar-lib],
99 ["$SHELL $am_aux_dir/ar-lib])])