distributable:
  url: https://download.savannah.gnu.org/releases/freetype/freetype-{{ version }}.tar.gz
  #FIXME our linux docker image TLS doesn’t like this URL
  # url: https://downloads.sourceforge.net/project/freetype/freetype{{ version.major }}/{{ version }}/freetype-{{ version }}.tar.gz
  strip-components: 1

versions:
  url: https://download.savannah.gnu.org/releases/freetype/
  match: /freetype-(\d+\.\d+(\.\d+)?)\.tar\.gz/
  strip:
    - /freetype-/
    - /.tar.gz/

dependencies:
  libpng.org: 1
  zlib.net: 1
  sourceware.org/bzip2: 1

#FIXME the freetype-config script contains fullpaths to libpng
# not sure of a portable way to fix that, probs best is using png-config

build:
  dependencies:
    freedesktop.org/pkg-config: ^0.29
    #NOTE cmake ∵ autoconf failed on Linux due to not creating the .so files
    cmake.org: '*'
  working-directory: build
  script: |
    cmake .. $ARGS
    make --jobs {{ hw.concurrency }} install
  env:
    ARGS:
      - -DBUILD_SHARED_LIBS=true
      - -DCMAKE_INSTALL_PREFIX="{{ prefix }}"
      - -DCMAKE_BUILD_TYPE=Release

test:
  dependencies:
    freedesktop.org/pkg-config: ^0.29
  script: |
    mv $FIXTURE test.c
    cc -o test test.c $(pkg-config --cflags --libs freetype2)
    ./test
  fixture: |
    #include <ft2build.h>
    #include FT_FREETYPE_H

    FT_Library  library;

    int main() {
      return FT_Init_FreeType( &library );
    }
