{% set version = "3.4.2" %}
{% set build = 0 %}

# give conda package a higher build number
{% if mpi_type == 'conda' %}
{% set build = build + 100 %}
{% endif %}

package:
  # must not match any outputs for requirements to be handled correctly
  name: mpich-mpi
  version: {{ version }}

source:
  fn: mpich-{{ version }}.tar.gz
  url: http://www.mpich.org/static/downloads/{{ version }}/mpich-{{ version }}.tar.gz
  sha256: 5c19bea8b84e8d74cca5f047e82b147ff3fba096144270e3911ad623d6c587bf

build:
  number: {{ build }}
  skip: true  # [win]

outputs:
  {% if mpi_type == 'external' %}
  - name: mpich
    string: {{ mpi_type }}_{{ build }}
    track_features:
      - mpich_{{ mpi_type }}
    requirements:
      run:
        - mpi 1.0 mpich
    test:
      commands:
        - echo "It works!"
  {% else %}
  - name: mpich
    script: build-mpi.sh
    build:
      run_exports:
        - {{ pin_subpackage('mpich', max_pin='x') }}
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - {{ compiler('fortran') }}
        - autoconf  # [unix]
        - automake  # [unix]
        - libtool   # [unix]
        - make  # [unix]
        - gnuconfig  # [arm64]

      host:
        - {{ fortran_compiler }}_{{ target_platform }} {{ fortran_compiler_version }}  # hack to force conda to make both fortran abi builds
      run:
        - mpi 1.0 mpich
    test:
      script: run_test.sh
      files:
        - mpiexec.sh
        - tests/helloworld.sh

  - name: mpich-mpicc
    build:
      script:
        - echo 'ok'  # [not osx]
        # make CONDA_BUILD_SYSROOT a 'used variable'
        # so that conda-build knows to pass it to the test env
        - echo "{{ CONDA_BUILD_SYSROOT }}"  # [osx]
    requirements:
      run:
        - {{ pin_subpackage('mpich', exact=True) }}
        # host C compilers work fine (better) on mac
        - {{ compiler('c') }}
    test:
      script: run_test.sh
      files:
        - mpiexec.sh
        - tests/helloworld.c

  - name: mpich-mpicxx
    build:
      script:
        - echo 'ok'  # [not osx]
        # make CONDA_BUILD_SYSROOT a 'used variable'
        # so that conda-build knows to pass it to the test env
        - echo "{{ CONDA_BUILD_SYSROOT }}"  # [osx]
    requirements:
      run:
        - {{ pin_subpackage('mpich', exact=True) }}
        # host C compilers work fine (better) on mac
        - {{ compiler('cxx') }}
    test:
      script: run_test.sh
      files:
        - mpiexec.sh
        - tests/helloworld.cxx

  - name: mpich-mpifort
    build:
      script:
        - echo 'ok'  # [not osx]
        # make CONDA_BUILD_SYSROOT a 'used variable'
        # so that conda-build knows to pass it to the test env
        - echo "{{ CONDA_BUILD_SYSROOT }}"  # [osx]
    requirements:
      run:
        - {{ pin_subpackage('mpich', exact=True) }}
        - {{ compiler('fortran') }}
    test:
      script: run_test.sh
      files:
        - mpiexec.sh
        - tests/helloworld.f
        - tests/helloworld.f90
  {% endif %}

about:
  home: http://www.mpich.org/
  license: LicenseRef-MPICH
  license_file: COPYRIGHT
  license_family: Other
  summary: A high performance widely portable implementation of the MPI standard.
  description: |
    MPICH is a high performance and widely portable implementation of the
    Message Passing Interface (MPI) standard.
  doc_url: http://www.mpich.org/documentation/guides
  dev_url: https://wiki.mpich.org/mpich/index.php/Main_Page

extra:
  recipe-maintainers:
    - astrofrog-conda-forge
    - bekozi
    - dalcinl
    - minrk
    - msarahan
    - ocefpaf
