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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20