# IT4Innovations 2020

easyblock = 'ConfigureMake'

name = 'OpenBLAS'
version = '0.2.20'

homepage = 'http://xianyi.github.com/OpenBLAS/'
description = "OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version."

toolchain = {'name': 'GCC', 'version': '8.3.0-2.32'}

local_large_src = 'large.tgz'
local_timing_src = 'timing.tgz'

source_urls = [
    # order matters, trying to download the large.tgz/timing.tgz LAPACK
    # tarballs from GitHub causes trouble
    'http://www.netlib.org/lapack/timing/',
    'https://github.com/xianyi/OpenBLAS/archive/',
]
sources = ['v%(version)s.tar.gz']
checksums = [
    '5ef38b15d9c652985774869efd548b8e3e972e1e99475c673b25537ed7bcf394',
    # v0.2.20.tar.gz (OpenBLAS)
    'f328d88b7fa97722f271d7d0cfea1c220e0f8e5ed5ff01d8ef1eb51d6f4243a1',  # large.tgz
    '999c65f8ea8bd4eac7f1c7f3463d4946917afd20a997807300fe35d70122f3af',  # timing.tgz
    # OpenBLAS-0.2.20_fix-Intel-L1-cache-size-detection.patch
    '1d043e4838ec1f90b2b49318b780e3ab13b46133cb72a8d83eb0e3b1b056c4d6',
    '1e6a046ab658c6e0b351de901d2812db28c2042f9f141416144c2faaf71fbb37',
    # OpenBLAS-0.2.20_revert-honor-cpuset.patch
]

patches = [
    (local_large_src, '.'),
    (local_timing_src, '.'),
    'OpenBLAS-%(version)s_fix-Intel-L1-cache-size-detection.patch',
    'OpenBLAS-%(version)s_revert-honor-cpuset.patch',
]

skipsteps = ['configure']

buildopts = 'BINARY=64 USE_THREAD=1 USE_OPENMP=1 CC="$CC" FC="$F77"'
installopts = "USE_THREAD=1 USE_OPENMP=1 PREFIX=%(installdir)s"

# extensive testing can be enabled by uncommenting the line below
# runtest = 'PATH=.:$PATH lapack-timing'

sanity_check_paths = {
    'files': [
        'include/cblas.h',
        'include/f77blas.h',
        'include/lapacke_config.h',
        'include/lapacke.h',
        'include/lapacke_mangling.h',
        'include/lapacke_utils.h',
        'include/openblas_config.h',
        'lib/libopenblas.a',
        'lib/libopenblas.%s' %
        SHLIB_EXT],
    'dirs': [],
}

moduleclass = 'numlib'
