blob: 4c07ea7c16817e6d97862ac5f59ad5f5fca5ac06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author Bart Verwilst <verwilst@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.9 2002/10/20 06:43:10 seemant Exp $
ECLASS=flag-o-matic
INHERITED="$INHERITED $ECLASS"
#
#### filter-flags <flag> ####
# Remove particular flags from C[XX]FLAGS
#
#### append-flags <flag> ####
# Add extra flags to your current C[XX]FLAGS
#
#### replace-flags <orig.flag> <new.flag> ###
# Replace a flag by another one
#
#### is-flag <flag> ####
# Returns "true" if flag is set in C[XX]FLAGS
# Matches only complete flag
#
#### strip-flags ####
# Strip C[XX]FLAGS of everything except known
# good options.
#
filter-flags () {
for x in $1
do
export CFLAGS="${CFLAGS/${x}}"
export CXXFLAGS="${CXXFLAGS/${x}}"
done
}
append-flags () {
CFLAGS="${CFLAGS} $1"
CXXFLAGS="${CXXFLAGS} $1"
}
replace-flags () {
CFLAGS="${CFLAGS/${1}/${2} }"
CXXFLAGS="${CXXFLAGS/${1}/${2} }"
}
is-flag() {
for x in ${CFLAGS} ${CXXFLAGS}
do
if [ "${x}" = "$1" ]
then
echo true
break
fi
done
}
strip-flags() {
local NEW_CFLAGS=""
local NEW_CXXFLAGS=""
local ALLOWED_FLAGS="-O -mcpu -march -pipe"
set -f
for x in ${CFLAGS}
do
for y in ${ALLOWED_FLAGS}
do
if [ "${x/${y}}" != "${x}" ]
then
if [ -z "${NEW_CFLAGS}" ]
then
NEW_CFLAGS="${x}"
else
NEW_CFLAGS="${NEW_CFLAGS} ${x}"
fi
fi
done
done
for x in ${CXXFLAGS}
do
for y in ${ALLOWED_FLAGS}
do
if [ "${x/${y}}" != "${x}" ]
then
if [ -z "${NEW_CXXFLAGS}" ]
then
NEW_CXXFLAGS="${x}"
else
NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}"
fi
fi
done
done
set +f
export CFLAGS="${NEW_CFLAGS}"
export CXXFLAGS="${NEW_CXXFLAGS}"
}
|