From mikko@mt.dynas.se Mon Aug  9 01:20:41 1999
Return-Path: <mikko@mt.dynas.se>
Received: from karon.dynas.se (karon.dynas.se [192.71.43.4])
	by hub.freebsd.org (Postfix) with SMTP id 1B90715177
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  9 Aug 1999 01:20:34 -0700 (PDT)
	(envelope-from mikko@mt.dynas.se)
Received: (qmail 47067 invoked from network); 9 Aug 1999 08:18:47 -0000
Received: from spirit.sto.dynas.se (HELO spirit.dynas.se) (172.16.1.10)
  by karon.sto.dynas.se with SMTP; 9 Aug 1999 08:18:47 -0000
Received: from mt.dynas.se by spirit.dynas.se with smtp
	(Smail3.1.28.1 #32) id m11Dkdq-000iT7C; Mon, 9 Aug 99 10:18:46 +0200
Received: (from mikko@localhost)
	by mt.dynas.se (8.9.3/8.9.3) id KAA06421;
	Mon, 9 Aug 1999 10:19:48 +0200 (CEST)
	(envelope-from mikko)
Message-Id: <199908090819.KAA06421@mt.dynas.se>
Date: Mon, 9 Aug 1999 10:19:48 +0200 (CEST)
From: mikko@dynas.se
Sender: mikko@mt.dynas.se
Reply-To: mikko@dynas.se
To: FreeBSD-gnats-submit@freebsd.org
Subject: make cannot find archive members
X-Send-Pr-Version: 3.2

>Number:         13039
>Category:       bin
>Synopsis:       make cannot find archive members
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    julian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug  9 01:20:00 PDT 1999
>Closed-Date:    Wed Sep 15 17:27:31 PDT 1999
>Last-Modified:  Wed Sep 15 17:29:14 PDT 1999
>Originator:     Mikko Tyljrvi
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

 Any FreeBSD/i386 between 3.1 (the oldest I have tested) and
 4.0-CURRENT Fri Aug  6 18:44:10 CEST 1999

>Description:

Make no longer properly parses archive files, so using archive members
as make targets, as described in PSD:12 section 4.2, does not work.


>How-To-Repeat:


Create a makefile, building a tiny archive. Type "make" a couple of
times, and watch make re-build the last target every time (actually,
not if make:ing several times within the same second).

  mt% echo 'int foo;' > x.c
  mt% cat > Makefile
  OBJS = x.o
  libx.a: libx.a($(OBJS))
	  ar crs $@ $?
  mt% make
  cc -O -pipe -c x.c
  ar crs libx.a x.o
  mt% make
  ar crs libx.a x.o
  mt% make
  ar crs libx.a x.o
  mt% make -dm
  Examining x.c...modified 9:54:47 Aug 9, 1999...up-to-date.
  Examining x.o...modified 9:55:19 Aug 9, 1999...up-to-date.
  Examining libx.a(x.o)...non-existent...modified before source...out-of-date.
			  ^^^^^^^^^^^^- not true...
  update time: 9:55:26 Aug 9, 1999
  Examining libx.a...modified 9:55:23 Aug 9, 1999...library...out-of-date.
  ar crs libx.a x.o
  update time: 9:55:26 Aug 9, 1999

Try the same thing with GNU make:

  mt% gmake
  gmake: `libx.a' is up to date.
  
You can even remove the object file (as per documentation for pmake):
  
  mt% rm x.o
  mt% gmake
  gmake: `libx.a' is up to date.

>Fix:
	
It looks like "ar" and friends from the GNU binutils build SVR4-ish
archives, with the index list in an entry called "/", and the long
file name table in one called "//".  See the comments in
"/usr/src/contrib/binutils/bfd/archive.c"

Most of the relevant code is already present in "make" - it is mainly
a matter of ifdeffing.  For example, like so:


diff -ru /usr/src/usr.bin/make/arch.c /tmp/make/arch.c
--- /usr/src/usr.bin/make/arch.c	Thu Oct 29 19:17:44 1998
+++ /tmp/make/arch.c	Mon Aug  9 09:53:40 1999
@@ -118,7 +118,7 @@
 static void ArchFree __P((ClientData));
 static struct ar_hdr *ArchStatMember __P((char *, char *, Boolean));
 static FILE *ArchFindMember __P((char *, char *, struct ar_hdr *, char *));
-#if defined(__svr4__) || defined(__SVR4)
+#if defined(__svr4__) || defined(__SVR4) || defined(__ELF__)
 #define SVR4ARCHIVES
 static int ArchSVR4Entry __P((Arch *, char *, size_t, FILE *));
 #endif
@@ -474,7 +474,7 @@
      * the comparisons easier...
      */
     cp = strrchr (member, '/');
-    if (cp != (char *) NULL) {
+    if (cp != (char *) NULL && strcmp(member, RANLIBMAG) != 0) {
 	member = cp + 1;
     }
 
diff -ru /usr/src/usr.bin/make/config.h /tmp/make/config.h
--- /usr/src/usr.bin/make/config.h	Thu Oct 29 19:17:45 1998
+++ /tmp/make/config.h	Mon Aug  9 09:53:06 1999
@@ -114,4 +114,8 @@
 # ifndef RANLIBMAG
 #  define RANLIBMAG "__.SYMDEF"
 # endif
+#else
+# ifndef RANLIBMAG
+#  define RANLIBMAG "/"
+# endif
 #endif

>Release-Note:
>Audit-Trail:

From: Tim Vanderhoek <tim@ppp18344.on.bellglobal.com>
To: freebsd-gnats-submit@freebsd.org, mikko@dynas.se
Cc:  
Subject: Re: bin/13039: make cannot find archive members
Date: Sun, 22 Aug 1999 01:10:05 -0400 (EDT)

 >
 >   make cannot find archive members
 
 This is more or less a duplicate of bin/10274, but I'm leaving both open.
 

From: Julian Elischer <julian@whistle.com>
To: freebsd-gnats-submit@freebsd.org, mikko@dynas.se
Cc:  
Subject: Re: bin/13039: make cannot find archive members
Date: Fri, 10 Sep 1999 14:29:48 -0700

 I have checked this change into -current.
 I will wait a little before adding it to 3.x
 
 julian
 

From: Julian Elischer <julian@whistle.com>
To: freebsd-gnats-submit@freebsd.org, mikko@dynas.se
Cc:  
Subject: Re: bin/13039: make cannot find archive members
Date: Fri, 10 Sep 1999 14:31:07 -0700

 I believe 10274 is a different problem..
 This fix doesn't seem to affect that.
 
 julian
 
Responsible-Changed-From-To: freebsd-bugs->julian 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Mon Sep 13 09:24:06 PDT 1999 
Responsible-Changed-Why:  
Julian will MFC. 
State-Changed-From-To: open->closed 
State-Changed-By: julian 
State-Changed-When: Wed Sep 15 17:27:31 PDT 1999 
State-Changed-Why:  
patch applied to -current and 3.x 
>Unformatted:
