1 # Copyright 1999-2013 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 )"
21 PDEPEND="emacs? ( app-emacs/lua-mode )"
24 local PATCH_PV=$(get_version_component_range 1-2)
26 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r1.patch
27 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-module_paths.patch
29 #EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
31 # correct lua versioning
32 sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:5:1/' src/Makefile
34 sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
36 if ! use deprecated ; then
37 # patches from 5.1.4 still apply
38 epatch "${FILESDIR}"/${PN}-5.1.4-deprecated.patch
39 epatch "${FILESDIR}"/${PN}-5.1.4-test.patch
42 if ! use readline ; then
43 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
46 # Using dynamic linked lua is not recommended for performance
47 # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
48 # Mainly, this is of concern if your arch is poor with GPRs, like x86
49 # Note that this only affects the interpreter binary (named lua), not the lua
50 # compiler (built statically) nor the lua libraries (both shared and static
53 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
56 # We want packages to find our things...
58 -e 's:/usr/local:'${EPREFIX}'/usr:' \
59 -e "s:/\<lib\>:/$(get_libdir):g" \
60 etc/lua.pc src/luaconf.h || die
63 # no need for a configure phase
64 src_configure() { true; }
69 # what to link to liblua
71 liblibs="${liblibs} $(dlopen_lib)"
73 # what to link to the executables
80 emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
81 RPATH="${EPREFIX}/usr/$(get_libdir)/" \
82 LUA_LIBS="${mylibs}" \
83 LIB_LIBS="${liblibs}" \
85 gentoo_all || die "emake failed"
87 mv lua_test ../test/lua.static
91 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
92 V=${PV} gentoo_install \
93 || die "emake install gentoo_install failed"
96 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
99 insinto /usr/$(get_libdir)/pkgconfig
102 doman doc/lua.1 doc/luac.1
106 local positive="bisect cf echo env factorial fib fibfor hello printf sieve
107 sort trace-calls trace-globals"
108 local negative="readonly"
112 for test in ${positive}; do
113 test/lua.static test/${test}.lua || die "test $test failed"
116 for test in ${negative}; do
117 test/lua.static test/${test}.lua && die "test $test failed"