File mingw64-mozilla-nss.spec of Package mingw64-mozilla-nss

#
# spec file for package mingw64-mozilla-nss
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           mingw64-mozilla-nss
Version:        3.18.1
Release:        0
Summary:        MinGW Windows port of NSS (Network Security Services)
License:        MPL-1.1 or GPL-2.0-or-later or LGPL-2.1-or-later
Group:          Development/Libraries
#!BuildIgnore: post-build-checks
Url:            http://www.mozilla.org/projects/security/pki/nss/
Source0:        nss-%{version}.tar.bz2
Source1:        nss.pc.in
Source2:        nss-config.in
Source3:        blank-cert8.db
Source4:        blank-key3.db
Source5:        blank-secmod.db
Patch0:         nss-build.patch
Patch1:         nss-3.18.1-headers.patch
BuildRequires:  mingw64-cross-binutils
BuildRequires:  mingw64-cross-gcc
BuildRequires:  mingw64-cross-pkg-config
BuildRequires:  mingw64-filesystem >= 33
BuildRequires:  mingw64-mozilla-nspr-devel >= 4.8.8
BuildRequires:  mingw64-sqlite-devel
BuildRequires:  mingw64-zlib-devel
%_mingw64_package_header_debug
BuildArch:      noarch

%description
Network Security Services (NSS) is a set of libraries designed to
support cross-platform development of security-enabled client and
server applications. Applications built with NSS can support SSL v2
and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509
v3 certificates, and other security standards.

%package devel
Summary:        MinGW Windows port of NSS (Network Security Services)
Group:          Development/Libraries

%description devel
Network Security Services (NSS) is a set of libraries designed to
support cross-platform development of security-enabled client and
server applications. Applications built with NSS can support SSL v2
and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509
v3 certificates, and other security standards.

%package tools
Summary:        MinGW Windows port of NSS (Network Security Services)
Group:          Development/Libraries

%description tools
Network Security Services (NSS) is a set of libraries designed to
support cross-platform development of security-enabled client and
server applications. Applications built with NSS can support SSL v2
and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509
v3 certificates, and other security standards.
Tools for developing, debugging, and managing applications that use NSS.

%_mingw64_debug_package

%prep
%setup -q -n nss-%{version}

%patch -P 0 -p1
%patch -P 1 -p1

%build
# Enable compiler optimizations and disable debugging code
BUILD_OPT=1
export BUILD_OPT

export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1

NSPR_INCLUDE_DIR=`%{_mingw64_target}-pkg-config --cflags-only-I nspr | sed 's/-I//'`
NSPR_LIB_DIR=`%{_mingw64_target}-pkg-config --libs-only-L nspr | sed 's/-L//'`

export NSPR_INCLUDE_DIR
export NSPR_LIB_DIR

(cd nss/coreconf/nsinstall && \
gcc -o nsinstall nsinstall.c pathsub.c)

pushd nss

%{_mingw64_make} OS_TARGET=WINNT OS_RELEASE=5.0 XP_WIN=1 \
	NSINSTALL=$(pwd)/coreconf/nsinstall/nsinstall NS_USE_GCC=1 USE_64=1 \
	NSS_USE_SYSTEM_SQLITE=1 USE_SYSTEM_ZLIB=1 ZLIB_LIBS=%{_mingw64_libdir}/libz.dll.a \
	CC=%{_mingw64_cc} RC=%{_mingw64_windres} RANLIB=%{_mingw64_ranlib}

%install

export PKG_CONFIG_PATH=%{_mingw64_libdir}/pkgconfig

# Set up our package file
mkdir -p %{buildroot}/%{_mingw64_libdir}/pkgconfig
cat %{SOURCE1} | sed -e "s,%%libdir%%,%{_mingw64_libdir},g" \
                          -e "s,%%prefix%%,%{_mingw64_prefix},g" \
                          -e "s,%%exec_prefix%%,%{_mingw64_prefix},g" \
                          -e "s,%%includedir%%,%{_mingw64_includedir}/nss3,g" \
                          -e "s,%%NSPR_VERSION%%,4\.7\.2,g" \
                          -e "s,%%NSS_VERSION%%,%{version},g" > \
                          %{buildroot}%{_mingw64_libdir}/pkgconfig/nss.pc

