/[gentoo-x86]/eclass/flag-o-matic.eclass
Gentoo

Diff of /eclass/flag-o-matic.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.40 Revision 1.42
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.40 2004/03/12 11:21:15 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.42 2004/04/06 03:45:00 tseng Exp $
4# 4#
5# Author Bart Verwilst <verwilst@gentoo.org> 5# Author Bart Verwilst <verwilst@gentoo.org>
6 6
7ECLASS=flag-o-matic 7ECLASS=flag-o-matic
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
46# If the user has -mfpmath=sse,386, running `filter-mfpmath sse` 46# If the user has -mfpmath=sse,386, running `filter-mfpmath sse`
47# will leave the user with -mfpmath=386 47# will leave the user with -mfpmath=386
48# 48#
49#### append-ldflags #### 49#### append-ldflags ####
50# Add extra flags to your current LDFLAGS 50# Add extra flags to your current LDFLAGS
51#
52#### filter-ldflags <flags> ####
53# Remove particular flags from LDFLAGS
54# Matches only complete flags
51# 55#
52#### etexec-flags #### 56#### etexec-flags ####
53# hooked function for hardened-gcc that appends 57# hooked function for hardened-gcc that appends
54# -yet_exec {C,CXX,LD}FLAGS when hardened-gcc is installed 58# -yet_exec {C,CXX,LD}FLAGS when hardened-gcc is installed
55# and a package is filtering -fPIC,-fpic, -fPIE, -fpie 59# and a package is filtering -fPIC,-fpic, -fPIE, -fpie
259 fi 263 fi
260 done 264 done
261 return 1 265 return 1
262} 266}
263 267
268has_pic() {
269 [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
270 [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
271 [ has_version sys-devel/hardened-gcc ] && return 0
272 [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0
273 return 1
274}
275
276has_pie() {
277 [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
278 [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
279 [ has_version sys-devel/hardened-gcc ] && return 0
280 [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0
281 return 1
282}
283
284has_ssp() {
285 [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0
286 [ has_version sys-devel/hardened-gcc ] && return 0
287 [ ! -z "`${CC/ .*/} --version| grep ssp`" ] && return 0
288 return 1
289}
290
264replace-sparc64-flags() { 291replace-sparc64-flags() {
265 local SPARC64_CPUS="ultrasparc v9" 292 local SPARC64_CPUS="ultrasparc v9"
266 293
267 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ] 294 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]
268 then 295 then
294append-ldflags() { 321append-ldflags() {
295 LDFLAGS="${LDFLAGS} $@" 322 LDFLAGS="${LDFLAGS} $@"
296 return 0 323 return 0
297} 324}
298 325
326filter-ldflags() {
327 # we do this fancy spacing stuff so as to not filter
328 # out part of a flag ... we want flag atoms ! :D
329 LDFLAGS=" ${LDFLAGS} "
330 for x in "$@" ; do
331 LDFLAGS="${LDFLAGS// ${x} / }"
332 done
333 LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}"
334 return 0
335}
336
299etexec-flags() { 337etexec-flags() {
300 has_version sys-devel/hardened-gcc 338 has_pie || has_pic
301 if [ $? == 0 ] ; then 339 if [ $? == 0 ] ; then
340 # strip -fPIC regardless if you've gotten this far
341 strip-flags -fPIC -fpic -fPIE -fpie -pie
302 if [ "`is-flag -yet_exec`" != "true" ]; then 342 if [ "`is-flag -yet_exec`" != "true" ]; then
343 # If our compile support -yet_exec, append it now
344 [ -z "`gcc -yet_exec -S -o /dev/null -xc /dev/null 2>&1`" ] \
303 debug-print ">>> appending flags -yet_exec" 345 && ( debug-print ">>> appending flags -yet_exec" ; \
304 append-flags -yet_exec 346 append-flags -yet_exec ; append-ldflags -yet_exec )
305 append-ldflags -yet_exec
306 fi 347 fi
307 fi 348 fi
308} 349}
309 350
310fstack-flags() { 351fstack-flags() {
311 has_version sys-devel/hardened-gcc 352 has_ssp
312 if [ $? == 0 ] ; then 353 if [ $? == 0 ] ; then
354 # strip -fstack-protector regardless if you've gotten this far
355 strip-flags -fstack-protector -fstack-protector-all
313 if [ "`is-flag -yno_propolice`" != "true" ]; then 356 if [ "`is-flag -yno_propolice`" != "true" ]; then
357 # If our compile support -yno_propolice, append it now
358 [ -z "`gcc -yno_propolice -S -o /dev/null -xc /dev/null 2>&1`" ] \
314 debug-print ">>> appending flags -yno_propolice" 359 && ( debug-print ">>> appending flags -yno_propolice" ; \
315 append-flags -yno_propolice 360 append-flags -yno_propolice ; append-ldflags -yno_propolice )
316 append-ldflags -yno_propolice
317 fi 361 fi
318 fi 362 fi
319} 363}

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.42

  ViewVC Help
Powered by ViewVC 1.1.20