File talloc-man.spec of Package talloc

#
# spec file for package talloc-man
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{!?python_sitearch:  %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%{!?py3_soflags:  %global py3_soflags cpython-%{python3_version_nodots}m}
%if 0%{?suse_version} > 1310 || 0%{?fedora_version} > 20
%define with_python3 1
%else
%define with_python3 0
%endif
%define build_man 1

%if %{build_man}
Name:           talloc-man
BuildRequires:  doxygen
%else
Name:           talloc
%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1140
%define	build_make_smp_mflags %{?_smp_mflags}
%else
%define	build_make_smp_mflags %{?jobs:-j%jobs}
%endif
BuildRequires:  autoconf
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  libxslt
%if 0%{?suse_version} > 1020
BuildRequires:  pkg-config
%else
BuildRequires:  pkgconfig
%endif
BuildRequires:  python-devel
%if %{with_python3}
BuildRequires:  python3-devel
%endif
%if 0%{?suse_version} > 1100
#!BuildIgnore:  python
%endif
%endif # build_man
Url:            http://talloc.samba.org/
Version:        2.1.8
Release:        0
PreReq:         /sbin/ldconfig
Summary:        Samba talloc Library
License:        LGPL-3.0+
Group:          System/Libraries
Source:         http://download.samba.org/pub/talloc/talloc-%{version}.tar.gz
Source1:        http://download.samba.org/pub/talloc/talloc-%{version}.tar.asc
Source4:        baselibs.conf
Patch0:         talloc-python3.5-fix-soabi_name.patch
Source50:       talloc.keyring
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Talloc is a hierarchical, reference counted memory pool system with
destructors.

It is the core memory allocator used in Samba.

%if ! %{build_man}

%if 0%{?suse_version} > 0
%define libtalloc_name libtalloc2
%else
%define libtalloc_name libtalloc
%endif
%package -n %{libtalloc_name}
Summary:        Libraries and Header Files to Develop Programs with talloc2 Support
Group:          System/Libraries
Provides:       bundled(libreplace)

%description -n %{libtalloc_name}
Talloc is a hierarchical, reference counted memory pool system with
destructors.

It is the core memory allocator used in Samba.

This package includes the talloc2 library.


%package -n libtalloc-devel
Summary:        Libraries and Header Files to Develop Programs with talloc2 Support
# Man pages are built in a 2nd spec file in order to break a build cycle with doxygen->cmake->krb5->libtalloc
Group:          Development/Libraries/C and C++
%if 0%{?suse_version} > 1030
Recommends:     %{name}-man
%endif
Requires:       %{libtalloc_name} = %{version}
%if 0%{?suse_version} > 1020
Requires:       pkg-config
%else
Requires:       pkgconfig
%endif

%description -n libtalloc-devel
Talloc is a hierarchical, reference counted memory pool system with
destructors.

It is the core memory allocator used in Samba.

Libraries and Header Files to Develop Programs with talloc2 Support


%package -n python-talloc
Summary:        Python bindings for the Talloc library
Group:          Development/Libraries/Python
Requires:       %{libtalloc_name} = %{version}
PreReq:         /sbin/ldconfig
Provides:       pytalloc = %{version}
Obsoletes:      pytalloc < %{version}

%description -n python-talloc
This package contains the python bindings for the Talloc library.


%package -n python-talloc-devel
Summary:        Developer tools for the Talloc library
Group:          Development/Libraries/Python
Requires:       python-talloc = %{version}
%if 0%{?suse_version} > 1020
Requires:       pkg-config
%else
Requires:       pkgconfig
%endif
Provides:       pytalloc-devel = %{version}
Obsoletes:      pytalloc-devel < %{version}
Conflicts:      python3-talloc-devel

%description -n python-talloc-devel
Libraries and Header Files to Develop Programs with python-talloc Support


%if %{with_python3}
%package -n python3-talloc
Summary:        Python3 bindings for the Talloc library
Group:          Development/Libraries/Python
Requires:       %{libtalloc_name} = %{version}
PreReq:         /sbin/ldconfig

%description -n python3-talloc
This package contains the python3 bindings for the Talloc library.


%package -n python3-talloc-devel
Summary:        Developer tools for the Talloc library
Group:          Development/Libraries/Python
Requires:       python3-talloc = %{version}
%if 0%{?suse_version} > 1020
Requires:       pkg-config
%else
Requires:       pkgconfig
%endif
Conflicts:      python-talloc-devel

%description -n python3-talloc-devel
Libraries and Header Files to Develop Programs with python3-talloc Support
%endif

%endif # ! build_man

%prep
%setup -n talloc-%{version} -q
%patch0 -p1

%build
%if ! %{build_man}
%if 0%{?suse_version} && 0%{?suse_version} < 911
	OPTIMIZATION="-O"
%else
	# use the default optimization
	unset OPTIMIZATION
%endif
export CFLAGS="${RPM_OPT_FLAGS} -D_GNU_SOURCE ${OPTIMIZATION} -D_LARGEFILE64_SOURCE -DIDMAP_RID_SUPPORT_TRUSTED_DOMAINS"
CONFIGURE_OPTIONS="\
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--disable-rpath \
	--disable-rpath-install \
	--disable-silent-rules \
	--bundled-libraries=NONE \
	--builtin-libraries=replace \
%if %{with_python3}
	--extra-python=/usr/bin/python3 \
%endif
"
./configure ${CONFIGURE_OPTIONS}
%{__make} %{build_make_smp_mflags} \
	all

%else

doxygen doxy.config

%endif # ! build_man

%if ! %{build_man}
%check
%if 0%{?suse_version} != 1110 || "%{_build_arch}" == x86_64
mkdir lib/talloc
ln test_magic_differs* lib/talloc/
LD_LIBRARY_PATH=bin/shared %{__make} test
%endif # suse_version != 1110; fails for i586 and ppc64
%endif # ! build_man

%install
%if ! %{build_man}
DESTDIR=${RPM_BUILD_ROOT} make install
rm -r ${RPM_BUILD_ROOT}/%{_mandir}

%else

# Install API documentation
mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}
cp -a doc/man/* ${RPM_BUILD_ROOT}/%{_mandir}

%endif  # ! build_man

%if ! %{build_man}
%post -n %{libtalloc_name} -p /sbin/ldconfig

%postun -n %{libtalloc_name} -p /sbin/ldconfig

%post -n python-talloc -p /sbin/ldconfig

%postun -n python-talloc -p /sbin/ldconfig

%if %{with_python3}
%post -n python3-talloc -p /sbin/ldconfig

%postun -n python3-talloc -p /sbin/ldconfig
%endif

%files -n %{libtalloc_name}
%defattr(-,root,root)
%{_libdir}/libtalloc.so.*

%files -n libtalloc-devel
%defattr(-,root,root)
%{_includedir}/talloc.h
%{_libdir}/libtalloc.so
%{_libdir}/pkgconfig/talloc.pc

%files -n python-talloc
%defattr(-,root,root)
%{_libdir}/libpytalloc-util.so.*
%{python_sitearch}/talloc.so

%files -n python-talloc-devel
%defattr(-,root,root)
%{_includedir}/pytalloc.h
%{_libdir}/pkgconfig/pytalloc-util.pc
%{_libdir}/libpytalloc-util.so

%if %{with_python3}
%files -n python3-talloc
%defattr(-,root,root)
%{_libdir}/libpytalloc-util.%{py3_soflags}.so.*
%{python3_sitearch}/talloc.%{py3_soflags}.so

%files -n python3-talloc-devel
%defattr(-,root,root)
%{_includedir}/pytalloc.h
%{_libdir}/pkgconfig/pytalloc-util.pc
%{_libdir}/libpytalloc-util.%{py3_soflags}.so
%endif

%else

%files
%defattr(-,root,root)
%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1100
%{_mandir}/man3/libtalloc*.3.*
%{_mandir}/man3/talloc*.3.*
%endif

%endif # ! build_man

%changelog