{% set version = "5.10.1" %}

package:
  name: suitesparse
  version: {{ version }}

source:
  - url: https://github.com/continuumIO/suitesparse-metis-for-windows/archive/master.zip   # [win]
    fn: suitesparse_cmake_setup.zip                                                      # [win]
  - url: https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v{{ version }}.tar.gz
    sha256: acb4d1045f48a237e70294b950153e48dce5b5f9ca8190e86c2b8c54ce00a7ee
    patches:
      - 0001-only-build-UMFPACK-library.patch
    # nest folder on Windows so that it clobbers the older stuff from the cmake build that vendors it
    folder: SuiteSparse-to-move                              # [win]

build:
  number: 2
  skip: True  # [blas_impl == 'openblas' and win]
  skip: True  # [s390x]
  run_exports:
    - {{ pin_subpackage("suitesparse") }}

requirements:
  build:
    - {{ compiler("c") }}
    - {{ compiler("cxx") }}
    - cmake
    - make  # [unix]
    - ninja  # [win]
    - patch     # [not win]
    - m2-patch  # [win]
  host:
    - metis
    - mkl-devel  {{ mkl }}           # [blas_impl == 'mkl']
    - openblas-devel {{ openblas }}  # [blas_impl == "openblas"]
    # required ABI/API was deprecated in later version
    - tbb-devel  <2021.1
    - mpfr
    - gmp        # [not win]
  run:
    - metis
    - gmp        # [not win]
test:
  commands:
    {% if unix %}
    - test -f ${PREFIX}/lib/libamd${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libbtf${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libcamd${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libccolamd${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libcholmod${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libcolamd${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libcxsparse${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libklu${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libldl${SHLIB_EXT}
    - test -f ${PREFIX}/lib/librbio${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libspqr${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libsuitesparseconfig${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libumfpack${SHLIB_EXT}
    - test -f ${PREFIX}/lib/libamd.a
    - test -f ${PREFIX}/lib/libbtf.a
    - test -f ${PREFIX}/lib/libcamd.a
    - test -f ${PREFIX}/lib/libccolamd.a
    - test -f ${PREFIX}/lib/libcholmod.a
    - test -f ${PREFIX}/lib/libcolamd.a
    - test -f ${PREFIX}/lib/libcxsparse.a
    - test -f ${PREFIX}/lib/libklu.a
    - test -f ${PREFIX}/lib/libldl.a
    - test -f ${PREFIX}/lib/librbio.a
    - test -f ${PREFIX}/lib/libspqr.a
    - test -f ${PREFIX}/lib/libsuitesparseconfig.a
    - test -f ${PREFIX}/lib/libumfpack.a
    {% else %}
    - IF NOT EXIST %LIBRARY_LIB%\amd.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\btf.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\camd.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\ccolamd.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\cholmod.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\colamd.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\cxsparse.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\klu.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\ldl.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\spqr.lib exit 1
    - IF NOT EXIST %LIBRARY_LIB%\umfpack.lib exit 1
    {% endif %}

about:
  home: http://faculty.cse.tamu.edu/davis/suitesparse.html
  license: LGPL v2 (AMD, BTF, etc), BSD 3-clause (UFget), GPL v2 (UMFPACK, RBIO, SPQR, GPUQRENGINE), Apache 2.0 (Metis)
  summary: A suite of sparse matrix algorithms

extra:
  recipe-maintainers:
    - grlee77
    - jakirkham
    - basnijholt
