{% set version = "0.21.1" %}
{% set am_version = "1.15" %} #  keep synchronized with build.sh
{% set posix = 'm2-' if win else '' %}
{% set native = 'm2w64-' if win else '' %}

package:
  name: gettext
  version: {{ version }}

source:
  url: https://ftp.gnu.org/pub/gnu/gettext/gettext-{{ version }}.tar.xz
  sha256: 50dbc8f39797950aa2c98e939947c527e5ac9ebd2c1b99dd7b06ba33a6767ae6
  patches:
    - 0001-Mark-v-snprintf-as-available.patch                          # [win]
    - 0002-Prevent-libtool-from-worrying-about-dependent-librar.patch  # [win]
    - 0003-Fix-some-DLL-export-markings-in-libintl.patch               # [win]
    - 0004-Fix-quoting-when-invoking-windres.patch                     # [win]
    - 0005-CXXLD-is-not-a-thing.patch                                  # [win]
    - 0007-Work-around-Unixisms-in-libgettextpo.patch                  # [win]
    - 0008-Add-missing-extern-C-protectors.patch                       # [win]
    - 0009-Avoid-close-inconsistencies.patch                           # [win]

build:
  number: 0
  run_exports:
    # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
    - {{ pin_subpackage('gettext') }}
  ignore_run_exports:
    - libcxx
    - libstdcxx-ng

requirements:
  build:
    - posix                              # [win]
    - {{ posix }}autoconf                  # [win]
    - {{ posix }}automake{{ am_version }}  # [win]
    - {{ posix }}libtool
    - {{ posix }}patch                     # [win]
    - {{ posix }}sed                       # [win]
    - {{ native }}binutils                 # [win]
    - {{ native }}crt-git                  # [win]
    - {{ compiler('c') }}                # [not win]
    - {{ compiler('cxx') }}              # [not win]
    - make                               # [unix]
  host:
    - libiconv  # [not linux]

test:
  commands:
    - msgfmt.exe -o %TMP%\an.gmo %RECIPE_DIR%\an.po                        # [win]
    - msgfmt -o $RECIPE_DIR/an.gmo $RECIPE_DIR/an.po                       # [not win]
    {% set lib_idents = [ "gettextlib", "gettextpo", "gettextsrc" ] %}
    {% set lib_idents = lib_idents + [ "intl" ] %}                         # [not linux]
    {% for lib_ident in lib_idents %}
    - test -f ${PREFIX}/lib/lib{{ lib_ident }}$SHLIB_EXT                   # [not win]
    - if not exist %PREFIX%\Library\lib\{{ lib_ident }}.dll.lib exit /b 1  # [win]
    - if not exist %PREFIX%\Library\bin\{{ lib_ident }}-*.dll exit /b 1    # [win]
    {% endfor %}

about:
  home: https://www.gnu.org/software/gettext/
  license: LGPL-2.1-or-later AND GPL-3.0-or-later
  license_file: COPYING
  summary: Internationalization package

extra:
  recipe-maintainers:
    - scopatz
    - ocefpaf
    - pkgw
