##
##  nss.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_major 3
%define       V_minor 12

#   package information
Name:         nss
Summary:      Mozilla Network Security Services
URL:          http://www.mozilla.org/projects/security/pki/nss/
Vendor:       Mozilla
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Cryptography
License:      MPL
Version:      %{V_major}.%{V_minor}
Release:      20080802

#   list of sources
Source0:      ftp://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/NSS_%{V_major}_%{V_minor}_RTM/src/nss-%{version}.tar.gz
Source1:      nss.pc
Source2:      nss.sh
Patch0:       nss.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, gcc, gcc::with_cxx = yes
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  nspr
PreReq:       nspr

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

%track
    prog nss = {
        version   = %{V_major}_%{V_minor}
        url       = ftp://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/
        regex     = NSS_(__VER__)
    }

%prep
    %setup -q
    %patch -p0

%build
    ( cd mozilla/security/coreconf
      %{l_make} %{l_mflags} \
          CC="%{l_cc} %{l_cflags} %{l_cppflags nspr} %{l_ldflags nspr}" \
          TARGETS='$(LIBRARY) $(PROGRAM)' \
          USE_STATIC_LIBS=1 \
          BUILD_OPT=1
    ) || exit $?
    ( cd mozilla/security/dbm
      %{l_make} %{l_mflags} \
          CC="%{l_cc} %{l_cflags} %{l_cppflags nspr} %{l_ldflags nspr}" \
          TARGETS='$(LIBRARY) $(PROGRAM)' \
          USE_STATIC_LIBS=1 \
          BUILD_OPT=1
    ) || exit $?
    ( cd mozilla/security/nss
      %{l_make} %{l_mflags} \
          CC="%{l_cc} %{l_cflags} %{l_cppflags nspr} %{l_ldflags nspr}" \
          TARGETS='$(LIBRARY) $(PROGRAM)' \
          USE_STATIC_LIBS=1 \
          BUILD_OPT=1
    ) || exit $?

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/nss \
        $RPM_BUILD_ROOT%{l_prefix}/include/nss \
        $RPM_BUILD_ROOT%{l_prefix}/lib/nss \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
    %{l_shtool} install -c -m 644 \
        mozilla/dist/public/nss/* \
        $RPM_BUILD_ROOT%{l_prefix}/include/nss/
    %{l_shtool} install -c -m 644 \
        mozilla/dist/*.OBJ/lib/*.a \
        $RPM_BUILD_ROOT%{l_prefix}/lib/nss/
    mv  $RPM_BUILD_ROOT%{l_prefix}/lib/nss/libssl.a \
        $RPM_BUILD_ROOT%{l_prefix}/lib/nss/libnssl.a
    %{l_shtool} install -c -s -m 755 \
        mozilla/dist/*.OBJ/bin/* \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/nss/
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        -e 's;@version@;%{version};g' \
        %{SOURCE nss.pc} \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE nss.sh} \
        $RPM_BUILD_ROOT%{l_prefix}/bin/nss
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

