Subject: pkg/20877: lang/gcc/buildlink2.mk does not work for gcc3 (+fix)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <joachim@cms.tecmath.com>
List: netbsd-bugs
Date: 03/24/2003 14:06:38
>Number:         20877
>Category:       pkg
>Synopsis:       lang/gcc/buildlink2.mk does not work for gcc3 (+fix)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 24 05:10:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Joachim Koenig-Baltes
>Release:        NetBSD 1.6Q
>Organization:
	
>Environment:
	
	
System: NetBSD compaq 1.6Q NetBSD 1.6Q (JOACHIM_ISDN) #0: Thu Mar 20 11:45:13 CET 2003 joachim@compaq:/usr/src/sys/arch/i386/compile/JOACHIM_ISDN i386
Architecture: i386
Machine: i386
>Description:
when trying to build packages that include lang/gcc/buildlink2.mk, they fail
to build when used with gcc3, e.g. gcc3.2 on Suse Linux 8.1 or even with
lang/gcc3 because gcc spits out multiple lines for the '--version' option
which lang/gcc/buildlink2.mk uses to determine the compiler version in line
37:

  _GCC_VERSION!=          ( gcc --version ) 2>/dev/null || ${ECHO} 0

>How-To-Repeat:
e.g. on Suse Linux 8.1 Professional:
% cd /usr/pkgsrc/graphics/ogle
% bmake
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `if PKG_DBDIR=/usr/pkg/var/db/pkg /usr/pkg/sbin/pkg_admin pmatch 'gcc>=2.95.3' gcc-gcc (GCC) 3.2 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; then  gccpath=`type gcc | /usr/bin/awk '{ print $NF }'`;     if [ "$gccpath" = "/usr/pkg/gcc-2.95.3/bin/gcc" ]; then  /bin/echo "YES";                              else                                                     /bin/echo "NO";        fi;                                                      else                   /bin/echo "YES";                                                 fi'
bmake: "../../lang/gcc/../../lang/gcc/buildlink2.mk" line 64: warning: "if PKG_DBDIR=/usr/pkg/var/db/pkg /usr/pkg/sbin/pkg_admin pmatch 'gcc>=2.95.3' gcc-gcc (GCC) 3.2 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; then  gccpath=`type gcc | /usr/bin/awk '{ print $NF }'`;      if [ "$gccpath" = "/usr/pkg/gcc-2.95.3/bin/gcc" ]; then  /bin/echo "YES";                                       else           /bin/echo "NO";                                  fi;                            else                                                             /bin/echo "YES";                                                fi" returned non-zero status

>Fix:
use '-dumpversion' option instead of '--version' option for gcc which is
available for gcc2 and gcc3 (on NetBSD too), as independendly suggested in

http://www.mail-archive.com/openpkg-bugdb@openpkg.org/msg00055.html

Here's the Fix:

--- buildlink2.mk.orig  2002-10-08 14:25:44.000000000 +0200
+++ buildlink2.mk       2003-03-24 10:39:27.000000000 +0100
@@ -34,7 +34,7 @@
 
 BUILDLINK_LDFLAGS.gcc= -L${_GCC_ARCHDIR} -Wl,-R${_GCC_ARCHDIR}
 
-_GCC_VERSION!=         ( gcc --version ) 2>/dev/null || ${ECHO} 0
+_GCC_VERSION!=         ( gcc -dumpversion ) 2>/dev/null || ${ECHO} 0
 #
 # GCC_VERSION is the version number of the gcc detected above.  EGCS gcc is
 # considered to be "gcc-2.8.1" so that it will match "gcc>=2.8.0".

>Release-Note:
>Audit-Trail:
>Unformatted: