# IT4Innovation
# BS

easyblock = 'MakeCp'

name = 'NSS'
version = '3.57'

homepage = 'https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS'
description = """Network Security Services (NSS) is a set of libraries designed to support cross-platform development
 of security-enabled client and server applications."""

toolchain = {'name': 'GCCcore', 'version': '10.2.0'}

source_urls = ['https://ftp.mozilla.org/pub/security/nss/releases/NSS_%(version_major)s_%(version_minor)s_RTM/src/']
sources = [SOURCELOWER_TAR_GZ]
patches = [
    'NSS-3.39_pkgconfig.patch',
    'NSS-3.42.1_CVE-2021-43527.patch',
]
checksums = [
    '55a86c01be860381d64bb4e5b94eb198df9b0f098a8af0e58c014df398bdc382',  # nss-3.57.tar.gz
    '5c4b55842e5afd1e8e67b90635f6474510b89242963c4ac2622d3e3da9062774',  # NSS-3.39_pkgconfig.patch
    'cc17945edcc8f6d951e8710a4e99604439a1758e38539d1b7b8c0cd95ac59355',  # NSS-3.42.1_CVE-2021-43527.patch
]

builddependencies = [('binutils', '2.35')]
dependencies = [
    ('NSPR', '4.29'),
    ('zlib', '1.2.11'),
]

# building in parallel fails
parallel = 1

# fix for not being able to find header files
buildopts = 'BUILD_OPT=1 USE_64=1 CPATH="$EBROOTNSPR/include/nspr:$CPATH" NSS_ENABLE_WERROR=0 '
# fix c standard causing missing functions
buildopts += 'OS_REL_CFLAGS="-D_XOPEN_SOURCE " && '
# also install pkgconfig file (see patch)
buildopts += "cd config && make PREFIX=%(installdir)s BUILD_OPT=1 USE_64=1 && cd -"
# optional testsuite (takes a long time)
# buildopts += " && cd %(builddir)s/%(namelower)s-%(version)s/%(namelower)s/tests && BUILD_OPT=1 USE_64=1 ./all.sh "

files_to_copy = ['../dist/Linux*.OBJ/*', (['../dist/public/*'], 'include')]

sanity_check_paths = {
    'files': ['bin/nss-config', 'bin/multinit', 'lib/libnss.a'],
    'dirs': ['include/dbm', 'include/nss'],
}

sanity_check_commands = [
    "multinit --help",
    "nss-config --version",
]

modextrapaths = {'CPATH': 'include/nss'}

moduleclass = 'lib'
