tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / ltcond2.sh
blob49b14d8e922392e1bf194932066653eef2906619
1 #! /bin/sh
2 # Copyright (C) 2003-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test for bug in conditionals.
19 required='cc native libtoolize'
20 . ./defs || exit 1
22 cat >> configure.ac << 'END'
23 AC_PROG_CC
24 AM_PROG_AR
25 AC_PROG_LIBTOOL
26 AC_SUBST([HELLO_SYSTEM], [hello-generic.lo])
27 AM_CONDITIONAL([LINUX], [true])
28 AC_OUTPUT
29 END
31 cat > Makefile.am << 'END'
32 lib_LTLIBRARIES = libhello.la
33 libhello_la_SOURCES = hello-common.c
34 EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
35 libhello_la_LIBADD = $(HELLO_SYSTEM)
36 libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
38 lib_LTLIBRARIES += libhello2.la
39 libhello2_la_SOURCES = hello-common.c
40 if LINUX
41 libhello2_la_SOURCES += hello-linux.c
42 else
43 libhello2_la_SOURCES += hello-generic.c
44 endif
46 bin_PROGRAMS = hello hello2
47 hello_SOURCES = main.c
48 hello_LDADD = libhello.la
49 hello2_SOURCES = main.c
50 hello2_LDADD = libhello2.la
52 check-local:
53 ./hello$(EXEEXT) | grep hello-generic
54 ./hello2$(EXEEXT) | grep hello-linux
55 : > check-ok
56 END
58 cat > hello-linux.c <<'END'
59 const char* str (void)
61 return "hello-linux";
63 END
65 cat > hello-generic.c <<'END'
66 const char* str (void)
68 return "hello-generic";
70 END
72 cat > hello-common.c <<'END'
73 #include <stdio.h>
74 const char* str (void);
75 void print (void)
77 puts (str ());
79 END
81 cat > main.c <<'END'
82 int main (void)
84 print();
85 return 0;
87 END
89 libtoolize
90 $ACLOCAL
91 $AUTOCONF
92 $AUTOMAKE --add-missing
93 ./configure
94 $MAKE check
95 test -f check-ok