From christian.mangin@gmail.com  Mon Sep  3 21:29:28 2012
Return-Path: <christian.mangin@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id E19B9106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  3 Sep 2012 21:29:28 +0000 (UTC)
	(envelope-from christian.mangin@gmail.com)
Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182])
	by mx1.freebsd.org (Postfix) with ESMTP id A85048FC08
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  3 Sep 2012 21:29:28 +0000 (UTC)
Received: by iebc12 with SMTP id c12so4984044ieb.13
        for <FreeBSD-gnats-submit@freebsd.org>; Mon, 03 Sep 2012 14:29:22 -0700 (PDT)
Received: by 10.50.7.212 with SMTP id l20mr11858472iga.43.1346707762643;
        Mon, 03 Sep 2012 14:29:22 -0700 (PDT)
Received: from localhost (cable-10-157-60.b2b2c.ca. [72.10.157.60])
        by mx.google.com with ESMTPS id nh1sm10155437igc.11.2012.09.03.14.29.21
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 03 Sep 2012 14:29:22 -0700 (PDT)
Message-Id: <50452132.21d4320a.231d.54d3@mx.google.com>
Date: Mon, 03 Sep 2012 14:29:22 -0700 (PDT)
From: Christian Mangin <christian.mangin@gmail.com>
Reply-To: Christian Mangin <christian.mangin@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] devel/tbb: Remove hardcoded dependency on gcc
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         171297
>Category:       ports
>Synopsis:       [PATCH] devel/tbb: Remove hardcoded dependency on gcc
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    martymac
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 03 21:30:05 UTC 2012
>Closed-Date:    Wed Dec 12 07:43:57 UTC 2012
>Last-Modified:  Wed Dec 12 07:43:57 UTC 2012
>Originator:     Christian Mangin
>Release:        FreeBSD 9.1-RC1 amd64
>Organization:
>Environment:
System: FreeBSD 9.1-RC1 amd64

>Description:
This port has a hardcoded dependency on gcc and will not compile if gcc 
is not present in the base system. It does honor $CXX but not $CC.

In fact, this port requires the presence of a file 'FreeBSD.<compiler>.inc' 
to actually accept using a given C compiler. At this time, only 
'FreeBSD.gcc.inc' is present and therefore gcc is required.

My solution here is to create a copy the file with the correct name for
the requested C compiler and make the appropriate substitutions.

This has been tested to work with base clang, base gcc and lang/gcc.
>How-To-Repeat:
>Fix:
Patch attached:

--- tbb.diff begins here ---
diff -ruN tbb.orig/Makefile tbb/Makefile
--- tbb.orig/Makefile	2012-01-16 04:46:55.000000000 -0500
+++ tbb/Makefile	2012-09-03 16:37:19.393758379 -0400
@@ -23,16 +23,17 @@
 USE_LDCONFIG=	yes
 USE_GMAKE=	yes
 ALL_TARGET=	default
-MAKE_ENV=	CPLUS=${CXX}
 
 WRKSRC=	${WRKDIR}/tbb40_233oss
 
 post-extract:
+	@${CP} ${WRKSRC}/build/FreeBSD.gcc.inc ${WRKSRC}/build/FreeBSD.${CC}.inc
 	@${CP} ${FILESDIR}/version_info_FreeBSD.sh ${WRKSRC}/build/
 
 post-patch:
-	@${REINPLACE_CMD} 's|-lpthread|${PTHREAD_LIBS}|g' \
-		${WRKSRC}/build/FreeBSD.gcc.inc
+	@${REINPLACE_CMD} -e 's|-lpthread|${PTHREAD_LIBS}|g' \
+		-e 's|gcc|${CC}|g' -e 's|g++|${CXX}|g' \
+		${WRKSRC}/build/FreeBSD.${CC}.inc
 
 do-install:
 	cd ${WRKSRC}; \
