luajit-2.1.0_p20240310.ebuild 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. GIT_COMMIT=d06beb0480c5d1eb53b3343e78063950275aa281
  5. LUA_COMPAT=( lua5-{1..4} luajit)
  6. inherit pax-utils lua-single toolchain-funcs
  7. MY_PV="$(ver_cut 1-5)"
  8. MY_PV="${MY_PV/_beta/-beta}"
  9. MY_P="LuaJIT-${MY_PV}"
  10. DESCRIPTION="Just-In-Time Compiler for the Lua programming language"
  11. HOMEPAGE="https://luajit.org/"
  12. #SRC_URI="https://luajit.org/download/${MY_P}.tar.gz"
  13. SRC_URI="https://github.com/LuaJIT/LuaJIT/archive/${GIT_COMMIT}.tar.gz -> ${P}.tar.gz"
  14. LICENSE="MIT"
  15. # this should probably be pkgmoved to 2.0 for sake of consistency.
  16. SLOT="2/${PV}"
  17. KEYWORDS="~amd64 ~arm ~arm64 -hppa ~mips ~ppc -riscv -sparc ~x86 ~amd64-linux ~x86-linux"
  18. IUSE="lua52compat static-libs"
  19. #BDEPEND="${LUA_DEPS}"
  20. RESTRICT="mirror"
  21. S="${WORKDIR}/LuaJIT-${GIT_COMMIT}"
  22. get-abi-cflags() {
  23. # Convert the ABI name we use in Gentoo to what gcc uses
  24. local map=()
  25. case ${CBUILD} in
  26. mips*)
  27. map=("o32 32" "n32 n32" "n64 64")
  28. ;;
  29. riscv*)
  30. map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32")
  31. ;;
  32. x86_64*)
  33. map=("amd64 m64" "x86 m32" "x32 mx32")
  34. ;;
  35. esac
  36. local m
  37. for m in "${map[@]}" ; do
  38. l=( ${m} )
  39. [[ $1 == ${l[0]} ]] && echo -${l[1]} && break
  40. done
  41. }
  42. src_configure() {
  43. tc-export_build_env
  44. # You need to use a 32-bit toolchain to build for a 32-bit architecture.
  45. # Some 64-bit toolchains (like amd64 and ppc64) usually have multilib
  46. # enabled, allowing you to build in 32-bit with -m32. This won't work in all
  47. # cases, but it will otherwise just break, so it's worth trying anyway. If
  48. # you're trying to build for 64-bit from 32-bit, then you're screwed, sorry.
  49. # See https://github.com/LuaJIT/LuaJIT/issues/664 for the upstream issue.
  50. if tc-is-cross-compiler; then
  51. BUILD_CFLAGS+="$(get-abi-cflags ${ABI})"
  52. BUILD_LDFLAGS+="$(get-abi-cflags ${ABI})"
  53. fi
  54. }
  55. _emake() {
  56. emake \
  57. Q= \
  58. PREFIX="${EPREFIX}/usr" \
  59. MULTILIB="$(get_libdir)" \
  60. DESTDIR="${D}" \
  61. CFLAGS="" \
  62. LDFLAGS="" \
  63. HOST_CC="$(tc-getBUILD_CC)" \
  64. HOST_CFLAGS="${BUILD_CPPFLAGS} ${BUILD_CFLAGS}" \
  65. HOST_LDFLAGS="${BUILD_LDFLAGS}" \
  66. STATIC_CC="$(tc-getCC)" \
  67. DYNAMIC_CC="$(tc-getCC) -fPIC" \
  68. TARGET_LD="$(tc-getCC)" \
  69. TARGET_CFLAGS="${CPPFLAGS} ${CFLAGS}" \
  70. TARGET_LDFLAGS="${LDFLAGS}" \
  71. TARGET_AR="$(tc-getAR) rcus" \
  72. BUILDMODE="$(usex static-libs mixed dynamic)" \
  73. TARGET_STRIP="true" \
  74. INSTALL_LIB="${ED}/usr/$(get_libdir)" \
  75. "$@"
  76. }
  77. src_compile() {
  78. _emake \
  79. $(tc-is-cross-compiler && echo CROSS="${CHOST}-" ) \
  80. $(tc-is-cross-compiler && echo HOST_LUA="${LUA}" ) \
  81. $(usex lua52compat "XCFLAGS=-DLUAJIT_ENABLE_LUA52COMPAT" '')
  82. }
  83. src_install() {
  84. _emake install
  85. dosym luajit-2.1.1710088188 /usr/bin/luajit
  86. pax-mark m "${ED}/usr/bin/luajit-${MY_PV}"
  87. HTML_DOCS="doc/." einstalldocs
  88. }