autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix autoscan to not search config-subdirs


From: Ralf Wildenhues
Subject: Fix autoscan to not search config-subdirs
Date: Tue, 28 Mar 2006 21:47:39 +0200
User-agent: Mutt/1.5.9i

The patch below fixes the autoscan buglet reported a while ago.
So, if the user already has a working configure.ac, autoscan won't add
unnecessary checks of AC_CONFIG_FILES for stuff found in subpackages.

If configure.ac is present but not parseable (due to syntax errors, for
example), then parsing with Autom4te::XFile will cause an error before
configure.scan is output.  To prevent this, I chose to use plain open;
is that ok?

Also, it would be nice if somebody could look over my weak perl fu.
AC_CONFIG_SUBDIR([foo]) and AC_CONFIG_SUBDIR([./foo]) won't both be
recognized at the moment, also I don't know whether File::Find::name
always starts with `./' (but the test should expose that).  Also,
probably autoscan should be improved to only trace once?

Cheers,
Ralf

        * bin/autoscan.in (scan_configure_ac): New function to scan
        `configure.ac' before other files to compute a list of config
        subdirs to produce..
        (subdir_regex): ..this new global.
        (scan_file): Skip configure subdirectory trees.
        * tests/autoscan.at (autoscan): Unmark xfail.

Index: bin/autoscan.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autoscan.in,v
retrieving revision 1.104
diff -u -r1.104 autoscan.in
--- bin/autoscan.in     26 Mar 2006 21:27:56 -0000      1.104
+++ bin/autoscan.in     28 Mar 2006 19:42:02 -0000
@@ -47,7 +47,7 @@
 use File::Find;
 use strict;
 
-use vars qw(@cfiles @makefiles @shfiles %printed);
+use vars qw(@cfiles @makefiles @shfiles %printed $subdir_regex);
 
 # The kind of the words we are looking for.
 my @kinds = qw (function header identifier program
@@ -379,6 +379,14 @@
   return
     if -f "$_.in";
 
+  # Skip config subdirs.
+  if (defined $subdir_regex
+      && $File::Find::name =~ /^\.\/($subdir_regex)$/o)
+    {
+      $File::Find::prune = 1;
+      return;
+    }
+
   # Save $_ as Find::File requires it to be preserved.
   local $_ = $_;
 
@@ -407,6 +415,36 @@
 }
 
 
+# scan_configure_ac ($CONFIGURE_AC)
+# ---------------------------------
+# Pre-scan CONFIGURE_AC to avoid AC_CONFIG_SUBDIRS.
+sub scan_configure_ac ($)
+{
+  my ($configure_ac) = @_;
+  my @subdir;
+
+  my $trace_option =
+    join (' --trace=', '',
+          'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1');
+  verb "running: $autoconf $trace_option $configure_ac";
+  if (open TRACE, "$autoconf $trace_option $configure_ac|")
+    {
+      while (<TRACE>)
+       {
+         push @subdir, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/;
+       }
+      close TRACE
+        or warn "warning: could not analyze $configure_ac.\n";
+    }
+  else
+    {
+      warn "warning: could not open trace to $configure_ac: $!\n";
+    }
+
+  $subdir_regex = join ('|', map { quotemeta } @subdir);
+}
+
+
 # scan_files ()
 # -------------
 # Read through the files and collect lists of tokens in them
@@ -629,6 +667,10 @@
 
 my $configure_ac = find_configure_ac;
 init_tables;
+if (-f $configure_ac)
+  {
+    scan_configure_ac ($configure_ac);
+  }
 scan_files;
 output ('configure.scan');
 if (-f $configure_ac)
Index: tests/autoscan.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/autoscan.at,v
retrieving revision 1.2
diff -u -r1.2 autoscan.at
--- tests/autoscan.at   16 Aug 2005 08:17:46 -0000      1.2
+++ tests/autoscan.at   27 Mar 2006 19:08:04 -0000
@@ -20,7 +20,6 @@
 # 02110-1301, USA.
 
 AT_SETUP([autoscan])
-AT_XFAIL_IF(:)
 
 AT_DATA([Makefile.am],
 [[SUBDIRS = subpkg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]