You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

156 lines
4.8 KiB

#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../gcc/parse-config
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# 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; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
# Use the stack protector patch, if not disabled for the pkg
#
if [ "${SDECFG_DEFAULT_CC:0:3}" = "gcc" -a "$SDECFG_PKG_GCC_STACKPRO" = 1 ]; then
if ! hasflag NO-SSP; then
var_append GCC_WRAPPER_INSERT ' ' '-fstack-protector'
else
echo_warning 'Package incompatible with GCC stack-protector, disabled'
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 [[ $SDECFG_DEFAULT_KCC = gcc* ]] ; then
export KCC="${archprefix}kcc"
if [ "$SDECFG_OPT" = "size" ] ; 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=\$SDECFG_DEFAULT_$x"
if [[ $y = gcc* ]] ; then
case "$x-$stagelevel" in
CC-*)
z="${archprefix}gcc ${archprefix}gcc" ;;
CXX-[1-9])
z="${archprefix}g++ ${archprefix}g++" ;;
F77-[2-9])
z="${archprefix}g77 ${archprefix}g77" ;;
*)
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
# Strip or add debug information
#
if [ "$SDECFG_DEBUG" = 0 ] ; then
var_append GCC_WRAPPER_APPEND " " "-s"
var_append SYSGCC_WRAPPER_APPEND " " "-s"
var_insert GCC_WRAPPER_REMOVE " " "-g*"
var_insert SYSGCC_WRAPPER_REMOVE " " "-g*"
else
if [[ $pkg != glibc* ]] ; then
var_append GCC_WRAPPER_APPEND " " "-ggdb"
var_insert GCC_WRAPPER_REMOVE " " "-s -g*"
fi
fi
# Remove the optimization options, since we pass generic ones ... In ROCK
# history this has been -m*, but this caused -msse and -maltivec style options
# to get lost. So we better explicitly only remove some -m options ... -ReneR
var_insert GCC_WRAPPER_REMOVE " " "-O -O[0-9s] -mtune* -march* -mcpu*"
var_insert SYSGCC_WRAPPER_REMOVE " " "-O -O[0-9s] -mtune* -march* -mcpu*"
case "$SDECFG_OPT" in
smart)
var_insert GCC_WRAPPER_INSERT " " "-SPEED-O2 -SIZE-Os"
var_insert GCC_WRAPPER_FILTER "|" "gawk -f $base/misc/tools-source/smartwr.awk $base/scripts/smart_db.txt -"
#SYSGCC - though smart is phasing out
;;
speed)
var_insert GCC_WRAPPER_INSERT " " "-O2"
var_insert SYSGCC_WRAPPER_INSERT " " "-O2"
;;
size)
var_insert GCC_WRAPPER_INSERT " " "-Os"
var_insert SYSGCC_WRAPPER_INSERT " " "-Os"
;;
lazy)
var_insert GCC_WRAPPER_INSERT " " "-O"
var_insert SYSGCC_WRAPPER_INSERT " " "-O"
;;
esac
# gcc-4.1.0 hangs with -v --help -pipe, thus we do not add it in that case
var_insert GCC_WRAPPER_INSERT ' ' '--help?:-pipe'
var_insert SYSGCC_WRAPPER_INSERT ' ' '--help?:-pipe'
[ "$SDECFG_LD_AS_NEEDED" != 0 ] &&
var_append GCC_WRAPPER_INSERT " " "-c?:-Wl,--as-needed"
[ "$SDECFG_PIE" != 0 ] &&
var_append GCC_WRAPPER_INSERT " " "-c?-fPIE:-pie"
var_append GCC_WRAPPER_APPEND " " "$SDECFG_C_FLAGS"
# Compile (i.e. link) all bins statically
#
if [ "$SDECFG_STATIC" = 1 ]; then
var_insert GCC_WRAPPER_INSERT " " "-static"
fi
# Compile with no exceptions or rtti, gcc itself must support both
#
if [ "$SDECFG_LIMITCXX" = 1 ] && [[ $pkg != gcc* ]] ; then
var_append CXX_WRAPPER_APPEND " " "-fno-exceptions -fno-rtti"
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"
# pkg-config and other output or hardcoded configure assumption
# do not include the "DESTDIR" we need to adapt the pathes accordingly
if atstage cross; then
var_append GCC_WRAPPER_FILTER '|' \
"sed -e 's,^\(-[LI]\)*\(/\|/usr/\|/usr/[^/]*/\|/opt/[^/]*/\)\(include\|lib\),\1$root\2\3,'"
fi
# Add the architecture gcc optimisation options
#
if [ -f architecture/$arch/gcc-options.in ] ; then
. architecture/$arch/gcc-options.in
fi
# Inject -fPIC if the package is marked to need a quirk ...
#
hasflag FPIC-QUIRK && var_append GCC_WRAPPER_APPEND ' ' '-fPIC'
# Remove -W,l,--as-needed, some packages throw up with it...
#
if hasflag NO-AS-NEEDED; then
var_remove_regex GCC_WRAPPER_INSERT ' ' ".*-Wl,--as-needed"
var_append GCC_WRAPPER_REMOVE ' ' "-Wl,--as-needed"
fi