1 # Copyright 1999-2012 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 ~x86-fbsd ~ppc-aix ~x64-freebsd ~ia64-hpux ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
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 # use glibtool on Darwin (versus Apple libtool)
30 if [[ ${CHOST} == *-darwin* ]] ; then
31 sed -i -e '/LIBTOOL = /s:libtool:glibtool:' \
32 Makefile src/Makefile || die
35 EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
37 # correct lua versioning
38 sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:4:1/' src/Makefile
40 sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
42 if ! use deprecated ; then
43 epatch "${FILESDIR}"/${P}-deprecated.patch
44 epatch "${FILESDIR}"/${P}-test.patch
47 if ! use readline ; then
48 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
51 # Using dynamic linked lua is not recommended for performance
52 # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
53 # Mainly, this is of concern if your arch is poor with GPRs, like x86
54 # Note that this only affects the interpreter binary (named lua), not the lua
55 # compiler (built statically) nor the lua libraries (both shared and static
58 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
61 # We want packages to find our things...
63 -e "s:/usr/local:${EPREFIX}/usr:" \
64 -e "s:/\<lib\>:/$(get_libdir):g" \
65 etc/lua.pc src/luaconf.h
68 # no need for a configure phase
69 src_configure() { true; }
74 # what to link to liblua
76 liblibs="${liblibs} $(dlopen_lib)"
78 # what to link to the executables
85 emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
86 RPATH="${EPREFIX}/usr/$(get_libdir)/" \
87 LUA_LIBS="${mylibs}" \
88 LIB_LIBS="${liblibs}" \
90 gentoo_all || die "emake failed"
92 mv lua_test ../test/lua.static
96 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
97 V=${PV} gentoo_install \
98 || die "emake install gentoo_install failed"
101 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
104 insinto /usr/$(get_libdir)/pkgconfig
107 doman doc/lua.1 doc/luac.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"