]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
dist: simplify automake code accordingly to the previous changes
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 2 Oct 2011 08:38:48 +0000 (10:38 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 8 Oct 2011 19:14:40 +0000 (21:14 +0200)
After the previous change `v1.11-1219-g326ecba', every Makefile.am
requiring a file in the "config auxdir" will cause it to be listed
in the DIST_COMMON variable of the corresponding generated
Makefile.in, not only of the top-level Makefile.in.  Thus we don't
need to worry anymore about trying to distribute files in the
config auxdir from the top-level Makefile or the Makefile in
config auxdir (if any).  This allows us to carry out some useful
simplifications in the automake script.

This will however cause some changes in the generated Makefile;
for example, if the `PROGRAMS' primary is used only in a subdir
Makefile.am, the `depcomp' script will be distributed only by
`subdir/Makefile', not by the top-level Makefile.  This change
can be seen as an internal detail though, and definitely warranted
by the nice simplifications the current commit provides.

* automake.in ($automake_will_process_aux_dir): Variable removed.
(scan_autoconf_files): Adjust and simplify.
(handle_makefiles_threaded): Likewise.
(get_number_of_threads): Likewise.
(require_file_internal): Likewise.
(maybe_push_required_file): Its return value is not used anymore,
so return nothing.  Add special handling for distributed files from
`$config_libobj_dir'.  Also, catch "this can't happen" situations,
and abort accordingly.  Fix function description to better fit its
new role.
* tests/libobj19.test: Extend to also check situations where the
Makefile.am using $(LIBOBJS) is not the top-level one.
* tests/distcom6.test: Delete, merged into ...
* tests/distcom2.test: ... this test, which has been update to
account for the changed automake semantics.
* tests/Makefile.am (TESTS): Update.
* NEWS: Update.

ChangeLog
NEWS
automake.in
tests/Makefile.am
tests/Makefile.in
tests/distcom2.test
tests/distcom6.test [deleted file]
tests/libobj19.test

index 4526648135aef99da8c7c2d3e2f367c0ce62b78d..563f91fa3ad10739f1a5e8f25bba1261c1f96873 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2011-10-08  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       dist: simplify automake code accordingly to the previous changes
+       After the previous change `v1.11-1219-g326ecba', every Makefile.am
+       requiring a file in the "config auxdir" will cause it to be listed
+       in the DIST_COMMON variable of the corresponding generated
+       Makefile.in, not only of the top-level Makefile.in.  Thus we don't
+       need to worry anymore about trying to distribute files in the
+       config auxdir from the top-level Makefile or the Makefile in
+       config auxdir (if any).  This allows us to carry out some useful
+       simplifications in the automake script.
+       This will however cause some changes in the generated Makefile;
+       for example, if the `PROGRAMS' primary is used only in a subdir
+       Makefile.am, the `depcomp' script will be distributed only by
+       `subdir/Makefile', not by the top-level Makefile.  This change
+       can be seen as an internal detail though, and definitely warranted
+       by the nice simplifications the current commit provides.
+       * automake.in ($automake_will_process_aux_dir): Variable removed.
+       (scan_autoconf_files): Adjust and simplify.
+       (handle_makefiles_threaded): Likewise.
+       (get_number_of_threads): Likewise.
+       (require_file_internal): Likewise.
+       (maybe_push_required_file): Its return value is not used anymore,
+       so return nothing.  Add special handling for distributed files from
+       `$config_libobj_dir'.  Also, catch "this can't happen" situations,
+       and abort accordingly.  Fix function description to better fit its
+       new role.
+       * tests/libobj19.test: Extend to also check situations where the
+       Makefile.am using $(LIBOBJS) is not the top-level one.
+       * tests/distcom6.test: Delete, merged into ...
+       * tests/distcom2.test: ... this test, which has been update to
+       account for the changed automake semantics.
+       * tests/Makefile.am (TESTS): Update.
+       * NEWS: Update.
+
 2011-10-08  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        dist: auxiliary files can be distributed from subdir Makefiles
diff --git a/NEWS b/NEWS
index 01442c34b16f6586e144c0a03c164b5ca4cb4441..765876d266f103afa151b8e0a38269321dfca8e3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -97,7 +97,7 @@ New in 1.11a:
   - Initial and still experimental support for the TAP test protocol is
     now provided.
 
-* Miscellaneous changes:
+* Changes related to distribution tarballs:
 
   - The `dist' and `dist-all' targets now can run compressors in parallel.
 
@@ -111,6 +111,13 @@ New in 1.11a:
     level via the XZ_OPT and BZIP2 envvars respectively.  E.g.,
     "make dist-xz XZ_OPT=-7" or "make dist-xz BZIP2=-5"
 
+  - Some auxiliary files that are automatically distributed by Automake
+    (e.g., `install-sh', or the `depcomp' script for packages compiling
+    C sources) might now be listed in the DIST_COMMON variable in many
+    Makefile.in files, rather than in the top-level one.
+
+* Miscellaneous changes:
+
   - Messages of types warning or error from `automake' and `aclocal' are now
     prefixed with the respective type, and presence of -Werror is noted.
 
index d5b39b741e438fa6536e2f0a5eb36b073e9c9c99..e3d2b9133a247fb2dc2f3a90c0c4e8777cdbed4a 100644 (file)
@@ -470,10 +470,6 @@ my %required_targets =
    'install-man' => 1,
   );
 
