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

github.setup                    AcademySoftwareFoundation openexr 3.5.2 v
github.tarball_from             releases
revision                        0

checksums                       rmd160  c0bc2a81777802246ce26eb57570f77bb445800e \
                                sha256  e5750af57bbed556b462cbf0c39550d9063b2028c0184ec65fe42fdae458cdea \
                                size    26404212

categories                      graphics
license                         BSD
maintainers                     {mascguy @mascguy} \
                                openmaintainer

description                     OpenEXR Graphics Library
long_description                OpenEXR is the professional-grade high dynamic range image \
                                storage format of the motion picture industry.
homepage                        https://www.openexr.com

# Python only used for tests
set py_ver                      3.14
set py_ver_nodot                [string map {. {}} ${py_ver}]

# std::filesystem
legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx     yes

if { (!(${universal_possible} && [variant_isset universal]) && ${configure.build_arch} eq "ppc")
     ||
     ((${universal_possible} && [variant_isset universal]) && "ppc" in ${configure.universal_archs}) } {
    # see description in patch file; bug in GCC, fixed in current branches, but not backported yet:
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110044
    patchfiles-append           patch-ensure_pack.diff
}

# https://trac.macports.org/ticket/74524
# aligned_alloc is missing on macOS <= 10.14
if {${os.platform} eq "darwin" && ${os.major} <= 18} {
    patchfiles-append           patch-src-lib-OpenEXRCore-internal_zstd.c.diff
}

depends_build-append            port:pkgconfig
depends_lib-append              port:imath \
                                port:libdeflate \
                                port:OpenJPH \
                                port:zstd

compiler.cxx_standard           2017

configure.args-append           -DBUILD_TESTING=OFF \
                                -DOPENEXR_BUILD_PYTHON=OFF

variant tests description {Enable test support} {
    depends_build-append        port:python${py_ver_nodot}

    configure.args-replace      -DBUILD_TESTING=OFF \
                                -DBUILD_TESTING=ON

    test.run                    yes
    test.target                 test
}

# only allow numbers, to avoid pre-release versions
github.livecheck.regex          {([0-9.]+)}
