File libdb-4_5.spec of Package libdb-4_5

#
# spec file for package libdb-4_5 (Version 4.5.20)
#
# Copyright (c) 2010 SUSE LINUX Products 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/
#

# norootforbuild


Name:           libdb-4_5
%define         generic_name db
%define         docdir %{_defaultdocdir}/%{name}
%define         source_dir %{_datadir}/%{name}-source
Version:        4.5.20
Release:        107
%define         major 4
%define         minor 5
Summary:        Berkeley DB Database Library Version 4.5
Source:         db-%{version}.tar.bz2
Url:            http://www.sleepycat.com
Patch0:         patch.%{version}.1
Patch1:         patch.%{version}.2
Patch2:         db-%{version}.dif
License:        BSD3c(or similar)
Group:          System/Libraries
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Prefix:         %{_prefix}
# bug437293
%ifarch ppc64
Obsoletes:      db-64bit
%endif
#

%description
The Berkeley DB Database is a programmatic toolkit that provides
database support for applications.

This package contains the necessary runtime libraries.



%package -n db45-utils-doc
License:        BSD3c(or similar)
Summary:        Documentation for the Command Line tools for Managing Berkeley DB Databases
Group:          Productivity/Databases/Tools
Prefix:         %{_prefix}
Requires:       libdb-4_5 = %{version}
%if 0%{?suse_version} >= 1120
BuildArch:      noarch
%endif

%description -n db45-utils-doc
The Berkeley DB Database is a programmatic toolkit that provides
database support for applications.

This package contains the documentation for the command line tools for
managing Berkeley DB databases.



%package -n db45-utils
License:        BSD3c(or similar)
Summary:        Command Line tools for Managing Berkeley DB Databases
Group:          Productivity/Databases/Tools
Prefix:         %{_prefix}
Requires:       libdb-4_5 = %{version}

%description -n db45-utils
The Berkeley DB Database is a programmatic toolkit that provides
database support for applications.

This package contains the command line tools for managing Berkeley DB
databases.



%package -n     db45-doc
License:        BSD3c(or similar)
Summary:        Documentation for Berkeley DB
Group:          Development/Libraries/C and C++
Prefix:         %{_prefix}
%if 0%{?suse_version} >= 1120
BuildArch:      noarch
%endif

%description -n db45-doc
The Berkeley DB Database is a programmatic toolkit that provides
database support for applications.

This package contains the documentation.



%package        devel
License:        BSD3c(or similar)
Summary:        Development Files and Libraries for the old Berkeley DB library Version 4.5
Group:          Development/Libraries/C and C++
Prefix:         %{_prefix}
Requires:       libdb-4_5 = %{version} glibc-devel

%description    devel
The Berkeley DB Database is a programmatic toolkit that provides
database support for applications.

This package contains the header files and libraries.



%prep
%setup -q -n %{generic_name}-%{version}
%patch0
%patch1
%patch2
cd ..
tar -jcf %{generic_name}-%{version}.tar.bz2 %{generic_name}-%{version}

%build
cd dist
./s_config
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
CC=gcc
export CFLAGS CXXFLAGS CC
#
# Build now the NPTL version
#
mkdir ../build_nptl
cd ../build_nptl
../dist/configure --prefix=%{_prefix} \
        --libdir=%{_libdir} --enable-compat185 --disable-dump185 \
        --enable-shared --enable-static --enable-rpc --disable-cxx \
	--with-mutex="POSIX/pthreads/library" \
        %{_target_cpu}-suse-linux
# Make sure O_DIRECT is really disabled (build host could have old kernel)
perl -pi -e 's/#define HAVE_O_DIRECT 1/#undef HAVE_O_DIRECT/' db_config.h
# Remove libtool predep_objects and postdep_objects wonkiness
perl -pi -e 's/^predep_objects=".*$/predep_objects=""/' libtool
perl -pi -e 's/^postdep_objects=".*$/postdep_objects=""/' libtool
perl -pi -e 's/-shared -nostdlib/-shared/' libtool
make %{?_smp_mflags} LIBSO_LIBS='$(LIBS)' LIBXSO_LIBS='$(LIBS)'" -L%{_libdir} -lstdc++"

%install
mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/db4
#mkdir -p ${RPM_BUILD_ROOT}% {source_dir}/
#
#cp % {_builddir}/% {generic_name}-% {version}.tar.bz2 ${RPM_BUILD_ROOT}% {source_dir}/
#mkdir -p $RPM_BUILD_ROOT/% {_defaultdocdir}/% {name}-source
#cat >>$RPM_BUILD_ROOT/% {_defaultdocdir}/% {name}-source/README<<EOF
#The patches in this directory were applied to the sources.
#The sources were installed to:
#% {source_dir}/% {generic_name}-% {version}.tar.bz2
#EOF
CONFIG_ARGS=$(find . -name "config.log" -exec grep "\$ \.\./dist\/configure" {} \; | sed 's/.*configure\( --.*\)/\1/g')
if [ -z "$CONFIG_ARGS" ]
then
  echo "could not find configure arguments ... exiting"
  exit 42
