From 0df76f10a8a3576e03f81c2acf73b5a226b80b9f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 6 Dec 1996 03:31:22 +0000 Subject: [PATCH] bug fixes for : mode support --- ChangeLog | 14 +++++ Makefile.am | 2 +- Makefile.in | 16 ++--- TODO | 4 ++ aclocal.m4 | 2 +- automake.in | 181 +++++++++++++++++++++++++++++++++++++---------------- lib/am/Makefile.am | 2 +- m4/Makefile.in | 8 +-- remake-subd.am | 23 ------- remake.am | 7 --- tests/ChangeLog | 2 + tests/Makefile.am | 3 +- tests/Makefile.in | 10 +-- tests/colon2.test | 22 +++++++ tests/colon3.test | 24 +++++++ 15 files changed, 214 insertions(+), 106 deletions(-) delete mode 100644 remake-subd.am create mode 100755 tests/colon2.test create mode 100755 tests/colon3.test diff --git a/ChangeLog b/ChangeLog index db397c2..5d4f465 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ Thu Dec 5 02:52:20 1996 Tom Tromey + * remake.am: Removed rules to regenerate Makefile and Makefile.in; + now handled by handle_configure. + + * remake-subd.am: Removed. + + * automake.in (scan_configure): Handle multiple ":"s in AC_OUTPUT + arg. + (parse_arguments): Ditto. + (handle_configure): Ditto. + (%other_output_files): Removed. + (rewrite_inputs_into_dependencies): New sub. + (handle_configure): Use it. + (handle_configure): Ditto. + From Gord Matzigkeit: * automake.in (generate_makefile): Handle ":" in AC_OUTPUT arg. (handle_configure): Ditto. diff --git a/Makefile.am b/Makefile.am index 5274827..e3a483f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ info_TEXINFOS = automake.texi pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \ compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \ header.am header-vars.am kr-extra.am libs.am library.am libtool.am ltlibs.am \ -mans-vars.am program.am progs.am remake-hdr.am remake-subd.am \ +mans-vars.am program.am progs.am remake-hdr.am \ remake.am scripts.am subdirs.am tags.am tags-clean.am \ texi-vers.am texinfos.am libs-clean.am \ progs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \ diff --git a/Makefile.in b/Makefile.in index 53df386..77ba8de 100644 --- a/Makefile.in +++ b/Makefile.in @@ -50,7 +50,7 @@ info_TEXINFOS = automake.texi pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \ compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \ header.am header-vars.am kr-extra.am libs.am library.am libtool.am ltlibs.am \ -mans-vars.am program.am progs.am remake-hdr.am remake-subd.am \ +mans-vars.am program.am progs.am remake-hdr.am \ remake.am scripts.am subdirs.am tags.am tags-clean.am \ texi-vers.am texinfos.am libs-clean.am \ progs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \ @@ -95,16 +95,16 @@ default: all .SUFFIXES: .SUFFIXES: .texi .texinfo .info .dvi +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in + cd $(top_srcdir) && automake --gnits Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + $(srcdir)/aclocal.m4: configure.in cd $(srcdir) && aclocal -$(srcdir)/Makefile.in: Makefile.am configure.in - cd $(srcdir) && automake --gnits Makefile - -# For an explanation of the following Makefile rules, see node -# `Automatic Remaking' in GNU Autoconf documentation. -Makefile: $(srcdir)/Makefile.in config.status $(BUILT_SOURCES) - CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status config.status: configure $(SHELL) ./config.status --recheck $(srcdir)/configure: configure.in $(ACLOCAL) $(CONFIGURE_DEPENDENCIES) diff --git a/TODO b/TODO index fd2396e..c80bd7b 100644 --- a/TODO +++ b/TODO @@ -22,6 +22,10 @@ Priorities for release: * figure out what to pass as CONFIG_HEADER to config.status + * for multi-":" mode and AC_OUTPUT, it would be good to pick the + first input file that has a corresponding .am file. + There are other bugs here too. + * look @ jim's $(t:=foo) problem * should install-foo target for a new dir (eg fooexecdir) be run via diff --git a/aclocal.m4 b/aclocal.m4 index 9720c14..ab6c5e5 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl aclocal.m4 generated automatically by aclocal 1.1j +dnl aclocal.m4 generated automatically by aclocal 1.1k # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. diff --git a/automake.in b/automake.in index 3e9993b..7b73079 100755 --- a/automake.in +++ b/automake.in @@ -122,7 +122,6 @@ $srcdir_name = ''; # List of files in AC_OUTPUT without Makefile.am, and their outputs. @other_input_files = (); -%other_output_files = (); # Line number at which AC_OUTPUT seen. $ac_output_line = 0; @@ -366,12 +365,25 @@ sub parse_arguments } else { - # Handle $local:$input syntax. - local ($local, $input) = split (/:/, $arglist[0]); - $input = $local if (!$input); - $input =~ s/\.in$//; + # Handle $local:$input syntax. Note that we only examine + # the first ":" file to see if it is automake input; the + # rest are just taken verbatim. We still keep all the + # files around for dependency checking, however. + local ($local, $input, @rest) = split (/:/, $arglist[0]); + if (! $input) + { + $input = $local; + } + else + { + # Strip .in; later on .am is tacked on. That is how + # the automake input file is found. Maybe not the + # best way, but it is easy to explain. FIXME: should + # be error if .in is missing. + $input =~ s/\.in$//; + } push (@input_files, $input); - $output_files{$input} = $local; + $output_files{$input} = join (':', ($local, @rest)); } shift (@arglist); @@ -402,6 +414,14 @@ sub generate_makefile $in_file_name = $am_file_name . '.in'; $am_file_name .= '.am'; + # $OUTPUT is encoded. If it contains a ":" then the first element + # is the real output file, and all remaining elements are input + # files. We don't scan or otherwise deal with these input file, + # other than to mark them as dependencies. See scan_configure for + # details. + local (@secondary_inputs); + ($output, @secondary_inputs) = split (/:/, $output); + &initialize_per_input; $relative_dir = &dirname ($output); $am_relative_dir = &dirname ($makefile); @@ -455,7 +475,7 @@ sub generate_makefile &check_gnu_standards; &check_gnits_standards; - &handle_configure ($output, $makefile); + &handle_configure ($output, $makefile, @secondary_inputs); &handle_gettext; &handle_libraries; &handle_programs; @@ -1813,7 +1833,7 @@ sub handle_dist_worker && cd $(srcdir) \\ && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir ' # Set strictness of output. - . ($cygnus_mode ? ' --cygnus' : ('--' . $strictness_name)) + . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name)) . "\n" ); } @@ -2290,56 +2310,91 @@ sub handle_aclocal_m4 } } +# Rewrite a list of input files into a form suitable to put on a +# dependency list. The idea is that if an input file has a directory +# part the same as the current directory, then the directory part is +# simply removed. But if the directory part is different, then +# $(top_srcdir) is prepended. Among other things, this is used to +# generate the dependency list for the output files generated by +# AC_OUTPUT. Consider what the dependencies should look like in this +# case: +# AC_OUTPUT(src/out:src/in1:lib/in2) +sub rewrite_inputs_into_dependencies +{ + local (@inputs) = @_; + local ($single, @newinputs); + + foreach $single (@inputs) + { + if (&dirname ($single) eq $relative_dir) + { + push (@newinputs, &basename ($single)); + } + else + { + push (@newinputs, '$(top_srcdir)/' . $single); + } + } + + return @newinputs; +} + # Handle remaking and configure stuff. # We need the name of the input file, to do proper remaking rules. sub handle_configure { - local ($local, $input) = @_; + local ($local, $input, @secondary_inputs) = @_; # If SUBDIRS defined, require AC_PROG_MAKE_SET. &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in") if &variable_defined ('SUBDIRS') && ! $seen_make_set; local ($top_reldir); - local ($xform) = ('s/\@ARGS\@/' - . ($cygnus_mode ? ' --cygnus' - : ('--' . $strictness_name)) - . '/;'); # Handle $local:$input syntax again. local ($amfile, $infile, $colon_infile); - if ($local eq $input) + $amfile = $input . '.am'; + # We know we can always add '.in' because it really should be an + # error if the .in was missing originally. + $infile = '$(srcdir)/' . $input . '.in'; + if ($local ne $input) { - $amfile = 'Makefile.am'; - $infile = '$(srcdir)/Makefile.in'; - $colon_infile = ''; - } - else - { - $amfile = '$(top_srcdir)/' . $input . '.am'; - $infile = '$(top_srcdir)/' . $input . '.in'; $colon_infile = ':' . $input . '.in'; } - - # Quote the amfile, infile, and colon_infile for the regular expression. - $amfile =~ s/([\$\(\)\/])/\\$1/g; - $infile =~ s/([\$\(\)\/])/\\$1/g; - $colon_infile =~ s/([\$\(\)\/])/\\$1/g; - - $xform .= 's/\@AMFILE\@/' . $amfile . '/;'; - $xform .= 's/\@INFILE\@/' . $infile . '/;'; - $xform .= 's/\@COLON_INFILE\@/' . $colon_infile . '/;'; + $colon_infile .= ':' . join (':', @secondary_inputs) + if @secondary_inputs; + + local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs); + # This rule remakes the Makefile.in. Note use of @MAINT@ forces + # us to abandon pretty-printing. Sigh. + $output_rules .= ($infile . ': ' . ($seen_maint_mode ? '@MAINT@ ' : '') + . $amfile . ' ' . '$(top_srcdir)/configure.in ' + . join (' ', @rewritten) . "\n" + . "\tcd \$(top_srcdir) && automake " + . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name)) + . ' ' . $input . $colon_infile . "\n\n"); + + # This rule remakes the Makefile. + $output_rules .= ($local . ': ' . $infile . ' ' + . '$(top_builddir)/config.status $(BUILT_SOURCES)' + . "\n" + . "\tcd \$(top_builddir) \\\n" + . "\t && CONFIG_FILES=" + # FIXME: is this right? + . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@') + . $colon_infile + . ' CONFIG_HEADERS= $(SHELL) ./config.status' + . "\n\n"); if ($relative_dir ne '.') { # In subdirectory. - $output_rules .= &file_contents_with_transform ($xform, 'remake-subd'); $top_reldir = '../'; } else { &handle_aclocal_m4; - $output_rules .= &file_contents_with_transform ($xform, 'remake'); + $output_rules .= &file_contents ('remake'); &examine_variable ('CONFIGURE_DEPENDENCIES'); $top_reldir = ''; } @@ -2417,29 +2472,34 @@ sub handle_configure # by config.status, and generate rules for them. local (@actual_other_files) = (); local ($file, $local); - local (@inputs); + local (@inputs, $single); foreach $file (@other_input_files) { - # Skip files not in this directory, any Makefile, and the - # config header. These last two must be handled specially. - next unless &dirname ($file) eq $relative_dir; - next if $file eq $top_builddir . '/' . $config_name; - ($local = $file) =~ s/^.*\///; - next if $local eq 'Makefile'; - - if ($local =~ /^(.*):(.*)$/) + if ($file =~ /^(.*):(.*)$/) { - # This is the ":" syntax of AC_OUTPUT. Note that the - # first word on @inputs must be the name of the created - # file. + # This is the ":" syntax of AC_OUTPUT. @inputs = split (':', $2); - $local = $1; + $file = $1; + $local = &basename ($file); } else { # Normal usage. - @inputs = $local . '.in'; + $local = &basename ($file); + @inputs = ($file . '.in'); } + + # Skip files not in this directory. + next unless &dirname ($local) eq $relative_dir; + + # Skip the config header. + next if $local eq $top_builddir . '/' . $config_name; + + # Skip any Makefile. + next if $local eq 'Makefile'; + + @inputs = &rewrite_inputs_into_dependencies (@inputs); + # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES # to $local:$input? $output_rules .= ($local . ': ' @@ -3098,7 +3158,7 @@ sub scan_configure %libsources = (); local ($in_ac_output, $in_ac_replace) = (0, 0); - local (@make_list, @make_input_list); + local (%make_list, @make_input_list); local ($libobj_iter); while () { @@ -3204,20 +3264,31 @@ sub scan_configure { next if $_ eq "\\"; - # Handle $local:$input syntax. - local ($local, $input) = split (/:/); - $input = $local if (!$input); - $input =~ s/\.in$//; + # Handle $local:$input syntax. Note that we ignore + # every input file past the first, though we keep + # those around for later. + local ($local, $input, @rest) = split (/:/); + if (! $input) + { + $input = $local; + } + else + { + # FIXME: should be error if .in is missing. + $input =~ s/\.in$//; + } if (-f $input . '.am') { + # We have a file that automake should generate. push (@make_input_list, $input); - $make_list{$input} = $local; + $make_list{$input} = join (':', ($local, @rest)); } else { - push (@other_input_files, $file); - $other_output_files{$input} = $local; + # We have a file that automake should cause to be + # rebuilt, but shouldn't generate itself. + push (@other_input_files, $_); } } } diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index 5274827..e3a483f 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -11,7 +11,7 @@ info_TEXINFOS = automake.texi pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \ compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am footer.am \ header.am header-vars.am kr-extra.am libs.am library.am libtool.am ltlibs.am \ -mans-vars.am program.am progs.am remake-hdr.am remake-subd.am \ +mans-vars.am program.am progs.am remake-hdr.am \ remake.am scripts.am subdirs.am tags.am tags-clean.am \ texi-vers.am texinfos.am libs-clean.am \ progs-clean.am data-clean.am COPYING INSTALL texinfo.tex ansi2knr.c \ diff --git a/m4/Makefile.in b/m4/Makefile.in index ead82f7..369153d 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -65,14 +65,14 @@ TAR = tar default: all .SUFFIXES: +$(srcdir)/m4/Makefile.in: m4/Makefile.am $(top_srcdir)/configure.in + cd $(top_srcdir) && automake --gnits m4/Makefile -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in - cd $(top_srcdir) && automake --gnits $(subdir)/Makefile - -Makefile: $(top_builddir)/config.status $(srcdir)/Makefile.in $(BUILT_SOURCES) +m4/Makefile: $(srcdir)/m4/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + install-m4dataDATA: $(m4data_DATA) $(NORMAL_INSTALL) $(mkinstalldirs) $(m4datadir) diff --git a/remake-subd.am b/remake-subd.am deleted file mode 100644 index 90c34f2..0000000 --- a/remake-subd.am +++ /dev/null @@ -1,23 +0,0 @@ -## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. - -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. - -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -## 02111-1307, USA. -$(srcdir)/Makefile.in: @MAINT@Makefile.am $(top_srcdir)/configure.in - cd $(top_srcdir) && automake @ARGS@ $(subdir)/Makefile - -Makefile: $(top_builddir)/config.status $(srcdir)/Makefile.in $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/remake.am b/remake.am index 5b75d4b..129f407 100644 --- a/remake.am +++ b/remake.am @@ -15,13 +15,6 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -$(srcdir)/Makefile.in: @MAINT@Makefile.am configure.in - cd $(srcdir) && automake @ARGS@ Makefile - -# For an explanation of the following Makefile rules, see node -# `Automatic Remaking' in GNU Autoconf documentation. -Makefile: $(srcdir)/Makefile.in config.status $(BUILT_SOURCES) - CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status config.status: configure $(SHELL) ./config.status --recheck $(srcdir)/configure: @MAINT@configure.in $(ACLOCAL) $(CONFIGURE_DEPENDENCIES) diff --git a/tests/ChangeLog b/tests/ChangeLog index 8912b5f..32ce217 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,7 @@ Thu Dec 5 18:23:17 1996 Tom Tromey + * colon3.test: New file. + * colon2.test: New file. * cxxo.test: New file. Wed Dec 4 00:41:44 1996 Tom Tromey diff --git a/tests/Makefile.am b/tests/Makefile.am index 313421a..08a8f95 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,7 +18,8 @@ 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 distdir.test lex2.test libobj4.test libobj5.test version.test \ -ranlib.test confvar.test confvar2.test stdlib.test cxxo.test +ranlib.test confvar.test confvar2.test stdlib.test cxxo.test colon2.test \ +colon3.test EXTRA_DIST = defs $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 527f1bb..d049757 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -57,7 +57,7 @@ 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 distdir.test lex2.test libobj4.test libobj5.test version.test \ -ranlib.test confvar.test confvar2.test stdlib.test cxxo.test +ranlib.test confvar.test confvar2.test stdlib.test cxxo.test colon2.test EXTRA_DIST = defs $(TESTS) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -75,13 +75,13 @@ TAR = tar default: all .SUFFIXES: +$(srcdir)/tests/Makefile.in: tests/Makefile.am $(top_srcdir)/configure.in + cd $(top_srcdir) && automake --gnits tests/Makefile -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in - cd $(top_srcdir) && automake --gnits $(subdir)/Makefile - -Makefile: $(top_builddir)/config.status $(srcdir)/Makefile.in $(BUILT_SOURCES) +tests/Makefile: $(srcdir)/tests/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + tags: TAGS TAGS: diff --git a/tests/colon2.test b/tests/colon2.test new file mode 100755 index 0000000..feeda98 --- /dev/null +++ b/tests/colon2.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# Make sure ":" works with files automake generates. + +. $srcdir/defs || exit 1 + +cat > configure.in << 'END' +PACKAGE=nonesuch +VERSION=nonesuch +AC_ARG_PROGRAM +AC_PROG_INSTALL +AC_OUTPUT(Makefile:zardoz.in) +END + +: > zardoz.am + +$AUTOMAKE || exit 1 + +# We actually check several things here. +test -f zardoz.in || exit 1 +grep '^zardoz:' zardoz.in && exit 1 +exit 0 diff --git a/tests/colon3.test b/tests/colon3.test new file mode 100755 index 0000000..1d5f832 --- /dev/null +++ b/tests/colon3.test @@ -0,0 +1,24 @@ +#! /bin/sh + +# Make sure ":" works with files automake generates. +# This test is for multiple ":"s. + +. $srcdir/defs || exit 1 + +cat > configure.in << 'END' +PACKAGE=nonesuch +VERSION=nonesuch +AC_ARG_PROGRAM +AC_PROG_INSTALL +AC_OUTPUT(Makefile:zardoz.in:two.in) +END + +: > zardoz.am +: > two.in + +$AUTOMAKE || exit 1 + +# We actually check several things here. +test -f zardoz.in || exit 1 +grep '^zardoz:' zardoz.in && exit 1 +grep ' two.in' zardoz.in -- 2.7.4