1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils multilib portability toolchain-funcs versionator
9 DESCRIPTION="A powerful light-weight programming language designed for extending applications"
10 HOMEPAGE="http://www.lua.org/"
11 SRC_URI="http://www.lua.org/ftp/${P}.tar.gz"
15 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~arm-linux ~x86-linux"
16 IUSE="+deprecated emacs readline static"
18 RDEPEND="readline? ( sys-libs/readline )
19 app-eselect/eselect-lua
23 PDEPEND="emacs? ( app-emacs/lua-mode )"
28 local PATCH_PV=$(get_version_component_range 1-2)
30 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r2.patch
31 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-module_paths.patch
33 #EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
35 # correct lua versioning
36 sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:5:1/' src/Makefile
38 sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
40 if ! use deprecated ; then
41 # patches from 5.1.4 still apply
42 epatch "${FILESDIR}"/${PN}-5.1.4-deprecated.patch
43 epatch "${FILESDIR}"/${PN}-5.1.4-test.patch
46 if ! use readline ; then
47 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
50 # Using dynamic linked lua is not recommended for performance
51 # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
52 # Mainly, this is of concern if your arch is poor with GPRs, like x86
53 # Note that this only affects the interpreter binary (named lua), not the lua
54 # compiler (built statically) nor the lua libraries (both shared and static
57 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
60 # We want packages to find our things...
62 -e 's:/usr/local:'${EPREFIX}'/usr:' \
63 -e "s:\([/\"]\)\<lib\>:\1$(get_libdir):g" \
64 etc/lua.pc src/luaconf.h || die
67 # no need for a configure phase
68 src_configure() { true; }
73 # what to link to liblua
75 liblibs="${liblibs} $(dlopen_lib)"
77 # what to link to the executables
84 emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
85 RPATH="${EPREFIX}/usr/$(get_libdir)/" \
86 LUA_LIBS="${mylibs}" \
87 LIB_LIBS="${liblibs}" \
88 V=$(get_version_component_range 1-2) \
89 gentoo_all || die "emake failed"
91 mv lua_test ../test/lua.static
95 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
96 V=${SLOT} gentoo_install \
97 || die "emake install gentoo_install failed"
100 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
103 insinto /usr/$(get_libdir)/pkgconfig
104 newins etc/lua.pc lua${SLOT}.pc
106 newman doc/lua.1 lua${SLOT}.1
107 newman doc/luac.1 luac${SLOT}.1
111 local positive="bisect cf echo env factorial fib fibfor hello printf sieve
112 sort trace-calls trace-globals"
113 local negative="readonly"
117 for test in ${positive}; do
118 test/lua.static test/${test}.lua || die "test $test failed"
121 for test in ${negative}; do
122 test/lua.static test/${test}.lua && die "test $test failed"