##
##  libvpx.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_release   1.15.2
%define       V_snapshot  20250529

#   package information
Name:         libvpx
Summary:      VP8/VP9 Video Codec
URL:          http://www.webmproject.org/
Vendor:       Google
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Video
License:      BSD
Version:      %{V_release}.%{V_snapshot}
Release:      20250529

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/libvpx/libvpx-%{V_snapshot}.tar.xz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, yasm, perl
PreReq:       OpenPKG, openpkg >= 20160101

%description
    This is the VP8/VP9 codec reference implementation. VP8/VP9 is an
    open video compression format owned by Google and originally created
    by On2 Technologies to replace its predecessor VP7. In the new WebM
    container format (based on the Matroska container format), the VP8
    video is used together with Vorbis audio and in later versions VP9
    video is used together with Opus audio.

%track
    prog libvpx:release = {
        version   = %{V_release}
        url       = https://chromium.googlesource.com/webm/libvpx
        regex     = /v(\d+\.\d+\.\d+)
    }
    prog libvpx:snapshot = {
        version   = %{V_snapshot}
        url       = http://download.openpkg.org/components/versioned/libvpx/
        regex     = libvpx-(__VER__)\.tar\.xz
    }

%prep
    %setup -q -n libvpx

%build
    %{l_shtool} subst \
        -e 's;/bin/bash;%{l_bash};g' \
        configure \
        tools/gen_authors.sh \
        tools/author_first_release.sh \
        build/make/gen_msvs_vcxproj.sh \
        build/make/gen_msvs_def.sh \
        build/make/gen_msvs_sln.sh \
        build/make/version.sh
    cd build
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags -O}"
    ../configure \
        --as=yasm \
        --enable-pic \
        --enable-vp8 \
        --enable-vp9 \
        --enable-postproc \
        --enable-tools \
        --enable-libs \
        --disable-examples \
        --disable-docs \
        --disable-optimizations
    %{l_make} %{l_mflags}

%install
    ( cd build
      %{l_make} %{l_mflags} install DIST_DIR=$RPM_BUILD_ROOT%{l_prefix}
    ) || exit $?
    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/include/vpx
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/bin   >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/build >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/src   >/dev/null 2>&1 || true
    chmod 644 $RPM_BUILD_ROOT%{l_prefix}/include/vpx/*
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

