/[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.7 Revision 1.11
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2002 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# Author Bart Verwilst <verwilst@gentoo.org> 3# Author Bart Verwilst <verwilst@gentoo.org>
4# /space/gentoo/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass 4# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.11 2002/12/22 12:11:56 cretin Exp $
5
5ECLASS=flag-o-matic 6ECLASS=flag-o-matic
6INHERITED="$INHERITED $ECLASS" 7INHERITED="$INHERITED $ECLASS"
8
7# 9#
8#### filter-flags <flag> #### 10#### filter-flags <flag> ####
9# Remove particular flags from C[XX]FLAGS 11# Remove particular flags from C[XX]FLAGS
10# 12#
11#### append-flags <flag> #### 13#### append-flags <flag> ####
16# 18#
17#### is-flag <flag> #### 19#### is-flag <flag> ####
18# Returns "true" if flag is set in C[XX]FLAGS 20# Returns "true" if flag is set in C[XX]FLAGS
19# Matches only complete flag 21# Matches only complete flag
20# 22#
23#### strip-flags ####
24# Strip C[XX]FLAGS of everything except known
25# good options.
26#
27#### get-flag <flag> ####
28# Find and echo the value for a particular flag
29#
21 30
22filter-flags () { 31filter-flags () {
23 32
24 for x in $1; do 33 for x in $1
34 do
25 CFLAGS="${CFLAGS/$x}" 35 export CFLAGS="${CFLAGS/${x}}"
26 CXXFLAGS="${CXXFLAGS/$x}" 36 export CXXFLAGS="${CXXFLAGS/${x}}"
27 done 37 done
28 38
29} 39}
30 40
31append-flags () { 41append-flags () {
32 42
33
34 CFLAGS="$CFLAGS $1" 43 CFLAGS="${CFLAGS} $1"
35 CXXFLAGS="$CXXFLAGS $1" 44 CXXFLAGS="${CXXFLAGS} $1"
36 45
37} 46}
38 47
39replace-flags () { 48replace-flags () {
40 49
41 CFLAGS="${CFLAGS/${1}/${2}}" 50 CFLAGS="${CFLAGS/${1}/${2} }"
42 CXXFLAGS="${CXXFLAGS/${1}/${2}}" 51 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
43 52
44} 53}
45 54
46is-flag() { 55is-flag() {
47 56
48 for x in $CFLAGS $CXXFLAGS; do 57 for x in ${CFLAGS} ${CXXFLAGS}
58 do
49 if [ "$x" == "$1" ]; then 59 if [ "${x}" = "$1" ]
60 then
50 echo true 61 echo true
51 break 62 break
52 fi 63 fi
53 done 64 done
54 65
55} 66}
67
68strip-flags() {
69
70 local NEW_CFLAGS=""
71 local NEW_CXXFLAGS=""
72
73 local ALLOWED_FLAGS="-O -mcpu -march -pipe -g"
74
75 set -f
76
77 for x in ${CFLAGS}
78 do
79 for y in ${ALLOWED_FLAGS}
80 do
81 if [ "${x/${y}}" != "${x}" ]
82 then
83 if [ -z "${NEW_CFLAGS}" ]
84 then
85 NEW_CFLAGS="${x}"
86 else
87 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
88 fi
89 fi
90 done
91 done
92
93 for x in ${CXXFLAGS}
94 do
95 for y in ${ALLOWED_FLAGS}
96 do
97 if [ "${x/${y}}" != "${x}" ]
98 then
99 if [ -z "${NEW_CXXFLAGS}" ]
100 then
101 NEW_CXXFLAGS="${x}"
102 else
103 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
104 fi
105 fi
106 done
107 done
108
109 set +f
110
111 export CFLAGS="${NEW_CFLAGS}"
112 export CXXFLAGS="${NEW_CXXFLAGS}"
113}
114
115get-flag() {
116 local findflag="$1"
117
118 for f in ${CFLAGS} ${CXXFLAGS} ; do
119 if [ "${f/${findflag}}" != "${f}" ] ; then
120 echo "${f/-${findflag}=}"
121 return
122 fi
123 done
124}

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20