>>> "adl" == Alexandre Duret-Lutz <[EMAIL PROTECTED]> writes:
adl> Hi, >>> "Magnus" == Magnus Fromreide <[EMAIL PROTECTED]> writes: Magnus> In the rules from lex.am and yacc.am, if the item %OBJ% Magnus> or the variable LEX_OUTPUT_ROOT in lex.am contains a / Magnus> then the sed expression fails. adl> When does this happens? I've tried to make a test case which adl> use the following Makefile.am adl> AUTOMAKE_OPTIONS = subdir-objects adl> bin_PROGRAMS = foo adl> foo_SOURCES = foo/parse.y adl> but this raised another problem: the specific rule output to adl> build foo/parse.c does not supports VPATH builds. Here are some test cases with their fixes. Index: ChangeLog =================================================================== RCS file: /cvs/automake/automake/ChangeLog,v retrieving revision 1.1761 diff -u -r1.1761 ChangeLog --- ChangeLog 2002/02/14 14:25:53 1.1761 +++ ChangeLog 2002/02/14 18:10:21 @@ -1,5 +1,18 @@ 2002-02-14 Alexandre Duret-Lutz <[EMAIL PROTECTED]> + * automake.in (scan_one_autoconf_file): Declare + LEX_OUTPUT_ROOT and LEXLIB as configure variables when + AM_PROG_LEX or AC_PROG_LEX are seen. This allow to ... + * lib/am/lex.am: ... remove the LEX_OUTPUT_ROOT and LEXLIB + definition. Search %SOURCE% in $(srcdir). Use s||| instead + of s/// in the sed invocation, to support objects containing + slash. + * lib/am/yacc.am: Search %SOURCE% in $(srcdir). Use s||| too. + * tests/lex5.test, tests/yacc8.test: New files. + * tests/Makefile.am (TESTS): Add them. + +2002-02-14 Alexandre Duret-Lutz <[EMAIL PROTECTED]> + * Makefile.am (FETCHFILES): Add Automake/XFile.pm. (fetch): Fetch XFile.pm. Update the files in $(srcdir) instead of asking the maintainer to do it manually. Index: NEWS =================================================================== RCS file: /cvs/automake/automake/NEWS,v retrieving revision 1.171 diff -u -r1.171 NEWS --- NEWS 2002/01/28 01:09:29 1.171 +++ NEWS 2002/02/14 18:10:21 @@ -31,6 +31,7 @@ * aclocal and automake are also installed with the version number appended, and some of the install directory names have changed. This lets you have multiple versions installed simultaneously. +* Support for parsers and lexers in subdirectories. New in 1.5: * Support for `configure.ac'. Index: automake.in =================================================================== RCS file: /cvs/automake/automake/automake.in,v retrieving revision 1.1276 diff -u -r1.1276 automake.in --- automake.in 2002/02/01 20:40:48 1.1276 +++ automake.in 2002/02/14 18:10:22 @@ -4920,11 +4920,15 @@ if (/AM_PROG_LEX/) { $configure_vars{'LEX'} = $here; + $configure_vars{'LEX_OUTPUT_ROOT'} = $here; + $configure_vars{'LEXLIB'} = $here; $seen_prog_lex = $here; } if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/) { $configure_vars{'LEX'} = $here; + $configure_vars{'LEX_OUTPUT_ROOT'} = $here; + $configure_vars{'LEXLIB'} = $here; $seen_prog_lex = $here; file_warning ($here, "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'"); Index: lib/am/lex.am =================================================================== RCS file: /cvs/automake/automake/lib/am/lex.am,v retrieving revision 1.6 diff -u -r1.6 lex.am --- lib/am/lex.am 2001/12/14 16:25:37 1.6 +++ lib/am/lex.am 2002/02/14 18:10:22 @@ -16,18 +16,13 @@ ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -## FIXME: These two are to be removed once we trace Autoconf, since -## they are AC_SUBST'ed. -LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -LEXLIB = @LEXLIB@ - ?GENERIC?%EXT%%DERIVED-EXT%: ?!GENERIC?%OBJ%: %SOURCE% if %?MORE-THAN-ONE% - $(SHELL) $(YLWRAP) %SOURCE% $(LEX_OUTPUT_ROOT).c %OBJ% -- %COMPILE% + $(SHELL) $(YLWRAP) `test -f %SOURCE% || echo '$(srcdir)/'`%SOURCE% +$(LEX_OUTPUT_ROOT).c %OBJ% -- %COMPILE% else !%?MORE-THAN-ONE% - %COMPILE% %SOURCE% + %COMPILE% `test -f %SOURCE% || echo '$(srcdir)/'`%SOURCE% ## Edit out `#line' or `#' directives. - sed '/^#/ s/$(LEX_OUTPUT_ROOT)\.c/%OBJ%/' $(LEX_OUTPUT_ROOT).c >%OBJ% + sed '/^#/ s|$(LEX_OUTPUT_ROOT)\.c|%OBJ%|' $(LEX_OUTPUT_ROOT).c >%OBJ% rm -f $(LEX_OUTPUT_ROOT).c endif !%?MORE-THAN-ONE% Index: lib/am/yacc.am =================================================================== RCS file: /cvs/automake/automake/lib/am/yacc.am,v retrieving revision 1.11 diff -u -r1.11 yacc.am --- lib/am/yacc.am 2002/01/28 00:40:10 1.11 +++ lib/am/yacc.am 2002/02/14 18:10:22 @@ -19,11 +19,11 @@ ?GENERIC?%EXT%%DERIVED-EXT%: ?!GENERIC?%OBJ%: %SOURCE% if %?MORE-THAN-ONE% - $(SHELL) $(YLWRAP) %SOURCE% y.tab.c %OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE% + $(SHELL) $(YLWRAP) `test -f %SOURCE% || echo '$(srcdir)/'`%SOURCE% y.tab.c +%OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE% else !%?MORE-THAN-ONE% - %COMPILE% %SOURCE% + %COMPILE% `test -f %SOURCE% || echo '$(srcdir)/'`%SOURCE% ## Edit out `#line' or `#' directives. - sed '/^#/ s/y\.tab\.c/%OBJ%/' y.tab.c >%OBJ% + sed '/^#/ s|y\.tab\.c|%OBJ%|' y.tab.c >%OBJ% rm -f y.tab.c ## Edit out Bison multiple inclusion guards. It may be BISON_Y_TAB_H, ## or Y_TAB_H depending upon the version, that's why the regexp is Index: tests/Makefile.am =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.am,v retrieving revision 1.376 diff -u -r1.376 Makefile.am --- tests/Makefile.am 2002/01/20 21:30:21 1.376 +++ tests/Makefile.am 2002/02/14 18:10:22 @@ -184,6 +184,7 @@ lex2.test \ lex3.test \ lex4.test \ +lex5.test \ libobj.test \ libobj2.test \ libobj3.test \ @@ -355,6 +356,7 @@ yacc5.test \ yacc6.test \ yacc7.test \ +yacc8.test \ yaccpp.test \ yaccvpath.test Index: tests/Makefile.in =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.in,v retrieving revision 1.488 diff -u -r1.488 Makefile.in --- tests/Makefile.in 2002/01/28 01:47:03 1.488 +++ tests/Makefile.in 2002/02/14 18:10:22 @@ -259,6 +259,7 @@ lex2.test \ lex3.test \ lex4.test \ +lex5.test \ libobj.test \ libobj2.test \ libobj3.test \ @@ -430,6 +431,7 @@ yacc5.test \ yacc6.test \ yacc7.test \ +yacc8.test \ yaccpp.test \ yaccvpath.test Index: tests/lex5.test =================================================================== RCS file: lex5.test diff -N lex5.test --- /dev/null Tue May 5 13:32:27 1998 +++ tests/lex5.test Thu Feb 14 10:10:22 2002 @@ -0,0 +1,73 @@ +#! /bin/sh + +# Test for subdir lexers. + +required='gcc make gzip' +. $srcdir/defs || exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_AUX_DIR([.]) +AC_PROG_CC +AM_PROG_CC_C_O +AM_PROG_LEX +AC_OUTPUT +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = foreign subdir-objects +LDADD = @LEXLIB@ + +bin_PROGRAMS = foo/foo +foo_foo_SOURCES = foo/foo.l +END + +mkdir foo + +cat > foo/foo.l << 'END' +%% +"END" return EOF; +. +%% +int +main () +{ + while (yylex () != EOF) + ; + + return 0; +} +END + +set -e + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +mkdir sub +cd sub +../configure +$MAKE foo/foo.o + +test -f foo/foo.c +test -f foo/foo.o + +# Now, adds another lexer to test ylwrap. + +cd .. +cp foo/foo.l foo/foo2.l +cat >> Makefile.am << 'END' +EXTRA_foo_foo_SOURCES = foo/foo2.l +END + +$AUTOMAKE -a +test -f ./ylwrap + +cd sub +make foo/foo2.o +test -f foo/foo2.c +test -f foo/foo2.o + +exit 0 Index: tests/yacc8.test =================================================================== RCS file: yacc8.test diff -N yacc8.test --- /dev/null Tue May 5 13:32:27 1998 +++ tests/yacc8.test Thu Feb 14 10:10:22 2002 @@ -0,0 +1,68 @@ +#! /bin/sh + +# Test for subdir parsers. + +required="gcc bison" + +. $srcdir/defs || exit 1 + +set -e + +cat >> configure.in << 'END' +AC_CONFIG_AUX_DIR([.]) +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_YACC +AC_OUTPUT +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects +bin_PROGRAMS = foo/foo +foo_foo_SOURCES = foo/parse.y +END + +mkdir foo + +cat > foo/parse.y << 'END' +%{ +int yylex () {return 0;} +void yyerror (char *s) {} +%} +%% +foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; +END + +# We are not checking Autoconf, so we pick $YACC for it. +YACC="bison -y" +export YACC + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +mkdir sub +cd sub + +../configure +$MAKE foo/parse.o +test -f foo/parse.c +test -f foo/parse.o + +# Now, adds another parser to test ylwrap. + +cd .. +cp foo/parse.y foo/parse2.y +cat >> Makefile.am << 'END' +EXTRA_foo_foo_SOURCES = foo/parse2.y +END + +$AUTOMAKE -a +test -f ./ylwrap + +cd sub +make foo/parse2.o +test -f foo/parse2.c +test -f foo/parse2.o + +exit 0 -- Alexandre Duret-Lutz