# Always use 4 numbers in the version to match run_exports!
# Add .0 if official version is on 3 numbers
{% set version = "7.0.6.1" %}

package:
  name: epics-base
  version: {{ version }}

source:
  # Don't use {{ version }} in the url as it can be on 3 numbers only
  url: https://epics.anl.gov/download/base/base-7.0.6.1.tar.gz
  sha256: 8ff318f25e2b70df466f933636a2da85e4b0c841504b9e89857652a4786b6387
  patches:
    - CONFIG_COMMON_install_permissions.patch
    - force_readline_commandline_library.patch  # [linux]

build:
  number: 0
  run_exports:
    - {{ pin_subpackage('epics-base', max_pin='x.x.x.x') }}

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - make
    - perl
    - m2-patch      # [win]
    # To run pre-build.py
    - python >=3.6  # [win]
  host:
    - readline      # [unix]
  run:
    - perl

test:
  source_files:
    - modules/pva2pva/loopback.conf
  commands:
    - caget -h
    - cainfo -h
    - caput -h
    - camonitor -h
    - pvget -h
    - pvput -h
    - pvinfo -h
    - pvlist -h
    - softIoc -h
    - softIocPVA -h
    # p2p -h exits with 1... Use -C flag to test it instead
    - p2p -C modules/pva2pva/loopback.conf
    - test -f ${EPICS_BASE}/bin/${EPICS_HOST_ARCH}/caget                # [not win]
    - test -f ${EPICS_BASE}/include/epicsVersion.h                      # [not win]
    - test -f ${EPICS_BASE}/lib/${EPICS_HOST_ARCH}/libCom${SHLIB_EXT}   # [not win]
    - test -f ${EPICS_BASE}/lib/${EPICS_HOST_ARCH}/libca${SHLIB_EXT}    # [not win]
    - if not exist %EPICS_BASE%\bin\%EPICS_HOST_ARCH%\caget.exe exit 1  # [win]
    - if not exist %EPICS_BASE%\bin\%EPICS_HOST_ARCH%\Com.dll exit 1    # [win]
    - if not exist %EPICS_BASE%\bin\%EPICS_HOST_ARCH%\ca.dll exit 1     # [win]
    - if not exist %EPICS_BASE%\include\epicsVersion.h exit 1           # [win]
    - if not exist %EPICS_BASE%\lib\%EPICS_HOST_ARCH%\ca.lib exit 1     # [win]
    - if not exist %EPICS_BASE%\lib\%EPICS_HOST_ARCH%\Com.lib exit 1    # [win]

outputs:
  - name: epics-base
    files:
      - etc
      - epics/bin
      - epics/cfg
      - epics/configure
      - epics/db
      - epics/dbd
      - epics/html
      - epics/include
      # windows .dll are under bin
      - epics/lib/*/*.lib    # [win]
      - epics/lib/*/*.dylib  # [osx]
      - epics/lib/*/*.so*    # [linux]
      - epics/lib/perl
      - epics/lib/pkgconfig
      - epics/templates

  - name: epics-base-static-libs                                 # [not win]
    requirements:                                                # [not win]
      run:                                                       # [not win]
        - {{ pin_subpackage('epics-base', exact=True) }}         # [not win]
    files:                                                       # [not win]
      - epics/lib/*/*.a                                          # [not win]
    test:                                                        # [not win]
      commands:                                                  # [not win]
        - test -f ${EPICS_BASE}/lib/${EPICS_HOST_ARCH}/libca.a   # [not win]
        - test -f ${EPICS_BASE}/lib/${EPICS_HOST_ARCH}/libCom.a  # [not win]

about:
  home: http://www.aps.anl.gov/epics
  license: EPICS
  license_file: LICENSE
  summary: EPICS Base Library

extra:
  recipe-maintainers:
    - beenje
    - mrakitin
    - tacaswell
