{% set name = "openmp" %}
{% set version = "10.0.1" %}
{% set sha256 = "d19f728c8e04fb1e94566c8d76aef50ec926cd2f95ef3bf1e0a5de4909b28b44" %}
{% set openmp_ver = "5.1" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/openmp-{{ version }}.src.tar.xz
  sha256: {{ sha256 }}

build:
  number: 0
  skip: true  # [win and vc<14]

outputs:
  - name: llvm-openmp
    script: build-llvm-openmp.sh  # [not win]
    script: bld-llvm-openmp.bat  # [win]
    build:
      ignore_run_exports:
        - libgcc-ng
        - libstdcxx-ng
        - _openmp_mutex
      run_exports:
        strong:
          - {{ pin_subpackage("llvm-openmp", max_pin=None) }}
          - _openmp_mutex >={{ openmp_ver }}  # [linux]
          - _openmp_mutex * *_llvm            # [linux]
    requirements:
      build:
        - {{ compiler('cxx') }}  # [unix]
        - vs2017_{{ target_platform }}  # [win]
        - cmake
        - make  # [unix]
        - perl
        - ninja  # [win]
      host:
        - llvmdev {{ version }}|{{ version }}.*
      run_constrained:
        - clangdev {{ version }}|{{ version }}.*
        - llvmdev {{ version }}|{{ version }}.*
        - openmp {{ version }}|{{ version }}.*
    test:
      requires:
        - clangxx
        - {{ compiler('cxx') }}  # [unix]
        - vs2017_{{ target_platform }}  # [win]
      commands:
        - if not exist %LIBRARY_BIN%\\libomp.dll exit 1   # [win]
        - test -f $PREFIX/lib/libomp.so                   # [linux]
        - test -f $PREFIX/lib/libomp.dylib                # [osx]
        - if not exist %LIBRARY_LIB%\\libomp.lib exit 1   # [win]
        - if not exist %LIBRARY_INC%\\omp.h exit 1        # [win]
        - test -f $PREFIX/include/omp.h                   # [unix]
        - $PREFIX/bin/clang -v -fopenmp -I$PREFIX/include -L$PREFIX/lib -Wl,-rpath,$PREFIX/lib omp_hello.c -o omp_hello  # [not win]
        - '%LIBRARY_BIN%\clang -v -fopenmp -I%LIBRARY_INC% -L%LIBRARY_LIB% omp_hello.c -o omp_hello.exe'   # [win]
        - ./omp_hello            # [unix]
        - '%cd%\omp_hello.exe'   # [win]
      files:
        - omp_hello.c

about:
  home: http://openmp.llvm.org/
  license: NCSA
  license_file: LICENSE.txt
  summary: The OpenMP API supports multi-platform shared-memory parallel programming in C/C++ and Fortran.

extra:
  recipe-maintainers:
    - inducer
    - jakirkham
    - yesimon
    - isuruf
    - beckermr
