Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / target-cflags.test
1 #! /bin/sh
2 # Copyright (C) 2000, 2001, 2002, 2004, 2010 Free Software Foundation,
3 # Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Test to make sure target specific CFLAGS work
19 # Assar Westerlund <assar@sics.se>
20
21 required=gcc
22 . ./defs || Exit 1
23
24 cat > configure.in << 'END'
25 AC_INIT(foo.c)
26 AM_INIT_AUTOMAKE(target-cflags,0.0)
27 AC_PROG_CC
28 AM_PROG_CC_C_O
29 AC_OUTPUT(Makefile)
30 END
31
32 cat > Makefile.am << 'END'
33 AUTOMAKE_OPTIONS = no-dependencies
34
35 bin_PROGRAMS = foo bar
36 foo_CFLAGS   = -DFOO
37 END
38
39 cat > foo.c << 'END'
40 #include <stdio.h>
41 #ifdef FOO
42 int main(void) {
43   return 0;
44 }
45 #endif
46 END
47
48 cat > bar.c << 'END'
49 #ifndef FOO
50 int main(void)
51 {
52   return 0;
53 }
54 #endif
55 END
56
57 set -e
58
59 $ACLOCAL
60 $AUTOCONF
61 $AUTOMAKE -a
62 mkdir build
63
64 cd build
65 ../configure
66 $MAKE
67 ./foo
68 ./bar
69 cd ..
70
71 ./configure
72 $MAKE
73 ./foo
74 ./bar