distributable:
  url: https://ftp.gnu.org/gnu/libunistring/libunistring-{{version.raw}}.tar.gz
  strip-components: 1

versions:
  url: https://ftp.gnu.org/gnu/libunistring/
  match: /libunistring-(\d+\.\d+(\.\d+)?)\.tar\.gz/
  strip:
    - /libunistring-/
    - /.tar.gz/

build:
  dependencies:
    gnu.org/gmp: '*'
    gnu.org/m4: '*'
  script: |
    ./configure --prefix={{ prefix }}
    make --jobs {{ hw.concurrency }} install

test:
  script: |
    mv $FIXTURE test.c
    cc -lunistring -o test test.c
    test "$(./test)" = "🫖\n"
  fixture: |
    #include <uniname.h>
    #include <unistdio.h>
    #include <unistr.h>
    #include <stdlib.h>
    int main (void) {
      uint32_t s[2] = {};
      uint8_t buff[12] = {};
      if (u32_uctomb (s, unicode_name_character ("TEAPOT"), sizeof s) != 1) abort();
      if (u8_sprintf (buff, "%llU", s) != 4) abort();
      printf ("%s\\n", buff);
      return 0;
    }
