| 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.109 2011/12/10 19:45:00 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.113 2012/07/21 16:11:01 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 |
| … | |
… | |
| 177 | # @FUNCTION: tc-is-softfloat |
177 | # @FUNCTION: tc-is-softfloat |
| 178 | # @DESCRIPTION: |
178 | # @DESCRIPTION: |
| 179 | # See if this toolchain is a softfloat based one. |
179 | # See if this toolchain is a softfloat based one. |
| 180 | # @CODE |
180 | # @CODE |
| 181 | # The possible return values: |
181 | # The possible return values: |
| 182 | # - only: the target is always softfloat (never had fpu) |
182 | # - only: the target is always softfloat (never had fpu) |
| 183 | # - 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 |
| 184 | # - no: the target doesn't support softfloat |
185 | # - no: the target doesn't support softfloat |
| 185 | # @CODE |
186 | # @CODE |
| 186 | # This allows us to react differently where packages accept |
187 | # This allows us to react differently where packages accept |
| 187 | # softfloat flags in the case where support is optional, but |
188 | # softfloat flags in the case where support is optional, but |
| 188 | # rejects softfloat flags where the target always lacks an fpu. |
189 | # rejects softfloat flags where the target always lacks an fpu. |
| 189 | tc-is-softfloat() { |
190 | tc-is-softfloat() { |
|
|
191 | local CTARGET=${CTARGET:-${CHOST}} |
| 190 | case ${CTARGET} in |
192 | case ${CTARGET} in |
| 191 | bfin*|h8300*) |
193 | bfin*|h8300*) |
| 192 | echo "only" ;; |
194 | echo "only" ;; |
| 193 | *) |
195 | *) |
| 194 | [[ ${CTARGET//_/-} == *-softfloat-* ]] \ |
196 | if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then |
| 195 | && echo "yes" \ |
197 | echo "yes" |
|
|
198 | elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then |
|
|
199 | echo "softfp" |
|
|
200 | else |
| 196 | || echo "no" |
201 | echo "no" |
|
|
202 | fi |
| 197 | ;; |
203 | ;; |
| 198 | esac |
204 | esac |
| 199 | } |
|
|
| 200 | |
|
|
| 201 | # @FUNCTION: tc-is-hardfloat |
|
|
| 202 | # @DESCRIPTION: |
|
|
| 203 | # See if this toolchain is a hardfloat based one. |
|
|
| 204 | # @CODE |
|
|
| 205 | # The possible return values: |
|
|
| 206 | # - yes: the target should support hardfloat |
|
|
| 207 | # - no: the target doesn't support hardfloat |
|
|
| 208 | tc-is-hardfloat() { |
|
|
| 209 | [[ ${CTARGET//_/-} == *-hardfloat-* ]] \ |
|
|
| 210 | && echo "yes" \ |
|
|
| 211 | || echo "no" |
|
|
| 212 | } |
205 | } |
| 213 | |
206 | |
| 214 | # @FUNCTION: tc-is-static-only |
207 | # @FUNCTION: tc-is-static-only |
| 215 | # @DESCRIPTION: |
208 | # @DESCRIPTION: |
| 216 | # 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 |
| … | |
… | |
| 218 | tc-is-static-only() { |
211 | tc-is-static-only() { |
| 219 | local host=${CTARGET:-${CHOST}} |
212 | local host=${CTARGET:-${CHOST}} |
| 220 | |
213 | |
| 221 | # *MiNT doesn't have shared libraries, only platform so far |
214 | # *MiNT doesn't have shared libraries, only platform so far |
| 222 | 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 |
| 223 | } |
229 | } |
| 224 | |
230 | |
| 225 | # @FUNCTION: tc-env_build |
231 | # @FUNCTION: tc-env_build |
| 226 | # @USAGE: <command> [command args] |
232 | # @USAGE: <command> [command args] |
| 227 | # @INTERNAL |
233 | # @INTERNAL |
| … | |
… | |
| 229 | # 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 |
| 230 | # 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 |
| 231 | # 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 |
| 232 | # the target build system does not check. |
238 | # the target build system does not check. |
| 233 | tc-env_build() { |
239 | tc-env_build() { |
|
|
240 | tc-export_build_env |
| 234 | CFLAGS=${BUILD_CFLAGS:--O1 -pipe} \ |
241 | CFLAGS=${BUILD_CFLAGS} \ |
| 235 | CXXFLAGS=${BUILD_CXXFLAGS:--O1 -pipe} \ |
242 | CXXFLAGS=${BUILD_CXXFLAGS} \ |
| 236 | CPPFLAGS=${BUILD_CPPFLAGS} \ |
243 | CPPFLAGS=${BUILD_CPPFLAGS} \ |
| 237 | LDFLAGS=${BUILD_LDFLAGS} \ |
244 | LDFLAGS=${BUILD_LDFLAGS} \ |
| 238 | AR=$(tc-getBUILD_AR) \ |
245 | AR=$(tc-getBUILD_AR) \ |
| 239 | AS=$(tc-getBUILD_AS) \ |
246 | AS=$(tc-getBUILD_AS) \ |
| 240 | CC=$(tc-getBUILD_CC) \ |
247 | CC=$(tc-getBUILD_CC) \ |
| … | |
… | |
| 603 | local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) |
610 | local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) |
| 604 | [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ |
611 | [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ |
| 605 | |
612 | |
| 606 | tc-is-static-only && return |
613 | tc-is-static-only && return |
| 607 | |
614 | |
|
|
615 | # Eventually we'd like to get rid of this func completely #417451 |
|
|
616 | case ${CTARGET:-${CHOST}} in |
|
|
617 | *-darwin*) ;; |
|
|
618 | *linux*) use prefix && return 0 ;; |
|
|
619 | *) return 0 ;; |
|
|
620 | esac |
|
|
621 | |
| 608 | # Just make sure it exists |
622 | # Just make sure it exists |
| 609 | dodir /usr/${libdir} |
623 | dodir /usr/${libdir} |
| 610 | |
624 | |
| 611 | if [[ $1 == "-a" ]] ; then |
625 | if [[ $1 == "-a" ]] ; then |
| 612 | auto=true |
626 | auto=true |
| … | |
… | |
| 669 | # understand linker scripts, just create a symlink. |
683 | # understand linker scripts, just create a symlink. |
| 670 | pushd "${ED}/usr/${libdir}" > /dev/null |
684 | pushd "${ED}/usr/${libdir}" > /dev/null |
| 671 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
685 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
| 672 | popd > /dev/null |
686 | popd > /dev/null |
| 673 | ;; |
687 | ;; |
| 674 | *-aix*|*-irix*|*64*-hpux*|*-interix*|*-winnt*) |
688 | *linux*) |
| 675 | if ${auto} ; then |
|
|
| 676 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
|
|
| 677 | # no way to retrieve soname on these platforms (?) |
|
|
| 678 | tlib=$(readlink "${ED}"/${libdir}/${lib}) |
|
|
| 679 | tlib=${tlib##*/} |
|
|
| 680 | if [[ -z ${tlib} ]] ; then |
|
|
| 681 | # ok, apparently was not a symlink, don't remove it and |
|
|
| 682 | # just link to it |
|
|
| 683 | tlib=${lib} |
|
|
| 684 | else |
|
|
| 685 | rm -f "${ED}"/${libdir}/${lib} |
|
|
| 686 | fi |
|
|
| 687 | else |
|
|
| 688 | tlib=${lib} |
|
|
| 689 | fi |
|
|
| 690 | |
|
|
| 691 | # we don't have GNU binutils on these platforms, so we symlink |
|
|
| 692 | # instead, which seems to work fine. Keep it relative, otherwise |
|
|
| 693 | # we break some QA checks in Portage |
|
|
| 694 | # on interix, the linker scripts would work fine in _most_ |
|
|
| 695 | # situations. if a library links to such a linker script the |
|
|
| 696 | # absolute path to the correct library is inserted into the binary, |
|
|
| 697 | # which is wrong, since anybody linking _without_ libtool will miss |
|
|
| 698 | # some dependencies, since the stupid linker cannot find libraries |
|
|
| 699 | # hardcoded with absolute paths (as opposed to the loader, which |
|
|
| 700 | # seems to be able to do this). |
|
|
| 701 | # this has been seen while building shared-mime-info which needs |
|
|
| 702 | # libxml2, but links without libtool (and does not add libz to the |
|
|
| 703 | # command line by itself). |
|
|
| 704 | pushd "${ED}/usr/${libdir}" > /dev/null |
|
|
| 705 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
|
|
| 706 | popd > /dev/null |
|
|
| 707 | ;; |
|
|
| 708 | hppa*-hpux*) # PA-RISC 32bit (SOM) only, others (ELF) match *64*-hpux* above. |
|
|
| 709 | if ${auto} ; then |
|
|
| 710 | tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}') |
|
|
| 711 | [[ -z ${tlib} ]] && tlib=${lib} |
|
|
| 712 | tlib=${tlib##*/} # 'internal name' can have a path component |
|
|
| 713 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
|
|
| 714 | # some SONAMEs are funky: they encode a version before the .so |
|
|
| 715 | if [[ ${tlib} != ${lib}* ]] ; then |
|
|
| 716 | mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die |
|
|
| 717 | fi |
|
|
| 718 | [[ ${tlib} != ${lib} ]] && |
|
|
| 719 | rm -f "${ED}"/${libdir}/${lib} |
|
|
| 720 | else |
|
|
| 721 | tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}') |
|
|
| 722 | [[ -z ${tlib} ]] && tlib=${lib} |
|
|
| 723 | tlib=${tlib##*/} # 'internal name' can have a path component |
|
|
| 724 | fi |
|
|
| 725 | pushd "${ED}"/usr/${libdir} >/dev/null |
|
|
| 726 | ln -snf "../../${libdir}/${tlib}" "${lib}" |
|
|
| 727 | # need the internal name in usr/lib too, to be available at runtime |
|
|
| 728 | # when linked with /path/to/lib.sl (hardcode_direct_absolute=yes) |
|
|
| 729 | [[ ${tlib} != ${lib} ]] && |
|
|
| 730 | ln -snf "../../${libdir}/${tlib}" "${tlib}" |
|
|
| 731 | popd >/dev/null |
|
|
| 732 | ;; |
|
|
| 733 | *) |
|
|
| 734 | if ${auto} ; then |
689 | if ${auto} ; then |
| 735 | tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) |
690 | tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) |
| 736 | [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" |
691 | [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" |
| 737 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
692 | mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die |
| 738 | # some SONAMEs are funky: they encode a version before the .so |
693 | # some SONAMEs are funky: they encode a version before the .so |