# -*- 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                   conflicts_build 1.0
PortGroup                   legacysupport 1.1

# TARGET_OS_IOS, TARGET_OS_WATCH, TARGET_OS_TV missing in TargetConditionals.h:
legacysupport.newest_darwin_requires_legacy 11

# Keep relevant lines in sync between ImageMagick and p5-perlmagick.

# Before updating to a newer version, install phpNN-imagick. After updating, run `phpNN -v`. If the following warning appears, revbump php-imagick.
# PHP Warning:  Version warning: Imagick was compiled against Image Magick version XXXX but version YYYY is loaded. Imagick will run but may behave surprisingly in Unknown on line 0

name                        ImageMagick
version                     6.9.13-46
revision                    0

checksums                   rmd160  1361bb5a5d5b115a1963ba7bad5e771e648dfcad \
                            sha256  012216e6e20985185922ced98e8e971cc91319e15df154255a49a716b06742d2 \
                            size    9634252

categories                  graphics devel
maintainers                 {ryandesign @ryandesign}
license                     Apache-2
use_xz                      yes

description                 Tools and libraries to manipulate images in many formats

long_description            This is the legacy ImageMagick version 6.  For the \
                            modern ImageMagick version 7, please go to port \
                            ImageMagick7. \
                            \
                            ImageMagick is a robust collection of tools and \
                            libraries to create, edit and compose bitmap images \
                            in a wide variety of formats. You can crop, resize, \
                            rotate, sharpen, color reduce or add effects or text \
                            or straight or curved lines to an image or image \
                            sequence and save your completed work in the same or \
                            differing image format. You can even create images \
                            from scratch. Image processing operations are \
                            available from the command line as well as through \
                            C, Ch, C++, Java, Perl, PHP, Python, Ruby and Tcl/Tk \
                            programming interfaces. Over 90 image formats are \
                            supported, including GIF, JPEG, JPEG 2000, PNG, PDF, \
                            PhotoCD and TIFF.

homepage                    https://legacy.imagemagick.org
master_sites                https://imagemagick.org/archive/ \
                            https://imagemagick.org/archive/releases/ \
                            https://mirror.aarnet.edu.au/pub/imagemagick/ \
                            https://ftp.icm.edu.pl/pub/unix/graphics/ImageMagick/ \
                            https://mirror.accum.se/mirror/imagemagick.org/ftp/ \
                            https://mirror.metanet.ch/imagemagick/ \
                            http://mirror.checkdomain.de/imagemagick/releases/ \
                            ftp://sunsite.icm.edu.pl/packages/ImageMagick/releases/

depends_lib                 port:bzip2 \
                            port:djvulibre \
                            port:xz \
                            port:jbigkit \
                            path:include/turbojpeg.h:libjpeg-turbo \
                            port:lcms2 \
                            port:libpng \
                            port:libraw \
                            port:tiff \
                            port:webp \
                            port:zlib \
                            port:fftw-3 \
                            port:freetype \
                            port:fontconfig \
                            port:ghostscript \
                            port:libiconv \
                            port:libtool \
                            port:openjpeg \
                            port:expat \
                            port:libxml2 \
                            port:libheif

# Magick-config etc. use pkg-config
depends_lib-append          path:bin/pkg-config:pkgconfig

depends_run                 port:urw-fonts

compiler.c_standard         2011

configure.ccache            no

configure.args              --enable-shared \
                            --enable-static \
                            --disable-silent-rules \
                            --with-frozenpaths \
                            --disable-hdri \
                            --with-dps \
                            --with-bzlib \
                            --with-djvu \
                            --with-fftw \
                            --with-fontconfig \
                            --with-gslib \
                            --with-jbig \
                            --with-jpeg \
                            --with-lcms \
                            --with-openjp2 \
                            --with-png \
                            --with-tiff \
                            --with-webp \
                            --with-zlib \
                            --with-modules \
                            --with-xml \
                            --with-heic \
                            --without-gcc-arch \
                            --without-perl \
                            --without-fpx \
                            --without-wmf \
                            --without-gvc \
                            --without-rsvg \
                            --without-openexr \
                            --without-lqr \
                            --without-pango \
                            --without-raqm \
                            --without-x \
                            --without-zstd \
                            --with-gs-font-dir=${prefix}/share/fonts/urw-fonts \
                            --disable-openmp

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    configure.args-append   --disable-opencl
} else {
    configure.args-append   --enable-opencl
    # On case-insensitive filesystems, ImageMagick finds cryptlib's libcl and
    # tries to use it as if it were Apple's OpenCL, which fails; see #23354.
    if {[file exists ${prefix}/lib/libCL.dylib]} {
        conflicts_build         cryptlib
    }
}

# https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr
configure.checks.implicit_function_declaration.whitelist-append strchr

test.run                    yes
test.target                 check
test.env                    DYLD_LIBRARY_PATH=${worksrcpath}/magick/.libs

# ImageMagick uses .la files at runtime to find its coder modules.
destroot.delete_la_files    no

variant graphviz description {Support Graphviz} {
    depends_lib-append      path:bin/dot:graphviz
    configure.args-replace  --without-gvc --with-gvc
}

variant lqr description {Support Liquid Rescale (experimental)} {
    depends_lib-append      port:liblqr
    configure.args-replace  --without-lqr --with-lqr
}

variant openexr description {Support OpenEXR} {
    depends_lib-append      port:openexr
    configure.args-replace  --without-openexr --with-openexr
}

variant pango description {Support Pango} {
    depends_lib-append      path:lib/pkgconfig/pango.pc:pango
    configure.args-replace  --without-pango --with-pango
}

variant rsvg description {Support SVG using librsvg} {
    depends_lib-append      path:lib/pkgconfig/librsvg-2.0.pc:librsvg
    configure.args-replace  --without-rsvg --with-rsvg
}

variant wmf description {Support the Windows Metafile Format} {
    depends_lib-append      port:libwmf
    configure.args-replace  --without-wmf --with-wmf
}

variant x11 {
    depends_lib-append      port:xorg-libX11 \
                            port:xorg-libXext \
                            port:xorg-libXt
    configure.args-replace  --without-x --with-x
}

default_variants            +openexr +x11

livecheck.type              regex
livecheck.url               [lindex ${master_sites} 0]
livecheck.regex             ${name}-(6(?:\\.\\d+)+(?:-\\d+)?)\.tar
