1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils multilib multilib-minimal 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 ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
15 IUSE="+deprecated emacs readline static"
17 RDEPEND="readline? ( >=sys-libs/readline-6.2_p5-r1:0=[${MULTILIB_USEDEP}] )
18 app-eselect/eselect-lua
22 PDEPEND="emacs? ( app-emacs/lua-mode )"
26 MULTILIB_WRAPPED_HEADERS=(
27 /usr/include/lua${SLOT}/luaconf.h
31 local PATCH_PV=$(get_version_component_range 1-2)
33 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r2.patch
34 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-module_paths.patch
36 # use glibtool on Darwin (versus Apple libtool)
37 if [[ ${CHOST} == *-darwin* ]] ; then
38 sed -i -e '/LIBTOOL = /s:libtool:glibtool:' \
39 Makefile src/Makefile || die
42 #EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
44 # correct lua versioning
45 sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:5:1/' src/Makefile
47 sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
49 if ! use deprecated ; then
50 # patches from 5.1.4 still apply
51 epatch "${FILESDIR}"/${PN}-5.1.4-deprecated.patch
52 epatch "${FILESDIR}"/${PN}-5.1.4-test.patch
55 if ! use readline ; then
56 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
59 # Using dynamic linked lua is not recommended for performance
60 # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
61 # Mainly, this is of concern if your arch is poor with GPRs, like x86
62 # Note that this only affects the interpreter binary (named lua), not the lua
63 # compiler (built statically) nor the lua libraries (both shared and static
66 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
73 multilib_src_configure() {
74 # We want packages to find our things...
76 -e 's:/usr/local:'${EPREFIX}'/usr:' \
77 -e "s:\([/\"]\)\<lib\>:\1$(get_libdir):g" \
78 etc/lua.pc src/luaconf.h || die
81 multilib_src_compile() {
84 # what to link to liblua
86 liblibs="${liblibs} $(dlopen_lib)"
88 # what to link to the executables
95 emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
96 RPATH="${EPREFIX}/usr/$(get_libdir)/" \
97 LUA_LIBS="${mylibs}" \
98 LIB_LIBS="${liblibs}" \
99 V=$(get_version_component_range 1-2) \
102 mv lua_test ../test/lua.static
105 multilib_src_install() {
106 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
107 V=${SLOT} gentoo_install
109 insinto /usr/$(get_libdir)/pkgconfig
110 newins etc/lua.pc lua${SLOT}.pc
113 multilib_src_install_all() {
115 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
119 newman doc/lua.1 lua${SLOT}.1
120 newman doc/luac.1 luac${SLOT}.1
123 multilib_src_test() {
124 local positive="bisect cf echo env factorial fib fibfor hello printf sieve
125 sort trace-calls trace-globals"
126 local negative="readonly"
129 cd "${BUILD_DIR}" || die
130 for test in ${positive}; do
131 test/lua.static test/${test}.lua || die "test $test failed"
134 for test in ${negative}; do
135 test/lua.static test/${test}.lua && die "test $test failed"