1 # Copyright 1999-2019 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 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~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
69 # A slotted Lua uses different directories for headers & names for
70 # libraries, and pkgconfig should reflect that.
72 -e "/^Libs:/s,((-llua)($| )),\2${SLOT}\3," \
73 -e "/^Cflags:/s,((-I..includedir.)($| )),\2/lua${SLOT}\3," \
80 multilib_src_configure() {
81 # We want packages to find our things...
83 -e 's:/usr/local:'${EPREFIX}'/usr:' \
84 -e "s:\([/\"]\)\<lib\>:\1$(get_libdir):g" \
85 etc/lua.pc src/luaconf.h || die
88 multilib_src_compile() {
91 # what to link to liblua
93 liblibs="${liblibs} $(dlopen_lib)"
95 # what to link to the executables
102 emake CC="${CC}" CFLAGS="-DLUA_USE_LINUX ${CFLAGS}" \
103 RPATH="${EPREFIX}/usr/$(get_libdir)/" \
104 LUA_LIBS="${mylibs}" \
105 LIB_LIBS="${liblibs}" \
106 V=$(get_version_component_range 1-2) \
109 mv lua_test ../test/lua.static
112 multilib_src_install() {
113 emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
114 V=${SLOT} gentoo_install
116 insinto /usr/$(get_libdir)/pkgconfig
117 newins etc/lua.pc lua${SLOT}.pc
120 multilib_src_install_all() {
122 dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
126 newman doc/lua.1 lua${SLOT}.1
127 newman doc/luac.1 luac${SLOT}.1
130 multilib_src_test() {
131 local positive="bisect cf echo env factorial fib fibfor hello printf sieve
132 sort trace-calls trace-globals"
133 local negative="readonly"
136 cd "${BUILD_DIR}" || die
137 for test in ${positive}; do
138 test/lua.static test/${test}.lua || die "test $test failed"
141 for test in ${negative}; do
142 test/lua.static test/${test}.lua && die "test $test failed"