From 6d2e961eed57d941310d061773eee0960ee09152 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 26 Jan 1996 17:45:45 +0000 Subject: [PATCH] Fixes from Gord for deeper hierarchies --- ChangeLog | 24 ++++++++++ Makefile.in | 7 --- NEWS | 1 + TODO | 6 +-- automake.in | 125 ++++++++++++++++++++++++++++++++++---------------- header-vars.am | 3 ++ lib/am/header-vars.am | 3 ++ remake-subd.am | 4 +- 8 files changed, 119 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf5c5cc..bbb59fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,29 @@ Fri Jan 26 00:15:25 1996 Tom Tromey + * automake.in (read_am_file): Compute top_builddir when including + header-vars.am. + (handle_configure): Use $top_builddir, not $top_reldir. + (other_input_files): New variable. + (dirname): Fixed bug where dirname of 'a/b/c' was 'a', not 'a/b'. + + Changes from Gord Matzigkeit to enabled hierarchies deeper than 2: + * automake.in (input_files, seen_make_set): Declare globally. + (parse_arguments): Use input_files, not make_list. + Only scan configure.in once. + (handle_dist): Use SUBDIRS to determine when to make + subdirectories and recurisvely dist. Use $(topdir), not "..", to + find top of dist tree. + (handle_configure): Check for AC_PROG_MAKE_SET here. Don't require + configure.in (done elsewhere). + (scan_configure): seen_make_set is global. Allow arbitrary space + in LIBOBJS assignment. + (top_builddir): New variable. + * header-vars.am (top_builddir): New variable. + * remake-subd.am (Makefile): Look in top_builddir, not .., when + remaking. + * automake.in (handle_merge_targets): Run 'all' before + check-recursive. + * automake.in (file_contents_with_transform): Changed error message. (handle_configure): Define $contents{'CONFIG_HEADER'}. diff --git a/Makefile.in b/Makefile.in index 862e5b8..7ab9281 100644 --- a/Makefile.in +++ b/Makefile.in @@ -230,13 +230,6 @@ dist: $(DEP_DISTFILES) || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $(srcdir)/$$file $(distdir)/$$file; \ done - for subdir in $(SUBDIRS); do \ - test -d $(distdir)/$$subdir \ - || mkdir $(distdir)/$$subdir \ - || exit 1; \ - chmod 777 $(distdir)/$$subdir; \ - (cd $$subdir && $(MAKE) dist) || exit 1; \ - done @for dir in $(DIST_SUBDIRS); do \ echo copying directory $$dir; \ tar chf - $$dir | (cd $(distdir) && tar xBpf -); \ diff --git a/NEWS b/NEWS index c1b2564..9339983 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ New in 0.29: * TEXINFOS and MANS now obsolete; use info_TEXINFOS and man_MANS instead. * CONFIG_HEADER variable now obsolete * Can handle multiple Texinfo sources +* Allow hierarchies deeper than 2. From Gord Matzigkeit. New in 0.28: * Added --gnu and --gnits options diff --git a/TODO b/TODO index 2ff34c9..b3a9421 100644 --- a/TODO +++ b/TODO @@ -137,15 +137,11 @@ Look at dist's jmake for ideas. dist is the name of the distribution including Metaconfig. Perl uses it. Should handle directory hierarchies deeper than 2. Right now there is -no support for this at all. Here are some of the issues: +some support for this. Here are some of the issues: * Should handle AC_CONFIG_SUBDIRS, ie must handle configure.in in subdirs * Must handle SUBDIRS in subdir Makefile.am's * Must handle AC_CONFIG_AUX_DIR * FIXME must already look in .. and ../.. - * Look for install.sh and give error! -* All this means there should be a "configure_dir" macro which points - to the directory in which config.status resides. This should be used - in eg remake-subd.am. ================================================================ diff --git a/automake.in b/automake.in index 8a9c8f0..08bef9c 100755 --- a/automake.in +++ b/automake.in @@ -82,12 +82,30 @@ $fp_c_prototypes = 0; $config_name = ''; $config_header = ''; +# Relative location of top build directory. +$top_builddir = ''; + +# List of Makefile.am's to process. +@input_files = (); + +# List of files in AC_OUTPUT without Makefile.am. +@other_input_files = (); + +# Whether AC_PROG_MAKE_SET has been seen in configure.in. +$seen_make_set = 0; + &initialize_global_constants; # Parse command line. -@input_files = &parse_arguments (@ARGV); +&parse_arguments (@ARGV); + +# Do configure.in scan only once. +&scan_configure; + +die "automake: no \`Makefile.am' found or specified\n" + if ! @input_files; # Now do all the work on each file. foreach $am_file (@input_files) @@ -111,7 +129,6 @@ exit $exit_status; sub parse_arguments { local (@arglist) = @_; - local (@make_list); # Start off as normal. &set_strictness ('normal'); @@ -178,7 +195,7 @@ sub parse_arguments { # Stop option processing. shift (@arglist); - push (@make_list, @arglist); + push (@input_files, @arglist); last; } elsif ($arglist[0] =~ /^-/) @@ -187,7 +204,7 @@ sub parse_arguments } else { - push (@make_list, $arglist[0]); + push (@input_files, $arglist[0]); } shift (@arglist); @@ -196,23 +213,6 @@ sub parse_arguments # Take global strictness from whatever we currently have set. $default_strictness = $strictness; $default_strictness_name = $strictness_name; - - if (! @make_list) - { - # Look around for some files. - push (@make_list, 'Makefile') if -f 'Makefile.am'; - - foreach (<*/Makefile.am>) - { - s/\.am$//; - push (@make_list, $_); - } - - die "automake: no \"Makefile.am\" found or specified\n" - if ! @make_list; - } - - return (@make_list); } # Ensure argument exists, or die. @@ -864,9 +864,9 @@ sub handle_dist_worker done '; - # If top level, create all dist subdirectories and do recursive - # build. - if ($relative_dir eq '.') + # If we have SUBDIRS, create all dist subdirectories and do + # recursive build. + if (defined $contents{'SUBDIRS'}) { # Test for directory existence here because previous automake # invocation might have created some directories. @@ -949,7 +949,7 @@ sub handle_dist else { $output_rules .= ("\nsubdir = " . $relative_dir . "\n" - . 'distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)' + . 'distdir = $(topdir)/$(PACKAGE)-$(VERSION)/$(subdir)' . "\n"); } @@ -1029,6 +1029,10 @@ sub handle_subdirs # Handle remaking and configure stuff. sub handle_configure { + # If SUBDIRS defined, require AC_PROG_MAKE_SET. + &am_error ("AC_PROG_MAKE_SET must be used in configure.in") + if defined $contents{'SUBDIRS'} && ! $seen_make_set; + local ($top_reldir); if ($relative_dir ne '.') { @@ -1038,9 +1042,6 @@ sub handle_configure } else { - &require_file ($NORMAL, 'configure.in'); - &scan_configure; - if (-f 'aclocal.m4') { $output_vars .= "ACLOCAL = aclocal.m4\n"; @@ -1095,9 +1096,9 @@ sub handle_configure if defined $contents{'CONFIG_HEADER'}; # Generate CONFIG_HEADER define, and define interally. - $output_vars .= "CONFIG_HEADER = ${top_reldir}${config_name}\n" + $output_vars .= "CONFIG_HEADER = ${top_builddir}${config_name}\n" if $config_name; - $contents{'CONFIG_HEADER'} = "${top_reldir}${config_name}"; + $contents{'CONFIG_HEADER'} = "${top_builddir}${config_name}"; } # Handle C headers. @@ -1166,7 +1167,7 @@ sub handle_merge_targets if (! defined $contents{'SUBDIRS'} || $relative_dir ne '.') { # 'check' must depend on 'all', but not at top level. - push (@check, 'all'); + unshift (@check, 'all'); } &do_one_merge_target ('check', @check); &do_one_merge_target ('installcheck', @installcheck); @@ -1373,7 +1374,7 @@ sub scan_configure # that won't always be the case. %libsources = (); - local ($seen_make_set) = 0; + local ($in_ac_output, @make_list) = 0; local ($seen_prog_install) = 0; local ($seen_arg_prog) = 0; local ($seen_canonical) = 0; @@ -1381,7 +1382,7 @@ sub scan_configure { # Remove comments from current line. s/\bdnl\b.*$//; - s/\b\#.*$//; + s/\#.*$//; # Populate libobjs array. if (/AC_FUNC_ALLOCA/) @@ -1407,15 +1408,39 @@ sub scan_configure $libsources{$_ . '.c'} = 1; } } - elsif (/LIBOBJS="(.*)\.o \$LIBOBJS"/) + elsif (/LIBOBJS="(.*)\.o\s+\$LIBOBJS"/) { $libsources{$1 . '.c'} = 1; } - elsif (/LIBOBJS="\$LIBOBJS (.*)\.o"/) + elsif (/LIBOBJS="\$LIBOBJS\s+(.*)\.o"/) { $libsources{$1 . '.c'} = 1; } + # Process the AC_OUTPUT macro. + if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//) + { + $in_ac_output = 1; + } + if ($in_ac_output) + { + s/\]//; + $in_ac_output = 0 if s/\)//; + + # Look at potential Makefile.am's. + foreach (split) + { + if (-f $_ . '.am') + { + push (@make_list, $_); + } + else + { + push (@other_input_files, $_); + } + } + } + # Check for ansi2knr. $fp_c_prototypes = 1 if /fp_C_PROTOTYPES/; @@ -1464,14 +1489,14 @@ sub scan_configure $seen_arg_prog = 1 if /AC_ARG_PROGRAM/; } + # Set input files if not specified by user. + @input_files = @make_list if (! @input_files); + # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and # config.sub. &require_file ($NORMAL, 'config.guess', 'config.sub') if $seen_canonical; - # If SUBDIRS defined, require AC_PROG_MAKE_SET. - &am_error ("AC_PROG_MAKE_SET must be used in configure.in") - if defined $contents{'SUBDIRS'} && ! $seen_make_set; &am_error ("fp_PROG_INSTALL must be used in configure.in") unless $seen_prog_install; &am_error ("AC_ARG_PROGRAM must be used in configure.in") @@ -1567,7 +1592,27 @@ sub read_am_file { local ($amfile) = @_; - local ($header_vars) = &file_contents ('header-vars'); + # Compute relative location of the top object directory. + local (@topdir) = (); + foreach (split (/\//, $relative_dir)) + { + next if $_ eq '.' || $_ eq ''; + if ($_ eq '..') + { + pop @topdir; + } + else + { + push (@topdir, '..'); + } + } + @topdir = ('.') if ! @topdir; + + $top_builddir = join ('/', @topdir); + local ($header_vars) = + &file_contents_with_transform + ('s/\@top_builddir\@/' . $top_builddir . '/g', + 'header-vars'); open (AM_FILE, $amfile) || die "automake: couldn't open $amfile: $!\n"; @@ -2146,7 +2191,7 @@ sub dirname local ($file) = @_; local ($sub); - ($sub = $file) =~ s,/+[^/]+,,g; + ($sub = $file) =~ s,/+[^/]+$,,g; $sub = '.' if $sub eq $file; return $sub; } diff --git a/header-vars.am b/header-vars.am index ddb47c0..3ef2697 100644 --- a/header-vars.am +++ b/header-vars.am @@ -41,6 +41,9 @@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +## Location of top build directory relative to this one. +top_builddir = @top_builddir@ + INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index ddb47c0..3ef2697 100644 --- a/lib/am/header-vars.am +++ b/lib/am/header-vars.am @@ -41,6 +41,9 @@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +## Location of top build directory relative to this one. +top_builddir = @top_builddir@ + INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ diff --git a/remake-subd.am b/remake-subd.am index 701f9ed..13dc29f 100644 --- a/remake-subd.am +++ b/remake-subd.am @@ -18,5 +18,5 @@ $(srcdir)/Makefile.in: Makefile.am cd $(top_srcdir) && automake $(subdir)/Makefile -Makefile: ../config.status Makefile.in - cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status +Makefile: $(top_builddir)/config.status Makefile.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status -- 2.7.4