tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / link_cond.sh
1 #! /bin/sh
2 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Test that automatic determination of the linker works well with
18 # conditional use of languages in a single program.
19 # This currently doesn't truly work, but we have an easy workaround
20 # at least, that is tested here.
21 # See automake bug#11089.
22
23 required='cc c++'
24 . test-init.sh
25
26 cat >> configure.ac << 'END'
27 AC_PROG_CC
28 AC_PROG_CXX
29 AM_CONDITIONAL([HAVE_CXX], [test $have_cxx = yes])
30 AC_OUTPUT
31 END
32
33 cat > Makefile.am << 'END'
34 bin_PROGRAMS = foo
35 if HAVE_CXX
36 foo_SOURCES = more.c++
37 else
38 foo_SOURCES = less.c
39 endif
40 ## FIXME: ideally, this workaround shouldn't be needed.
41 if HAVE_CXX
42 foo_LINK = $(CXXLINK)
43 else
44 foo_LINK = $(LINK)
45 endif
46 END
47
48 $ACLOCAL
49 $AUTOMAKE
50 $AUTOCONF
51
52 rm -f *.c++
53 cat > less.c <<'END'
54 /* Valid C but deliberately invalid C++ */
55 main ()
56 {
57   int new = 0;
58   return new;
59 }
60 END
61
62 ./configure have_cxx=no
63 run_make CXX=false
64
65 # Sanity check.
66 rm -f foo foo.exe
67 run_make CC=false && fatal_ '"make CC=false" succeeded unexpectedly'
68
69 $MAKE distclean
70
71 rm -f *.c
72 cat > more.c++ <<'END'
73 /* Valid C++ but deliberately invalid C */
74 using namespace std;
75 int main (void)
76 {
77   return 0;
78 }
79 END
80
81 ./configure have_cxx=yes
82 run_make CC=false
83
84 # Sanity check.
85 rm -f foo foo.exe
86 run_make CXX=false && fatal_ '"make CXX=false" succeeded unexpectedly'
87
88 :