/[gentoo-x86]/eclass/flag-o-matic.eclass
Gentoo

Contents of /eclass/flag-o-matic.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Tue Mar 25 07:07:42 2003 UTC (11 years, 7 months ago) by lostlogic
Branch: MAIN
Changes since 1.13: +9 -15 lines
Fix strip-flags to do greedy matching and not have duplicated matched flags

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

  ViewVC Help
Powered by ViewVC 1.1.20