{% set version = "3.0.2" %}

package:
  name: gdal-split
  version: {{ version }}

source:
  url: http://download.osgeo.org/gdal/{{ version }}/gdal-{{ version }}.tar.xz
  sha256: c3765371ce391715c8f28bd6defbc70b57aa43341f6e94605f04fe3c92468983
  patches:
    # BUILT_AS_DYNAMIC_LIB.
    - patches/windowshdf5.patch  # [win]
    # Use multiple cores on Windows.
    - patches/multiprocessor.patch  # [win]
    # disable 12 bit jpeg on Windows as we aren't using internal jpeg
    - patches/disable_jpeg12.patch  # [win]
    # Fix missing include
    - patches/include-limits-missing.patch  # [linux]

build:
  number: 5
  # Has never been built for s390x
  skip: True  # [s390x]
  ignore_run_exports:
    - krb5  # [win]

requirements:
  build:
    - cmake  # [win]
    - pkg-config >=0.21  # [not win]
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - make  # [not win]
    - libtool  # [not win]
    - m2-patch  # [win]
    - patch  # [linux]
  host:
    - cfitsio
    - curl
    - expat
    - freexl
    - geos
    - geotiff
    - giflib  # [not win]
    - hdf4
    - hdf5
    - icu
    - jpeg
    - json-c  # [not win]
    - kealib
    - libcurl
    - libdap4  # [not win]
    - libkml
    - libnetcdf
    - libpng
    - libpq
    - libspatialite
    - libtiff
    - libuuid  # [linux]
    # exclusions due to https://bugs.launchpad.net/lxml/+bug/1928795
    - libxml2 !=2.9.11, !=2.9.12
    - m2w64-xz  # [win]
    - openjpeg
    - openssl
    - pcre
    - poppler <=0.81  # [not win]
    - postgresql
    - proj
    - sqlite
    - tiledb
    - xerces-c
    - xz  # [not win or vc>=14]
    - zlib

outputs:
  - name: libgdal
    script: install_lib.sh   # [unix]
    script: install_lib.bat  # [win]
    build:
      run_exports:
        # no idea, going with minor pin
        - {{ pin_subpackage('libgdal', max_pin='x.x') }}
      ignore_run_exports:
        - icu  # [osx or win]
        - libkml  # [win]
        - libxml2  # [win]
        - openssl  # [win]
        - pcre  # [win]
        - zstd  # [osx or win]
        - xz  # [osx or win]
        - zlib  # [osx or win]
        - krb5  # [win]
    requirements:
      build:
        # ranlib used at install time
        - {{ compiler('c') }}
        # libstdc++ is needed in requirements/run
        - {{ compiler('cxx') }}
        - pkg-config  # [not win]
        - make  # [not win]
      host:
        - cfitsio
        - curl
        - expat
        - freexl
        - geos
        - geotiff
        - giflib  # [not win]
        - hdf4
        - hdf5
        - icu
        - jpeg
        - json-c  # [not win]
        - kealib
        - krb5  # [win]
        - libcurl
        - libdap4  # [not win]
        - libiconv  # [osx]
        - libkml
        - libnetcdf
        - libpng
        - libpq
        - libspatialite
        - libtiff
        - libuuid  # [linux]
        # exclusions due to https://bugs.launchpad.net/lxml/+bug/1928795
        - libxml2 !=2.9.11, !=2.9.12
        - m2w64-xz  # [win]
        - openjpeg
        - openssl
        - pcre
        - poppler <=0.81  # [not win]
        - proj
        - sqlite
        - tiledb
        - xerces-c
        - xz  # [not win or vc>=14]
        - zlib
        - zstd
      run:
        - cfitsio
        - expat  # [win]
        - geotiff
        - giflib  # [not win]
        - hdf5  # [win]
        - json-c  # [not win]
        - krb5  # [win]
        - libdap4  # [not win]
        - libiconv  # [win]
        - libpq
        - libspatialite
        - libuuid  # [linux]
        - libwebp-base  # [linux or osx]
        - m2w64-xz  # [win]
        - poppler # [not win]
        - proj
        - tiledb
        - vs2015_runtime  # [win]
        - xerces-c  # [win]
        - xz  # [not win or vc>=14]
        - zlib
    test:
      files:
        - test_data
      commands:
        - gdal_grid --version
        - gdal_rasterize --version
        - gdal_translate --version
        - gdaladdo --version
        - gdalenhance --version
        - gdalwarp --version
        - gdalinfo --formats
        # (tkoch) this one fails often, maybe because of connectivity issues.
        #- gdalinfo http://thredds.nersc.no/thredds/dodsC/greenpath/Model/topaz  # [not win]
        - {{ RECIPE_DIR }}/run_test.bat  # [win]
        - bash {{ RECIPE_DIR }}/run_test.sh  # [not win]
    about:
      home: https://www.gdal.org
      license: MIT
      license_family: MIT
      license_file: LICENSE.TXT
      summary: The Geospatial Data Abstraction Library (GDAL)
      description: |
        GDAL is a translator library for raster and vector geospatial data formats that is released under an
        X/MIT style Open Source license by the Open Source Geospatial Foundation.
      dev_url: https://github.com/OSGeo/gdal
      doc_url: https://gdal.org/tutorials/index.html

  - name: gdal
    script: install_python.sh   # [unix]
    script: install_python.bat  # [win]
    build:
      ignore_run_exports:
        - openssl
        - hdf5
      # Doesn't build with Python 3.10 on Windows, has never been built before.
      skip: True  # [py>39 and win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - cmake  # [win]
        - make   # [not win]
      host:
        - python
        - setuptools <58.0.0
        - pip
        - numpy
        - {{ pin_subpackage('libgdal', exact=True) }}
        # openssl and hdf5 are dependencies from libgdal but are included here
        # as conda-build tried to use incompatible versions if they are not
        # explicitiy listed.  Ignore the run exports using ignore_run_exports.
        # see https://github.com/conda/conda-build/issues/3308
        - openssl
        - hdf5
      run:
        - python
        - {{ pin_compatible('numpy') }}
        - {{ pin_subpackage('libgdal', exact=True) }}
    test:
      files:
        - test_data
        - extra_tests.py
        - run_test.py
      imports:
        - osr
        - gdal
        - gdalconst
        - osgeo
        - osgeo.ogr
        - osgeo.gdal
        - osgeo._gdal
        - osgeo._gdalconst
        - osgeo._ogr
        - osgeo._osr
      commands:
        - python run_test.py
    about:
      home: https://www.gdal.org
      license: MIT
      license_family: MIT
      license_file: LICENSE.TXT
      summary: Python wrapper for the Geospatial Data Abstraction Library (GDAL)
      description: |
        GDAL is a translator library for raster and vector geospatial data formats that is released under an
        X/MIT style Open Source license by the Open Source Geospatial Foundation.
      dev_url: https://github.com/OSGeo/gdal
      doc_url: https://gdal.org/tutorials/index.html

about:
  home: https://www.gdal.org
  license: MIT
  license_family: MIT
  license_file: LICENSE.TXT
  summary: The Geospatial Data Abstraction Library (GDAL)
  description: |
    GDAL is a translator library for raster and vector geospatial data formats that is released under an
    X/MIT style Open Source license by the Open Source Geospatial Foundation.
  dev_url: https://github.com/OSGeo/gdal
  doc_url: https://gdal.org/tutorials/index.html

extra:
  recipe-maintainers:
    - gillins
    - kmuehlbauer
    - mingwandroid
    - msarahan
    - ocefpaf
