easyblock = 'CMakeMake'

name = 'grib_api'
version = '1.28.0'

homepage = 'https://software.ecmwf.int/wiki/display/GRIB/Home'
description = """The ECMWF GRIB API is an application program interface accessible from C, FORTRAN and Python
 programs developed for encoding and decoding WMO FM-92 GRIB edition 1 and edition 2 messages. A useful set of
 command line tools is also provided to give quick access to GRIB messages."""

toolchain = {'name': 'iimpi', 'version': '2019b'}
toolchainopts = {'pic': True, 'usempi': True}

source_urls = ['https://confluence.ecmwf.int/download/attachments/3473437/']
sources = ['grib_api-%(version)s-Source.tar.gz']

builddependencies = [('CMake', '3.15.3')]
dependencies = [
    ('netCDF', '4.7.1'),
    ('Python', '2.7.16'),
    ('libjpeg-turbo', '2.0.3'),
    ('libpng', '1.6.37'),
    #('JasPer', '2.0.14'),
    ('JasPer', '1.900.1'),  # 2.x doesn't work
]

separate_build_dir = True

configopts = '-DENABLE_JPG=ON'
configopts += '-DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS="-std=c++11 -pthread" -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -lpthread"'

sanity_check_paths = {
    'files': ['lib/libgrib_api_f90.so'],
    'dirs': ['share/grib_api/definitions/grib1'],
}

moduleclass = 'data'
