##
##  libxslt.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_major 1.1
%define       V_minor 35

#   package information
Name:         libxslt
Summary:      XML Stylesheet Language (XSL) Transformation Library
URL:          http://xmlsoft.org/XSLT/
Vendor:       Daniel Veillard
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        XML
License:      MIT-style
Version:      %{V_major}.%{V_minor}
Release:      20220523

#   package options
%option       with_regexp  no
%option       with_crypto  no

#   list of sources
Source0:      https://download.gnome.org/sources/libxslt/%{V_major}/libxslt-%{version}.tar.xz
Patch0:       libxslt.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  libxml >= 2.6.32
PreReq:       libxml >= 2.6.32
%if "%{with_regexp}" == "yes"
BuildPreReq:  pcre
PreReq:       pcre
%endif
%if "%{with_crypto}" == "yes"
BuildPreReq:  gcrypt
PreReq:       gcrypt
%endif

%description
    LibXSLT is a XML Stylesheet Language (XSL) Transformation C library
    developped for the Gnome project. It provides an XSLT engine for
    transforming XML documents into other (output) markup languages.

%track
    prog libxslt = {
        version   = %{version}
        url       = https://gitlab.gnome.org/GNOME/libxslt/-/releases
        regex     = libxslt-(\d+\.\d+\.\d+)\.tar\.gz
    }

%prep
    %setup -q
    %patch -p0

%build
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags -O} %{l_cppflags}"
    export CPPFLAGS="%{l_cppflags}"
    export LDFLAGS="%{l_ldflags}"
    export LIBS="-lz -liconv"
%if "%{with_regexp}" == "yes"
    CPPFLAGS="$CPPFLAGS -DEXSLT_REGEXP_ENABLED"
    LIBS="$LIBS -lpcre"
    %{l_shtool} subst \
        -e 's;\(@EXSLT_LIBS@\);\1 -lpcre;g' \
        libexslt.pc.in
%endif
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
        --with-libxml-prefix=%{l_prefix} \
%if "%{with_crypto}" == "yes"
        --with-crypto \
%else
        --without-crypto \
%endif
        --without-debug \
        --without-python \
        --enable-static \
        --disable-shared
    %{l_make} %{l_mflags -O}

%install
    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std}

%files -f files

%clean

