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

Summary:	Netscape Portable Runtime
Summary(ja):    Netscape ポータブルランタイム
Name:		nspr
Version:	4.22
Release:	1%{?_dist_release}
License:	MPLv2.0
URL:		http://www.mozilla.org/projects/nspr/
Group:		System Environment/Libraries
Source0:	https://archive.mozilla.org/pub/nspr/releases/v%{version}/src/%{name}-%{version}.tar.gz

Patch1:		nspr-config-pc.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Provides:	mozilla-nspr
Obsoletes:	mozilla-nspr

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

%description
NSPR provides platform independence for non-GUI operating system 
facilities. These facilities include threads, thread synchronization, 
normal file and network I/O, interval timing and calendar time, basic 
memory management (malloc and free) and shared library linking.

%package devel
Summary:	Development libraries for the Netscape Portable Runtime
Group:		Development/Libraries
Requires:	nspr = %{version}-%{release}
Requires:       pkgconfig
Provides:	mozilla-nspr-devel
Obsoletes:	mozilla-nspr-devel

%description devel
Header files for doing development with the Netscape Portable Runtime.


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary:	Netscape Portable Runtime
Group: System Environment/Libraries

%description -n compat32-%{name}
NSPR provides platform independence for non-GUI operating system 
facilities. These facilities include threads, thread synchronization, 
normal file and network I/O, interval timing and calendar time, basic 
memory management (malloc and free) and shared library linking.



%prep

%setup -q

# Original nspr-config is not suitable for our distribution,
# because on different platforms it contains different dynamic content.
# Therefore we produce an adjusted copy of nspr-config that will be 
# identical on all platforms.
# However, we need to use original nspr-config to produce some variables
# that go into nspr.pc for pkg-config.

cp ./nspr/config/nspr-config.in ./nspr/config/nspr-config-pc.in
%patch1 -p0

%build

LDFLAGS+=-Wl,-z,relro
export LDFLAGS

%define _configure ./nspr/configure
%configure \
                 --prefix=%{_prefix} \
                 --libdir=%{_libdir} \
                 --includedir=%{_includedir}/nspr4 \
%ifarch x86_64 ppc64 ia64 s390x
                 --enable-64bit \
%endif
                 --enable-optimize="$RPM_OPT_FLAGS" \
                 --disable-debug

make

%install

%{__rm} -Rf $RPM_BUILD_ROOT

DESTDIR=$RPM_BUILD_ROOT \
  make install

mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1

NSPR_LIBS=`./config/nspr-config --libs`
NSPR_CFLAGS=`./config/nspr-config --cflags`
NSPR_VERSION=`./config/nspr-config --version`
%{__mkdir_p} $RPM_BUILD_ROOT/%{_libdir}/pkgconfig

# Get rid of the things we don't want installed (per upstream)
%{__rm} -rf \
   $RPM_BUILD_ROOT/%{_bindir}/compile-et.pl \
   $RPM_BUILD_ROOT/%{_bindir}/prerr.properties \
   $RPM_BUILD_ROOT/%{_libdir}/libnspr4.a \
   $RPM_BUILD_ROOT/%{_libdir}/libplc4.a \
   $RPM_BUILD_ROOT/%{_libdir}/libplds4.a \
   $RPM_BUILD_ROOT/%{_datadir}/aclocal/nspr.m4 \
   $RPM_BUILD_ROOT/%{_includedir}/nspr4/md

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%post
/sbin/ldconfig >/dev/null 2>/dev/null

%postun
/sbin/ldconfig >/dev/null 2>/dev/null

%files
%defattr(-,root,root)
%{_libdir}/libnspr4.so
%{_libdir}/libplc4.so
%{_libdir}/libplds4.so

%files devel
%defattr(-, root, root)
%{_includedir}/nspr4
%{_libdir}/pkgconfig/nspr.pc
%{_bindir}/nspr-config

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


%changelog
* Fri Sep 27 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.22-1
- update to 4.22.

* Thu Nov 08 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.20-1
- update to 4.20.
- dropped Patch2.

* Sat Oct 07 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.13.1-1
- update to 4.13.1.

* Tue May 10 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.11-1
- update to 4.11

* Thu Jun 12 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 4.10.6-1
- update to 4.10.6

* Thu Oct 17 2013 Daisuke SUZUKI <daisuke@linux.or.jp> 4.10.1-1
- update to 4.10.1

* Thu Apr 04 2013 Daisuke SUZUKI <daisuke@linux.or.jp> 4.9.6-1
- update to 4.9.6

