autoconf-patches
[Top][All Lists]
Advanced

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

FYI: 10-autoconf-general.patch


From: Akim Demaille
Subject: FYI: 10-autoconf-general.patch
Date: 30 Jul 2001 11:05:13 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Academic Rigor)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/Autoconf/General.pm: New.
        * autom4te.in (Autoconf::General): Use it.
        ($me, $tmp, $verbose, $debug, &mktmpdir, &verbose, &xsystem)
        (&find_configure_ac, &find_slave): Remove.
        * autoscan.in: Likewise.
        * autoupdate.in: Likewise.
        
Index: autom4te.in
--- autom4te.in Sun, 29 Jul 2001 09:54:24 +0200 akim (ace/c/10_autom4te.i 1.9 
644)
+++ autom4te.in Sun, 29 Jul 2001 11:51:57 +0200 akim (ace/c/10_autom4te.i 1.9 
644)
@@ -23,11 +23,6 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 # 02111-1307, USA.
 
-require 5.005;
-use File::Basename;
-
-my $me = basename ($0);
-
 ## --------- ##
 ## Request.  ##
 ## --------- ##
@@ -44,6 +39,7 @@
 
 use Data::Dumper;
 use Autoconf::Struct;
+use Autoconf::General;
 use Carp;
 use Getopt::Long;
 use IO::File;
@@ -225,14 +221,12 @@ sub load
 
 package Autom4te;
 
+use Autoconf::General;
 use Getopt::Long;
 use File::Basename;
 use IO::File;
 use strict;
 
-# Our tmp dir.
-my $tmp;
-
 # The macros we always trace.
 my @required_trace =
   (
@@ -251,8 +245,6 @@ sub load
 # user.
 my %trace;
 
-my $verbose = 0;
-my $debug = 0;
 my $output = '-';
 my @warning;
 
@@ -283,40 +275,6 @@ sub load
 ## ---------- ##
 
 
-# mktmpdir ($SIGNATURE)
-# ---------------------
-# Create a temporary directory which name is based on $SIGNATURE.
-sub mktmpdir ($)
-{
-  my ($signature) = @_;
-  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
-
-  # If mktemp supports dirs, use it.
-  $tmp = `(umask 077 &&
-           mktemp -d -q "$TMPDIR/${signature}XXXXXX") 2>/dev/null`;
-  chomp $tmp;
-
-  if (!$tmp || ! -d $tmp)
-    {
-      $tmp = "$TMPDIR/$signature" . int (rand 10000) . ".$$";
-      mkdir $tmp, 0700
-       or die "$me: cannot create $tmp: $!\n";
-    }
-
-  print STDERR "$me:$$: working in $tmp\n"
-    if $debug;
-}
-
-
-# verbose
-# -------
-sub verbose (@)
-{
-  print STDERR "$me: ", @_, "\n"
-    if $verbose;
-}
-
-
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
@@ -347,23 +305,6 @@ sub END
     or (warn "$me: closing standard output: $!\n"), _exit (1);
 
   ($!, $?) = (0, $q);
-}
-
-
-# xsystem ($COMMAND)
-# ------------------
-sub xsystem ($)
-{
-  my ($command) = @_;
-
-  verbose "running: $command";
-
-  (system $command) == 0
-    or die ("$me: "
-           . (split (' ', $command))[0]
-           . " failed with exit status: "
-           . ($? >> 8)
-           . "\n");
 }
 
 
Index: autoscan.in
--- autoscan.in Thu, 26 Jul 2001 21:23:21 +0200 akim (ace/13_autoscan.p 1.44 
644)
+++ autoscan.in Sun, 29 Jul 2001 11:51:57 +0200 akim (ace/13_autoscan.p 1.44 
644)
@@ -21,17 +21,24 @@
 # Written by David MacKenzie <address@hidden>.
 
 use 5.005;
+
+BEGIN
+{
+  my $prefix = "@prefix@";
+  # FIXME: Import Struct into Autoconf.
+  my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@";
+  unshift @INC, "$perllibdir";
+}
+
 use File::Basename;
 use File::Find;
 use Getopt::Long;
 use IO::File;
+use Autoconf::General;
 use strict;
 
 use vars qw(@cfiles @makefiles @shfiles %c_keywords %printed);
 
-my $me = basename ($0);
-my $verbose = 0;
-
 # $USED{KIND}{ITEM} is set if ITEM is used in the program.
 # It is set to its list of locations.
 my %used = ();
@@ -67,7 +74,7 @@
   or die "$me: cannot open $me.log: $!\n";
 
 # Autoconf and lib files.
