File jsoncpp.spec of Package jsoncpp
%define realname jsoncpp
%define srcext tar.bz2
%define so_ver 25
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
# Common info
Name: lib%{realname}%{?so_ver}
Version: 1.0.0
Release: wiz%{?extraver:0.}1%{?dist}
License: MIT
Group: System/Libraries
URL: https://github.com/open-source-parsers/jsoncpp
Summary: C++ library that allows manipulating JSON values
# Install-time parameters
Provides: %{realname} = %{version}
Provides: lib%{realname} = %{version}
# Build-time parameters
BuildRequires: meson >= 0.50.0 ninja
BuildRequires: pkg-config
BuildRequires: gcc-c++
BuildRoot: %{_tmppath}/%{name}-root
Source: %{realname}-%{version}%{?extraver}.%{srcext}
%description
JsonCpp is a C++ library that allows manipulating JSON values, including
serialization and deserialization to and from strings. It can also preserve
existing comment in unserialization/serialization steps, making it a convenient
format to store user input files.
%package -n lib%{realname}-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}
Provides: %{realname}-devel = %{version}
Provides: %{name}-devel = %{version}
%description -n lib%{realname}-devel
Development files for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver}
sed -ri 's/-Werror//' CMakeLists.txt
%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
meson setup build \
--buildtype=release \
--strip \
--optimization=2 \
\
--prefix=%{_prefix} \
--default-library=shared \
\
-Db_ndebug=if-release \
-Db_lto=true \
-Dcpp_args="$_CFLAGS" \
-Dcpp_link_args="$_LDFLAGS"
ninja -v -C build %{?_smp_mflags}
%install
DESTDIR=%{buildroot} ninja -v -C build install
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license LICENSE
%doc AUTHORS README.md
%{_libdir}/lib%{realname}.so.%{so_ver}
# Development stuff
%files -n lib%{realname}-devel
%defattr(-,root,root)
%{_libdir}/pkgconfig/%{realname}.pc
%dir %{_includedir}/json
%{_includedir}/json/*.h
%{_libdir}/lib%{realname}.so
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog