📄 autoupdate.in
字号:
#! @PERL@ -w# -*- perl -*-# autoupdate - modernize an Autoconf file.# Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003# 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., 59 Temple Place - Suite 330, Boston, MA# 02111-1307, 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) 2003 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; }}# ------------- ## M4 builtins. ## ------------- #my @m4_builtins;# &handle_m4_symbols ()# ---------------------# Create the following $tmp files:# m4.m4 -- enable the m4 builtins.# unm4.m4 -- disable the m4 builtins.# savem4.m4 -- save the m4 builtins.sub handle_m4_macros (){ # Get the list of builtins. xsystem ("echo dumpdef | $m4 2>$tmp/m4.defs >/dev/null"); my $m4_defs = new Autom4te::XFile "$tmp/m4.defs"; while ($_ = $m4_defs->getline) { push @m4_builtins, $1 if /^(\w+):/; } $m4_defs->close; # Output the files. my $m4_m4 = new Autom4te::XFile ">$tmp/m4.m4"; print $m4_m4 "# m4.m4 -- enable the m4 builtins.\n"; my $unm4_m4 = new Autom4te::XFile ">$tmp/unm4.m4"; print $unm4_m4 "# unm4.m4 -- disable the m4 builtins.\n"; print $unm4_m4 "# Because Autoconf, via M4sugar, redefines some of these\n"; print $unm4_m4 "# macros, and therefore since unac.m4 disables them,\n"; print $unm4_m4 "# disable only if defined.\n"; my $m4save_m4 = new Autom4te::XFile ">$tmp/m4save.m4"; print $m4save_m4 "# savem4.m4 -- save the m4 builtins.\n"; foreach (@m4_builtins) { print $m4save_m4 "define([_au_$_], defn([$_]))\n"; print $unm4_m4 "_au_ifdef([$_], [_au_undefine([$_])])\n"; print $m4_m4 "_au_define([$_], _au_defn([_au_$_]))\n"; }}# ----------------- ## Autoconf macros. ## ----------------- ## @AU_MACROS & AC_MACROS -- AU and AC macros and yet another useful comment.my (%ac_macros, %au_macros);# HANDLE_AUTOCONF_MACROS ()# -------------------------# @M4_BUILTINS -- M4 builtins and a useful comment.sub handle_autoconf_macros (){ my $macros = new Autom4te::XFile ("$autoconf" . " --trace AU_DEFUN:'AU:\$f:\$1'" . " --trace define:'AC:\$f:\$1'" . " --melt /dev/null |"); while ($_ = $macros->getline) { chomp; my ($domain, $file, $macro) = /^(AC|AU):(.*):([^:]*)$/ or next; # ../lib/m4sugar/m4sugar.m4 -> m4sugar # ../lib/autoconf/general.m4 -> autoconf # aclocal.m4 -> aclocal my $set = basename (dirname ($file)); $set = 'aclocal' if $file eq 'aclocal.m4'; error "unknown set: $set: $_" unless $set =~ /^(m4sugar|aclocal|autoconf)$/; if ($domain eq "AC") { $ac_macros{$macro} = $set; } else { $au_macros{$macro} = $set; } } $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 (@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 grep { $ac_macros{$_} ne 'm4sugar' } keys %ac_macros) { print $ac_m4 "_au_define([$_], [[\$0(\$\@)]])\n"; print $unac_m4 "_au_undefine([$_])\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_m4_macros;handle_autoconf_macros;# $au_changequote -- enable the quote `[', `]' right before any AU macro.my $au_changequote = 's/\b(' . join ('|', keys %au_macros) . ')\b/_au_changequote([,])$1/g';# au.m4 -- definitions the AU macros.xsystem ("$autoconf --trace AU_DEFUN:'_au_defun(\@<:\@\$1\@:>\@,\@<:\@\$2\@:>\@)' --melt /dev/null " . ">$tmp/au.m4");## ------------------- #### Process the files. #### ------------------- ##foreach my $file (@ARGV) { my $filename = $file; # 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([, ]) # Move all the builtins into the `_au_' pseudo namespace include([m4save.m4]) # _au_defun(NAME, BODY) # --------------------- # Define NAME to BODY, plus AU activation/deactivation. _au_define([_au_defun], [_au_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, and m4sugar. _au_define([__au_enable], [_au_divert(-1) # Enable special characters. _au_changecom([#]) # Enable the m4 builtins, m4sugar and the autoquoting AC macros. _au_include([m4.m4]) _au_include([m4sugar/m4sugar.m4]) _au_include([ac.m4]) _au_divert(0)]) # _au_enable # ---------- # Called at the beginning of all the obsolete macros. Reenable the # builtins, and m4sugar if needed. _au_define([_au_enable], [_au_ifdef([_au_enabled], [], [__au_enable()])_au_dnl _au_pushdef([_au_enabled])]) # __au_disable # ------------ # Disable the builtins, and m4sugar. _au_define([__au_disable], [_au_divert(-1) # Disable m4sugar, the AC autoquoting macros, and m4. _au_include([unac.m4]) _au_include([unm4.m4]) # Disable special characters. _au_changequote() _au_changecom() _au_divert(0)]) # _au_disable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -