SHA256
6
0
forked from mcepl/luajit-mike
Files
luajit-mike/luajit.spec

232 lines
7.9 KiB
RPMSpec

#
# spec file for package luajit
#
# Copyright (c) 2024 SUSE LLC
#
# 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/
#
# These numbers are from readelf -a /usr/lib*/lib*.so* |grep soname (dots replaced by underscores)
%define major_version 5.1
%define long_version 5.1.2
%define lib_version 5_1
%define so_version 2
%define upname LuaJIT
%define libname libluajit-%{lib_version}-%{so_version}
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
Name: luajit
Version: 5.1.2.1.0+git.1753364724.871db2c8
Release: 0
Summary: JIT compiler for Lua language
License: MIT
URL: https://luajit.org/
Source0: %{upname}-%{version}.tar.xz
Source1: baselibs.conf
# PATCH-FIX-OPENSUSE luajit-lua-versioned.patch mcepl@suse.com
# Because we obsolete moonjit with version number higher than %%{version} we have to emulate Epoch
Patch0: luajit-lua-versioned.patch
# https://salsa.debian.org/lua-team/luajit/-/raw/master/debian/patches/0002-Enable-debugging-symbols-in-the-build.patch
Patch2: 0002-Enable-debugging-symbols-in-the-build.patch
# https://salsa.debian.org/lua-team/luajit/-/raw/master/debian/patches/0003-Get-rid-of-LUAJIT_VERSION_SYM-that-changes-ABI-on-ev.patch
Patch3: 0003-Get-rid-of-LUAJIT_VERSION_SYM-that-changes-ABI-on-ev.patch
# Most recent s390x patches at https://github.com/luajit/luajit/pull/631
Patch4: luajit-s390x.patch
# PPC64 patches are out of sync
# # https://salsa.debian.org/lua-team/luajit/-/raw/master/debian/patches/0004-Add-ppc64-support-based-on-koriakin-GitHub-patchset.patch
# # Patch again out of sync, gh#LuaJIT/LuaJIT#140
# Patch5: 0004-Add-ppc64-support-based-on-koriakin-GitHub-patchset.patch
# Patch6: luajit-ppc64-replace-asserts.patch
BuildRequires: git
BuildRequires: lua-macros
BuildRequires: pkgconfig
Requires: %{name}-%{lib_version}-%{so_version} = %{version}
Provides: lua51-luajit = %{version}-%{release}
Obsoletes: lua51-luajit <= 2.2.0
Provides: moonjit = %{version}-%{release}
Obsoletes: moonjit <= 2.2.0
Provides: lua = %{version}-%{release}
# lj_arch.h:441:2: error: #error "No target architecture defined"
ExclusiveArch: x86_64 %{ix86} aarch64 %{arm} ppc mips mips64 mips64el s390x
# Both lua51 and luajit use %%{_libdir}/lua/%%{major_version}
Provides: lua51
Conflicts: lua51
%if %{with libalternatives}
BuildRequires: alts
BuildRequires: lua-interpreter
Requires: alts
Requires: lua-interpreter
%else
Requires(post): update-alternatives
Requires(postun): update-alternatives
%endif
%description
A Just-In-Time Compiler for Lua language
%package -n %{libname}
Summary: Library for JIT Lua compiler
Provides: %{name}-%{lib_version}-%{so_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}
Libraries to use JIT Lua compiler
%package devel
Summary: Devel files for %{name}
Requires: %{name} = %{version}
Requires: lua-macros
Requires: luajit-%{lib_version}-%{so_version} = %{version}
Conflicts: lua-devel
Provides: moonjit-devel = %{version}-%{release}
Obsoletes: moonjit-devel <= 2.2.0
Provides: libluajit-devel = %{version}-%{release}
Provides: lua-devel = %{version}
Provides: Lua(devel) = %{major_version}
Provides: pkgconfig(lua) = %{version}
%description devel
Devel files for luajit package
%prep
%autosetup -p1 -n %{upname}-%{version}
# Fix variables
sed -i "s,PREFIX= %{_prefix}/local,PREFIX= %{_prefix}," Makefile
sed -i "s,%{_libexecdir},%{_libdir}," etc/luajit.pc
# Unfortunately, tar_scm doesn't use git archive (gh#openSUSE/obs-service-tar_scm#144)
%global realver 2.1.%(echo '%{version}' | cut -d. -f 6)
echo '%{version}' | cut -d. -f 6 >.relver
%build
export CFLAGS="%{optflags}"
%make_build %{?_make_output_sync} \
Q= \
DYNAMIC_CC="cc -fPIC" \
LDCONFIG="true" \
XCFLAGS="-DLUAJIT_ENABLE_LUA52COMPAT" \
TARGET_AR="ar rcus" \
TARGET_STRIP=: \
MULTILIB=%{_lib}
%install
make DESTDIR=%{buildroot} install \
INSTALL_LIB="%{buildroot}%{_libdir}" \
DYNAMIC_CC="cc -fPIC" \
LDCONFIG="true" \
TARGET_AR="ar rcus" \
TARGET_STRIP=: \
MULTILIB=%{_lib}
# remove static lib, not needed
rm %{buildroot}%{_libdir}/*.a
# Create runnable binary
ln -sf %{_bindir}/luajit-%{lib_version}-%{realver} %{buildroot}%{_bindir}/luajit
%if %{with libalternatives}
# alternatives - create configuration file
mkdir -p %{buildroot}%{_datadir}/libalternatives/lua
cat > %{buildroot}%{_datadir}/libalternatives/lua/52.conf <<EOF
binary=%{_bindir}/luajit
man=luajit
EOF
%else
# update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch "%{buildroot}%{_sysconfdir}/alternatives/%{name}"
ln -sf "%{_sysconfdir}/alternatives/%{name}" "%{buildroot}%{_bindir}/%{name}"
touch "%{buildroot}%{_sysconfdir}/alternatives/%{name}.1%{ext_man}"
ln -sf "%{_sysconfdir}/alternatives/%{name}.1%{ext_man}" \
"%{buildroot}%{_mandir}/man1/%{name}.1%{ext_man}"
%endif
# Compat link with older unprefixed library and with soname 0 from deb/etc
chmod +x %{buildroot}%{_libdir}/*
ln -s libluajit-%{major_version}.so.%{so_version} \
%{buildroot}%{_libdir}/liblua%{major_version}.so.%{long_version}
ln -s libluajit-%{major_version}.so.%{so_version} \
%{buildroot}%{_libdir}/liblua%{long_version}.so
ln -s %{_libdir}/liblua%{long_version}.so \
%{buildroot}%{_libdir}/liblua.so
ln -s luajit.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc
# Compat link for /usr/bin/lua5.1
ln -s luajit %{buildroot}%{_bindir}/lua%{major_version}
%if %{without libalternatives}
%post
%{_sbindir}/update-alternatives --install \
%{_bindir}/lua lua %{_bindir}/lua%{major_version} 52 \
--slave %{_mandir}/man1/lua.1%{ext_man} lua.1%{ext_man} %{_mandir}/man1/lua%{major_version}.1%{ext_man}
%postun
if [ "$1" = 0 ] ; then
%{_sbindir}/update-alternatives --remove lua %{_bindir}/lua%{major_version}
fi
%endif
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%files
%license COPYRIGHT
%doc README
%{_bindir}/luajit
%{_bindir}/luajit-%{lib_version}
%{_bindir}/luajit-%{lib_version}-%{realver}
%{_bindir}/lua%{major_version}
%{_mandir}/man1/luajit-%{lib_version}.1%{?ext_man}
%{_datadir}/luajit-%{lib_version}-2.1
%dir %{_libdir}/lua
%dir %{_libdir}/lua/%{major_version}
%dir %{_datadir}/lua
%dir %{_datadir}/lua/%{major_version}
%if %{with libalternatives}
%{_datadir}/libalternatives/lua/52.conf
%else
# alternatives
%{_bindir}/lua
%{_mandir}/man1/lua.1%{?ext_man}
%ghost %{_sysconfdir}/alternatives/lua
%ghost %{_sysconfdir}/alternatives/lua.1%{ext_man}
%endif
%files -n %{libname}
%{_libdir}/libluajit-%{major_version}.so.*
%{_libdir}/liblua%{major_version}.so.*
%files devel
%dir %{_includedir}/luajit-%{lib_version}-2.1
%{_includedir}/luajit-%{lib_version}-2.1/lauxlib.h
%{_includedir}/luajit-%{lib_version}-2.1/lua.h
%{_includedir}/luajit-%{lib_version}-2.1/lua.hpp
%{_includedir}/luajit-%{lib_version}-2.1/luaconf.h
%{_includedir}/luajit-%{lib_version}-2.1/luajit.h
%{_includedir}/luajit-%{lib_version}-2.1/lualib.h
%{_libdir}/libluajit-%{major_version}.so
%{_libdir}/liblua.so
%{_libdir}/liblua%{long_version}.so
%{_libdir}/pkgconfig/luajit.pc
%{_libdir}/pkgconfig/lua.pc
%changelog