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