/[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.28
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.28 2003/10/26 00:40:52 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"
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" ] && fstack-flags
113 done
114 return 0
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} }"
120 return 0
90} 121}
91 122
92is-flag() { 123is-flag() {
93 for x in ${CFLAGS} ${CXXFLAGS} ; do 124 for x in ${CFLAGS} ${CXXFLAGS} ; do
94 if [ "${x}" == "$1" ] ; then 125 if [ "${x}" == "$1" ] ; then
147 export CXXFLAGS="${NEW_CXXFLAGS}" 178 export CXXFLAGS="${NEW_CXXFLAGS}"
148} 179}
149 180
150get-flag() { 181get-flag() {
151 local findflag="$1" 182 local findflag="$1"
152
153 for f in ${CFLAGS} ${CXXFLAGS} ; do 183 for f in ${CFLAGS} ${CXXFLAGS} ; do
154 if [ "${f/${findflag}}" != "${f}" ] ; then 184 if [ "${f/${findflag}}" != "${f}" ] ; then
155 echo "${f/-${findflag}=}" 185 echo "${f/-${findflag}=}"
156 return 186 return 0
157 fi 187 fi
158 done 188 done
189 return 1
159} 190}
160 191
161replace-sparc64-flags() { 192replace-sparc64-flags() {
162 local SPARC64_CPUS="ultrasparc v9" 193 local SPARC64_CPUS="ultrasparc v9"
163 194
185 do 216 do
186 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" 217 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
187 done 218 done
188 fi 219 fi
189} 220}
221
222append-ldflags() {
223 LDFLAGS="${LDFLAGS} $@"
224 return 0
225}
226
227etexec-flags() {
228 has_version 'sys-devel/hardened-gcc' && {
229 debug-print ">>> appending flags -yet_exec"
230 append-flags -yet_exec
231 append-ldflags -yet_exec
232 }
233}
234
235fstack-flags() {
236 has_version 'sys-devel/hardened-gcc' && {
237 debug-print ">>> appending flags -yno_propolice"
238 append-flags -yno_propolice
239 append-ldflags -yno_propolice
240 }
241}

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

  ViewVC Help
Powered by ViewVC 1.1.20