autom4te.in

来自「LINUX下的源码工具,可自己分析,或者直接装在系统上作为应用」· IN 代码 · 共 1,233 行 · 第 1/3 页

IN
1,233
字号
#! @PERL@ -w# -*- perl -*-# @configure_input@eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'    if 0;# autom4te - Wrapper around M4 libraries.# Copyright (C) 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# 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.BEGIN{  my $datadir = ($ENV{'autom4te_perllibdir'} || '@datadir@');  unshift @INC, "$datadir";}## --------- #### Request.  #### --------- ##package Request;use Data::Dumper;use Autom4te::General;use Autom4te::Struct;use Autom4te::XFile;use Carp;use strict;# List of requests.# We can't declare it `my' as the loading, performed via `do',# would refer to another scope, and @request would not be updated.# It used to work with `my' vars, and I don't know whether the current# behavior (5.6) is wanted or not.use vars qw(@request);struct  (   # The key of the cache files.   'id' => "\$",   # True iff %MACRO contains all the macros we want to trace.   'valid' => "\$",   # The include path.   'path' => '@',   # The set of input files.   'input' => '@',   # The set of macros currently traced.   'macro' => '%',  );# $REQUEST-OBJ# retrieve ($SELF, %ATTR)# -----------------------# Find a request with the same path and input.# Private.sub retrieve{  my ($self, %attr) = @_;  foreach (@request)    {      # Same path.      next	if join ("\n", @{$_->path}) ne join ("\n", @{$attr{path}});      # Same inputs.      next	if join ("\n", @{$_->input}) ne join ("\n", @{$attr{input}});      # Found it.      return $_;    }  return undef;}# $REQUEST-OBJ# register ($SELF, %ATTR)# -----------------------# NEW should not be called directly.# Private.sub register ($%){  my ($self, %attr) = @_;  # path and input are the only ID for a request object.  my $obj = $self->new ('path'  => $attr{path},			'input' => $attr{input});  push @request, $obj;  # Assign an id for cache file.  $obj->id ("$#request");  return $obj;}# $REQUEST-OBJ# request($SELF, %REQUEST)# ------------------------# Return a request corresponding to $REQUEST{path} and $REQUEST{input},# using a cache value if it exists.sub request ($%){  my ($self, %request) = @_;  my $req = Request->retrieve (%request) || Request->register (%request);  # If there are new traces to produce, then we are not valid.  foreach (@{$request{'macro'}})    {      if (! exists ${$req->macro}{$_})        {          ${$req->macro}{$_} = 1;          $req->valid (0);        }    }  # It would be great to have $REQ check that it up to date wrt its  # dependencies, but that requires getting traces (to fetch the  # included files), which is out of the scope of Request  # (currently?).  return $req;}# Serialize a request or all the current requests.sub marshall{  my ($caller) = @_;  my $res = '';  if (ref ($caller))    {      # CALLER is an object: instance method.      my $marshall = Data::Dumper->new ([$caller]);      $marshall->Indent(2)->Terse(0);      $res = $marshall->Dump . "\n";    }  else    {      # CALLER is the package: class method.      my $marshall = Data::Dumper->new ([\@request], [qw (*request)]);      $marshall->Indent(2)->Terse(0);      $res = $marshall->Dump . "\n";    }  return $res;}# includes_p (@MACRO)# -------------------# Does this request covers all the @MACRO.sub includes_p{  my ($self, @macro) = @_;  foreach (@macro)    {      return 0	if ! exists ${$self->macro}{$_};    }  return 1;}# SAVE ($FILENAME)# ----------------sub save{  my ($self, $filename) = @_;  croak "$me: cannot save a single request\n"    if ref ($self);  my $requests = new Autom4te::XFile ("> $filename");  print $requests    "# This file was created by $me.\n",    "# It contains the lists of macros which have been traced.\n",    "# It can be safely removed.\n",    "\n",    $self->marshall;}# LOAD ($FILE)# ------------sub load{  my ($self, $file) = @_;  croak "$me: cannot load a single request\n"    if ref ($self);  (my $return) = do "$file";  croak "$me: cannot parse $file: $@\n" if $@;  croak "$me: cannot do $file: $!\n"    unless defined $return;  croak "$me: cannot run $file\n"       unless $return;}## ---------- #### Autom4te.  #### ---------- ##package Autom4te;use Autom4te::General;use File::Basename;use Autom4te::XFile;use strict;# Data directory.my $datadir = $ENV{'AC_MACRODIR'} || '@datadir@';# $LANGUAGE{LANGUAGE} -- Automatic options for LANGUAGE.my %language;my $output = '-';# Mode of the output file except for traces.my $mode = "0666";# If melt, don't use frozen files.my $melt = 0;# Names of the cache directory, cache directory index, trace cache# prefix, and output cache prefix.my $cache;my $icache;my $tcache;my $ocache;# The macros to trace mapped to their format, as specified by the# user.my %trace;# The macros the user will want to trace in the future.# We need `include' to get the included file, `m4_pattern_forbid' and# `m4_pattern_allow' to check the output.## FIXME: What about `sinclude'?my @preselect = ('include', 'm4_pattern_allow', 'm4_pattern_forbid');# List of warnings.my @warning;# M4 include path.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.error "need GNU m4 1.4 or later: $m4"  if system "$m4 --help </dev/null 2>&1 | grep reload-state >/dev/null";# Set some high recursion limit as the default limit, 250, has already# been hit with AC_OUTPUT.  Don't override the user's choice.$m4 .= ' --nesting-limit=1024'  if " $m4 " !~ / (--nesting-limit|-L) /;# @M4_BUILTIN -- M4 builtins and a useful comment.my @m4_builtin = `echo dumpdef | $m4 2>&1 >/dev/null`;map { s/:.*//;s/\W// } @m4_builtin;# %M4_BUILTIN_ALTERNATE_NAME# --------------------------# The builtins are renamed, e.g., `define' is renamed `m4_define'.# So map `define' to `m4_define' and conversely.# Some macros don't follow this scheme: be sure to properly map to their# alternate name too.## This is because GNU M4 1.4's tracing of builtins is buggy.  When run on# this input:## | divert(-1)# | changequote([, ])# | define([m4_eval], defn([eval]))# | eval(1)# | m4_eval(2)# | undefine([eval])# | m4_eval(3)## it behaves this way:## | % m4 input.m4 -da -t eval# | m4trace: -1- eval(1)# | m4trace: -1- m4_eval(2)# | m4trace: -1- m4_eval(3)# | %## Conversely:## | % m4 input.m4 -da -t m4_eval# | %## So we will merge them, i.e.  tracing `BUILTIN' or tracing# `m4_BUILTIN' will be the same: tracing both, but honoring the# *last* trace specification.## FIXME: This is not enough: in the output `$0' will be `BUILTIN'# sometimes and `m4_BUILTIN' at others.  We should return a unique name,# the one specified by the user.## FIXME: To be absolutely rigorous, I would say that given that we# _redefine_ divert (instead of _copying_ it), divert and the like# should not be part of this list.my %m4_builtin_alternate_name;@m4_builtin_alternate_name{"$_", "m4_$_"} = ("m4_$_", "$_")  foreach (grep { !/m4wrap|m4exit|dnl|ifelse|__.*__/ } @m4_builtin);@m4_builtin_alternate_name{"ifelse", "m4_if"}   = ("m4_if", "ifelse");@m4_builtin_alternate_name{"m4exit", "m4_exit"} = ("m4_exit", "m4exit");@m4_builtin_alternate_name{"m4wrap", "m4_wrap"} = ("m4_wrap", "m4wrap");# $HELP# -----$help = << "EOF";Usage: $0 [OPTION] ... [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 M4frozen files of all the previous files (which are therefore not loaded).If \`FILE.m4f\' is not found, then \`FILE.m4\' will be used, together withall the previous files.Some files may be optional, i.e., will only be processed if found in theinclude path, but then must end in \`.m4?\';  the question mark is not part ofthe actual file name.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  -o, --output=FILE        save output in FILE (defaults to \`-\', stdout)  -f, --force              don\'t rely on cached values  -W, --warnings=CATEGORY  report the warnings falling in CATEGORY  -l, --language=LANG      specify the set of M4 macros to use  -C, --cache=DIRECTORY    preserve results for future runs in DIRECTORY      --no-cache           disable the cache  -m, --mode=OCTAL         change the non trace output file mode (0666)  -M, --melt               don\'t use M4 frozen filesLanguages include:  \`Autoconf\'   create Autoconf configure scripts  \`Autotest\'   create Autotest test suites  \`M4sh\'       create M4sh shell scripts  \`M4sugar\'    create M4sugar outputWarning categories include:  \`cross\'         cross compilation issues  \`obsolete\'      obsolete constructs  \`syntax\'        dubious syntactic constructs  \`all\'           all the warnings  \`no-CATEGORY\'   turn off the warnings on CATEGORY  \`none\'          turn off all the warnings  \`error\'         warnings are errorThe environment variable \`WARNINGS\' is honored.Library directories:  -B, --prepend-include=DIR  prepend directory DIR to search path  -I, --include=DIR          append directory DIR to search pathTracing:  -t, --trace=MACRO      report the MACRO invocations  -p, --preselect=MACRO  prepare to trace MACRO in a future runFreezing:  -F, --freeze   produce an M4 frozen state file for FILESReport bugs to <bug-autoconf\@gnu.org>.EOF# $VERSION# --------$version =  <<"EOF";autom4te (@PACKAGE_NAME@) @VERSION@Written by Akim Demaille.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?