febuild/dev-lang/lua/lua-5.5.0.ebuild

117 lines
2.9 KiB
Bash
Executable File

# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit flag-o-matic toolchain-funcs optfeature
DESCRIPTION="A powerful light-weight programming language designed for extending applications"
HOMEPAGE="https://www.lua.org/"
# tarballs produced from ${PV} branches in https://gitweb.gentoo.org/proj/lua-patches.git
# Old gentoo URL
# SRC_URI="https://dev.gentoo.org/~soap/distfiles/${P}.tar.xz"
SRC_URI="https://www.lua.org/ftp/${P}.tar.gz"
LICENSE="MIT"
SLOT="5.5"
KEYWORDS="amd64"
IUSE="+deprecated readline"
DEPEND="
>=app-eselect/eselect-lua-3
readline? ( sys-libs/readline:= )
!dev-lang/lua:0"
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"
src_prepare() {
default
# elibtoolize
if use elibc_musl; then
# locales on musl are non-functional (#834153)
# https://wiki.musl-libc.org/open-issues.html#Locale-limitations
sed -e 's|os.setlocale("pt_BR") or os.setlocale("ptb")|false|g' \
-i tests/literals.lua || die
fi
}
src_configure() {
use deprecated && append-cppflags -DLUA_COMPAT_5_4
# econf $(use_with readline)
}
src_compile() {
use readline || mytarget="posix"
emake \
CC="$(tc-getCC)" \
AR="$(tc-getAR) rcu" \
RANLIB="$(tc-getRANLIB)" \
MYCFLAGS="${CFLAGS} ${CPPFLAGS} -fPIC -DLUA_USE_LINUX" \
MYLDFLAGS="${LDFLAGS}" \
"${mytarget}"
pushd src > /dev/null || die
$(tc-getCC) -shared -o liblua.so \
-Wl,-soname,liblua-${PV%.*}.so \
-Wl,--whole-archive liblua.a -Wl,--no-whole-archive \
${LDFLAGS} -lm -ldl || die "Failed to build shared library"
popd > /dev/null || die
}
src_install() {
# INSTALL_MAN="${ED}/usr/share/man/man1" \
emake \
INSTALL_TOP="${ED}/usr" \
INSTALL_LIB="${ED}/usr/$(get-libdir)" \
install
local sover="${PV%.*}"
dolib.so "src/liblua.so"
mv "${ED}/usr/bin/lua" "${ED}/usr/bin/lua${SLOT}" || die
mv "${ED}/usr/bin/luac" "${ED}/usr/bin/luac${SLOT}" || die
dodir "/usr/include/lua${SLOT}"
mv "${ED}/usr/include/"*.h "${ED}/usr/include/lua${SLOT}/" || die
mv "${ED}/usr/include/"*.hpp "${ED}/usr/include/lua${SLOT}/" 2>/dev/null
local pc_file="${T}/lua${SLOT}.pc"
cat > "${pc_file}" <<-EOF || die
V=${sover}
R=${PV}
prefix=/usr
INSTALL_BIN=\${prefix}/bin
INSTALL_INC=\${prefix}/include/lua${SLOT}
INSTALL_LIB=\${prefix}/$(get-libdir)
INSTALL_MAN=\${prefix}/share/man/man1
INSTALL_LMOD=\${prefix}/share/lua/${sover}
INSTALL_CMOD=\${prefix}/$(get-libdir)/lua/${sover}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/$(get-libdir)
includedir=\${prefix}/include/lua${SLOT}
NAME: Lua
Description: An Extensible Language
Version: ${PV}
Requires:
Libs: -L\${libdir} -llua -lm -ldl
CFLAGS: -I\${includedir}
EOF
insinto "/usr/$(get-libdir)/pkgconfig"
doins "${pc_file}"
find "${ED}" -name '*.a' -delete || die
find "${ED}" -name '*.la' -delete || die
}
pkg_postinst() {
eselect lua set --if-unset "${PN}${SLOT}"
optfeature "Lua support for Emacs" app-emacs/lua-mode
}