[comp.bugs.4bsd] make fails to support archive

daved@physiol.su.oz (Dave Davey) (12/07/88)

According to documentation, make supports dependencies of archive
members on source files, e.g. in the manual for make:

Two special forms of a name are recognized.  A name like
a(b) means the file named b stored in the archive named a.

This is supposed to allow for makefiles like:

L	= lib.a
LIBOBJS	= $L(a.o) $L(b.o)
.c.a:
	$(CC) -c $<
	ar rv $L $*.o
	rm -f $*.o
L:	 $(LIBOBJS)

The 4.3BSD and 4.3BSD(tahoe) versions of make do not support
this form of dependency - only some of the code needed
is present.  The following context differences will patch either
the original 4.3 or the tahoe sources.

*** doname.c.orig	Wed Dec  7 14:15:02 1988
--- doname.c	Wed Dec  7 14:18:07 1988
***************
*** 14,19 ****
--- 14,22 ----
  
  extern char *sys_siglist[];
  
+ extern	char	arfname[MAXNAMLEN];
+ char		*savenamep;
+ 
  doname(p, reclevel, tval)
  register struct nameblock *p;
  int reclevel;
***************
*** 140,145 ****
--- 143,157 ----
  		}
  	}
  
+ if((strchr(p->namep,'(')) != NULL)
+ {
+ 	/* fake the target */
+ 	if(dbgflag)
+ 		printf("\tARCHIVE MEMBER: %s\n",arfname);
+ 	savenamep = p->namep;
+ 	p->namep = copys(arfname);
+ }
+ 
  /* Look for implicit dependents, using suffix rules */
  
  for(lp = sufflist ; lp ; lp = lp->nxtlineblock)
***************
*** 148,153 ****
--- 160,170 ----
  	pnamep = suffp->depname->namep;
  	if(suffix(p->namep , pnamep , prefix))
  		{
+ 		if(savenamep)
+ 		{
+ 			/* fake the type of target */
+ 			pnamep = ".a";
+ 		}
  
  		srchdir( concat(prefix,"*",temp) , NO, (struct depblock *) NULL);
  		for(lp1 = sufflist ; lp1 ; lp1 = lp1->nxtlineblock)
*** files.c.orig	Wed Dec  7 14:15:19 1988
--- files.c	Wed Dec  7 14:16:51 1988
***************
*** 406,412 ****
  
  static long arflen;
  static long arfdate;
! static char arfname[16];
  FILE *arfd;
  long int arpos, arlen;
  
--- 406,412 ----
  
  static long arflen;
  static long arfdate;
! char arfname[MAXNAMLEN];
  FILE *arfd;
  long int arpos, arlen;
  
***************
*** 470,475 ****
--- 470,476 ----
  		}
  	}
  
+ 	strcpy(arfname,s);
  clarch();
  return( 0L);
  }
***************
*** 519,524 ****
--- 520,526 ----
  {
  	struct ar_hdr arhead;
  	long atol();
+ 	int i;
  
  arpos += (arflen + 1) & ~1L;	/* round archived file length up to even */
  if(arpos >= arlen)
***************
*** 535,540 ****
--- 537,552 ----
  	arfdate = arhead.ar_date;
  #endif
  	strncpy(arfname, arhead.ar_name, sizeof(arhead.ar_name));
+ #ifdef ASCARCH
+ 	for(i=sizeof arfname; i > 0; i--)
+ 	{
+ 		if(arfname[i-1] == '\0')
+ 			continue;
+ 		if(arfname[i-1] != ' ')
+ 			break;
+ 		arfname[i-1] = '\0';
+ 	}
+ #endif ASCARCH
  return(1);
  }