{% set version = "6.1" %}

package:
  name: ncurses
  version: {{ version }}

source:
  fn: ncurses-{{ version }}.tar.gz
  url: http://ftp.gnu.org/pub/gnu/ncurses/ncurses-{{ version }}.tar.gz
  md5: 98c889aaf8d23910d2b92d65be2e737a
  patches:
    # http://lists.gnu.org/archive/html/bug-ncurses/2011-04/txtkWQqiQvcZe.txt
    - fix.patch
    # http://lists.gnu.org/archive/html/bug-ncurses/2015-01/msg00016.html
    - ncurses-5.9-gcc-5.patch
    - clang.patch

build:
  skip: True  # [win]
  number: 1
  run_exports:
    # pretty good compat within major version
    #  https://abi-laboratory.pro/tracker/timeline/ncurses/
    - {{ pin_subpackage('ncurses') }}

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - pkg-config
    - make

test:
# TODO :: conda-build needs seperate test/requires_build and test/requires_host
#  requires:
#    - pkg-config
  commands:
    # Test libraries
    {% set ncurses_libraries = [
        "libncurses",
        "libtinfo",
        "libform",
        "libmenu",
        "libpanel",
    ] %}
    {% for each_ncurses_library in ncurses_libraries %}
    - test -f ${PREFIX}/lib/{{ each_ncurses_library }}.a
    - test -f ${PREFIX}/lib/{{ each_ncurses_library }}w.a
    - test -f ${PREFIX}/lib/{{ each_ncurses_library }}.dylib    # [osx]
    - test -f ${PREFIX}/lib/{{ each_ncurses_library }}w.dylib   # [osx]
    - test -f ${PREFIX}/lib/{{ each_ncurses_library }}.so       # [linux]
    - test -f ${PREFIX}/lib/{{ each_ncurses_library }}w.so      # [linux]
    {% endfor %}

    # Test include directories
    - test -d ${PREFIX}/include/ncurses
    - test -d ${PREFIX}/include/ncursesw

    # Test headers
    {% set ncurses_headers = [
        "curses.h",
        "cursesapp.h",
        "cursesf.h",
        "cursesm.h",
        "cursesp.h",
        "cursesw.h",
        "cursslk.h",
        "eti.h",
        "etip.h",
        "form.h",
        "menu.h",
        "nc_tparm.h",
        "ncurses.h",
        "ncurses_dll.h",
        "panel.h",
        "term.h",
        "term_entry.h",
        "termcap.h",
        "tic.h",
        "unctrl.h"
    ] %}
    {% for each_ncurses_header in ncurses_headers %}
    - test -L ${PREFIX}/include/ncurses/{{ each_ncurses_header }}
    - test -L ${PREFIX}/include/ncursesw/{{ each_ncurses_header }}
    - test -f ${PREFIX}/include/{{ each_ncurses_header }}
    {% endfor %}

    # Test pkg-config files
    {% set ncurses_pc_files = [
        "form",
        "menu",
        "ncurses++",
        "ncurses",
        "panel",
        "tinfo"
    ] %}
    {% for each_ncurses_pc_file in ncurses_pc_files %}
    - test -f ${PREFIX}/lib/pkgconfig/{{ each_ncurses_pc_file }}.pc
    - test -f ${PREFIX}/lib/pkgconfig/{{ each_ncurses_pc_file }}w.pc
    {% endfor %}

    # Test ncurses library arguments.
    # - pkg-config ncursesw --libs | grep "^-L${PREFIX}/lib -lncursesw -ltinfow$"
    # - pkg-config tinfow --libs | grep "^-L${PREFIX}/lib -ltinfow$"
    # - pkg-config ncurses --libs | grep "^-L${PREFIX}/lib -lncurses -ltinfo$"
    # - pkg-config tinfo --libs | grep "^-L${PREFIX}/lib -ltinfo$"

about:
  home: http://www.gnu.org/software/ncurses/
  license: Free software (MIT-like)
  summary: Library for text-based user interfaces
  
  description: |
    The ncurses (new curses) library is a free software
    emulation of curses in System V Release 4.0 (SVr4),
    and more. It uses terminfo format, supports pads and
    color and multiple highlights and forms characters and
    function-key mapping, and has all the other SVr4-curses
    enhancements over BSD curses. SVr4 curses is better
    known today as X/Open Curses
  doc_url: http://invisible-island.net/ncurses/NCURSES-Programming-HOWTO.html
  dev_url: http://invisible-island.net/ncurses/

extra:
  recipe-maintainers:
    - jakirkham
    - jjhelmus
