1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils multilib multilib-minimal portability pax-utils toolchain-funcs flag-o-matic check-reqs git-r3
8 DESCRIPTION="Just-In-Time Compiler for the Lua programming language"
9 HOMEPAGE="https://luajit.org/"
10 EGIT_REPO_URI="https://luajit.org/git/luajit-2.0.git"
12 EGIT_MIN_CLONE_TYPE="single"
13 EGIT_COMMIT="v${PV/_/-}"
16 KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
19 IUSE="debug valgrind lua52compat +optimization"
22 valgrind? ( dev-util/valgrind )
26 app-eselect/eselect-luajit
27 app-eselect/eselect-lua
30 # Arm64 and ppc have luajit keyworded upstream, so we can't really
31 # change them. However, virtual/lua has to run everywhere. I can't
32 # quite figure out how to make repoman understand that the luajit
33 # USE flag will never be applied in these cases, so handle it here
36 !ppc64? ( !ppc? ( !arm64? ( virtual/lua[luajit] ) ) )
41 MULTILIB_WRAPPED_HEADERS=(
42 "/usr/include/luajit-${SLOT}/luaconf.h"
46 if use optimization; then
47 CHECKREQS_MEMORY="300M"
61 # fixing prefix and version
63 -e "s|^(VERSION)=.*|\1=${PV}|" \
64 -e 's|^(INSTALL_SONAME)=.*|\1=$(INSTALL_SOSHORT1).$(VERSION)|' \
65 -e "s|^(INSTALL_PCNAME)=.*|\1=${P}.pc|" \
66 -e 's|^(FILE_MAN)=.*|\1=${P}.1|' \
67 -e "s|( PREFIX)=.*|\1=${EROOT}/usr|" \
68 -i Makefile || die "failed to fix prefix in Makefile"
72 -e 's/#(CCDEBUG= -g)/\1 -O0/' \
73 -i src/Makefile || die "Failed to enable debug"
75 mv "${S}"/etc/${PN}.1 "${S}"/etc/${P}.1
82 multilib_src_configure() {
84 -e "s|^(prefix)=.*|\1=${EROOT}/usr|" \
85 -e "s|^(multilib)=.*|\1=$(get_libdir)|" \
86 -i "etc/${PN}.pc" || die "Failed to slottify"
89 multilib_src_compile() {
91 use optimization && opt="amalg";
96 $(usex lua52compat "-DLUAJIT_ENABLE_LUA52COMPAT" "")
97 $(usex debug "-DLUAJIT_USE_GDBJIT" "")
98 $(usex valgrind "-DLUAJIT_USE_VALGRIND" "")
99 $(usex valgrind "-DLUAJIT_USE_SYSMALLOC" "")
100 $(usex amd64 "-DLUAJIT_ENABLE_GC64" "")
101 # $(usex arm64 "-DLUAJIT_ENABLE_GC64" "")
102 # $(usex mips64 "-DLUAJIT_ENABLE_GC64" "")
103 # $(usex ppc64 "-DLUAJIT_ENABLE_GC64" "")
104 # $(usex s390_64 "-DLUAJIT_ENABLE_GC64" "")
109 HOST_CC="$(tc-getCC)" \
111 TARGET_STRIP="true" \
112 XCFLAGS="${xcflags[*]}" ${opt}
115 multilib_src_install() {
116 emake DESTDIR="${D}" MULTILIB="$(get_libdir)" install
120 host-is-pax && pax-mark m "${ED}/usr/bin/${P}"
121 newman "etc/${P}.1" "luacjit-${PV}.1"
122 newbin "${FILESDIR}/luac.jit" "luacjit-${PV}"
123 ln -fs "${P}" "${ED}/usr/bin/${PN}-${SLOT}"
127 if [[ ! -n $(readlink "${EROOT}/usr/bin/luajit") ]] ; then
128 eselect luajit set luajit-${PV}
130 if [[ ! -n $(readlink "${EROOT}/usr/bin/lua") ]] ; then
131 eselect lua set jit-${PV}