maint: run "make update-copyright"
[platform/upstream/automake.git] / tests / ltcond2.test
1 #! /bin/sh
2 # Copyright (C) 2003-2012 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 . ./defs || Exit 1
21
22 cat >> configure.in << '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 (void)
60 {
61   return "hello-linux";
62 }
63 END
64
65 cat > hello-generic.c <<'END'
66 const char* str (void)
67 {
68   return "hello-generic";
69 }
70 END
71
72 cat > hello-common.c <<'END'
73 #include <stdio.h>
74 const char* str (void);
75 void print (void)
76 {
77   puts (str ());
78 }
79 END
80
81 cat > main.c <<'END'
82 int main (void)
83 {
84   print();
85   return 0;
86 }
87 END
88
89 libtoolize
90 $ACLOCAL
91 $AUTOCONF
92 $AUTOMAKE --add-missing
93 ./configure
94 $MAKE check
95 test -f check-ok
96
97 :