File lua51.spec of Package lua51
#
# spec file for package lua51
#
# Copyright (c) 2026 SUSE LLC
# Copyright (c) 2026 Boian Berberov
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global major_version 5.1
%global libname liblua5_1-5
Name: lua51
Version: 5.1.5
Release: 0%{?dist}
Group: Development/Languages/Other
Summary: Small Embeddable Language with Procedural Syntax
License: MIT
URL: https://www.lua.org
Source0: %{url}/ftp/lua-%{version}.tar.gz
Source1: %{url}/tests/lua%{major_version}-tests.tar.gz
# PATCH-FIX-SUSE tweak the buildsystem to produce what is needed for SUSE
Patch0: lua-build-system.patch
# Yes, Lua is from Brasil, we need pt_BR locale
BuildRequires: glibc-locale
BuildRequires: libtool
BuildRequires: lua-macros
BuildRequires: pkgconfig
BuildRequires: readline-devel
Requires(post): /usr/sbin/update-alternatives
Requires(postun): /usr/sbin/update-alternatives
Provides: lua = %{version}
Obsoletes: lua < %{version}
Provides: Lua(API) = %{major_version}
%description
Lua is a programming language originally designed for extending
applications, but is also frequently used as a general-purpose,
stand-alone language.
Lua combines procedural syntax (similar to Pascal) with
data description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, interpreted from byte codes, and
has automatic memory management, making it suitable for configuration,
scripting, and rapid prototyping. Lua is implemented as a small library
of C functions, written in ANSI C.
%package devel
Summary: Development files for lua
Group: Development/Libraries/C and C++
Requires: %{libname} == %{version}
Requires: %{name} == %{version}
Requires: lua-macros
Conflicts: lua-devel
Provides: lua-devel = %{version}
Provides: Lua(devel) = %{major_version}
Provides: pkgconfig(lua) = %{version}
BuildArch: noarch
%description devel
Lua is a programming language originally designed for extending
applications, but is also frequently used as a general-purpose,
stand-alone language.
This package contains files needed for embedding lua into your
application.
%package -n %{libname}
Group: System/Libraries
Summary: The Lua integration library
# Compat as libtool changes the soname
Provides: liblua5_1 = %{version}-%{release}
Obsoletes: liblua5_1 < %{version}-%{release}
Provides: %{name}-libs = %{version}
Obsoletes: %{name}-libs < %{version}
%ifarch aarch64 x86_64 ppc64 ppc64le s390x riscv64
Provides: liblua.so.5.1()(64bit)
%else
Provides: liblua.so.5.1
%endif
%description -n %{libname}
Lua is a programming language originally designed for extending
applications, but is also frequently used as a general-purpose,
stand-alone language.
Lua combines procedural syntax (similar to Pascal) with
data description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, interpreted from byte codes, and
has automatic memory management, making it suitable for configuration,
scripting, and rapid prototyping. Lua is implemented as a small library
of C functions, written in ANSI C.
%package doc
Group: Documentation/HTML
Summary: Documentation for Lua, a small embeddable language
Supplements: (lua51 and patterns-base-documentation)
BuildArch: noarch
%description doc
Lua is a programming language originally designed for extending
applications, but is also frequently used as a general-purpose,
stand-alone language.
Lua combines procedural syntax (similar to Pascal) with
data description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, interpreted from byte codes, and
has automatic memory management, making it suitable for configuration,
scripting, and rapid prototyping. Lua is implemented as a small library
of C functions, written in ANSI C.
%prep
%setup -q -n lua-%{version} -a1
mv lua%{major_version}-tests testes
%patch -P0 -p1
%__sed -i -e 's@lib/lua/@%{_lib}/lua/@g' src/luaconf.h
# Manpages
%__sed -e 's/TH LUA 1/TH LUA%{major_version} 1/' doc/lua.1 > doc/lua%{major_version}.1
%__sed -e 's/TH LUAC 1/TH LUAC%{major_version} 1/' doc/luac.1 > doc/luac%{major_version}.1
%build
%define _lto_cflags %{nil}
%make_build \
-C src \
all \
CC='cc' \
MYCFLAGS='%{optflags} -std=gnu99 -D_GNU_SOURCE -fPIC -DLUA_USE_LINUX -DLUA_COMPAT_MODULE' \
MYLIBS='-Wl,-E -ldl -lreadline -lhistory -lncurses' \
LIBTOOL='libtool --quiet' \
V=%{major_version}
%install
%make_install \
INSTALL_TOP='%{buildroot}%{_prefix}' \
INSTALL_LIB='%{buildroot}%{_libdir}' \
INSTALL_MAN='%{buildroot}%{_mandir}/man1' \
LIBTOOL='libtool --quiet' \
V=%{major_version}
# Remove libtool files
find %{buildroot} -type f -name '*.la' -delete -print
# Create pkg-config file
cat > lua%{major_version}.pc <<-EOF
prefix=%{_prefix}
exec_prefix=%{_prefix}
libdir=%{_libdir}
includedir=%{_includedir}/lua%{major_version}
INSTALL_LMOD=%{_datadir}/lua/%{major_version}
INSTALL_CMOD=%{_libdir}/lua/%{major_version}
Name: Lua %{major_version}
Description: An Extensible Extension Language
Version: %{version}
Libs: -llua%{major_version} -lm
Cflags: -I\${includedir}
EOF
%__install -D -m 0644 lua%{major_version}.pc %{buildroot}%{_libdir}/pkgconfig/lua%{major_version}.pc
# alternatives - create configuration file
for file in lua luac
do
mkdir -p %{buildroot}%{_datadir}/libalternatives/${file}
cat > %{buildroot}%{_datadir}/libalternatives/${file}/51.conf <<EOF
binary=%{_bindir}/${file}%{major_version}
man=${file}%{major_version}
EOF
done
# Compat link with older unprefixed library and with soname 0 from deb/etc
chmod +x %{buildroot}%{_libdir}/*
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version}
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0
ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version}
# We don’t create alternatives for -devel content, just conflict those
ln -s %{_libdir}/liblua%{major_version}.so %{buildroot}%{_libdir}/liblua.so
ln -s %{_libdir}/pkgconfig/lua%{major_version}.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
%check
# WARNING: this whole check section is incredibly interdependent and brittle, don't change anything
# unless you really thought through what you would be doing.
# The distributed binary of the Lua interpreter is (correctly) build without LUA_USE_APICHECK option,
# we have to build a special interpreter just for the testing.
mkdir -p build-test
cp -r src build-test/
cp Makefile build-test/
pushd build-test
%make_build -C src clean
%make_build \
-C src \
all \
CC="cc" \
MYCFLAGS="%{optflags} -std=gnu99 -D_GNU_SOURCE -fPIC -DLUA_USE_LINUX -DLUA_COMPAT_MODULE -DLUA_USE_APICHECK" \
MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses" \
V=%{major_version} \
LIBTOOL="libtool --quiet"
popd
cd testes
pushd libs
%make_build \
all \
CFLAGS='-fPIC -std=gnu99 -D_GNU_SOURCE -I../../build-test/src'
cp -- *.so ..
popd
# Yes, Lua is from Brasil
export LANG=pt_BR.utf8
export LD_LIBRARY_PATH=../build-test/src/.libs
# I haven't found a way how to run FULL all.lua test suite, so we are just running
# what we can for checking the sanity of the build.
for testFile in \
api.lua \
attrib.lua \
calls.lua \
closure.lua \
code.lua \
constructs.lua \
db.lua \
errors.lua \
events.lua \
files.lua \
gc.lua \
checktable.lua \
literals.lua \
locals.lua \
math.lua \
nextvar.lua \
pm.lua \
sort.lua \
strings.lua \
vararg.lua \
verybig.lua \
;
do
../build-test/src/.libs/lua%{major_version} "${testFile}"
done
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%files
%doc README
%dir %{_libdir}/lua
%dir %{_libdir}/lua/%{major_version}
%dir %{_datadir}/lua
%dir %{_datadir}/lua/%{major_version}
%{_bindir}/lua%{major_version}
%{_bindir}/luac%{major_version}
%{_mandir}/man1/lua%{major_version}.1%{?ext_man}
%{_mandir}/man1/luac%{major_version}.1%{?ext_man}
%{_datadir}/libalternatives/lua/51.conf
%{_datadir}/libalternatives/luac/51.conf
# alternatives
# %%{_bindir}/lua
# %%{_bindir}/luac
# %%{_mandir}/man1/lua.1%%{?ext_man}
# %%{_mandir}/man1/luac.1%%{?ext_man}
%ghost %{_sysconfdir}/alternatives/lua
%ghost %{_sysconfdir}/alternatives/luac
%ghost %{_sysconfdir}/alternatives/lua.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/luac.1%{ext_man}
%files -n %{libname}
%{_libdir}/liblua%{major_version}.so.*
%{_libdir}/liblua.so.*
%files devel
%dir %{_includedir}/lua%{major_version}
%{_includedir}/lua%{major_version}/lauxlib.h
%{_includedir}/lua%{major_version}/lua.h
%{_includedir}/lua%{major_version}/lua.hpp
%{_includedir}/lua%{major_version}/luaconf.h
%{_includedir}/lua%{major_version}/lualib.h
%{_libdir}/liblua%{major_version}.so
%{_libdir}/pkgconfig/lua%{major_version}.pc
%{_libdir}/liblua.so
%{_libdir}/pkgconfig/lua.pc
%files doc
%doc doc/*
%changelog
* Wed Apr 1 2026 Boian Berberov
- Added changelog for openSUSE Leap 16