summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-03-26 15:26:46 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-03-27 15:23:01 +0200
commit6805810d314e2b4ecb8ff14e04779d8f0ad2b4f8 (patch)
tree180d139f129e5715de118ee8dc1748c668138261
parent619c1b265564ba2aac50004dec9761df567c69b3 (diff)
downloadautomake-6805810d314e2b4ecb8ff14e04779d8f0ad2b4f8.tar.gz
tests: workaround for automatic linker determination and conditionals
See automake bug#11089. Automake is not very smart in automatically determining the command to be used to link a program whose source files' languages are conditionally defined. For example, an input like: if HAVE_CXX foo_SOURCES = more.c++ else foo_SOURCES = less.c endif will cause the build rules for 'foo' to *unconditionally* use the C++ compiler for linking, even when the 'HAVE_CXX' conditional evaluates to false (which might mean that no C++ compiler is available). This behaviour is not really correct, but it's easy enough to work around, and it's only relevant for fringe use cases (at best). So let's just test that the workaround really works. * tests/link_cond.test: New test. * tests/list-of-tests.mk: Add it. * THANKS: Update. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rw-r--r--THANKS1
-rwxr-xr-xtests/link_cond.test90
-rw-r--r--tests/list-of-tests.mk1
3 files changed, 92 insertions, 0 deletions
diff --git a/THANKS b/THANKS
index 455cc6279..702c97bda 100644
--- a/THANKS
+++ b/THANKS
@@ -149,6 +149,7 @@ James Youngman jay@gnu.org
Jan Engelhardt jengelh@medozas.de
Janos Farkas chexum@shadow.banki.hu
Jared Davis abiword@aiksaurus.com
+Jason DeVinney jasondevinney@gmail.com
Jason Duell jcduell@lbl.gov
Jason Molenda crash@cygnus.co.jp
Javier Jardón jjardon@gnome.org
diff --git a/tests/link_cond.test b/tests/link_cond.test
new file mode 100755
index 000000000..0d61865ac
--- /dev/null
+++ b/tests/link_cond.test
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that automatic determination of the linker works well with
+# conditional use of languages in a single program.
+# This currently doesn't truly work, but we have an easy workaround
+# at least, that is tested here.
+# See automake bug#11089.
+
+required='cc c++'
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_CONDITIONAL([HAVE_CXX], [test $have_cxx = yes])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+if HAVE_CXX
+foo_SOURCES = more.c++
+else
+foo_SOURCES = less.c
+endif
+## FIXME: ideally, this workaround shouldn't be needed.
+if HAVE_CXX
+foo_LINK = $(CXXLINK)
+else
+foo_LINK = $(LINK)
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+rm -f *.c++
+cat > less.c <<'END'
+/* Valid C but deliberately invalid C++ */
+main ()
+{
+ int new = 0;
+ return new;
+}
+END
+
+./configure have_cxx=no
+CXX=false $MAKE -e
+
+# Sanity check.
+rm -f foo foo.exe
+CC=false $MAKE -e && Exit 99
+
+$MAKE distclean
+
+rm -f *.c
+cat > more.c++ <<'END'
+/* Valid C++ but deliberately invalid C */
+using namespace std;
+int main (void)
+{
+ return 0;
+}
+END
+
+./configure have_cxx=yes
+CC=false $MAKE -e
+
+# Sanity check.
+rm -f foo foo.exe
+CXX=false $MAKE -e && Exit 99
+
+:
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index 819cd06de..2548174df 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -553,6 +553,7 @@ libtoo11.test \
license.test \
license2.test \
link_c_cxx.test \
+link_cond.test \
link_dist.test \
link_f90_only.test \
link_fc.test \