From fe84dc13c035b7265e9b4b445f8368920a31a01a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 11 Oct 1996 07:03:08 +0000 Subject: [PATCH] better lex error message --- ChangeLog | 9 +++++++ TODO | 60 ++++++++++++++++++++-------------------------- automake.in | 50 ++++++++++++++++++++++++++++++++------ tests/ChangeLog | 5 ++++ tests/Makefile.am | 2 +- tests/Makefile.in | 6 ++--- tests/distdir.test | 15 ++++++++++++ tests/lex.test | 1 + tests/lex2.test | 20 ++++++++++++++++ 9 files changed, 123 insertions(+), 45 deletions(-) create mode 100755 tests/distdir.test create mode 100755 tests/lex2.test diff --git a/ChangeLog b/ChangeLog index eeec7bfb..8d5714c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Oct 11 00:44:49 1996 Tom Tromey + + * automake.in (handle_lib_objects): Added $lex_seen argument. + Error if lex file used but LEXLIB not seen. + (handle_programs): Ditto. + (handle_yacc_lex_cxx): Define LEXLIB variable. + (handle_lib_objects): Don't allow LEXLIB to end up on dependency + list. + Thu Oct 10 16:12:38 1996 Tom Tromey * automake.in (handle_gettext): Moved check for SUBDIRS and diff --git a/TODO b/TODO index 3019f9a2..c1d5c879 100644 --- a/TODO +++ b/TODO @@ -15,26 +15,23 @@ Further: - consider adding "echo"s to installs again. users can use make SHELL='sh -x' to get the full dirt -Some long-term projects: -* if $(FOO) is used somewhere, ensure FOO is defined, either by - user or by automake if possible -* Don't rearrange order of `include' lines relative to += assignments. -* Handle += assignments at all. - Avoid loops when installing; instead unroll them in automake Franc,ois> * ansi2knr was uselessly compiled, and it might be an Franc,ois> Automake problem: -MUST look @ Franc,ois' run-time-replacement code - -From David A Swierczek: automake should notice (eg) AC_CHECK_PROG and -auto-generate Makefile substitution: +Some long-term projects: +* if $(FOO) is used somewhere, ensure FOO is defined, either by + user or by automake if possible +* Don't rearrange order of `include' lines relative to += assignments. +* Handle += assignments at all. +* From David A Swierczek: automake should notice (eg) AC_CHECK_PROG and + auto-generate Makefile substitution: AC_CHECK_PROG(AR, ...) => AR = @AR@ in Makefile.in -Ditto AC_SUBST and other things that make sense. Furthermore, other -macros (eg AC_PROG_CC) should be handled via a similar mechanism; many -special cases could be eliminated. + Ditto AC_SUBST and other things that make sense. Furthermore, other + macros (eg AC_PROG_CC) should be handled via a similar mechanism; many + special cases could be eliminated. consider putting all check-* targets onto @check? To support --help/--version checking? @@ -161,9 +158,6 @@ $output_rules. * Should be a way to have "nobuild_PROGRAMS" which aren't even built, but which could be by running the magic make command. -* Should have tool like "autoreconf" that only remakes Makefiles that - need it. Probably autoreconf should be modified to handle automake - Other priorities: * Must rewrite am_install_var. Should break into multiple functions. This will allow the callers to be a little smarter. @@ -177,9 +171,6 @@ Things to finish libtool support: * Handle clean changes * New definition for LINK -Scan source directories and warn about missing files, eg .c/.h files -that aren't mentioned? - Need way to say there are no suffixes in a Makefile (Franc,ois' "override" idea suffices here) @@ -205,13 +196,13 @@ whatever else Fran Add support for html via an option. Use texi2html. Use "html_TEXINFOS", and htmldir = .../html. Include html files in distribution. Also allow "html_DATA", for raw .html files. - [ when will texinfo support html? ] - [ is there a texinfo.tex that supports texi2html extensions? ] + [ when will texinfo directly support html? ] uninstall and pkg-dirs should rm -rf the dir. a potential bug: configure puts "blah.o" into LIBOBJS, thus implying these files can't be de-ansified. Not a problem? + [ fix by using ansi2knr wrapper program ] In general most .am files should be merged into automake. For instance all the "clean" targets could be merged by keeping lists of @@ -238,7 +229,6 @@ Lex, yacc support: * Consider supporting syntax from autoconf "derived:source", eg: y.tab.c:perly.y for yacc and lex source -* if AC_PROG_LEX used, ensure (no, *PUT*) LEXLIB in foo_LDADD Multi-language support: * should have mapping of file extensions to languages @@ -250,8 +240,6 @@ Eg .f.o rules should be recognized & auto-handled in _SOURCES That way any random language can be treated with C/C++ on a first-class basis (maybe) -Should 'distclean' "rm -rf .deps"? - It might be cool to generate .texi dependencies by grepping for @include. (If done, it should be done the same way C dependencies are done) @@ -288,15 +276,6 @@ Check all source files to make sure that FSF address is up-to-date. Merge each -vars.am file with corresponding ".am" file. Can do this because of changes to &file_contents. -Looked at a program called 'ezmake', which seems to do something -similar. The only idea there that is possibly worth stealing is using -globs in definitions. Also has negations. Eg in a directory with -files a.c, b.c and c.c, the line: - foo_SOURCES = *.c ~c.c -would be equivalent to: - foo_SOURCES = a.c b.c -Is this worth implementing? - Should libexec programs have the name transform done on them? Order the output rules sensibly, so FOO_SOURCES and FOO_OBJECTS are @@ -314,7 +293,6 @@ some support for this. Here are some of the issues: * can do this by looking at subdirs, seeing configure.in and auto-running Automake there -These can both be handled via dist-hook: . Consider supporting guile-style PLUGIN directories automatically? djm says: @@ -450,3 +428,17 @@ could eliminate a common source of problems. * make the auto-dep code crash if GNU make not in use? (doesn't it already?) + +Looked at a program called 'ezmake', which seems to do something +similar. The only idea there that is possibly worth stealing is using +globs in definitions. Also has negations. Eg in a directory with +files a.c, b.c and c.c, the line: + foo_SOURCES = *.c ~c.c +would be equivalent to: + foo_SOURCES = a.c b.c +Is this worth implementing? + [ No... it is more reliable to spell everything out. ] + +Scan source directories and warn about missing files, eg .c/.h files +that aren't mentioned? + [ distcheck makes this less useful ] diff --git a/automake.in b/automake.in index 81cf79da..0aa5d225 100755 --- a/automake.in +++ b/automake.in @@ -694,6 +694,7 @@ sub handle_yacc_lex_cxx push (@suffixes, '.l'); &define_variable ("LEX", "\@LEX\@"); &define_variable ("LEX_OUTPUT_ROOT", "\@LEX_OUTPUT_ROOT\@"); + &define_variable ("LEXLIB", "\@LEXLIB\@"); $output_rules .= ".l.c:\n\t"; if ($lex_count > 1) { @@ -914,17 +915,24 @@ sub handle_source_transform # Arguments are: # transformed name of object being built, or empty string if no object # name of _LDADD/_LIBADD-type variable to examine +# boolean (lex_seen) which is true if a lex source file was seen in this +# object. valid only for LDADDs, not LIBADDs. If set, LEXLIB +# must be in LDADD. sub handle_lib_objects { - local ($xname, $var) = @_; + local ($xname, $var, $lex_seen) = @_; - die "programming error in handle_lib_objects" + die "programming error 1 in handle_lib_objects" if ! &variable_defined ($var); + die "programming error 2 in handle_lib_objects" + if $lex_seen && $var =~ /LIBADD/; + # We recognize certain things that are commonly put in LIBADD or # LDADD. local ($lsearch); local (@dep_list) = (); + local ($lex_ok) = 0; foreach $lsearch (&variable_value_as_list ($var)) { @@ -970,6 +978,20 @@ sub handle_lib_objects $dep_files{'.deps/alloca.P'} = 1; &require_file_with_line ($var, $FOREIGN, 'alloca.c'); } + elsif ($lsearch eq '@LEXLIB@') + { + # FIXME: variable_value_as_list requires us to force + # @LEXLIB@ here, where we're really prefer $(LEXLIB). + # Nasty -- this will have to wait until many cleanups are + # made, I think. + $lex_ok = 1; + } + + } + + if (! $lex_ok) + { + &am_line_error ($var, 'lex source file used without @LEXLIB@'); } if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES')) @@ -1012,11 +1034,16 @@ sub handle_programs } } + # FIXME: Using a trick to figure out if any lex sources appear + # in our program; should use some cleaner method. + local ($lex_num) = scalar (keys %lex_sources); local ($linker) = &handle_source_transform ($xname, $one_file, $obj); + local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num); if (&variable_defined ($xname . "_LDADD")) { - &handle_lib_objects ($xname, $xname . '_LDADD'); + &handle_lib_objects ($xname, $xname . '_LDADD', $lex_file_seen); + $lex_file_seen = 0; } else { @@ -1025,8 +1052,17 @@ sub handle_programs # This does a bit too much work. But we need it to # generate _DEPENDENCIES when appropriate. - &handle_lib_objects ($xname, 'LDADD') - if (&variable_defined ('LDADD')); + if (&variable_defined ('LDADD')) + { + &handle_lib_objects ($xname, 'LDADD', $lex_file_seen); + $lex_file_seen = 0; + } + } + + if ($lex_file_seen) + { + &am_line_error ($one_file . $xt, + 'lex source file used without @LEXLIB@'); } # Determine program to use for link. @@ -1048,7 +1084,7 @@ sub handle_programs 'program'); } - &handle_lib_objects ('', 'LDADD') + &handle_lib_objects ('', 'LDADD', 0) if &variable_defined ('LDADD'); } @@ -1120,7 +1156,7 @@ sub handle_libraries if (&variable_defined ($xlib . '_LIBADD')) { - &handle_lib_objects ($xlib, $xlib . '_LIBADD'); + &handle_lib_objects ($xlib, $xlib . '_LIBADD', 0); } else { diff --git a/tests/ChangeLog b/tests/ChangeLog index 359ba029..e9560d99 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +Fri Oct 11 00:51:04 1996 Tom Tromey + + * distdir.test: New file. + * lex2.test: New file. + Sun Oct 6 11:00:44 1996 Tom Tromey * acsilent.test: New file. diff --git a/tests/Makefile.am b/tests/Makefile.am index e1de16e0..6feb12ff 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,6 +17,6 @@ order.test libobj2.test interp.test alllib.test block.test libobj3.test \ gnits.test interp2.test colneq.test implicit.test spell.test spell2.test \ confsub.test primary.test primary2.test depend2.test spell3.test \ comment2.test vpath.test symlink.test discover.test acinclude.test req.test \ -acsilent.test +acsilent.test distdir.test lex2.test EXTRA_DIST = defs $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index a1686c7d..959a0f7c 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.1f from Makefile.am +# Makefile.in generated automatically by automake 1.1g from Makefile.am # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -55,7 +55,7 @@ order.test libobj2.test interp.test alllib.test block.test libobj3.test \ gnits.test interp2.test colneq.test implicit.test spell.test spell2.test \ confsub.test primary.test primary2.test depend2.test spell3.test \ comment2.test vpath.test symlink.test discover.test acinclude.test req.test \ -acsilent.test +acsilent.test distdir.test lex2.test EXTRA_DIST = defs $(TESTS) mkinstalldirs = $(top_srcdir)/mkinstalldirs @@ -78,7 +78,7 @@ default: all $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in cd $(top_srcdir) && automake $(subdir)/Makefile -Makefile: $(top_builddir)/config.status $(srcdir)/Makefile.in +Makefile: $(top_builddir)/config.status $(srcdir)/Makefile.in $(BUILT_SOURCES) cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status tags: TAGS TAGS: diff --git a/tests/distdir.test b/tests/distdir.test new file mode 100755 index 00000000..80db3789 --- /dev/null +++ b/tests/distdir.test @@ -0,0 +1,15 @@ +#! /bin/sh + +# Test to make sure subdirs in EXTRA_DIST work. Also tests to make +# sure "./" is ignored. + +. $srcdir/defs || exit 1 + +cat > Makefile.am << 'END' +EXTRA_DIST = foo/bar ./joe +END + +$AUTOMAKE || exit 1 + +grep 'mkinstalldirs.*\.' Makefile.in && exit 1 +grep 'mkinstalldirs.*foo' Makefile.in diff --git a/tests/lex.test b/tests/lex.test index d6ea7c6e..b667fd90 100755 --- a/tests/lex.test +++ b/tests/lex.test @@ -12,6 +12,7 @@ END cat > Makefile.am << 'END' bin_PROGRAMS = zot zot_SOURCES = joe.l +LDADD = @LEXLIB@ END : > joe.l diff --git a/tests/lex2.test b/tests/lex2.test new file mode 100755 index 00000000..fe7a9a94 --- /dev/null +++ b/tests/lex2.test @@ -0,0 +1,20 @@ +#! /bin/sh + +# Test of lex error case. + +. $srcdir/defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_LEX +AC_DECL_YYTEXT +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = zot +zot_SOURCES = joe.l +END + +: > joe.l + +$AUTOMAKE && exit 1 +exit 0 -- 2.43.5