File unicorn.spec of Package unicorn

#
# spec file for package unicorn
#
# Copyright (c) 2022 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 http://bugs.opensuse.org/
#

###⅜%global _lto_cflags %%{?_lto_cflags} -ffat-lto-objects
%define         _lto_cflags      %{nil}
%define _lver   2
Name:           unicorn
Version:        2.0.0
Release:        0
Summary:        Multi-CPU emulator engine based on QEMU
### recheck this one
License:        GPL-2.0
Group:          System/Emulators/Other
URL:            http://www.unicorn-engine.org
Source0:        https://github.com/unicorn-engine/unicorn/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  cmake-full
BuildRequires:  fdupes
BuildRequires:  libcmocka-devel
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
# Temporarily excluded until (gh#unicorn-engine/unicorn#766) is fully addressed
###ExcludeArch:    ppc ppc64 s390x

%description
Unicorn is a lightweight multi-platform, multi-architecture CPU emulator
framework.

Highlight features:

   * Multi-architectures: Arm, Arm64 (Armv8), M68K, Mips, Sparc
     & X86 (X86_64 included).
   * Clean/simple/lightweight/intuitive architecture-neutral API.
   * Implemented in pure C language, with bindings for Rust, Haskell,
     Ruby, Python, Java, Go, .NET, Delphi/Pascal & MSVC available.
   * Native support for Windows & *nix (with Mac OSX, Linux, *BSD
     & Solaris confirmed).
   * High performance by using Just-In-Time compiler technique.
   * Support fine-grained instrumentation at various levels.
   * Thread-safe by design.
   * Distributed under free software license GPLv2.

%package        devel
Summary:        Development files for package %{name}
Group:          Development/Libraries/C and C++
Requires:       lib%{name}%{_lver} = %{version}

%description    devel
This package contains development files for %{name}

%package        devel-static
Summary:        Development files for package %{name} (static version)
Group:          Development/Libraries/C and C++
Requires:       %{name}-devel = %{version}

%description    devel-static
This package contains development files for %{name} (static version)

%package -n     lib%{name}%{_lver}
Summary:        Support library for %{name}
Group:          System/Libraries

%description -n lib%{name}%{_lver}
This package contains the support library for %{name}

%package -n     python3-%{name}
Summary:        Python3 bindings for %{name}
Group:          Development/Languages/Python
Requires:       lib%{name}%{_lver} = %{version}

%description -n python3-%{name}
This package contains the Python3 bindings for %{name}

%prep
%autosetup -p1

# hopefully temporary until bug #765 is fixed
####%%ifarch %%arm ppc ppc64 ppc64le s390x
###sed -e '/unit test/d' -i Makefile
###%%endif
# hopefully temporary until bug #766 is fixed
####%%ifarch ppc ppc64 s390x
###sed -e '/DIFF.*py\.test/d' -i bindings/Makefile
###sed -e '/bindings test/d' -i Makefile
####%%endif

%build
#%%cmake
#%%cmake_build
#
mkdir build; cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
#
%cmake_build

#cd ../bindings/python
#python3 setup.py build

%install
%cmake_install

pushd bindings/python
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} --install-lib=%{python3_sitearch}
mkdir -pv %{buildroot}%{_datadir}/doc/packages/python3-%{name}/samples
install -m 644 sample* shellcode.py -t %{buildroot}%{_datadir}/doc/packages/python3-%{name}/samples
popd
rm -rf %{buildroot}%{python3_sitearch}/%{name}/include %{buildroot}%{python3_sitearch}/%{name}/lib

mkdir -pv %{buildroot}%{_datadir}/doc/packages/%{name}-devel/samples
install -m 644 samples/*.c -t %{buildroot}%{_datadir}/doc/packages/%{name}-devel/samples

%fdupes %{buildroot}%{python3_sitearch}

%check
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/build
%ctest

%post -n lib%{name}%{_lver} -p /sbin/ldconfig
%postun -n lib%{name}%{_lver} -p /sbin/ldconfig

%files devel
%doc ChangeLog COPYING CREDITS.TXT README.md
%doc %{_datadir}/doc/packages/%{name}-devel
%dir %{_includedir}/%{name}
%{_includedir}/%{name}/arm.h
%{_includedir}/%{name}/arm64.h
%{_includedir}/%{name}/m68k.h
%{_includedir}/%{name}/mips.h
%{_includedir}/%{name}/platform.h
%{_includedir}/%{name}/ppc.h
%{_includedir}/%{name}/riscv.h
%{_includedir}/%{name}/s390x.h
%{_includedir}/%{name}/sparc.h
%{_includedir}/%{name}/tricore.h
%{_includedir}/%{name}/unicorn.h
%{_includedir}/%{name}/x86.h
%{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc

%files devel-static
%{_libdir}/lib%{name}.a

%files -n lib%{name}%{_lver}
%doc ChangeLog COPYING CREDITS.TXT README.md
%{_libdir}/libunicorn.so.%{_lver}

%files -n python3-%{name}
%doc ChangeLog COPYING CREDITS.TXT bindings/README README.md
%doc %{_datadir}/doc/packages/python3-%{name}
%{python3_sitearch}/%{name}
%{python3_sitearch}/%{name}-%{version}-py%{py3_ver}.egg-info

%changelog
openSUSE Build Service is sponsored by