%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
Summary: The zlib compression and decompression library.
Summary(ja): zlib 圧縮/展開ライブラリ
Name: zlib
Version: 1.2.11
Release: 4%{?_dist_release}
Group: system
Vendor: Project Vine
Distribution: Vine Linux

License: zlib and Boost
URL: https://www.zlib.net/
Source: https://www.zlib.net/zlib-%{version}.tar.xz

# https://github.com/madler/zlib/pull/210
Patch0: zlib-1.2.5-minizip-fixuncrypt.patch
# resolves: #805113
#Patch1: zlib-1.2.11-optimized-s390.patch
# IBM Z optimalizations
Patch7: zlib-1.2.11-IBM-Z-hw-accelrated-deflate-s390x.patch
# IBM CRC32 optimalization for POWER archs
Patch8: zlib-1.2.11-optimized-CRC32-framework.patch
# fixed firefox crash + added test case
Patch9: zlib-1.2.11-firefox-crash-fix.patch
# fixed covscan issues
Patch10: zlib-1.2.11-covscan-issues.patch
# fix for IBM Z optimalizations
Patch11: zlib-1.2.11-IBM-Z-hw-accelrated-deflate-fix.patch
# permit a deflateParams() parameter change
Patch12: zlib-1.2.11-permit-deflateParams-change.patch
# fixed DFLTCC compression level switching issues
# enabled HW compression for compression levels 1 through 6
Patch13: zlib-1.2.11-IBM-DFLTCC-compression-level-switching-issues.patch
# fixed inflateSyncPoint() bad return value on z15
Patch14: zlib-1.2.11-inflateSyncPoint-return-value-fix.patch
# fixed issues found by covscan for rhel-9
# ref: https://github.com/madler/zlib/pull/554
Patch15: zlib-1.2.11-covscan-issues-rhel9.patch
# Fix for s390x vectorize CRC32
Patch16: zlib-1.2.11-s390x-vectorize-crc32.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root

%global __provides_exclude_from ^%{_libdir}/pkgconfig/.*$

%description
The zlib compression library provides in-memory compression and
decompression functions, including integrity checks of the
uncompressed data.  This version of the library supports only one
compression method (deflation), but other algorithms may be added
later, which will have the same stream interface.  The zlib library is
used by many different system programs.

%description -l ja
zlib圧縮ライブラリーは、メモリ内で圧縮と解凍を行う関数や、解凍後
のデータの整合性チェックを行う関数を提供します。今バージョンのラ
イブラリは「デフレーション（deflation）」という圧縮方法のみをサポ
ートしていますが、今後同じストリームインターフェースを持つ他の圧
縮方法も追加する予定です。zlibライブラリーは多種のプログラムで使
用されています。


%package devel
Summary: Header files and libraries for developing apps which will use zlib.
Summary(ja): zlib を使ったプログラム開発に必要なヘッダファイル/ライブラリ
Group: programming
Requires: %{name} = %{version}-%{release}
Provides: pkgconfig(zlib) = %{version}

%description devel
The zlib-devel package contains the header files and libraries needed
to develop programs that use the zlib compression and decompression
library.


%package static
Summary: Static libraries for  %{name}
Summary(ja): %{name} のスタティックライブラリ
Group: programming
Requires: %{name}-devel = %{version}-%{release}

%description static
The zlib-static package contains the static library for %{name}


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary: The zlib compression and decompression library.
Summary(ja): zlib 圧縮/展開ライブラリ
Group: system,legacy
Requires: %{name} = %{version}-%{release}

%description -n compat32-%{name}
The zlib compression library provides in-memory compression and
decompression functions, including integrity checks of the
uncompressed data.  This version of the library supports only one
compression method (deflation), but other algorithms may be added
later, which will have the same stream interface.  The zlib library is
used by many different system programs.

