File lua-mpack.spec of Package lua-mpack

# spec file for package lua-mpack
# Copyright (c) 2020 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

%define flavor @BUILD_FLAVOR@
%define libmpack_version 1.0.5
%define mod_name mpack
Version:        1.0.6
Release:        0
Summary:        Implementation of MessagePack for Lua 5.1
License:        MIT
Group:          Development/Libraries/Other
# libmpack source is necessary to build lua-mpack, next release should build
# fine against system version
# The latest source can be downloaded from:
# PATCH-FIX-UPSTREAM lua51-mpack-fix-gcc7.patch gh#libmpack/libmpack-lua#3 -- Fix compilation error when using GCC7.
Patch0:         lua51-mpack-fix-gcc7.patch
# PATCH-FIX-UPSTREAM lua51-mpack-fix-compilation.patch gh#libmpack/libmpack-lua#2 -- Fix compilation error when using `USE_SYSTEM_LUA=1`.
Patch1:         lua51-mpack-fix-compilation.patch
BuildRequires:  %{flavor}-devel
BuildRequires:  gcc
BuildRequires:  libtool
Requires:       %{flavor}
%if "%{flavor}" == ""
Name:           lua-%{mod_name}
ExclusiveArch:  do_not_build
Name:           %{flavor}-%{mod_name}

mpack is a binary serialization/RPC library that implements both the msgpack
and msgpack-rpc specifications.

%setup -q -n libmpack-lua-%{version}
%patch0 -p1
%patch1 -p1

# Extract the libmpack source to the right directory.
mkdir -p mpack-src
pushd mpack-src
cp %{SOURCE1} ./
tar --strip-components=1 -xzf libmpack-%{libmpack_version}.tar.gz

# Fix lua directory.
sed -i 's|LUA_CMOD_INSTALLDIR :=.*|LUA_CMOD_INSTALLDIR := $(shell echo "%{lua_archdir}")|g' Makefile

%make_build \
    USE_SYSTEM_LUA=yes \
    MPACK_LUA_VERSION=%{lua_version} \
    CFLAGS="%{optflags} -fPIC"

%make_install USE_SYSTEM_LUA=yes

%doc mpack-src/LICENSE-MIT
%dir %{lua_archdir}

openSUSE Build Service is sponsored by