tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / yacc-subdir.sh
blob6adb7d666558373ef2dcc7e4ebaf859f851e2bbc
1 #! /bin/sh
2 # Copyright (C) 2002-2018 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 # Test for subdir parsers.
19 required='cc yacc'
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_PROG_YACC
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 AUTOMAKE_OPTIONS = subdir-objects
31 bin_PROGRAMS = foo/foo
32 foo_foo_SOURCES = foo/parse.y
33 AM_YFLAGS = -d
35 .PHONY: obj
36 obj: foo/parse.$(OBJEXT)
38 .PHONY: test1 test2
39 test1: foo/parse.$(OBJEXT)
40 test -f foo/parse.c
41 test -f foo/parse.$(OBJEXT)
42 test2: foo/parse2.$(OBJEXT)
43 test -f foo/parse2.c
44 test -f foo/parse2.$(OBJEXT)
45 END
47 mkdir foo
49 cat > foo/parse.y << 'END'
51 int yylex () { return 0; }
52 void yyerror (char *s) {}
55 foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
56 END
58 $ACLOCAL
59 $AUTOCONF
60 $AUTOMAKE -a
62 mkdir sub
63 cd sub
65 ../configure
66 $MAKE test1
68 # Aside of the rest of this test, let's see if we can recover from
69 # parse.h removal.
70 test -f foo/parse.h
71 rm -f foo/parse.h
72 $MAKE foo/parse.h
73 test -f foo/parse.h
75 # Make sure foo/parse.h is not updated, unless when needed.
76 $sleep
77 touch ../foo/parse.y
78 $MAKE obj
79 is_newest ../foo/parse.y foo/parse.h
80 $sleep
81 sed 's/%%/%token TOKEN\n%%/g' ../foo/parse.y >../foo/parse.yt
82 mv -f ../foo/parse.yt ../foo/parse.y
83 $MAKE obj
84 is_newest foo/parse.h ../foo/parse.y
86 # Now, adds another parser to test ylwrap.
88 cd ..
90 # Sleep some to make sure timestamp of Makefile.am will change.
91 $sleep
93 cp foo/parse.y foo/parse2.y
94 cat >> Makefile.am << 'END'
95 EXTRA_foo_foo_SOURCES = foo/parse2.y
96 END
98 $AUTOMAKE -a
99 test -f ./ylwrap
101 cd sub
102 # Regenerate Makefile (automatic in GNU Make, but not in other Makes).
103 ./config.status
104 $MAKE test2