-# Set to 1 if this run will create the Makefile.in that distributes
-# the files in config_aux_dir.
-my $automake_will_process_aux_dir = 0;
-
 # The name of the Makefile currently being processed.
 my $am_file = 'BUG';
 \f
@@ -5545,37 +5541,6 @@ sub scan_autoconf_files ()
 
   locate_aux_dir ();
 
-  # Reorder @input_files so that the Makefile that distributes aux
-  # files is processed last.  This is important because each directory
-  # can require auxiliary scripts and we should wait until they have
-  # been installed before distributing them.
-
-  # The Makefile.in that distribute the aux files is the one in
-  # $config_aux_dir or the top-level Makefile.
-  my $auxdirdist = is_make_dir ($config_aux_dir) ? $config_aux_dir : '.';
-  my @new_input_files = ();
-  while (@input_files)
-    {
-      my $in = pop @input_files;
-      my @ins = split (/:/, $output_files{$in});
-      if (dirname ($ins[0]) eq $auxdirdist)
-       {
-         push @new_input_files, $in;
-         $automake_will_process_aux_dir = 1;
-       }
-      else
-       {
-         unshift @new_input_files, $in;
-       }
-    }
-  @input_files = @new_input_files;
-
-  # If neither the auxdir/Makefile nor the ./Makefile are generated
-  # by Automake, we won't distribute the aux files anyway.  Assume
-  # the user know what (s)he does, and pretend we will distribute
-  # them to disable the error in require_file_internal.
-  $automake_will_process_aux_dir = 1 if ! is_make_dir ($auxdirdist);
-
   # Look for some files we need.  Always check for these.  This
   # check must be done for every run, even those where we are only
   # looking at a subdir Makefile.  We must set relative_dir for
@@ -7608,16 +7573,17 @@ sub locate_aux_dir ()
 
 # &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
 # --------------------------------------------------
