/[gentoo-x86]/eclass/flag-o-matic.eclass
Gentoo

Diff of /eclass/flag-o-matic.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.11
1# Copyright 1999-2002 Gentoo Technologies, Inc. 1# Copyright 1999-2002 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# Author Bart Verwilst <verwilst@gentoo.org> 3# Author Bart Verwilst <verwilst@gentoo.org>
4# /space/gentoo/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass 4# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.11 2002/12/22 12:11:56 cretin Exp $
5
5ECLASS=flag-o-matic 6ECLASS=flag-o-matic
7INHERITED="$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#
6 30
7filter-flags () { 31filter-flags () {
8 32
9 for x in $1; do 33 for x in $1
34 do
10 CFLAGS="${CFLAGS/$x}" 35 export CFLAGS="${CFLAGS/${x}}"
11 CXXFLAGS="${CXXFLAGS/$x}" 36 export CXXFLAGS="${CXXFLAGS/${x}}"
12 done 37 done
13 38
14} 39}
15 40
16max-optim () { 41append-flags () {
17 42
18 for x in $CFLAGS; do 43 CFLAGS="${CFLAGS} $1"
19 echo $x 44 CXXFLAGS="${CXXFLAGS} $1"
45
46}
47
48replace-flags () {
49
50 CFLAGS="${CFLAGS/${1}/${2} }"
51 CXXFLAGS="${CXXFLAGS/${1}/${2} }"
52
53}
54
55is-flag() {
56
57 for x in ${CFLAGS} ${CXXFLAGS}
58 do
59 if [ "${x}" = "$1" ]
60 then
61 echo true
62 break
63 fi
20 done 64 done
21 65
22} 66}
67
68strip-flags() {
69
70 local NEW_CFLAGS=""
71 local NEW_CXXFLAGS=""
72
73 local ALLOWED_FLAGS="-O -mcpu -march -pipe -g"
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
115get-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}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20