File lua51-luajit.spec of Package lua51-luajit

#
# spec file for package lua51-luajit
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%define lua_suffix 5_1
%define lib_suffix 2
%ifarch x86_64 aarch64 s390x
%global multilib_flag MULTILIB=lib64
%endif
Name:           lua51-luajit
Version:        2.0.4
Release:        0
Summary:        JIT compiler for Lua language
License:        MIT
Group:          Development/Languages/Lua
Url:            http://www.luajit.com/
Source:         http://luajit.org/download/LuaJIT-%{version}.tar.gz
Patch0:         luajit-lua-versioned.patch
BuildRequires:  pkgconfig
Requires:       libluajit-%{lua_suffix}-%{lib_suffix} = %{version}
Requires(post): update-alternatives
Requires(preun): update-alternatives
Conflicts:      otherproviders(luajit)
Provides:       luajit = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# lj_arch.h do not support ppc64/ppc64le
ExcludeArch:    ppc64 ppc64le

%description
A Just-In-Time Compiler for Lua language

%package -n libluajit-%{lua_suffix}-%{lib_suffix}
Summary:        Library for JIT Lua compiler
Group:          System/Libraries

%description -n libluajit-%{lua_suffix}-%{lib_suffix}
Libraries to use JIT Lua compiler

%package devel
Summary:        Devel files for LuaJIT
Group:          Development/Languages/Lua
Requires:       %{name} = %{version}
Requires:       libluajit-%{lua_suffix}-%{lib_suffix} = %{version}
Conflicts:      otherproviders(luajit-devel)
Provides:       luajit-devel = %{version}

%description devel
Devel files for luajit package

%prep
%setup -q -n LuaJIT-%{version}
%patch0 -p1
# Fix variables
sed -i "s,PREFIX= %{_prefix}/local,PREFIX= %{_prefix}," Makefile

%build
CFLAGS="%{optflags}" \
make %{?_smp_mflags} \
	Q= \
	DYNAMIC_CC="cc -fPIC" \
	LDCONFIG="true" \
	TARGET_AR="ar rcus" \
	TARGET_STRIP=: \
	%{?multilib_flag}

%install
make DESTDIR=%{buildroot} install \
	INSTALL_LIB="%{buildroot}/%{_libdir}" \
	DYNAMIC_CC="cc -fPIC" \
	LDCONFIG="true" \
	TARGET_AR="ar rcus" \
	TARGET_STRIP=: \
	%{?multilib_flag}
# remove static lib, not needed
rm %{buildroot}/%{_libdir}/*.a

# update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives/
touch %{buildroot}%{_sysconfdir}/alternatives/luajit
touch %{buildroot}%{_sysconfdir}/alternatives/luajit.1%{ext_man}
ln -sf %{_sysconfdir}/alternatives/luajit %{buildroot}%{_bindir}/luajit
ln -sf %{_sysconfdir}/alternatives/luajit.1%{ext_man} %{buildroot}%{_mandir}/man1/luajit.1%{ext_man}

%post
%{_sbindir}/update-alternatives --install %{_bindir}/luajit luajit %{_bindir}/luajit-%{lua_suffix}-%{version} 60 \
	--slave %{_mandir}/man1/luajit.1%{ext_man} luajit.1%{ext_man} %{_mandir}/man1/luajit-%{lua_suffix}.1%{ext_man}

%preun
if [ "$1" = 0 ] ; then
	%{_sbindir}/update-alternatives --remove luajit %{_bindir}/luajit-%{lua_suffix}-%{version}
fi

%post -n libluajit-%{lua_suffix}-%{lib_suffix} -p /sbin/ldconfig
%postun -n libluajit-%{lua_suffix}-%{lib_suffix} -p /sbin/ldconfig

%files
%defattr(-,root,root)
%ghost %{_sysconfdir}/alternatives/luajit
%ghost %{_sysconfdir}/alternatives/luajit.1%{ext_man}
%{_bindir}/luajit
%{_bindir}/luajit-%{lua_suffix}
%{_bindir}/luajit-%{lua_suffix}-%{version}
%{_mandir}/man1/luajit.1%{ext_man}
%{_mandir}/man1/luajit-%{lua_suffix}.1%{ext_man}
%{_datadir}/luajit-%{lua_suffix}-%{version}/

%files -n libluajit-%{lua_suffix}-%{lib_suffix}
%defattr(-,root,root)
%{_libdir}/libluajit-5.1.so.2.0.4

%files devel
%defattr(-,root,root)
%{_includedir}/luajit-%{lua_suffix}-2.0/
%{_libdir}/libluajit-5.1.so
%{_libdir}/pkgconfig/luajit.pc

%changelog
openSUSE Build Service is sponsored by