tests: avoid a spurious failure on MacOS X 10.6.8
[platform/upstream/automake.git] / t / ltcond2.sh
1 #! /bin/sh
2 # Copyright (C) 2003-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 for bug in conditionals.
18
19 required='cc native libtoolize'
20 . test-init.sh
21
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
30
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)
37
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
45
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
51
52 check-local:
53         ./hello$(EXEEXT) | grep hello-generic
54         ./hello2$(EXEEXT) | grep hello-linux
55         : > check-ok
56 END
57
58 cat > hello-linux.c <<'END'
59 const char* str = "hello-linux";
60 END
61
62 cat > hello-generic.c <<'END'
63 const char* str = "hello-generic";
64 END
65
66 cat > hello-common.c <<'END'
67 #include <stdio.h>
68 extern const char* str;
69 void print (void)
70 {
71   puts (str);
72 }
73 END
74
75 cat > main.c <<'END'
76 int main (void)
77 {
78   print();
79   return 0;
80 }
81 END
82
83 libtoolize
84 $ACLOCAL
85 $AUTOCONF
86 $AUTOMAKE --add-missing
87 ./configure
88 $MAKE check
89 test -f check-ok
90
91 :