From: Akim Demaille Date: Tue, 5 Feb 2002 08:12:46 +0000 (+0000) Subject: Implement `autom4te --freeze'. X-Git-Tag: AUTOCONF-2.52h~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0f11860484d34ee2b80d70e761e359cf13a0e9a;p=thirdparty%2Fautoconf.git 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. --- diff --git a/ChangeLog b/ChangeLog index c2eef4af8..970b67c9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-02-05 Akim Demaille + + 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 * bin/autom4te.in (&parse_args): Implement `frozen files are diff --git a/bin/autom4te.in b/bin/autom4te.in index 42a23ca86..64c2f01b3 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -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 . 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" + . ' > 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" + . ' > 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") { diff --git a/lib/autoconf/autoconf.m4 b/lib/autoconf/autoconf.m4 index 138f5d411..85a0c42b8 100644 --- a/lib/autoconf/autoconf.m4 +++ b/lib/autoconf/autoconf.m4 @@ -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]) diff --git a/lib/autotest/autotest.m4 b/lib/autotest/autotest.m4 index 993e8abdb..1ae2f626e 100644 --- a/lib/autotest/autotest.m4 +++ b/lib/autotest/autotest.m4 @@ -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]) diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 2874b74a5..490432304 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -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