# -*- 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.02.0 v
revision            1
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  3a725afab382bc2f33e082100dc7c3ad7a6935a0 \
                    sha256  7a265e1cd58b317d8c9175816a54e0ab14199c21d81eb779047d7088fca52ae4 \
                    size    10775839

# 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