-my $autoconf;
+my $autoconf = find_peer ('autoconf', "@bindir@", 'autoconf-name');
 my $datadir = $ENV{"AC_MACRODIR"} || "@datadir@";
 
 # Exit nonzero whenever closing STDOUT fails.
@@ -152,50 +159,6 @@ sub parse_args ()
 }
 
 
-# find_autoconf
-# -------------
-# Find the lib files and autoconf.
-sub find_autoconf
-{
-  my $dir = dirname ($0);
-  # We test "$dir/autoconf" in case we are in the build tree, in which case
-  # the names are not transformed yet.
-  foreach my $file ($ENV{"AUTOCONF"} || '',
-                   "$dir/@autoconf-name@",
-                   "$dir/autoconf",
-                   "@bindir@/@autoconf-name@")
-    {
-      if (-x $file)
-       {
-         $autoconf = $file;
-         last;
-       }
-    }
-}
-
-
-# $CONFIGURE_AC
-# &find_configure_ac ()
-# ---------------------
-sub find_configure_ac ()
-{
-  if (-f 'configure.ac')
-    {
-      if (-f 'configure.in')
-       {
-         warn "warning: `configure.ac' and `configure.in' both present.\n";
-         warn "warning: proceeding with `configure.ac'.\n";
-       }
-      return 'configure.ac';
-    }
-  elsif (-f 'configure.in')
-    {
-      return 'configure.in';
-    }
-  return;
-}
-
-
 # init_tables ()
 # --------------
 # Put values in the tables of what to do with each token.
@@ -642,8 +605,6 @@ sub check_configure_ac ($)
 ## -------------- ##
 
 parse_args;
-# Find the lib files and autoconf.
-find_autoconf;
 my $configure_ac = find_configure_ac;
 init_tables;
 scan_files;
Index: autoupdate.in
--- autoupdate.in Thu, 26 Jul 2001 21:23:21 +0200 akim (ace/c/9_autoupdate 1.8 
644)
+++ autoupdate.in Sun, 29 Jul 2001 11:58:05 +0200 akim (ace/c/9_autoupdate 1.8 
644)
@@ -22,22 +22,29 @@
 # Rewritten by Akim Demaille <address@hidden>.
 
 use 5.005;
+
+BEGIN
+{
+  my $prefix = "@prefix@";
+  # FIXME: Import Struct into Autoconf.
+  my $perllibdir = $ENV{'autom4te_perllibdir'} || "@datadir@";
+  unshift @INC, "$perllibdir";
+}
+
 use Getopt::Long;
 use File::Basename;
+use Autoconf::General;
 use strict;
 
 (my $me = $0) =~ s,.*[\\/],,;
 
 # Lib files.
 my $autoconf_dir = $ENV{"AC_MACRODIR"} || "@datadir@";
-my $autoconf = '';
-my $debug = 0;
+my $autoconf = find_peer ('autoconf', "@bindir@", 'autoconf-name');
 my $localdir = '.';
 # m4.
 my $m4 = $ENV{"M4"} || "@M4@";
-my $verbose = 0;
 my $SIMPLE_BACKUP_SUFFIX = $ENV{'SIMPLE_BACKUP_SUFFIX'} || '~';
-my $tmp = '';
 
 
 ## ---------- ##
@@ -45,37 +52,6 @@
 ## ---------- ##
 
 
-# &mktmpdir ()
-# ------------
-sub mktmpdir ()
-{
-  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
-
-  # If mktemp supports dirs, use it to please Marc E.
-  $tmp = `(umask 077 && mktemp -d -q "$TMPDIR/auXXXXXX") 2>/dev/null`;
-  chomp $tmp;
-
-  if (!$tmp || !-d $tmp)
-    {
-      $tmp = "$TMPDIR/au" . int (rand 10000) . ".$$";
-      mkdir $tmp, 0700
-       or die "$me: cannot create $tmp: $!\n";
-    }
-
-  print STDERR "$me:$$: working in $tmp\n"
-    if $debug;
-}
-
-
-# verbose
-# -------
-sub verbose (@)
-{
-  print STDERR "$me: ", @_, "\n"
-    if $verbose;
-}
-
-
 # END
 # ---
 # Exit nonzero whenever closing STDOUT fails.
@@ -106,23 +82,6 @@ sub END
 }
 
 
-# xsystem ($COMMAND)
-# ------------------
-sub xsystem ($)
-{
-  my ($command) = @_;
-
-  verbose "running: $command";
-
-  (system $command) == 0
-    or die ("$me: "
-           . (split (' ', $command))[0]
-           . " failed with exit status: "
-           . ($? >> 8)
-           . "\n");
-}
-
-
 # print_usage ()
 # --------------
 # Display usage (--help).
@@ -172,28 +131,6 @@ sub print_version
 }
 
 
