easyblock = 'CMakeMake'

name = 'g2clib'
version = '2.2.0'

homepage = 'https://github.com/NOAA-EMC/NCEPLIBS-g2c'
description = """Library contains GRIB2 encoder/decoder ('C' version)."""

toolchain = {'name': 'GCCcore', 'version': '13.3.0'}
toolchainopts = {'pic': True}

source_urls = ['https://github.com/NOAA-EMC/NCEPLIBS-g2c/archive/refs/tags/']
sources = ['v%(version)s.tar.gz']
checksums = ['cf0ac8f75aed662ccc64f4c44fbe46a70307bc27cbe95417fdfb6caf75245457']

builddependencies = [
    ('binutils', '2.42'),
    ('CMake', '3.29.3'),
]

dependencies = [
    ('JasPer', '4.2.4'),
    ('libaec', '1.1.3'),
    ('libpng', '1.6.43'),
    ('libjpeg-turbo', '3.0.1'),
    ('zlib', '1.3.1'),
]

# Symlink libg2c to libgrib2c
postinstallcmds = ['cd %(installdir)s/lib && for l in libg2c{.,_,w}*; do ln -s "${l}" "${l/g2c/grib2c}"; done']

sanity_check_paths = {
    'files': ['lib/libg2c.%s' % SHLIB_EXT],
    'dirs': ['include'],
}

moduleclass = 'data'
