##
##  woff.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 versions
%define       V_opkg       20180902
%define       V_woffcode   20091004
%define       V_wofftools  20180902
%define       V_woff2      20180902

#   package information
Name:         woff
Summary:      WOFF Font Format Tools
URL:          http://people.mozilla.org/~jkew/woff/
Vendor:       Jonathan Kew
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Graphics
License:      MPL/GPL
Version:      %{V_opkg}
Release:      20180902

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/woff/woff-code-%{V_woffcode}.zip
Source1:      http://download.openpkg.org/components/versioned/woff/wofftools-%{V_wofftools}.tar.gz
Source2:      http://download.openpkg.org/components/versioned/woff/woff2-%{V_woff2}.tar.gz
Patch0:       woff.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, gcc::with_cxx = yes
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  zlib, python, fonttools
PreReq:       zlib, python, fonttools

%description
    This is a small utility to convert existing TrueType/OpenType fonts
    (based on the SFNT format) to Mozilla's new Web Open Font Format
    (WOFF) format.

%track
    prog woff:woffcode = {
        version   = %{V_woffcode}
        url       = http://download.openpkg.org/components/versioned/woff/
        regex     = woff-code-(__VER__)\.zip
    }
    prog woff:wofftools = {
        version   = %{V_wofftools}
        url       = http://download.openpkg.org/components/versioned/woff/
        regex     = wofftools-(__VER__)\.tar\.gz
    }
    prog woff:woff2 = {
        version   = %{V_woff2}
        url       = http://download.openpkg.org/components/versioned/woff/
        regex     = woff2-(__VER__)\.tar\.gz
    }

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

%build
    %{l_make} %{l_mflags} \
        CC="%{l_cc}" \
        CFLAGS="%{l_cflags -O} %{l_cppflags}" \
        LDFLAGS="%{l_ldflags}"
    ( cd wofftools
      %{l_prefix}/bin/python setup.py build
    ) || exit $?
    ( cd woff2
      %{l_make} %{l_mflags} \
          CC="%{l_cc} %{l_cflags -O}" \
          CXX="%{l_cxx} %{l_cxxflags -O}"
    ) || exit $?

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin
    %{l_shtool} install -c -s -m 755 \
        sfnt2woff $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -s -m 755 \
        woff2sfnt $RPM_BUILD_ROOT%{l_prefix}/bin/
    ( cd wofftools
      %{l_prefix}/bin/python setup.py install \
          --root=$RPM_BUILD_ROOT \
          --prefix=%{l_prefix}
    ) || exit $?
    %{l_shtool} install -c -s -m 755 \
        woff2/woff2_compress woff2/woff2_decompress \
        $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

