1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils autotools multilib portability toolchain-funcs versionator
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"
14 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x86-linux"
15 IUSE="+deprecated emacs readline static"
17 RDEPEND="readline? ( sys-libs/readline:0= )
18 app-eselect/eselect-lua
22 PDEPEND="emacs? ( app-emacs/lua-mode )"
25 local PATCH_PV=$(get_version_component_range 1-2)
27 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r1.patch
29 [ -d "${FILESDIR}/${PV}" ] && \
30 EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
33 -e 's:\(define LUA_ROOT\s*\).*:\1"'${EPREFIX}'/usr/":' \
34 -e "s:\(define LUA_CDIR\s*LUA_ROOT \"\)lib:\1$(get_libdir):" \
36 || die "failed patching luaconf.h"
38 # correct lua versioning
39 sed -i -e 's/\(LIB_VERSION = \)6:1:1/\10:0:0/' src/Makefile
41 sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
43 if ! use readline ; then
44 sed -i -e '/#define LUA_USE_READLINE/d' src/luaconf.h
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
54 sed -i -e 's:\(-export-dynamic\):-static \1:' src/Makefile
57 # upstream does not use libtool, but we do (see bug #336167)
58 cp "${FILESDIR}/configure.in" "${S}"
65 # what to link to liblua
67 liblibs="${liblibs} $(dlopen_lib)"
69 # what to link to the executables
71 use readline && mylibs="-lreadline"
76 use deprecated && myCFLAGS="-DLUA_COMPAT_ALL"
80 *) myCFLAGS+=" -DLUA_USE_LINUX" ;;
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) \
93 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
94 V=${SLOT} gentoo_install
97 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
99 newman doc/lua.1 lua${SLOT}.1
100 newman doc/luac.1 luac${SLOT}.1
102 # We want packages to find our things...
103 cp "${FILESDIR}/lua.pc" "${WORKDIR}"
105 -e "s:^V=.*:V= ${PATCH_PV}:" \
106 -e "s:^R=.*:R= ${PV}:" \
107 -e "s:/,lib,:/$(get_libdir):g" \
110 insinto "/usr/$(get_libdir)/pkgconfig"
111 newins "${WORKDIR}/lua.pc" "lua${SLOT}.pc"
114 # Makefile contains a dummy target that doesn't do tests
115 # but causes issues with slotted lua (bug #510360)