#needsrootforbuild
%global __cargo_skip_build 0
%global __cargo_common_opts %{?__cargo_common_opts} --all
Name:           native-turbo
Version:        1.0.0
Release:        6
Summary:        Numa Aware Scheduling
License:        Mulan PSL v2
URL:            https://gitee.com/openeuler/native-turbo

Source0:        %{name}.tar.xz

BuildRequires: meson >= 0.49.2, clang >= 12.0.1
BuildRequires: make >= 4.0, bison >= 2.7, binutils >= 2.30-17, gcc >= 10.3.1
BuildRequires: ncurses-devel

%description
sysboost can merge ELF files to improve performance.

# Add devel subpackage
%package devel
Summary: Development files for %{name}

%description devel
The %{name}-devel package contains some tools of sysboost.

%package tools
Summary: Some tools for %{name}
Requires: xz, binutils

%description tools
The %{name}-tools package contains some tools of sysboost.

%prep
export RPM_BUILD_DIR=%_topdir/BUILD
export RPM_BUILD_SOURCE=%_topdir/SOURCES

tar -Jxf $RPM_BUILD_SOURCE/%{name}.tar.xz

cp $RPM_BUILD_SOURCE/objreloc.sh $RPM_BUILD_DIR/objreloc

%build
cd $RPM_BUILD_DIR/native-turbo
make release
make

%install
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_libdir}
mkdir -p $RPM_BUILD_ROOT/usr/include/

pushd native-turbo/build
install -D -p -m 644 ./lib/libsi_array.a $RPM_BUILD_ROOT/%{_libdir}/libsi_array.a
install -D -p -m 644 ./lib/libsi_hashmap.a $RPM_BUILD_ROOT/%{_libdir}/libsi_hashmap.a
install -D -p -m 644 ./lib/libsi_ring.a $RPM_BUILD_ROOT/%{_libdir}/libsi_ring.a
install -D -p -m 644 ./lib/libsi_sys.a $RPM_BUILD_ROOT/%{_libdir}/libsi_sys.a
popd

pushd native-turbo
install -D -p -m 644 ./lib/sys/include/* $RPM_BUILD_ROOT/usr/include/
install -D -p -m 644 ./lib/hashmap/si_hashmap.h $RPM_BUILD_ROOT/usr/include/si_hashmap.h
install -D -p -m 644 ./lib/array/si_array.h $RPM_BUILD_ROOT/usr/include/si_array.h
install -D -p -m 644 ./lib/ring/si_ring_core.h $RPM_BUILD_ROOT/usr/include/si_ring_core.h
install -D -p -m 644 ./lib/ring/si_ring.h $RPM_BUILD_ROOT/usr/include/si_ring.h
popd

install -m 755 $RPM_BUILD_DIR/objreloc $RPM_BUILD_ROOT%{_bindir}/

%check

%files

%files devel
%{_libdir}/*
/usr/include/*

%files tools
%defattr(0755,root,root)
%{_bindir}/objreloc

%doc

%changelog
* Tue Aug 29 2023 liutie <liutie4@huawei.com> - 1.0.0-6
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: fix issue can not find native-turbo.service

* Mon Jun 12 2023 liutie <liutie4@huawei.com> - 1.0.0-5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: when tools should run with xz and

* Mon Jun 12 2023 liutie <liutie4@huawei.com> - 1.0.0-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: create static libs and change devel subpackage name

* Tue May 16 2023 liutie <liutie4@huawei.com> - 1.0.0-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: Add sysboostd service for sysboost

* Mon May 8 2023 liutie <liutie4@huawei.com> - 1.0.0-2
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: Independently generate the objreloc tool

* Mon May 8 2023 liutie <liutie4@huawei.com> - 1.0.0-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: Independently generate the objreloc tool

* Thu Apr 6 2023 liutie <liutie4@huawei.com> - 1.0.0-0
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: init