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

github.setup        thorfdbg libjpeg 702114c8130ae818ccd2354cc03e879dac69e579
# https://github.com/macports/macports-ports/pull/28116#issuecomment-2847585194
name                jpeg-xt
# https://github.com/thorfdbg/libjpeg/blob/master/README
version             1.72
revision            0

categories          graphics
license             GPL-3
maintainers         {@Dave-Allured noaa.gov:dave.allured} \
                    openmaintainer

description         Complete implementation of 10918-1 (JPEG) from jpeg.org

long_description    A complete implementation of 10918-1 (JPEG) coming \
                    from jpeg.org (the ISO group) with extensions for \
                    HDR standardized as 18477 (JPEG XT).

checksums           rmd160  3b7e6a743c676d2c87b222b0b482cfa2622853f1 \
                    sha256  91cc611c6ead4fd34cabdb724b8f2abd86163ed5e3cc444af40fce2a742e8b94 \
                    size    565303

post-patch {
    reinplace {s|-Wno-shift-negative-value||} \
        ${worksrcpath}/Makefile_Settings.gcc
}

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

build.target        doc final

destroot.destdir    INSTALLDIR=${destroot}${prefix}/bin

if {[string match *clang* ${configure.cc}]} {
    build.target-append \
                    SETTINGS=clang
    destroot.post_args-append \
                    SETTINGS=clang
} elseif {[string match *gcc* ${configure.cc}]} {
    build.target-append \
                    SETTINGS=gcc
    destroot.post_args-append \
                    SETTINGS=gcc
}

post-destroot {
    move            ${destroot}${prefix}/bin/jpeg \
                    ${destroot}${prefix}/bin/jpeg-xt
}

# Upstream does not use github tags, but keeps version numbers in the README.
livecheck.type      regex
livecheck.version   ${version}
livecheck.url       ${github.homepage}/raw/refs/heads/master/README
livecheck.regex     {Release +([0-9.]+):}
