components/make/patches/32511.patch
author Rich Burridge <rich.burridge@oracle.com>
Mon, 18 Mar 2013 14:10:55 -0700
changeset 1219 cdd8157bab31
parent 913 646785c43987
permissions -rw-r--r--
PSARC 2012/095 pbzip2 version 1.1.6 - parallel bzip2 15636394 SUNBT6943710 Parallel bzip2 - pbzip2 - should be part of the Solaris distro

This diff is taken from git:
https://github.com/scfc/gnumake/commit/d952d36acf66398b7fe1e3efa15af73add937ecb
minus changes in the 'Changelog' files which don't apply cleanly to our sources

and it fixes Savannah bug 32511
http://savannah.gnu.org/bugs/?32511

diff --git a/ChangeLog b/ChangeLog
index 2345823..e2a9786 100644
diff --git a/remake.c b/remake.c
index 669eadc..5526624 100644
--- a/remake.c
+++ b/remake.c
@@ -1534,8 +1534,7 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
   unsigned int liblen;
 
   /* Information about the earliest (in the vpath sequence) match.  */
-  unsigned int best_vpath, best_path;
-  unsigned int std_dirs = 0;
+  unsigned int best_vpath = 0, best_path = 0;
 
   char **dp;
 
@@ -1554,6 +1553,7 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
       static char *buf = NULL;
       static unsigned int buflen = 0;
       static int libdir_maxlen = -1;
+      static unsigned int std_dirs = 0;
       char *libbuf = variable_expand ("");
 
       /* Expand the pattern using LIB as a replacement.  */
diff --git a/tests/scripts/features/vpath3 b/tests/scripts/features/vpath3
index 978c5ee..c6ede28 100644
--- a/tests/scripts/features/vpath3
+++ b/tests/scripts/features/vpath3
@@ -1,50 +1,35 @@
-#                                                                     -*-perl-*-
+#                                                                    -*-perl-*-
 
 $description = "Test the interaction of the -lfoo feature and vpath";
 $details = "";
 
-open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE "vpath %.a a1\n";
-print MAKEFILE "vpath %.so b1\n";
-print MAKEFILE "vpath % a2 b2\n";
-print MAKEFILE "vpath % b3\n";
-print MAKEFILE "all: -l1 -l2 -l3; \@echo \$^\n";
-
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
-
-mkdir("a1", 0777);
-mkdir("b1", 0777);
-mkdir("a2", 0777);
-mkdir("b2", 0777);
-mkdir("b3", 0777);
-
-@files_to_touch = ("a1${pathsep}lib1.a",
-		   "b1${pathsep}lib1.so",
-		   "a2${pathsep}lib2.a",
-		   "b2${pathsep}lib2.so",
-		   "lib3.a",
-		   "b3${pathsep}lib3.so");
+my @dirs_to_make = qw(a1 b1 a2 b2 b3);
+for my $d (@dirs_to_make) {
+    mkdir($d, 0777);
+}
 
+my @files_to_touch = ("a1${pathsep}lib1.a",
+                      "a1${pathsep}libc.a",
+                      "b1${pathsep}lib1.so",
+                      "a2${pathsep}lib2.a",
+                      "b2${pathsep}lib2.so",
+                      "lib3.a",
+                      "b3${pathsep}lib3.so");
 &touch(@files_to_touch);
 
-&run_make_with_options($makefile,"",&get_logfile);
-
-# Create the answer to what should be produced by this Makefile
-$answer = "a1${pathsep}lib1.a a2${pathsep}lib2.a lib3.a\n";
-
-if (&compare_output($answer,&get_logfile(1)))
-{
-  unlink @files_to_touch;
-  rmdir("a1");
-  rmdir("b1");
-  rmdir("a2");
-  rmdir("b2");
-  rmdir("b3");
+run_make_test('
+vpath %.h b3
+vpath %.a a1
+vpath %.so b1
+vpath % a2 b2
+vpath % b3
+all: -l1 -lc -l2 -l3; @echo $^
+',
+              '', "a1${pathsep}lib1.a a1${pathsep}libc.a a2${pathsep}lib2.a lib3.a\n");
+
+unlink(@files_to_touch);
+for my $d (@dirs_to_make) {
+    rmdir($d);
 }
 
 1;