/[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.9
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.9 2002/10/20 06:43:10 seemant Exp $
5
5ECLASS=flag-o-matic 6ECLASS=flag-o-matic
7INHERITED="$INHERITED $ECLASS"
6 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> ####
12# Add extra flags to your current C[XX]FLAGS 14# Add extra flags to your current C[XX]FLAGS
13# 15#
14#### change-flags <orig.flag> <new.flag> ### 16#### replace-flags <orig.flag> <new.flag> ###
15# Replace a flag by another one 17# Replace a flag by another one
16# 18#
17 19#### is-flag <flag> ####
20# Returns "true" if flag is set in C[XX]FLAGS
21# Matches only complete flag
22#
23#### strip-flags ####
24# Strip C[XX]FLAGS of everything except known
25# good options.
26#
18 27
19filter-flags () { 28filter-flags () {
20 29
21 for x in $1; do 30 for x in $1
31 do
22 CFLAGS="${CFLAGS/$x}" 32 export CFLAGS="${CFLAGS/${x}}"
23 CXXFLAGS="${CXXFLAGS/$x}" 33 export CXXFLAGS="${CXXFLAGS/${x}}"
24 done 34 done
25 35
26} 36}
27 37
28append-flags () { 38append-flags () {
29 39
30
31 CFLAGS="$CFLAGS $1" 40 CFLAGS="${CFLAGS} $1"
32 CXXFLAGS="$CXXFLAGS $1" 41 CXXFLAGS="${CXXFLAGS} $1"
33 42
34} 43}
35 44
36change-flags () { 45replace-flags () {
37 46
38 CFLAGS="${CFLAGS/${1}/${2}" 47 CFLAGS="${CFLAGS/${1}/${2} }"
39 CXXFLAGS="${CXXFLAGS/${1}/${2}" 48 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
40 49
41} 50}
51
52is-flag() {
53
54 for x in ${CFLAGS} ${CXXFLAGS}
55 do
56 if [ "${x}" = "$1" ]
57 then
58 echo true
59 break
60 fi
61 done
62
63}
64
65strip-flags() {
66
67 local NEW_CFLAGS=""
68 local NEW_CXXFLAGS=""
69
70 local ALLOWED_FLAGS="-O -mcpu -march -pipe"
71
72 set -f
73
74 for x in ${CFLAGS}
75 do
76 for y in ${ALLOWED_FLAGS}
77 do
78 if [ "${x/${y}}" != "${x}" ]
79 then
80 if [ -z "${NEW_CFLAGS}" ]
81 then
82 NEW_CFLAGS="${x}"
83 else
84 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
85 fi
86 fi
87 done
88 done
89
90 for x in ${CXXFLAGS}
91 do
92 for y in ${ALLOWED_FLAGS}
93 do
94 if [ "${x/${y}}" != "${x}" ]
95 then
96 if [ -z "${NEW_CXXFLAGS}" ]
97 then
98 NEW_CXXFLAGS="${x}"
99 else
100 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
101 fi
102 fi
103 done
104 done
105
106 set +f
107
108 export CFLAGS="${NEW_CFLAGS}"
109 export CXXFLAGS="${NEW_CXXFLAGS}"
110}
111

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

  ViewVC Help
Powered by ViewVC 1.1.20