tests: expose automake bug#14560
[platform/upstream/automake.git] / t / target-cflags.sh
1 #! /bin/sh
2 # Copyright (C) 2000-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 to make sure target specific CFLAGS work
18 # Assar Westerlund <assar@sics.se>
19
20 required=cc
21 . test-init.sh
22
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AM_PROG_CC_C_O
26 AC_OUTPUT
27 END
28
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS = no-dependencies
31
32 bin_PROGRAMS = foo bar
33 foo_CFLAGS   = -DFOO
34 END
35
36 cat > foo.c << 'END'
37 #include <stdio.h>
38 #ifdef FOO
39 int main(void)
40 {
41   return 0;
42 }
43 #endif
44 END
45
46 cat > bar.c << 'END'
47 #ifndef FOO
48 int main(void)
49 {
50   return 0;
51 }
52 #endif
53 END
54
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE -a
58 mkdir build
59
60 cd build
61 ../configure
62 $MAKE
63 if ! cross_compiling; then
64   ./foo
65   ./bar
66 fi
67 cd ..
68
69 ./configure
70 $MAKE
71 if ! cross_compiling; then
72   ./foo
73   ./bar
74 fi
75
76 :