# -*- 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
PortGroup           legacysupport 1.1
PortGroup           ffmpeg 1.0
PortGroup           limit_flags 1.0

github.setup        gpac gpac 26.07.0 v
revision            0
categories          multimedia
# https://trac.macports.org/ticket/56408
platforms           {darwin >= 12}
maintainers         {makr @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  5e3e747f55f469157b83282de937b14638518ded \
                    sha256  57822c1a74dcb83d76ff1f671e1b4fae2e7614e8194a5adb9f20661e0e9421dd \
                    size    10835591

# Needed for clock_gettime()
legacysupport.newest_darwin_requires_legacy \
                    15

ffmpeg.version      8

depends_build       path:bin/pkg-config:pkgconfig

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 \
                    port:XviD \
                    port:zlib \
                    path:lib/libssl.dylib:openssl \
                    port:libsdl2 \
                    port:libcaca \
                    port:nghttp2 \
                    port:curl \
                    port:pulseaudio \
                    port:xz

# 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-static.diff \
                    patch-no-hevc-yosemite.diff

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

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

# pulseaudio is recognized if installed but build fails
configure.args      --cc="${configure.cc}" \
                    --cxx="${configure.cxx}" \
                    --extra-cflags="${configure.cc_archflags}" \
                    --extra-ldflags="${configure.ld_archflags}" \
                    --mandir=${prefix}/share/man \
                    --disable-jack \
                    --disable-x11 \
                    --verbose

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

livecheck.url       ${github.homepage}/releases
livecheck.regex     tag/${github.tag_prefix}${github.livecheck.regex}
