]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* lib/Automake/Configure_ac.pm (&find_configure_ac)
authorAkim Demaille <akim@epita.fr>
Thu, 21 Aug 2003 08:49:25 +0000 (08:49 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 21 Aug 2003 08:49:25 +0000 (08:49 +0000)
(&require_configure_ac): Accept an optional directory argument.
($configure_ac): Remove.
* aclocal.in, automake.in ($configure_ac): New.
* lib/Automake/Variable.pm: Don't use $configure_ac, just
configure.ac.

ChangeLog
aclocal.in
automake.in
lib/Automake/Configure_ac.pm
lib/Automake/Variable.pm

index b82a4e72b6cd9a3e018f00611e5708f9db11d412..b5d850c2ab55b59d6c554c31a5b450d9f550bb8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-21  Akim Demaille  <akim@epita.fr>
+
+       * lib/Automake/Configure_ac.pm (&find_configure_ac)
+       (&require_configure_ac): Accept an optional directory argument.
+       ($configure_ac): Remove.
+       * aclocal.in, automake.in ($configure_ac): New.
+       * lib/Automake/Variable.pm: Don't use $configure_ac, just
+       configure.ac.
+
 2003-08-20  Akim Demaille  <akim@epita.fr>
 
        * lib/Automake/FileUtils.pm: More perldoc.
index 0bb7ea84f4def5dbc24347707d786bdf4a44018b..f0df416351b60fd83da88cd065be7ba3d950eefd 100644 (file)
@@ -52,6 +52,9 @@ $default_dirlist = "$default_acdir/dirlist";
 
 # Some globals.
 
+# configure.ac or configure.in.
+my $configure_ac = require_configure_ac;
+
 # Exit status.
 $exit_status = 0;
 
@@ -235,42 +238,40 @@ sub parse_arguments (@)
 
 sub scan_configure ()
 {
-    require_configure_ac;
-
-    if (! open (CONFIGURE, $configure_ac))
-      {
-       print STDERR "aclocal: couldn't open `$configure_ac': $!\n";
-       exit 1;
-      }
+  if (! open (CONFIGURE, $configure_ac))
+    {
+      print STDERR "aclocal: couldn't open `$configure_ac': $!\n";
+      exit 1;
+    }
 
-    my $mtime = mtime $configure_ac;
-    $greatest_mtime = $mtime if $greatest_mtime < $mtime;
+  my $mtime = mtime $configure_ac;
+  $greatest_mtime = $mtime if $greatest_mtime < $mtime;
 
-    # Make sure we include acinclude.m4 if it exists.
-    if (-f 'acinclude.m4')
+  # Make sure we include acinclude.m4 if it exists.
+  if (-f 'acinclude.m4')
     {
-       &add_file ('acinclude.m4');
+      &add_file ('acinclude.m4');
     }
 
-    while (<CONFIGURE>)
+  while (<CONFIGURE>)
     {
-       # Remove comments from current line.
-       s/\bdnl\b.*$//;
-       s/\#.*$//;
-
-       # Search for things we know about.  The "search" sub is
-       # constructed dynamically by scan_m4_files.  The last
-       # parenthethical match makes sure we don't match things that
-       # look like macro assignments or AC_SUBSTs.
-       if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
+      # Remove comments from current line.
+      s/\bdnl\b.*$//;
+      s/\#.*$//;
+
+      # Search for things we know about.  The "search" sub is
+      # constructed dynamically by scan_m4_files.  The last
+      # parenthethical match makes sure we don't match things that
+      # look like macro assignments or AC_SUBSTs.
+      if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
        {
-           # Macro not found, but AM_ prefix found.
-           warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
-           $exit_status = 1;
+         # Macro not found, but AM_ prefix found.
+         warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
+         $exit_status = 1;
        }
     }
 
-    close (CONFIGURE);
+  close (CONFIGURE);
 }
 
 ################################################################
@@ -369,56 +370,56 @@ sub add_macro ($)
 # Add a file to output.
 sub add_file ($)
 {
-    local ($file) = @_;
+  local ($file) = @_;
 
-    # Only add a file once.
-    return if ($file_seen{$file});
-    $file_seen{$file} = 1;
+  # Only add a file once.
+  return if ($file_seen{$file});
+  $file_seen{$file} = 1;
 
-    my $mtime = mtime $file;
-    $greatest_mtime = $mtime if $greatest_mtime < $mtime;
+  my $mtime = mtime $file;
+  $greatest_mtime = $mtime if $greatest_mtime < $mtime;
 
-    # If the file to add looks like path outside the project,
-    # copy it to the output.
-    # The regex catches filenames starting with things like
-    #   / \ c:\ ../ ./../ etc.
-    if ($file =~ m,^(?:(?:\w:)?[\\/]|(?:\.[\\/]+)*\.\.[\\/]),)
-      {
-       $output .= $file_contents{$file} . "\n";
-      }
-    else
-      {
-       # Otherwise, simply include the file.
-       $output .= "m4_include([$file])\n";
-      }
-    my (@rlist);
-    foreach (split ("\n", $file_contents{$file}))
+  # If the file to add looks like path outside the project,
+  # copy it to the output.
+  # The regex catches filenames starting with things like
+  #   / \ c:\ ../ ./../ etc.
+  if ($file =~ m,^(?:(?:\w:)?[\\/]|(?:\.[\\/]+)*\.\.[\\/]),)
+    {
+      $output .= $file_contents{$file} . "\n";
+    }
+  else
+    {
+      # Otherwise, simply include the file.
+      $output .= "m4_include([$file])\n";
+    }
+  my (@rlist);
+  foreach (split ("\n", $file_contents{$file}))
     {
-       # Remove comments from current line.
-       s/\bdnl\b.*$//;
-       s/\#.*$//;
+      # Remove comments from current line.
+      s/\bdnl\b.*$//;
+      s/\#.*$//;
 
-       if (/$ac_require_rx/g)
+      if (/$ac_require_rx/g)
        {
-           push (@rlist, $1 || $2);
+         push (@rlist, $1 || $2);
        }
 
-       # The search function is constructed dynamically by
-       # scan_m4_files.  The last parenthethical match makes sure we
-       # don't match things that look like macro assignments or
-       # AC_SUBSTs.
-       if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
+      # The search function is constructed dynamically by
+      # scan_m4_files.  The last parenthethical match makes sure we
+      # don't match things that look like macro assignments or
+      # AC_SUBSTs.
+      if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
        {
-           # Macro not found, but AM_ prefix found.
-           warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
-           $exit_status = 1;
+         # Macro not found, but AM_ prefix found.
+         warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
+         $exit_status = 1;
        }
     }
 
-    local ($macro);
-    foreach $macro (@rlist)
+  local ($macro);
+  foreach $macro (@rlist)
     {
-       &add_macro ($macro);
+      &add_macro ($macro);
     }
 }
 
index df61f28d2d83969353091e99930a8dec15caa3d3..a55f1a94b077a7b96b1586075a7503549c640f6c 100755 (executable)
@@ -288,6 +288,9 @@ my $force_missing = 0;
 ## Variables filled during files scanning.  ##
 ## ---------------------------------------- ##
 
+# Name of the configure.ac file.
+my $configure_ac = require_configure_ac;
+
 # Files found by scanning configure.ac for LIBOBJS.
 my %libsources = ();
 
@@ -3268,39 +3271,39 @@ sub handle_subdirs ()
 # &scan_aclocal_m4
 # ----------------
 # If aclocal.m4 creation is automated, return the list of its dependencies.
-sub scan_aclocal_m4
+sub scan_aclocal_m4 ()
 {
-    my $regen_aclocal = 0;
+  my $regen_aclocal = 0;
 
-    set_seen 'CONFIG_STATUS_DEPENDENCIES';
-    set_seen 'CONFIGURE_DEPENDENCIES';
+  set_seen 'CONFIG_STATUS_DEPENDENCIES';
+  set_seen 'CONFIGURE_DEPENDENCIES';
 
-    if (-f 'aclocal.m4')
+  if (-f 'aclocal.m4')
     {
-       &push_dist_common ('aclocal.m4')
-         if $relative_dir eq '.';
-       &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
+      &push_dist_common ('aclocal.m4')
+       if $relative_dir eq '.';
+      &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
 
-       my $aclocal = new Automake::XFile "< aclocal.m4";
-       my $line = $aclocal->getline;
-       $regen_aclocal = $line =~ 'generated automatically by aclocal';
+      my $aclocal = new Automake::XFile "< aclocal.m4";
+      my $line = $aclocal->getline;
+      $regen_aclocal = $line =~ 'generated automatically by aclocal';
     }
 
-    my @ac_deps = ();
+  my @ac_deps = ();
 
-    if (set_seen ('ACLOCAL_M4_SOURCES'))
+  if (set_seen ('ACLOCAL_M4_SOURCES'))
     {
-       push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
-       msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
-                "`ACLOCAL_M4_SOURCES' is obsolete.\n"
-                . "It should be safe to simply remove it.");
+      push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
+      msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
+              "`ACLOCAL_M4_SOURCES' is obsolete.\n"
+              . "It should be safe to simply remove it.");
     }
 
