| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 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/toolchain-funcs.eclass,v 1.108 2011/10/17 19:11:49 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.112 2012/06/14 03:38:51 vapier Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: toolchain-funcs.eclass |
5 | # @ECLASS: toolchain-funcs.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Toolchain Ninjas <toolchain@gentoo.org> |
7 | # Toolchain Ninjas <toolchain@gentoo.org> |
| 8 | # @BLURB: functions to query common info about the toolchain |
8 | # @BLURB: functions to query common info about the toolchain |
| … | |
… | |
| 11 | # for gleaning useful information about the toolchain and to simplify |
11 | # for gleaning useful information about the toolchain and to simplify |
| 12 | # ugly things like cross-compiling and multilib. All of this is done |
12 | # ugly things like cross-compiling and multilib. All of this is done |
| 13 | # in such a way that you can rely on the function always returning |
13 | # in such a way that you can rely on the function always returning |
| 14 | # something sane. |
14 | # something sane. |
| 15 | |
15 | |
| 16 | ___ECLASS_RECUR_TOOLCHAIN_FUNCS="yes" |
16 | if [[ ${___ECLASS_ONCE_TOOLCHAIN_FUNCS} != "recur -_+^+_- spank" ]] ; then |
| 17 | [[ -z ${___ECLASS_RECUR_MULTILIB} ]] && inherit multilib |
17 | ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank" |
|
|
18 | |
|
|
19 | inherit multilib |
| 18 | |
20 | |
| 19 | DESCRIPTION="Based on the ${ECLASS} eclass" |
21 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 20 | |
22 | |
| 21 | # tc-getPROG <VAR [search vars]> <default> [tuple] |
23 | # tc-getPROG <VAR [search vars]> <default> [tuple] |
| 22 | _tc-getPROG() { |
24 | _tc-getPROG() { |
| … | |
… | |
| 175 | # @FUNCTION: tc-is-softfloat |
177 | # @FUNCTION: tc-is-softfloat |
| 176 | # @DESCRIPTION: |
178 | # @DESCRIPTION: |
| 177 | # See if this toolchain is a softfloat based one. |
179 | # See if this toolchain is a softfloat based one. |
| 178 | # @CODE |
180 | # @CODE |
| 179 | # The possible return values: |
181 | # The possible return values: |
| 180 | # - only: the target is always softfloat (never had fpu) |
182 | # - only: the target is always softfloat (never had fpu) |
| 181 | # - yes: the target should support softfloat |
183 | # - yes: the target should support softfloat |
|
|
184 | # - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention |
| 182 | # - no: the target doesn't support softfloat |
185 | # - no: the target doesn't support softfloat |
| 183 | # @CODE |
186 | # @CODE |
| 184 | # This allows us to react differently where packages accept |
187 | # This allows us to react differently where packages accept |
| 185 | # softfloat flags in the case where support is optional, but |
188 | # softfloat flags in the case where support is optional, but |
| 186 | # rejects softfloat flags where the target always lacks an fpu. |
189 | # rejects softfloat flags where the target always lacks an fpu. |
| 187 | tc-is-softfloat() { |
190 | tc-is-softfloat() { |
|
|
191 | local CTARGET=${CTARGET:-${CHOST}} |
| 188 | case ${CTARGET} in |
192 | case ${CTARGET} in |
| 189 | bfin*|h8300*) |
193 | bfin*|h8300*) |
| 190 | echo "only" ;; |
194 | echo "only" ;; |
| 191 | *) |
195 | *) |
| 192 | [[ ${CTARGET//_/-} == *-softfloat-* ]] \ |
196 | if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then |
| 193 | && echo "yes" \ |
197 | echo "yes" |
|
|
198 | elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then |
|
|
199 | echo "softfp" |
|
|
200 | else |
| 194 | || echo "no" |
201 | echo "no" |
|
|
202 | fi |
| 195 | ;; |
203 | ;; |
| 196 | esac |
204 | esac |
| 197 | } |
|
|
| 198 | |
|
|
| 199 | # @FUNCTION: tc-is-hardfloat |
|
|
| 200 | # @DESCRIPTION: |
|
|
| 201 | # See if this toolchain is a hardfloat based one. |
|
|
| 202 | # @CODE |
|
|
| 203 | # The possible return values: |
|
|
| 204 | # - yes: the target should support hardfloat |
|
|
| 205 | # - no: the target doesn't support hardfloat |
|
|
| 206 | tc-is-hardfloat() { |
|
|
| 207 | [[ ${CTARGET//_/-} == *-hardfloat-* ]] \ |
|
|
| 208 | && echo "yes" \ |
|
|
| 209 | || echo "no" |
|
|
| 210 | } |
205 | } |
| 211 | |
206 | |
| 212 | # @FUNCTION: tc-is-static-only |
207 | # @FUNCTION: tc-is-static-only |
| 213 | # @DESCRIPTION: |
208 | # @DESCRIPTION: |
| 214 | # Return shell true if the target does not support shared libs, shell false |
209 | # Return shell true if the target does not support shared libs, shell false |
| … | |
… | |
| 216 | tc-is-static-only() { |
211 | tc-is-static-only() { |
| 217 | local host=${CTARGET:-${CHOST}} |
212 | local host=${CTARGET:-${CHOST}} |
| 218 | |
213 | |
| 219 | # *MiNT doesn't have shared libraries, only platform so far |
214 | # *MiNT doesn't have shared libraries, only platform so far |
| 220 | return $([[ ${host} == *-mint* ]]) |
215 | return $([[ ${host} == *-mint* ]]) |
|
|
216 | } |
|
|
217 | |
|
|
218 | # @FUNCTION: tc-export_build_env |
|
|
219 | # @USAGE: [compiler variables] |
|
|
220 | # @DESCRIPTION: |
|
|
221 | # Export common build related compiler settings. |
|
|
222 | tc-export_build_env() { |
|
|
223 | tc-export "$@" |
|
|
224 | : ${BUILD_CFLAGS:=-O1 -pipe} |
|
|
225 | : ${BUILD_CXXFLAGS:=-O1 -pipe} |
|
|
226 | : ${BUILD_CPPFLAGS:=} |
|
|
227 | : ${BUILD_LDFLAGS:=} |
|
|
228 | export BUILD_{C,CXX,CPP,LD}FLAGS |
| 221 | } |
229 | } |
| 222 | |
230 | |
| 223 | # @FUNCTION: tc-env_build |
231 | # @FUNCTION: tc-env_build |
| 224 | # @USAGE: <command> [command args] |
232 | # @USAGE: <command> [command args] |
| 225 | # @INTERNAL |
233 | # @INTERNAL |
| … | |
… | |
| 227 | # Setup the compile environment to the build tools and then execute the |
235 | # Setup the compile environment to the build tools and then execute the |
| 228 | # specified command. We use tc-getBUILD_XX here so that we work with |
236 | # specified command. We use tc-getBUILD_XX here so that we work with |
| 229 | # all of the semi-[non-]standard env vars like $BUILD_CC which often |
237 | # all of the semi-[non-]standard env vars like $BUILD_CC which often |
| 230 | # the target build system does not check. |
238 | # the target build system does not check. |
| 231 | tc-env_build() { |
239 | tc-env_build() { |
|
|
240 | tc-export_build_env |
| 232 | CFLAGS=${BUILD_CFLAGS:--O1 -pipe} \ |
241 | CFLAGS=${BUILD_CFLAGS} \ |
| 233 | CXXFLAGS=${BUILD_CXXFLAGS:--O1 -pipe} \ |
242 | CXXFLAGS=${BUILD_CXXFLAGS} \ |
| 234 | CPPFLAGS=${BUILD_CPPFLAGS} \ |
243 | CPPFLAGS=${BUILD_CPPFLAGS} \ |
| 235 | LDFLAGS=${BUILD_LDFLAGS} \ |
244 | LDFLAGS=${BUILD_LDFLAGS} \ |
| 236 | AR=$(tc-getBUILD_AR) \ |
245 | AR=$(tc-getBUILD_AR) \ |
| 237 | AS=$(tc-getBUILD_AS) \ |
246 | AS=$(tc-getBUILD_AS) \ |
| 238 | CC=$(tc-getBUILD_CC) \ |
247 | CC=$(tc-getBUILD_CC) \ |
| … | |
… | |
| 757 | ;; |
766 | ;; |
| 758 | esac |
767 | esac |
| 759 | fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" |
768 | fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" |
| 760 | done |
769 | done |
| 761 | } |
770 | } |
|
|
771 | |
|
|
772 | fi |