##
##  libxml.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 2.9
%define       V_minor 14

#   package information
Name:         libxml
Summary:      Extensible Markup Language (XML) Parsing Library
URL:          http://xmlsoft.org/
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_python no

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

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  zlib, libiconv
PreReq:       zlib, libiconv
%if "%{with_python}" == "yes"
BuildPreReq:  python
PreReq:       python
%endif

%description
    LibXML is a Extensible Markup Language (XML) C library developped
    for the Gnome project. It provides an (optionally validating) XML
    parser, XPath and XPointer implementations, DOM and SAX interfaces
    and support fetching remote resources via HTTP and FTP.

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

%prep
    %setup -q -n libxml2-%{version}
    %patch -p0

%build
    %{l_shtool} subst \
        -e 's;/etc/sgml/catalog;%{l_prefix}/share/sgml/catalog;g' \
        -e 's;/etc/xml/catalog;%{l_prefix}/share/sgml/catalog.xml;g' \
        catalog.c xmlcatalog.c
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O} %{l_cppflags}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    GREP="grep" \
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
        --with-iconv=%{l_prefix} \
        --with-zlib=%{l_prefix} \
        --without-lzma \
        --disable-shared \
        --without-threads \
%if "%{with_python}" == "yes"
        --with-python
%else
        --without-python
%endif
    %{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
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/gtk-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

