/[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.26 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.26 2003/09/15 15:21:04 vapier 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"
35# 35#
36#### filter-mfpmath <math types> #### 36#### filter-mfpmath <math types> ####
37# Remove specified math types from the fpmath specification 37# Remove specified math types from the fpmath specification
38# If the user has -mfpmath=sse,386, running `filter-mfpmath sse` 38# If the user has -mfpmath=sse,386, running `filter-mfpmath sse`
39# will leave the user with -mfpmath=386 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#
40 54
41# C[XX]FLAGS that we allow in strip-flags 55# C[XX]FLAGS that we allow in strip-flags
42ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g" 56ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
43case "${ARCH}" in 57case "${ARCH}" in
44 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;; 58 mips) ALLOWED_FLAGS="${ALLOWED_FLAGS} -mips1 -mips2 -mips3 -mips4 -mabi" ;;
69 replace-flags "$orig_mfpmath" "$new_mfpmath" 83 replace-flags "$orig_mfpmath" "$new_mfpmath"
70 fi 84 fi
71} 85}
72 86
73filter-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
74 # we do this fancy spacing stuff so as to not filter 96 # we do this fancy spacing stuff so as to not filter
75 # out part of a flag ... we want flag atoms ! :D 97 # out part of a flag ... we want flag atoms ! :D
76 CFLAGS=" ${CFLAGS} " 98 CFLAGS=" ${CFLAGS} "
77 CXXFLAGS=" ${CXXFLAGS} " 99 CXXFLAGS=" ${CXXFLAGS} "
78 for x in $@ ; do 100 for x in $@ ; do
84} 106}
85 107
86append-flags() { 108append-flags() {
87 CFLAGS="${CFLAGS} $@" 109 CFLAGS="${CFLAGS} $@"
88 CXXFLAGS="${CXXFLAGS} $@" 110 CXXFLAGS="${CXXFLAGS} $@"
111 for x in $@; do
112 [ "${x}" = "-fno-stack-protector" ] &&
113 fstack-flags
114 done
89} 115}
90 116
91replace-flags() { 117replace-flags() {
92 CFLAGS="${CFLAGS/${1}/${2} }" 118 CFLAGS="${CFLAGS/${1}/${2} }"
93 CXXFLAGS="${CXXFLAGS/${1}/${2} }" 119 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
189 do 215 do
190 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" 216 CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}"
191 done 217 done
192 fi 218 fi
193} 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.26  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.20