]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Implement `autom4te --freeze'.
authorAkim Demaille <akim@epita.fr>
Tue, 5 Feb 2002 08:12:46 +0000 (08:12 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 5 Feb 2002 08:12:46 +0000 (08:12 +0000)
* bin/autom4te.in (&freeze): New.
* lib/autoconf/autoconf.m4, lib/autotest/general.m4,
* lib/m4sugar/m4sh.m4: Don't include files given by autom4te.

ChangeLog
bin/autom4te.in
lib/autoconf/autoconf.m4
lib/autotest/autotest.m4
lib/m4sugar/m4sh.m4

index c2eef4af8c4f5191748666f25dc89ed5c72c54eb..970b67c9e5ff4e82fe4329e954ab3f0442f3c4ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2002-02-05  Akim Demaille  <akim@epita.fr>
+
+       Implement `autom4te --freeze'.
+
+       * bin/autom4te.in (&freeze): New.
+       * lib/autoconf/autoconf.m4, lib/autotest/general.m4,
+       * lib/m4sugar/m4sh.m4: Don't include files given by autom4te.
+
+       
 2002-02-05  Akim Demaille  <akim@epita.fr>
 
        * bin/autom4te.in (&parse_args): Implement `frozen files are
index 42a23ca864710abf7b504d1ce1a887ee96797c65..64c2f01b3e306ce07579f85a573b11e8f57c34ff 100644 (file)
@@ -272,6 +272,9 @@ my @include;
 # 0 for EXIT_SUCCESS.
 my $exit_status = 0;
 
+# Do we freeze?
+my $freeze = 0;
+
 # $M4.
 my $m4 = $ENV{"M4"} || '@M4@';
 # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
@@ -344,8 +347,8 @@ my %m4_builtin_alternate_name;
 $help = << "EOF";
 Usage: $0 [OPTION] ... [FILES]
 
-Run GNU M4 on the FILES, avoiding useless runs.  If tracing, the output
-consists of the traces only, otherwise output the expansion of the FILES.
+Run GNU M4 on the FILES, avoiding useless runs.  Output the traces if tracing,
+the frozen file if freezing, otherwise the expansion of the FILES.
 
 If some of the FILES are named \`FILE.m4f\' they are considered to be M4
 frozen files of all the previous files (which are therefore not loaded).
@@ -392,6 +395,9 @@ Tracing:
   -t, --trace=MACRO      report the MACRO invocations
   -p, --preselect=MACRO  prepare to trace MACRO in a future run
 
+Freezing:
+  -F, --freeze   produce an M4 frozen state file for FILES
+
 Report bugs to <bug-autoconf\@gnu.org>.
 EOF
 
@@ -496,12 +502,25 @@ sub parse_args ()
      # by hand.
      "t|trace=s"     => \@trace,
      "p|preselect=s" => \@preselect,
+
+     # Freezing.
+     "F|freeze"  => \$freeze,
     );
 
   die "$me: too few arguments
 Try `$me --help' for more information.\n"
     unless @ARGV;
 
+  # Freezing:
+  # We cannot trace at the same time (well, we can, but it sounds insane).
+  # And it implies melting: there is risk not to update properly using
+  # old frozen files, and worse yet: we could load a frozen file and
+  # refreeze it!  A sort of caching :)
+  die "$me: cannot freeze and trace\n"
+    if $freeze && @trace;
+  $melt = 1
+    if $freeze;
+
   # Normalize the includes: the first occurrence is enough, several is
   # a pain since it introduces a useless difference in the path which
   # invalidates the cache.  And strip `.' which is implicit and always
@@ -1003,6 +1022,56 @@ sub up_to_date ($)
 }
 
 
+## ---------- ##
+## Freezing.  ##
+## ---------- ##
+
+# freeze ($OUTPUT)
+# ----------------
+sub freeze ($)
+{
+  my ($output) = @_;
+
+  # When processing the file with diversion disabled, there must be no
+  # output but comments and empty lines.
+  my $command = ("$m4"
+                . ' --fatal-warning'
+                . join (' --include=', '', reverse @include)
+                . ' --define=divert'
+                . " @ARGV"
+                . ' </dev/null');
+  verbose "running: $command";
+  my $result = `$command`;
+  $result =~ s/#.*\n//g;
+  $result =~ s/^\n//mg;
+  if ($?)
+    {
+      verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
+      exit $? >> 8;
+    }
+  if ($result)
+    {
+      print STDERR "$me: freezing produced output:\n$result";
+      exit 1;
+    }
+
+  # If freezing produces output, something went wrong: a bad `divert',
+  # or an improper paren etc.
+  $command = ("$m4"
+             . ' --fatal-warning'
+             . join (' --include=', '', reverse @include)
+             . " --freeze-state=$output"
+             . " @ARGV"
+             . ' </dev/null');
+  verbose "running: $command";
+  system $command;
+  if ($?)
+    {
+      verbose "$m4: failed with exit status: " . ($? >> 8) . "\n";
+      exit $? >> 8;
+    }
+}
+
 ## -------------- ##
 ## Main program.  ##
 ## -------------- ##
@@ -1011,6 +1080,13 @@ mktmpdir ('t4');
 load_configuration;
 parse_args;
 
+# Freezing does not involve the cache.
+if ($freeze)
+  {
+    freeze ($output);
+    exit 0;
+  }
+
 # We need our cache directory.
 if (! -d "$cache")
   {
index 138f5d41121ef0a1a0196e6400fc6baecebfb8f0..85a0c42b8573c181c477c452138cf0251e362e42 100644 (file)
@@ -1,7 +1,6 @@
-divert(-1)#                                                -*- Autoconf -*-
-# This file is part of Autoconf.
+# This file is part of Autoconf.                -*- Autoconf -*-
 # Driver that loads the Autoconf macro files.
-# Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
+# Copyright 1994, 1999, 2000, 2001, 2002 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
@@ -51,9 +50,6 @@ divert(-1)#                                                -*- Autoconf -*-
 # yet when Autoconf is frozen.
 # Do not sinclude ./aclocal.m4 here, to prevent it from being frozen.
 
-changequote()
-changequote([, ])
-include([m4sugar/m4sh.m4])
 # general includes some AU_DEFUN.
 m4_include([autoconf/autoupdate.m4])
 
index 993e8abdba57f0db8d4238dd4c2cc4c9e2ede9cf..1ae2f626ea20b9f28cb7bf19e8f981c042a29a01 100644 (file)
@@ -1,7 +1,6 @@
-divert(-1)#                                            -*- Autoconf -*-
-# This file is part of Autoconf.
+# This file is part of Autoconf.                       -*- Autoconf -*-
 # M4 macros used in building test suites.
-# Copyright 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002 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
@@ -45,7 +44,4 @@ divert(-1)#                                           -*- Autoconf -*-
 # such potential, you must delete any notice of this special exception
 # to the GPL from your modified version.
 
-changequote()
-changequote([, ])
-include([m4sugar/m4sh.m4])
 m4_include([autotest/general.m4])
index 2874b74a5919520ecc059cdacd7f95023bcc71df..49043230458c71f2505e189fda473b3f33f7d409 100644 (file)
@@ -1,8 +1,7 @@
-changequote()changequote([, ])include(m4sugar/m4sugar.m4)#  -*- Autoconf -*-
-# This file is part of Autoconf.
+# This file is part of Autoconf.                          -*- Autoconf -*-
 # M4 sugar for common shell constructs.
 # Requires GNU M4 and M4sugar.
-# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002 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