-    # Note that it might be possible that aclocal.m4 doesn't exist but
-    # should be auto-generated.  This case probably isn't very
-    # important.
+  # Note that it might be possible that aclocal.m4 doesn't exist but
+  # should be auto-generated.  This case probably isn't very
+  # important.
 
-    return ($regen_aclocal, @ac_deps);
+  return ($regen_aclocal, @ac_deps);
 }
 
 
@@ -3363,7 +3366,7 @@ sub handle_configure ($$@)
 
   my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
 
-  my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
+  my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
 
 
   define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
@@ -4169,39 +4172,39 @@ my %make_list;
 # -------------------------------------------
 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
 # (or AC_OUTPUT).
-sub scan_autoconf_config_files
+sub scan_autoconf_config_files ($)
 {
-    my ($config_files) = @_;
-    # Look at potential Makefile.am's.
-    foreach (split ' ', $config_files)
+  my ($config_files) = @_;
+  # Look at potential Makefile.am's.
+  foreach (split ' ', $config_files)
     {
-        # Must skip empty string for Perl 4.
-        next if $_ eq "\\" || $_ eq '';
+      # Must skip empty string for Perl 4.
+      next if $_ eq "\\" || $_ eq '';
 
-        # Handle $local:$input syntax.  Note that we ignore
-        # every input file past the first, though we keep
-        # those around for later.
-        my ($local, $input, @rest) = split (/:/);
-        if (! $input)
+      # Handle $local:$input syntax.  Note that we ignore
+      # every input file past the first, though we keep
+      # those around for later.
+      my ($local, $input, @rest) = split (/:/);
+      if (! $input)
         {
-            $input = $local;
+         $input = $local;
         }
-        else
+      else
         {
-            # FIXME: should be error if .in is missing.
-            $input =~ s/\.in$//;
+         # FIXME: should be error if .in is missing.
+         $input =~ s/\.in$//;
         }
 
-        if (-f $input . '.am')
+      if (-f $input . '.am')
         {
-            # We have a file that automake should generate.
-            $make_list{$input} = join (':', ($local, @rest));
+         # We have a file that automake should generate.
+         $make_list{$input} = join (':', ($local, @rest));
         }
-        else
+      else
         {
-            # We have a file that automake should cause to be
-            # rebuilt, but shouldn't generate itself.
-            push (@other_input_files, $_);
+         # We have a file that automake should cause to be
+         # rebuilt, but shouldn't generate itself.
+         push (@other_input_files, $_);
         }
     }
 }
