##
##  libextractor.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:         libextractor
Summary:      File Extraction and Classification Library
URL:          http://gnunet.org/libextractor/
Vendor:       Christian Grothoff & Vids Samanta
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Filesystem
License:      GPL
Version:      1.7
Release:      20180713

#   list of sources
Source0:      http://ftp.gnu.org/gnu/libextractor/libextractor-%{version}.tar.gz
Source1:      libextractor.pc

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, gcc::with_cxx = yes, make, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  libtool, gettext, libiconv, bzip2, zlib, flac, png, libgsf, glib, poppler
PreReq:       libtool, gettext, libiconv, bzip2, zlib, flac, png, libgsf, glib, poppler

%description
    libextractor is a library used to extract meta-data from files of
    arbitrary type. It is designed to use helper-libraries to perform
    the actual extraction, and to be trivially extendable by linking
    against external extractors for additional file types. Currently, it
    supports the formats HTML, PDF, PS, OLE2 (DOC, XLS, PPT), OpenOffice
    StarOffice, DVI, MAN, FLAC, MP3, NSF(E), SID, OGG, WAV, EXIV2, JPEG,
    GIF, PNG, TIFF, DEB, RPM, TAR(.GZ), ZIP, ELF, S3M (Scream Tracker
    3), XM, IT, FLV, REAL, RIFF (AVI), MPEG, QT and ASF. Also, various
    additional MIME types are detected.

%track
    prog libextractor = {
        version   = %{version}
        url       = http://ftp.gnu.org/gnu/libextractor/
        regex     = libextractor-(__VER__)\.tar\.gz
    }

%prep
    %setup -q

%build
    ( echo "ac_cv_prog_HAVE_CXX=yes"
    ) >config.cache
    CC="%{l_cc}" \
    CXX="%{l_cxx}" \
    CFLAGS="%{l_cflags -O}" \
    CXXFLAGS="%{l_cxxflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    LIBS="`pkg-config gobject-2.0 poppler --libs` -lz -lbz2 -lstdc++" \
    ./configure \
        --cache-file=./config.cache \
        --prefix=%{l_prefix} \
        --libdir=%{l_prefix}/lib \
        --mandir=%{l_prefix}/man \
        --infodir=%{l_prefix}/info \
        --enable-shared \
        --enable-static \
        --enable-gsf \
        --enable-ltdl-install \
        --with-libintl-prefix=%{l_prefix} \
        --with-libiconv-prefix=%{l_prefix} \
        --without-qt \
        --disable-xpdf \
        --disable-exiv2 \
        --disable-gtktest \
        --disable-glibtest \
        --disable-gnome
    %{l_make} %{l_mflags}

%install
    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    %{l_shtool} subst \
        -e 's;^\(dlname=.\).*\(.\);\1\2;' \
        -e 's;^\(library_names=.\).*\(.\);\1\2;' \
        $RPM_BUILD_ROOT%{l_prefix}/lib/libextractor.la \
        $RPM_BUILD_ROOT%{l_prefix}/lib/libextractor_common.la
    strip  $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/locale
    rm -f  $RPM_BUILD_ROOT%{l_prefix}/lib/libextractor/libextractor_*.a
    rm -f  $RPM_BUILD_ROOT%{l_prefix}/lib/libextractor.so*
    rm -f  $RPM_BUILD_ROOT%{l_prefix}/lib/libextractor_common.so*
    rm -f  $RPM_BUILD_ROOT%{l_prefix}/info/dir
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        -e "s;@version@;%{version};" \
        %{SOURCE libextractor.pc} \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