NSS_VMAJOR=`cat nss/lib/nss/nss.h \
	| grep "#define.*NSS_VMAJOR" \
	| awk '{print $3}'`
NSS_VMINOR=`cat nsss/lib/nss/nss.h \
	| grep "#define.*NSS_VMINOR" \
	| awk '{print $3}'`
NSS_VPATCH=`cat nss/lib/nss/nss.h \
	| grep "#define.*NSS_VPATCH" \
	| awk '{print $3}'`

export NSS_VMAJOR
export NSS_VMINOR
export NSS_VPATCH

mkdir -p %{buildroot}%{_mingw64_bindir}
cat %{SOURCE2} | sed -e "s,@libdir@,%{_mingw64_libdir},g" \
                          -e "s,@prefix@,%{_mingw64_prefix},g" \
                          -e "s,@exec_prefix@,%{_mingw64_prefix},g" \
                          -e "s,@includedir@,%{_mingw64_includedir}/nss3,g" \
                          -e "s,@MOD_MAJOR_VERSION@,$NSS_VMAJOR,g" \
                          -e "s,@MOD_MINOR_VERSION@,$NSS_VMINOR,g" \
                          -e "s,@MOD_PATCH_VERSION@,$NSS_VPATCH,g" \
                          > %{buildroot}%{_mingw64_bindir}/nss-config

chmod 755 %{buildroot}/%{_mingw64_bindir}/nss-config

# There is no make install target so we'll do it ourselves.

mkdir -p %{buildroot}/%{_mingw64_includedir}/nss3
mkdir -p %{buildroot}/%{_mingw64_bindir}
mkdir -p %{buildroot}/%{_mingw64_libdir}
mkdir -p %{buildroot}/%{_mingw64_libdir}/nss

# Copy the binary libraries we want
for file in softokn nss nssutil \
            ssl smime nssdbm
do
  install -m 755 dist/*.OBJ/lib/${file}3.dll %{buildroot}/%{_mingw64_bindir}/
  install -m 644 dist/*.OBJ/lib/lib${file}3.a %{buildroot}/%{_mingw64_libdir}/lib${file}3.dll.a
done

install -m 755 dist/*.OBJ/lib/nssckbi.dll %{buildroot}/%{_mingw64_bindir}/
install -m 755 dist/*.OBJ/lib/freebl3.dll %{buildroot}/%{_mingw64_bindir}/

# Install the empty NSS db files
mkdir -p %{buildroot}/%{_mingw64_sysconfdir}/pki/nssdb
install -m 644 %{SOURCE3} %{buildroot}/%{_mingw64_sysconfdir}/pki/nssdb/cert8.db
install -m 644 %{SOURCE4} %{buildroot}/%{_mingw64_sysconfdir}/pki/nssdb/key3.db
install -m 644 %{SOURCE5} %{buildroot}/%{_mingw64_sysconfdir}/pki/nssdb/secmod.db

# Copy the development libraries we want
for file in libcrmf.a libnssb.a libnssckfw.a
do
  install -m 644 dist/*.OBJ/lib/$file %{buildroot}/%{_mingw64_libdir}
done

# Copy the binaries we want
for file in certutil cmsutil crlutil modutil pk12util signtool signver ssltap
do
  install -m 755 dist/*.OBJ/bin/$file.exe %{buildroot}/%{_mingw64_bindir}
done

# Copy the binaries we ship as unsupported
for file in atob btoa derdump ocspclnt pp selfserv shlibsign strsclnt symkeyutil \
 tstclnt vfyserv vfychain
do
  install -m 755 dist/*.OBJ/bin/$file.exe %{buildroot}/%{_mingw64_libdir}/nss
done

# Copy the include files we want
for file in dist/public/nss/*.h
do
  install -m 644 $file %{buildroot}/%{_mingw64_includedir}/nss3
done

%files
%defattr(-,root,root)
%{_mingw64_bindir}/*.dll

%files devel
%defattr(-,root,root)
%{_mingw64_libdir}/*.a
%{_mingw64_libdir}/pkgconfig/nss.pc
%{_mingw64_bindir}/nss-config
%{_mingw64_includedir}/nss3
%{_mingw64_sysconfdir}/pki/nssdb/*.db

%files tools
%defattr(-,root,root)
%{_mingw64_bindir}/*.exe
%{_mingw64_libdir}/nss/*.exe

%changelog
openSUSE Build Service is sponsored by