luajit-2.1.1731601260.ebuild 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. inherit pax-utils toolchain-funcs
  5. # Split release channel (such as "2.1") from relver (such as "1727870382")
  6. VER_CHANNEL=${PV%.*}
  7. VER_RELVER=${PV##*.}
  8. DESCRIPTION="Just-In-Time Compiler for the Lua programming language"
  9. HOMEPAGE="https://luajit.org/"
  10. if [[ ${VER_RELVER} == 9999999999 ]]; then
  11. # Upstream recommends pulling rolling releases from versioned branches.
  12. # > The old git master branch is phased out and stays pinned to the v2.0
  13. # > branch. Please follow the versioned branches instead.
  14. #
  15. # See http://luajit.org/status.html for additional information.
  16. EGIT_BRANCH="v${VER_CHANNEL}"
  17. EGIT_REPO_URI="https://luajit.org/git/luajit.git"
  18. inherit git-r3
  19. else
  20. # Update this commit hash to bump a pinned-commit ebuild.
  21. GIT_COMMIT=fe71d0fb54ceadfb5b5f3b6baf29e486d97f6059
  22. SRC_URI="https://github.com/LuaJIT/LuaJIT/archive/${GIT_COMMIT}.tar.gz -> ${P}.tar.gz"
  23. S="${WORKDIR}/LuaJIT-${GIT_COMMIT}"
  24. KEYWORDS="~amd64 ~arm ~arm64 -hppa ~mips ~ppc -riscv -sparc ~x86 ~amd64-linux ~x86-linux"
  25. fi
  26. LICENSE="MIT"
  27. # this should probably be pkgmoved to 2.1 for sake of consistency.
  28. SLOT="2/${PV}"
  29. IUSE="lua52compat static-libs"
  30. get-abi-cflags() {
  31. # Convert the ABI name we use in Gentoo to what gcc uses
  32. local map=()
  33. case ${CBUILD} in
  34. mips*)
  35. map=("o32 32" "n32 n32" "n64 64")
  36. ;;
  37. riscv*)
  38. map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32")
  39. ;;
  40. x86_64*)
  41. map=("amd64 m64" "x86 m32" "x32 mx32")
  42. ;;
  43. esac
  44. local m
  45. for m in "${map[@]}" ; do
  46. l=( ${m} )
  47. [[ $1 == ${l[0]} ]] && echo -${l[1]} && break
  48. done
  49. }
  50. src_configure() {
  51. tc-export_build_env
  52. # You need to use a 32-bit toolchain to build for a 32-bit architecture.
  53. # Some 64-bit toolchains (like amd64 and ppc64) usually have multilib
  54. # enabled, allowing you to build in 32-bit with -m32. This won't work in all
  55. # cases, but it will otherwise just break, so it's worth trying anyway. If
  56. # you're trying to build for 64-bit from 32-bit, then you're screwed, sorry.
  57. # See https://github.com/LuaJIT/LuaJIT/issues/664 for the upstream issue.
  58. if tc-is-cross-compiler; then
  59. BUILD_CFLAGS+="$(get-abi-cflags ${ABI})"
  60. BUILD_LDFLAGS+="$(get-abi-cflags ${ABI})"
  61. fi
  62. }
  63. _emake() {
  64. emake \
  65. Q= \
  66. PREFIX="${EPREFIX}/usr" \
  67. MULTILIB="$(get_libdir)" \
  68. DESTDIR="${D}" \
  69. CFLAGS="" \
  70. LDFLAGS="" \
  71. HOST_CC="$(tc-getBUILD_CC)" \
  72. HOST_CFLAGS="${BUILD_CPPFLAGS} ${BUILD_CFLAGS}" \
  73. HOST_LDFLAGS="${BUILD_LDFLAGS}" \
  74. STATIC_CC="$(tc-getCC)" \
  75. DYNAMIC_CC="$(tc-getCC) -fPIC" \
  76. TARGET_LD="$(tc-getCC)" \
  77. TARGET_CFLAGS="${CPPFLAGS} ${CFLAGS}" \
  78. TARGET_LDFLAGS="${LDFLAGS}" \
  79. TARGET_SHLDFLAGS="${LDFLAGS}" \
  80. TARGET_AR="$(tc-getAR) rcus" \
  81. BUILDMODE="$(usex static-libs mixed dynamic)" \
  82. TARGET_STRIP="true" \
  83. INSTALL_LIB="${ED}/usr/$(get_libdir)" \
  84. "$@"
  85. }
  86. src_compile() {
  87. # _emake \
  88. # $(tc-is-cross-compiler && echo CROSS="${CHOST}-" ) \
  89. # $(tc-is-cross-compiler && echo HOST_LUA="${LUA}" ) \
  90. # $(usex lua52compat "XCFLAGS=-DLUAJIT_ENABLE_LUA52COMPAT" '')
  91. tc-export_build_env
  92. _emake XCFLAGS="$(usex lua52compat "-DLUAJIT_ENABLE_LUA52COMPAT" "")"
  93. }
  94. src_install() {
  95. _emake install
  96. local relver="$(cat "${S}/src/luajit_relver.txt" || die 'error retrieving relver')"
  97. dosym luajit-"${VER_CHANNEL}.${relver}" /usr/bin/luajit
  98. pax-mark m "${ED}/usr/bin/luajit-${MY_PV}"
  99. HTML_DOCS="doc/." einstalldocs
  100. }