{% set xorg_name = "libxcb" %}
{% set xorg_category = "lib" %}
{% set name = "libxcb" %}
{% set version = "1.15" %}
{% set sha256 = "1cb65df8543a69ec0555ac696123ee386321dfac1964a3da39976c9a05ad724d" %}
{% set am_version = "1.15" %} # keep synchronized with build.sh

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

source:
  fn: {{ xorg_name }}-{{ version }}.tar.bz2
  url: https://xorg.freedesktop.org/archive/individual/{{ xorg_category }}/{{ xorg_name }}-{{ version }}.tar.gz
  sha256: {{ sha256 }}
  patches:
    - windows.patch  # [win]

build:
  number: 0
  detect_binary_files_with_prefix: true
  run_exports:
    - {{ pin_subpackage('libxcb', max_pin='x.x') }}
  
requirements:
  build:
    - m2-autoconf                   # [win]
    - m2-automake{{ am_version }}   # [win]
    - m2-libtool                    # [win]
    - m2w64-pkg-config              # [win]
    - pkg-config                    # [not win]
    - posix                         # [win]
    - gnuconfig  # [unix]
    - {{ compiler('c') }}           # [unix]
    - {{ compiler('m2w64_c') }}     # [win]
    - make                          # [unix]
    - autoconf                      # [unix]
    - automake                      # [unix]
    - gettext                       # [unix]
    - libtool                       # [unix]
    - python  # [build_platform != target_platform]
  host:
    - pthread-stubs
    - xorg-libxau
    - xorg-libxdmcp
    - xorg-util-macros
    - xcb-proto {{ version }}
    - xorg-xproto
  run:
    - pthread-stubs
    - xorg-libxau
    - xorg-libxdmcp

test:
  commands:
    {% set lib_idents = [
      "xcb",
      "xcb-composite",
      "xcb-damage",
      "xcb-dpms",
      "xcb-dri2",
      "xcb-glx",
      "xcb-present",
      "xcb-randr",
      "xcb-record",
      "xcb-res",
      "xcb-screensaver",
      "xcb-shape",
      "xcb-shm",
      "xcb-sync",
      "xcb-xf86dri",
      "xcb-xfixes",
      "xcb-xinerama",
      "xcb-xkb",
      "xcb-xtest",
      "xcb-xv",
      "xcb-xvmc",
    ] %}
    {% set lib_idents = lib_idents + ['xcb-dri3', 'xcb-render', 'xcb-xinput'] %}  # [not win]
    {% for lib_ident in lib_idents %}
    - test -f $PREFIX/lib/lib{{ lib_ident }}.dylib  # [osx]
    - test -f $PREFIX/lib/lib{{ lib_ident }}.so  # [linux]
    - if not exist %PREFIX%/Library/lib/lib{{ lib_ident }}.dll.a exit /b 1  # [win]
    - if not exist %PREFIX%/Library/bin/msys-{{ lib_ident }}-*.dll exit /b 1  # [win]
    {% endfor %}

about:
  home: http://xcb.freedesktop.org/
  license: MIT
  license_family: MIT
  license_file: COPYING
  summary: "This is the C-language Binding (XCB) package to the X Window System protocol"

extra:
  recipe-maintainers:
    - ccordoba12
    - mingwandroid
    - pkgw
