{% set name = "llvm-openmp" %}
{% set version = "8.0.1" %}
{% set sha256 = "3e85dd3cad41117b7c89a41de72f2e6aa756ea7b4ef63bb10dcddf8561a7722c" %}

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 }}
  patches:
    - D65714.patch

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

test:
  requires:
    - clangdev
    - {{ compiler('cxx') }}  # [linux]
  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

outputs:
  - name: llvm-openmp
    script: build-llvm-openmp.sh  # [not win]
    script: bld-llvm-openmp.bat   # [win]
    build:
      run_exports:
        strong:
          - {{ pin_subpackage("llvm-openmp", max_pin=None) }}
    requirements:
      build:
        - {{ compiler("cxx") }}
        - cmake
        - perl
        - ninja  # [win]
      host:
        - llvmdev {{ version }}|{{ version }}.*
      run_constrained:
        - clangdev {{ version }}|{{ version }}.*
        - llvmdev {{ version }}|{{ version }}.*
        - openmp {{ version }}|{{ version }}.*

  - name: openmp
    requirements:
      run:
        - {{ pin_subpackage("llvm-openmp", exact=True) }}

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
