%define _unpackaged_files_terminate_build 1

Summary:        C library for reading, creating, and modifying zip archives
Name:           libzip
Version:        1.4.0
Release:        1%{?_dist_release}

Group:          System Environment/Libraries
License:        BSD
URL:            https://libzip.org/
Source0:        https://libzip.org/download/%{name}-%{version}.tar.xz

# allow path customization (lib64)
Patch0:  libzip-upstream.patch
# drop RPATH from installed binaries
Patch1:  libzip-rpath.patch
# fix multi-lib issue
Patch2:  libzip-multilib.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-root
BuildRequires:  zlib-devel >= 1.2.2
BuildRequires:  bzip2-devel
BuildRequires:  pkgconfig
BuildRequires:  cmake

%description
libzip is a C library for reading, creating, and modifying zip archives. Files
can be added from data buffers, files, or compressed data copied directly from 
other zip archives. Changes made without closing the archive can be reverted. 
The API is documented by man pages.

%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
Requires: zlib-devel

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%prep
%autosetup -p1

%build
%cmake .
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'

find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc LICENSE* AUTHORS* NEWS* README* THANKS* TODO*
%{_bindir}/*
%{_libdir}/libzip.so.*
%{_mandir}/man1/*zip*

%files devel
%defattr(-,root,root,-)
%{_includedir}/*
%{_libdir}/libzip.so
%{_libdir}/pkgconfig/libzip.pc
%{_mandir}/man3/*


%changelog
* Mon Jan 08 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.0-1
- new upstream release.
- import patches from rawhide.

* Sun Sep 26 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.9.3-2
- rebuild with rpm-4.8.1 for pkg-config file

* Sat Mar  6 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.9.3-1
- new upstream release
- built with new toolchain

* Sun Aug 30 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.9-5
- fixed %%changelog based on libzip-0.9-1vl5(VinePlus/5.0) package

* Sun Aug 30 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.9-4
- Initial build for Vine Linux

* Sat Feb 14 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 0.9-1
- initial release