-# See if we want to push this file onto dist_common.  This function
-# encodes the rules for deciding when to do so.
+# Push the given file onto DIST_COMMON.
 sub maybe_push_required_file
 {
   my ($dir, $file, $fullfile) = @_;
 
+  # If the file to be distributed is in the same directory of the
+  # currently processed Makefile.am, then we want to distribute it
+  # from this same Makefile.am.
   if ($dir eq $relative_dir)
     {
       push_dist_common ($file);
-      return 1;
     }
   # This is needed to allow a construct in a non-top-level Makefile.am
   # to require a file in the build-aux directory (see at least the test
@@ -7628,7 +7594,20 @@ sub maybe_push_required_file
     {
       # FIXME: this breaks serialization of threaded automake :-(
       push_dist_common ("$am_config_aux_dir/$file");
-      return 1;
+    }
+  # FIXME: another spacial case, for AC_LIBOBJ/AC_LIBSOURCE support.
+  # We probably need some refactoring of this function and its callers,
+  # to have a more explicit and systematic handling of all the special
+  # cases; but, since there are only two of them, this is low-priority
+  # ATM.
+  elsif ($config_libobj_dir && $dir eq $config_libobj_dir)
+    {
+      # Avoid unsightly '/.'s.
+      my $am_config_libobj_dir =
+        '$(top_srcdir)' .
+        ($config_libobj_dir eq '.' ? "" : "/$config_libobj_dir");
+      $am_config_libobj_dir =~ s|/*$||;
+      push_dist_common ("$am_config_libobj_dir/$file");
     }
   elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
     {
@@ -7666,9 +7645,12 @@ sub maybe_push_required_file
        if $dir =~ m,^\.\.(?:$|/),;
 
       push_dist_common ($fullfile);
-      return 1;
     }
-  return 0;
+  else
+    {
+      prog_error "a Makefile in relative directory $relative_dir " .
+                 "can't add files in directory $dir to DIST_COMMON";
+    }
 }
 
 
@@ -7774,23 +7756,7 @@ sub require_file_internal ($$$@)
                        }
                      set_dir_cache_file ($dir, $file);
                    }
-
-                 if (! maybe_push_required_file (dirname ($fullfile),
-                                                 $file, $fullfile))
-                   {
-                     if (! $found_it && ! $automake_will_process_aux_dir)
-                       {
-                         # We have added the file but could not push it
-                         # into DIST_COMMON, probably because this is
-                         # an auxiliary file and we are not processing
-                         # the top level Makefile.  Furthermore Automake
-                         # hasn't been asked to create the Makefile.in
-                         # that distributes the aux dir files.
-                         error ($where, 'please rerun automake without '
-                                . "Makefile arguments\n"
-                                . "so $fullfile gets distributed");
-                       }
-                   }
+                 maybe_push_required_file ($dir, $file, $fullfile);
                }
              else
                {
@@ -8483,11 +8449,6 @@ sub get_number_of_threads
   # It doesn't make sense to use more threads than makefiles,
   my $max_threads = @input_files;
 
-  # but a single worker thread is helpful for exposing bugs.
-  if ($automake_will_process_aux_dir && $max_threads > 1)
-    {
-      $max_threads--;
-    }
   if ($nthreads > $max_threads)
     {
       $nthreads = $max_threads;
@@ -8511,18 +8472,11 @@ sub handle_makefiles_threaded ($)
 {
   my ($nthreads) = @_;
 
-  my @queued_input_files = @input_files;
-  my $last_input_file = undef;
-  if ($automake_will_process_aux_dir)
-    {
-      $last_input_file = pop @queued_input_files;
-    }
-
   # The file queue distributes all makefiles, the message queues
   # collect all serializations needed for respective files.
   my $file_queue = Thread::Queue->new;
   my %msg_queues;
-  foreach my $file (@queued_input_files)
+  foreach my $file (@input_files)
     {
       $msg_queues{$file} = Thread::Queue->new;
     }
@@ -8548,12 +8502,12 @@ sub handle_makefiles_threaded ($)
        });
     }
 
-  # Queue all normal makefiles.
-  verb "queuing " . @queued_input_files . " input files";
-  $file_queue->enqueue (@queued_input_files, (undef) x @threads);
+  # Queue all makefiles.
+  verb "queuing " . @input_files . " input files";
+  $file_queue->enqueue (@input_files, (undef) x @threads);
 
   # Collect and process serializations.
-  foreach my $file (@queued_input_files)
+  foreach my $file (@input_files)
     {
       verb "dequeuing messages for " . $file;
       reset_local_duplicates ();
@@ -8581,13 +8535,6 @@ sub handle_makefiles_threaded ($)
       $exit_code = $exit_thread[0]
        if ($exit_thread[0] > $exit_code);
     }
-
-  # The master processes the last file.
-  if ($automake_will_process_aux_dir)
-    {
-      verb "processing last input file";
-      handle_makefile ($last_input_file);
-    }
 }
 
 ################################################################
index 8fdec80f5347675d9f3be80b2d2dd641d42d9c29..6918aed7680504d85b0a94455e4671a7ce5b981d 100644 (file)
@@ -412,7 +412,6 @@ distcom2.test \
 distcom3.test \
 distcom4.test \
 distcom5.test \
-distcom6.test \
 distcom-subdir.test \
 distdir.test \
 distlinks.test \
index dbe4621bb088cbf93680e7449b47ea2030adc607..3436d4e41cf2b4cfc8f66711718edbc3dd47fd81 100644 (file)
@@ -676,7 +676,6 @@ distcom2.test \
 distcom3.test \
 distcom4.test \
 distcom5.test \
-distcom6.test \
 distcom-subdir.test \
 distdir.test \
 distlinks.test \
index e093e069eccd644ea6ae3f2274e4e99591b5aa02..7dd020d8be8901aaf89e6b1a8df65b0bfc71cb0e 100755 (executable)
@@ -15,9 +15,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test to make sure that depcomp and compile are added to DIST_COMMON
-# From Pavel Roskin.
-# Please keep this in sync with sister test 'distcom6.test'.
+# Test to make sure that depcomp and compile are added to DIST_COMMON.
+# Report from Pavel Roskin.  Report of problems with `--no-force' from
+# Scott James Remnant (Debian #206299)
 
 . ./defs || Exit 1
 
@@ -41,29 +41,45 @@ foo_SOURCES = foo.c
 foo_CFLAGS = -DBAR
 END
 
-rm -f compile depcomp
-
 $ACLOCAL
-$AUTOMAKE --add-missing
-
-test -f compile
-test -f depcomp
-
-sed -n -e '/^DIST_COMMON =.*\\$/ {
-   :loop
-   p
-   n
-   t clear
-   :clear
-   s/\\$/\\/
-   t loop
-   p
-   n
-   }' -e 's/$/ /' -e '/^DIST_COMMON =/p' Makefile.in > dc.txt
-
-cat dc.txt # might be useful for debugging
-
-$FGREP ' compile ' dc.txt
-$FGREP ' depcomp ' dc.txt
+
+rm -f compile depcomp Makefile.in subdir/Makefile.in dc.txt subdir/dc.txt
+
+for opt in '' --no-force; do
+
+  $AUTOMAKE $opt --add-missing
+
+  test -f compile
+  test -f depcomp
+
+  for dir in . subdir; do
+    # FIXME: the logic of this check and other similar ones in other
+    # FIXME: `distcom*.test' files should be factored out in a common
+    # FIXME: subroutine in `defs'...
+    sed -n -e "
+      /^DIST_COMMON =.*\\\\$/ {
+        :loop
+        p
+        n
+        t clear
+        :clear
+        s/\\\\$/\\\\/
+        t loop
+        s/$/ /
+        s/[$tab ][$tab ]*/ /g
+        p
+        n
+      }" $dir/Makefile.in > $dir/dc.txt
+  done
+
+  cat dc.txt # For debugging.
+  cat subdir/dc.txt # Likewise.
+
+  $FGREP ' $(top_srcdir)/depcomp ' subdir/dc.txt
+  # The `compile' script will be listed in the DIST_COMMON of the top-level
+  # Makefile because it's required in configure.in (by AM_PROG_CC_C_O).
+  $FGREP ' $(top_srcdir)/compile ' dc.txt || $FGREP ' compile ' dc.txt
+
+done
 
 :
diff --git a/tests/distcom6.test b/tests/distcom6.test
deleted file mode 100755 (executable)
index fd7f0ab..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2003, 2004, 2006, 2010, 2011 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, see <http://www.gnu.org/licenses/>.
-
-# Test to make sure that depcomp and compile required in subdirectories
-# are added to the top-level DIST_COMMON even with --no-force.
-# This is similar to distcom2.test, but with --no-force added.
-# Report from Scott James Remnant (Debian #206299).
-# Please keep this in sync with sister test 'distcom2.test'.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_CONFIG_FILES([subdir/Makefile])
-AC_OUTPUT
-END
-
-cat > Makefile.am << 'END'
-SUBDIRS = subdir
-END
-
-mkdir subdir
-: > subdir/foo.c
-
-cat > subdir/Makefile.am << 'END'
-noinst_PROGRAMS = foo
-foo_SOURCES = foo.c
-foo_CFLAGS = -DBAR
-END
-
-rm -f compile depcomp
-
-$ACLOCAL
-$AUTOMAKE --add-missing --no-force
-
-test -f compile
-test -f depcomp
-
-sed -n -e '/^DIST_COMMON =.*\\$/ {
-   :loop
-   p
-   n
-   t clear
-   :clear
-   s/\\$/\\/
-   t loop
-   p
-   n
-   }' -e 's/$/ /' -e '/^DIST_COMMON =/p' Makefile.in > dc.txt
-
-cat dc.txt # might be useful for debugging
-
-$FGREP ' compile ' dc.txt
-$FGREP ' depcomp ' dc.txt
-
-:
index bc495b5b543c99e967381105f1cc7abb6590e25a..2f2a3d6c1312bb055691016c6222c576eb9097eb 100755 (executable)
@@ -31,13 +31,17 @@ AUTOMAKE_OPTIONS = subdir-objects
 noinst_LIBRARIES = libtu.a
 libtu_a_SOURCES =
 libtu_a_LIBADD = $(LIBOBJS)