-# $CONFIGURE_AC
-# &find_configure_ac ()
-# ---------------------
-sub find_configure_ac ()
-{
-  if (-f 'configure.ac')
-    {
-      if (-f 'configure.in')
-       {
-         warn "warning: `configure.ac' and `configure.in' both present.\n";
-         warn "warning: proceeding with `configure.ac'.\n";
-       }
-      return 'configure.ac';
-    }
-  elsif (-f 'configure.in')
-    {
-      return 'configure.in';
-    }
-  return;
-}
-
-
 # parse_args ()
 # -------------
 # Process any command line arguments.
@@ -226,45 +163,11 @@ sub parse_args ()
 }
 
 
-# find_slaves
-# -----------
-# Find the lib files and autoconf.
-sub find_slaves ()
-{
-  # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
-  die "Autoconf requires GNU m4 1.4 or later\n"
-    if system "$m4 --help </dev/null 2>&1 | fgrep reload-state >/dev/null";
-
-  # autoconf.
-  (my $dir = $0) =~ s,[^\\/]*$,,;
-
-  # We test "$dir/autoconf" in case we are in the build tree, in which case
-  # the names are not transformed yet.
-  foreach my $file ($ENV{"AUTOCONF"} || '',
-                   "$dir/@autoconf-name@",
-                   "$dir/autoconf",
-                   "@bindir@/@autoconf-name@")
-    {
-      if (-x $file)
-       {
-         $autoconf = $file;
-         last;
-       }
-    }
-
-  # This is needed because perl's '-x' isn't a smart as bash's; that
-  # is, it won't find autoconf.sh.
-  $autoconf = 'autoconf'
-    if !$autoconf;
-}
-
-
 ## -------------- ##
 ## Main program.  ##
 ## -------------- ##
-find_slaves;
 parse_args;
-mktmpdir;
+mktmpdir ('au');
 $autoconf .= " --autoconf-dir $autoconf_dir --localdir $localdir ";
 $autoconf .= "--debug " if $debug;
 $autoconf .= "--verbose " if $verbose;
@@ -278,11 +181,11 @@ sub find_slaves ()
 # unm4.m4 -- disable the m4 builtins.
 # savem4.m4 -- save the m4 builtins.
 open M4_M4, ">$tmp/m4.m4"
-  or die "$me: cannot open: $!\n";
+  or die "$me: cannot open $tmp/m4.m4: $!\n";
 open UNM4_M4, ">$tmp/unm4.m4"
-  or die "$me: cannot open: $!\n";
+  or die "$me: cannot open $tmp/unm4.m4: $!\n";
 open M4SAVE_M4, ">$tmp/m4save.m4"
