]> git.draconx.ca Git - dxcommon.git/commitdiff
DX_AUTOMAKE_COMPAT: Fix install-sh with newer Automake.
authorNick Bowler <nbowler@draconx.ca>
Wed, 6 Dec 2023 01:46:26 +0000 (20:46 -0500)
committerNick Bowler <nbowler@draconx.ca>
Wed, 6 Dec 2023 02:07:10 +0000 (21:07 -0500)
Current versions of Automake's install-sh depends on substitutions like
${var:-foo}, which are not supported by ULTRIX 4.5 /bin/sh.

Now, ksh does support these and configure does find and use this shell
on ULTRIX, but install-sh starts with #!/bin/sh so when it is executed
directly, it is run with /bin/sh instead of the shell we want.

We can work around the problem by patching up the MKDIR_P and INSTALL
assignments at configure time to include the known-good shell, which
seems to work well.

m4/am-compat.m4

index ec148199f2117d414a8644930d13548ad4394e4c..f8592ab74b5db82a22be26e6f3b7b4d9a60f0092 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2012, 2021 Nick Bowler
+dnl Copyright © 2012, 2021, 2023 Nick Bowler
 dnl
 dnl Definitions to help maintain compatibility with multiple Automake versions.
 dnl
@@ -11,6 +11,12 @@ dnl
 dnl Provides definitions to help maintain compatibility with older versions of
 dnl Automake.  Currently, this means:
 dnl
+dnl  - Automake 1.15 includes an install-sh that depends on a "better" shell
+dnl    environment.  However, even if such a shell is available and found by
+dnl    configure, the script includes #!/bin/sh so it won't work if /bin/sh
+dnl    is deficient.  This problem is worked around by patching MKDIR_P
+dnl    and INSTALL to include $SHELL.
+dnl
 dnl  - AM_V and AM_DEFAULT_V (new in Automake 1.12) are defined and AC_SUBSTed
 dnl    if Automake did not already, in a manner compatible with silent-rules
 dnl    support from previous versions.
@@ -33,27 +39,30 @@ dnl    properly if your string can actually be aligned in all versions of
 dnl    Automake being targeted (this means you are limited to 6 characters
 dnl    in Automake 1.11).
 
-AC_DEFUN_ONCE([DX_AUTOMAKE_COMPAT], [dnl
-AC_REQUIRE([DX_INIT])
+AC_DEFUN_ONCE([DX_AUTOMAKE_COMPAT],
+[AC_REQUIRE([DX_INIT])dnl
+AC_CONFIG_COMMANDS_PRE([# Patch install-sh references to include $SHELL
+AS_CASE([$MKDIR_P], ["$ac_install_sh"*], [MKDIR_P="$SHELL $MKDIR_P"])
+AS_CASE([$INSTALL], ["$ac_install_sh"*], [INSTALL="$SHELL $INSTALL"])
 
-AC_CONFIG_COMMANDS_PRE([dnl
-       AS_VAR_SET_IF([AM_V], [], [AC_SUBST([AM_V], ['$(V)'])])
-       AS_VAR_SET_IF([AM_DEFAULT_V], [],
-               [AC_SUBST([AM_DEFAULT_V], ['$(AM_DEFAULT_VERBOSITY)'])])])
+# Substitute AM_V/AM_DEFAULT_V for compatibility with <automake-1.12
+AS_VAR_SET_IF([AM_V], [], [AC_SUBST([AM_V], ['$(V)'])])
+AS_VAR_SET_IF([AM_DEFAULT_V], [],
+  [AC_SUBST([AM_DEFAULT_V], ['$(AM_DEFAULT_VERBOSITY)'])])])dnl
 
 # This will only work if there is a Makefile.in generated at the top srcdir.
 AC_CACHE_CHECK([for alignment of silent-rules output], [dx_cv_align_v], [dnl
 cat >conftest.sed <<'EOF'
 /^am__v_GEN_0 *=/{
-       s/@<:@^"@:>@*"  \(GEN *\).*/\1/
-       s/ /x/g
-       p
+  s/@<:@^"@:>@*"  \(GEN *\).*/\1/
+  s/ /x/g
+  p
 }
 EOF
 if sed -nf conftest.sed "$srcdir/Makefile.in" >conftest.out 2>/dev/null; then
-       read dx_genline <conftest.out
-       dx_cv_align_v=`expr "$dx_genline" : '.*'`
-       test $dx_cv_align_v -eq 0 && dx_cv_align_v=unknown
+  read dx_genline <conftest.out
+  dx_cv_align_v=`expr "$dx_genline" : '.*'`
+  test $dx_cv_align_v -eq 0 && dx_cv_align_v=unknown
 fi
 : "${dx_cv_align_v:=unknown}"
 rm -f conftest*