placate repoman... again
[lua-alt-overlay.git] / dev-lang / luajit / luajit-2.1.0_beta3.ebuild
blobc168db5fb02421b352d4ac0d829279ecc9b206df
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=7
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"
11 EGIT_BRANCH="v2.1"
12 EGIT_MIN_CLONE_TYPE="single"
13 EGIT_COMMIT="v${PV/_/-}"
15 SLOT="2"
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"
18 LICENSE="MIT"
19 IUSE="debug valgrind lua52compat +optimization"
21 RDEPEND="
22         valgrind? ( dev-util/valgrind )
24 DEPEND="
25         ${RDEPEND}
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
34 # as well.
35 PDEPEND="
36         !ppc64? ( !ppc? ( !arm64? ( virtual/lua[luajit] ) ) )
39 HTML_DOCS=( "doc/." )
41 MULTILIB_WRAPPED_HEADERS=(
42         "/usr/include/luajit-${SLOT}/luaconf.h"
45 check_req() {
46         if use optimization; then
47                 CHECKREQS_MEMORY="300M"
48                 check-reqs_pkg_${1}
49         fi
52 pkg_pretend() {
53         check_req pretend
56 pkg_setup() {
57         check_req setup
60 src_prepare() {
61         # fixing prefix and version
62         sed -r \
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"
70         use debug && (
71                 sed -r \
72                         -e 's/#(CCDEBUG= -g)/\1 -O0/' \
73                         -i src/Makefile || die "Failed to enable debug"
74         )
75         mv "${S}"/etc/${PN}.1 "${S}"/etc/${P}.1
77         eapply_user
79         multilib_copy_sources
82 multilib_src_configure() {
83         sed -r \
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() {
90         local opt xcflags;
91         use optimization && opt="amalg";
93         tc-export CC
95         xcflags=(
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" "")
105         )
107         emake \
108                 Q= \
109                 HOST_CC="$(tc-getCC)" \
110                 CC="${CC}" \
111                 TARGET_STRIP="true" \
112                 XCFLAGS="${xcflags[*]}" ${opt}
115 multilib_src_install() {
116         emake DESTDIR="${D}" MULTILIB="$(get_libdir)" install
118         einstalldocs
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}"
126 pkg_postinst() {
127         if [[ ! -n $(readlink "${EROOT}/usr/bin/luajit") ]] ; then
128                 eselect luajit set luajit-${PV}
129         fi
130         if [[ ! -n $(readlink "${EROOT}/usr/bin/lua") ]] ; then
131                 eselect lua set jit-${PV}
132         fi