[net.unix] Make problem

gdykes@batcomputer.TN.CORNELL.EDU (Gene Dykes) (02/21/86)

(My apologies if this was seen before - I was told that my previous
posting never got out...)

In BSD4.2 and BSD4.3, I have the following problem:
In the manual for make, there are the following sentences...

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

Now, suppose I have a Makefile that looks like this:

main: main.o /usr/lib/libcurses.a(scroll.o)
	cc main.o -lcurses

In other words I want main to depend on the binary scroll.o which is in
the archive /usr/lib/libcurses.a

What I get is the following message:

Make:  Don't know how to make /usr/lib/libcurses.a(scroll.o).  Stop.

What this means to me is that make may very well RECOGNIZE such a construct
(since it gives a different message if the archive doesn't exist),
but it has no idea what to DO about it.  Since the archived binary is much
older than main there should be no reason to remake it.

It seems to me it would be very useful to have makefiles depending on
archived binaries, but this doesn't work.   I've been reading this and related
newsgroups for years now and I've never heard anybody else complain about this.
This means either that I am an idiot and don't understand the manual (please
inform me gently), or that this bug has never been found before (hard to 
believe), or that nobody cares (harder to believe).  Other possibilities
undoubtedly exist.

Thanks for any suggestions or comments.

-- 
Gene Dykes, 120 Rand Hall, Cornell U., Ithaca, NY 14853 (607)256-4880
{ihnp4,decvax,allegra,vax135}!cornell!batcomputer!gdykes

matt@oddjob.UUCP (Matt Crawford) (02/24/86)

The make syntaxes "a(b)" and "a((b))" don't even come
close to working in the 4.2 make.  The following fixes
the former only.  In /usr/src/bin/make:

RCS file: RCS/files.c,v
retrieving revision 1.1
diff -c -r1.1 files.c
*** /tmp/,RCSt1003671	Sun Feb 23 20:16:33 1986
--- files.c	Sun Feb 23 20:16:21 1986
***************
*** 372,378
  
  static long arflen;
  static long arfdate;
! static char arfname[16];
  FILE *arfd;
  long int arpos, arlen;
  

--- 372,378 -----
  
  static long arflen;
  static long arfdate;
! static char arfname[16];		/* size S/B determined from ar.h */
  FILE *arfd;
  long int arpos, arlen;
  
***************
*** 414,420
  	{
  	if(objarch)
  		{
! 		getobj();
  		nsym = objhead.a_syms / sizeof(objentry);
  		for(i = 0; i<nsym ; ++i)
  			{

--- 414,421 -----
  	{
  	if(objarch)
  		{
! 		if( !getobj() )
! 			continue;	/* not a .o file (eg: __.SYMDEF) */
  		nsym = objhead.a_syms / sizeof(objentry);
  		for(i = 0; i<nsym ; ++i)
  			{
***************
*** 484,489
  getarch()
  {
  	struct ar_hdr arhead;
  	long atol();
  
  arpos += (arflen + 1) & ~1L;	/* round archived file length up to even */

--- 485,491 -----
  getarch()
  {
  	struct ar_hdr arhead;
+ 	char *p;
  	long atol();
  
  arpos += (arflen + 1) & ~1L;	/* round archived file length up to even */
***************
*** 501,506
  	arfdate = arhead.ar_date;
  #endif
  	strncpy(arfname, arhead.ar_name, sizeof(arhead.ar_name));
  return(1);
  }
  

--- 503,511 -----
  	arfdate = arhead.ar_date;
  #endif
  	strncpy(arfname, arhead.ar_name, sizeof(arhead.ar_name));
+ 	p = &arfname[sizeof(arhead.ar_name)];
+ 	while( *--p == ' ' )
+ 		*p = '\0';		/* trim for eqstr */
  return(1);
  }
  
***************
*** 511,517
  
  fread( (char *) &objhead, sizeof(objhead), 1, arfd);
  if (N_BADMAG(objhead))
! 	fatal1("%s is not an object module", arfname);
  skip = objhead.a_text + objhead.a_data;
  #if defined(vax) || defined(sun)
  skip += objhead.a_trsize + objhead.a_drsize;

--- 516,522 -----
  
  fread( (char *) &objhead, sizeof(objhead), 1, arfd);
  if (N_BADMAG(objhead))
! 	return 0;
  skip = objhead.a_text + objhead.a_data;
  #if defined(vax) || defined(sun)
  skip += objhead.a_trsize + objhead.a_drsize;
***************
*** 520,525
  	skip *= 2;
  #endif
  fseek(arfd, skip, 1);
  }
  
  

--- 525,531 -----
  	skip *= 2;
  #endif
  fseek(arfd, skip, 1);
+ return 1;
  }
  
  
***************
*** 528,534
  int n;
  {
  register int i;
! for(i = 0 ; i < n ; ++i)
  	if(*a++ != *b++)
  		return(NO);
  return(YES);

--- 534,540 -----
  int n;
  {
  register int i;
! for(i = 0 ; i < n && (*a || *b) ; ++i)
  	if(*a++ != *b++)
  		return(NO);
  return(YES);
_____________________________________________________
Matt		University	crawford@anl-mcs.arpa
Crawford	of Chicago	ihnp4!oddjob!matt