From skv@FreeBSD.org  Mon Sep  5 09:08:47 2005
Return-Path: <skv@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 30CF316A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  5 Sep 2005 09:08:47 +0000 (GMT)
	(envelope-from skv@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0317B43D46
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  5 Sep 2005 09:08:47 +0000 (GMT)
	(envelope-from skv@FreeBSD.org)
Received: from freefall.freebsd.org (skv@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j8598ked066862
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 5 Sep 2005 09:08:46 GMT
	(envelope-from skv@freefall.freebsd.org)
Received: (from skv@localhost)
	by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j8598k7C066861;
	Mon, 5 Sep 2005 09:08:46 GMT
	(envelope-from skv)
Message-Id: <200509050908.j8598k7C066861@freefall.freebsd.org>
Date: Mon, 5 Sep 2005 09:08:46 GMT
From: skv@freebsd.org
Reply-To: skv@freebsd.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: Force imake respect CC/CXX
X-Send-Pr-Version: 3.2

>Number:         85735
>Category:       ports
>Synopsis:       Force imake respect CC/CXX
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-x11
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 05 09:10:11 GMT 2005
>Closed-Date:    Fri Nov 25 12:18:57 GMT 2005
>Last-Modified:  Fri Nov 25 12:18:57 GMT 2005
>Originator:     Sergey Skvortsov
>Release:        FreeBSD 4.11-STABLE i386
>Organization:
<Organization of PR author (multiple lines)>
>Environment:

	<Relevant environment information (multiple lines)>

>Description:

Force imake respect CC/CXX (accordingly to section 17.14 from "FreeBSD Porter's Handbook").

>How-To-Repeat:

	<Code/input/activities to reproduce the problem (multiple lines)>

>Fix:

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/devel/imake-6/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- Makefile	17 Mar 2005 23:22:07 -0000	1.7
+++ Makefile	5 Sep 2005 09:02:40 -0000
@@ -50,7 +50,9 @@
 INSTALL_TARGET=	install install.man
 
 pre-configure:
-	@${REINPLACE_CMD} -e 's|%%PTHREAD_CFLAGS%%|${PTHREAD_CFLAGS}|g ; \
+	${REINPLACE_CMD} -E 's|%%PTHREAD_CFLAGS%%|${PTHREAD_CFLAGS}|g ; \
+		s|^(#define CcCmd).*|\1	${CC}|; \
+		s|^(#define CplusplusCmd).*|\1	${CXX}|; \
 		s|%%PTHREAD_LIBS%%|${PTHREAD_LIBS}|g' \
 		${WRKSRC}/cf/FreeBSD.cf
 
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->x11 
Responsible-Changed-By: skv 
Responsible-Changed-When: Mon Sep 5 09:13:05 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85735 
Responsible-Changed-From-To: x11->freebsd-x11 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Sep 5 13:34:05 GMT 2005 
Responsible-Changed-Why:  
Canonicalize assignment. 

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

From: Dejan Lesjak <dejan.lesjak@ijs.si>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: ports/85735: Force imake respect CC/CXX
Date: Mon, 5 Sep 2005 23:48:10 +0200

 Proposed patch actually replaces defaults with the settings of $CC and $CXX in 
 effect at the time imake is built. This doesn't seem right. (See also 
 ports/65277).
 
 Furthermore I seem to be unable to reproduce the case where imake would not 
 respect $CC. If I define CC=notcc in either /etc/make.conf or try to build 
 imake with these commands:
 
 make CC=nocc build
 env CC=nocc make build
 
 I always get this error:
 
 ===>  Configuring for imake-6.8.2
 cd ./config/imake && make  -f Makefile.ini BOOTSTRAPCFLAGS="" CC="nocc"
 making imake with BOOTSTRAPCFLAGS= and CROSSCOMPILEFLAGS=-DCROSSCOMPILEDIR="" 
 in config/imake
 nocc -o ccimake -DCROSSCOMPILEDIR=\"\"  -O -I../../include 
 -I../../imports/x11/include/X11 ccimake.c
 nocc: not found
 *** Error code 127
 
 This seems to suggest imake is indeed respecting CC. Is there some specific 
 case where it is not so?

From: Sergey Skvortsov <skv@FreeBSD.org>
To: bug-followup@FreeBSD.org, Dejan Lesjak <dejan.lesjak@ijs.si>
Cc:  
Subject: Re: ports/85735: Force imake respect CC/CXX
Date: Wed, 07 Sep 2005 19:29:28 +0400

 Dejan Lesjak wrote:
 >
 >  effect at the time imake is built. This doesn't seem right. (See also
 >  ports/65277).
 >
 >  Furthermore I seem to be unable to reproduce the case where imake would not
 >  respect $CC. If I define CC=notcc in either /etc/make.conf or try to build
 >  imake with these commands:
 >
 >  make CC=nocc build
 >
 >  This seems to suggest imake is indeed respecting CC. Is there some specific
 >  case where it is not so?
 
 You used unexisting cc. Try the real one - install lang/gcc34.
 
 %uname -r
 4.11-STABLE
 
 /etc/make.conf:
 X_WINDOW_SYSTEM=        xorg
 
 # compile all ports with gcc-3.4
 .if ${.CURDIR:N*/ports/*} == ""
 CC:=gcc34
 CXX:=g++34
 CFLAGS= -O2 -pipe -Wall -mtune=pentium4
 .endif
 
 %cd /usr/ports/devel/imake-6
 %make
 ===>  Extracting for imake-6.8.2
 => Checksum OK for xorg/X11R6.8.2-src1.tar.gz.
 => Checksum OK for xorg/X11R6.8.2-src3.tar.gz.
 ===>   imake-6.8.2 depends on file: /usr/local/bin/perl5.8.7 - found
 ===>  Patching for imake-6.8.2
 ===>   imake-6.8.2 depends on file: /usr/local/bin/perl5.8.7 - found
 ===>  Applying FreeBSD patches for imake-6.8.2
 ===>   imake-6.8.2 depends on file: /usr/local/bin/perl5.8.7 - found
 ===>  Configuring for imake-6.8.2
 cd ./config/imake && make   -f Makefile.ini BOOTSTRAPCFLAGS="" CC="gcc34"
 making imake with BOOTSTRAPCFLAGS= and
 CROSSCOMPILEFLAGS=-DCROSSCOMPILEDIR="" in config/imake
 gcc34 -o ccimake -DCROSSCOMPILEDIR=\"\"  -O -I../../include
 -I../../imports/x11/include/X11 ccimake.c
 if [ -n "" ] ; then  /cc -E `./ccimake`  -DCROSSCOMPILE_CPP imakemdep.h >
 imakemdep_cpp.h;  else touch imakemdep_cpp.h; fi
 gcc34 -c  -O -I../../include -I../../imports/x11/include/X11 `./ccimake` imake.c
 gcc34 -o imake  -O -I../../include -I../../imports/x11/include/X11 imake.o
 rm -f ./config/makedepend/Makefile.proto
 ./config/imake/imake -I./config/cf  -s ./config/makedepend/Makefile.proto -f
 ./config/makedepend/Imakefile -DTOPDIR=../.. -DCURDIR=./config/makedepend
 cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o
 bootstrap
 cd ./config/makedepend && make -f Makefile.proto bootstrap
 ./config/imake/imake -I./config/cf  -s ./config/imake/Makefile.proto -f ./config
 /imake/Imakefile -DTOPDIR=../.. -DCURDIR=./config/imake -DBootStrap
 cd ./config/makedepend && rm -f -r Makefile Makefile.dep makedepend *.o
 bootstrap
 cd ./config/imake && make   -f Makefile.ini BOOTSTRAPCFLAGS="" CC="gcc34"
 bootstrap
 + mkdir bootstrap
 mv *.o bootstrap
 + mv imake bootstrap
 cd ./config/imake && make -f Makefile.proto imakeonly
 cc -O2 -pipe -Wall -mtune=pentium4   -ansi -pedantic -Wno-system-headers
 -Dasm=__asm -Wall -Wpointer-arith -Wundef   -I../../include
 -I../../exports/include/X11  -I../.. -I../../exports/include   -DCSRG_BASED
  -DFUNCPROTO=15 -DNARROWPROTO
    -DCPP_PROGRAM="\"/usr/bin/cpp\"" -DHAS_MERGE_CONSTANTS=`if cc
 -fmerge-constants -xc /dev/null -S -o /dev/null 2> /dev/null 1> /dev/null;
 then echo 1; else echo 0; fi`          -c imake.c
 cc1: Invalid option `tune=pentium4'
 cc1: Invalid option `-Wno-system-headers'
 *** Error code 1
 
 Stop in /usr/ports/devel/imake-6/work/xc/config/imake.
 *** Error code 1
 
 Stop in /usr/ports/devel/imake-6/work/xc.
 make: cannot open xmakefile.
 *** Error code 2
 
 Stop in /usr/ports/devel/imake-6.
 
 So, "cc1" is used anyway because Imake.tmpl does not updated with correct CC
 variables.
 
 -- 
 Sergey Skvortsov
 mailto: skv@FreeBSD.org

From: Dejan Lesjak <dejan.lesjak@ijs.si>
To: bug-followup@freebsd.org,
 skv@freebsd.org
Cc:  
Subject: Re: ports/85735: Force imake respect CC/CXX
Date: Wed, 7 Sep 2005 20:10:39 +0200

 > You used unexisting cc. Try the real one - install lang/gcc34.
 
 Ah, my testcase was flawed as I feared. Thanks for the cluebat :)
 
 Do you agree though that changing FreeBSD.cf as in patch would not be optimal 
 wrt hardcoding $CC and $CXX in installed imake configuration? If so, here's 
 what I'm considering now: we can add the following two lines to ports 
 Makefile:
 
 MAKE_ENV+=     MAKEFLAGS="CC=${CC} CXX=${CXX}"
 SCRIPTS_ENV+=	CC=${CC}
 
 and modify the last two lines in scripts/configure to:
 
 env MAKEFLAGS="CC=${CC}" make Makefile.boot
 env MAKEFLAGS="CC=${CC}" make -f xmakefile VerifyOS version.def Makefiles 
 includes
 
 Would this kind of change make sense?
 If so, the CFLAGS could also be fixed in same way.

From: Sergey Skvortsov <skv@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/85735: Force imake respect CC/CXX
Date: Fri, 09 Sep 2005 13:00:12 +0400

 Dejan Lesjak wrote:
 >>You used unexisting cc. Try the real one - install lang/gcc34.
 > 
 > Ah, my testcase was flawed as I feared. Thanks for the cluebat :)
 > 
 > Do you agree though that changing FreeBSD.cf as in patch would not be optimal 
 > wrt hardcoding $CC and $CXX in installed imake configuration? If so, here's 
 > what I'm considering now: we can add the following two lines to ports 
 > Makefile:
 > 
 > MAKE_ENV+=     MAKEFLAGS="CC=${CC} CXX=${CXX}"
 > SCRIPTS_ENV+=	CC=${CC}
 > 
 > and modify the last two lines in scripts/configure to:
 > 
 > env MAKEFLAGS="CC=${CC}" make Makefile.boot
 > env MAKEFLAGS="CC=${CC}" make -f xmakefile VerifyOS version.def Makefiles 
 > includes
 > 
 > Would this kind of change make sense?
 > If so, the CFLAGS could also be fixed in same way.
 
 Your approach seems to be more correct, however the result is still the same
 (I just try to avoid creating new patch-* files).
 
 I also see another problem. Imake.tmpl is created while imake building and
 installed into /usr/X11R6/lib/X11/config/Imake.tmpl. This template will be
 used for all imake-depended ports. But futher compiling such ports with
 another CC/CXX values may cause strangest errors. Some method for detection
  this situation should be introduced.
 
 -- 
 Sergey Skvortsov
 mailto: skv@FreeBSD.org
 

From: Dejan Lesjak <dejan.lesjak@ijs.si>
To: bug-followup@freebsd.org,
 skv@freebsd.org
Cc:  
Subject: Re: ports/85735: Force imake respect CC/CXX
Date: Wed, 14 Sep 2005 14:56:57 +0200

 Hardcoding the value of CC and CXX is actually what I was trying to avoid. 
 Namely I was considering that imake is build with gcc40 and thus CcCmd is 
 recorded with value "gcc40" in Imake.tmpl. Now everything that uses imake to 
 create Makefiles will grab this value and compile with same compiler imake 
 port was compiled with even if this is not desired.
 However on the other hand it could also be said that that is exactly what is 
 expected - that compiling imake with CC=gcc40 should in fact record that 
 gcc40 is desired compiler for all things using imake. Overriding this default 
 should still be possible with usual usage of make.
 Even looking at imake configuration files as defining the defaults for 
 specific system (in this case FreeBSD as defined in FreeBSD.cf) both 
 alternatives above make sense to me right now (with perhaps a minor tweak of 
 placing such override in host.def or site.def instead of Imake.tmpl).
 As right now we are in ports slush, I would feel more comfortable in changing 
 things after 6-release is out and I'll ponder on this some more until then if 
 you don't think this needs urgent fixing.
State-Changed-From-To: open->closed 
State-Changed-By: lesi 
State-Changed-When: Fri Nov 25 12:15:24 GMT 2005 
State-Changed-Why:  
I still believe making just imake build respect CC as opposed to changing 
it's configuration files is better solution so I've committed that one. 

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