dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / dev-lang / lua / lua-5.2.3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit eutils autotools multilib portability toolchain-funcs versionator
7
8 DESCRIPTION="A powerful light-weight programming language designed for extending applications"
9 HOMEPAGE="http://www.lua.org/"
10 SRC_URI="http://www.lua.org/ftp/${P}.tar.gz"
11
12 LICENSE="MIT"
13 SLOT="5.2"
14 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x86-linux"
15 IUSE="+deprecated emacs readline static"
16
17 RDEPEND="readline? ( sys-libs/readline:0= )
18         app-eselect/eselect-lua
19         !dev-lang/lua:0"
20 DEPEND="${RDEPEND}
21         sys-devel/libtool"
22 PDEPEND="emacs? ( app-emacs/lua-mode )"
23
24 src_prepare() {
25         local PATCH_PV=$(get_version_component_range 1-2)
26
27         epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r1.patch
28
29         [ -d "${FILESDIR}/${PV}" ] && \
30                 EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
31
32         sed -i \
33                 -e 's:\(define LUA_ROOT\s*\).*:\1"'${EPREFIX}'/usr/":' \
34                 -e "s:\(define LUA_CDIR\s*LUA_ROOT \"\)lib:\1$(get_libdir):" \
35                 src/luaconf.h \
36         || die "failed patching luaconf.h"
37
38         # correct lua versioning
39         sed -i -e 's/\(LIB_VERSION = \)6:1:1/\10:0:0/' src/Makefile
40
41         sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
42
43         if ! use readline ; then
44                 sed -i -e '/#define LUA_USE_READLINE/d' src/luaconf.h
45         fi
46
47         # Using dynamic linked lua is not recommended for performance
48         # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
49         # Mainly, this is of concern if your arch is poor with GPRs, like x86
50         # Note that this only affects the interpreter binary (named lua), not the lua
51         # compiler (built statically) nor the lua libraries (both shared and static
52         # are installed)
53         if use static ; then
54                 sed -i -e 's:\(-export-dynamic\):-static \1:' src/Makefile
55         fi
56
57         # upstream does not use libtool, but we do (see bug #336167)
58         cp "${FILESDIR}/configure.in" "${S}"
59         eautoreconf
60 }
61
62 src_compile() {
63         tc-export CC
64
65         # what to link to liblua
66         liblibs="-lm"
67         liblibs="${liblibs} $(dlopen_lib)"
68
69         # what to link to the executables
70         mylibs=
71         use readline && mylibs="-lreadline"
72
73         cd src
74
75         local myCFLAGS=""
76         use deprecated && myCFLAGS="-DLUA_COMPAT_ALL"
77
78         case "${CHOST}" in
79                 *-mingw*) : ;;
80                 *) myCFLAGS+=" -DLUA_USE_LINUX" ;;
81         esac
82
83         emake CC="${CC}" CFLAGS="${myCFLAGS} ${CFLAGS}" \
84                         SYSLDFLAGS="${LDFLAGS}" \
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
90 }
91
92 src_install() {
93         emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
94                         V=${SLOT} gentoo_install
95
96         dodoc README
97         dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
98
99         newman doc/lua.1 lua${SLOT}.1
100         newman doc/luac.1 luac${SLOT}.1
101
102         # We want packages to find our things...
103         cp "${FILESDIR}/lua.pc" "${WORKDIR}"
104         sed -i \
105                 -e "s:^V=.*:V= ${PATCH_PV}:" \
106                 -e "s:^R=.*:R= ${PV}:" \
107                 -e "s:/,lib,:/$(get_libdir):g" \
108                 "${WORKDIR}/lua.pc"
109
110         insinto "/usr/$(get_libdir)/pkgconfig"
111         newins "${WORKDIR}/lua.pc" "lua${SLOT}.pc"
112 }
113
114 # Makefile contains a dummy target that doesn't do tests
115 # but causes issues with slotted lua (bug #510360)
116 src_test() { :; }