/[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.8 - (hide annotations) (download)
Sun Oct 13 01:01:58 2002 UTC (11 years, 9 months ago) by azarah
Branch: MAIN
Changes since 1.7: +67 -11 lines
add strip-flags() to flag-o-matic.eclass

1 verwilst 1.1 # Copyright 1999-2002 Gentoo Technologies, Inc.
2     # Distributed under the terms of the GNU General Public License v2
3     # Author Bart Verwilst <verwilst@gentoo.org>
4 azarah 1.8 # $Header: $
5    
6 verwilst 1.1 ECLASS=flag-o-matic
7 danarmak 1.6 INHERITED="$INHERITED $ECLASS"
8 azarah 1.8
9 verwilst 1.2 #
10 verwilst 1.3 #### filter-flags <flag> ####
11     # Remove particular flags from C[XX]FLAGS
12 verwilst 1.2 #
13 verwilst 1.3 #### append-flags <flag> ####
14     # Add extra flags to your current C[XX]FLAGS
15     #
16 verwilst 1.4 #### replace-flags <orig.flag> <new.flag> ###
17 verwilst 1.3 # Replace a flag by another one
18     #
19 danarmak 1.7 #### is-flag <flag> ####
20     # Returns "true" if flag is set in C[XX]FLAGS
21     # Matches only complete flag
22     #
23 azarah 1.8 #### strip-flags ####
24     # Strip C[XX]FLAGS of everything except known
25     # good options.
26     #
27 verwilst 1.3
28 verwilst 1.1 filter-flags () {
29    
30 azarah 1.8 for x in $1
31     do
32     export CFLAGS="${CFLAGS/${x}}"
33     export CXXFLAGS="${CXXFLAGS/${x}}"
34 verwilst 1.1 done
35 verwilst 1.2
36     }
37    
38     append-flags () {
39    
40 azarah 1.8 CFLAGS="${CFLAGS} $1"
41     CXXFLAGS="${CXXFLAGS} $1"
42 verwilst 1.1
43     }
44    
45 verwilst 1.4 replace-flags () {
46 verwilst 1.1
47 drobbins 1.5 CFLAGS="${CFLAGS/${1}/${2}}"
48     CXXFLAGS="${CXXFLAGS/${1}/${2}}"
49 danarmak 1.7
50     }
51    
52     is-flag() {
53    
54 azarah 1.8 for x in ${CFLAGS} ${CXXFLAGS}
55     do
56     if [ "${x}" = "$1" ]
57     then
58     echo true
59     break
60 danarmak 1.7 fi
61     done
62 verwilst 1.1
63     }
64 azarah 1.8
65     strip-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     }

  ViewVC Help
Powered by ViewVC 1.1.20