automake-patches
[Top][All Lists]
Advanced

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

Re: FYI: distinguish user/automake/system aclocal include patch more cle


From: Alexandre Duret-Lutz
Subject: Re: FYI: distinguish user/automake/system aclocal include patch more clearly
Date: Wed, 17 Nov 2004 23:36:43 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:

 adl> I'm checking this in.
 adl> This is some distant preparation for the --copy (or --update, or
 adl> --install, or whatever name we find) feature [*], in which
 adl> aclocal will have to distinguish whether an m4 file is local to
 adl> a package (subject to update), or is a third-party macro
 adl> (subject to copy), or is an automake macro (subject to nothing).

Let's propagate that information deeper, where when need to
decide whether to install/update a macro.  Incidentally this
helps to fix a discrepancy between aclocal and its doc: only
relative filename found via -I should be m4_included.

2004-11-17  Alexandre Duret-Lutz  <address@hidden>

        * aclocal.in (%file_type, FT_USER, FT_AUTOMAKE_SYSTEM): New variables.
        (scan_m4_dirs): New function, extracted from ...
        (scan_m4_files): ... here.  Call scan_m4_files three times, for each
        FT_ constant.
        (scan_file): Take a file type argument to update %file_type.
        (write_aclocal): Do not m4_include files that are not of type FT_USER.
        * tests/dirlist.test: Make sure m4_include is not used for --acdir
        files.

Index: aclocal.in
===================================================================
RCS file: /cvs/automake/automake/aclocal.in,v
retrieving revision 1.115
diff -u -r1.115 aclocal.in
--- aclocal.in  9 Nov 2004 20:24:41 -0000       1.115
+++ aclocal.in  17 Nov 2004 22:28:22 -0000
@@ -92,6 +92,12 @@
 # Map file names to file contents.
 my %file_contents = ();
 
+# Map file names to file types.
+my %file_type = ();
+use constant FT_USER => 1;
+use constant FT_AUTOMAKE => 2;
+use constant FT_SYSTEM => 3;
+
 # Map file names to included files (transitively closed).
 my %file_includes = ();
 
@@ -128,22 +134,14 @@
 
 ################################################################
 
-# Scan all the installed m4 files and construct a map.
-sub scan_m4_files (@)
+# scan_m4_dirs($TYPE, @DIRS)
+# --------------------------
+# Scan all M4 files installed in @DIRS for new macro definitions.
+# Register each file as of type $TYPE (one of the FT_* constants).
+sub scan_m4_dirs ($@)
 {
-  my @dirlist = @_;
-
-  # First, scan configure.ac.  It may contain macro definitions,
-  # or may include other files that define macros.
-  &scan_file ($configure_ac, 'aclocal');
+  my ($type, @dirlist) = @_;
 
-  # Then, scan acinclude.m4 if it exists.
-  if (-f 'acinclude.m4')
-    {
-      &scan_file ('acinclude.m4', 'aclocal');
-    }
-
-  # Finally, scan all files in our search path.
   foreach my $m4dir (@dirlist)
     {
       if (! opendir (DIR, $m4dir))
@@ -162,10 +160,29 @@
          next if $file eq 'aclocal.m4';
 
          my $fullfile = File::Spec->canonpath ("$m4dir/$file");
-           &scan_file ($fullfile, 'aclocal');
+           &scan_file ($type, $fullfile, 'aclocal');
        }
       closedir (DIR);
     }
