diff --git a/_multibuild b/_multibuild
new file mode 100644
index 0000000..630968e
--- /dev/null
+++ b/_multibuild
@@ -0,0 +1,3 @@
+
+ contrib
+
diff --git a/openldap2.changes b/openldap2.changes
index 6a3064e..b5750cc 100644
--- a/openldap2.changes
+++ b/openldap2.changes
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Sat Mar 26 14:08:57 UTC 2022 - Stephan Kulow
+
+- Add _multibuild support to integrate the build of libldapcpp-devel
+ to drop the outdated copy
+
-------------------------------------------------------------------
Mon Oct 25 22:03:53 UTC 2021 - Michael Ströder
diff --git a/openldap2.spec b/openldap2.spec
index 2c30de8..4277be1 100644
--- a/openldap2.spec
+++ b/openldap2.spec
@@ -1,7 +1,7 @@
#
-# spec file for package openldap2
+# spec file
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,8 +19,14 @@
%define run_test_suite 0
%define version_main 2.5.9
%define slapdrundir %{_rundir}/slapd
+%define flavor @BUILD_FLAVOR@%{nil}
+%if "%flavor" == "contrib"
+%define name_suffix -%{flavor}-src
+%else
+%define name_suffix %{nil}
+%endif
-Name: openldap2
+Name: openldap2%{name_suffix}
Summary: An open source implementation of the Lightweight Directory Access Protocol
License: OLDAP-2.8
Group: Productivity/Networking/LDAP/Servers
@@ -64,6 +70,10 @@ BuildRequires: unixODBC-devel
# avoid cycle with krb5
BuildRequires: pkgconfig(krb5)
BuildRequires: pkgconfig(systemd)
+%if "%flavor" == "contrib"
+BuildRequires: gcc-c++
+BuildRequires: openldap2-devel
+%endif
%if %{suse_version} < 1500
%{?systemd_requires}
%endif
@@ -203,6 +213,26 @@ Recommends: libldap-data >= %{version_main}
%description -n libldap-2_5-0
This package contains the OpenLDAP client libraries.
+%package -n libldapcpp-devel
+Summary: C++ wrapper around openLDAP API
+Group: Development/Libraries/C and C++
+Requires: libldapcpp0 = %{version}
+Requires: openldap2-devel
+
+%description -n libldapcpp-devel
+This package contains files needed for development with the LDAP C++
+library.
+
+%package -n libldapcpp0
+Summary: C++ wrapper around openLDAP API
+Group: Development/Libraries/C and C++
+Provides: ldapcpplib = %{version}
+Obsoletes: ldapcpplib <= 0.0.5
+
+%description -n libldapcpp0
+This package provides a C++ library for accessing LDAP (Version 3)
+Servers
+
%prep
# Unpack and patch OpenLDAP 2.5
%setup -q -a 9 -n openldap-%{version_main}
@@ -213,6 +243,11 @@ This package contains the OpenLDAP client libraries.
cp %{SOURCE5} .
%build
+%if "%flavor" == "contrib"
+cd contrib/ldapc++
+%configure --disable-static
+make %{?_smp_mflags}
+%else
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
export CFLAGS="%{optflags} -Wno-format-extra-args -fno-strict-aliasing -DNDEBUG -DSLAP_CONFIG_DELETE -DSLAP_SCHEMA_EXPOSE -DLDAP_COLLECTIVE_ATTRIBUTES -DLDAP_USE_NON_BLOCKING_TLS"
export STRIP=""
@@ -259,6 +294,7 @@ make -C contrib/slapd-modules/smbk5pwd %{?_smp_mflags} "sysconfdir=%{_sysconfdir
# Create ldap user
%sysusers_generate_pre %{SOURCE19} ldap
+%endif
%check
%if %run_test_suite
@@ -286,6 +322,10 @@ make SLAPD_DEBUG=0 test
%endif
%install
+%if "%flavor" == "contrib"
+cd contrib/ldapc++
+%make_install
+%else
mkdir -p %{buildroot}%{_libdir}/openldap
mkdir -p %{buildroot}/usr/lib/openldap
mkdir -p %{buildroot}%{_sbindir}
@@ -365,6 +405,7 @@ rm -f %{buildroot}%{_libdir}/*.la
# Provide a libldap_r for backwards-compatibility with OpenLDAP < 2.5.
ln -fs libldap.so "%{buildroot}%{_libdir}/libldap_r.so"
+%endif
%pre -f ldap.pre
%service_add_pre slapd.service
@@ -384,6 +425,19 @@ ln -fs libldap.so "%{buildroot}%{_libdir}/libldap_r.so"
%postun
%service_del_postun slapd.service
+%if "%flavor" == "contrib"
+%files -n libldapcpp-devel
+%doc contrib/ldapc++/README
+%_includedir/*.h
+%_libdir/libldapcpp.la
+%_libdir/libldapcpp.so
+
+%files -n libldapcpp0
+%_libdir/libldapcpp.so.0
+%_libdir/libldapcpp.so.0.0.0
+
+%else
+
%files
%defattr(-,root,root)
%config %{_sysconfdir}/openldap/schema/*.schema
@@ -551,4 +605,6 @@ ln -fs libldap.so "%{buildroot}%{_libdir}/libldap_r.so"
%_libdir/liblber.a
%_libdir/libldap*.a
+%endif # !flavor:contrib
+
%changelog