# -*- 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           cmake 1.1
PortGroup           github 1.0
PortGroup           muniversal 1.0

github.setup        libjpeg-turbo libjpeg-turbo 3.0.3
categories          graphics
license             BSD
maintainers         {larryv @larryv} {mascguy @mascguy} {jmr @jmroot}

conflicts           libjpeg-turbo-devel mozjpeg

description         SIMD-accelerated libjpeg-compatible JPEG codec \
                    library
long_description    libjpeg-turbo is a JPEG image codec that uses SIMD \
                    instructions (MMX, SSE2, NEON) to accelerate \
                    baseline JPEG compression and decompression on \
                    x86, x86-64, and ARM systems. On such systems, \
                    libjpeg-turbo is generally 2-6x as fast as \
                    libjpeg, all else being equal. On other types of \
                    systems, libjpeg-turbo can still outperform \
                    libjpeg by a significant amount, by virtue of its \
                    highly-optimized Huffman coding routines. In many \
                    cases, the performance of libjpeg-turbo rivals \
                    that of proprietary high-speed JPEG codecs.
homepage            https://www.libjpeg-turbo.org/

github.tarball_from releases
checksums           rmd160 e2c1243ff02d41d87eecf2680825dc2ed5b063e0 \
                    sha256 343e789069fc7afbcdfe44dbba7dbbf45afa98a15150e079a38e60e44578865d

configure.args      -DWITH_JPEG8=ON

if {${universal_possible} && [variant_isset universal]} {
    if {"x86_64" in ${configure.universal_archs} || "i386" in ${configure.universal_archs}} {
        depends_build-append port:nasm
    }
    set merger_configure_env(i386)  ASM_NASM=${prefix}/bin/nasm
    set merger_configure_env(x86_64)    ASM_NASM=${prefix}/bin/nasm
} elseif {${configure.build_arch} in {i386 x86_64}} {
    depends_build-append port:nasm
    configure.env       ASM_NASM=${prefix}/bin/nasm
} elseif {${configure.build_arch} eq "ppc"} {
    if {[catch {sysctl hw.vectorunit} result] || $result == 0} {
        configure.args-append   -DWITH_SIMD=OFF
        archive_sites
    }
}

variant java description "Add Java support" {
    PortGroup           java 1.0

    java.version        1.8
    java.fallback       openjdk8
    configure.args-append -DWITH_JAVA=ON
}

test.run            yes
test.env            CTEST_OUTPUT_ON_FAILURE=1

# Betas are numbered x.x.9x
livecheck.regex     [string cat {(\d+\.\d+\.(?:\d|[0-8]\d)(?:\.[0-9]+)*)} [quotemeta ${extract.suffix}]]