-  or die "$me: cannot open: $!\n";
+  or die "$me: cannot open $tmp/unm4.m4: $!\n";
 foreach (@m4_builtins)
   {
     print M4_M4     "_au_define([$_], _au_defn([_au_$_]))\n";
Index: lib/Autoconf/Makefile.am
--- lib/Autoconf/Makefile.am Sun, 15 Jul 2001 16:36:26 +0200 akim 
(ace/c/22_Makefile.a 1.1 666)
+++ lib/Autoconf/Makefile.am Sun, 29 Jul 2001 09:57:48 +0200 akim 
(ace/c/22_Makefile.a 1.1 666)
@@ -1,5 +1,5 @@
 ## Process this file with automake to create Makefile.in
 
 perllibdir = $(pkgdatadir)/Autoconf
-perllib_DATA = Struct.pm
+perllib_DATA = General.pm Struct.pm
 EXTRA_DIST = $(perllib_DATA)
Index: man/Makefile.am
--- man/Makefile.am Fri, 27 Jul 2001 20:21:13 +0200 akim (ace/b/3_Makefile.a 
1.10 644)
+++ man/Makefile.am Sun, 29 Jul 2001 11:51:50 +0200 akim (ace/b/3_Makefile.a 
1.10 644)
@@ -49,6 +49,7 @@
        test -f $(top_srcdir)/config/$* && prog=$(top_srcdir)/config/$*; \
        if test -n "$$prog"; then \
          echo "Updating man page $@"; \
+         autom4te_perllibdir="$(top_srcdir)/lib" \
          $(HELP2MAN) \
            --include=$(srcdir)/$*.x \
            --include=$(srcdir)/common.x \
Index: tests/tools.at
--- tests/tools.at Sun, 29 Jul 2001 09:44:07 +0200 akim (ace/b/30_tools.m4 1.40 
666)
+++ tests/tools.at Sun, 29 Jul 2001 11:55:28 +0200 akim (ace/b/30_tools.m4 1.40 
666)
@@ -80,6 +80,7 @@
 # | ./autom4te syntax OK
 # Ignore it, it might change between releases.
 AT_CHECK([$PERL -c ../autom4te],   0, [], [ignore])
+AT_CHECK([$PERL -c ../autoscan],   0, [], [ignore])
 AT_CHECK([$PERL -c ../autoupdate], 0, [], [ignore])
 
 AT_CLEANUP
Index: lib/Autoconf/General.pm
--- lib/Autoconf/General.pm Sun, 29 Jul 2001 12:04:05 +0200 akim ()
+++ lib/Autoconf/General.pm Sun, 29 Jul 2001 11:50:12 +0200 akim 
(ace/c/32_General.pm  644)
@@ -0,0 +1,160 @@
+# autoconf -- create `configure' using m4 macros
+# Copyright 2001 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.
+
+package Autoconf::General;
+
+use 5.005;
+use Exporter;
+use File::Basename;
+use Carp;
+use strict;
+use vars qw (@ISA @EXPORT $me);
+
address@hidden = qw (Exporter);
address@hidden = qw (&find_configure_ac &find_peer &mktmpdir &verbose &xsystem
+             $me $verbose $debug $tmp);
+
+# Variable we share with the main package.  Be sure to have a single
+# copy of them: using `my' together with multiple inclusion of this
+# package would introduce several copies.
+use vars qw ($me);
+$me = basename ($0);
+
+use vars qw ($verbose);
+$verbose = 0;
+
+use vars qw ($debug);
+$debug = 0;
+
+
+# $CONFIGURE_AC
+# &find_configure_ac ()
+# ---------------------
+sub find_configure_ac ()
+{
+  if (-f 'configure.ac')
+    {
+      if (-f 'configure.in')
+       {
+         warn "warning: `configure.ac' and `configure.in' both present.\n";
+         warn "warning: proceeding with `configure.ac'.\n";
+       }
+      return 'configure.ac';
+    }
+  elsif (-f 'configure.in')
+    {
+      return 'configure.in';
+    }
+  return;
+}
+
+
+# $PEER_PATH
+# find_peer($PEER, $BINDIR, $PEER-NAME)
+# -------------------------------------
+# Look for $PEER executables: autoconf, autoheader etc.
+# $BINDIR is @bindir@, and $PEER-NAME the transformed peer name
+# (when configured with --transform-program-names etc.).
+# We could have it AC_SUBST'ed in here, but it then means General.pm
+# is in builddir, hence more paths to adjust etc.  Yick.
+sub find_peer ($$$)
+{
+  my ($peer, $bindir, $peer_name) = @_;
+  my $res = undef;
+  my $PEER = uc $peer;
+  my $dir = dirname ($0);
+
+  # We test "$dir/autoconf" in case we are in the build tree, in which case
+  # the names are not transformed yet.
+  foreach my $file ($ENV{"$PEER"} || '',
+                   "$dir/$peer_name",
+                   "$dir/$peer",
+                   "$bindir/$peer_name")
+    {
+      # FIXME: This prevents passing options...  Maybe run --version?
+      if (-x $file)
+       {
+         $res = $file;
+         last;
+       }
+    }
+
+  # This is needed because perl's '-x' isn't a smart as bash's; that
+  # is, it won't find `autoconf.sh' etc.
+  $res ||= $peer;
+
+  return $res;
+}
+
+
+# Our tmp dir.
+use vars qw ($tmp);
+$tmp = undef;
+
+# mktmpdir ($SIGNATURE)
+# ---------------------
+# Create a temporary directory which name is based on $SIGNATURE.
+sub mktmpdir ($)
+{
+  my ($signature) = @_;
+  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
+
+  # If mktemp supports dirs, use it.
+  $tmp = `(umask 077 &&
+           mktemp -d -q "$TMPDIR/${signature}XXXXXX") 2>/dev/null`;
+  chomp $tmp;
+
+  if (!$tmp || ! -d $tmp)
+    {
+      $tmp = "$TMPDIR/$signature" . int (rand 10000) . ".$$";
+      mkdir $tmp, 0700
+       or croak "$me: cannot create $tmp: $!\n";
+    }
+
+  print STDERR "$me:$$: working in $tmp\n"
+    if $debug;
+}
+
+
+# verbose
+# -------
+sub verbose (@)
+{
+  print STDERR "$me: ", @_, "\n"
+    if $verbose;
+}
+
+
+# xsystem ($COMMAND)
+# ------------------
+sub xsystem ($)
+{
+  my ($command) = @_;
+
+  verbose "running: $command";
+
+  (system $command) == 0
+    or croak ("$me: "
+             . (split (' ', $command))[0]
+             . " failed with exit status: "
+             . ($? >> 8)
+             . "\n");
+}
+
+
+1; # for require



reply via email to

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