* Wed Jan 09 2013 Daisuke SUZUKI <daisuke@linux.or.jp> 4.9.4-1
- update to 4.9.4

* Mon Sep 03 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 4.9.2
- new upstream release

* Sun Mar 18 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.9-1
- new upstram release
- update Patch1 (nspr-config-pc.patch)

* Wed Sep 28 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 4.8.9-1
- new upstram release

* Wed Jun 01 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 4.8.8-1
- new upstream release

* Mon Mar 28 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 4.8.7-1
- new upstream release

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

* Tue Sep 14 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 4.8.6-1
- new upstream release

* Wed Apr  7 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 4.8.4-1
- new upstream release

* Sat Jan 09 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 4.8.2-1
- new upstream release

* Sat Jul 04 2009 Munehiro Yamamoto <munepi@cg8.so-net.ne.jp> 4.8-2
- added compat32 subpackages

* Sun Jun 21 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.8-1
- new upstream release

* Wed Apr 22 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 4.7.4-1
- new upstream release

* Wed Jul 02 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 4.7.1-1
- new upstream release

* Fri Oct 19 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 4.6.7-0vl1
- new upstream release

* Fri May 18 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 4.6.6-0vl1
- initial build for Vine Linux

* Wed Mar 07 2007 Kai Engert <kengert@redhat.com> - 4.6.6-1
- Update to 4.6.6
- Adjust IPv6 patch to latest upstream version

* Sat Feb 24 2007 Kai Engert <kengert@redhat.com> - 4.6.5-2
- Update to latest ipv6 upstream patch
- Add upstream patch to fix a thread cleanup issue
- Now requires pkgconfig

* Mon Jan 22 2007 Wan-Teh Chang <wtchang@redhat.com> - 4.6.5-1
- Update to 4.6.5

* Tue Jan 16 2007 Kai Engert <kengert@redhat.com> - 4.6.4-2
- Include upstream patch to fix ipv6 support (rhbz 222554)

* Tue Nov 21 2006 Kai Engert <kengert@redhat.com> - 4.6.4-1
- Update to 4.6.4

* Thu Sep 14 2006 Kai Engert <kengert@redhat.com> - 4.6.3-1
- Update to 4.6.3

* Wed Jul 12 2006 Jesse Keating <jkeating@redhat.com> - 4.6.2-1.1
- rebuild

* Fri May 26 2006 Kai Engert <kengert@redhat.com> - 4.6.2-1
- Update to 4.6.2
- Tweak nspr-config to be identical on all platforms.

* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 4.6.1-2.2
- bump again for double-long bug on ppc(64)

* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> - 4.6.1-2.1
- rebuilt for new gcc4.1 snapshot and glibc changes

* Thu Jan  5 2006 Kai Engert <kengert@redhat.com> 4.6.1-2
- Do not use -ansi when compiling, because of a compilation
  problem with latest glibc and anonymous unions.
  See also bugzilla.mozilla.org # 322427.

* Wed Jan  4 2006 Kai Engert <kengert@redhat.com>
- Add an upstream patch to fix gcc visibility issues.

* Tue Jan  3 2006 Christopher Aillon <caillon@redhat.com>
- Stop shipping static libraries; NSS and dependencies no longer
  require static libraries to build.

* Thu Dec 15 2005 Christopher Aillon <caillon@redhat.com> 4.6.1-1
- Update to 4.6.1

* Fri Dec 09 2005 Jesse Keating <jkeating@redhat.com>
- rebuilt

* Fri Jul 15 2005 Christopher Aillon <caillon@redhat.com> 4.6-4
- Use the NSPR version numbering scheme reported by NSPR,
  which unfortunately is not exactly the same as the real
  version (4.6 != 4.6.0 according to RPM and pkgconfig).

* Fri Jul 15 2005 Christopher Aillon <caillon@redhat.com> 4.6-3
- Correct the CFLAGS reported by pkgconfig

* Tue Jul 12 2005 Christopher Aillon <caillon@redhat.com> 4.6-2
- Temporarily include the static libraries allowing nss and 
  its dependencies to build. 

* Tue Jul 12 2005 Christopher Aillon <caillon@redhat.com> 4.6-1
- Update to NSPR 4.6

* Wed Apr 20 2005 Christopher Aillon <caillon@redhat.com> 4.4.1-2
- NSPR doesn't have make install, but it has make real_install.  Use it.

* Thu Apr 14 2005 Christopher Aillon <caillon@redhat.com> 4.4.1-1
- Let's make an RPM.
