/[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.10 - (show annotations) (download)
Mon Nov 25 04:39:33 2002 UTC (11 years, 8 months ago) by vapier
Branch: MAIN
Changes since 1.9: +14 -1 lines
added get-flag function

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 # $Header: /home/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.9 2002/10/20 06:43:10 seemant Exp $
5
6 ECLASS=flag-o-matic
7 INHERITED="$INHERITED $ECLASS"
8
9 #
10 #### filter-flags <flag> ####
11 # Remove particular flags from C[XX]FLAGS
12 #
13 #### append-flags <flag> ####
14 # Add extra flags to your current C[XX]FLAGS
15 #
16 #### replace-flags <orig.flag> <new.flag> ###
17 # Replace a flag by another one
18 #
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 #
27 #### get-flag <flag> ####
28 # Find and echo the value for a particular flag
29 #
30
31 filter-flags () {
32
33 for x in $1
34 do
35 export CFLAGS="${CFLAGS/${x}}"
36 export CXXFLAGS="${CXXFLAGS/${x}}"
37 done
38
39 }
40
41 append-flags () {
42
43 CFLAGS="${CFLAGS} $1"
44 CXXFLAGS="${CXXFLAGS} $1"
45
46 }
47
48 replace-flags () {
49
50 CFLAGS="${CFLAGS/${1}/${2} }"
51 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
52
53 }
54
55 is-flag() {
56
57 for x in ${CFLAGS} ${CXXFLAGS}
58 do
59 if [ "${x}" = "$1" ]
60 then
61 echo true
62 break
63 fi
64 done
65
66 }
67
68 strip-flags() {
69
70 local NEW_CFLAGS=""
71 local NEW_CXXFLAGS=""
72
73 local ALLOWED_FLAGS="-O -mcpu -march -pipe"
74
75 set -f
76
77 for x in ${CFLAGS}
78 do
79 for y in ${ALLOWED_FLAGS}
80 do
81 if [ "${x/${y}}" != "${x}" ]
82 then
83 if [ -z "${NEW_CFLAGS}" ]
84 then
85 NEW_CFLAGS="${x}"
86 else
87 NEW_CFLAGS="${NEW_CFLAGS} ${x}"
88 fi
89 fi
90 done
91 done
92
93 for x in ${CXXFLAGS}
94 do
95 for y in ${ALLOWED_FLAGS}
96 do
97 if [ "${x/${y}}" != "${x}" ]
98 then
99 if [ -z "${NEW_CXXFLAGS}" ]
100 then
101 NEW_CXXFLAGS="${x}"
102 else
103 NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
104 fi
105 fi
106 done
107 done
108
109 set +f
110
111 export CFLAGS="${NEW_CFLAGS}"
112 export CXXFLAGS="${NEW_CXXFLAGS}"
113 }
114
115 get-flag() {
116 local findflag="$1"
117
118 for f in ${CFLAGS} ${CXXFLAGS} ; do
119 if [ "${f/${findflag}}" != "${f}" ] ; then
120 echo "${f/-${findflag}=}"
121 return
122 fi
123 done
124 }

  ViewVC Help
Powered by ViewVC 1.1.20