%description -n compat32-%{name} -l ja
zlib圧縮ライブラリーは、メモリ内で圧縮と解凍を行う関数や、解凍後
のデータの整合性チェックを行う関数を提供します。今バージョンのラ
イブラリは「デフレーション（deflation）」という圧縮方法のみをサポ
ートしていますが、今後同じストリームインターフェースを持つ他の圧
縮方法も追加する予定です。zlibライブラリーは多種のプログラムで使
用されています。


%package -n compat32-%{name}-devel
Summary: Header files and libraries for developing apps which will use zlib.
Summary(ja): zlib を使ったプログラム開発に必要なヘッダファイル/ライブラリ
Group: programming,legacy
Requires: %{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}-%{release}

%description -n compat32-%{name}-devel
The zlib-devel package contains the header files and libraries needed
to develop programs that use the zlib compression and decompression
library.

Install the zlib-devel package if you want to develop applications that
will use the zlib library.


%debug_package


%prep
%setup -q
%autopatch -p1


%build
mkdir static shared

export CFLAGS="$RPM_OPT_FLAGS -fPIC"
export LDFLAGS="$LDFLAGS -Wl,-z,relro -Wl,-z,now"

# build shared lib
CFLAGS="$RPM_OPT_FLAGS -fPIC" ./configure --shared --prefix=%{_prefix}

./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--includedir=%{_includedir} \
	--shared

make %{?_smp_mflags}
%ifarch x86_64
make test
%endif
mv -f Makefile zconf.h *.o *.so* shared/

# build static lib
./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--includedir=%{_includedir}

make %{?_smp_mflags}
%ifarch x86_64
make test
%endif
mv -f Makefile zconf.h *.o *.a static/


%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{_prefix}

