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

1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4 #
5 # Author Bart Verwilst <verwilst@gentoo.org>
6
7 ECLASS=flag-o-matic
8 INHERITED="$INHERITED $ECLASS"
9
10 #
11 #### filter-flags <flag> ####
12 # Remove particular flags from C[XX]FLAGS
13 #
14 #### append-flags <flag> ####
15 # Add extra flags to your current C[XX]FLAGS
16 #
17 #### replace-flags <orig.flag> <new.flag> ###
18 # Replace a flag by another one
19 #
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 #
31
32 filter-flags () {
33
34 for x in $1
35 do
36 export CFLAGS="${CFLAGS/${x}}"
37 export CXXFLAGS="${CXXFLAGS/${x}}"
38 done
39
40 }
41
42 append-flags () {
43
44 CFLAGS="${CFLAGS} $1"
45 CXXFLAGS="${CXXFLAGS} $1"
46
47 }
48
49 replace-flags () {
50
51 CFLAGS="${CFLAGS/${1}/${2} }"
52 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
53
54 }
55
56 is-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
69 strip-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
116 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