/[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.11 - (hide annotations) (download)
Sun Dec 22 12:11:56 2002 UTC (12 years ago) by cretin
Branch: MAIN
CVS Tags: GENTOO_1_4_SNAP_2003010800
Changes since 1.10: +2 -2 lines
Allow -g in strip-flags

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 cretin 1.11 # $Header: /home/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.10 2002/11/25 04:39:33 vapier Exp $
5 azarah 1.8
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 vapier 1.10 #### get-flag <flag> ####
28     # Find and echo the value for a particular flag
29     #
30 verwilst 1.3
31 verwilst 1.1 filter-flags () {
32    
33 azarah 1.8 for x in $1
34     do
35     export CFLAGS="${CFLAGS/${x}}"
36     export CXXFLAGS="${CXXFLAGS/${x}}"
37 verwilst 1.1 done
38 verwilst 1.2
39     }
40    
41     append-flags () {
42    
43 azarah 1.8 CFLAGS="${CFLAGS} $1"
44     CXXFLAGS="${CXXFLAGS} $1"
45 verwilst 1.1
46     }
47    
48 verwilst 1.4 replace-flags () {
49 verwilst 1.1
50 seemant 1.9 CFLAGS="${CFLAGS/${1}/${2} }"
51     CXXFLAGS="${CXXFLAGS/${1}/${2} }"
52 danarmak 1.7
53     }
54    
55     is-flag() {
56    
57 azarah 1.8 for x in ${CFLAGS} ${CXXFLAGS}
58     do
59     if [ "${x}" = "$1" ]
60     then
61     echo true
62     break
63 danarmak 1.7 fi
64     done
65 verwilst 1.1
66     }
67 azarah 1.8
68     strip-flags() {
69    
70     local NEW_CFLAGS=""
71     local NEW_CXXFLAGS=""
72    
73 cretin 1.11 local ALLOWED_FLAGS="-O -mcpu -march -pipe -g"
74 azarah 1.8
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 vapier 1.10 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