]> git.draconx.ca Git - dxcommon.git/blobdiff - tests/scripts.at
fix-ltdl: Fix LIBOBJ mangling to work with automake-1.16.
[dxcommon.git] / tests / scripts.at
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