diff -ruN tbb.orig/files/patch-build-FreeBSD.gcc.inc tbb/files/patch-build-FreeBSD.gcc.inc
--- tbb.orig/files/patch-build-FreeBSD.gcc.inc	2010-09-03 04:52:37.000000000 -0400
+++ tbb/files/patch-build-FreeBSD.gcc.inc	1969-12-31 19:00:00.000000000 -0500
@@ -1,11 +0,0 @@
---- build/FreeBSD.gcc.inc.orig	2010-08-28 00:14:43.080234020 +0200
-+++ build/FreeBSD.gcc.inc	2010-08-28 00:14:53.400821755 +0200
-@@ -37,7 +37,7 @@
- 
- TBB_NOSTRICT = 1
- 
--CPLUS = g++ 
-+#CPLUS = g++ 
- CONLY = gcc
- LIB_LINK_FLAGS = -shared
- LIBS = -lpthread 
diff -ruN tbb.orig/files/patch-build-FreeBSD.inc tbb/files/patch-build-FreeBSD.inc
--- tbb.orig/files/patch-build-FreeBSD.inc	2009-04-29 03:35:00.000000000 -0400
+++ tbb/files/patch-build-FreeBSD.inc	2012-09-03 14:03:42.506757619 -0400
@@ -1,5 +1,23 @@
---- build/FreeBSD.inc.orig	2008-06-07 08:56:22.000000000 +0200
-+++ build/FreeBSD.inc	2008-12-16 09:32:21.710673762 +0100
+--- build/FreeBSD.inc.orig	2012-09-03 13:10:45.423760088 -0400
++++ build/FreeBSD.inc	2012-09-03 13:13:15.765760027 -0400
+@@ -37,14 +37,14 @@
+ endif
+ 
+ ifndef runtime
+-        gcc_version:=$(shell gcc -v 2>&1 | grep 'gcc version' | sed -e 's/^gcc version //' | sed -e 's/ .*$$//')
++        gcc_version:=$(shell $(CC) -v 2>&1 | grep ' version' | sed -e 's/^.* version //' | sed -e 's/ .*$$//')
+         os_version:=$(shell uname -r)
+         os_kernel_version:=$(shell uname -r | sed -e 's/-.*$$//')
+         export runtime:=cc$(gcc_version)_kernel$(os_kernel_version)
+ endif
+ 
+-native_compiler := gcc
+-export compiler ?= gcc
++native_compiler := $(CC) 
++export compiler ?= $(CC)
+ debugger ?= gdb
+ 
+ CMD=$(SHELL) -c
 @@ -54,7 +54,7 @@
  MD?=mkdir -p
  NUL= /dev/null
diff -ruN tbb.orig/files/version_info_FreeBSD.sh tbb/files/version_info_FreeBSD.sh
--- tbb.orig/files/version_info_FreeBSD.sh	2009-04-29 03:35:00.000000000 -0400
+++ tbb/files/version_info_FreeBSD.sh	2012-09-03 12:45:31.831779484 -0400
@@ -5,7 +5,7 @@
 echo '"TBB:' "BUILD_HOST\t\t"`hostname -s`" ("`uname -p`")"'" ENDL \'
 echo '"TBB:' "BUILD_OS\t\t"`uname -sr`'" ENDL \'
 echo '"TBB:' "BUILD_KERNEL\t"`uname -rv`'" ENDL \'
-echo '"TBB:' "BUILD_GCC\t\t"`g++ -v </dev/null 2>&1 | grep 'gcc.*version'`'" ENDL \'
+echo '"TBB:' "BUILD_GCC\t\t"`${CXX} -v </dev/null 2>&1 | grep ' version'`'" ENDL \'
 [ -z "$COMPILER_VERSION" ] || echo '"TBB:' "BUILD_COMPILER\t"$COMPILER_VERSION'" ENDL \'
 echo '"TBB:' "BUILD_GLIBC\t"`ldconfig -r | grep -oE '/lib/libc.so.[0-9]+' | sort -rn | head -n 1 | sed 's|/lib/libc\.so\.||'`'" ENDL \'
 echo '"TBB:' "BUILD_LD\t\t"`ld -v | grep 'version'`'" ENDL \'
--- tbb.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->martymac 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Sep 3 21:30:19 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

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

From: "Ganael LAPLANCHE" <martymac@FreeBSD.org>
To: Christian Mangin <christian.mangin@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/171297: [PATCH] devel/tbb: Remove hardcoded dependency on gcc
Date: Thu,  6 Sep 2012 06:28:15 +0000 (UTC)

 Hi Christian,
 
 Thank you very much for your patch.
 
 I will upgrade devel/tbb to 4.0.5 soon (after the upcoming ports freeze)
 ; I'll integrate your patch with this update.
 
 Best regards,
 
 --
 Ganael LAPLANCHE <ganael.laplanche@martymac.org>
 http://www.martymac.org | http://contribs.martymac.org
 FreeBSD: martymac <martymac@FreeBSD.org>, http://www.FreeBSD.org
State-Changed-From-To: open->closed 
State-Changed-By: martymac 
State-Changed-When: Wed Dec 12 07:43:57 UTC 2012 
State-Changed-Why:  
Committed, thanks! 

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