##
##  djvulibre.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 information
Name:         djvulibre
Summary:      DjVu Library
URL:          http://djvu.sourceforge.net/
Vendor:       Leon Bottou & Yann Le Cun et al.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Postscript
License:      GPL
Version:      3.5.29
Release:      20250703

#   list of sources
Source0:      http://download.sourceforge.net/djvu/djvulibre-%{version}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, gcc::with_cxx = yes, make, autoconf, automake
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  libiconv, jpeg, tiff, zlib
PreReq:       libiconv, jpeg, tiff, zlib

%description
    DjVu is a set of compression technologies, a file format, and
    a software platform for the delivery over the Web of digital
    documents, scanned documents, and high resolution images. DjVu
    documents download and display extremely quickly, and look exactly
    the same on all platforms. DjVu can be seen as superior alternative
    to PDF and Postscript for digital documents, to TIFF (and PDF) for
    scanned documents, to JPEG for photographs and pictures, and to
    GIF for large palettized images. DjVu is the only Web format that
    is practical for distributing high-resolution scanned documents in
    color. No other format comes close.

%track
    prog djvulibre = {
        version   = %{version}
        url       = http://djvu.sourceforge.net/index.html
        regex     = djvulibre-(__VER__)\.tar\.gz
    }

%prep
    %setup -q

%build
    sh autogen.sh
    CC="%{l_cc}" \
    CXX="%{l_cxx}" \
    CFLAGS="%{l_cflags -O}" \
    CXXFLAGS="%{l_cxxflags -O}" \
    CPPFLAGS="%{l_cppflags tiff .}" \
    LDFLAGS="%{l_ldflags}" \
    LIBS="-ltiff -ljpeg -lz" \
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
        --with-jpeg=%{l_prefix} \
        --with-tiff=%{l_prefix} \
        --disable-djview \
        --disable-threads \
        --disable-shared \
        --without-x
    %{l_make} %{l_mflags -O}

%install
    %{l_make} %{l_mflags} install \
        prefix=$RPM_BUILD_ROOT%{l_prefix} \
        exec_prefix=$RPM_BUILD_ROOT%{l_prefix} \
        mandir=$RPM_BUILD_ROOT%{l_prefix}/man
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/cs
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/de
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/fr
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/ja
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

