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

Summary: Perl-compatible regular expression library
Summary(ja): Perl 互換の正規表現ライブラリ
Name: pcre2
Version: 10.42
Release: 1%{?_dist_release}
Group: system
Vendor: Project Vine
Distribution: Vine Linux
Packager: inagaki

License: BSD
URL: https://www.pcre.org/
Source0: https://github.com/PhilipHazel/pcre2/releases/download/pcre2-%{version}/pcre2-%{version}.tar.bz2
# Upstream thinks RPATH is good idea.
Patch0: pcre2-10.31-multilib.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: zlib-devel
BuildRequires: bzip2-devel
BuildRequires: libedit-devel
# New libtool to get rid of rpath
BuildRequires: autoconf, automake, libtool

%description
Perl-compatible regular expression library.
PCRE has its own native API, but a set of "wrapper" functions that are based on
the POSIX API are also supplied in the library libpcreposix. Note that this
just provides a POSIX calling interface to PCRE: the regular expressions
themselves still follow Perl syntax and semantics. The header file
for the POSIX-style functions is called pcreposix.h.


%package devel
Summary: Development files for %{name}
Summary(ja): %{name} の開発用ファイル
Group: programming
Requires: %{name} = %{version}-%{release}

%description devel
Development files (Headers, libraries for static linking, etc) for %{name}.


%package -n compat32-%{name}
Summary: Perl-compatible regular expression library
Summary(ja): Perl 互換の正規表現ライブラリ
Group: system,legacy

%description -n compat32-%{name}
Perl-compatible regular expression library.
PCRE has its own native API, but a set of "wrapper" functions that are based on
the POSIX API are also supplied in the library libpcreposix. Note that this
just provides a POSIX calling interface to PCRE: the regular expressions
themselves still follow Perl syntax and semantics. The header file
for the POSIX-style functions is called pcreposix.h.


%package -n compat32-%{name}-devel
Summary: Development files for %{name}
Summary(ja): %{name} の開発用ファイル
Group: programming,legacy
Requires: compat32-%{name} = %{version}-%{release}

%description -n compat32-%{name}-devel
Development files (Headers, libraries for static linking, etc) for %{name}.


%debug_package


%prep
%setup -q
# Get rid of rpath
%patch0 -p1 -b .multilib
# Because of rpath patch
libtoolize --copy --force && autoreconf -vif
# One contributor's name is non-UTF-8
for F in ChangeLog; do
    iconv -f latin1 -t utf8 "$F" >"${F}.utf8"
    touch --reference "$F" "${F}.utf8"
    mv "${F}.utf8" "$F"
done


%build
%configure \
    --enable-jit \
    --disable-static \
    --enable-utf8 \
    --enable-unicode-properties \
    --enable-pcregrep-libz \
    --enable-pcregrep-libbz2 \
    --enable-pcretest-libedit \
    --enable-pcre2-8 \
    --enable-pcre2-16 \
    --enable-pcre2-32

make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

rm -rf $RPM_BUILD_ROOT%{_datadir}/doc
rm -f $RPM_BUILD_ROOT%{_libdir}/lib*.la


%check
%ifarch s390 s390x ppc
# larger stack is needed on s390, ppc
ulimit -s 10240
%endif
make %{?_smp_mflags} check VERBOSE=yes


%clean
rm -rf $RPM_BUILD_ROOT 