+}
+
+# Scan all the installed m4 files and construct a map.
+sub scan_m4_files ()
+{
+  # First, scan configure.ac.  It may contain macro definitions,
+  # or may include other files that define macros.
+  &scan_file (FT_USER, $configure_ac, 'aclocal');
+
+  # Then, scan acinclude.m4 if it exists.
+  if (-f 'acinclude.m4')
+    {
+      &scan_file (FT_USER, 'acinclude.m4', 'aclocal');
+    }
+
+  # Finally, scan all files in our search paths.
+  scan_m4_dirs (FT_USER, @user_includes);
+  scan_m4_dirs (FT_AUTOMAKE, @automake_includes);
+  scan_m4_dirs (FT_SYSTEM, @system_includes);
 
   # Construct a new function that does the searching.  We use a
   # function (instead of just evaluating $search in the loop) so that
@@ -273,15 +290,17 @@
 # Point to the documentation for underquoted AC_DEFUN only once.
 my $underquoted_manual_once = 0;
 
-# scan_file ($FILE, $WHERE)
+# scan_file ($TYPE, $FILE, $WHERE)
 # -------------------------
 # Scan a single M4 file ($FILE), and all files it includes.
 # Return the list of included files.
+# $TYPE is one of FT_USER, FT_AUTOMAKE, or FT_SYSTEM, depending
+# on where the file comes from.
 # $WHERE is the location to use in the diagnostic if the file
 # does not exist.
-sub scan_file ($$)
+sub scan_file ($$$)
 {
-  my ($file, $where) = @_;
+  my ($type, $file, $where) = @_;
   my $base = dirname $file;
 
   # Do not scan the same file twice.
@@ -291,6 +310,8 @@
 
   unshift @file_order, $file;
 
+  $file_type{$file} = $type;
+
   fatal "$where: file `$file' does not exist" if ! -e $file;
 
   my $fh = new Automake::XFile $file;
@@ -356,7 +377,8 @@
   # With Perl 5.8.2 it undefines @inc_files.
   my @copy = @inc_files;
   my @all_inc_files = (@inc_files,
-                      map { scan_file ($_, "$file:$inc_lines{$_}") } @copy);
+                      map { scan_file ($type, $_,
+                                       "$file:$inc_lines{$_}") } @copy);
   $file_includes{$file} = address@hidden;
   return @all_inc_files;
 }
@@ -464,13 +486,16 @@
        if (exists $map_traced_defs{$m}
            && $map{$m} eq $map_traced_defs{$m});
     }
+  # Always include acinclude.m4, even if it does not appear to be used.
   $files{'acinclude.m4'} = 1 if -f 'acinclude.m4';
+  # Do not explicitly include a file that is already indirectly included.
   %files = strip_redundant_includes %files;
+  # Never include configure.ac :)
   delete $files{$configure_ac};
 
   for my $file (grep { exists $files{$_} } @file_order)
     {
-      # Check the time stamp of this file, and all files it includes.
+      # Check the time stamp of this file, and of all files it includes.
       for my $ifile ($file, @{$file_includes{$file}})
        {
          my $mtime = mtime $ifile;
@@ -480,7 +505,8 @@
       # If the file to add looks like outside the project, copy it
       # to the output.  The regex catches filenames starting with
       # things like `/', `\', or `c:\'.
-      if ($file =~ m,^(?:\w:)?[\\/],)
+      if ($file_type{$file} != FT_USER
+         || $file =~ m,^(?:\w:)?[\\/],)
        {
          $output .= $file_contents{$file} . "\n";
        }
@@ -681,7 +707,7 @@
 parse_WARNINGS;                    # Parse the WARNINGS environment variable.
 parse_arguments;
 $configure_ac = require_configure_ac;
-scan_m4_files (@user_includes, @automake_includes, @system_includes);
+scan_m4_files;
 scan_configure;
 if (! $exit_code)
   {
Index: tests/dirlist.test
===================================================================
RCS file: /cvs/automake/automake/tests/dirlist.test,v
retrieving revision 1.6
diff -u -r1.6 dirlist.test
--- tests/dirlist.test  14 Nov 2003 21:25:58 -0000      1.6
+++ tests/dirlist.test  17 Nov 2004 22:28:22 -0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2002, 2003  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -47,11 +47,17 @@
 
 $ACLOCAL
 $AUTOCONF
+
+# there should be no m4_include in aclocal.m4, even tho m4/dirlist contains
+# `./dirlist-test' as a relative directory.  Only -I directories are subject
+# to file inclusion.
+grep m4_include aclocal.m4 && exit 1
+
 grep 'GUILE-VERSION' configure
 
 # This bug can occur only when we do a VPATH build of Automake
-# (because of the `-I' passed to aclocal in tests/defs) but it's
-# OK because this is what `make distcheck' does.
+# (because of the `-I' passed to aclocal in tests/defs/aclocal.in) but
+# it's OK because VPATH builds are done by `make distcheck'.
 grep 'I should not be included' configure && exit 1
 
 :

-- 
Alexandre Duret-Lutz





reply via email to

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