mv -f shared/* .
%make_install

mv -f Makefile zconf.h *.o *.so* shared/
mv -f static/* .
%make_install

install -m644 zutil.h ${RPM_BUILD_ROOT}%{_includedir}/zutil.h
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man3
install -m644 zlib.3 ${RPM_BUILD_ROOT}%{_mandir}/man3

cat %{buildroot}/usr/include/zlib.h | sed -n '1,/*\//p' > LICENSE


%clean
rm -rf ${RPM_BUILD_ROOT}


%files
%defattr(-,root,root)
%license LICENSE
%doc README
%{_libdir}/*.so
%{_libdir}/libz.so.*

%files devel
%defattr(-,root,root)
%doc ChangeLog doc/algorithm.txt
%{_libdir}/pkgconfig/zlib.pc
%{_includedir}/*
%{_mandir}/man3/zlib.3*

%files static
%defattr(-,root,root)
%{_libdir}/*.a

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

%files -n compat32-%{name}-devel
%defattr(-,root,root)
%{_libdir}/*.so
%{_libdir}/pkgconfig/zlib.pc
%endif


%changelog
* Tue Aug 17 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.2.11-4
- rebuilt with current environment.
- dropped ldconfig scriptlets.
- imported all patches from rawhide.

* Sun Mar 29 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.2.11-3
- fixed "Provides:".

* Sat Mar 21 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.2.11-2
- dropped "Provides:pkgconfig(zlib)" from compat32-zlib-devel.

* Wed Jan 02 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.2.11-1
- new upstream release.
- added license text.
- reverted moving libz.so for compat32 package.

* Sat Mar 19 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.2.8-2
- moved libz.so into the main package.

* Fri Mar 21 2014 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.2.8-1
- new upstream release
- changed archive type bz2 to xz

* Fri Oct 19 2012 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> - 1.2.7-1
- new upstream release
- drop patch0 (resolved by upstream)
- use smp flag in make section

* Fri Oct 1 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.2.5-2
- added patch0 from gentoo to fix zlib.h errors on i686 compiling some applications

* Wed Sep 22 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 1.2.5-1
- new upstream release (built with rpm-4.8.1-1 for pkg-config file)
- changed License: BSD to zlib and Boost
- added %%{_libdir}/pkgconfig/zlib.pc in -devel package
- fixed %%doc files in -devel package

* Fri Mar 05 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2.3-7
- add Requires(post,pre): /sbin/ldconfig

* Fri Feb 12 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2.3-6
- rebuilt with gcc-4.4.3-3 on ppc

* Mon Feb  8 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.2.3-5
- rebuilt with new toolchain

* Fri Mar 27 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2.3-4
- split static library to zlib-static
  - needed by tuxonice-userui

* Wed Dec 17 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 1.2.3-3
- change spec into UTF-8

* Sun May 18 2008 NAKAMURA Kenta <kenta@vinelinux.org> 1.2.3-2
- removed %%if !%%{build_compat32} case condition

* Sat May 17 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2.3-1
- applied new versioning policy
- rebuilt with new toolchains

* Mon Feb 06 2006 Shu KONNO <owa@bg.wakwak.com> 1.2.3-0vl5
- moved macros _lib to /usr/lib/rpm/rpmrc or macros files

* Fri Feb 03 2006 Shu KONNO <owa@bg.wakwak.com> 1.2.3-0vl4
- added compat32-* packages for x86_64 architecture support

* Tue Oct 25 2005 NAKAMURA Kenta <kenta@c.csce.kyushu-u.ac.jp> 1.2.3-0vl3
- added compat32- packages for x86_64 architecture support

* Tue Oct 25 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2.3-0vl2
- clean up specfile (do not build twice..)

* Tue Jul 19 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2.3-0vl1
- new upstream release

* Sun Jul 10 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2.2.2-0vl1
- new upstream release
- add Patch1 for CAN-2005-2096

* Fri Mar 25 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2.2-0vl1
- new upstream version
- add translated descriptions (thanks to spec file translation project)

* Sun Apr 06 2003 Satoshi MACHINO <machino@vinelinux.org> 1.1.4-0vl3
- fixed buffer overrun on gzprintf
	-- added zlib-1.1.4-vsnprintf.patch from http://archives.neohapsis.com/archives/bugtraq/2003-02/0290.html

* Fri Sep 20 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.1.4-0vl2
- changed URL to more preferable site

* Tue Mar 12 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 1.1.4-0vl1
- upstream release

* Tue Dec 26 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.1.3-14vl1
- based on 1.1.3-14 from Rawhide
- added Japanese summary

* Fri Sep 15 2000 Florian La Roche <Florian.LaRoche@redhat.de>
- add -fPIC for shared libs (patch by Fritz Elfert)

* Thu Sep  7 2000 Jeff Johnson <jbj@redhat.com>
- on 64bit systems, make sure libraries are located correctly.

* Thu Aug 17 2000 Jeff Johnson <jbj@redhat.com>
- summaries from specspo.

* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Sun Jul 02 2000 Trond Eivind Glomsr <teg@redhat.com>
- rebuild

* Tue Jun 13 2000 Jeff Johnson <jbj@redhat.com>
- FHS packaging to build on solaris2.5.1.

* Wed Jun 07 2000 Trond Eivind Glomsr <teg@redhat.com>
- use %%{_mandir} and %%{_tmppath}

* Fri May 12 2000 Trond Eivind Glomsr <teg@redhat.com>
- updated URL and source location
- moved README to main package

* Mon Feb  7 2000 Jeff Johnson <jbj@redhat.com>
- compress man page.

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 5)

* Wed Sep 09 1998 Cristian Gafton <gafton@redhat.com>
- link against glibc

* Mon Jul 27 1998 Jeff Johnson <jbj@redhat.com>
- upgrade to 1.1.3

* Fri May 08 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Wed Apr 08 1998 Cristian Gafton <gafton@redhat.com>
- upgraded to 1.1.2
- buildroot

* Tue Oct 07 1997 Donnie Barnes <djb@redhat.com>
- added URL tag (down at the moment so it may not be correct)
- made zlib-devel require zlib

* Thu Jun 19 1997 Erik Troan <ewt@redhat.com>
- built against glibc
