# -*- 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           gitlab 1.0
PortGroup           muniversal 1.1

epoch               1

gitlab.instance     https://code.videolan.org
# Get minor version (X264_BUILD) from
# https://code.videolan.org/videolan/x264/-/blob/stable/x264.h
# Get patch version using commit id from
# https://artifacts.videolan.org/x264/release-macos-arm64/
# Change in minor version requires rev-bumping dependents
gitlab.setup        videolan x264 b35605ace3ddf7c1a5d67a2eb553f034aef41d55
version             0.165.3222
revision            0
categories          multimedia
license             GPL-2+
maintainers         {devans @dbevans} {makr @mohd-akram} openmaintainer
description         x264 - a free h264/avc encoder
long_description    x264 is a free library for encoding H264/AVC video streams. \
                    The code is written by Laurent Aimar, Eric Petit(OS X), Min \
                    Chen (vfw/nasm), Justin Clay(vfw), Måns Rullgård and Loren \
                    Merritt from scratch. It is released under the terms of the \
                    GPL license.
homepage            https://www.videolan.org/x264.html

checksums           rmd160  55d345985a769c873d22278a7f9268d8059c9bb5 \
                    sha256  6eeb82934e69fd51e043bd8c5b0d152839638d1ce7aa4eea65a3fedcf83ff224 \
                    size    848719

depends_build       port:nasm

patchfiles          altivec-x264.patch

set rev             [lindex [split ${version} .] 2]
set sha             [string range ${gitlab.version} 0 6]

post-patch {
    reinplace "s|ver=\"x\"|ver=\"$rev $sha\"|" \
        ${worksrcpath}/version.sh
    reinplace "s|version=\"\"|version=\" r$rev $sha\"|" \
        ${worksrcpath}/version.sh
}

configure.args      --enable-pic \
                    --enable-shared \
                    --enable-static \
                    --disable-avs \
                    --disable-swscale \
                    --disable-lavf \
                    --disable-ffms \
                    --disable-gpac \
                    --disable-lsmash

platform darwin powerpc {
    configure.args-append   --disable-vsx
}

platform darwin 8 {
    depends_build-append    port:gmake
    build.cmd               gmake
}

# sets its own optflags
configure.optflags

# https://trac.macports.org/ticket/72733
if {[info exists livecheck.branch]} {
livecheck.url       ${git.url}
livecheck.type      git
livecheck.branch    stable
} else {
livecheck.type      none
}
