/[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.71 Revision 1.72
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
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.71 2004/10/01 10:00:36 robbat2 Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.72 2004/10/09 18:28:46 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"
9 9
10# Please leave ${IUSE} in this until portage .51 is stable, otherwise 10# Please leave ${IUSE} in this until portage .51 is stable, otherwise
11# IUSE gets clobbered. 11# IUSE gets clobbered.
12IUSE="${IUSE} debug" 12IUSE="${IUSE} debug"
13
14# need access to emktemp()
15inherit eutils
13 16
14# 17#
15#### filter-flags <flags> #### 18#### filter-flags <flags> ####
16# Remove particular flags from C[XX]FLAGS 19# Remove particular flags from C[XX]FLAGS
17# Matches only complete flags 20# Matches only complete flags
263 return 0 266 return 0
264} 267}
265 268
266test_flag() { 269test_flag() {
267 local cc=${CC:-gcc} ; cc=${cc%% *} 270 local cc=${CC:-gcc} ; cc=${cc%% *}
268 if ${cc} -S -xc "$@" -o /dev/null /dev/null &>/dev/null; then 271 if ${cc} -S -xc "$@" -o "$(emktemp)" /dev/null &>/dev/null; then
269 printf "%s\n" "$*" 272 printf "%s\n" "$*"
270 return 0 273 return 0
271 fi 274 fi
272 return 1 275 return 1
273} 276}
343has_m64() { 346has_m64() {
344 # this doesnt test if the flag is accepted, it tests if the flag 347 # this doesnt test if the flag is accepted, it tests if the flag
345 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 348 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
346 # please dont replace this function with test_flag in some future 349 # please dont replace this function with test_flag in some future
347 # clean-up! 350 # clean-up!
348 temp=`mktemp` 351 local temp="$(emktemp)"
349 echo "int main() { return(0); }" > ${temp}.c 352 echo "int main() { return(0); }" > ${temp}.c
350 ${CC/ .*/} -m64 -o /dev/null ${temp}.c > /dev/null 2>&1 353 ${CC/ .*/} -m64 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
351 ret=$? 354 local ret=$?
352 rm -f ${temp}.c 355 rm -f ${temp}.c
353 [ "$ret" != "1" ] && return 0 356 [ "$ret" != "1" ] && return 0
354 return 1 357 return 1
355} 358}
356 359
357has_m32() { 360has_m32() {
358 # this doesnt test if the flag is accepted, it tests if the flag 361 # this doesnt test if the flag is accepted, it tests if the flag
359 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! 362 # actually -WORKS-. non-multilib gcc will take both -m32 and -m64!
360 # please dont replace this function with test_flag in some future 363 # please dont replace this function with test_flag in some future
361 # clean-up! 364 # clean-up!
362 temp=`mktemp` 365 local temp="$(emktemp)"
363 echo "int main() { return(0); }" > ${temp}.c 366 echo "int main() { return(0); }" > ${temp}.c
364 ${CC/ .*/} -m32 -o /dev/null ${temp}.c > /dev/null 2>&1 367 ${CC/ .*/} -m32 -o "$(emktemp)" ${temp}.c > /dev/null 2>&1
365 ret=$? 368 local ret=$?
366 rm -f ${temp}.c 369 rm -f ${temp}.c
367 [ "$ret" != "1" ] && return 0 370 [ "$ret" != "1" ] && return 0
368 return 1 371 return 1
369} 372}
370 373

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.72

  ViewVC Help
Powered by ViewVC 1.1.20