Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / lflags2.test
1 #! /bin/sh
2 # Copyright (C) 2010 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 # Check that $(LFLAGS) takes precedence over both $(AM_LFLAGS) and
18 # $(foo_LFLAGS).
19 # Please keep this in sync with the sister tests lflags.test, yflags.test
20 # and yflags2.test
21
22 required=g++ # FIXME: any working C++ compiler should be OK
23 . ./defs || Exit 1
24
25 set -e
26
27 cat >fake-lex <<'END'
28 #!/bin/sh
29 echo '/*' "$*" '*/' >lex.yy.c
30 echo 'extern int dummy;' >> lex.yy.c
31 END
32 chmod a+x fake-lex
33
34 # Remove Lex from the environment, so that it won't interfere
35 # with `make -e' below.
36 unset LEX || :
37
38 cat >> configure.in <<'END'
39 AC_PROG_CXX
40 # Simulate presence of Lex using our fake-lex script.
41 AC_SUBST([LEX], ['$(abs_top_srcdir)'/fake-lex])
42 AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
43 AC_SUBST([LEXLIB], [''])
44 AC_OUTPUT
45 END
46
47 cat > Makefile.am <<'END'
48 bin_PROGRAMS = foo bar
49 foo_SOURCES = main.cc foo.ll
50 bar_SOURCES = main.cc bar.l++
51 AM_LFLAGS = __am_flags__
52 bar_LFLAGS = __bar_flags__
53 END
54
55 $ACLOCAL
56 $AUTOMAKE -a
57
58 grep '\$(LFLAGS).*\$(bar_LFLAGS)' Makefile.in && Exit 1
59 grep '\$(LFLAGS).*\$(AM_LFLAGS)' Makefile.in && Exit 1
60
61 echo 'int main(void) { return 0; }' > main.cc
62 : > foo.ll
63 : > bar.l++
64
65 $AUTOCONF
66 ./configure
67 env LFLAGS=__user_flags__ $MAKE -e
68
69 ls -l
70
71 cat foo.cc
72 grep '__am_flags__.*__user_flags__' foo.cc
73 cat bar-bar.c++
74 grep '__bar_flags__.*__user_flags__' bar-bar.c++
75
76 :