fix up some repoman arch stuff
[lua-alt-overlay.git] / dev-lang / lua / lua-5.3.5.ebuild
blob912370f860cfff174f471d8f829e14008825349e
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=7
6 inherit eutils autotools multilib multilib-minimal portability toolchain-funcs
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"
12 LICENSE="MIT"
13 SLOT="5.3"
14 KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
15 IUSE="+deprecated emacs +static"
17 RDEPEND="
18         >=sys-libs/readline-6.3:0[${MULTILIB_USEDEP}]
19         app-eselect/eselect-lua
20         !dev-lang/lua:0
22 DEPEND="${RDEPEND}
23         sys-devel/libtool"
24 PDEPEND="emacs? ( app-emacs/lua-mode )"
26 MULTILIB_WRAPPED_HEADERS=(
27         "/usr/include/lua${SLOT}/luaconf.h"
30 src_prepare() {
31         eapply "${FILESDIR}/lua-5.3.4_make.patch"
33         # use glibtool on Darwin (versus Apple libtool)
34         if [[ ${CHOST} == *-darwin* ]] ; then
35                 sed -i -e '/LIBTOOL = /s:/libtool:/glibtool:' \
36                         Makefile src/Makefile || die
37         fi
39         sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html || die
41         sed -i -e 's/\(LIB_VERSION = \)6:1:1/\10:0:0/' src/Makefile || die
43         # Using dynamic linked lua is not recommended for performance
44         # reasons. http://article.gmane.org/gmane.comp.lang.lua.general/18519
45         # Mainly, this is of concern if your arch is poor with GPRs, like x86
46         # Note that this only affects the interpreter binary (named lua), not the lua
47         # compiler (built statically) nor the lua libraries (both shared and static
48         # are installed)
49         if use static ; then
50                 sed -i -e 's:\(-export-dynamic\):-static \1:' src/Makefile || die
51         fi
53         eapply_user
55         # upstream does not use libtool, but we do (see bug #336167)
56         cp "${FILESDIR}/configure.ac" "${S}"/ || die
57         eautoreconf
59         # custom Makefiles
60         multilib_copy_sources
62         cp "${FILESDIR}/lua.pc" "${S}"
63         # A slotted Lua uses different directories for headers & names for
64         # libraries, and pkgconfig should reflect that.
65         sed -r -i \
66                 -e "s:^V=.*:V= ${SLOT}:" \
67                 -e "s:^R=.*:R= ${PV}:" \
68                 -e "s:/,lib,:/$(get_libdir):g" \
69                 -e "/^Libs:/s,((-llua)($| )),\2${SLOT}\3," \
70                 "${S}"/lua.pc
73 multilib_src_configure() {
74         sed -i \
75                 -e 's:\(define LUA_ROOT\s*\).*:\1"'${EPREFIX}'/usr/":' \
76                 -e "s:\(define LUA_CDIR\s*LUA_ROOT \"\)lib:\1$(get_libdir):" \
77                 src/luaconf.h \
78         || die "failed patching luaconf.h"
80         econf
83 multilib_src_compile() {
84         tc-export CC
86         # what to link to liblua
87         liblibs="-lm"
88         liblibs="${liblibs} $(dlopen_lib)"
90         # what to link to the executables
91         mylibs="-lreadline"
93         cd src
95         local myCFLAGS;
96         use deprecated && myCFLAGS="-DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1 -DLUA_COMPAT_ALL"
97 # -DLUA_COMPAT_FLOATSTRING"
99         case "${CHOST}" in
100                 *-mingw*) : ;;
101                 *) myCFLAGS+=" -DLUA_USE_LINUX" ;;
102         esac
104         emake CC="${CC}" CFLAGS="${myCFLAGS} ${CFLAGS}" \
105                         SYSLDFLAGS="${LDFLAGS}" \
106                         RPATH="${EPREFIX}/usr/$(get_libdir)/" \
107                         LUA_LIBS="${mylibs}" \
108                         LIB_LIBS="${liblibs}" \
109                         V=${SLOT} \
110                         gentoo_all
113 multilib_src_install() {
114         emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
115                         V=${SLOT} gentoo_install
117         insinto "/usr/$(get_libdir)/pkgconfig"
118         newins "${S}/lua.pc" "lua${SLOT}.pc"
121 multilib_src_install_all() {
122         DOCS=(README)
123         HTML_DOCS=(doc/*.html doc/*.png doc/*.css doc/*.gif)
124         einstalldocs
126         newman doc/lua.1 lua${SLOT}.1
127         newman doc/luac.1 luac${SLOT}.1
130 # Makefile contains a dummy target that doesn't do tests
131 # but causes issues with slotted lua (bug #510360)
132 src_test() { :; }