]> git.draconx.ca Git - dxcommon.git/commitdiff
fix-ltdl: Fix LIBOBJ mangling to work with automake-1.16.
authorNick Bowler <nbowler@draconx.ca>
Sat, 26 Feb 2022 22:55:30 +0000 (17:55 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 26 Feb 2022 23:03:44 +0000 (18:03 -0500)
Apparently automake 1.16 changed how object files in a subdirectory are
named when using subdir-objects.  As the generated rules to copy compiled
objects to the ltdl_LTLIBOBJ substituted names, these rules are now failing
on current automake.

Fix this by explicitly setting a _SHORTNAME for the dummy libobj library,
which explicitly sets the name to use and thus it will be consistent
between different Automake versions.

Add new test cases to verify this behaviour.

scripts/fix-ltdl.pl
tests/macros.at
tests/scripts.at
testsuite.at

index cfd05457aebbe7c7d0020e0169d7bc6553877c50..bd026c87f7416acb27668dea91157af36929fd70 100755 (executable)
@@ -61,9 +61,9 @@ sub handle_libobj {
        die if (!defined $am_dir_prefix);
        print <<EOF;
 ${am_dir_prefix}libobj_la_SOURCES += $distfile
-$ltdl_dir/$base.lo: $ltdl_dir/${am_dir_prefix}libobj_la-$base.lo
+$ltdl_dir/$base.lo: $ltdl_dir/lo-$base.lo
 \t\$(AM_V_at)-rm -f \$@
-\t\$(AM_V_at)(cd \$(\@D) && \$(LN_S) ${am_dir_prefix}libobj_la-\$(\@F) \$(\@F))
+\t\$(AM_V_at)cd \$(\@D) && \$(LN_S) lo-\$(\@F) \$(\@F)
 EOF
 
        return 0;
@@ -134,6 +134,7 @@ EXTRA_LTLIBRARIES += $ltdl_dir/libobj.la
 ${am_dir_prefix}libobj_la_SOURCES =
 ${am_dir_prefix}libobj_la_CPPFLAGS = \$(AM_CPPFLAGS) \$(LTDL_CPPFLAGS)
 ${am_dir_prefix}libobj_la_LINK = false
+${am_dir_prefix}libobj_la_SHORTNAME = lo
 EOF
        }
 
index e0681c4cca90735968e0401be455833c6b6ac24d..a5efc2388189ed98f2997e933374d518220433fe 100644 (file)
@@ -341,8 +341,7 @@ exit 1])
 AT_CLEANUP
 
 m4_define([TEST_SYMFILES_INIT],
-[echo : >compile
-TEST_CONFIGURE_AC([[AM_INIT_AUTOMAKE([foreign])
+[TEST_CONFIGURE_AC([[AM_INIT_AUTOMAKE([foreign])
 AM_PROG_CC_C_O
 AC_SUBST([GLSRC], [.])
 DX_AUTOMAKE_COMPAT
index a546b61a557240ae8b10a26065c8cee4a1a275aa..b49a94dad6b3cad48005af18100b200db0d4d4f4 100644 (file)
@@ -580,6 +580,10 @@ AT_CHECK([echo wat | $JOIN -v1 - /dev/null], [0],
 AT_CLEANUP
 
 m4_divert_push([PREPARE_TESTS])dnl
+test_fix_ltdl () {
+  $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
+  $PERL -f "$srcdir/scripts/fix-ltdl.pl" "$@"
+}
 test_fix_gnulib () {
   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
   $PERL -f "$srcdir/scripts/fix-gnulib.pl" "$@"
@@ -623,3 +627,92 @@ sed -n -e '/^## begin gnulib/,/^## end   gnulib/p' \
 [0], [expout])
 
 AT_CLEANUP
+
+dnl TEST_FIND_AUTOMAKE_VER([to-check], [test-action])
+dnl
+dnl For each whitespace-separated version token in to-check, check if we can
+dnl run the programs automake-VER and aclocal-VER.  The special token 'default'
+dnl also checks the unversioned automake and aclocal (or, if set in the
+dnl environment, $AUTOMAKE and $ACLOCAL).
+dnl
+dnl Then test-action is expanded such that shell variables $ac and $am refer to
+dnl the aclocal and automake programs, and $amver is the actual version
+dnl reported by --version.  The action should do nothing if the version is
+dnl acceptable, or "continue" if the version is unacceptable.
+dnl
+dnl If an acceptable version is found, the AUTOMAKE and ACLOCAL environment
+dnl variables are set accordingly.  Otherwise, the test group is skipped.
+m4_define([TEST_FIND_AUTOMAKE],
+[have_am=false
+for am in $1; do
+  AS_CASE([$am],
+    [default], [ac=${ACLOCAL-aclocal} am=${AUTOMAKE-automake}],
+    [ac=aclocal-$am; am=automake-$am])
+  amver=`$am --version | sed -n '1s/.* //p'`
+  acver=`$ac --version | sed -n '1s/.* //p'`
+  set x $amver $acver; shift; test x"$[]#" = x"2" || continue
+  test x"$amver" = x"$acver" || continue
+  $2
+  have_am=:; break
+done
+AT_CHECK([$have_am || exit 77])
+AUTOMAKE=$am; export AUTOMAKE
+ACLOCAL=$ac; export ACLOCAL
+AT_CHECK([$ACLOCAL --version && $AUTOMAKE --version], [0], [stdout])
+])
+
+m4_define([TEST_LTDL_LIBOBJ_MANGLING],
+[TEST_CONFIGURE_AC([[AM_INIT_AUTOMAKE([foreign subdir-objects])
+AC_PROG_CC
+LT_INIT
+AC_SUBST([ltdl_LTLIBOBJS], [libltdl/test.lo])
+AC_CONFIG_FILES([Makefile])
+]])
+
+mkdir libltdl
+AT_DATA([ltdl.mk.in], [[
+AM_CPPFLAGS += -DSTRING=\"helloworld\"
+
+noinst_LTLIBRARIES = libltdl/libltdl.la
+libltdl_libltdl_la_SOURCES = libltdl/ltdl.c
+libltdl_libltdl_la_LIBADD = $(ltdl_LTLIBOBJS)
+libltdl_libltdl_la_DEPENDENCIES = $(ltdl_LTLIBOBJS)
+
+EXTRA_DIST += libltdl/test.c
+]])
+AT_DATA([Makefile.am], [[AM_CPPFLAGS =
+include $(top_srcdir)/ltdl.mk
+AM_LIBTOOLFLAGS = --quiet
+bin_PROGRAMS = test
+test_SOURCES =
+test_LDADD = libltdl/libltdl.la
+all-local: ; @printf '%s\n' $(AM_CPPFLAGS)
+]])
+AT_DATA([libltdl/test.c], [[#include <stdio.h>
+int foo(void) { printf("%s\n", STRING); return 0; }
+]])
+AT_DATA([libltdl/ltdl.c], [[int foo(void); int main(void) { return foo(); }
+]])
+
+AT_CHECK([test_fix_ltdl -i ltdl.mk.in -o ltdl.mk])
+libtoolize; TEST_AUTORECONF
+TEST_CONFIGURE([--disable-shared])
+AT_CHECK([make -s && ./test], [0], [
+helloworld
+])])
+
+AT_SETUP([fix-ltdl.pl LIBOBJ mangling (<automake-1.16)])
+
+TEST_FIND_AUTOMAKE([default 1.10 1.11 1.12 1.13 1.14 1.15],
+  [AS_VERSION_COMPARE(["$amver"], [1.16], [], [continue], [continue])])
+TEST_LTDL_LIBOBJ_MANGLING
+
+AT_CLEANUP
+
+AT_SETUP([fix-ltdl.pl LIBOBJ mangling (>=automake-1.16)])
+
+TEST_FIND_AUTOMAKE([default 1.16 1.17 1.18 1.19],
+  [AS_VERSION_COMPARE(["$amver"], [1.16], [continue])])
+TEST_LTDL_LIBOBJ_MANGLING
+
+AT_CLEANUP
index 2879f38cfde75ee61a85cfb69603d05ca1f1a3d1..a74969ff659d81fecb6d27f7eb405a3a9413f0f4 100644 (file)
@@ -25,6 +25,7 @@ AC_OUTPUT
 cp "$srcdir/install-sh" \
    "$srcdir/depcomp" \
    "$srcdir/missing" \
+   "$srcdir/compile" \
    "$srcdir/config.sub" \
    .
 # Simplified config.guess script avoids some spurious testcase failures