From 0908c7155ab29c589a90242aa5c2f878bf8202ca Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 27 Aug 1996 05:19:28 +0000 Subject: [PATCH] Do variable interpolation --- ChangeLog | 11 ++++++++ NEWS | 1 + TODO | 6 +++++ automake.in | 65 +++++++++++++++++++++++++++++++++++------------ automake.texi | 56 ++++++++++++++++++++++++++++++++-------- tests/ChangeLog | 4 +++ tests/Makefile.am | 2 +- tests/Makefile.in | 2 +- tests/interp.test | 15 +++++++++++ 9 files changed, 133 insertions(+), 29 deletions(-) create mode 100755 tests/interp.test diff --git a/ChangeLog b/ChangeLog index 14a34190..272cfa2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Mon Aug 26 21:37:32 1996 Tom Tromey + + * automake.in (variable_value_as_list): New sub. + (handle_source_transform): Use it. + (handle_lib_objects): Ditto. + (handle_libraries): Ditto. + (handle_texinfo): Ditto. + (handle_man_pages): Ditto. + (am_install_var): Ditto. + (handle_options): Ditto. + Sat Aug 24 09:30:46 1996 Tom Tromey Reported by Jim Meyering: diff --git a/NEWS b/NEWS index 5900bb8e..171b1343 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ New in 1.1d: * Better C++, yacc, lex support * Random files listed in AC_OUTPUT now removed by "make clean" * Will compute _DEPENDENCIES variables automatically if not supplied +* Will interpolate $(...) and ${...} when examining contents of a variable New in 1.0: * Bug fixes diff --git a/TODO b/TODO index 25b2bf82..195987de 100644 --- a/TODO +++ b/TODO @@ -286,6 +286,12 @@ autosystem... Document: +go through handle_configure and make sure each macro is documented in +the appropriate place. Clean up ordering in document. Add info about +AM_ macros. + +finish yacc, lex, c++ nodes + Document customary ordering of Makefile.am. From François. must document that @ALLOCA@ works in _LDADD diff --git a/automake.in b/automake.in index a5421385..406df90c 100755 --- a/automake.in +++ b/automake.in @@ -461,7 +461,7 @@ sub handle_options { return if ! &variable_defined ('AUTOMAKE_OPTIONS'); - foreach (split (' ', $contents{'AUTOMAKE_OPTIONS'})) + foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS')) { last if /^#/; @@ -722,34 +722,34 @@ sub handle_source_transform return; } - local ($source_list); + local (@files); local ($prefix); foreach $prefix ('', 'EXTRA_') { - $source_list = ''; + @files = (); if (&variable_defined ($prefix . $one_file . "_SOURCES")) { push (@sources, '$(' . $prefix . $one_file . "_SOURCES)"); push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)") unless $prefix eq 'EXTRA_'; - $source_list = $contents{$prefix . $one_file . "_SOURCES"}; + @files = &variable_value_as_list ($prefix + . $one_file . "_SOURCES"); } elsif ($prefix eq '') { $output_vars .= $one_file . "_SOURCES = " . $unxformed . ".c\n"; push (@sources, $unxformed . '.c'); push (@objects, $unxformed . $obj); - $source_list = $unxformed . ".c "; + push (@files, $unxformed . ".c "); } else { $output_vars .= "EXTRA_" . $one_file . "_SOURCES =\n"; } - if ($source_list) + if (length (@files)) { # Turn sources into objects. - local (@files) = split (' ', $source_list); local (@result) = (); foreach (@files) { @@ -761,9 +761,6 @@ sub handle_source_transform next if /\.h\+\+$/; next if /\.hh$/; next if /\.hpp$/; - # Skip things that look like macro references. - next if /^\$\(.*\)$/; - next if /^\$\{.*\}$/; # Skip things that look like configure substitutions. next if /^\@.*\@$/; @@ -849,7 +846,7 @@ sub handle_lib_objects local ($lsearch); local (@dep_list) = (); - foreach $lsearch (split (' ', $contents{$var})) + foreach $lsearch (&variable_value_as_list ($var)) { # Skip -lfoo and -Ldir. next if /^-[lL]/; @@ -999,7 +996,7 @@ sub handle_libraries if (&variable_defined ($onedir . '_LIBRARIES')) { @outlist = (); - foreach $onelib (split (' ', $contents{$onedir . '_LIBRARIES'})) + foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES')) { push (@outlist, 'lib' . $onelib . '.a'); } @@ -1145,7 +1142,7 @@ sub handle_texinfo return if (! &variable_defined ('info_TEXINFOS') && ! &variable_defined ('html_TEXINFOS')); - local (@texis) = split (' ', $contents{'info_TEXINFOS'}); + local (@texis) = &variable_value_as_list ('info_TEXINFOS'); local (@infos_list, @info_deps_list, @dvis_list, @texi_deps); local ($infobase, $info_cursor); @@ -1283,7 +1280,7 @@ sub handle_man_pages # We generate the manpage install code by hand to avoid the use of # basename in the generated Makefile. - local (@mans) = split (' ', $contents{'man_MANS'}); + local (@mans) = &variable_value_as_list ('man_MANS'); local (%sections, %inames, %mbases, %secmap, %fullsecmap); local ($i) = 1; foreach (@mans) @@ -1703,7 +1700,7 @@ sub handle_subdirs # Make sure each directory mentioned in SUBDIRS actually exists. local ($dir); - foreach $dir (split (' ', $contents{'SUBDIRS'})) + foreach $dir (&variable_value_as_list ('SUBDIRS')) { # Skip directories substituted by configure. next if $dir =~ /^\@.*\@$/; @@ -2742,6 +2739,42 @@ sub variable_defined return (defined $contents{$var} && ! defined $targets{$var}); } +# Return contents of variable as list, split as whitespace. This will +# recursively follow $(...) and ${...} inclusions. It preserves @...@ +# substitutions. If PARENT is specified, it is the name of the +# including variable; this is only used for error reports. +sub variable_value_as_list +{ + local ($var, $parent) = @_; + local (@result); + + if (defined $targets{$var}) + { + &am_line_error ($var, "\`$var' is target; expected variable"); + } + elsif (! defined $contents{$var}) + { + &am_error ($parent, "variable \`$var' not defined"); + } + else + { + foreach (split (' ', $contents{$var})) + { + # Handle variable substitutions. + if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/) + { + push (@result, &variable_value_as_list ($1, $var)); + } + else + { + push (@result, $_); + } + } + } + + return @result; +} + # Read Makefile.am and set up %contents. Simultaneously copy lines # from Makefile.am into $output_trailer or $output_vars as # appropriate. NOTE we put rules in the trailer section. We want @@ -3305,7 +3338,7 @@ sub am_install_var # Append actual contents of where_PRIMARY variable to # result. local ($rcurs); - foreach $rcurs (split (' ', $contents{$one_name})) + foreach $rcurs (&variable_value_as_list ($one_name)) { # Skip configure substitutions. Possibly bogus. next if $rcurs =~ /^\@.*\@$/; diff --git a/automake.texi b/automake.texi index 91d28d47..0c03b345 100644 --- a/automake.texi +++ b/automake.texi @@ -501,9 +501,12 @@ Automake will also detect statements which put @samp{.o} files into This is required if any libraries are built in the package. @cvindex AC_PROG_RANLIB +@item AC_PROG_CXX +This is required if any C++ source is included. +@cvindex AC_PROG_CXX + @item AC_PROG_INSTALL @item AM_PROG_INSTALL - @code{AM_PROG_INSTALL} is required if any scripts (@pxref{Scripts}) are installed by the package. Otherwise, @code{AC_PROG_INSTALL} is required. @code{AM_INIT_AUTOMAKE} automatically calls @@ -518,6 +521,21 @@ Libtool Manual, libtool.info, The Libtool Manual}). This work is still preliminary. @cvindex AM_PROG_LIBTOOL +@item AC_PROG_YACC +If a Yacc source file is seen, then you must either use this macro or +declare the variable @samp{YACC} in @file{configure.in}. The former is +preferred. +@cvindex AC_PROG_YACC +@cvindex YACC + +@item AC_DECL_YYTEXT +This macro is required if there is Yacc source in the package. +@cvindex AC_DECL_YYTEXT + +@item AC_PROG_LEX +If a Lex source file is seen, then this macro must be used. +@cvindex AC_PROG_LEX + @item ALL_LINGUAS If Automake sees that this variable is set in @file{configure.in}, it will check the @file{po} directory to ensure that all the named @@ -736,26 +754,38 @@ handled in the dependency-tracking scheme, see @xref{Dependencies}. @node Program variables @section Variables used when building a program -@table @code -@item CC -@item CFLAGS -@item CPPFLAGS -@item CXX -@item CXXFLAGS -@item DEFS -@item LDFLAGS -@item LIBS +Occasionally it is useful to know which @file{Makefile} variables +Automake uses for compilations; for instance you might need to do your +own compilation in some special cases. + +Some variables are inherited from Autoconf; these are @code{CC}, +@code{CFLAGS}, @code{CPPFLAGS}, @code{CXX}, @code{CXXFLAGS}, +@code{DEFS}, @code{LDFLAGS}, and @code{LIBS}. + +There are some additional variables which Automake itself defines: + +@table @code @item INCLUDES +A list of @samp{-I} options. This can be set in your @file{Makefile.am} +if you have special directories you want to look in. + @item COMPILE +This is the command used to actually compile a C source file. The +filename is appended to form the complete command line. + @item LINK +This is the command used to actually link a C program. @end table @node Yacc and Lex @section Yacc and Lex support -Y +Automake has somewhat idiosyncratic support for Yacc and Lex. + + + @node C++ @section C++ and other languages @@ -764,7 +794,11 @@ Automake includes full support for C++, and rudimentary support for other languages. Support for other languages will be improved based on demand. +Any package including C++ code must use @code{AC_PROG_CXX} in its +@file{configure.in}. + +A few additional variables are defined when a C++ source file is seen. @node ANSI diff --git a/tests/ChangeLog b/tests/ChangeLog index f2ade8ed..35d8eb68 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +Mon Aug 26 23:04:01 1996 Tom Tromey + + * interp.test: New file. + Mon Aug 12 13:58:55 1996 Tom Tromey * libobj2.test: New file. diff --git a/tests/Makefile.am b/tests/Makefile.am index 430d1a4e..08f197a0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,6 +13,6 @@ yacc.test mkinstall2.test texinfo2.test ansi.test depacl.test depacl2.test \ error.test colon.test vtexi2.test tags.test comment.test libfiles.test \ man.test info.test obsolete.test lex.test scripts.test subdir2.test \ exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test \ -order.test libobj2.test +order.test libobj2.test interp.test EXTRA_DIST = defs $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 76fb31cb..2f5698a7 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -51,7 +51,7 @@ yacc.test mkinstall2.test texinfo2.test ansi.test depacl.test depacl2.test \ error.test colon.test vtexi2.test tags.test comment.test libfiles.test \ man.test info.test obsolete.test lex.test scripts.test subdir2.test \ exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test \ -order.test libobj2.test +order.test libobj2.test interp.test EXTRA_DIST = defs $(TESTS) mkinstalldirs = $(top_srcdir)/mkinstalldirs diff --git a/tests/interp.test b/tests/interp.test new file mode 100755 index 00000000..e593b68a --- /dev/null +++ b/tests/interp.test @@ -0,0 +1,15 @@ +#! /bin/sh + +# Test to make sure variable interpolation works. + +. $srcdir/defs || exit 1 + +cat > Makefile.am << 'END' +bin_PROGRAMS = qqq +s1 = z.c +qqq_SOURCES = $(s1) +END + +$AUTOMAKE || exit 1 + +grep 'z\.o' Makefile.in -- 2.43.5