📄 autoupdate.in
字号:
#! @PERL@ -w# -*- perl -*-# @configure_input@# autoupdate - modernize an Autoconf file.# Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006# 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# the Free Software Foundation; either version 2, or (at your option)# any later version.# This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA# 02110-1301, USA.# Originally written by David MacKenzie <djm@gnu.ai.mit.edu>.# Rewritten by Akim Demaille <akim@freefriends.org>.eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' if 0;BEGIN{ my $datadir = $ENV{'autom4te_perllibdir'} || '@datadir@'; unshift @INC, $datadir; # Override SHELL. On DJGPP SHELL may not be set to a shell # that can handle redirection and quote arguments correctly, # e.g.: COMMAND.COM. For DJGPP always use the shell that configure # has detected. $ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos');}use Autom4te::ChannelDefs;use Autom4te::Channels;use Autom4te::Configure_ac;use Autom4te::FileUtils;use Autom4te::General;use Autom4te::XFile;use File::Basename;use strict;# Lib files.my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';my $autoconf = "$autom4te --language=autoconf";# We need to find m4sugar.my @prepend_include;my @include = ('@datadir@');my $force = 0;# m4.my $m4 = $ENV{"M4"} || '@M4@';# $HELP# -----$help = "Usage: $0 [OPTION] ... [TEMPLATE-FILE...]Update the TEMPLATE-FILE... if given, or `configure.ac' if present,or else `configure.in', to the syntax of the current version ofAutoconf. The original files are backed up.Operation modes: -h, --help print this help, then exit -V, --version print version number, then exit -v, --verbose verbosely report processing -d, --debug don't remove temporary files -f, --force consider all files obsoleteLibrary directories: -B, --prepend-include=DIR prepend directory DIR to search path -I, --include=DIR append directory DIR to search pathReport bugs to <bug-autoconf\@gnu.org>.";# $VERSION# --------$version = "autoupdate (@PACKAGE_NAME@) @VERSION@Written by David J. MacKenzie and Akim Demaille.Copyright (C) 2006 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.";## ---------- #### Routines. #### ---------- ### parse_args ()# -------------# Process any command line arguments.sub parse_args (){ my $srcdir; getopt ('I|include=s' => \@include, 'B|prepend-include=s' => \@prepend_include, 'f|force' => \$force); if (! @ARGV) { my $configure_ac = require_configure_ac; push @ARGV, $configure_ac; }}# ----------------- ## Autoconf macros. ## ----------------- #my (%ac_macros, %au_macros, %m4_builtins);# HANDLE_AUTOCONF_MACROS ()# -------------------------# @M4_BUILTINS -- M4 builtins and a useful comment.sub handle_autoconf_macros (){ # Get the builtins. xsystem ("echo dumpdef | $m4 2>$tmp/m4.defs >/dev/null"); my $m4_defs = new Autom4te::XFile "$tmp/m4.defs"; while ($_ = $m4_defs->getline) { $m4_builtins{$1} = 1 if /^(\w+):/; } $m4_defs->close; my $macros = new Autom4te::XFile ("$autoconf" . " --trace AU_DEFINE:'AU:\$f:\$1'" . " --trace define:'AC:\$f:\$1'" . " --melt /dev/null |"); while ($_ = $macros->getline) { chomp; my ($domain, $file, $macro) = /^(AC|AU):(.*):([^:]*)$/ or next; if ($domain eq "AU") { $au_macros{$macro} = 1; } elsif ($file =~ /(^|\/)m4sugar\/(m4sugar|version)\.m4$/) { # Add the m4sugar macros to m4_builtins. $m4_builtins{$macro} = 1; } else { # Autoconf, aclocal, and m4sh macros. $ac_macros{$macro} = 1; } } $macros->close; # Don't keep AU macros in @AC_MACROS. delete $ac_macros{$_} foreach (keys %au_macros); # Don't keep M4sugar macros which are redefined by Autoconf, # such as `builtin', `changequote' etc. See autoconf/autoconf.m4. delete $ac_macros{$_} foreach (keys %m4_builtins); error "no current Autoconf macros found" unless keys %ac_macros; error "no obsolete Autoconf macros found" unless keys %au_macros; if ($debug) { print STDERR "Current Autoconf macros:\n"; print STDERR join (' ', sort keys %ac_macros) . "\n\n"; print STDERR "Obsolete Autoconf macros:\n"; print STDERR join (' ', sort keys %au_macros) . "\n\n"; } # ac.m4 -- autoquoting definitions of the AC macros (M4sugar excluded). # unac.m4 -- undefine the AC macros. my $ac_m4 = new Autom4te::XFile ">$tmp/ac.m4"; print $ac_m4 "# ac.m4 -- autoquoting definitions of the AC macros.\n"; my $unac_m4 = new Autom4te::XFile ">$tmp/unac.m4"; print $unac_m4 "# unac.m4 -- undefine the AC macros.\n"; foreach (sort keys %ac_macros) { print $ac_m4 "_au_m4_define([$_], [m4_if(\$#, 0, [[\$0]], [[\$0(\$\@)]])])\n"; print $unac_m4 "_au_m4_undefine([$_])\n"; } # m4save.m4 -- save the m4 builtins. # unm4.m4 -- disable the m4 builtins. # m4.m4 -- enable the m4 builtins. my $m4save_m4 = new Autom4te::XFile ">$tmp/m4save.m4"; print $m4save_m4 "# m4save.m4 -- save the m4 builtins.\n"; my $unm4_m4 = new Autom4te::XFile ">$tmp/unm4.m4"; print $unm4_m4 "# unm4.m4 -- disable the m4 builtins.\n"; my $m4_m4 = new Autom4te::XFile ">$tmp/m4.m4"; print $m4_m4 "# m4.m4 -- enable the m4 builtins.\n"; foreach (sort keys %m4_builtins) { print $m4save_m4 "_au__save([$_])\n"; print $unm4_m4 "_au__undefine([$_])\n"; print $m4_m4 "_au__restore([$_])\n"; }}## -------------- #### Main program. #### -------------- ##parse_args;$autoconf .= " --debug" if $debug;$autoconf .= " --force" if $force;$autoconf .= " --verbose" if $verbose;$autoconf .= join (' --include=', '', @include);$autoconf .= join (' --prepend-include=', '', @prepend_include);mktmpdir ('au');handle_autoconf_macros;# $au_changequote -- enable the quote `[', `]' right before any AU macro.my $au_changequote = 's/\b(' . join ('|', keys %au_macros) . ')\b/_au_m4_changequote([,])$1/g';# au.m4 -- definitions the AU macros.xsystem ("$autoconf --trace AU_DEFINE:'_au_defun(\@<:\@\$1\@:>\@,\@<:\@\$2\@:>\@)' --melt /dev/null " . ">$tmp/au.m4");## ------------------- #### Process the files. #### ------------------- ##foreach my $file (@ARGV) { # We need an actual file. if ($file eq '-') { $file = "$tmp/stdin"; system "cat >$file"; } elsif (! -r "$file") { die "$me: $file: No such file or directory"; } # input.m4 -- m4 program to produce the updated file. # Load the values, the dispatcher, neutralize m4, and the prepared # input file. my $input_m4 = <<\EOF; divert(-1) -*- Autoconf -*- changequote([,]) # Define our special macros: define([_au__defn], defn([defn])) define([_au__divert], defn([divert])) define([_au__include], defn([include])) define([_au__undefine], defn([undefine])) define([_au__save], [m4_ifdef([$1], [m4_copy([$1], [_au_$1])])]) define([_au__restore], [_au_m4_ifdef([_au_$1], [_au_m4_define([$1], _au__defn([_au_$1]))])]) # Set up m4sugar. include(m4sugar/m4sugar.m4) # Redefine __file__ to make warnings nicer; $file is replaced below. m4_define([__file__], [$file]) # Redefine m4_location to fix the line number. m4_define([m4_location], [__file__:m4_eval(__line__ - _au__first_line)]) # Move all the builtins into the `_au_' pseudo namespace m4_include([m4save.m4]) # _au_defun(NAME, BODY) # --------------------- # Define NAME to BODY, plus AU activation/deactivation. _au_m4_define([_au_defun], [_au_m4_define([$1], [_au_enable()dnl $2[]dnl _au_disable()])]) # Import the definition of the obsolete macros. _au__include([au.m4]) ## ------------------------ ## ## _au_enable/_au_disable. ## ## ------------------------ ## # They work by pair: each time an AU macro is activated, it runs # _au_enable, and at its end its runs _au_disable (see _au_defun # above). AU macros might use AU macros, which should # enable/disable only for the outer AU macros. # # `_au_enabled' is used to this end, determining whether we really # enable/disable. # __au_enable # ----------- # Reenable the builtins, m4sugar, and the autoquoting AC macros. _au_m4_define([__au_enable], [_au__divert(-1) # Enable special characters. _au_m4_changecom([#]) _au__include([m4.m4]) _au__include([ac.m4]) _au__divert(0)]) # _au_enable # ---------- # Called at the beginning of all the obsolete macros. If this is the # outermost level, call __au_enable. _au_m4_define([_au_enable], [_au_m4_ifdef([_au_enabled], [], [__au_enable()])_au_dnl _au_m4_pushdef([_au_enabled])]) # __au_disable # ------------ # Disable the AC autoquoting macros, m4sugar, and m4. _au_m4_define([__au_disable], [_au__divert(-1) _au__include([unac.m4]) _au__include([unm4.m4]) # Disable special characters. _au_m4_changequote() _au_m4_changecom() _au__divert(0)]) # _au_disable # ----------- # Called at the end of all the obsolete macros. If we are at the # outermost level, call __au_disable.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -