/[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.41 Revision 1.48
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.41 2004/03/16 21:37:09 solar Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.48 2004/05/06 02:36:37 vapier 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"
64# and a package is filtering -fstack-protector, -fstack-protector-all 64# and a package is filtering -fstack-protector, -fstack-protector-all
65# 65#
66 66
67# C[XX]FLAGS that we allow in strip-flags 67# C[XX]FLAGS that we allow in strip-flags
68setup-allowed-flags() { 68setup-allowed-flags() {
69 if [ -z "${ALLOWED_FLAGS}" ] ; then
69 export ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g" 70 export ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
70 case "${ARCH}" in 71 case "${ARCH}" in
71 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;; 72 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;;
72 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 73 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
73 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 74 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
74 ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 75 ia64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
75 esac 76 esac
77 fi
76 78
77 # C[XX]FLAGS that we are think is ok, but needs testing 79 # C[XX]FLAGS that we are think is ok, but needs testing
78 # NOTE: currently -Os have issues with gcc3 and K6* arch's 80 # NOTE: currently -Os have issues with gcc3 and K6* arch's
79 export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" 81 export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
80 return 0 82 return 0
102 return 0 104 return 0
103} 105}
104 106
105filter-lfs-flags() { 107filter-lfs-flags() {
106 filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE 108 filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
109}
110
111append-lfs-flags() {
112 append-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
107} 113}
108 114
109append-flags() { 115append-flags() {
110 export CFLAGS="${CFLAGS} $@" 116 export CFLAGS="${CFLAGS} $@"
111 export CXXFLAGS="${CXXFLAGS} $@" 117 export CXXFLAGS="${CXXFLAGS} $@"
228 export CXXFLAGS="${NEW_CXXFLAGS}" 234 export CXXFLAGS="${NEW_CXXFLAGS}"
229 return 0 235 return 0
230} 236}
231 237
232test_flag() { 238test_flag() {
233 if gcc -S -xc "$@" -o /dev/null /dev/null >/dev/null 2>&1; then 239 if [ -z "`gcc -S -xc "$@" -o /dev/null /dev/null 2>&1`" ]; then
234 echo "$@" 240 echo "$@"
235 return 0 241 return 0
236 fi 242 fi
237 return 1 243 return 1
238} 244}
263 fi 269 fi
264 done 270 done
265 return 1 271 return 1
266} 272}
267 273
274has_pic() {
275 [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0
276 [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0
277 has_version sys-devel/hardened-gcc && return 0
278 [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0
279 return 1
280}
281
282has_pie() {
283 [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0
284 [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0
285 has_version sys-devel/hardened-gcc && return 0
286 [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0
287 return 1
288}
289
290has_ssp() {
291 [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0
292 has_version sys-devel/hardened-gcc && return 0
293 [ ! -z "`${CC/ .*/} --version| grep ssp`" ] && return 0
294 return 1
295}
296
268replace-sparc64-flags() { 297replace-sparc64-flags() {
269 local SPARC64_CPUS="ultrasparc v9" 298 local SPARC64_CPUS="ultrasparc v9"
270 299
271 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ] 300 if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]
272 then 301 then
310 LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}" 339 LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}"
311 return 0 340 return 0
312} 341}
313 342
314etexec-flags() { 343etexec-flags() {
315 has_version sys-devel/hardened-gcc 344 has_pie || has_pic
316 if [ $? == 0 ] ; then 345 if [ $? == 0 ] ; then
317 if [ "`is-flag -yet_exec`" != "true" ]; then 346 [ -z "`is-flag -yet_exec`" ] &&
318 debug-print ">>> appending flags -yet_exec" 347 export CFLAGS="${CFLAGS} `test_flag -yet_exec`"
319 append-flags -yet_exec 348 [ -z "`is-flag -nopie`" ] &&
320 append-ldflags -yet_exec 349 export CFLAGS="${CFLAGS} `test_flag -nopie`"
321 fi
322 fi 350 fi
323} 351}
324 352
325fstack-flags() { 353fstack-flags() {
326 has_version sys-devel/hardened-gcc 354 has_ssp
327 if [ $? == 0 ] ; then 355 if [ $? == 0 ] ; then
328 if [ "`is-flag -yno_propolice`" != "true" ]; then 356 [ -z "`is-flag -yno_propolice`" ] &&
329 debug-print ">>> appending flags -yno_propolice" 357 export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`"
330 append-flags -yno_propolice
331 append-ldflags -yno_propolice
332 fi 358 fi
333 fi
334} 359}

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.48

  ViewVC Help
Powered by ViewVC 1.1.20