# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem                  1.0
PortGroup                   github 1.0
PortGroup                   muniversal 1.0

# getline
# https://github.com/libgd/libgd/issues/611
PortGroup                   legacysupport 1.0
legacysupport.newest_darwin_requires_legacy 10

github.setup                libgd libgd 2.3.3 gd-
revision                    7
checksums                   rmd160  97564248f7f14e90921c5571ff69d1aba5e016cc \
                            sha256  3fe822ece20796060af63b7c60acb151e5844204d289da0ce08f8fdf131e5a61 \
                            size    2809056

name                        gd2
categories                  graphics
maintainers                 {ryandesign @ryandesign} openmaintainer
license                     gd
homepage                    https://libgd.github.io
platforms                   darwin
use_parallel_build          yes

description                 GD creates PNG and JPEG images, among other formats

long_description            gd is a graphics library. It allows your code to \
                            quickly draw images complete with lines, arcs, \
                            text, multiple colors, cut and paste from other \
                            images, and flood fills, and write out the result \
                            as a .PNG file. This is particularly useful in \
                            World Wide Web applications, where .PNG is the \
                            format used for inline images. gd is not a paint \
                            program. If you are looking for a paint program, \
                            you are looking in the wrong place. If you are not \
                            a programmer, you are looking in the wrong place.

github.tarball_from         releases
use_xz                      yes

depends_build               port:gettext \
                            path:bin/pkg-config:pkgconfig

depends_lib                 port:freetype \
                            port:fontconfig \
                            path:include/turbojpeg.h:libjpeg-turbo \
                            port:libheif \
                            port:libiconv \
                            port:libpng \
                            port:tiff \
                            port:webp \
                            port:zlib

patchfiles                  patch-src-gdft.c.diff

configure.args-append       --disable-werror \
                            --with-freetype=${prefix} \
                            --with-fontconfig=${prefix} \
                            --with-heif=${prefix} \
                            --with-jpeg=${prefix} \
                            --with-png=${prefix} \
                            --with-tiff=${prefix} \
                            --with-webp=${prefix} \
                            --with-zlib=${prefix} \
                            --without-avif \
                            --without-liq \
                            --without-raqm \
                            --without-x \
                            --without-xpm

configure.cflags-append     -DDEFAULT_FONTPATH='"/System/Library/Fonts:/Library/Fonts"'

variant x11 {
    depends_lib-append      port:xpm
    configure.args-delete   --without-x \
                            --without-xpm
    configure.args-append   --with-xpm=${prefix} \
                            --x-includes=${prefix}/include \
                            --x-libraries=${prefix}/lib
}

default_variants +x11
