go-1.7.4.ebuild 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. export CBUILD=${CBUILD:-${CHOST}}
  5. export CTARGET=${CTARGET:-${CHOST}}
  6. MY_PV=${PV/_/}
  7. inherit toolchain-funcs
  8. BOOTSTRAP_DIST="https://dev.gentoo.org/~williamh/dist"
  9. SRC_URI="!gccgo? (
  10. kernel_Darwin? (
  11. x64-macos? ( ${BOOTSTRAP_DIST}/go-darwin-amd64-bootstrap.tbz )
  12. )
  13. kernel_FreeBSD? (
  14. amd64-fbsd? ( ${BOOTSTRAP_DIST}/go-freebsd-amd64-bootstrap.tbz )
  15. x86-fbsd? ( ${BOOTSTRAP_DIST}/go-freebsd-386-bootstrap-1.tbz )
  16. )
  17. kernel_linux? (
  18. amd64? ( ${BOOTSTRAP_DIST}/go-linux-amd64-bootstrap.tbz )
  19. arm? ( ${BOOTSTRAP_DIST}/go-linux-arm-bootstrap.tbz )
  20. arm64? ( ${BOOTSTRAP_DIST}/go-linux-arm64-bootstrap.tbz )
  21. ppc64? (
  22. ${BOOTSTRAP_DIST}/go-linux-ppc64-bootstrap.tbz
  23. ${BOOTSTRAP_DIST}/go-linux-ppc64le-bootstrap.tbz
  24. )
  25. s390? ( ${BOOTSTRAP_DIST}/go-linux-s390x-bootstrap.tbz )
  26. x86? ( ${BOOTSTRAP_DIST}/go-linux-386-bootstrap-1.tbz )
  27. )
  28. kernel_SunOS? (
  29. x64-solaris? ( ${BOOTSTRAP_DIST}/go-solaris-amd64-bootstrap.tbz )
  30. )
  31. )
  32. "
  33. if [[ ${PV} = 9999 ]]; then
  34. EGIT_REPO_URI="git://github.com/golang/go.git"
  35. inherit git-r3
  36. else
  37. SRC_URI+="https://storage.googleapis.com/golang/go${MY_PV}.src.tar.gz"
  38. case ${PV} in
  39. *9999*|*_rc*) ;;
  40. *)
  41. KEYWORDS="-* amd64 arm ~arm64 ~ppc64 x86 ~amd64-fbsd ~x86-fbsd ~x64-macos ~x64-solaris"
  42. ;;
  43. esac
  44. fi
  45. DESCRIPTION="A concurrent garbage collected and typesafe programming language"
  46. HOMEPAGE="http://www.golang.org"
  47. LICENSE="BSD"
  48. SLOT="0/${PV}"
  49. IUSE="gccgo"
  50. DEPEND="gccgo? ( >=sys-devel/gcc-5[go] )"
  51. RDEPEND="!<dev-go/go-tools-0_pre20150902"
  52. # These test data objects have writable/executable stacks.
  53. QA_EXECSTACK="usr/lib/go/src/debug/elf/testdata/*.obj"
  54. # Do not complain about CFLAGS, etc, since Go doesn't use them.
  55. QA_FLAGS_IGNORED='.*'
  56. REQUIRES_EXCLUDE="/usr/lib/go/src/debug/elf/testdata/*"
  57. # The tools in /usr/lib/go should not cause the multilib-strict check to fail.
  58. QA_MULTILIB_PATHS="usr/lib/go/pkg/tool/.*/.*"
  59. # The go language uses *.a files which are _NOT_ libraries and should not be
  60. # stripped. The test data objects should also be left alone and unstripped.
  61. STRIP_MASK="/usr/lib/go/pkg/*.a
  62. /usr/lib/go/src/debug/elf/testdata/*
  63. /usr/lib/go/src/debug/dwarf/testdata/*
  64. /usr/lib/go/src/runtime/race/*.syso"
  65. if [[ ${PV} != 9999 ]]; then
  66. S="${WORKDIR}"/go
  67. fi
  68. go_arch()
  69. {
  70. # By chance most portage arch names match Go
  71. local portage_arch=$(tc-arch $@)
  72. case "${portage_arch}" in
  73. x86) echo 386;;
  74. x64-*) echo amd64;;
  75. ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;;
  76. s390) echo s390x ;;
  77. *) echo "${portage_arch}";;
  78. esac
  79. }
  80. go_arm()
  81. {
  82. case "${1:-${CHOST}}" in
  83. armv5*) echo 5;;
  84. armv6*) echo 6;;
  85. armv7*) echo 7;;
  86. *)
  87. die "unknown GOARM for ${1:-${CHOST}}"
  88. ;;
  89. esac
  90. }
  91. go_os()
  92. {
  93. case "${1:-${CHOST}}" in
  94. *-linux*) echo linux;;
  95. *-darwin*) echo darwin;;
  96. *-freebsd*) echo freebsd;;
  97. *-netbsd*) echo netbsd;;
  98. *-openbsd*) echo openbsd;;
  99. *-solaris*) echo solaris;;
  100. *-cygwin*|*-interix*|*-winnt*)
  101. echo windows
  102. ;;
  103. *)
  104. die "unknown GOOS for ${1:-${CHOST}}"
  105. ;;
  106. esac
  107. }
  108. go_tuple()
  109. {
  110. echo "$(go_os $@)_$(go_arch $@)"
  111. }
  112. go_cross_compile()
  113. {
  114. [[ $(go_tuple ${CBUILD}) != $(go_tuple) ]]
  115. }
  116. pkg_pretend()
  117. {
  118. # make.bash does not understand cross-compiling a cross-compiler
  119. if [[ $(go_tuple) != $(go_tuple ${CTARGET}) ]]; then
  120. die "CHOST CTARGET pair unsupported: CHOST=${CHOST} CTARGET=${CTARGET}"
  121. fi
  122. }
  123. src_unpack()
  124. {
  125. if [[ ${PV} = 9999 ]]; then
  126. git-r3_src_unpack
  127. fi
  128. default
  129. }
  130. src_compile()
  131. {
  132. export GOROOT_BOOTSTRAP="${WORKDIR}"/go-$(go_os)-$(go_arch)-bootstrap
  133. if use gccgo; then
  134. mkdir -p "${GOROOT_BOOTSTRAP}/bin" || die
  135. local go_binary=$(gcc-config --get-bin-path)/go-5
  136. [[ -x ${go_binary} ]] || go_binary=$(
  137. find "${EPREFIX}"/usr/${CHOST}/gcc-bin/*/go-5 | sort -V | tail -n1)
  138. [[ -x ${go_binary} ]] || die "go-5: command not found"
  139. ln -s "${go_binary}" "${GOROOT_BOOTSTRAP}/bin/go" || die
  140. fi
  141. export GOROOT_FINAL="${EPREFIX}"/usr/lib/go
  142. export GOROOT="$(pwd)"
  143. export GOBIN="${GOROOT}/bin"
  144. # Go's build script does not use BUILD/HOST/TARGET consistently. :(
  145. export GOHOSTARCH=$(go_arch ${CBUILD})
  146. export GOHOSTOS=$(go_os ${CBUILD})
  147. export CC=$(tc-getBUILD_CC)
  148. export GOARCH=$(go_arch)
  149. export GOOS=$(go_os)
  150. export CC_FOR_TARGET=$(tc-getCC)
  151. export CXX_FOR_TARGET=$(tc-getCXX)
  152. if [[ ${ARCH} == arm ]]; then
  153. export GOARM=$(go_arm)
  154. fi
  155. elog "GOROOT_BOOTSTRAP is ${GOROOT_BOOTSTRAP}"
  156. cd src
  157. ./make.bash || die "build failed"
  158. }
  159. src_test()
  160. {
  161. go_cross_compile && return 0
  162. cd src
  163. PATH="${GOBIN}:${PATH}" \
  164. ./run.bash -no-rebuild || die "tests failed"
  165. }
  166. src_install()
  167. {
  168. local bin_path f x
  169. dodir /usr/lib/go
  170. insinto /usr/lib/go
  171. # There is a known issue which requires the source tree to be installed [1].
  172. # Once this is fixed, we can consider using the doc use flag to control
  173. # installing the doc and src directories.
  174. # [1] https://golang.org/issue/2775
  175. doins -r bin doc lib pkg src
  176. fperms -R +x /usr/lib/go/bin /usr/lib/go/pkg/tool
  177. cp -a misc "${D}"/usr/lib/go/misc
  178. if go_cross_compile; then
  179. bin_path="bin/$(go_tuple)"
  180. else
  181. bin_path=bin
  182. fi
  183. for x in ${bin_path}/*; do
  184. f=${x##*/}
  185. dosym ../lib/go/${bin_path}/${f} /usr/bin/${f}
  186. done
  187. dodoc AUTHORS CONTRIBUTORS PATENTS README.md
  188. }