dev-python/urllib3: Removed old.
[gentoo.git] / dev-lang / lua / lua-5.1.4-r8.ebuild
1 # Copyright 1999-2012 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 ~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"
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         # 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
33         fi
34
35         EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
36
37         # correct lua versioning
38         sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:4:1/' src/Makefile
39
40         sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
41
42         if ! use deprecated ; then
43                 epatch "${FILESDIR}"/${P}-deprecated.patch
44                 epatch "${FILESDIR}"/${P}-test.patch
45         fi
46
47         if ! use readline ; then
48                 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
49         fi
50
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
56         # are installed)
57         if use static ; then
58                 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
59         fi
60
61         # We want packages to find our things...
62         sed -i \
63                 -e "s:/usr/local:${EPREFIX}/usr:" \
64                 -e "s:/\<lib\>:/$(get_libdir):g" \
65                 etc/lua.pc src/luaconf.h
66 }
67
68 # no need for a configure phase
69 src_configure() { true; }
70
71 src_compile() {
72         tc-export CC
73         myflags=
74         # what to link to liblua
75         liblibs="-lm"
76         liblibs="${liblibs} $(dlopen_lib)"
77
78         # what to link to the executables
79         mylibs=
80         if use readline; then
81                 mylibs="-lreadline"
82         fi
83
84         cd src
85         emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
86                         RPATH="${EPREFIX}/usr/$(get_libdir)/" \
87                         LUA_LIBS="${mylibs}" \
88                         LIB_LIBS="${liblibs}" \
89                         V=${PV} \
90                         gentoo_all || die "emake failed"
91
92         mv lua_test ../test/lua.static
93 }
94
95 src_install() {
96         emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
97                         V=${PV} gentoo_install \
98         || die "emake install gentoo_install failed"
99
100         dodoc HISTORY README
101         dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
102
103         doicon etc/lua.ico
104         insinto /usr/$(get_libdir)/pkgconfig
105         doins etc/lua.pc
106
107         doman doc/lua.1 doc/luac.1
108 }
109
110 src_test() {
111         local positive="bisect cf echo env factorial fib fibfor hello printf sieve
112         sort trace-calls trace-globals"
113         local negative="readonly"
114         local test
115
116         cd "${S}"
117         for test in ${positive}; do
118                 test/lua.static test/${test}.lua || die "test $test failed"
119         done
120
121         for test in ${negative}; do
122                 test/lua.static test/${test}.lua && die "test $test failed"
123         done
124 }