From gunther@aurora.regenstrief.org  Mon Oct 15 14:55:02 2001
Return-Path: <gunther@aurora.regenstrief.org>
Received: from aurora.regenstrief.org (aurora.regenstrief.org [134.68.31.122])
	by hub.freebsd.org (Postfix) with ESMTP id ACB0837B409
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 15 Oct 2001 14:55:01 -0700 (PDT)
Received: (from gunther@localhost)
	by aurora.regenstrief.org (8.11.6/8.9.3) id f9FLtQi67462;
	Mon, 15 Oct 2001 16:55:26 -0500 (EST)
	(envelope-from gunther)
Message-Id: <200110152155.f9FLtQi67462@aurora.regenstrief.org>
Date: Mon, 15 Oct 2001 16:55:26 -0500 (EST)
From: Gunther Schadow <gunther@aurora.regenstrief.org>
Reply-To: Gunther Schadow <gunther@aurora.regenstrief.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: fix crunchgen to work with more contrib-kind of sources
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31304
>Category:       bin
>Synopsis:       [patch] fix crunchgen(1) to work with more contrib-kind of sources
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 15 15:00:01 PDT 2001
>Closed-Date:    Mon Feb 21 09:49:24 UTC 2011
>Last-Modified:  Mon Feb 21 09:49:24 UTC 2011
>Originator:     Gunther Schadow
>Release:        FreeBSD 4.4-RELEASE i386
>Organization:
Regenstrief Institute
>Environment:
System: FreeBSD aurora.regenstrief.org 4.4-RELEASE FreeBSD 4.4-RELEASE #0: Thu Sep 20 15:35:07 EST 2001 root@aurora.regenstrief.org:/usr/src/sys/compile/AURORA i386


	
>Description:
Crunchgen does not currently crunch all FreeBSD src programs.
This bug report contains a patch to make it crunch more of them.
For example, none of the bind-8 related programs can be crunched
without severe headache. Take for example usr.bin/dnsquery. There
is only a short Makefile that includes another Makefile via a
relative path:

.include "../../usr.sbin/named/Makefile.inc"

The problem is that when crunchgen extracts the make parameters,
it does not actually cd into "usr.bin/dnsquery" so that the 
relative path makes no sense. 

The attached patches fix this problem as follows:

- always cd into the srcdir when running the generated makefile
  extracting make variables

- in order for this to be done, change some occurrences of 
  p->srcdir to p->realsrcdir

The fix is minor thanks to someone having already provided for
p->realsrcdir! This fix should complete what was begun then.

Note: I'm not 100% sure this fix will not break certain 
crunchgen.conf logics that relied on the fact that the 
generated makefile for extracting make variables is run
in crunchgen.conf's directory instead of the srcdir.
However, I can see no rationale for why such logic needs
to be.

	
>How-To-Repeat:
	
>Fix:
*** crunchgen.c~        Sun Aug 19 05:41:57 2001
--- crunchgen.c Mon Oct 15 16:35:43 2001
***************
*** 631,638 ****
                snprintf(line, MAXLINELEN, "Using %s for %s", path, p->name);
                status(line);
        } else
!               if (p->srcdir)
!                       snprintf(path, sizeof(path), "%s/Makefile", p->srcdir);
        if (!p->objs && p->srcdir && is_nonempty_file(path))
                fillin_program_objs(p, path);
  
--- 631,639 ----
                snprintf(line, MAXLINELEN, "Using %s for %s", path, p->name);
                status(line);
        } else
!               if (p->realsrcdir)
!                       snprintf(path, sizeof(path), "%s/Makefile",
!                                p->realsrcdir);
        if (!p->objs && p->srcdir && is_nonempty_file(path))
                fillin_program_objs(p, path);
  
***************
*** 686,700 ****
        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;
--- 687,715 ----
        fprintf(f, ".endif\n");
        fprintf(f, "loop:\n\t@echo 'OBJS= '${%s}\n", objvar);
  
!       fprintf(f, "crunchgen_objs:\n\t@");
! 
!       /* assure that we run this make file in the source directory */
!       if(p->realsrcdir) {
!         fprintf(f, "cd %s;", p->realsrcdir);
!       }
! 
!       fprintf(f, "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);
  
!       /* assure that we run this make file in the source directory */
!       if(p->srcdir) {
!         snprintf(line, MAXLINELEN, "cd %s ; make -f %s crunchgen_objs 2>&1", 
!                  p->srcdir, tempfname);
!       } 
!       else
!         snprintf(line, MAXLINELEN, "make -f %s crunchgen_objs 2>&1", 
!                  tempfname);
!         
        if ((f = popen(line, "r")) == NULL) {
                warn("submake pipe");
                goterror = 1;

	
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->joe 
Responsible-Changed-By: joe 
Responsible-Changed-When: Tue Oct 16 02:54:38 PDT 2001 
Responsible-Changed-Why:  
I'll take a look.  Thanks. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31304 
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Mon Apr 17 19:43:17 UTC 2006 
State-Changed-Why:  
Did this patch ever get incorporated? 


Responsible-Changed-From-To: joe->linimon 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Apr 17 19:43:17 UTC 2006 
Responsible-Changed-Why:  
joe has returned his bit for safekeeping due to lack of time. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=31304 
State-Changed-From-To: feedback->suspended 
State-Changed-By: linimon 
State-Changed-When: Sun May 6 00:42:41 UTC 2007 
State-Changed-Why:  
No one ever responded to my request for status about this PR, so mark 
it as suspended. 


Responsible-Changed-From-To: linimon->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun May 6 00:42:41 UTC 2007 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=31304 
State-Changed-From-To: suspended->closed 
State-Changed-By: brucec 
State-Changed-When: Mon Feb 21 09:48:20 UTC 2011 
State-Changed-Why:  
This appears to have been fixed with r113855 and r113886. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=31304 
>Unformatted:
