From: Nick Bowler Date: Sat, 26 Feb 2022 22:55:30 +0000 (-0500) Subject: fix-ltdl: Fix LIBOBJ mangling to work with automake-1.16. X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/commitdiff_plain/8d922a2f63801c78bfebc41612cb57839f5367b8 fix-ltdl: Fix LIBOBJ mangling to work with automake-1.16. 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. --- diff --git a/scripts/fix-ltdl.pl b/scripts/fix-ltdl.pl index cfd0545..bd026c8 100755 --- a/scripts/fix-ltdl.pl +++ b/scripts/fix-ltdl.pl @@ -61,9 +61,9 @@ sub handle_libobj { die if (!defined $am_dir_prefix); print <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 diff --git a/tests/scripts.at b/tests/scripts.at index a546b61..b49a94d 100644 --- a/tests/scripts.at +++ b/tests/scripts.at @@ -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 +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.16 1.17 1.18 1.19], + [AS_VERSION_COMPARE(["$amver"], [1.16], [continue])]) +TEST_LTDL_LIBOBJ_MANGLING + +AT_CLEANUP diff --git a/testsuite.at b/testsuite.at index 2879f38..a74969f 100644 --- a/testsuite.at +++ b/testsuite.at @@ -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