# -*- 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.2.4 v
github.tarball_from             archive
revision                        0

checksums                       rmd160  e3ddfebd6a6aa17507bd7e19e0e479b13c57e240 \
                                sha256  81e6518f2c4656fdeaf18a018f135e96a96e7f66dbe1c1f05860dd94772176cc \
                                size    18856440

categories                      graphics
license                         BSD
maintainers                     {mcalhoun @MarcusCalhoun-Lopez} {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.12
set py_ver_nodot                [string map {. {}} ${py_ver}]

# NOTE: legacysupport needed for 'sys/fcntl.h'
legacysupport.newest_darwin_requires_legacy 12
platform darwin {
    # Also need macports-libcxx for 10.7/10.8
    if { (${os.major} >= 11) && (${os.major} <= 12) } {
        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
}

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

compiler.cxx_standard           2014

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.]+)}
