# -*- 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
conflicts           libopenraw
set my_name         libopenraw
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.

set url_base        https://libopenraw.freedesktop.org
set url_home        ${url_base}/${my_name}/
set url_download    ${url_base}/download/
homepage            ${url_home}
master_sites        ${url_download}
use_bzip2           yes
distname            ${my_name}-${version}
dist_subdir         ${my_name}

# stealth update; remove for next release
dist_subdir         ${dist_subdir}/${version}_1
checksums           rmd160  0a220994efdbd6c2f9129fd05d1ee0d9c987e2fb \
                    sha256  5515b2610361ef34580b6b976635119f6dedb4f0a79d54662fa5fe6186a45ed5 \
                    size    3026490

# https://gitlab.freedesktop.org/libopenraw/libopenraw/-/issues/13
patchfiles-append   patch-Makefile.am.diff
patchfiles-append   patch-ifdentry.hpp.diff
patchfiles-append   patch-Make-CR3-support-optional.diff
patchfiles-append   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       ${url_home}
livecheck.regex     "${my_name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"