1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils autotools 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 TEST_PV="5.3.4" # no 5.3.5-specific release yet
11 TEST_A="${PN}-${TEST_PV}-tests.tar.gz"
14 http://www.lua.org/ftp/${PKG_A}
15 test? ( https://www.lua.org/tests/${TEST_A} )"
19 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
20 IUSE="+deprecated emacs readline static test test-complete"
21 RESTRICT="!test? ( test )"
23 RDEPEND="readline? ( sys-libs/readline:0= )
24 app-eselect/eselect-lua
28 PDEPEND="emacs? ( app-emacs/lua-mode )"
30 MULTILIB_WRAPPED_HEADERS=(
31 /usr/include/lua${SLOT}/luaconf.h
35 local PATCH_PV=$(get_version_component_range 1-2)
37 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r1.patch
39 # use glibtool on Darwin (versus Apple libtool)
40 if [[ ${CHOST} == *-darwin* ]] ; then
41 sed -i -e '/LIBTOOL = /s:/libtool:/glibtool:' \
42 Makefile src/Makefile || die
45 [ -d "${FILESDIR}/${PV}" ] && \
46 EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
48 # correct lua versioning
49 sed -i -e 's/\(LIB_VERSION = \)6:1:1/\10:0:0/' src/Makefile || die
51 sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html || die
53 if ! use readline ; then
54 sed -i -e '/#define LUA_USE_READLINE/d' src/luaconf.h || die
57 # Using dynamic linked lua is not recommended for performance
58 # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
59 # Mainly, this is of concern if your arch is poor with GPRs, like x86
60 # Note that this only affects the interpreter binary (named lua), not the lua
61 # compiler (built statically) nor the lua libraries (both shared and static
64 sed -i -e 's:\(-export-dynamic\):-static \1:' src/Makefile || die
67 # upstream does not use libtool, but we do (see bug #336167)
68 cp "${FILESDIR}/configure.in" "${S}/configure.ac" || die
71 # A slotted Lua uses different directories for headers & names for
72 # libraries, and pkgconfig should reflect that.
74 -e "/^Libs:/s,((-llua)($| )),\2${SLOT}\3," \
75 -e "/^Cflags:/s,((-I..includedir.)($| )),\2/lua${SLOT}\3," \
82 multilib_src_configure() {
84 -e 's:\(define LUA_ROOT\s*\).*:\1"'${EPREFIX}'/usr/":' \
85 -e "s:\(define LUA_CDIR\s*LUA_ROOT \"\)lib:\1$(get_libdir):" \
87 || die "failed patching luaconf.h"
92 multilib_src_compile() {
95 # what to link to liblua
97 liblibs="${liblibs} $(dlopen_lib)"
99 # what to link to the executables
101 use readline && mylibs="-lreadline"
106 use deprecated && myCFLAGS="-DLUA_COMPAT_ALL"
110 *) myCFLAGS+=" -DLUA_USE_LINUX" ;;
113 emake CC="${CC}" CFLAGS="${myCFLAGS} ${CFLAGS}" \
114 SYSLDFLAGS="${LDFLAGS}" \
115 RPATH="${EPREFIX}/usr/$(get_libdir)/" \
116 LUA_LIBS="${mylibs}" \
117 LIB_LIBS="${liblibs}" \
118 V=$(get_version_component_range 1-2) \
122 multilib_src_install() {
123 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
124 V=${SLOT} gentoo_install
126 # We want packages to find our things...
127 cp "${FILESDIR}/lua.pc" "${WORKDIR}"
129 -e "s:^prefix= :prefix= ${EPREFIX}:" \
130 -e "s:^V=.*:V= ${PATCH_PV}:" \
131 -e "s:^R=.*:R= ${PV}:" \
132 -e "s:/,lib,:/$(get_libdir):g" \
135 insinto "/usr/$(get_libdir)/pkgconfig"
136 newins "${WORKDIR}/lua.pc" "lua${SLOT}.pc"
139 multilib_src_install_all() {
141 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
143 newman doc/lua.1 lua${SLOT}.1
144 newman doc/luac.1 luac${SLOT}.1
147 # Makefile contains a dummy target that doesn't do tests
148 # but causes issues with slotted lua (bug #510360)
150 debug-print-function ${FUNCNAME} "$@"
151 cd "${WORKDIR}/lua-${TEST_PV}-tests" || die
152 # https://www.lua.org/tests/
153 # There are two sets:
157 # The basic subset is selected by passing -e'_U=true'
158 # The complete set is noted to contain tests that may consume too much memory or have non-portable tests.
159 # attrib.lua for example needs some multilib customization (have to compile the stuff in libs/ for each ABI)
160 use test-complete || TEST_OPTS="-e_U=true"
161 TEST_MARKER="${T}/test.failed"
162 rm -f "${TEST_MARKER}"
164 # If we are failing, set the marker file, and only check it after done all ABIs
166 debug-print-function ${FUNCNAME} "$@"
167 TEST_LOG="${T}/test.${MULTIBUILD_ID}.log"
168 eval "${BUILD_DIR}"/src/lua${SLOT} ${TEST_OPTS} all.lua 2>&1 | tee "${TEST_LOG}" || die
169 grep -sq -e "final OK" "${TEST_LOG}" || echo "FAIL ${MULTIBUILD_ID}" >>"${TEST_MARKER}"
173 multilib_foreach_abi abi_src_test
175 if [ -e "${TEST_MARKER}" ]; then