{% set version = "0.2.20" %}

package:
  name: openblas_multipkg
  version: {{ version }}

source:
  fn: openblas-{{ version }}.tar.gz
  url: https://github.com/xianyi/OpenBLAS/archive/v{{ version }}.tar.gz
  sha256: 5ef38b15d9c652985774869efd548b8e3e972e1e99475c673b25537ed7bcf394
  patches:
    - gh_1247.patch
    - gh_1259.patch
    - gh_1256.patch
    - gh_1264.patch
    - gh_1279.patch
    - gh_1323.patch
    # this one is failing to apply on win right now.
    - gh_1350.patch  # [unix]
    - gh_1377.patch
    - gh_1417.patch

build:
  number: 7

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('fortran') }}
    # libgcc-ng should be a dependecy of libgfortran
    # until this is fixed add libgcc explicitly
    - libgcc-ng  # [linux]
    - make       # [unix]
    - jom        # [win]
    - cmake      # [win]

outputs:

  - name: libopenblas
    files:
      - lib/libblas.so          # [linux]
      - lib/libblas.dylib       # [osx]
      - lib/libcblas.so         # [linux]
      - lib/libcblas.dylib      # [osx]
      - lib/liblapack.so        # [linux]
      - lib/liblapack.dylib     # [osx]
      - lib/libopenblas*.so*    # [linux]
      - lib/libopenblas*.dylib  # [osx]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('fortran') }}
        # libgcc-ng should be a dependecy of libgfortran
        # until this is fixed add libgcc explicitly
        - libgcc-ng  # [linux]
    test:
      requires:
        - python      # [unix]
      commands:
        - python -c "import ctypes; ctypes.cdll['${PREFIX}/lib/libopenblas${SHLIB_EXT}']"  # [unix]
        - if not exist %PREFIX%\\Library\\lib\\openblas.lib exit 1    # [win]
    about:
      home: http://www.openblas.net/
      license: BSD
      license_file: LICENSE
      summary: An Optimized BLAS library
      description: |
        OpenBLAS is based on GotoBLAS2 1.13 BSD version.
      doc_url: http://www.openblas.net/
      doc_source_url: https://github.com/xianyi/OpenBLAS/blob/develop/README.md
      dev_url: https://github.com/xianyi/OpenBLAS

  - name: libopenblas-static
    files:
      - lib/libblas.a
      - lib/libcblas.a
      - lib/liblapack.a
      - lib/libopenblas*.a
    test:
      commands:
        - test -f ${PREFIX}/lib/libopenblas.a                            # [unix]
    about:
      summary: OpenBLAS static libraries.

  - name: openblas-devel
    files:
      - include/cblas.h
      - include/f77blas.h
      - include/lapacke*.h
      - include/openblas_config.h
      - lib/cmake/openblas
      - lib/pkgconfig/blas.pc
      - lib/pkgconfig/cblas.pc
      - lib/pkgconfig/lapack.pc
      - lib/pkgconfig/openblas.pc
      - site.cfg
    run_exports:
      - {{ pin_subpackage('libopenblas', max_pin='x.x.x') }}
      - {{ pin_subpackage('blas', exact=True) }}
    requirements:
      run:
        - {{ pin_subpackage('libopenblas', max_pin='x.x.x') }}
    about:
      summary: OpenBLAS headers and libraries for developing software that used OpenBLAS.

  # openblas meta-package. It is better to require openblas-devel or libopenblas
  - name: openblas
    requirements:
      run:
        - {{ pin_subpackage('libopenblas', max_pin='x.x.x') }}
        - {{ pin_subpackage('openblas-devel', max_pin='x.x.x') }}
        - {{ pin_subpackage('blas', exact=True) }}
    about:
      home: http://www.openblas.net/
      license: BSD
      license_file: LICENSE
      summary: An Optimized BLAS library
      description: |
        OpenBLAS is based on GotoBLAS2 1.13 BSD version.
      doc_url: http://www.openblas.net/
      doc_source_url: https://github.com/xianyi/OpenBLAS/blob/develop/README.md
      dev_url: https://github.com/xianyi/OpenBLAS

  # mutex package to keep only one blas implementation in a given env
  - name: blas
    version: 1.0
    build:
      string: openblas
      track_features:
        - nomkl

  - name: nomkl
    version: 3.0
    build:
      number: 0
      track_features:
        - nomkl
    requirements:
      run:
        - {{ pin_subpackage('blas', exact=True) }}
    about:
      license: BSD

extra:
  recipe-maintainers:
    - gillins
    - groutr
    - jakirkham
    - jschueller
    - isuruf
