{% set version = "0.22.5" %}
{% 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-split
  version: {{ version }}

source:
  url: https://ftp.gnu.org/pub/gnu/gettext/gettext-{{ version }}.tar.xz
  sha256: fe10c37353213d78a5b83d48af231e005c4da84db5ce88037d88355938259640
  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]
    - 0006-Work-around-Unixisms-in-libgettextpo.patch                  # [win]
    - 0007-Add-missing-extern-C-protectors.patch                       # [win]
    - 0008-Avoid-close-inconsistencies.patch                           # [win]

build:
  number: 2
  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') }}
    - {{ compiler('cxx') }}
    - make                               # [unix]
  host:
    - libiconv  # [not linux]


outputs:
  - name: libintl
    build:
      skip: true  # [linux]
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libintl') }}
      ignore_run_exports:
        - libcxx
        - libstdcxx-ng
    script: install-libintl.sh  # [unix]
    script: install-libintl.bat  # [not unix]
    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:
        # Only the actual binary (versioned) variant should be in this package
        - test -f ${PREFIX}/lib/libintl.*.dylib                   # [osx]
        - test -f ${PREFIX}/lib/libintl.so.*                      # [linux]
        - if not exist %PREFIX%\Library\bin\intl-*.dll exit /b 1  # [win]
        # The unversioned variants as well as the lib on Windows should be in the main gettext package.
        - test ! -f ${PREFIX}/lib/libintl$SHLIB_EXT               # [not win]
        - test ! -f ${PREFIX}/include/libintl.h                   # [osx]
        - if exist %PREFIX%\Library\lib\intl.dll.lib exit /b 1    # [win]
        - if exist %PREFIX%\Library\lib\intl.lib exit /b 1        # [win]
        - if exist %PREFIX%\Library\include\libintl.h exit /b1    # [win]
    about:
      home: https://www.gnu.org/software/gettext/
      license: LGPL-2.1-or-later
      license_file: COPYING
      summary: library that provides native language support to programs
  - name: libintl-devel
    build:
      skip: true  # [linux]
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libintl') }}
      ignore_run_exports:
        - libcxx
        - libstdcxx-ng
    script: install-libintl-devel.sh  # [unix]
    script: install-libintl-devel.bat  # [not unix]
    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]
        - {{ pin_subpackage('libintl', exact=true) }}
      run:
        - {{ pin_subpackage('libintl', exact=true) }}
    test:
      commands:
        - test -f ${PREFIX}/lib/libintl${SHLIB_EXT}                   # [osx]
        - test -f ${PREFIX}/include/libintl.h                         # [osx]
        - if not exist %PREFIX%\Library\lib\intl.dll.lib exit /b 1    # [win]
        - if not exist %PREFIX%\Library\lib\intl.lib exit /b 1        # [win]
        - if not exist %PREFIX%\Library\include\libintl.h exit /b1    # [win]
    about:
      home: https://www.gnu.org/software/gettext/
      license: LGPL-2.1-or-later
      license_file: COPYING
      summary: library that provides native language support to programs
  - name: libasprintf
    build:
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libasprintf') }}
      ignore_run_exports:
        - libcxx
        - libiconv
    script: install-asprintf.sh  # [unix]
    script: install-asprintf.bat  # [not unix]
    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:
        # Only the actual binary (versioned) variant should be in this package
        - test -f ${PREFIX}/lib/libasprintf.*.dylib                   # [osx]
        - test -f ${PREFIX}/lib/libasprintf.so.0                      # [linux]
        - if not exist %PREFIX%\Library\bin\asprintf-*.dll exit /b 1  # [win]
        # The unversioned variants as well as the lib on Windows should be in the main gettext package.
        - test ! -f ${PREFIX}/lib/libasprintf$SHLIB_EXT               # [not win]
        - if exist %PREFIX%\Library\lib\asprintf.dll.lib exit /b 1    # [win]
        - if exist %PREFIX%\Library\lib\asprintf.lib exit /b 1    # [win]
    about:
      home: https://www.gnu.org/software/gettext/
      license: LGPL-2.1-or-later
      license_file: COPYING
      summary: C-style formatted output in C++
  - name: libasprintf-devel
    build:
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libasprintf') }}
      ignore_run_exports:
        - libcxx
        - libstdcxx-ng
        - libiconv
    script: install-asprintf-devel.sh  # [unix]
    script: install-asprintf-devel.bat  # [not unix]
    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]
        - {{ pin_subpackage('libasprintf', exact=True) }}
      run:
        - {{ pin_subpackage('libasprintf', exact=True) }}
    test:
      commands:
        - test -f ${PREFIX}/lib/libasprintf${SHLIB_EXT}               # [not win]
        - if not exist %PREFIX%\Library\lib\asprintf.dll.lib exit /b 1    # [win]
        - if not exist %PREFIX%\Library\lib\asprintf.lib exit /b 1    # [win]
    about:
      home: https://www.gnu.org/software/gettext/
      license: LGPL-2.1-or-later
      license_file: COPYING
      summary: Decomposed printf argument list
  - name: libgettextpo
    build:
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libgettextpo') }}
      ignore_run_exports:
        - libcxx
        - libstdcxx-ng
    script: install-libgettextpo.sh  # [unix]
    script: install-libgettextpo.bat  # [not unix]
    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:
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
        - libiconv  # [not linux]
      run:
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
    test:
      commands:
        # Only the actual binary (versioned) variant should be in this package
        - test -f ${PREFIX}/lib/libgettextpo.*.dylib                   # [osx]
        - test -f ${PREFIX}/lib/libgettextpo.so.0                      # [linux]
        - if not exist %PREFIX%\Library\bin\gettextpo-*.dll exit /b 1  # [win]
        # The unversioned variants as well as the lib on Windows should be in the main gettext package.
        - test ! -f ${PREFIX}/lib/libgettextpo$SHLIB_EXT               # [not win]
        - if exist %PREFIX%\Library\lib\gettextpo.dll.lib exit /b 1    # [win]
        - if exist %PREFIX%\Library\lib\gettextpo.lib exit /b 1    # [win]
    about:
      home: https://www.gnu.org/software/gettext/
      license: GPL-3.0-or-later
      license_file: COPYING
      summary: library for interfacing programmatically with GNU gettext .po files
  - name: libgettextpo-devel
    build:
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libgettextpo') }}
      ignore_run_exports:
        - libcxx
        - libstdcxx-ng
    script: install-libgettextpo-devel.sh  # [unix]
    script: install-libgettextpo-devel.bat  # [not unix]
    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:
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libgettextpo', exact=True) }}
        - libiconv  # [not linux]
      run:
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libgettextpo', exact=True) }}
    test:
      commands:
        - test -f ${PREFIX}/lib/libgettextpo$SHLIB_EXT               # [not win]
        - if not exist %PREFIX%\Library\lib\gettextpo.dll.lib exit /b 1    # [win]
        - if not exist %PREFIX%\Library\lib\gettextpo.lib exit /b 1    # [win]
    about:
      home: https://www.gnu.org/software/gettext/
      license: GPL-3.0-or-later
      license_file: COPYING
      summary: library for interfacing programmatically with GNU gettext .po files
  - name: gettext-tools
    script: install-gettext.sh  # [unix]
    script: install-gettext.bat  # [not unix]
    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') }}
        - {{ compiler('cxx') }}
        - make                               # [unix]
      host:
        - libiconv  # [not linux]
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libasprintf', exact=True ) }}
        - {{ pin_subpackage('libgettextpo', exact=True ) }}
        # Devel packages are included for deduplication-purposes only
        - {{ pin_subpackage('libintl-devel', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libasprintf-devel', exact=True ) }}
        - {{ pin_subpackage('libgettextpo-devel', exact=True ) }}
      run:
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
    test:
      files:
        - an.po
      commands:
        - msgfmt.exe --help  # [win]
        - msgfmt.exe -o an.gmo an.po                 # [win]
        - msgfmt -o an.gmo an.po                     # [not win]
    about:
      home: https://www.gnu.org/software/gettext/
      # The binaries of gettext are the GPL-3.0 licensed part.
      license: GPL-3.0-or-later
      license_file: COPYING
      summary: Internationalization package (executable tools)

  - name: gettext
    build:
      # Required to make overdepending checks pass.
      ignore_run_exports:
        - libintl
        - libasprintf
        - libgettextpo
      run_exports:
        # Seems pretty good: https://abi-laboratory.pro/tracker/timeline/gettext/
        - {{ pin_subpackage('libintl') }}  # [not linux]
        - {{ pin_subpackage('libasprintf') }}
        - {{ pin_subpackage('libgettextpo') }}
    script: install-gettext.sh  # [unix]
    script: install-gettext.bat  # [not unix]
    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]
        - {{ pin_subpackage('gettext-tools', exact=True) }}
        - {{ pin_subpackage('libintl-devel', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libasprintf-devel', exact=True ) }}
        - {{ pin_subpackage('libasprintf', exact=True ) }}
        - {{ pin_subpackage('libgettextpo-devel', exact=True ) }}
        - {{ pin_subpackage('libgettextpo', exact=True ) }}
      run:
        - {{ pin_subpackage('gettext-tools', exact=True) }}
        - {{ pin_subpackage('libintl-devel', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libintl', exact=True) }}  # [not linux]
        - {{ pin_subpackage('libasprintf-devel', exact=True ) }}
        - {{ pin_subpackage('libasprintf', exact=True ) }}
        - {{ pin_subpackage('libgettextpo-devel', exact=True ) }}
        - {{ pin_subpackage('libgettextpo', exact=True ) }}
    test:
      commands:
        {% 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]
        - test ! -f ${PREFIX}/lib/lib{{ lib_ident }}.a                         # [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

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:
  feedstock-name: gettext
  recipe-maintainers:
    - scopatz
    - ocefpaf
    - pkgw
    - xhochy
