multilib-gcc-wrapper-0.ebuild 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 1999-2014 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils multilib
  5. DESCRIPTION="Wrappers for gcc tools to be used on non-native CHOSTs"
  6. HOMEPAGE="https://www.gentoo.org"
  7. SRC_URI=""
  8. LICENSE="public-domain"
  9. SLOT="0"
  10. KEYWORDS="~amd64"
  11. IUSE=""
  12. RDEPEND="sys-devel/gcc:="
  13. S=${WORKDIR}
  14. mkwrap() {
  15. einfo " ${2}"
  16. cat > "${T}"/wrapper <<-_EOF_
  17. #!${EPREFIX}/bin/sh
  18. exec ${1} $(get_abi_CFLAGS) "\${@}"
  19. _EOF_
  20. newbin "${T}"/wrapper "${2}"
  21. }
  22. src_install() {
  23. local host_prefix=${CHOST}
  24. # stolen from sys-devel/gcc-config
  25. # TODO: check if all of them actually support $(get_ABI_CFLAGS)
  26. local tools=(
  27. cpp cc gcc c++ g++ f77 g77 gcj gcjh gdc gdmd gfortran gccgo
  28. )
  29. cd "${EROOT%/}"/usr/bin || die
  30. eshopts_push -s nullglob
  31. # same as toolchain.eclass
  32. : ${TARGET_DEFAULT_ABI:=${DEFAULT_ABI}}
  33. : ${TARGET_MULTILIB_ABIS:=${MULTILIB_ABIS}}
  34. local ABI t e
  35. for ABI in $(get_all_abis TARGET); do
  36. [[ ${ABI} == ${TARGET_DEFAULT_ABI} ]] && continue
  37. einfo "Creating wrappers for ${ABI} ..."
  38. for t in "${tools[@]}"; do
  39. # look for both plain *-gcc and e.g. *-gcc-4.8.3
  40. # (but avoid *-gcc-nm)
  41. # note: nullglob applied above
  42. for e in ${host_prefix}[-]${t}{,-[0-9]*}; do
  43. local newname=$(get_abi_CHOST)-${e#${host_prefix}-}
  44. einfo " ${newname}"
  45. cat > "${T}"/wrapper <<-_EOF_
  46. #!${EPREFIX}/bin/sh
  47. exec ${e} $(get_abi_CFLAGS) "\${@}"
  48. _EOF_
  49. newbin "${T}"/wrapper "${newname}"
  50. done
  51. done
  52. done
  53. eshopts_pop
  54. }