##
##  subversion-perl.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_dist      1.14.5
%define       V_opkg      1.14.5

#   package information
Name:         subversion-perl
Summary:      Subversion Source Revision Control System (Perl Bindings)
URL:          http://subversion.apache.org/
Vendor:       Apache Software Foundation
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        SCM
License:      Apache/BSD
Version:      %{V_opkg}
Release:      20241209

#   list of sources
Source0:      http://www.apache.org/dist/subversion/subversion-%{V_dist}.tar.bz2

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, libtool, sed, pkgconfig, swig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  zlib, libiconv, expat, serf, apr, sqlite, libutf8proc, lz4
PreReq:       zlib, libiconv, expat, serf, apr, sqlite, libutf8proc, lz4
BuildPreReq:  perl, perl-openpkg
PreReq:       perl

%description
    This is the Subversion Perl language bindings.

%track
    prog subversion-perl = {
        version   = %{V_dist}
        url       = http://subversion.apache.org/download/
        regex     = subversion-(\d+\.\d+.\d+)\.tar\.bz2
    }

%prep
    %setup -q -n subversion-%{V_dist}

    #   patch: adjust path to configuration directory
    %{l_shtool} subst \
        -e 's;/etc/subversion;%{l_prefix}/etc/subversion;g' \
        subversion/libsvn_subr/config_impl.h \
        subversion/libsvn_subr/config_file.c

%build
    #   configure package
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags libxml2 openssl10 .} -DSQLITE_THREADSAFE=1" \
    LDFLAGS="%{l_ldflags openssl10 .} %{l_fsl_ldflags}" \
    LIBS="`pkg-config serf-1 apr-util-1 --libs-only-l` -lz %{l_fsl_libs} -lm" \
    CONFIG_SHELL="%{l_bash}" \
    PERL="%{l_prefix}/bin/perl" \
    RUBY="false" \
    PYTHON="false" \
    ./configure \
        --prefix=%{l_prefix} \
        --libdir=%{l_prefix}/lib/subversion-perl \
        --mandir=%{l_prefix}/man \
        --without-berkeley-db \
        --with-sqlite=%{l_prefix} \
        --with-zlib=%{l_prefix} \
        --with-apr=%{l_prefix} \
        --with-apr-util=%{l_prefix} \
        --with-serf=%{l_prefix} \
        --with-swig=%{l_prefix}/bin/swig \
        --with-perl=%{l_prefix}/bin/perl \
        --without-sasl \
        --without-apxs \
        --disable-nls \
        --enable-shared \
        --disable-static

    #   build package
    %{l_make} %{l_mflags}

    #   build Python bindings
    %{l_make} %{l_mflags} swig-pl

%install
    #   install package
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT

    #   install Python bindings
    %{l_make} %{l_mflags} install-swig-pl DESTDIR=$RPM_BUILD_ROOT
    %{l_prefix}/bin/perl-openpkg -F- fixate >/dev/null

    #   strip down installation
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/bin
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/build-1
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/include
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/subversion-perl/pkgconfig

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

