Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 66185

Summary: gcc-2.95 configuration within ebuild question
Product: Gentoo Linux Reporter: John (EBo) David <ebo>
Component: New packagesAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED INVALID    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---

Description John (EBo) David 2004-10-02 22:54:03 UTC
I hunted around and found various ways that people were configuring various compilers including gcc.  Two of these solutions used the gcc.eclass (provided as part of the portage tools) and playing with information returned by gcc-configure...

I was unable to find anything that made configuring an ebuild to use gcc-2.95.* specific, so I hacked the following together:

oo_setup() {

    # gcc-2.95 required!

    if [ -x /usr/sbin/gcc-config ]
        then
    # Do we have a gcc that use the new layout and gcc-config ?
    if /usr/sbin/gcc-config --get-current-profile &> /dev/null
                      then
             # grab the gcc-2.95 specific config
  export GCC_PROFILE="$(/usr/sbin/gcc-config --list-profiles | awk '{print $2}' | grep "2.95")"

  # Just recheck gcc version ...
  if [ '$GCC_PROFILE' != "" ] 
    then
   # See if we can get a gcc profile we know is proper ...
   if /usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE} &> /dev/null
     then
    export PATH="$(/usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE}):$(/usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE} | sed s%gcc-bin/2.95%bin%):${PATH}"

    # for some reason configure does *not* find the name in
    # the path.  Therefore I have hard coded the compilers
    # here...

    export CC="$(/usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE})/gcc"
    export CXX="$(/usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE})/g++"

echo "version $(gcc --version)"

    # During configures CC discovery, it runs a bunch of code tests that
    # use CFLAGS and CXXFLAGS to check for GCC sanity...  These flags
    # must be cleared otherwise it breaks the configure script.  Here
    # appears to be the easiest place to hack this.
    export CFLAGS=""
    export CXXFLAGS=""

echo
echo "CC=$CC CXX=$CXX"
#echo "extra -> $(/usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE} | sed s%gcc-bin/2.95%bin%)"
echo "portage discovered a gcc-2.95 configuration (${GCC_PROFILE}) at $(/usr/sbin/gcc-config --get-bin-path ${GCC_PROFILE})"
echo
      else
    eerror "This build needs gcc-2.95.3!"
    eerror
    eerror "Use gcc-config to change your gcc profile:"
    eerror
    eerror "  # gcc-config $CHOST-2.95.3"
    eerror
    eerror "or whatever gcc version is relevant."
    die
      fi
      else
   eerror "This build needs gcc-2.95.3!"
   eerror
   eerror "Use gcc-config to change your gcc profile:"
   eerror
   eerror "  # gcc-config $CHOST-2.95.3"
   eerror
   eerror "or whatever gcc version is relevant."
   die
     fi
    fi
   fi
}

Is there an easier way to do this?  This is *not* IMNSHO an eligant solution.  If there is no better solution available, maybe it can be included in gcc.eclass as "WANT_GCC_2" or some such.  It might also be nice to extend gcc-config to allow you to grab a configuration that is version specific such as:

   gcc-config --get-full-path --version 2.95\*  ...

Just questions and ideas for a head-banger-ebuild-headache.

  EBo --
Comment 1 Mr. Bones. (RETIRED) gentoo-dev 2004-10-04 00:50:37 UTC
This isn't really the venue for questions.  Please take this to the forums or the mailing lists.  Thanks.