# -*- 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           compiler_blacklist_versions 1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.1

github.setup        gpac gpac 2.2.1 v
revision            2
categories          multimedia
maintainers         {outlook.com:mohd.akram @mohd-akram} openmaintainer
license             LGPL-2.1+

description         multimedia framework for research and academic purposes
long_description    GPAC is an Open Source multimedia framework for \
                    research and academic purposes. The project \
                    covers different aspects of multimedia, with a \
                    focus on presentation technologies (graphics, \
                    animation and interactivity). Includes MP4Box and \
                    Osmo4.

homepage            https://gpac.wp.imt.fr

github.tarball_from archive
checksums           rmd160  e4d98e4053ea317a0042ced770f44d007a03f088 \
                    sha256  8173ecc4143631d7f2c59f77e1144b429ccadb8de0d53a4e254389fb5948d8b8 \
                    size    11377184

# Needed for clock_gettime()
legacysupport.newest_darwin_requires_legacy \
                    15

depends_build       port:pkgconfig \
                    port:zlib

depends_lib         port:freetype \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    port:openjpeg \
                    port:libmad \
                    port:faad2 \
                    port:libogg \
                    port:libvorbis \
                    port:libtheora \
                    port:a52dec \
                    path:lib/libavcodec.dylib:ffmpeg \
                    port:x264 \
                    port:aom \
                    port:XviD \
                    path:lib/libssl.dylib:openssl \
                    port:libsdl2

# Though HEVC is officially supported only in 10.13+, the symbol
# kCMVideoCodecType_HEVC is available in 10.11+ [1][2]
# [1] https://build.macports.org/builders/ports-10.10_x86_64-builder/builds/94933/steps/install-port/logs/stdio
# [2] https://build.macports.org/builders/ports-10.11_x86_64-builder/builds/94369/steps/install-port/logs/stdio
patchfiles          patch-configure.diff \
                    patch-no-hevc-yosemite.diff

post-patch {
    reinplace "s|@APPLICATIONS_DIR@|${applications_dir}|g" ${worksrcpath}/configure
}

if {${os.platform} eq "darwin" && ${os.major} < 12} {
    known_fail  yes
    pre-fetch {
        # See https://trac.macports.org/ticket/56408
        ui_error "${name} @${version} requires OS X 10.8 or greater."
        return -code error "incompatible Mac OS X version"
    }
}

# fatal error: 'stdatomic.h' file not found
compiler.blacklist-append {clang < 700}
compiler.c_standard   2011

# pulseaudio is recognized if installed but build fails
# -fno-builtin-strrchr to fix https://trac.macports.org/ticket/68589
configure.args      --cc="${configure.cc}" \
                    --cxx="${configure.cxx}" \
                    --extra-cflags="${configure.cc_archflags} -fno-builtin-strrchr" \
                    --extra-ldflags="${configure.ld_archflags}" \
                    --mandir=${prefix}/share/man \
                    --disable-pulseaudio \
                    --disable-x11 \
                    --verbose

# This project's build system detects CPU and endianness at configure time.
# muniversal is worth a try.
universal_variant   no
use_parallel_build  no
