dev-python/urllib3: Removed old.
[gentoo.git] / dev-lang / lua / lua-5.1.5.ebuild
1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 inherit eutils multilib portability toolchain-funcs versionator
8
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"
12
13 LICENSE="MIT"
14 SLOT="0"
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"
17
18 RDEPEND="readline? ( sys-libs/readline )"
19 DEPEND="${RDEPEND}
20         sys-devel/libtool"
21 PDEPEND="emacs? ( app-emacs/lua-mode )"
22
23 src_prepare() {
24         local PATCH_PV=$(get_version_component_range 1-2)
25
26         epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r1.patch
27         epatch "${FILESDIR}"/${PN}-${PATCH_PV}-module_paths.patch
28
29         #EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
30
31         # correct lua versioning
32         sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:5:1/' src/Makefile
33
34         sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
35
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
40         fi
41
42         if ! use readline ; then
43                 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
44         fi
45
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
51         # are installed)
52         if use static ; then
53                 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
54         fi
55
56         # We want packages to find our things...
57         sed -i \
58                 -e 's:/usr/local:'${EPREFIX}'/usr:' \
59                 -e "s:/\<lib\>:/$(get_libdir):g" \
60                 etc/lua.pc src/luaconf.h || die
61 }
62
63 # no need for a configure phase
64 src_configure() { true; }
65
66 src_compile() {
67         tc-export CC
68         myflags=
69         # what to link to liblua
70         liblibs="-lm"
71         liblibs="${liblibs} $(dlopen_lib)"
72
73         # what to link to the executables
74         mylibs=
75         if use readline; then
76                 mylibs="-lreadline"
77         fi
78
79         cd src
80         emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
81                         RPATH="${EPREFIX}/usr/$(get_libdir)/" \
82                         LUA_LIBS="${mylibs}" \
83                         LIB_LIBS="${liblibs}" \
84                         V=${PV} \
85                         gentoo_all || die "emake failed"
86
87         mv lua_test ../test/lua.static
88 }
89
90 src_install() {
91         emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
92                         V=${PV} gentoo_install \
93         || die "emake install gentoo_install failed"
94
95         dodoc HISTORY README
96         dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
97
98         doicon etc/lua.ico
99         insinto /usr/$(get_libdir)/pkgconfig
100         doins etc/lua.pc
101
102         doman doc/lua.1 doc/luac.1
103 }
104
105 src_test() {
106         local positive="bisect cf echo env factorial fib fibfor hello printf sieve
107         sort trace-calls trace-globals"
108         local negative="readonly"
109         local test
110
111         cd "${S}"
112         for test in ${positive}; do
113                 test/lua.static test/${test}.lua || die "test $test failed"
114         done
115
116         for test in ${negative}; do
117                 test/lua.static test/${test}.lua && die "test $test failed"
118         done
119 }