easyblock = 'ConfigureMake'

name = 'GDAL'
version = '2.1.2'
versionsuffix = '-Python-%(pyver)s'

homepage = 'http://www.gdal.org/'
description = """GDAL is a translator library for raster geospatial data formats that is released under an X/MIT style
 Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single abstract data model
 to the calling application for all supported formats. It also comes with a variety of useful commandline utilities for
 data translation and processing."""

toolchain = {'name': 'intel', 'version': '2016b'}

source_urls = ['http://download.osgeo.org/gdal/%(version)s/']
sources = [SOURCELOWER_TAR_XZ]

patches = ['GDAL-%(version)s_fix-vrtsources.patch']

dependencies = [
    ('Python', '2.7.12'),
    ('netCDF', '4.4.1.1'),
    ('expat', '2.2.0'),
    ('GEOS', '3.6.1', versionsuffix),
    ('SQLite', '3.13.0'),
    ('libxml2', '2.9.4'),
    ('libpng', '1.6.24'),
    ('libjpeg-turbo', '1.5.0'),
    ('JasPer', '1.900.1'),
    ('LibTIFF', '4.0.6'),
    ('zlib', '1.2.8'),
    ('cURL', '7.49.1'),
    ('PCRE', '8.39'),
]

configopts = '--with-expat=$EBROOTEXPAT --with-libz=$EBROOTLIBZ --with-hdf5=$EBROOTHDF5 --with-netcdf=$EBROOTNETCDF'
configopts += ' --with-xml2=$EBROOTLIBXML2 --with-geos=$EBROOTGEOS/bin/geos-config --with-jpeg=$EBROOTLIBJPEGTURBO'
configopts += ' --with-png=$EBROOTLIBPNG --with-sqlite3=$EBROOTSQLITE --with-jasper=$EBROOTJASPER'
configopts += ' --with-libtiff=$EBROOTLIBTIFF --with-pcre=$EBROOTPCRE --with-python=$EBROOTPYTHON/bin/python'
# there is a bug in the build system causing the build with libtool to fail for the moment
# (static library is also missing because of this)
configopts += ' --without-libtool'

modextrapaths = {'PYTHONPATH': 'lib/python%(pyshortver)s/site-packages'}

sanity_check_paths = {
    'files': ['lib/libgdal.%s' % SHLIB_EXT],
    'dirs': ['bin', 'include', 'lib/python%(pyshortver)s/site-packages']
}

moduleclass = 'data'