@@ -4383,68 +4386,68 @@ sub scan_autoconf_traces ($)
 # Check whether we use `configure.ac' or `configure.in'.
 # Scan it (and possibly `aclocal.m4') for interesting things.
 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
-sub scan_autoconf_files
+sub scan_autoconf_files ()
 {
-    # Reinitialize libsources here.  This isn't really necessary,
-    # since we currently assume there is only one configure.ac.  But
-    # that won't always be the case.
-    %libsources = ();
+  # Reinitialize libsources here.  This isn't really necessary,
+  # since we currently assume there is only one configure.ac.  But
+  # that won't always be the case.
+  %libsources = ();
 
-    scan_autoconf_traces (require_configure_ac);
+  scan_autoconf_traces ($configure_ac);
 
-    # Set input and output files if not specified by user.
-    if (! @input_files)
+  # Set input and output files if not specified by user.
+  if (! @input_files)
     {
-       @input_files = sort keys %make_list;
-       %output_files = %make_list;
+      @input_files = sort keys %make_list;
+      %output_files = %make_list;
     }
 
-    @configure_input_files = sort keys %make_list;
+  @configure_input_files = sort keys %make_list;
 
-    if (! $seen_init_automake)
-      {
-       err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
-               . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
-               . "\nthat aclocal.m4 is present in the top-level directory,\n"
-               . "and that aclocal.m4 was recently regenerated "
-               . "(using aclocal).");
-      }
-    else
-      {
-       if (! $seen_automake_version)
-         {
-           if (-f 'aclocal.m4')
-             {
-               error ($seen_init_automake,
-                      "your implementation of AM_INIT_AUTOMAKE comes from " .
-                      "an\nold Automake version.  You should recreate " .
-                      "aclocal.m4\nwith aclocal and run automake again.\n");
-             }
-           else
-             {
-               error ($seen_init_automake,
-                      "no proper implementation of AM_INIT_AUTOMAKE was " .
-                      "found,\nprobably because aclocal.m4 is missing...\n" .
-                      "You should run aclocal to create this file, then\n" .
-                      "run automake again.\n");
-             }
-         }
-      }
+  if (! $seen_init_automake)
+    {
+      err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
+             . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
+             . "\nthat aclocal.m4 is present in the top-level directory,\n"
+             . "and that aclocal.m4 was recently regenerated "
+             . "(using aclocal).");
+    }
+  else
+    {
+      if (! $seen_automake_version)
+       {
+         if (-f 'aclocal.m4')
+           {
+             error ($seen_init_automake,
+                    "your implementation of AM_INIT_AUTOMAKE comes from " .
+                    "an\nold Automake version.  You should recreate " .
+                    "aclocal.m4\nwith aclocal and run automake again.\n");
+           }
+         else
+           {
+             error ($seen_init_automake,
+                    "no proper implementation of AM_INIT_AUTOMAKE was " .
+                    "found,\nprobably because aclocal.m4 is missing...\n" .
+                    "You should run aclocal to create this file, then\n" .
+                    "run automake again.\n");
+           }
+       }
+    }
 
