tap/awk: avoid redirection issues with bash 3.2 and earlier
[platform/upstream/automake.git] / aclocal.in
index 4b63c1a..93ed5eb 100644 (file)
@@ -54,9 +54,12 @@ $perl_threads = 0;
 # Include paths for searching macros.  We search macros in this order:
 # user-supplied directories first, then the directory containing the
 # automake macros, and finally the system-wide directories for
-# third-party macro.  @user_includes can be augmented with -I.
-# @system_includes can be augmented with the `dirlist' file.  Also
-# --acdir will reset both @automake_includes and @system_includes.
+# third-party macros.
+# @user_includes can be augmented with -I.
+# @automake_includes can be reset with the `--automake-acdir' option.
+# @system_includes can be augmented with the `dirlist' file or the
+# ACLOCAL_PATH environment variable, and reset with the `--system-acdir'
+# option.
 my @user_includes = ();
 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
 my @system_includes = ('@datadir@/aclocal');
@@ -184,8 +187,7 @@ sub check_acinclude ()
   foreach my $key (keys %map)
     {
       # FIXME: should print line number of acinclude.m4.
-      msg ('syntax', "warning: macro `$key' defined in "
-          . "acinclude.m4 but never used")
+      msg ('syntax', "macro `$key' defined in acinclude.m4 but never used")
        if $map{$key} eq 'acinclude.m4' && ! exists $macro_seen{$key};
     }
 }
@@ -436,7 +438,7 @@ sub scan_configure_dep ($)
          # Make this just a warning, because we do not know whether
          # the macro is actually used (it could be called conditionally).
          msg ('unsupported', "$file:$line",
-              "warning: macro `$2' not found in library");
+              "macro `$2' not found in library");
        }
     }
 
@@ -508,7 +510,7 @@ sub scan_file ($$$)
          if ($number !~ /$serial_number_rx/go)
            {
              msg ('syntax', "$file:$.",
-                  "warning: ill-formed serial number `$number', "
+                  "ill-formed serial number `$number', "
                   . "expecting a version string with only digits and dots");
            }
          elsif ($defun_seen)
@@ -560,9 +562,9 @@ sub scan_file ($$$)
          $defun_seen = 1;
          if (! defined $1)
            {
-             msg ('syntax', "$file:$.", "warning: underquoted definition of $2"
-                  . "\n  run info '(automake)Extending aclocal'\n"
-                  . "  or see http://sources.redhat.com/automake/"
+             msg ('syntax', "$file:$.", "underquoted definition of $2"
+                  . "\n  run info Automake 'Extending aclocal'\n"
+                  . "  or see http://www.gnu.org/software/automake/manual/"
                   . "automake.html#Extending-aclocal")
                unless $underquoted_manual_once;
              $underquoted_manual_once = 1;
@@ -872,21 +874,23 @@ sub usage ($)
 {
   my ($status) = @_;
 
-  print "Usage: aclocal [OPTIONS] ...
+  print "Usage: aclocal [OPTION]...
 
 Generate `aclocal.m4' by scanning `configure.ac' or `configure.in'
 
 Options:
-      --acdir=DIR           directory holding config files (for debugging)
+      --automake-acdir=DIR  directory holding automake-provided m4 files
+      --system-acdir=DIR    directory holding third-party system-wide files
       --diff[=COMMAND]      run COMMAND [diff -u] on M4 files that would be
-                              changed (implies --install and --dry-run)
+                            changed (implies --install and --dry-run)
       --dry-run             pretend to, but do not actually update any file
       --force               always update output file
       --help                print this help, then exit
   -I DIR                    add directory to search list for .m4 files
       --install             copy third-party files to the first -I directory
       --output=FILE         put output in FILE (default aclocal.m4)
-      --print-ac-dir        print name of directory holding m4 files, then exit
+      --print-ac-dir        print name of directory holding system-wide
+                              third-party m4 files, then exit
       --verbose             don't be silent
       --version             print version number, then exit
   -W, --warnings=CATEGORY   report the warnings falling in CATEGORY
@@ -923,6 +927,15 @@ EOF
   exit 0;
 }
 
+# Using --acdir overrides both the automake (versioned) directory and
+# the public (unversioned) system directory.  This usage is obsolete.
+sub handle_acdir_option ($$)
+{
+  msg 'obsolete', '', "`--acdir' is deprecated\n";
+  @system_includes = ($_[1]);
+  @automake_includes = ();
+}
+
 # Parse command line.
 sub parse_arguments ()
 {
@@ -931,12 +944,9 @@ sub parse_arguments ()
 
   my %cli_options =
     (
-     'acdir=s'         => sub # Setting --acdir overrides both the
-                             { # automake (versioned) directory and the
-                              # public (unversioned) system directory.
-                              @automake_includes = ();
-                              @system_includes = ($_[1])
-                            },
+     'acdir=s'         => \&handle_acdir_option,
+     'system-acdir=s'  => sub { shift; @system_includes = @_; },
+     'automake-acdir=s'        => sub { shift; @automake_includes = @_; },
      'diff:s'          => \$diff_command,
      'dry-run'         => \$dry_run,
      'force'           => \$force_output,
@@ -987,13 +997,13 @@ sub parse_arguments ()
        }
       if (exists $argopts{$ARGV[0]})
        {
-         fatal ("option `$ARGV[0]' requires an argument\n"
-                . "Try `$0 --help' for more information.");
+         fatal ("option `$ARGV[0]' requires an argument.\n"
+                . "Try `$0 --help' for more information");
        }
       else
        {
          fatal ("unrecognized option `$ARGV[0]'\n"
-                . "Try `$0 --help' for more information.");
+                . "Try `$0 --help' for more information");
        }
     }
 
@@ -1014,37 +1024,40 @@ sub parse_arguments ()
   if ($install && !@user_includes)
     {
       fatal ("--install should copy macros in the directory indicated by the"
-            . "\nfirst -I option, but no -I was supplied.");
+            . "\nfirst -I option, but no -I was supplied");
     }
 
