dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / dev-lang / lua / lua-5.1.5-r100.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit eutils multilib multilib-minimal portability toolchain-funcs versionator
7
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"
11
12 LICENSE="MIT"
13 SLOT="5.1"
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"
16
17 RDEPEND="readline? ( >=sys-libs/readline-6.2_p5-r1:0=[${MULTILIB_USEDEP}] )
18         app-eselect/eselect-lua
19         !dev-lang/lua:0"
20 DEPEND="${RDEPEND}
21         sys-devel/libtool"
22 PDEPEND="emacs? ( app-emacs/lua-mode )"
23
24 SAN_SLOT="${SLOT//.}"
25
26 MULTILIB_WRAPPED_HEADERS=(
27         /usr/include/lua${SLOT}/luaconf.h
28 )
29
30 src_prepare() {
31         local PATCH_PV=$(get_version_component_range 1-2)
32
33         epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make-r2.patch
34         epatch "${FILESDIR}"/${PN}-${PATCH_PV}-module_paths.patch
35
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
40         fi
41
42         #EPATCH_SOURCE="${FILESDIR}/${PV}" EPATCH_SUFFIX="upstream.patch" epatch
43
44         # correct lua versioning
45         sed -i -e 's/\(LIB_VERSION = \)6:1:1/\16:5:1/' src/Makefile
46
47         sed -i -e 's:\(/README\)\("\):\1.gz\2:g' doc/readme.html
48
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
53         fi
54
55         if ! use readline ; then
56                 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-readline.patch
57         fi
58
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
64         # are installed)
65         if use static ; then
66                 epatch "${FILESDIR}"/${PN}-${PATCH_PV}-make_static-r1.patch
67         fi
68
69         # custom Makefiles
70         multilib_copy_sources
71 }
72
73 multilib_src_configure() {
74         # We want packages to find our things...
75         sed -i \
76                 -e 's:/usr/local:'${EPREFIX}'/usr:' \
77                 -e "s:\([/\"]\)\<lib\>:\1$(get_libdir):g" \
78                 etc/lua.pc src/luaconf.h || die
79 }
80
81 multilib_src_compile() {
82         tc-export CC
83         myflags=
84         # what to link to liblua
85         liblibs="-lm"
86         liblibs="${liblibs} $(dlopen_lib)"
87
88         # what to link to the executables
89         mylibs=
90         if use readline; then
91                 mylibs="-lreadline"
92         fi
93
94         cd src
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) \
100                         gentoo_all
101
102         mv lua_test ../test/lua.static
103 }
104
105 multilib_src_install() {
106         emake INSTALL_TOP="${ED}/usr" INSTALL_LIB="${ED}/usr/$(get_libdir)" \
107                         V=${SLOT} gentoo_install
108
109         insinto /usr/$(get_libdir)/pkgconfig
110         newins etc/lua.pc lua${SLOT}.pc
111 }
112
113 multilib_src_install_all() {
114         dodoc HISTORY README
115         dohtml doc/*.html doc/*.png doc/*.css doc/*.gif
116
117         doicon etc/lua.ico
118
119         newman doc/lua.1 lua${SLOT}.1
120         newman doc/luac.1 luac${SLOT}.1
121 }
122
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"
127         local test
128
129         cd "${BUILD_DIR}" || die
130         for test in ${positive}; do
131                 test/lua.static test/${test}.lua || die "test $test failed"
132         done
133
134         for test in ${negative}; do
135                 test/lua.static test/${test}.lua && die "test $test failed"
136         done
137 }