summaryrefslogtreecommitdiff
blob: 21cfa89c4641e4a5b84cce1a3a0e016f1eff3929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: This ebuild is from Lua overlay; Bumped by mva; $

EAPI="5"

inherit base eutils multilib multilib-minimal portability pax-utils toolchain-funcs versionator flag-o-matic check-reqs git-r3

DESCRIPTION="Just-In-Time Compiler for the Lua programming language"
HOMEPAGE="http://luajit.org/"
SRC_URI=""
EGIT_REPO_URI="git://repo.or.cz/luajit-2.0.git"
SLOT="2.1"
EGIT_BRANCH="v${SLOT}"

LICENSE="MIT"
KEYWORDS=""
IUSE="debug valgrind lua52compat +optimization"

RDEPEND="
	valgrind? ( dev-util/valgrind )
"
DEPEND="${RDEPEND}"

PDEPEND="
	virtual/lua[luajit]
	app-eselect/eselect-luajit
"

HTML_DOCS=( "doc/" )

MULTILIB_WRAPPED_HEADERS=(
    /usr/include/luajit-${SLOT}/luaconf.h
)


check_req() {
	if use optimization; then
		CHECKREQS_MEMORY="300M"
		check-reqs_pkg_${1}
	fi
}

pkg_pretend() {
	check_req pretend
}

pkg_setup() {
	check_req setup
}

src_prepare(){
	# fixing prefix and version
	sed -r \
		-e 's|^(VERSION)=.*|\1=$(MAJVER).$(MINVER)|' \
		-e 's|^(FILE_MAN)=.*|\1=${PN}-$(VERSION).1|' \
		-e 's|\$\(MAJVER\)\.\$\(MINVER\)\.\$\(RELVER\)|$(VERSION)|' \
		-e 's|^(INSTALL_PCNAME)=.*|\1=${PN}-$(VERSION).pc|' \
		-e 's|^(INSTALL_SOSHORT)=.*|\1=lib${PN}-${SLOT}.so|' \
		-e 's|^(INSTALL_ANAME)=.*|\1=lib${PN}-${SLOT}.a|' \
		-e 's|^(INSTALL_SONAME)=.*|\1=lib${PN}-${SLOT}.so.${PV}|' \
		-e 's|( PREFIX)=.*|\1=/usr|' \
		-e '/\$\(SYMLINK\)\ \$\(INSTALL_TNAME\)\ \$\(INSTALL_TSYM\)/d' \
		-i Makefile || die "failed to fix prefix in Makefile"

	sed -r \
		-e 's|^(libname=.*-)\$\{abiver\}|\1${majver}.${minver}|' \
		-i "etc/${PN}.pc" || die "Failed to slottify"

	sed -r \
		-e 's|^(TARGET_SONAME)=.*|\1=lib${PN}-${SLOT}.so.${PV}|' \
		-i src/Makefile || die "Failed to slottify"

	sed -r \
		-e 's|^(#define LUA_LJDIR).*|\1 "/'${PN}-${SLOT}'/"|' \
		-i src/luaconf.h || die "Failed to slotify"

	use debug && (
		sed -r \
			-e 's/#(CCDEBUG= -g)/\1 -ggdb/' \
			-i src/Makefile || die "Failed to enable debug"
	)
	mv "${S}"/etc/${PN}.1 "${S}"/etc/${PN}-${SLOT}.1

	multilib_copy_sources
}

multilib_src_configure() {
	sed -r \
		-e "s|^(prefix)=.*|\1=/usr|" \
		-e "s|^(multilib)=.*|\1=$(get_libdir)|" \
		-i "etc/${PN}.pc" || die "Failed to slottify"
}

multilib_src_compile() {
	local opt xcflags;
	use optimization && opt="amalg";

	tc-export CC

	xcflags=(
		$(usex lua52compat "-DLUAJIT_ENABLE_LUA52COMPAT" "")
		$(usex debug "-DLUAJIT_USE_GDBJIT" "")
		$(usex valgrind "-DLUAJIT_USE_VALGRIND" "")
		$(usex valgrind "-DLUAJIT_USE_SYSMALLOC" "")
	)

	emake \
		Q= \
		HOST_CC="$(tc-getCC)" \
		CC="${CC}" \
		TARGET_STRIP="true" \
		XCFLAGS="${xcflags[*]}" "${opt}"
}

multilib_src_install() {
	emake DESTDIR="${D}" MULTILIB="$(get_libdir)" install

	base_src_install_docs

	host-is-pax && pax-mark m "${ED}usr/bin/${PN}-${SLOT}"
	newman "etc/${PN}-${SLOT}.1" "luacjit-${SLOT}.1"
	newbin "${FILESDIR}/luac.jit" "luacjit-${SLOT}"
	[[ ! -e "/usr/bin/luajit" ]] && dosym "${PN}-${SLOT}" "${ED}usr/bin/${PN}"
}