%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

%define pkg_date	20220414

Summary:	A JSON implementation in C
Name:		json-c
Version:	0.16
Release:	1%{?_dist_release}
Group:		system
Vendor:		Project Vine
Distribution:	Vine Linux

License:	MIT
URL:		http://json-c.github.io/json-c/
Source0: 	https://github.com/json-c/json-c/archive/json-c-%{version}-%{pkg_date}.tar.gz

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
BuildRequires:	cmake ninja

%description
JSON-C implements a reference counting object model that allows you to easily
construct JSON objects in C, output them as JSON formatted strings and parse
JSON formatted strings back into the C representation of JSON objects.


%package devel
Summary:	Development files for json-c
Group:		programming
Requires:	%{name} = %{version}-%{release}
Requires:	pkgconfig

%description devel
This package contains the libraries and header files that are needed
for writing applications that are using json-c.


%package doc
Summary:	Documentation for json-c
Group:		documentation
Requires:	%{name} = %{version}-%{release}
BuildArch:	noarch

%description doc
This package contains documentation for json-c.


%package -n compat32-%{name}
Summary:	A JSON implementation in C
Group:		system,legacy
Requires:	%{name} = %{version}-%{release}

%description -n compat32-%{name}
JSON-C implements a reference counting object model that allows you to easily
construct JSON objects in C, output them as JSON formatted strings and parse
JSON formatted strings back into the C representation of JSON objects.

%package -n compat32-%{name}-devel
Summary:	Development files for json-c
Group:		programming,legacy
Requires:	compat32-%{name} = %{version}-%{release}
Requires:	pkgconfig

%description -n compat32-%{name}-devel
This package contains the libraries and header files that are needed
for writing applications that are using json-c.


%debug_package


%prep
%setup -q -n json-c-json-c-%{version}-%{pkg_date}


%build
%cmake \
  -DBUILD_SHARED_LIBS:BOOL=ON \
  -DBUILD_STATIC_LIBS:BOOL=OFF       \
  -DCMAKE_BUILD_TYPE:STRING=RELEASE  \
  -DCMAKE_C_FLAGS_RELEASE:STRING=""  \
  -DDISABLE_BSYMBOLIC:BOOL=OFF       \
  -DDISABLE_WERROR:BOOL=ON           \
  -DENABLE_RDRAND:BOOL=ON            \
  -DENABLE_THREADING:BOOL=ON         \
  -G Ninja

%cmake_build


%install
%{__rm} -rf $RPM_BUILD_ROOT
%cmake_install

%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/*.la


%check
%ctest


%clean
%{__rm} -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%license COPYING
%doc AUTHORS ChangeLog NEWS README*
%{_libdir}/libjson-c.so.*

%files devel
%defattr(-,root,root,-)
%dir %{_includedir}/json-c
%{_includedir}/json-c/*
%{_libdir}/libjson-c.so
%{_libdir}/pkgconfig/json-c.pc
%dir %{_libdir}/cmake/json-c
%{_libdir}/cmake/json-c/*.cmake

%files doc
%defattr(-,root,root,-)
%doc doc/html/*

%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/libjson-c.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/libjson-c.so
%endif


%changelog
* Wed Oct 26 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.16-1
- new upstream release.

* Fri Sep 03 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.15-1
- new upstream release.
- dropped Patch1000: fixed in upstream.

* Sat May 16 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.14-1
- updated to 0.14.
- added Patch1000 to fix CVE-2020-12762.

* Tue Jan 01 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.13.1-1
- updated to 0.13.1.

* Sat Jan 17 2015 Daisuke SUZUKI <daisuke@vinelinux.org> 0.11-1
- update to 0.11

* Wed Nov 28 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 0.10-1
- update to 0.10
- update URL

* Sat Oct 08 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.9-2
- create compat32 sub packages

* Fri Oct 07 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.9-1
- initial build for Vine Linux