File postgresql-libs.spec of Package postgresql.openSUSE_12.1_Update

#
# spec file for package postgresql-libs
#
# Copyright (c) 2012 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/
#


%if 0%{?sles_version} && %sles_version <= 11
%define libs_package 1
%else
%define libs_package 0
%endif

Name:           postgresql-libs
%define _name postgresql
%define libpq libpq5
%define libecpg libecpg6
%define buildall 0
%define extensiondir %_datadir/postgresql/extension
%if 0%{?suse_version} > 910
BuildRequires:  krb5-devel
BuildRequires:  libxslt-devel
%endif
BuildRequires:  openldap2-devel
BuildRequires:  openssl-devel
Summary:        Basic Clients and Utilities for PostgreSQL
License:        BSD-3-Clause
Group:          Productivity/Databases/Tools
Version:        9.1.3
Release:        0
%define pg_minor_version %(echo %version | sed -r 's/^([0-9]+\\.[0-9]+).*/\\1/')
Source0:        postgresql-%version.tar.bz2
Source1:        baselibs.conf
Source2:        postgresql-README.SuSE.de
Source3:        postgresql-README.SuSE.en
Source8:        postgresql-sysconfig
Source9:        postgresql-init
Source15:       postgresql-bashprofile
Source16:       postgresql-firewall
Source17:       postgresql-rpmlintrc
Source100:      postgresql-mkspecfiles
Source101:      postgresql.spec.in
Patch1:         postgresql-conf.patch
Patch2:         postgresql-regress.patch
Patch3:         postgresql-sle10-timestamptz.patch
Patch4:         postgresql-plperl.patch
Url:            http://www.postgresql.org/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       postgresql = %pg_minor_version

%description
PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, and user-defined
types and functions.

This package contains the basic utility and client programs necessary
to maintain and work with local or remote PostgreSQL databases as well
as manual pages for the SQL commands that PostgreSQL supports. Full
HTML documentation for PostgreSQL can be found in the postgresql-docs
package.

%if %libs_package

%package libs
Summary:        Shared Libraries Required for PostgreSQL Clients
Group:          Productivity/Databases/Clients
# bug437293
%ifarch ppc64
Obsoletes:      postgresql-libs-64bit
%endif
#
Provides:       postgresql-libs = %pg_minor_version
PreReq:         sh-utils fileutils

%description libs
PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.

This package provides the essential shared libraries for (almost) any
PostgreSQL client program or interface. You will need to install this
package in order to use any other PostgreSQL package or any clients
that need to connect to a PostgreSQL server.
%else

%package -n %libpq
Summary:        Shared Libraries Required for PostgreSQL Clients
Group:          Productivity/Databases/Clients
Provides:       postgresql-libs = %version
Obsoletes:      postgresql-libs < %version
# bug437293
%ifarch ppc64
Obsoletes:      postgresql-libs-64bit
%endif

%description -n %libpq
PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.

This package provides the client library that most PostgreSQL client
program or language bindings are using.

%package -n %libecpg
Summary:        Shared Libraries Required for PostgreSQL Clients
Group:          Productivity/Databases/Clients
Provides:       postgresql-libs:%_libdir/libecpg.so.6

%description -n %libecpg
PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.

This package provides the runtime library of the embedded SQL C
preprocessor for PostgreSQL.
%endif

%package -n %_name-devel
Summary:        PostgreSQL development header files and libraries
Group:          Productivity/Databases/Tools
%if %libs_package
Requires:       postgresql-libs
%else
Requires:       %libecpg
Requires:       %libpq
%endif

%description -n %_name-devel
PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, and user-defined
types and functions.

This package contains the header files and libraries needed to compile
C applications which will directly interact with a PostgreSQL database
management server and the ECPG Embedded C Postgres preprocessor. You
need to install this package if you want to develop applications in C
which will interact with a PostgreSQL server.


%prep
%setup -q -n %_name-%version
# Keep the timestamp of configure, because patching it would otherwise
# confuse PostgreSQL's build system
touch -r configure tmp
%patch1
%patch2
# apply the following patch only on SLE10
%if 0%{?suse_version} == 1010
%patch3 -p1
%endif
%patch4
touch -r tmp configure
rm tmp

%build
export CFLAGS="%optflags $SP"
# uncomment the following line to enable the stack protector
# CFLAGS="$CFLAGS -fstack-protector"
%configure \
	--includedir=%_includedir/pgsql \
	--datadir=%_datadir/postgresql \
	--docdir=%_docdir \
	--disable-rpath \
	--enable-nls \
	--enable-thread-safety \
	--enable-integer-datetimes \
        --without-readline \
	--with-openssl \
	--with-ldap \
%if 0%{?suse_version} > 910
	--with-gssapi \
	--with-libxml \
	--with-libxslt \
	--with-krb5 \
%endif
	--with-system-tzdata=/usr/share/zoneinfo
make -C src/backend %{?jobs:-j%jobs} libpq-recursive
make -C src/interfaces %{?jobs:-j%jobs}
make -C src/port %{?jobs:-j%jobs} libpgport.a
make -C src/bin/pg_config %{?jobs:-j%jobs} pg_config

%install
SUBINSTALL=install
install -d %buildroot%_mandir/man1
install doc/src/sgml/man1/{ecpg,pg_config}.1 %buildroot%_mandir/man1
if test -n "$SUBINSTALL"; then
# Install them for postgresql-libs and uninstall them for postgresql
make -C src DESTDIR=%buildroot $SUBINSTALL-local
for dir in \
        config \
        src/bin/pg_config \
        src/interfaces \
        src/include \
        src/makefiles \
        src/port \
        src/test/regress
do
        make -C $dir DESTDIR=%buildroot $SUBINSTALL
done
fi
# Don't ship static libraries, libpgport.a is needed, though.
rm -f $(ls %buildroot/%_libdir/*.a | grep -F -v libpgport.a)

%find_lang libpq5-%{pg_minor_version} %libpq.lang
%find_lang ecpglib6-%{pg_minor_version} %libecpg.lang
cat %libpq.lang %libecpg.lang > postgresql-libs.lang
%find_lang ecpg-%{pg_minor_version} %_name-devel.lang 
%find_lang pg_config-%{pg_minor_version} %_name-devel.lang 
%if %libs_package

%post -n postgresql-libs -p /sbin/ldconfig

%postun -n postgresql-libs -p /sbin/ldconfig
%else

%post -n %libpq -p /sbin/ldconfig

%postun -n %libpq -p /sbin/ldconfig

%post -n %libecpg -p /sbin/ldconfig

%postun -n %libecpg -p /sbin/ldconfig
%endif

%clean
rm -rf %buildroot
rm -f %my_provides

%if %libs_package

%files -n postgresql-libs -f postgresql-libs.lang
%else

%files -n %libpq -f %libpq.lang
%endif
%defattr(-,root,root)
%_libdir/libpq.so.*
%if !%libs_package

%files -n %libecpg -f %libecpg.lang
%defattr(-,root,root)
%endif
%_libdir/libecpg*.so.*
%_libdir/libpgtypes.so.*

%files -n %_name-devel -f %_name-devel.lang
%defattr(-,root,root)
%doc %_mandir/man1/ecpg.1*
%_bindir/pg_config
%doc %_mandir/man1/pg_config.1*
%_bindir/ecpg
%_libdir/libpgport.a
%_libdir/lib*.so
%dir %_libdir/postgresql
%_libdir/postgresql/pgxs
%_includedir/pgsql
%dir %_datadir/postgresql
%_datadir/postgresql/pg_service.conf.sample

%changelog