| 1 |
vapier |
1.60 |
# Copyright 1999-2004 Gentoo Foundation
|
| 2 |
verwilst |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
agriffis |
1.64 |
# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.63 2004/07/18 04:59:30 vapier Exp $
|
| 4 |
vapier |
1.12 |
#
|
| 5 |
verwilst |
1.1 |
# Author Bart Verwilst <verwilst@gentoo.org>
|
| 6 |
azarah |
1.8 |
|
| 7 |
verwilst |
1.1 |
ECLASS=flag-o-matic
|
| 8 |
danarmak |
1.6 |
INHERITED="$INHERITED $ECLASS"
|
| 9 |
vapier |
1.63 |
|
| 10 |
agriffis |
1.64 |
# Please leave ${IUSE} in this until portage .51 is stable, otherwise
|
| 11 |
|
|
# IUSE gets clobbered.
|
| 12 |
|
|
IUSE="${IUSE} debug"
|
| 13 |
azarah |
1.8 |
|
| 14 |
verwilst |
1.2 |
#
|
| 15 |
vapier |
1.18 |
#### filter-flags <flags> ####
|
| 16 |
verwilst |
1.3 |
# Remove particular flags from C[XX]FLAGS
|
| 17 |
vapier |
1.18 |
# Matches only complete flags
|
| 18 |
verwilst |
1.2 |
#
|
| 19 |
vapier |
1.18 |
#### append-flags <flags> ####
|
| 20 |
verwilst |
1.3 |
# Add extra flags to your current C[XX]FLAGS
|
| 21 |
|
|
#
|
| 22 |
verwilst |
1.4 |
#### replace-flags <orig.flag> <new.flag> ###
|
| 23 |
verwilst |
1.3 |
# Replace a flag by another one
|
| 24 |
|
|
#
|
| 25 |
vapier |
1.37 |
#### replace-cpu-flags <new.cpu> <old.cpus> ###
|
| 26 |
|
|
# Replace march/mcpu flags that specify <old.cpus>
|
| 27 |
|
|
# with flags that specify <new.cpu>
|
| 28 |
|
|
#
|
| 29 |
danarmak |
1.7 |
#### is-flag <flag> ####
|
| 30 |
|
|
# Returns "true" if flag is set in C[XX]FLAGS
|
| 31 |
vapier |
1.18 |
# Matches only complete a flag
|
| 32 |
danarmak |
1.7 |
#
|
| 33 |
azarah |
1.8 |
#### strip-flags ####
|
| 34 |
|
|
# Strip C[XX]FLAGS of everything except known
|
| 35 |
|
|
# good options.
|
| 36 |
|
|
#
|
| 37 |
puggy |
1.29 |
#### strip-unsupported-flags ####
|
| 38 |
|
|
# Strip C[XX]FLAGS of any flags not supported by
|
| 39 |
|
|
# installed version of gcc
|
| 40 |
|
|
#
|
| 41 |
vapier |
1.10 |
#### get-flag <flag> ####
|
| 42 |
|
|
# Find and echo the value for a particular flag
|
| 43 |
|
|
#
|
| 44 |
joker |
1.16 |
#### replace-sparc64-flags ####
|
| 45 |
|
|
# Sets mcpu to v8 and uses the original value
|
| 46 |
|
|
# as mtune if none specified.
|
| 47 |
|
|
#
|
| 48 |
vapier |
1.26 |
#### filter-mfpmath <math types> ####
|
| 49 |
|
|
# Remove specified math types from the fpmath specification
|
| 50 |
|
|
# If the user has -mfpmath=sse,386, running `filter-mfpmath sse`
|
| 51 |
|
|
# will leave the user with -mfpmath=386
|
| 52 |
solar |
1.27 |
#
|
| 53 |
|
|
#### append-ldflags ####
|
| 54 |
|
|
# Add extra flags to your current LDFLAGS
|
| 55 |
|
|
#
|
| 56 |
solar |
1.41 |
#### filter-ldflags <flags> ####
|
| 57 |
|
|
# Remove particular flags from LDFLAGS
|
| 58 |
|
|
# Matches only complete flags
|
| 59 |
|
|
#
|
| 60 |
solar |
1.27 |
#### etexec-flags ####
|
| 61 |
pappy |
1.50 |
# hooked function for hardened gcc that appends
|
| 62 |
|
|
# -fno-pic to {C,CXX,LD}FLAGS
|
| 63 |
|
|
# when a package is filtering -fpic, -fPIC, -fpie, -fPIE
|
| 64 |
solar |
1.27 |
#
|
| 65 |
|
|
#### fstack-flags ####
|
| 66 |
pappy |
1.50 |
# hooked function for hardened gcc that appends
|
| 67 |
|
|
# -fno-stack-protector to {C,CXX,LD}FLAGS
|
| 68 |
|
|
# when a package is filtering -fstack-protector, -fstack-protector-all
|
| 69 |
|
|
# notice: modern automatic specs files will also suppress -fstack-protector-all
|
| 70 |
|
|
# when only -fno-stack-protector is given
|
| 71 |
solar |
1.27 |
#
|
| 72 |
verwilst |
1.3 |
|
| 73 |
azarah |
1.17 |
# C[XX]FLAGS that we allow in strip-flags
|
| 74 |
vapier |
1.36 |
setup-allowed-flags() {
|
| 75 |
vapier |
1.44 |
if [ -z "${ALLOWED_FLAGS}" ] ; then
|
| 76 |
lv |
1.52 |
export ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -fno-unit-at-a-time -pipe -g"
|
| 77 |
vapier |
1.44 |
case "${ARCH}" in
|
| 78 |
|
|
mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;;
|
| 79 |
lv |
1.51 |
amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC -m64" ;;
|
| 80 |
|
|
x86) ALLOWED_FLAGS="${ALLOWED_FLAGS} -m32" ;;
|
| 81 |
vapier |
1.44 |
alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
|
| 82 |
|
|
ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
|
| 83 |
|
|
esac
|
| 84 |
|
|
fi
|
| 85 |
vapier |
1.36 |
|
| 86 |
|
|
# C[XX]FLAGS that we are think is ok, but needs testing
|
| 87 |
|
|
# NOTE: currently -Os have issues with gcc3 and K6* arch's
|
| 88 |
|
|
export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
|
| 89 |
|
|
return 0
|
| 90 |
aliz |
1.24 |
}
|
| 91 |
verwilst |
1.13 |
|
| 92 |
vapier |
1.18 |
filter-flags() {
|
| 93 |
agriffis |
1.61 |
local x f fset
|
| 94 |
|
|
declare -a new_CFLAGS new_CXXFLAGS
|
| 95 |
agriffis |
1.58 |
|
| 96 |
vapier |
1.36 |
for x in "$@" ; do
|
| 97 |
solar |
1.27 |
case "${x}" in
|
| 98 |
solar |
1.39 |
-fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;;
|
| 99 |
solar |
1.32 |
-fstack-protector|-fstack-protector-all) fstack-flags;;
|
| 100 |
solar |
1.27 |
esac
|
| 101 |
|
|
done
|
| 102 |
vapier |
1.36 |
|
| 103 |
agriffis |
1.61 |
for fset in CFLAGS CXXFLAGS; do
|
| 104 |
agriffis |
1.64 |
# Looping over the flags instead of using a global
|
| 105 |
|
|
# substitution ensures that we're working with flag atoms.
|
| 106 |
|
|
# Otherwise globs like -O* have the potential to wipe out the
|
| 107 |
|
|
# list of flags.
|
| 108 |
agriffis |
1.61 |
for f in ${!fset}; do
|
| 109 |
|
|
for x in "$@"; do
|
| 110 |
|
|
# Note this should work with globs like -O*
|
| 111 |
|
|
[[ ${f} == ${x} ]] && continue 2
|
| 112 |
|
|
done
|
| 113 |
|
|
eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f}
|
| 114 |
|
|
done
|
| 115 |
|
|
eval export ${fset}=\${new_${fset}\[*]}
|
| 116 |
verwilst |
1.1 |
done
|
| 117 |
agriffis |
1.61 |
|
| 118 |
vapier |
1.36 |
return 0
|
| 119 |
verwilst |
1.2 |
}
|
| 120 |
|
|
|
| 121 |
vapier |
1.40 |
filter-lfs-flags() {
|
| 122 |
|
|
filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
|
| 123 |
|
|
}
|
| 124 |
|
|
|
| 125 |
vapier |
1.48 |
append-lfs-flags() {
|
| 126 |
|
|
append-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
|
| 127 |
|
|
}
|
| 128 |
|
|
|
| 129 |
vapier |
1.18 |
append-flags() {
|
| 130 |
agriffis |
1.58 |
export CFLAGS="${CFLAGS} $*"
|
| 131 |
|
|
export CXXFLAGS="${CXXFLAGS} $*"
|
| 132 |
|
|
[ -n "`is-flag -fno-stack-protector`" -o \
|
| 133 |
|
|
-n "`is-flag -fno-stack-protector-all`" ] && fstack-flags
|
| 134 |
vapier |
1.28 |
return 0
|
| 135 |
verwilst |
1.1 |
}
|
| 136 |
|
|
|
| 137 |
vapier |
1.18 |
replace-flags() {
|
| 138 |
agriffis |
1.64 |
local f fset
|
| 139 |
|
|
declare -a new_CFLAGS new_CXXFLAGS
|
| 140 |
|
|
|
| 141 |
|
|
for fset in CFLAGS CXXFLAGS; do
|
| 142 |
|
|
# Looping over the flags instead of using a global
|
| 143 |
|
|
# substitution ensures that we're working with flag atoms.
|
| 144 |
|
|
# Otherwise globs like -O* have the potential to wipe out the
|
| 145 |
|
|
# list of flags.
|
| 146 |
|
|
for f in ${!fset}; do
|
| 147 |
|
|
# Note this should work with globs like -O*
|
| 148 |
|
|
[[ ${f} == ${1} ]] && f=${2}
|
| 149 |
|
|
eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f}
|
| 150 |
|
|
done
|
| 151 |
|
|
eval export ${fset}=\${new_${fset}\[*]}
|
| 152 |
|
|
done
|
| 153 |
|
|
|
| 154 |
vapier |
1.28 |
return 0
|
| 155 |
danarmak |
1.7 |
}
|
| 156 |
|
|
|
| 157 |
vapier |
1.37 |
replace-cpu-flags() {
|
| 158 |
agriffis |
1.58 |
local oldcpu newcpu="$1" ; shift
|
| 159 |
vapier |
1.37 |
for oldcpu in "$@" ; do
|
| 160 |
agriffis |
1.64 |
# quote to make sure that no globbing is done (particularly on
|
| 161 |
|
|
# ${oldcpu} prior to calling replace-flags
|
| 162 |
|
|
replace-flags "-march=${oldcpu}" "-march=${newcpu}"
|
| 163 |
|
|
replace-flags "-mcpu=${oldcpu}" "-mcpu=${newcpu}"
|
| 164 |
|
|
replace-flags "-mtune=${oldcpu}" "-mtune=${newcpu}"
|
| 165 |
vapier |
1.37 |
done
|
| 166 |
|
|
return 0
|
| 167 |
|
|
}
|
| 168 |
|
|
|
| 169 |
danarmak |
1.7 |
is-flag() {
|
| 170 |
agriffis |
1.58 |
local x
|
| 171 |
|
|
|
| 172 |
vapier |
1.18 |
for x in ${CFLAGS} ${CXXFLAGS} ; do
|
| 173 |
|
|
if [ "${x}" == "$1" ] ; then
|
| 174 |
azarah |
1.8 |
echo true
|
| 175 |
vapier |
1.18 |
return 0
|
| 176 |
|
|
fi
|
| 177 |
danarmak |
1.7 |
done
|
| 178 |
vapier |
1.18 |
return 1
|
| 179 |
verwilst |
1.1 |
}
|
| 180 |
azarah |
1.8 |
|
| 181 |
vapier |
1.36 |
filter-mfpmath() {
|
| 182 |
agriffis |
1.58 |
local orig_mfpmath new_math prune_math
|
| 183 |
|
|
|
| 184 |
vapier |
1.36 |
# save the original -mfpmath flag
|
| 185 |
agriffis |
1.58 |
orig_mfpmath="`get-flag -mfpmath`"
|
| 186 |
vapier |
1.36 |
# get the value of the current -mfpmath flag
|
| 187 |
agriffis |
1.58 |
new_math=" `get-flag mfpmath | tr , ' '` "
|
| 188 |
vapier |
1.36 |
# figure out which math values are to be removed
|
| 189 |
agriffis |
1.58 |
prune_math=""
|
| 190 |
vapier |
1.36 |
for prune_math in "$@" ; do
|
| 191 |
|
|
new_math="${new_math/ ${prune_math} / }"
|
| 192 |
|
|
done
|
| 193 |
|
|
new_math="`echo ${new_math:1:${#new_math}-2} | tr ' ' ,`"
|
| 194 |
|
|
|
| 195 |
|
|
if [ -z "${new_math}" ] ; then
|
| 196 |
|
|
# if we're removing all user specified math values are
|
| 197 |
|
|
# slated for removal, then we just filter the flag
|
| 198 |
|
|
filter-flags ${orig_mfpmath}
|
| 199 |
|
|
else
|
| 200 |
|
|
# if we only want to filter some of the user specified
|
| 201 |
|
|
# math values, then we replace the current flag
|
| 202 |
|
|
replace-flags ${orig_mfpmath} -mfpmath=${new_math}
|
| 203 |
|
|
fi
|
| 204 |
|
|
return 0
|
| 205 |
|
|
}
|
| 206 |
|
|
|
| 207 |
azarah |
1.8 |
strip-flags() {
|
| 208 |
agriffis |
1.58 |
local x y flag NEW_CFLAGS NEW_CXXFLAGS
|
| 209 |
|
|
|
| 210 |
vapier |
1.36 |
setup-allowed-flags
|
| 211 |
|
|
|
| 212 |
azarah |
1.8 |
local NEW_CFLAGS=""
|
| 213 |
|
|
local NEW_CXXFLAGS=""
|
| 214 |
|
|
|
| 215 |
azarah |
1.17 |
# Allow unstable C[XX]FLAGS if we are using unstable profile ...
|
| 216 |
vapier |
1.49 |
if has ~${ARCH} ${ACCEPT_KEYWORDS} ; then
|
| 217 |
|
|
use debug && einfo "Enabling the use of some unstable flags"
|
| 218 |
azarah |
1.17 |
ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}"
|
| 219 |
|
|
fi
|
| 220 |
|
|
|
| 221 |
agriffis |
1.58 |
set -f # disable pathname expansion
|
| 222 |
azarah |
1.8 |
|
| 223 |
agriffis |
1.58 |
for x in ${CFLAGS}; do
|
| 224 |
|
|
for y in ${ALLOWED_FLAGS}; do
|
| 225 |
lostlogic |
1.14 |
flag=${x%%=*}
|
| 226 |
vapier |
1.63 |
if [ "${flag%%${y}}" = "" ] || [ "${flag:0:5}" = "-fno-" ] || [ "${flag:0:5}" = "-mno-" ] ; then
|
| 227 |
lostlogic |
1.14 |
NEW_CFLAGS="${NEW_CFLAGS} ${x}"
|
| 228 |
|
|
break
|
| 229 |
azarah |
1.8 |
fi
|
| 230 |
|
|
done
|
| 231 |
|
|
done
|
| 232 |
|
|
|
| 233 |
agriffis |
1.58 |
for x in ${CXXFLAGS}; do
|
| 234 |
|
|
for y in ${ALLOWED_FLAGS}; do
|
| 235 |
lostlogic |
1.14 |
flag=${x%%=*}
|
| 236 |
vapier |
1.63 |
if [ "${flag%%${y}}" = "" ] || [ "${flag:0:5}" = "-fno-" ] || [ "${flag:0:5}" = "-mno-" ] ; then
|
| 237 |
lostlogic |
1.14 |
NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
|
| 238 |
|
|
break
|
| 239 |
azarah |
1.8 |
fi
|
| 240 |
|
|
done
|
| 241 |
|
|
done
|
| 242 |
azarah |
1.30 |
|
| 243 |
|
|
# In case we filtered out all optimization flags fallback to -O2
|
| 244 |
|
|
if [ "${CFLAGS/-O}" != "${CFLAGS}" -a "${NEW_CFLAGS/-O}" = "${NEW_CFLAGS}" ]; then
|
| 245 |
|
|
NEW_CFLAGS="${NEW_CFLAGS} -O2"
|
| 246 |
|
|
fi
|
| 247 |
|
|
if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then
|
| 248 |
|
|
NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2"
|
| 249 |
|
|
fi
|
| 250 |
azarah |
1.8 |
|
| 251 |
agriffis |
1.58 |
set +f # re-enable pathname expansion
|
| 252 |
azarah |
1.8 |
|
| 253 |
|
|
export CFLAGS="${NEW_CFLAGS}"
|
| 254 |
|
|
export CXXFLAGS="${NEW_CXXFLAGS}"
|
| 255 |
vapier |
1.36 |
return 0
|
| 256 |
puggy |
1.29 |
}
|
| 257 |
|
|
|
| 258 |
vapier |
1.36 |
test_flag() {
|
| 259 |
agriffis |
1.58 |
local cc=${CC:-gcc} ; cc=${cc%% *}
|
| 260 |
|
|
if ${cc} -S -xc "$@" -o /dev/null /dev/null &>/dev/null; then
|
| 261 |
|
|
printf "%s\n" "$*"
|
| 262 |
vapier |
1.36 |
return 0
|
| 263 |
puggy |
1.29 |
fi
|
| 264 |
vapier |
1.36 |
return 1
|
| 265 |
puggy |
1.29 |
}
|
| 266 |
|
|
|
| 267 |
agriffis |
1.58 |
test_version_info() {
|
| 268 |
|
|
local cc=${CC:-gcc} ; cc=${cc%% *}
|
| 269 |
|
|
if [[ $(${cc} --version 2>&1) == *$1* ]]; then
|
| 270 |
|
|
return 0
|
| 271 |
|
|
else
|
| 272 |
|
|
return 1
|
| 273 |
|
|
fi
|
| 274 |
|
|
}
|
| 275 |
|
|
|
| 276 |
puggy |
1.29 |
strip-unsupported-flags() {
|
| 277 |
agriffis |
1.58 |
local NEW_CFLAGS NEW_CXXFLAGS
|
| 278 |
|
|
|
| 279 |
vapier |
1.36 |
for x in ${CFLAGS} ; do
|
| 280 |
agriffis |
1.58 |
NEW_CFLAGS="${NEW_CFLAGS} `test_flag ${x}`"
|
| 281 |
puggy |
1.29 |
done
|
| 282 |
vapier |
1.36 |
for x in ${CXXFLAGS} ; do
|
| 283 |
agriffis |
1.58 |
NEW_CXXFLAGS="${NEW_CXXFLAGS} `test_flag ${x}`"
|
| 284 |
puggy |
1.29 |
done
|
| 285 |
|
|
|
| 286 |
vapier |
1.36 |
export CFLAGS="${NEW_CFLAGS}"
|
| 287 |
|
|
export CXXFLAGS="${NEW_CXXFLAGS}"
|
| 288 |
azarah |
1.8 |
}
|
| 289 |
|
|
|
| 290 |
vapier |
1.10 |
get-flag() {
|
| 291 |
agriffis |
1.58 |
local f findflag="$1"
|
| 292 |
|
|
|
| 293 |
vapier |
1.36 |
# this code looks a little flaky but seems to work for
|
| 294 |
|
|
# everything we want ...
|
| 295 |
|
|
# for example, if CFLAGS="-march=i686":
|
| 296 |
agriffis |
1.58 |
# `get-flag -march` == "-march=i686"
|
| 297 |
|
|
# `get-flag march` == "i686"
|
| 298 |
vapier |
1.10 |
for f in ${CFLAGS} ${CXXFLAGS} ; do
|
| 299 |
|
|
if [ "${f/${findflag}}" != "${f}" ] ; then
|
| 300 |
agriffis |
1.58 |
printf "%s\n" "${f/-${findflag}=}"
|
| 301 |
vapier |
1.28 |
return 0
|
| 302 |
vapier |
1.10 |
fi
|
| 303 |
|
|
done
|
| 304 |
vapier |
1.28 |
return 1
|
| 305 |
joker |
1.16 |
}
|
| 306 |
|
|
|
| 307 |
solar |
1.53 |
has_hardened() {
|
| 308 |
agriffis |
1.58 |
test_version_info Hardened
|
| 309 |
solar |
1.53 |
return $?
|
| 310 |
|
|
}
|
| 311 |
|
|
|
| 312 |
tseng |
1.42 |
has_pic() {
|
| 313 |
|
|
[ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
|
| 314 |
|
|
[ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
|
| 315 |
agriffis |
1.58 |
test_version_info pie && return 0
|
| 316 |
tseng |
1.42 |
return 1
|
| 317 |
|
|
}
|
| 318 |
|
|
|
| 319 |
|
|
has_pie() {
|
| 320 |
tseng |
1.43 |
[ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0
|
| 321 |
|
|
[ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0
|
| 322 |
agriffis |
1.58 |
test_version_info pie && return 0
|
| 323 |
tseng |
1.42 |
return 1
|
| 324 |
|
|
}
|
| 325 |
|
|
|
| 326 |
|
|
has_ssp() {
|
| 327 |
|
|
[ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0
|
| 328 |
agriffis |
1.58 |
test_version_info ssp && return 0
|
| 329 |
tseng |
1.42 |
return 1
|
| 330 |
|
|
}
|
| 331 |
|
|
|
| 332 |
lv |
1.56 |
has_m64() {
|
| 333 |
lv |
1.62 |
# this doesnt test if the flag is accepted, it tests if the flag
|
| 334 |
|
|
# actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
|
| 335 |
|
|
# please dont replace this function with test_flag in some future
|
| 336 |
|
|
# clean-up!
|
| 337 |
|
|
temp=`mktemp`
|
| 338 |
|
|
echo "int main() { return(0); }" > ${temp}.c
|
| 339 |
|
|
${CC/ .*/} -m64 -o /dev/null ${temp}.c > /dev/null 2>&1
|
| 340 |
|
|
ret=$?
|
| 341 |
|
|
rm -f ${temp}.c
|
| 342 |
|
|
[ "$ret" != "1" ] && return 0
|
| 343 |
|
|
return 1
|
| 344 |
lv |
1.56 |
}
|
| 345 |
|
|
|
| 346 |
|
|
has_m32() {
|
| 347 |
lv |
1.62 |
# this doesnt test if the flag is accepted, it tests if the flag
|
| 348 |
|
|
# actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
|
| 349 |
|
|
# please dont replace this function with test_flag in some future
|
| 350 |
|
|
# clean-up!
|
| 351 |
|
|
temp=`mktemp`
|
| 352 |
|
|
echo "int main() { return(0); }" > ${temp}.c
|
| 353 |
|
|
${CC/ .*/} -m32 -o /dev/null ${temp}.c > /dev/null 2>&1
|
| 354 |
|
|
ret=$?
|
| 355 |
|
|
rm -f ${temp}.c
|
| 356 |
|
|
[ "$ret" != "1" ] && return 0
|
| 357 |
|
|
return 1
|
| 358 |
lv |
1.56 |
}
|
| 359 |
|
|
|
| 360 |
vapier |
1.18 |
replace-sparc64-flags() {
|
| 361 |
joker |
1.16 |
local SPARC64_CPUS="ultrasparc v9"
|
| 362 |
|
|
|
| 363 |
agriffis |
1.58 |
if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
|
| 364 |
|
|
for x in ${SPARC64_CPUS}; do
|
| 365 |
joker |
1.16 |
CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}"
|
| 366 |
|
|
done
|
| 367 |
|
|
else
|
| 368 |
agriffis |
1.58 |
for x in ${SPARC64_CPUS}; do
|
| 369 |
joker |
1.16 |
CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
|
| 370 |
|
|
done
|
| 371 |
|
|
fi
|
| 372 |
|
|
|
| 373 |
agriffis |
1.58 |
if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
|
| 374 |
|
|
for x in ${SPARC64_CPUS}; do
|
| 375 |
joker |
1.16 |
CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}"
|
| 376 |
|
|
done
|
| 377 |
|
|
else
|
| 378 |
agriffis |
1.58 |
for x in ${SPARC64_CPUS}; do
|
| 379 |
joker |
1.16 |
CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
|
| 380 |
|
|
done
|
| 381 |
|
|
fi
|
| 382 |
vapier |
1.59 |
|
| 383 |
|
|
export CFLAGS CXXFLAGS
|
| 384 |
solar |
1.27 |
}
|
| 385 |
|
|
|
| 386 |
|
|
append-ldflags() {
|
| 387 |
vapier |
1.59 |
export LDFLAGS="${LDFLAGS} $*"
|
| 388 |
vapier |
1.28 |
return 0
|
| 389 |
solar |
1.27 |
}
|
| 390 |
|
|
|
| 391 |
solar |
1.41 |
filter-ldflags() {
|
| 392 |
agriffis |
1.58 |
local x
|
| 393 |
|
|
|
| 394 |
solar |
1.41 |
# we do this fancy spacing stuff so as to not filter
|
| 395 |
|
|
# out part of a flag ... we want flag atoms ! :D
|
| 396 |
|
|
LDFLAGS=" ${LDFLAGS} "
|
| 397 |
|
|
for x in "$@" ; do
|
| 398 |
|
|
LDFLAGS="${LDFLAGS// ${x} / }"
|
| 399 |
|
|
done
|
| 400 |
|
|
LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}"
|
| 401 |
vapier |
1.59 |
export LDFLAGS
|
| 402 |
solar |
1.41 |
return 0
|
| 403 |
|
|
}
|
| 404 |
|
|
|
| 405 |
vapier |
1.36 |
etexec-flags() {
|
| 406 |
agriffis |
1.58 |
# if you're not using a hardened compiler you wont need this
|
| 407 |
solar |
1.53 |
# PIC/no-pic kludge in the first place.
|
| 408 |
agriffis |
1.58 |
has_hardened || return 0
|
| 409 |
pappy |
1.50 |
|
| 410 |
agriffis |
1.58 |
if has_pie || has_pic; then
|
| 411 |
|
|
[ -z "`is-flag -fno-pic`" ] &&
|
| 412 |
|
|
export CFLAGS="${CFLAGS} `test_flag -fno-pic`"
|
| 413 |
|
|
[ -z "`is-flag -nopie`" ] &&
|
| 414 |
|
|
export CFLAGS="${CFLAGS} `test_flag -nopie`"
|
| 415 |
solar |
1.35 |
fi
|
| 416 |
agriffis |
1.58 |
return 0
|
| 417 |
solar |
1.27 |
}
|
| 418 |
|
|
|
| 419 |
|
|
fstack-flags() {
|
| 420 |
agriffis |
1.58 |
if has_ssp; then
|
| 421 |
|
|
[ -z "`is-flag -fno-stack-protector`" ] &&
|
| 422 |
|
|
export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`"
|
| 423 |
solar |
1.35 |
fi
|
| 424 |
agriffis |
1.58 |
return 0
|
| 425 |
vapier |
1.10 |
}
|