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

# for strndup
legacysupport.newest_darwin_requires_legacy 10

name                imlib2
version             1.12.6
revision            2
categories          graphics devel
license             Permissive
maintainers         nomaintainer
description         Image loading and rendering library

long_description    Imlib2 is a general image loading and rendering \
                    library designed to make the task of loading \
                    images and obtaining X-Windows drawables a simple \
                    task as well as a quick one. It also aims to \
                    provide simple manipulation routines that might be \
                    desired for common operations.

homepage            https://docs.enlightenment.org/api/imlib2/html/
master_sites        sourceforge:project/enlightenment/imlib2-src/${version}/
use_xz              yes
checksums           rmd160  509ba91d64f4d72c1356032193818cafba4281ec \
                    sha256  250f9752f69dc522e529a81aaa9395705f7fc312ff2453e5de59ac2ba1f2858f \
                    size    844488

depends_build       path:bin/pkg-config:pkgconfig

# No librsvg until 2.46+ is available.

depends_lib-append  port:bzip2 \
                    path:lib/pkgconfig/freetype2.pc:freetype \
                    port:giflib \
                    port:libavif \
                    port:libheif \
                    port:libid3tag \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libjxl \
                    port:libpng \
                    port:libraw \
                    port:libspectre \
                    port:tiff \
                    port:webp \
                    port:xorg-libsm \
                    port:xorg-libX11 \
                    port:xorg-libxcb \
                    port:xorg-libXext \
                    port:xz \
                    port:zlib

# error: redefinition of typedef 'heif_image_handle'
compiler.c_standard 2011

post-patch {
    reinplace "s|-Wl,-z,nodelete||" ${worksrcpath}/src/modules/loaders/Makefile.in
}

configure.args      --disable-amd64 \
                    --disable-silent-rules

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING ChangeLog README \
        TODO ${destroot}${docdir}
}

variant doc {
    depends_lib-append \
                    path:bin/doxygen:doxygen

    configure.args-append \
                    --enable-doc-build

    post-destroot {
        set docdir ${prefix}/share/doc/${name}
        xinstall -d ${destroot}${docdir}/html
        xinstall -m 644 {*}[glob -directory ${worksrcpath}/doc/html *.{html,gif}] \
            ${destroot}${docdir}/html
    }
}

default_variants    +doc

platform darwin 8 {
    patchfiles-append   patch-imlib2-off_t.diff

    configure.args-append --disable-mmx
}

livecheck.distname  ${name}
