/[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.24 Revision 1.27
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.24 2003/07/22 12:48:11 aliz Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.27 2003/09/24 05:51:32 solar 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"
31# 31#
32#### replace-sparc64-flags #### 32#### replace-sparc64-flags ####
33# Sets mcpu to v8 and uses the original value 33# Sets mcpu to v8 and uses the original value
34# as mtune if none specified. 34# as mtune if none specified.
35# 35#
36 36#### filter-mfpmath <math types> ####
37# Remove specified math types from the fpmath specification
38# If the user has -mfpmath=sse,386, running `filter-mfpmath sse`
39# will leave the user with -mfpmath=386
40#
41#### append-ldflags ####
42# Add extra flags to your current LDFLAGS
43#
44#### etexec-flags ####
45# hooked function for hardened-gcc that appends
46# -yet_exec {C,CXX,LD}FLAGS when hardened-gcc is installed
47# and a package is filtering -fPIC
48#
49#### fstack-flags ####
50# hooked function for hardened-gcc that appends
51# -yno_propolice to {C,CXX,LD}FLAGS when hardened-gcc is installed
52# and a package is filtering -fstack-protector
53#
37 54
38# C[XX]FLAGS that we allow in strip-flags 55# C[XX]FLAGS that we allow in strip-flags
39ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g" 56ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
40case "${ARCH}" in 57case "${ARCH}" in
41 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;; 58 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;;
42 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;; 59 amd64) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
60 alpha) ALLOWED_FLAGS="${ALLOWED_FLAGS} -fPIC" ;;
43esac 61esac
44 62
45# C[XX]FLAGS that we are think is ok, but needs testing 63# C[XX]FLAGS that we are think is ok, but needs testing
46# NOTE: currently -Os have issues with gcc3 and K6* arch's 64# NOTE: currently -Os have issues with gcc3 and K6* arch's
47UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" 65UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays"
65 replace-flags "$orig_mfpmath" "$new_mfpmath" 83 replace-flags "$orig_mfpmath" "$new_mfpmath"
66 fi 84 fi
67} 85}
68 86
69filter-flags() { 87filter-flags() {
88 # we do two loops to avoid the first and last char from being chomped.
89 for x in $@ ; do
90 case "${x}" in
91 -fPIC) etexec-flags;;
92 -fstack-protector) fstack-flags;;
93 *) ;;
94 esac
95 done
70 # we do this fancy spacing stuff so as to not filter 96 # we do this fancy spacing stuff so as to not filter
71 # out part of a flag ... we want flag atoms ! :D 97 # out part of a flag ... we want flag atoms ! :D
72 export CFLAGS=" ${CFLAGS} " 98 CFLAGS=" ${CFLAGS} "
73 export CXXFLAGS=" ${CXXFLAGS} " 99 CXXFLAGS=" ${CXXFLAGS} "
74 for x in $@ ; do 100 for x in $@ ; do
75 export CFLAGS="${CFLAGS/ ${x} / }" 101 CFLAGS="${CFLAGS/ ${x} / }"
76 export CXXFLAGS="${CXXFLAGS/ ${x} / }" 102 CXXFLAGS="${CXXFLAGS/ ${x} / }"
77 done 103 done
78 export CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" 104 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
79 export CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" 105 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
80} 106}
81 107
82append-flags() { 108append-flags() {
83 CFLAGS="${CFLAGS} $@" 109 CFLAGS="${CFLAGS} $@"
84 CXXFLAGS="${CXXFLAGS} $@" 110 CXXFLAGS="${CXXFLAGS} $@"
111 for x in $@; do
112 [ "${x}" = "-fno-stack-protector" ] &&
113 fstack-flags
114 done
85} 115}
86 116
87replace-flags() { 117replace-flags() {
88 CFLAGS="${CFLAGS/${1}/${2} }" 118 CFLAGS="${CFLAGS/${1}/${2} }"
89 CXXFLAGS="${CXXFLAGS/${1}/${2} }" 119 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
185 do 215 do
186 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" 216 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
187 done 217 done
188 fi 218 fi
189} 219}
220
221append-ldflags() {
222 LDFLAGS="${LDFLAGS} $@"
223}
224
225etexec-flags() {
226 has_version 'sys-devel/hardened-gcc' && {
227 debug-print ">>> appending flags -yet_exec"
228 append-flags -yet_exec
229 append-ldflags -yet_exec
230 }
231}
232
233fstack-flags() {
234 has_version 'sys-devel/hardened-gcc' && {
235 debug-print ">>> appending flags -yno_propolice"
236 append-flags -yno_propolice
237 append-ldflags -yno_propolice
238 }
239}

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.20