
%define apuver 1

Summary: Apache Portable Runtime Utility library
Name: apr-util
Version: APU_VERSION
Release: APU_RELEASE%{?dist}
License: Apache-2.0 AND (Beerware AND LicenseRef-Fedora-Public-Domain AND OLDAP-2.7 AND BSD-4.3RENO)
URL: http://apr.apache.org/
Source0: https://www.apache.org/dist/apr/%{name}-%{version}.tar.bz2
BuildRequires: gcc
BuildRequires: autoconf, apr-devel >= 1.3.0
BuildRequires: pkgconfig(expat), libuuid-devel
BuildRequires: libxcrypt-devel
Recommends: apr-util-openssl%{_isa} = %{version}-%{release}
Recommends: apr-util-lmdb%{_isa} = %{version}-%{release}

%description
The mission of the Apache Portable Runtime (APR) is to provide a
free library of C data structures and routines.  This library
contains additional utility interfaces for APR; including support
for XML, LDAP, database interfaces, URI parsing and more.

%package devel
Summary: APR utility library development kit
Requires: apr-util%{?_isa} = %{version}-%{release}, apr-devel%{?_isa}, pkgconfig
Requires: pkgconfig(ldap)

%description devel
This package provides the support files which can be used to 
build applications using the APR utility library.  The mission 
of the Apache Portable Runtime (APR) is to provide a free 
library of C data structures and routines.

%package lmdb
Summary: APR utility library LMDB driver
BuildRequires: pkgconfig(lmdb)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(lmdb) = %{version}-%{release}

%description lmdb
This package provides the LMDB driver for the apr-util
DBM (database abstraction) interface.

%package pgsql
Summary: APR utility library PostgreSQL DBD driver
BuildRequires: pkgconfig(libpq)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(pgsql) = %{version}-%{release}

%description pgsql
This package provides the PostgreSQL driver for the apr-util
DBD (database abstraction) interface.

%package mysql
Summary: APR utility library MySQL DBD driver
BuildRequires: pkgconfig(mariadb)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(mysql) = %{version}-%{release}

%description mysql
This package provides the MySQL driver for the apr-util DBD
(database abstraction) interface.

%package sqlite
Summary: APR utility library SQLite DBD driver
BuildRequires: pkgconfig(sqlite3)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(sqlite) = %{version}-%{release}

%description sqlite
This package provides the SQLite driver for the apr-util DBD
(database abstraction) interface.

%package odbc
Summary: APR utility library ODBC DBD driver
BuildRequires: pkgconfig(odbc)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(odbc) = %{version}-%{release}

%description odbc
This package provides the ODBC driver for the apr-util DBD
(database abstraction) interface.

%package ldap
Summary: APR utility library LDAP support
BuildRequires: pkgconfig(ldap)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(ldap) = %{version}-%{release}

%description ldap
This package provides the LDAP support for the apr-util.

%package openssl
Summary: APR utility library OpenSSL crypto support
BuildRequires: pkgconfig(libcrypto)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(openssl) = %{version}-%{release}

%description openssl
This package provides the OpenSSL crypto support for the apr-util.

%package nss
Summary: APR utility library NSS crypto support
BuildRequires: pkgconfig(nss)
Requires: apr-util%{?_isa} = %{version}-%{release}
Provides: apr-%{aprver}(nss) = %{version}-%{release}

%description nss
This package provides the NSS crypto support for the apr-util.

%prep
%autosetup -p1

%build
autoheader && autoconf
# A fragile autoconf test which fails if the code trips
# any other warning; force correct result for OpenLDAP:
export ac_cv_ldap_set_rebind_proc_style=three
%configure --with-apr=%{_prefix} \
        --includedir=%{_includedir}/apr-%{apuver} \
        --with-ldap=ldap --without-gdbm \
        --with-sqlite3 --with-pgsql --with-mysql --with-odbc \
        --with-dbm=lmdb --with-lmdb \
        --without-sqlite2 \
        --with-crypto --with-openssl \
        --with-nss \
   || { cat config.log; exit 1; }
%{make_build}

%install
rm -rf $RPM_BUILD_ROOT
%{make_install}

mkdir -p $RPM_BUILD_ROOT/%{_datadir}/aclocal
install -m 644 build/find_apu.m4 $RPM_BUILD_ROOT/%{_datadir}/aclocal

# Unpackaged files; remove the static libaprutil
rm -f $RPM_BUILD_ROOT%{_libdir}/aprutil.exp \
      $RPM_BUILD_ROOT%{_libdir}/libapr*.a

# And remove the reference to the static libaprutil from the .la
# file.
sed -i '/^old_library/s,libapr.*\.a,,' \
      $RPM_BUILD_ROOT%{_libdir}/libapr*.la

# Remove unnecessary exports from dependency_libs
sed -ri '/^dependency_libs/{s,-l(pq|sqlite[0-9]|rt|dl|uuid) ,,g}' \
      $RPM_BUILD_ROOT%{_libdir}/libapr*.la

# Trim libtool DSO cruft
rm -f $RPM_BUILD_ROOT%{_libdir}/apr-util-%{apuver}/*.*a

%check
# Run the less verbose test suites
export MALLOC_CHECK_=2 MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
cd test
%{make_build}
export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}/apr-util-%{apuver}
./testall -v -q

%ldconfig_scriptlets

%files
%doc CHANGES LICENSE NOTICE
%{_libdir}/libaprutil-%{apuver}.so.*
%dir %{_libdir}/apr-util-%{apuver}

%files lmdb
%{_libdir}/apr-util-%{apuver}/apr_dbm_lmdb*

%files pgsql
%{_libdir}/apr-util-%{apuver}/apr_dbd_pgsql*

%files mysql
%{_libdir}/apr-util-%{apuver}/apr_dbd_mysql*

%files sqlite
%{_libdir}/apr-util-%{apuver}/apr_dbd_sqlite*

%files odbc
%{_libdir}/apr-util-%{apuver}/apr_dbd_odbc*

%files ldap
%{_libdir}/apr-util-%{apuver}/apr_ldap*

%files openssl
%{_libdir}/apr-util-%{apuver}/apr_crypto_openssl*

%files nss
%{_libdir}/apr-util-%{apuver}/apr_crypto_nss*

%files devel
%{_bindir}/apu-%{apuver}-config
%{_libdir}/libaprutil-%{apuver}.la
%{_libdir}/libaprutil-%{apuver}.so
%{_includedir}/apr-%{apuver}/*.h
%{_libdir}/pkgconfig/*.pc
%{_datadir}/aclocal/*.m4

%changelog
* Wed Mar 19 2025 Graham Leggett <minfrin@sharp.fm> 1.7.0-1
- update to support v1.7.0 of APR

* Tue Jun 22 2004 Graham Leggett <minfrin@sharp.fm> 1.0.0-1
- update to support v1.0.0 of APR
                                                                                
* Tue Jun 22 2004 Graham Leggett <minfrin@sharp.fm> 1.0.0-1
- derived from Fedora Core apr.spec

