File libjansson.spec of Package libjansson
%define realname jansson
%define realver 2.14
%define srcext tar.gz
%define so_ver 4
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
# Common info
Name: lib%{realname}%{?so_ver}
Version: %{realver}
Release: %{?extraver:0.}1%{?dist}
License: MIT
Group: Development/Libraries/C and C++
URL: https://github.com/akheron/jansson
Summary: C library for encoding, decoding and manipulating JSON data
# Install-time parameters
Provides: %{realname} = %{version}
# Build-time parameters
BuildRequires: cmake >= 3.1
BuildRequires: pkg-config
BuildRoot: %{_tmppath}/%{name}-root
Source: https://codeload.github.com/akheron/jansson/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
Jansson is a C library for encoding, decoding and manipulating JSON data.
It features:
* Simple and intuitive API and data model
* Comprehensive documentation
* No dependencies on other libraries
* Full Unicode support (UTF-8)
* Extensive test suite
Jansson is licensed under the MIT license.
%package -n lib%{realname}-devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}
Provides: %{name}-devel = %{version}
Provides: %{realname}-devel = %{version}
%description -n lib%{realname}-devel
Development files for %{name}
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%{__sed} -i '/DESTINATION/ s|lib|%{_lib}|' CMakeLists.txt
%build
_CFLAGS='%{optflags} %{?gcc_lto}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
_CMAKE_ARGS=(
-DCMAKE_INSTALL_PREFIX=%{_prefix}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_FLAGS_RELEASE="$_CFLAGS"
-DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS"
-DCMAKE_VERBOSE_MAKEFILE=YES
)
%{__mkdir} build
cd build
cmake .. \
"${_CMAKE_ARGS[@]}" \
\
-DJANSSON_BUILD_SHARED_LIBS=YES \
-DJANSSON_EXAMPLES=NO \
-DJANSSON_BUILD_DOCS=OFF \
-DJANSSON_INSTALL_CMAKE_DIR=%{_libdir}/cmake/jansson
%{__make} %{?_smp_mflags}
%check
%{__make} -C build test
%install
%{__make} -C build install DESTDIR=%{buildroot}
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license LICENSE
%doc README.rst
%{_libdir}/lib%{realname}.so.%{?so_ver}*
# Development stuff
%files -n lib%{realname}-devel
%defattr(-,root,root)
%license LICENSE
%doc README.rst doc/*.rst
%{_libdir}/pkgconfig/%{realname}.pc
%dir %{_libdir}/cmake/jansson
%dir %{_libdir}/cmake
%{_libdir}/cmake/jansson/*.cmake
%{_includedir}/%{realname}*.h
%{_libdir}/lib%{realname}.so
%exclude %{_libdir}/*.la
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%changelog