File freetds.spec of Package freetds

#
# spec file for package freetds
#
# 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/
#


Name:           freetds
Version:        0.91
Release:        0
%define dirver  0.91
%define filever 0.91
Summary:        A free re-implementation of the TDS (Tabular DataStream) protocol
License:        LGPL-2.1+ and GPL-2.0+
Group:          Productivity/Databases/Clients
Url:            http://www.freetds.org/
Source:         %{name}-%{filever}.tar.bz2
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libtool
BuildRequires:  unixODBC
BuildRequires:  unixODBC-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?suse_version}
Requires:       glibc-locale
%endif

%description
FreeTDS is a project to document and implement the TDS (Tabular DataStream)
protocol. TDS is used by Sybase and Microsoft for client to database server
communications. FreeTDS includes call level interfaces for DB-Lib, CT-Lib,
and ODBC.

%package -n libfreetds
Summary:        A free re-implementation of the TDS (Tabular DataStream) protocol
License:        LGPL-2.1+
Group:          System/Libraries
Provides:       %{name} = %{version}
Obsoletes:      %{name} < %{version}

%description -n libfreetds
FreeTDS is a project to document and implement the TDS (Tabular DataStream)
protocol. TDS is used by Sybase and Microsoft for client to database server
communications. FreeTDS includes call level interfaces for DB-Lib, CT-Lib,
and ODBC.

%package	tools
Summary:        Applications for working with the TDS (Tabular DataStream) protocol
License:        LGPL-2.1+ and GPL-2.0+
Group:          Development/Libraries/C and C++
Requires:       libfreetds = %version

%description tools
FreeTDS is a project to document and implement the TDS (Tabular DataStream)
protocol. TDS is used by Sybase and Microsoft for client to database server
communications. FreeTDS includes call level interfaces for DB-Lib, CT-Lib,
and ODBC.

This package provides application to allow users to make use of the protocol

%package	devel
Summary:        Include files needed for development with FreeTDS
License:        LGPL-2.1+
Group:          Development/Libraries/C and C++
Requires:       libfreetds = %version

%description devel
The freetds-devel package contains the files necessary for development with
the FreeTDS libraries.

%package	-n libtdsodbc0
Summary:        FreeTDS ODBC Driver for unixODBC
License:        LGPL-2.1+
Group:          Productivity/Databases/Clients
Requires:       unixODBC >= 2.0.0

%description -n libtdsodbc0
The freetds-unixodbc package contains ODBC driver build for unixODBC.

%package	doc
Summary:        User documentation for FreeTDS
License:        LGPL-2.1+ and GPL-2.0+
Group:          Productivity/Databases/Clients

%description doc
The freetds-doc package contains the useguide and reference of FreeTDS
and can be installed even if FreeTDS main package is not installed

%prep
%setup -n %{name}-%{dirver}

%build
ODBCDIR=$(odbc_config --prefix || true)
if test ! -r "$ODBCDIR/include/sql.h"; then
	ODBCDIR=/usr/local
fi
if test ! -r "$ODBCDIR/include/sql.h"; then
	ODBCDIR=/usr
fi
autoreconf --force --install
%configure						\
	--with-unixodbc="$ODBCDIR"			\
	--enable-threadsafe				\
	--sysconfdir=%{_sysconfdir}			\
	--with-tdsver=4.2				\
	--with-docdir=%{_docdir}/freetds \
    --disable-static \
    --with-pic
make %{?_smp_flags} RPM_OPT_FLAGS="%{optflags}"

%install
%makeinstall
mkdir 	-p	%{buildroot}%{_docdir}/freetds/
mv	%{buildroot}%{_datadir}/doc/freetds-*/* %{buildroot}%{_docdir}/freetds/
rm -rf 	%{buildroot}%{_docdir}/freetds-* %{buildroot}/%{_datadir}/doc/freetds-*
%fdupes %{buildroot}/%{_docdir}/freetds/userguide

%post -n libfreetds -p /sbin/ldconfig

%postun -n libfreetds -p /sbin/ldconfig

%post -n libtdsodbc0
echo "[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = %{_libdir}/libtdsodbc.so.0
Setup = %{_libdir}/libtdsodbc.so.0" | odbcinst -i -d -r > /dev/null 2>&1 || true
echo "[SQL Server]
Description = FreeTDS unixODBC Driver
Driver = %{_libdir}/libtdsodbc.so.0
Setup = %{_libdir}/libtdsodbc.so.0" | odbcinst -i -d -r > /dev/null 2>&1 || true
/sbin/ldconfig 2> /dev/null

%postun -n libtdsodbc0 -p /sbin/ldconfig

%preun -n libtdsodbc0
odbcinst -u -d -n 'FreeTDS' > /dev/null 2>&1 || true
odbcinst -u -d -n 'SQL Server' > /dev/null 2>&1 || true

%files -n libfreetds
%defattr(-,root,root)
%doc AUTHORS BUGS COPYING* ChangeLog INSTALL NEWS README TODO
%{_libdir}/libct.so.*
%{_libdir}/libsybdb.so.*
%config %{_sysconfdir}/*
%{_mandir}/man5/*.5.gz

%files tools
%defattr (-,root,root)
%{_bindir}/*
%{_mandir}/man1/*.1.gz

%files devel
%defattr (-,root,root)
%exclude %{_libdir}/*.la
%{_libdir}/*.so
%{_includedir}/*

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

%files doc
%defattr (-,root,root)
%{_datadir}/doc/packages/freetds/

%changelog