]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 62173] Fix archive tests for non-GNU systems
authorPaul Smith <psmith@gnu.org>
Sat, 23 Apr 2022 20:30:02 +0000 (16:30 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 24 Apr 2022 14:39:32 +0000 (10:39 -0400)
Original patch from Dmitry Goncharov <dgoncharov@users.sf.net>

Fix the ar flags to match the default values in make.  If the
U option is supported, add it to the end not the beginning,
since ARFLAGS now starts with a "-".

* tests/test_driver.pl: Add defaults for global variables.
(get_osname): Preserve $osname if it's set from $^O
* tests/scripts/features/archive: Set the default arflags.
If "U" is available add it to the end of the flags.

tests/scripts/features/archives
tests/test_driver.pl

index dcd38e5a81cbde2c0f73452d0d544398c981668f..d40581194e018da9dd2641043b2ca2c86f26775a 100644 (file)
@@ -35,16 +35,17 @@ my $ar = get_config('AR') || 'ar';
 my $redir = '2>&1';
 $redir = '' if $osname eq 'VMS';
 
-my $arflags = 'rv';
+# This is the value from src/default.c
+my $arflags = $ostype eq 'aix' ? '-Xany -rv' : '-rv';
 my $arvar = "AR=$ar";
 
 # Newer versions of binutils can be built with --enable-deterministic-archives
 # which forces all timestamps (among other things) to always be 0, defeating
 # GNU make's archive support.  See if ar supports the U option to disable it.
 unlink('libxx.a');
-$_ = `$ar U$arflags libxx.a a1.o $redir`;
+$_ = `$ar ${arflags}U libxx.a a1.o $redir`;
 if ($? == 0) {
-    $arflags = 'Urv';
+    $arflags = "${arflags}U";
     $arvar = "$arvar ARFLAGS=$arflags";
 }
 
index 5522ac11b1dfd364f6253a810b6834ed46f09b85..fd5a7696849da886b3e312913472acb2a48cdce6 100644 (file)
@@ -47,6 +47,10 @@ $tests_run = 0;
 # The number of tests in this category that have passed
 $tests_passed = 0;
 
+$port_type = undef;
+$osname = undef;
+$vos = undef;
+$pathsep = undef;
 
 # Yeesh.  This whole test environment is such a hack!
 $test_passed = 1;
@@ -331,6 +335,8 @@ sub get_osname
 {
   # Set up an initial value.  In perl5 we can do it the easy way.
   $osname = defined($^O) ? $^O : '';
+  $vos = 0;
+  $pathsep = "/";
 
   # find the type of the port.  We do this up front to have a single
   # point of change if it needs to be tweaked.
@@ -366,10 +372,7 @@ sub get_osname
     $port_type = 'UNIX';
   }
 
-  if ($osname eq 'VMS')
-  {
-    $vos = 0;
-    $pathsep = "/";
+  if ($osname eq 'VMS') {
     return;
   }
 
@@ -399,7 +402,7 @@ sub get_osname
     $vos = 1;
     $pathsep = ">";
 
-  } else {
+  } elsif ($osname eq '') {
     # the following is regrettably gnarly, but it seems to be the only way
     # to not get ugly error messages if uname can't be found.
     # Hmmm, BSD/OS 2.0's uname -a is excessively verbose.  Let's try it
@@ -414,8 +417,6 @@ sub get_osname
         $osname = "(something posixy)";
       }
     }
-    $vos = 0;
-    $pathsep = "/";
   }
 
   if (! $short_filenames) {