autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

26-fyi-autoreconf-perl.patch


From: Akim Demaille
Subject: 26-fyi-autoreconf-perl.patch
Date: Mon, 08 Oct 2001 10:30:07 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * bin/autoreconf.in: Rewrite in Perl.
        * configure.ac: Adjust.
        * lib/Autom4te/General.pm (&up_to_date_p): New.
        * bin/autom4te.in (&up_to_date_p): Use it.
        Rename as...
        (&up_to_date): this.
        
Index: configure.ac
--- configure.ac Mon, 01 Oct 2001 16:36:39 +0200 akim
+++ configure.ac Mon, 08 Oct 2001 01:11:41 +0200 akim
@@ -39,7 +39,7 @@
                 [chmod +x tests/autoheader])
 AC_CONFIG_FILES([tests/autom4te],
                 [chmod +x tests/autom4te])
-AC_CONFIG_FILES([tests/autoreconf],
+AC_CONFIG_FILES([tests/autoreconf:tests/wrappl.in],
                 [chmod +x tests/autoreconf])
 AC_CONFIG_FILES([tests/autoscan:tests/wrappl.in],
                 [chmod +x tests/autoscan])
@@ -94,7 +94,7 @@
 
 AC_OUTPUT
 # Report the state of this version of Autoconf if this is a beta.
-m4_match(m4_defn([AC_PACKAGE_VERSION]),  [[a-z]],
+m4_bmatch(m4_defn([AC_PACKAGE_VERSION]),  [[a-z]],
 [    cat <<EOF
 
 You are about to use an experimental version of Autoconf.  Be sure to
Index: bin/autom4te.in
--- bin/autom4te.in Fri, 28 Sep 2001 09:38:15 +0200 akim
+++ bin/autom4te.in Mon, 08 Oct 2001 01:06:49 +0200 akim
@@ -942,13 +942,13 @@ sub handle_traces ($$%)
 
 
 # $BOOL
-# up_to_date_p ($REQ)
-# -------------------
+# up_to_date ($REQ)
+# -----------------
 # Are the cache files of $REQ up to date?
 # $REQ is `valid' if it corresponds to the request and exists, which
 # does not mean it is up to date.  It is up to date if, in addition,
 # its files are younger than its dependencies.
-sub up_to_date_p ($)
+sub up_to_date ($)
 {
   my ($req) = @_;
 
@@ -983,20 +983,7 @@ sub up_to_date_p ($)
   push @dep, map { chomp; find_file ($_, @include) } $deps->getlines;
 
   # If $FILE is younger than one of its dependencies, it is outdated.
-  verbose "$file is the youngest cache file";
-  foreach (@dep)
-    {
-      verbose "  dependency: $_";
-      if ($mtime < mtime ($_))
-       {
-         verbose "cache files are outdated: $_ is more recent";
-         return 0;
-       }
-    }
-
-  # Well, really, it's fine!
-  verbose "cache files are up to date";
-  return 1;
+  return up_to_date_p ($file, @dep);
 }
 
 
@@ -1028,7 +1015,7 @@ sub up_to_date_p ($)
 
 # If $REQ's cache files are not up to date, declare it invalid.
 $req->valid (0)
-  if ! up_to_date_p ($req);
+  if ! up_to_date ($req);
 
 # We now know whether we can trust the Request object.  Say it.
 if ($verbose)
Index: bin/autoreconf.in
--- bin/autoreconf.in Sun, 23 Sep 2001 08:45:24 +0200 akim
+++ bin/autoreconf.in Mon, 08 Oct 2001 01:28:30 +0200 akim
@@ -1,6 +1,11 @@
-#! @SHELL@
-# -*- shell-script -*-
-# autoreconf - remake all Autoconf configure scripts in a directory tree
+#! @PERL@ -w
+# -*- perl -*-
+# @configure_input@
+
+eval 'exec @PERL@ -S $0 ${1+"$@"}'
+    if 0;
+
+# autoreconf - install the GNU Build System in a directory tree
 # Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -18,18 +23,35 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 # 02111-1307, USA.
 
-me=`echo "$0" | sed -e 's,.*[\\/],,'`
+# Written by David J. MacKenzie.
+# Extended and rewritten in Perl by Akim Demaille.
 
-usage="\
-Usage: $0 [OPTION] ... [TEMPLATE-FILE]
+BEGIN
+{
+  my $perllibdir = $ENV{'autom4te_perllibdir'} || '@datadir@';
+  unshift @INC, "$perllibdir";
+}
 
-Run \`autoconf' (and \`autoheader', \`aclocal' and \`automake', where
-appropriate) repeatedly to remake the Autoconf \`configure' scripts
+use Autom4te::General;
+use Autom4te::XFile;
+use File::Find;
+use strict;
+
+## ----------- ##
+## Variables.  ##
+## ----------- ##
+
+# $HELP
+# -----
+$help = "Usage: $0 [OPTION] ... [TEMPLATE-FILE]
+
+Run `autoconf' (and `autoheader', `aclocal' and `automake', where
+appropriate) repeatedly to remake the Autoconf `configure' scripts
 and configuration header templates in the directory tree rooted at the
 current directory.  By default, it only remakes those files that are
 older than their predecessors.  If you install a new version of
-Autoconf, running \`autoreconf' remakes all of the files by giving it
-the \`--force' option.
+Autoconf, running `autoreconf' remakes all of the files by giving it
+the `--force' option.
 
 Operation modes:
   -h, --help      print this help, then exit
@@ -40,290 +62,186 @@ Usage: $0 [OPTION] ... [TEMPLATE-FILE]
   -i, --install   copy missing auxiliary files
   -s, --symlink   instead of copying, install symbolic links
 
-The option \`--install' is similar to the option \`--add-missing' in
+The option `--install' is similar to the option `--add-missing' in
 other tools.
 
 Library directories:
   -A, --autoconf-dir=ACDIR  location of Autoconf's macro files (rarely needed)
-  -l, --localdir=DIR        location of \`aclocal.m4' and \`acconfig.h'
+  -l, --localdir=DIR        location of `aclocal.m4' and `acconfig.h'
   -M, --m4dir=M4DIR         this package's Autoconf extensions
 
-Unless specified, heuristics try to compute \`M4DIR' from the \`Makefile.am',
-or defaults to \`m4' if it exists.
-
-The following options are passed to \`automake':
-     --cygnus          assume program is part of Cygnus-style tree
-     --foreign         set strictness to foreign
-     --gnits           set strictness to gnits
-     --gnu             set strictness to gnu
-     --include-deps    include generated dependencies in Makefile.in
+Unless specified, heuristics try to compute `M4DIR' from the `Makefile.am',
+or defaults to `m4' if it exists.
 
 The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, and ACLOCAL
 are honored.
 
-Report bugs to <address@hidden>."
+Report bugs to <address@hidden>.
+";
 
-version="\
-autoreconf (@PACKAGE_NAME@) @VERSION@
-Written by David J. MacKenzie.
+# $VERSION
+# --------
+$version = "autoreconf (@PACKAGE_NAME@) @VERSION@
+Written by David J. MacKenzie and Akim Demaille.
 
-Copyright 1994, 1999, 2000 Free Software Foundation, Inc.
+Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+";
+
+# Lib files.
+my $autoconf   = $ENV{'AUTOCONF'}   || '@autoconf-name@';
+my $autoheader = $ENV{'AUTOHEADER'} || '@autoheader-name@';
+my $automake   = $ENV{'AUTOMAKE'}   || 'automake';
+my $aclocal    = $ENV{'ACLOCAL'}    || 'aclocal';
 
-help="\
-Try \`$me --help' for more information."
 
-exit_missing_arg="\
-echo \"$me: option \\\`\$1' requires an argument\" >&2
-echo \"\$help\" >&2
-exit 1"
-
-# NLS nuisances.
-# Only set these to C if already set.  These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
-
-# Variables.
-: address@hidden@}}
-: address@hidden@}
-: address@hidden@}
-# Looking for automake.
-: ${AUTOMAKE=automake}
-# Looking for aclocal.
-: ${ACLOCAL=aclocal}
-
-debug=false
-dir=`echo "$0" | sed -e 's,[^\\/]*$,,'`
-force=false
 # --install -- as --add-missing in other tools.
-install=false
-localdir=.
+my $install = 0;
+my $localdir = '.';
+my $autoconf_dir = '.';
 # m4dir -- local Autoconf extensions.  Typically `m4'.
-m4dir=
-status=0
+my $m4dir;
+my $status = 0;
 # symlink -- when --install, use symlinks instead.
-symlink=false
-verbose=:
+my $symlink = 0;
+# $force -- update up to date files.
+my $force = 0;
 
-# Parse command line.
-while test $# -gt 0; do
-  optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
-               "x$1" : 'x-.\(.*\)'`
-  case "$1" in
-    --version | -V )
-       echo "$version" ; exit 0 ;;
-    --help | -h )
-       echo "$usage"; exit 0 ;;
-
-    --verbose | -v )
-       verbose=echo
-       shift;;
-    --debug | -d )
-       debug=:; shift ;;
-
-    --localdir=* | -l?* )
-       localdir=$optarg
-       shift ;;
-    --localdir | -l )
-       test $# = 1 && eval "$exit_missing_arg"
-       shift
-       localdir=$1
-       shift ;;
-
-    --autoconf-dir=* | -A?* )
-      autoconf_dir=$optarg
-       shift ;;
-    --autoconf-dir | -A )
-       test $# = 1 && eval "$exit_missing_arg"
-       shift
-       autoconf_dir=$1
-       shift ;;
-    --macrodir=* | -m?* )
-       echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
-       autoconf_dir=$optarg
-       shift ;;
-    --macrodir | -m )
-       echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
-       test $# = 1 && eval "$exit_missing_arg"
-       shift
-       autoconf_dir=$1
-       shift ;;
-
-    --m4dir=* | -M?* )
-       m4dir=$optarg
-       shift ;;
-    --m4dir | -M )
-       test $# = 1 && eval "$exit_missing_arg"
-       shift
-       m4dir=$1
-       shift ;;
-
-     --force | -f )
-       force=:; shift ;;
-
-     --install | -i )
-       install=:; shift ;;
-     --symlink | -s )
-       symlink=:; shift ;;
-
-     # Options of Automake.
-     --cygnus | --foreign | --gnits | --gnu | --include-deps | -i )
-       AUTOMAKE="$AUTOMAKE $1"; shift ;;
-
-     -- )     # Stop option processing.
-       shift; break ;;
-     -* )
-       exec >&2
-       echo "$me: invalid option $1"
-       echo "$help"
-       exit 1 ;;
-     * )
-       break ;;
-  esac
-done
-
-# Find the input file.
-if test $# -ne 0; then
-  exec >&2
-  echo "$me: invalid number of arguments"
-  echo "$help"
-  exit 1
-fi
-
-# If verbose, say what you are going to use.
-if test $verbose = echo; then
-  $AUTOCONF --version |
-    sed "s,.*)\(.*\)$,$me: using autoconf\1: $autoconf,;1q" >&2
-  $AUTOHEADER --version |
-    sed "s,.*)\(.*\)$,$me: using autoheader\1: $autoheader,;1q" >&2
-  $AUTOMAKE --version |
-    sed "s,.*)\(.*\)$,$me: using automake\1: $automake,;1q" >&2
-  $ACLOCAL --version |
-    sed "s,.*)\(.*\)$,$me: using aclocal\1: $aclocal,;1q" >&2
-fi
-
-# Dispatch autoreconf's option to the tools.
-# --localdir
-autoconf="$AUTOCONF -A $autoconf_dir -l $localdir"
-autoheader="$AUTOHEADER -A $autoconf_dir -l $localdir"
-# --force
-$force || AUTOMAKE="$AUTOMAKE --no-force"
-$force &&
-{
-  autoconf="$autoconf --force"
-  autoheader="$autoheader --force"
-}
-# --verbose
-autoconf="$autoconf `$verbose --verbose`"
-autoheader="$autoheader `$verbose --verbose`"
-automake="$automake `$verbose --verbose`"
-aclocal="$ACLOCAL `$verbose --verbose`"
-# --debug
-$debug &&
-{
-  autoconf="$autoconf --debug"
-  autoheader="$autoheader --debug"
-}
-# --install and --symlink
-if $install; then
-  automake="$automake --add-missing `$symlink || echo --copy`"
-fi
 
-# Trap on 0 to stop playing with `rm'.
-$debug ||
-{
-  trap 'status=$?; rm -rf $tmp && exit $status' 0
-  trap '(exit 1); exit 1' 1 2 13 15
-}
+## ---------- ##
+## Routines.  ##
+## ---------- ##
 
-# Create a (secure) tmp directory for tmp files.
-: ${TMPDIR=/tmp}
-{
-  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/arXXXXXX") 2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
-}  ||
-{
-  tmp=$TMPDIR/ar$$
-  (umask 077 && mkdir $tmp)
-} ||
-{
-   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
-   (exit 1); exit 1
-}
 
-# When debugging, it is convenient that all the related temporary
-# files be at the same place.
-TMPDIR=$tmp
-export TMPDIR
+# parse_args ()
+# -------------
+# Process any command line arguments.
+sub parse_args ()
+{
+  my $srcdir;
 
-# alflags.sed -- Fetch the aclocal flags.
-cat >$tmp/alflags.sed <<EOF
-#n
-/^ACLOCAL_[A-Z_]*FLAGS/{
-  s/.*=//
-  p
-  q
+  getopt ('l|localdir=s'                => \$localdir,
+         'A|autoconf-dir|m|macrodir=s' => \$autoconf_dir,
+         'M|m4dir=s'                   => \$m4dir,
+         'f|force'                     => \$force,
+         'i|install'                   => \$install,
+         's|symlink'                   => \$symlink);
+
+  die "$me: too many arguments\n"
+    if @ARGV;
+
+  if ($verbose && $debug)
+    {
+      xsystem ("$autoconf --version | sed 1q >&2");
+      print STDERR "\n";
+      xsystem ("$autoheader --version | sed 1q >&2");
+      print STDERR "\n";
+      xsystem ("$automake --version | sed 1q >&2");
+      print STDERR "\n";
+      xsystem ("$aclocal --version | sed 1q >&2");
+      print STDERR "\n";
+    }
+
+  # Dispatch autoreconf's option to the tools.
+  # --localdir
+  $autoconf   .= " --include=$autoconf_dir --include=$localdir";
+  $autoheader .= " --include=$autoconf_dir --include=$localdir";
+  # --force;
+  if ($force)
+    {
+      $autoconf   .= ' --force';
+      $autoheader .= ' --force';
+    }
+  else
+    {
+      $automake .= ' --no-force';
+    }
+  # --verbose
+  if ($verbose)
+    {
+      $autoconf   .= ' --verbose';
+      $autoheader .= ' --verbose';
+      $automake   .= ' --verbose';
+      $aclocal    .= ' --verbose';
+    }
+  # --debug;
+  if ($debug)
+    {
+      $autoconf   .= ' --debug';
+      $autoheader .= ' --debug';
+    }
+  # --install and --symlink;
+  if ($install)
+    {
+      $automake .= ' --add-missing';
+      $automake .= ' --copy'
+       unless $symlink;
+    }
 }
-EOF
 
-# update.sh --
-# Exit 0 if the first argument is not the most recent of all or is missing.
-cat >$tmp/update.sh <<\EOF
-test -f "$1" || { :; exit; }
-test x`ls -1dt "$@" 2>/dev/null | sed 1q` != x"$1"
-EOF
-update="@SHELL@ $tmp/update.sh"
-
-
-# ----------------------- #
-# Real work starts here.  #
-# ----------------------- #
-
-# Make a list of directories to process.
-# The xargs grep filters out Cygnus configure.in files.
-find . '(' -name configure.ac -o -name configure.in ')' -print |
-xargs grep -l AC_INIT |
-sed 's,/configure\.ac$,,;s,/configure\.in$,,;s,^./,,' |
-while read dir; do
-  (
-  cd $dir || continue
 
+# &autoreconf ()
+# --------------
+# Reconf the current directory.
+sub autoreconf ()
+{
+  # If there it's not `configure.ac' or `configure.in', we are not
+  # interested in the directory.
+  verbose "{$_}\n";
+  return
+    if !/^configure\.(ac|in)$/;
+
+  my $configure_ac = $_;
+  verbose "working on $configure_ac";
+
+  # If there is no AC_INIT, then we are not interested: it looks like
+  # a Cygnus thingy.
+  my $configure_ac_file = new Autom4te::XFile $configure_ac;
+  my $autoconf_driven;
+  while ($_ = $configure_ac_file->getline)
+     {
+       $autoconf_driven = 1
+        if /AC_INIT/;
+     }
+  if (!$autoconf_driven)
+    {
+      verbose "$configure_ac: not Autoconf";
+      return;
+    }
 
   # ----------------- #
   # Running aclocal.  #
   # ----------------- #
 
-  # uses_aclocal -- is this package using aclocal?
-  uses_aclocal=false
-  grep 'generated .* by aclocal' $localdir/aclocal.m4 >/dev/null 2>&1 &&
-     uses_aclocal=:
-  test -f "$localdir/aclocal.m4" ||
-     uses_aclocal=:
-  if $uses_aclocal &&
-     { $force ||
-       $update $localdir/aclocal.m4 $localdir/acinclude.m4; } then
-     # If there are flags for aclocal in Makefile.am, use them.
-     aclocal_flags=`sed -f $tmp/alflags.sed Makefile.am 2>/dev/null`
-
-     # If m4dir no specified and these flags do not specify the
-     # location of the local Autoconf extensions, default to `m4'.
-     case $m4dir,$aclocal_flags in
-       ,*"-I "* ) ;; # Not overriden and specified.
-       ,*) # Not specified at all.
-           test -d "m4" && aclocal_flags="$aclocal_flags -I m4";;
-       * ) # Specified by the user.
-           aclocal_flags="$aclocal_flags -I $m4dir";;
-     esac
-
-     $verbose $me: running $aclocal $aclocal_flags 
--output=$localdir/aclocal.m4 in $dir >&2
-     $aclocal $aclocal_flags --output=$localdir/aclocal.m4
-  fi
+  if (-f "$localdir/aclocal.m4" &&
+      ($force ||
+       !up_to_date_p ("$localdir/aclocal.m4", "$localdir/acinclude.m4")))
+    {
+      # If there are flags for aclocal in Makefile.am, use them.
+      my $aclocal_flags;
+      if (-f "Makefile.am")
+       {
+         my $aclocal_m4 = new Autom4te::XFile "Makefile.am";
+         while ($_ = $aclocal_m4->getline)
+           {
+             if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/)
+               {
+                 $aclocal_flags = $1;
+                 last;
+               }
+           }
+       }
+
+      # If m4dir is not specified and these flags do not specify the
+      # location of the local Autoconf extensions, default to `m4'.
+      if (!$aclocal_flags)
+       {
+         $aclocal_flags = '-I ' . ($m4dir || 'm4');
+       }
+      xsystem ("$aclocal $aclocal_flags")
+    }
+
 
 
   # ------------------ #
@@ -331,76 +249,56 @@ Usage: $0 [OPTION] ... [TEMPLATE-FILE]
   # ------------------ #
 
   # Assumes that there is a Makefile.am in the topmost directory.
-  uses_automake=false
-  test -f "Makefile.am" &&
-    uses_automake=:
-  # We should always run automake, and let it decide whether it shall
-  # update the file or not.  In fact, the effect of `$force' is already
-  # included in `$automake' via `--no-force'.
-  if $uses_automake; then
-    $verbose $me: running $automake in $dir >&2
-    $automake
-  fi
+  if (-f 'Makefile.am')
+    {
+      # We should always run automake, and let it decide whether it shall
+      # update the file or not.  In fact, the effect of `$force' is already
+      # included in `$automake' via `--no-force'.
+      xsystem ($automake);
+    }
 
 
   # ------------------ #
   # Running autoconf.  #
   # ------------------ #
 
-  if $force ||
-     $update configure configure.ac $localdir/aclocal.m4 ||
-     $update configure configure.in $localdir/aclocal.m4; then
-    $verbose $me: running $autoconf in $dir >&2
-    $autoconf
-  fi
+  # Don't try to be smarter than `autoconf', which does its own
+  # up to date checkings.
+  xsystem ($autoconf);
 
 
   # -------------------- #
   # Running autoheader.  #
   # -------------------- #
 
-  # templates -- arguments of AC_CONFIG_HEADERS.
-  $verbose $me: running $autoconf -t 'AC_CONFIG_HEADERS:$1' >&2
-  templates=`$autoconf -t 'AC_CONFIG_HEADERS:$1'`
-  if test -n "$templates"; then
-    tcount=`set -- $templates; echo $#`
-    template=`set -- $templates; echo $1 | sed '
-        s/.*://
-        t colon
-        s/$/.in/
-        : colon
-        s/:.*//
-      '`
-    template_dir=`echo $template | sed -e 's,[\\/]*[^\\/]*$,,;s,^$,.,'`
-    stamp_num=`test "$tcount" -gt 1 && echo "$tcount"`
-    stamp=$template_dir/stamp-h$stamp_num.in
-    # If config.hin exists, don't override it unless it was really
-    # created by autoheader (users are allowed to write them by hand!).
-    uses_autoheader=false
-    grep autoheader "$template" >/dev/null 2>&1 &&
-       uses_autoheader=:
-    test -f "$template" ||
-       uses_autoheader=:
-    if $uses_autoheader &&
-       { $force ||
-         $update $template \
-            configure.ac $localdir/aclocal.m4 $localdir/acconfig.h ||
-         $update $template \
-            configure.in $localdir/aclocal.m4 $localdir/acconfig.h ||
-         $update $stamp    \
-            configure.ac $localdir/aclocal.m4 $localdir/acconfig.h ||
-         $update $stamp    \
-            configure.in $localdir/aclocal.m4 $localdir/acconfig.h; } then
-      $verbose $me: running $autoheader in $dir >&2
-      $autoheader &&
-      $verbose "touching $stamp" >&2 &&
-      touch $stamp
-    fi
-  fi
-  )
-done
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# End:
+  # We now consider that if AC_CONFIG_HEADERS is used, then autoheader
+  # is used too.
+  # Just as for autoconf, up to date ness is performed by the tool itself.
+  my $autoheader_driven = 0;
+  my $traces = new Autom4te::XFile "$autoconf --trace=AC_CONFIG_HEADERS |";
+  while ($_ = $traces->getline)
+    {
+      $autoheader_driven = 1
+       if /AC_CONFIG_HEADERS/;
+    }
+  if (!$autoheader_driven)
+    {
+      verbose "$configure_ac: not Autoheader";
+    }
+  else
+    {
+      xsystem ($autoheader);
+    }
+}
+
+
+## ------ ##
+## Main.  ##
+## ------ ##
+
+# When debugging, it is convenient that all the related temporary
+# files be at the same place.
+mktmpdir ('ah');
+$ENV{'TMPDIR'} = $tmp;
+parse_args;
+find (\&autoreconf, '.');
Index: lib/Autom4te/General.pm
--- lib/Autom4te/General.pm Sun, 23 Sep 2001 10:43:52 +0200 akim
+++ lib/Autom4te/General.pm Mon, 08 Oct 2001 01:05:44 +0200 akim
@@ -30,7 +30,7 @@
 
 @ISA = qw (Exporter);
 @EXPORT = qw (&debug &find_configure_ac &find_file &getopt &mktmpdir &mtime
-              &uniq &update_file &verbose &xsystem
+              &uniq &update_file &up_to_date_p &verbose &xsystem
              $debug $help $me $tmp $verbose $version);
 
 # Variable we share with the main package.  Be sure to have a single