-    # 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 so that
-    # the file-finding machinery works.
-    # FIXME: Is this broken because it needs dynamic scopes.
-    # My tests seems to show it's not the case.
-    $relative_dir = '.';
-    require_conf_file ($configure_ac, FOREIGN,
-                      'install-sh', 'mkinstalldirs', 'missing');
-    err_am "`install.sh' is an anachronism; use `install-sh' instead"
-      if -f $config_aux_path[0] . '/install.sh';
+  # 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 so that
+  # the file-finding machinery works.
+  # FIXME: Is this broken because it needs dynamic scopes.
+  # My tests seems to show it's not the case.
+  $relative_dir = '.';
+  require_conf_file ($configure_ac, FOREIGN,
+                    'install-sh', 'mkinstalldirs', 'missing');
+  err_am "`install.sh' is an anachronism; use `install-sh' instead"
+    if -f $config_aux_path[0] . '/install.sh';
 
-    # Preserve dist_common for later.
-    $configure_dist_common = variable_value ('DIST_COMMON') || '';
+  # Preserve dist_common for later.
+  $configure_dist_common = variable_value ('DIST_COMMON') || '';
 }
 
 ################################################################
@@ -6462,9 +6465,11 @@ sub push_dist_common
 
 ################################################################
 
+# generate_makefile ($OUTPUT, $MAKEFILE)
+# --------------------------------------
 # Generate a Makefile.in given the name of the corresponding Makefile and
 # the name of the file output by config.status.
-sub generate_makefile
+sub generate_makefile ($$)
 {
   my ($output, $makefile) = @_;
 
index 6798ba181556beaab7c49a8b9489f6d65b405d93..f8523dc81844d820f702fb31c4ee9d585657112d 100644 (file)
@@ -25,7 +25,7 @@ use Automake::ChannelDefs;
 use vars qw (@ISA @EXPORT);
 
 @ISA = qw (Exporter);
-@EXPORT = qw ($configure_ac &find_configure_ac &require_configure_ac);
+@EXPORT = qw (&find_configure_ac &require_configure_ac);
 
 =head1 NAME
 
@@ -42,37 +42,45 @@ Automake::Configure_ac - Locate configure.ac or configure.in.
   # Likewise, but bomb out if the file does not exist.
   my $filename = require_configure_ac;
 
-In both cases, the name of the file found is also put in the
-C<$configure_ac> global variable.
+  # Likewise, but in $dir.
+  my $filename = find_configure_ac ($dir);
+  my $filename = require_configure_ac ($dir);
 
 =cut
 
-use vars '$configure_ac';
-
-sub find_configure_ac ()
+sub find_configure_ac (;@)
 {
-  if (-f 'configure.ac')
+  my ($directory) = @_;
+  $directory ||= '.';
+  my $configure_ac =
+    File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.ac'));
+  my $configure_in =
+    File::Spec->canonpath (File::Spec->catfile ($directory, 'configure.in'));
+
+  if (-f $configure_ac)
     {
-      if (-f 'configure.in')
+      if (-f $configure_in)
        {
          msg ('unsupported',
-              "`configure.ac' and `configure.in' both present.\n"
-              . "proceeding with `configure.ac'.");
+              "`$configure_ac' and `$configure_in' both present.\n"
+              . "proceeding with `$configure_ac'.");
        }
-      $configure_ac = 'configure.ac';
+      return $configure_ac
     }
   elsif (-f 'configure.in')
     {
-      $configure_ac = 'configure.in';
+      return $configure_in;
     }
   return $configure_ac;
 }
 
-sub require_configure_ac ()
+
+sub require_configure_ac (;$)
 {
+  my $res = find_configure_ac (@_);
   fatal "`configure.ac' or `configure.in' is required"
-    unless find_configure_ac;
-  return $configure_ac;
+    unless defined $res;
+  return $res
 }
 
 1;
index f993ca5a1dba6e26dc4e914e76254acf477a3142..e5d6a54f4ff0d697f72b3b86ce1735489be951b8 100644 (file)
@@ -179,6 +179,9 @@ my %_ac_macro_for_var =
    YACC => 'AC_PROG_YACC',
    );
 
+# The name of the configure.ac file.
+my $configure_ac = require_configure_ac;
+
 # Variables that can be overriden without complaint from -Woverride
 my %_silent_variable_override =
   (AR => 1,