##
##  dirac.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_dirac         1.0.2
%define       V_schroedinger  1.0.11

#   package information
Name:         dirac
Summary:      DIRAC Video Codec
URL:          http://diracvideo.org/
Vendor:       Thomas Davies, David Schleef
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Video
License:      MPL, MIT
Version:      %{V_dirac}
Release:      20161210

#   list of sources
Source0:      http://diracvideo.org/download/dirac-research/dirac-%{V_dirac}.tar.gz
Source1:      http://diracvideo.org/download/schroedinger/schroedinger-%{V_schroedinger}.tar.gz
Patch0:       dirac.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, gcc::with_cxx = yes, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  orc
PreReq:       orc

%description
    Dirac is an advanced royalty-free video compression format designed
    for a wide range of uses, from delivering low-resolution web content
    to broadcasting HD and beyond, to near-lossless studio editing. The
    name "Dirac" is a reference to Paul A. M. Dirac, British physicist
    and winner of the 1933 Nobel Prize in Physics. The prize was shared
    with Erwin Schrödinger, for whom the Schroedinger implementation of
    Dirac was named. This OpenPKG package contains with the original
    libdirac (C++) and the newer libschroedinger (C) implementation.

%track
    prog dirac:dirac = {
        version   = %{V_dirac}
        url       = http://diracvideo.org/download/dirac-research/
        regex     = dirac-(__VER__)\.tar\.gz
    }
    prog dirac:schroedinger = {
        version   = %{V_schroedinger}
        url       = http://diracvideo.org/download/schroedinger/
        regex     = schroedinger-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -c -T -D -a 1
    %patch -p0

%build
    ( cd dirac-%{V_dirac}
      CC="%{l_cc}" \
      CXX="%{l_cxx}" \
      CFLAGS="%{l_cflags -O}" \
      CXXFLAGS="%{l_cxxflags -O}" \
      ./configure \
          --prefix=%{l_prefix} \
          --disable-shared
      %{l_make} %{l_mflags -O}
    ) || exit $?
    ( cd schroedinger-%{V_schroedinger}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      ./configure \
          --prefix=%{l_prefix} \
          --disable-orc \
          --disable-gtk-doc \
          --disable-gstreamer \
          --disable-shared
      %{l_make} %{l_mflags -O}
    ) || exit $?

%install
    ( cd dirac-%{V_dirac}
      %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    ) || exit $?
    ( cd schroedinger-%{V_schroedinger}
      %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    ) || exit $?
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/gtk-doc >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

