automake
[Top][All Lists]
Advanced

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

29-backname.patch


From: Akim Demaille
Subject: 29-backname.patch
Date: Wed, 07 Feb 2001 00:56:40 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * automake.in: Various formatting changes, and modernization of
        Perl constructs.
        (&backname): New.
        (&handle_configure, define_standard_variables): Use it.
        
        
Index: automake.in
--- automake.in Sun, 04 Feb 2001 15:32:38 +0100 akim (am/f/39_automake.i 1.33 
755)
+++ automake.in Sun, 04 Feb 2001 17:30:42 +0100 akim (am/f/39_automake.i 1.33 
755)
@@ -447,7 +447,7 @@ sub parse_arguments
        if ($arglist[0] eq "--version")
        {
            print "automake (GNU $PACKAGE) $VERSION\n\n";
-           print "Copyright 2000 Free Software Foundation, Inc.\n";
+           print "Copyright 2000, 2001 Free Software Foundation, Inc.\n";
            print "This is free software; see the source for copying 
conditions.  There is NO\n";
            print "warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE.\n\n";
            print "Written by Tom Tromey <address@hidden>\n";
@@ -3311,37 +3311,14 @@ sub handle_configure
            }
            else
            {
-               local (@rel_out_path);
-               # FIXME this chunk of code should be its own sub.
-               # It is used elsewhere.
-               foreach (split (/\//, $relative_dir))
-               {
-                   next if $_ eq '' || $_ eq '.';
-                   if ($_ eq '..')
-                   {
-                       # FIXME: actually this is an error.
-                       pop @rel_out_path;
-                   }
-                   else
-                   {
-                       push (@rel_out_path, '..');
-                   }
-               }
-               if (@rel_out_path)
-               {
-                   $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
-               }
-               else
-               {
-                   $ch_sans_dir = $one_hdr;
-               }
+               $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
            }
 
            &require_file_with_conf_line ($config_header_line,
                                          $FOREIGN, $ch_sans_dir);
 
            # Header defined and in this directory.
-           local (@files);
+           my @files;
            if (-f $one_name . '.top')
            {
                push (@files, "${cn_sans_dir}.top");
@@ -3362,26 +3339,24 @@ sub handle_configure
                }
                else
                {
-                   # Strange quoting because this gets fed through
-                   # Perl.
-                   push (@files, '\$(top_srcdir)/acconfig.h');
+                   push (@files, '$(top_srcdir)/acconfig.h');
                }
            }
 
-           local ($stamp_name) = 'stamp-h';
-           $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
+           my $stamp_name = 'stamp-h';
+           $stamp_name .= "$hdr_index"
+             if scalar (@config_headers) > 1;
 
-           local ($xform) = '';
+           my $xform = '';
+           my $out_dir = &dirname ($ch_sans_dir);
 
            $xform = &transform ('CONFIGURE_AC'       => $configure_ac,
                                 'FILES'              => join (' ', @files),
                                 'CONFIG_HEADER'      => $cn_sans_dir,
                                 'CONFIG_HEADER_IN'   => $ch_sans_dir,
                                 'CONFIG_HEADER_FULL' => $one_fullname,
-                                'STAMP'          => "$stamp_dir$stamp_name");
-
-           local ($out_dir) = &dirname ($ch_sans_dir);
-           $xform .= &transform ('SRC_STAMP' => "${out_dir}/${stamp_name}");
+                                'STAMP'            => "$stamp_dir$stamp_name",
+                                'SRC_STAMP'        => "$out_dir/$stamp_name");
            $output_rules .= &file_contents ('remake-hdr', $xform);
 
            &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
@@ -3773,6 +3748,7 @@ sub handle_merge_targets
     &depend ('.PHONY', 'install-strip');
 }
 
+
 # Helper for handle_merge_targets.  Note that handle_merge_targets
 # relies on the fact that this doesn't add an extra \n at the end.
 sub do_one_merge_target
@@ -6460,23 +6436,7 @@ sub read_am_file
 # twice.
 sub define_standard_variables
 {
-    # Compute relative location of the top object directory.
-    local (@topdir) = ();
-    foreach (split (/\//, $relative_dir))
-    {
-       next if $_ eq '.' || $_ eq '';
-       if ($_ eq '..')
-       {
-           pop @topdir;
-       }
-       else
-       {
-           push (@topdir, '..');
-       }
-    }
-    @topdir = ('.') if ! @topdir;
-
-    $top_builddir = join ('/', @topdir);
+    $top_builddir = backname ($relative_dir);
     $output_vars .=
         &file_contents ('header-vars',
                        &transform ('top_builddir' => $top_builddir));
@@ -6671,7 +6631,7 @@ sub initialize_global_constants
 
     # Copyright on generated Makefile.ins.
     $gen_copyright = "\
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 # Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -7790,26 +7750,60 @@ sub set_strictness
 
 ################################################################
 
+# $DIRNAME
+# &dirname ($FILE)
+# ----------------
 # Return directory name of file.
-sub dirname
+sub dirname ($)
 {
-    local ($file) = @_;
-    local ($sub);
+    my ($file) = @_;
+    my ($sub);
 
     ($sub = $file) =~ s,/+[^/]+$,,g;
     $sub = '.' if $sub eq $file;
     return $sub;
 }
 
+
+# $BASENAME
+# &basename ($FILE)
+# -----------------
 # Return file name of a file.
-sub basename
+sub basename ($)
 {
-    local ($file) = @_;
-    local ($sub);
+    my ($file) = @_;
+    my $sub;
 
     ($sub = $file) =~s,^.*/+,,g;
     return $sub;
 }
+
+
+# $BACKPATH
+# &backname ($REL-DIR)
+# --------------------
+# If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
+# For instance `src/foo' => `../..'.
+# Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
+sub backname ($)
+{
+    my ($file) = @_;
+    my (@res);
+    foreach (split (/\//, $file))
+    {
+       next if $_ eq '.' || $_ eq '';
+       if ($_ eq '..')
+       {
+           pop @res;
+       }
+       else
+       {
+           push (@res, '..');
+       }
+    }
+    return join ('/', @res) || '.';
+}
+
 
 # Ensure a file exists.
 sub create



reply via email to

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