@@ -56,6 +56,12 @@
 $version = undef;
 
 
+## ------------ ##
+## Prototypes.  ##
+## ------------ ##
+
+sub verbose (@);
+
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
@@ -242,17 +248,40 @@ sub mtime ($)
 # Return LIST with no duplicates.
 sub uniq (@)
 {
-   my @res = ();
-   my %seen = ();
-   foreach my $item (@_)
-     {
-       if (! exists $seen{$item})
-        {
-          $seen{$item} = 1;
-          push (@res, $item);
-        }
-     }
-   return wantarray ? @res : "@res";
+  my @res = ();
+  my %seen = ();
+  foreach my $item (@_)
+    {
+      if (! exists $seen{$item})
+       {
+         $seen{$item} = 1;
+         push (@res, $item);
+       }
+    }
+  return wantarray ? @res : "@res";
+}
+
+
+# $BOOLEAN
+# &up_to_date_p ($FILE, @DEPS)
+# ----------------------------
+# Is $FILE more recent than @DEPS?
+sub up_to_date_p ($@)
+{
+  my ($file, @dep) = @_;
+  my $mtime = mtime ($file);
+
+  foreach my $dep (@dep)
+    {
+      if ($mtime < mtime ($dep))
+       {
+         verbose "up_to_date ($file): outdated: $dep";
+         return 0;
+       }
+    }
+
+  verbose "up_to_date ($file): up to date";
+  return 1;
 }
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]