fi
#echo $CONFIG_ARGS >> $RPM_BUILD_ROOT/% {_defaultdocdir}/% {name}-source/configure_args.txt
#cp % {_sourcedir}/*patch* $RPM_BUILD_ROOT/% {_defaultdocdir}/% {name}-source || true
#cp % {_sourcedir}/*.dif*  $RPM_BUILD_ROOT/% {_defaultdocdir}/% {name}-source || true
#
mkdir -p ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}
cd build_nptl
make prefix=${RPM_BUILD_ROOT}%{_prefix} libdir=${RPM_BUILD_ROOT}%{_libdir} strip=true install
cd ..
# make ldd happy:
chmod 755 $RPM_BUILD_ROOT%{_libdir}/libdb*.so
# Fix header file installation
mv ${RPM_BUILD_ROOT}%{_includedir}/*.h ${RPM_BUILD_ROOT}%{_includedir}/db4
echo "#include <db4/db.h>" > ${RPM_BUILD_ROOT}%{_includedir}/db.h
echo "#include <db4/db_185.h>" > ${RPM_BUILD_ROOT}%{_includedir}/db_185.h
rm -f ${RPM_BUILD_ROOT}%{_includedir}/db4/db_cxx.h
# remove dangling tags symlink from examples.
rm -f examples_cxx/tags
rm -f examples_c/tags
# Move documentation to the right directory
mkdir -p $RPM_BUILD_ROOT%{docdir}
mv $RPM_BUILD_ROOT%{_prefix}/docs/* $RPM_BUILD_ROOT/%{docdir}
cp -a examples_cxx examples_c $RPM_BUILD_ROOT/%{docdir}
cp -a LICENSE README $RPM_BUILD_ROOT/%{docdir}
#
# Remove api documentation for Java and TCL
rm -rf $RPM_BUILD_ROOT/%{docdir}/java
rm -rf $RPM_BUILD_ROOT/%{docdir}/api_java
rm -rf $RPM_BUILD_ROOT/%{docdir}/api_tcl
mv $RPM_BUILD_ROOT/%{docdir}/collections/tutorial $RPM_BUILD_ROOT/%{docdir}/
# Remove crappy *.la files
rm -rf $RPM_BUILD_ROOT%{_libdir}/*.la
rm -rf $RPM_BUILD_ROOT%{_libdir}/tls/*.la

mv $RPM_BUILD_ROOT/%{_bindir}/berkeley_db_svc $RPM_BUILD_ROOT/%{_bindir}/berkeley_db45_svc
mv $RPM_BUILD_ROOT/%{_bindir}/db_archive $RPM_BUILD_ROOT/%{_bindir}/db45_archive
mv $RPM_BUILD_ROOT/%{_bindir}/db_checkpoint $RPM_BUILD_ROOT/%{_bindir}/db45_checkpoint
mv $RPM_BUILD_ROOT/%{_bindir}/db_deadlock $RPM_BUILD_ROOT/%{_bindir}/db45_deadlock
mv $RPM_BUILD_ROOT/%{_bindir}/db_dump $RPM_BUILD_ROOT/%{_bindir}/db45_dump
mv $RPM_BUILD_ROOT/%{_bindir}/db_load $RPM_BUILD_ROOT/%{_bindir}/db45_load
mv $RPM_BUILD_ROOT/%{_bindir}/db_printlog $RPM_BUILD_ROOT/%{_bindir}/db45_printlog
mv $RPM_BUILD_ROOT/%{_bindir}/db_recover $RPM_BUILD_ROOT/%{_bindir}/db45_recover
mv $RPM_BUILD_ROOT/%{_bindir}/db_stat $RPM_BUILD_ROOT/%{_bindir}/db45_stat
mv $RPM_BUILD_ROOT/%{_bindir}/db_upgrade $RPM_BUILD_ROOT/%{_bindir}/db45_upgrade
mv $RPM_BUILD_ROOT/%{_bindir}/db_verify $RPM_BUILD_ROOT/%{_bindir}/db45_verify
mv $RPM_BUILD_ROOT/%{_bindir}/db_hotbackup $RPM_BUILD_ROOT/%{_bindir}/db45_hotbackup

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,root)
%{_libdir}/libdb-%{major}.%{minor}.so

%files -n db45-doc
%defattr(-,root,root)
%dir %{docdir}
%doc %{docdir}/LICENSE
%doc %{docdir}/README
%doc %{docdir}/index.html
%doc %{docdir}/license
%doc %{docdir}/images
%doc %{docdir}/api_c
%doc %{docdir}/api_cxx
%doc %{docdir}/gsg*
%doc %{docdir}/ref
%doc %{docdir}/examples_c
%doc %{docdir}/examples_cxx
%doc %{docdir}/tutorial

%files -n db45-utils-doc
%defattr(-,root,root)
%doc %{docdir}/utility

%files -n db45-utils
%defattr(-,root,root)
%{_bindir}/berkeley_db45_svc
%{_bindir}/db45_archive
%{_bindir}/db45_checkpoint
%{_bindir}/db45_deadlock
%{_bindir}/db45_dump
%{_bindir}/db45_load
%{_bindir}/db45_printlog
%{_bindir}/db45_recover
%{_bindir}/db45_stat
%{_bindir}/db45_upgrade
%{_bindir}/db45_verify
%{_bindir}/db45_hotbackup

%files devel
%defattr(-,root,root)
%dir %{_includedir}/db4
%{_includedir}/db.h
%{_includedir}/db_185.h
%{_includedir}/db4/db.h
%{_includedir}/db4/db_185.h
%{_libdir}/libdb.so
%{_libdir}/libdb.a
%{_libdir}/libdb-%{major}.%{minor}.a
%{_libdir}/libdb-%{major}.so
#% files source
#% defattr(-,root,root)
#% {_defaultdocdir}/% {name}-source
#% {source_dir}
#

%changelog