test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / lflags.sh
blob9e832c2e64e92266df634db9e25e1ee8dd3530d4
1 #! /bin/sh
2 # Copyright (C) 2010-2024 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check that $(LFLAGS) takes precedence over both $(AM_LFLAGS) and
18 # $(foo_LFLAGS).
19 # Please keep this in sync with the sister tests:
20 # - lflags-cxx.sh
21 # - yflags.sh
22 # - yflags-cxx.sh
24 required=cc
25 . test-init.sh
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
34 cat >> configure.ac <<'END'
35 AC_SUBST([CC], [false])
36 # Simulate presence of Lex using our fake-lex script.
37 AC_SUBST([LEX], ['$(abs_top_srcdir)'/fake-lex])
38 AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
39 AC_SUBST([LEXLIB], [''])
40 AC_OUTPUT
41 END
43 cat > Makefile.am <<'END'
44 AUTOMAKE_OPTIONS = no-dependencies
45 bin_PROGRAMS = foo bar
46 foo_SOURCES = main.c foo.l
47 bar_SOURCES = main.c bar.l
48 AM_LFLAGS = __am_flags__
49 bar_LFLAGS = __bar_flags__
50 END
52 $ACLOCAL
53 $AUTOMAKE -a
55 grep '\$(LFLAGS).*\$(bar_LFLAGS)' Makefile.in && exit 1
56 grep '\$(LFLAGS).*\$(AM_LFLAGS)' Makefile.in && exit 1
58 : > foo.l
59 : > bar.l
61 $AUTOCONF
62 ./configure
63 run_make LFLAGS=__user_flags__ foo.c bar-bar.c
65 cat foo.c
66 cat bar-bar.c
68 grep '__am_flags__.*__user_flags__' foo.c
69 grep '__bar_flags__.*__user_flags__' bar-bar.c