# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
# 
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
# 
# ROCK Linux: rock-src/package/base/gcc3/parse-config
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
# 
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
# 
# --- ROCK-COPYRIGHT-NOTE-END ---

# Use the GCC-[23] stack protector patch
#
if [ $pkg != glibc23 -a $pkg != glibc22 -a \
     $pkg != grub  -a $pkg != dietlibc ]
then
	if [ "$ROCKCFG_PKG_GCC2_STACKPRO" = 1 ] ; then
		var_append GCC2_WRAPPER_INSERT " " "-fstack-protector"
	fi
	if [ "$ROCKCFG_PKG_GCC3_STACKPRO" = 1 ] ; then
		var_append GCC3_WRAPPER_INSERT " " "-fstack-protector"
	fi
fi

# maybe we add something more later. But imo it's better to
# let the options of KCC unmodified for gcc[23].  (Clifford)
#
if [ "$ROCKCFG_DEFAULT_KCC" = "gcc2" -o \
     "$ROCKCFG_DEFAULT_KCC" = "gcc3" ] ; then
	export KCC="${archprefix}kcc-${ROCKCFG_DEFAULT_KCC#gcc}"
	if [ "$ROCKCFG_OPTSIZE" = 1 ] ; then
		var_insert KCC_WRAPPER_REMOVE " " "-O -O[0-9]"
		var_insert KCC_WRAPPER_INSERT " " "-Os"
	fi
fi

# set CC, CXX and F77 environment variables
#
for x in CC CXX F77 ; do
	eval "y=\$ROCKCFG_DEFAULT_$x"
	if [ "$y" = "gcc2" -o "$y" = "gcc3" ] ; then
		case "$x-$stagelevel" in
		    CC-*)
			z="${archprefix}gcc ${archprefix}gcc-${y#gcc}" ;;
		    CXX-[2-9])
			z="${archprefix}g++ ${archprefix}g++-${y#gcc}" ;;
		    F77-[2-9])
			z="${archprefix}g77 ${archprefix}g77-${y#gcc}" ;;
		    *)
			export $x=${x}_not_available_in_stage_${stagelevel}
			continue ;;
		esac
		for y in $z ; do
			[ "`type -p $y`" ] && export $x=$y
		done
	fi
done

# Add the usual gcc optimazation options
#
if [ "$ROCKCFG_OPTSIZE" = 1 ] ; then
	var_insert GCC_WRAPPER_REMOVE " " "-O -O[0-9] -m*"
	var_insert GCC_WRAPPER_INSERT " " "-Os -pipe"
else
	var_insert GCC_WRAPPER_REMOVE " " "-O -O[01s] -m*"
	var_insert GCC_WRAPPER_INSERT " " "-O2 -pipe"
fi

# Strip or add debug information
#
if [ "$ROCKCFG_STRIP" != 0 ] ; then
	var_append GCC_WRAPPER_APPEND " " "-s"
	var_insert GCC_WRAPPER_REMOVE " " "-g*"
else
	if [ "$pkg" != glibc23 -a "$pkg" != glibc22 ] ; then
		var_append GCC_WRAPPER_APPEND " " "-ggdb"
		var_insert GCC_WRAPPER_REMOVE " " "-s -g*"
	fi
fi

# Passing -I/usr{/local/}include creates a warning in gcc3 which is confusing
# some of the configure scripts and Makefiles.
#
var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/include"
var_insert GCC3_WRAPPER_REMOVE " " "-I/usr/local/include"

# Add the architecture gcc optimazation options
#
if [ -f architecture/$arch/gcc-options ] ; then
	. architecture/$arch/gcc-options
fi