-  if (! -d $system_includes[0])
+  # Finally, adds any directory listed in the `dirlist' file.
+  if (open (DIRLIST, "$system_includes[0]/dirlist"))
     {
-      # By default $(datadir)/aclocal doesn't exist.  We don't want to
-      # get an error in the case where we are searching the default
-      # directory and it hasn't been created.  (We know
-      # @system_includes has its default value if @automake_includes
-      # is not empty, because --acdir is the only way to change this.)
-      @system_includes = () if @automake_includes;
+      while (<DIRLIST>)
+        {
+          # Ignore '#' lines.
+          next if /^#/;
+          # strip off newlines and end-of-line comments
+          s/\s*\#.*$//;
+          chomp;
+          foreach my $dir (glob)
+            {
+              push (@system_includes, $dir) if -d $dir;
+            }
+        }
+      close (DIRLIST);
     }
-  else
+}
+
+# Add any directory listed in the `ACLOCAL_PATH' environment variable
+# to the list of system include directories.
+sub parse_ACLOCAL_PATH ()
+{
+  return if not defined $ENV{"ACLOCAL_PATH"};
+  # Directories in ACLOCAL_PATH should take precedence over system
+  # directories, so we use unshift.  However, directories that
+  # come first in ACLOCAL_PATH take precedence over directories
+  # coming later, which is why the result of split is reversed.
+  foreach my $dir (reverse split /:/, $ENV{"ACLOCAL_PATH"})
     {
-      # Finally, adds any directory listed in the `dirlist' file.
-      if (open (DIRLIST, "$system_includes[0]/dirlist"))
-       {
-         while (<DIRLIST>)
-           {
-             # Ignore '#' lines.
-             next if /^#/;
-             # strip off newlines and end-of-line comments
-             s/\s*\#.*$//;
-             chomp;
-             foreach my $dir (glob)
-               {
-                 push (@system_includes, $dir) if -d $dir;
-               }
-           }
-         close (DIRLIST);
-       }
+      unshift (@system_includes, $dir) if $dir ne '' && -d $dir;
     }
 }
 
@@ -1052,6 +1065,7 @@ sub parse_arguments ()
 
 parse_WARNINGS;                    # Parse the WARNINGS environment variable.
 parse_arguments;
+parse_ACLOCAL_PATH;
 $configure_ac = require_configure_ac;
 
 # We may have to rerun aclocal if some file have been installed, but
@@ -1065,7 +1079,7 @@ my $loop = 0;
 while (1)
   {
     ++$loop;
-    prog_error "Too many loops." if $loop > 2;
+    prog_error "too many loops" if $loop > 2;
 
     reset_maps;
     scan_m4_files;