/[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.12 - (hide annotations) (download)
Sun Feb 16 04:26:21 2003 UTC (11 years, 10 months ago) by vapier
Branch: MAIN
Changes since 1.11: +3 -2 lines
header fixes

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 vapier 1.12 # $Header: $
4     #
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.1 filter-flags () {
33    
34 azarah 1.8 for x in $1
35     do
36     export CFLAGS="${CFLAGS/${x}}"
37     export CXXFLAGS="${CXXFLAGS/${x}}"
38 verwilst 1.1 done
39 verwilst 1.2
40     }
41    
42     append-flags () {
43    
44 azarah 1.8 CFLAGS="${CFLAGS} $1"
45     CXXFLAGS="${CXXFLAGS} $1"
46 verwilst 1.1
47     }
48    
49 verwilst 1.4 replace-flags () {
50 verwilst 1.1
51 seemant 1.9 CFLAGS="${CFLAGS/${1}/${2} }"
52     CXXFLAGS="${CXXFLAGS/${1}/${2} }"
53 danarmak 1.7
54     }
55    
56     is-flag() {
57    
58 azarah 1.8 for x in ${CFLAGS} ${CXXFLAGS}
59     do
60     if [ "${x}" = "$1" ]
61     then
62     echo true
63     break
64 danarmak 1.7 fi
65     done
66 verwilst 1.1
67     }
68 azarah 1.8
69     strip-flags() {
70    
71     local NEW_CFLAGS=""
72     local NEW_CXXFLAGS=""
73    
74 cretin 1.11 local ALLOWED_FLAGS="-O -mcpu -march -pipe -g"
75 azarah 1.8
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    
116 vapier 1.10 get-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     }

  ViewVC Help
Powered by ViewVC 1.1.20