# -*- 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 latest stable commit id from
# https://code.videolan.org/videolan/x264/-/tree/stable
# Get minor version (X264_BUILD) from
# https://code.videolan.org/videolan/x264/-/blob/stable/x264.h
# Run port livecheck to get patch version
# Change in minor version requires rev-bumping dependents
gitlab.setup        videolan x264 31e19f92f00c7003fa115047ce50978bc98c3a0d
version             0.164.3108
revision            1
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  e006e270e1c87c70ddee225ebaf2f586ad8620f3 \
                    sha256  01a4acb74eea1118c3aa96c3e18ee3384bc1f2bc670f31fb0f63be853e4d9d08 \
                    size    778279

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

# Can't livecheck stable branch but use it to validate version matches commit
livecheck.url       https://artifacts.videolan.org/x264/release-macos-arm64/
livecheck.type      regex
livecheck.version   $rev
livecheck.regex     "r(\[0-9]+)-$sha"
