| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2003 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 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.36 2004/02/21 07:07:56 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.37 2004/02/21 07:19:29 vapier Exp $ |
| 4 | # |
4 | # |
| 5 | # Author Bart Verwilst <verwilst@gentoo.org> |
5 | # Author Bart Verwilst <verwilst@gentoo.org> |
| 6 | |
6 | |
| 7 | ECLASS=flag-o-matic |
7 | ECLASS=flag-o-matic |
| 8 | INHERITED="$INHERITED $ECLASS" |
8 | INHERITED="$INHERITED $ECLASS" |
| … | |
… | |
| 15 | #### append-flags <flags> #### |
15 | #### append-flags <flags> #### |
| 16 | # Add extra flags to your current C[XX]FLAGS |
16 | # Add extra flags to your current C[XX]FLAGS |
| 17 | # |
17 | # |
| 18 | #### replace-flags <orig.flag> <new.flag> ### |
18 | #### replace-flags <orig.flag> <new.flag> ### |
| 19 | # Replace a flag by another one |
19 | # Replace a flag by another one |
|
|
20 | # |
|
|
21 | #### replace-cpu-flags <new.cpu> <old.cpus> ### |
|
|
22 | # Replace march/mcpu flags that specify <old.cpus> |
|
|
23 | # with flags that specify <new.cpu> |
| 20 | # |
24 | # |
| 21 | #### is-flag <flag> #### |
25 | #### is-flag <flag> #### |
| 22 | # Returns "true" if flag is set in C[XX]FLAGS |
26 | # Returns "true" if flag is set in C[XX]FLAGS |
| 23 | # Matches only complete a flag |
27 | # Matches only complete a flag |
| 24 | # |
28 | # |
| … | |
… | |
| 84 | # we do this fancy spacing stuff so as to not filter |
88 | # we do this fancy spacing stuff so as to not filter |
| 85 | # out part of a flag ... we want flag atoms ! :D |
89 | # out part of a flag ... we want flag atoms ! :D |
| 86 | CFLAGS=" ${CFLAGS} " |
90 | CFLAGS=" ${CFLAGS} " |
| 87 | CXXFLAGS=" ${CXXFLAGS} " |
91 | CXXFLAGS=" ${CXXFLAGS} " |
| 88 | for x in "$@" ; do |
92 | for x in "$@" ; do |
| 89 | CFLAGS="${CFLAGS/ ${x} / }" |
93 | CFLAGS="${CFLAGS// ${x} / }" |
| 90 | CXXFLAGS="${CXXFLAGS/ ${x} / }" |
94 | CXXFLAGS="${CXXFLAGS// ${x} / }" |
| 91 | done |
95 | done |
| 92 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
96 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
| 93 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
97 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
| 94 | return 0 |
98 | return 0 |
| 95 | } |
99 | } |
| … | |
… | |
| 104 | replace-flags() { |
108 | replace-flags() { |
| 105 | # we do this fancy spacing stuff so as to not filter |
109 | # we do this fancy spacing stuff so as to not filter |
| 106 | # out part of a flag ... we want flag atoms ! :D |
110 | # out part of a flag ... we want flag atoms ! :D |
| 107 | CFLAGS=" ${CFLAGS} " |
111 | CFLAGS=" ${CFLAGS} " |
| 108 | CXXFLAGS=" ${CXXFLAGS} " |
112 | CXXFLAGS=" ${CXXFLAGS} " |
| 109 | CFLAGS="${CFLAGS/ ${1} / ${2} }" |
113 | CFLAGS="${CFLAGS// ${1} / ${2} }" |
| 110 | CXXFLAGS="${CXXFLAGS/ ${1} / ${2} }" |
114 | CXXFLAGS="${CXXFLAGS// ${1} / ${2} }" |
| 111 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
115 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
| 112 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
116 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
|
|
117 | return 0 |
|
|
118 | } |
|
|
119 | |
|
|
120 | replace-cpu-flags() { |
|
|
121 | local newcpu="$1" ; shift |
|
|
122 | local oldcpu="" |
|
|
123 | for oldcpu in "$@" ; do |
|
|
124 | replace-flags -march=${oldcpu} -march=${newcpu} |
|
|
125 | replace-flags -mcpu=${oldcpu} -mcpu=${newcpu} |
|
|
126 | done |
| 113 | return 0 |
127 | return 0 |
| 114 | } |
128 | } |
| 115 | |
129 | |
| 116 | is-flag() { |
130 | is-flag() { |
| 117 | for x in ${CFLAGS} ${CXXFLAGS} ; do |
131 | for x in ${CFLAGS} ${CXXFLAGS} ; do |