-check-local: distdir
-       ls -l $(srcdir)/* $(builddir)/* $(distdir)/*
+## Hack with this variable ans with extra make recursion in the check-local
+## rule are required for when we move this Makefile in a subdir, later.
+my_distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)
+check-local:
+       (cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) distdir)
+       ls -l $(top_srcdir)/* $(top_builddir)/* $(my_distdir)/*
        test -f libtu.a
-       test ! -r $(srcdir)/foobar.c
-       test -f $(srcdir)/libobj-dir/foobar.c
-       test ! -r $(distdir)/foobar.c
-       test -f $(distdir)/libobj-dir/foobar.c
+       test ! -r $(top_srcdir)/foobar.c
+       test -f $(top_srcdir)/libobj-dir/foobar.c
+       test ! -r $(my_distdir)/foobar.c
+       test -f $(my_distdir)/libobj-dir/foobar.c
        $(AR) t libtu.a
        $(AR) t libtu.a | grep foobar
 END
@@ -57,4 +61,30 @@ $MAKE
 $MAKE check
 $MAKE distcheck
 
+# Same check, but with the Makefile.am using $(LIBOBJS) not being
+# the top-level one.
+
+$MAKE distclean
+rm -rf autom4te*.cache aclocal.m4 configure
+
+mkdir sub
+mv -f Makefile.am sub
+echo SUBDIRS = sub > Makefile.am
+
+sed '/^AC_OUTPUT/i\
+AC_CONFIG_FILES([sub/Makefile])
+' configure.in > t
+mv -f t configure.in
+cat configure.in # For debugging.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+
 :