distributable:
  #FIXME: they use a weird versioning scheme
  url: https://github.com/ImageMagick/ImageMagick/archive/7.1.1-12.tar.gz
  strip-components: 1

versions:
  #FIXME: they use a weird versioning scheme
  # github: ImageMagick/ImageMagick
  - 7.1.1.12

provides:
  - bin/animate
  - bin/compare
  - bin/composite
  - bin/conjure
  - bin/convert
  - bin/display
  - bin/identify
  - bin/import
  - bin/magick
  - bin/magick-script
  - bin/Magick++-config
  - bin/MagickCore-config
  - bin/MagickWand-config
  - bin/mogrify
  - bin/montage
  - bin/stream

dependencies:
    libpng.org: '*'
    ijg.org: '*'
    freetype.org: '*'
    libjpeg-turbo.org: '*'
    liblqr.wikidot.com: '*'
    simplesystems.org/libtiff: '*'
    gnu.org/libtool: '*'
    littlecms.com: '*'
    openexr.com: '*'
    openjpeg.org: '*'
    google.com/webp: '*'
    tukaani.org/xz: '*'
    sourceware.org/bzip2: '*'
    gnome.org/libxml2: '*'
    zlib.net: '*'
    jpeg.org/jpegxl: '*'
    perl.org: '*'
    libzip.org: '*'
    darwin:
      openmp.llvm.org: '*'
      github.com/strukturag/libheif: '*'
    linux/x86-64:
      github.com/strukturag/libheif: '*'
    linux:
      x.org/x11: '*'

runtime:
  MAGICK_HOME: "{{prefix}}"

build:
  dependencies:
    freedesktop.org/pkg-config: '*'
  script:
    - sed -i'' -e 's|${PACKAGE_NAME}-${PACKAGE_BASE_VERSION}|${PACKAGE_NAME}|g' configure
    - find . -type f -name '*-config.in' -exec sed -i'' -e 's|@PKG_CONFIG@|pkg-config|g' {} +
    - ./configure $ARGS
    - make --jobs {{ hw.concurrency }} install
    - run: sed -i'' -e 's|^prefix=.*|prefix=${MAGICK_HOME}|g' Magick++-config MagickCore-config MagickWand-config
      working-directory: ${{prefix}}/bin

  env:
    # https://github.com/ImageMagick/ImageMagick/issues/1549
    LDFLAGS:
      - -L{{deps.gnu.org/libtool.prefix}}/lib
      - -L{{deps.liblqr.wikidot.com.prefix}}/lib
      - -L{{deps.sourceware.org/bzip2.prefix}}/lib
      - -L{{deps.ijg.org.prefix}}/lib
    ARGS:
      - --prefix={{ prefix }}
      - --libdir={{prefix}}/lib
      - --enable-osx-universal-binary=no
      - --disable-silent-rules
      - --disable-opencl
      - --enable-static
      - --disable-shared
      - --with-png=yes
      - --with-tiff=yes
      - --with-jxl=yes
      - --with-perl=yes
      - --with-freetype=yes
      - --with-gvc=no
      - --with-modules
      - --with-openjp2
      - --with-openexr
      - --with-webp=yes
      - --with-heic=yes
      - --with-lqr
      - --without-lzma
      - --without-djvu
      - --without-fftw
      - --without-pango
      - --without-wmf
      - --without-perl
      - --enable-openmp
      - --with-zip=yes

    linux:
      ARGS:
        - --with-x=yes
        - --x-includes={{deps.x.org/x11.prefix}}/include
        - --x-libraries={{deps.x.org/x11.prefix}}/lib
    darwin:
      ARGS:
        - --without-x

test:
  env:
    MAGICK_HOME: "{{prefix}}"
  dependencies:
    curl.se: '*'
  script:
    #FIXME: they use a weird versioning scheme
    - magick -version | grep 7.1.1-12
    - curl "https://upload.wikimedia.org/wikipedia/commons/6/6a/PNG_Test.png" -o a.png
    - magick identify a.png | grep "a.png PNG"
