# -*- 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           boost 1.0
PortGroup           compiler_blacklist_versions 1.0

name                libopenraw-legacy
version             0.3.7
revision            1

categories          graphics
license             LGPL-3+
maintainers         {mascguy @mascguy} {@barracuda156 gmail.com:vital.had} openmaintainer

description         libopenraw is an ongoing project to provide a free software implementation \
                    for decoding camera RAW files.
long_description    ${description} \
                    One of the main reasons is that dcraw is not suited for easy integration into \
                    applications, and there is a need for an easy to use API to build free software \
                    digital image processing applications. It also has the goal to address features \
                    missing from dcraw such as meta-data decoding and easy thumbnail extraction.

homepage            https://libopenraw.freedesktop.org/${name}/
master_sites        https://libopenraw.freedesktop.org/download/

use_xz              yes

distname            libopenraw-${version}
checksums           ${distname}${extract.suffix} \
                    rmd160  0b9a75af63f820c8785038adc66b085bed9b742f \
                    sha256  0ece41951b2cd91e43f6a8a5c6a894bbc8b5923b4e49a82ebb6d8ce62bded68c \
                    size    2536380

conflicts           libopenraw

# https://gitlab.freedesktop.org/libopenraw/libopenraw/-/issues/13
patchfiles          patch-Makefile.am.diff \
                    patch-ifdentry.hpp.diff \
                    patch-Make-CR3-support-optional.diff \
                    patch-endian.diff

depends_build-append \
                    port:autoconf-archive \
                    port:cctools \
                    port:gawk \
                    port:grep \
                    port:gsed \
                    port:pkgconfig

depends_lib-append  port:curl \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libxml2

#--------------------------------------------------------------------------------------------------
# Blacklist MacPorts Clang 14 and 15 for now, as crashes during link.
#
# See: https://trac.macports.org/ticket/65246
#--------------------------------------------------------------------------------------------------
compiler.blacklist-append \
                    {macports-clang-1[4-5]}

# as of version 0.3.0 requires C++14 to build
compiler.cxx_standard 2014

# Teach glibtool about -stdlib=libc++
use_autoreconf      yes
autoreconf.args     -fvi

configure.args-append \
                    --with-boost=[boost::install_area] \
                    --disable-gnome \
                    --disable-cr3

variant gnome description {Build with GNOME/GTK+ support} {
    depends_build-append \
                    port:gettext
    depends_lib-append \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2
    configure.args-delete \
                   --disable-gnome
}

default_variants +gnome

# Disable silent rules
build.args          V=1

post-activate {
    if {[variant_isset gnome]} {
        ui_debug "Updating gdk-pixbuf.loaders..."
        system "${prefix}/bin/gdk-pixbuf-query-loaders --update-cache"
    }
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