%files
%defattr(-,root,root)
%license COPYING LICENCE
%doc AUTHORS ChangeLog NEWS README
%{_bindir}/pcre2grep
%{_libdir}/*.so.*
%{_mandir}/man1/pcre2grep.*

%files devel
%defattr(-,root,root)
%doc doc/html/*
%{_bindir}/pcre2-config
%{_bindir}/pcre2test
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%{_mandir}/man1/pcre2-config.*
%{_mandir}/man1/pcre2test.*
%{_mandir}/man3/*

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

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


%changelog
* Tue Dec 13 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.42-1
- new upstream release.

* Wed Dec 07 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.41-1
- new upstream release.

* Sat Apr 16 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.40-1
- new upstream release.

* Sat Oct 30 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.39-1
- new upstream release.

* Wed Oct 27 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.38-1
- new upstream release.

* Mon Jul 26 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.37-1
- new upstream release.
- dropped ldconfig scriptletes.

* Mon Feb 22 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.36-1
- new upstream release.

* Thu Oct 08 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.35-1
- new upstream release.

* Sun Mar 08 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 10.34-1
- new upstream release.

* Sun May 20 2018 IWAI, Masaharu <iwaim.sub@gmail.com> 10.31-1
- new: pcre2 package
- update multilib patch (Patch0)
- drop unnecessary patch (Patch1)

* Fri Jul 29 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 8.39-2
- create comapt32 packages

* Thu Jun 30 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 8.39-1
- new upstream release.
- dropped Patch1000,1001: fixed in upstream.

* Wed Mar 23 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 8.38-1
- new upstream release.
- removed Patch2,Patch3 (no longer needed).
- added Patch1000 to fix CVE-2016-1283.

* Sun Apr  5 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 8.36-1
- new upstream release 
- added patches including security fix from Fedora (CVE-2014-8964) 
* Thu Nov 20 2014 Petr Pisar <ppisar@redhat.com> - 8.36-3
  - Fix CVE-2014-8964 (unused memory usage on zero-repeat assertion condition)
    (bug #1165626)
  * Fri Nov 07 2014 Petr Pisar <ppisar@redhat.com> - 8.36-2
  - Reset non-matched groups within capturing group up to forced match
    (bug #1161587)
  * Mon May 09 2011 Petr Pisar <ppisar@redhat.com> - 8.12-3
  - Fix typos in manual pages (bugs #675476, #675477)

* Thu Sep 11 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 8.35-1
- new upstream release 
- add --enable-pcre32 and --enable-pcretest-libedit

* Wed Oct 24 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 8.31-1
- new upstream release 
- add --enable-pcre16 --enable-pcre8 --enable-jit
- API change
- change includedir to /usr/include

* Sat Sep 10 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 8.13-1
- new upstream release

* Tue Mar 22 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 8.12-1
- new upstream release

* Mon Sep 27 2010 Shu KONNO <owa@bg.wakwak.com> 8.10-2
- rebuilt with rpm-4.8.1 for pkg-config

* Thu Aug 19 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 8.10-1
- new upstream release

* Mon May 10 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 8.02-1
- new upstream release with security fix

* Sat Feb  6 2010 Ryoiochi INAGAKI <ryo1@bc.wakwak.com> 8.01-1
- new upstream release

* Sat Jan 16 2010 Ryoiochi INAGAKI <ryo1@bc.wakwak.com> 8.00-1
- new upstream release

* Tue Jul 07 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 7.9-2
- add --enable-unicode-properties to configure option

* Wed Jun 10 2009 Ryoiochi INAGAKI <ryo1@bc.wakwak.com> 7.9-1
- new upstream release
- added BR: zlib-devel, bzip2-devel
- removed static libraries from devel package
- added Packager tag

* Sat Jan 24 2009 Ryoiochi INAGAKI <ryo1@bc.wakwak.com> 7.8-1vl5
- new upstream release
- spec in UTF-8

* Sun Jul  6 2008 Ryoiochi INAGAKI <ryo1@bc.wakwak.com> 7.7-1vl5
- new upstream release

* Tue May 13 2008 Yasumichi Akahoshi <yasumichi@vinelinux.org> 7.6-1vl5
- use macro for Release

* Fri May 09 2008 Yasumichi Akahoshi <yasumichi@vinelinux.org> 7.6-1vl5
- apply new virsioning policy.
- remove *.la

* Thu Feb  7 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 7.6-0vl1
- new upstream release

* Wed Nov  7 2007 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 7.4-0vl1
- new upstream release

* Sun Aug 19 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 7.2-0vl1
- new upstream release

* Fri May 11 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 6.6-0vl2
- rebuild with new environment/toolchain

* Wed Feb 15 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.6-0vl1
- new upstream release

* Mon Sep  5 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.3-0vl2
- added --enable-utf8 option

* Sun Sep  4 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.3-0vl1
- new upstream release

* Thu Jan 27 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 5.0-0vl1
- new upstream release
- added Japanese summary

* Sun Apr 18 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 4.5-0vl1
- new upstream release

* Mon Oct 13 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.4-0vl1
- new upstream release

* Mon May  5 2003 Tomoya TAKA <taka@vinelinux.org> 4.1-0vl3
- skip 'make check' on alpha

* Fri Mar 28 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.1-0vl2
- change install section
- change files section

* Fri Mar 28 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 4.1-0vl1
- update to 4.1
- add %{_bindir}/pcretest
- add %doc AUTHORS COPYING ChangeLog INSTALL LICENCE NEWS README

* Sun Dec 15 2002 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 3.9-0vl2
- rebuild with new toolchains

* Sat Mar 16 2002 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 3.9-0vl1
- Update to 3.9

* Wed Dec 26 2001 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 3.7-0vl1
- Update to 3.7

* Sun Oct 14 2001 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 3.5-0vl1
- Update to 3.5

* Wed Oct 10 2001 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 3.4-2vl1
- Build for VineSeed

* Thu May 17 2001 Bernhard Rosenkraenzer <bero@redhat.com> 3.4-2
- Move libpcre to /lib, grep uses it these days (#41104)

* Wed Apr 18 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- Move this to a separate package, used to be in kdesupport, but it's
  generally useful...
