From nobody@FreeBSD.org  Wed Mar 27 13:00:36 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 4B8FA37B42A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Mar 2002 13:00:33 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g2RL0XY33711;
	Wed, 27 Mar 2002 13:00:33 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200203272100.g2RL0XY33711@freefall.freebsd.org>
Date: Wed, 27 Mar 2002 13:00:33 -0800 (PST)
From: Sam Leffler <sam@errno.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: crunchgen does not handle Makefiles with includes properly
X-Send-Pr-Version: www-1.0

>Number:         36385
>Category:       bin
>Synopsis:       crunchgen(1) does not handle Makefiles with includes properly
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    luigi
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 27 13:10:01 PST 2002
>Closed-Date:    
>Last-Modified:  Wed May 21 21:30:23 UTC 2008
>Originator:     Sam Leffler
>Release:        4.5
>Organization:
>Environment:
FreeBSD ebb.errno.com 4.5-STABLE FreeBSD 4.5-STABLE #3: Mon Mar 18 14:41:49 PST 2002     sam@ebb.errno.com:/usr/src/sys/compile/EBB  i386
>Description:
     crunchgen does not properly handle Makefiles that have relative includes because it runs the Makefile from the current directory instead of the source directory when generating the list of object files 
>How-To-Repeat:
      Try to run crunchgen on /usr/ports/security/isakmpd; notice that it does not get the value of SRCS set properly because the .include's of features/<mumble> fail (silently because the Makefile checks if the file exists before including it). This is because crunchgen generates a temp Makefile in /tmp and then does make -f <temp makefile> from the current working directory.
>Fix:
      A patch can be found in http://www.errno.com/patches/crunchgen.patch.  This causes the make command used to generate the obj list to be done in the srcdir.  This patch also includes a -d option to aid in debugging problems like this and support for PR misc/33778.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->murray 
Responsible-Changed-By: murray 
Responsible-Changed-When: Thu Mar 28 03:27:54 PST 2002 
Responsible-Changed-Why:  
I would very much like to see something like this added so we can 
clean up the ugliness I added to src/sbin/dhclient/Makefile in 
-CURRENT. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=36385 
Responsible-Changed-From-To: murray->luigi 
Responsible-Changed-By: murray 
Responsible-Changed-When: Sun Apr 14 06:10:01 PDT 2002 
Responsible-Changed-Why:  
Luigi imported a similar change to -CURRENT.  Can you please look to 
see how this interacts with the work you are doing in this area, 
Luigi? 


http://www.freebsd.org/cgi/query-pr.cgi?pr=36385 

From: Tim Kientzle <kientzle@acm.org>
To: luigi@FreeBSD.org, sam@errno.com,
	freebsd-gnats-submit@FreeBSD.org
Cc: Nate Lawson <nate@root.org>
Subject: Re: misc/36385: crunchgen does not handle Makefiles with includes properly
Date: Tue, 19 Nov 2002 20:49:57 -0800

 This is a multi-part message in MIME format.
 --------------080106010803040502090603
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Luigi,
 
 I sent this patch in to Nate before
 I noticed the open PR on this issue.
 I think the attached diff fixes it.
 Would you please try it?
 
 Among other issues, this bug makes
 it impossible to build a crunchgen
 binary containing 'csh', which is
 necessary for a project I'm working
 on.  The attached patch seems to
 address that.
 
 Tim Kientzle
 
 --------------080106010803040502090603
 Content-Type: text/plain;
  name="kientzle_crunchgen.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="kientzle_crunchgen.diff"
 
 Index: crunchgen.c
 ===================================================================
 RCS file: /mnt/cvs/src/usr.sbin/crunch/crunchgen/crunchgen.c,v
 retrieving revision 1.31
 diff -c -r1.31 crunchgen.c
 *** crunchgen.c	30 Mar 2002 16:48:30 -0000	1.31
 --- crunchgen.c	20 Nov 2002 04:07:07 -0000
 ***************
 *** 691,705 ****
   	fprintf(f, ".endif\n");
   	fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar);
   
 ! 	fprintf(f, "crunchgen_objs:\n\t@make -f %s $(BUILDOPTS) $(%s_OPTS)",
 ! 	    tempfname, p->ident);
   	for (s = p->buildopts; s != NULL; s = s->next)
   		fprintf(f, " %s", s->str);
   	fprintf(f, " loop\n");
   
   	fclose(f);
   
 ! 	snprintf(line, MAXLINELEN, "make -f %s crunchgen_objs 2>&1", tempfname);
   	if ((f = popen(line, "r")) == NULL) {
   		warn("submake pipe");
   		goterror = 1;
 --- 691,708 ----
   	fprintf(f, ".endif\n");
   	fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar);
   
 ! 	fprintf(f, "crunchgen_objs:\n\t@cd %s && make -f %s $(BUILDOPTS) $(%s_OPTS)",
 ! 	    p->srcdir, tempfname, p->ident);
   	for (s = p->buildopts; s != NULL; s = s->next)
   		fprintf(f, " %s", s->str);
   	fprintf(f, " loop\n");
   
   	fclose(f);
   
 ! 	snprintf(line, MAXLINELEN, "cd %s && make -f %s crunchgen_objs 2>&1",
 ! 		 p->srcdir,
 ! 		 tempfname);
 ! 
   	if ((f = popen(line, "r")) == NULL) {
   		warn("submake pipe");
   		goterror = 1;
 
 
 --------------080106010803040502090603--
 
>Unformatted:
