File libqt4-sql-plugins.spec.in of Package libqt4

#
# spec file for package libqt4-sql-plugins
#
# 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/
#
# nodebuginfo

%if 0%{?suse_version} >= 1330
%bcond_with mysql
%else
%bcond_without mysql
%endif

Name:           libqt4-sql-plugins
BuildRequires:  pkgconfig(gl)
BuildRequires:  alsa-devel
BuildRequires:  cups-devel
BuildRequires:  gtk2-devel
%if %{with mysql}
BuildRequires:  libmysqlclient-devel
%endif
%if 0%{?suse_version} >= 1330
BuildRequires:  libnsl-devel
%endif
BuildRequires:  pkgconfig
BuildRequires:  postgresql-devel
BuildRequires:  unixODBC-devel
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
%endif
License:        SUSE-LGPL-2.1-with-digia-exception-1.1 or GPL-3.0
Summary:        Qt 4 SQL related libraries
Url:            http://qt.digia.com/
Group:          System/Libraries
# COMMON-VERSION-BEGIN
# COMMON-VERSION-END
BuildRequires:  libqt4-devel >= %{version}
# COMMON-BEGIN
# COMMON-END

# COMMON-DESC-BEGIN
%package -n libqt4-sql-unixODBC
Summary:        Qt 4 unixODBC plugin
Group:          Development/Libraries/C and C++
Requires:       libqt4-sql = %{version}
Provides:       libqt4_sql_backend = %{version}
Obsoletes:      qt-sql-unixODBC < 4.6.0
Provides:       qt-sql-unixODBC = 4.6.0

%description -n libqt4-sql-unixODBC
Qt unixODBC plugin to support databases via unixODBC within Qt
applications.

%package -n libqt4-sql-postgresql
Summary:        Qt 4 PostgreSQL plugin
Group:          Development/Libraries/C and C++
Requires:       libqt4-sql = %{version}
Provides:       libqt4_sql_backend = %{version}
Obsoletes:      qt-sql-postgresql < 4.6.0
Provides:       qt-sql-postgresql = 4.6.0

%description -n libqt4-sql-postgresql
Qt SQL plugin to support PostgreSQL servers in Qt applications.

%package -n libqt4-sql-mysql
Summary:        Qt 4 MySQL support
Group:          Development/Libraries/C and C++
Requires:       libqt4-sql = %{version}
Provides:       libqt4_sql_backend = %{version}
Obsoletes:      qt-sql-mysql < 4.6.0
Provides:       qt-sql-mysql = 4.6.0

%description -n libqt4-sql-mysql
A plugin to support MySQL server in Qt applications.
# COMMON-DESC-END

# COMMON-PREP-BEGIN
# COMMON-PREP-END

%build
export QTDIR=$PWD
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib/
%ifarch ppc64
export RPM_OPT_FLAGS="%{optflags} -mminimal-toc"
%endif
export CXXFLAGS="%{optflags}"
export CFLAGS="%{optflags}"
export MAKEFLAGS="%{?_smp_mflags}"
%ifarch sparc64
platform="-platform linux-g++-64"
%else
platform=""
%endif
echo yes | ./configure %common_options $platform \
   -no-webkit -no-xmlpatterns -nomake examples \
   -plugin-sql-psql -I/usr/include -I/usr/include/pgsql/ -I/usr/include/pgsql/server \
%if %{with mysql}
   -plugin-sql-mysql -I/usr/include/mysql/ \
%else
   -no-sql-mysql \
%endif
   -no-sql-sqlite -no-sql-sqlite2 \
   -plugin-sql-odbc

rpm -ql libqt4-devel | grep %{_bindir}/ | sed 's#%{_bindir}/##' | \
    ( while read file; do test -e bin/$file || ln -s %{_bindir}/$file bin/ ; done )
rpm -ql libqt4-devel | grep %{_libdir}/lib | sed 's#%{_libdir}/##' | \
    ( while read file; do test -e lib/$file || ln -s %{_libdir}/$file lib/ ; done )
make %{?_smp_mflags} -C src/sql
make %{?_smp_mflags} -C src/plugins/sqldrivers

%install
export QTDIR=$PWD
make INSTALL_ROOT=%{buildroot} -C src/sql install
make INSTALL_ROOT=%{buildroot} -C src/plugins/sqldrivers install

# argggh, qmake is such a piece of <censored>
mkdir -p %{buildroot}/%{_libdir}/pkgconfig
find  %{buildroot}/%{_libdir} -type f -name '*.pc' -exec mv {} %{buildroot}/%{_libdir}/pkgconfig \;
# fix more qmake errors
mkdir -p %{buildroot}/%{_libdir}/qt
find %{buildroot}/%{_libdir} -type f -name '*la' -print -exec perl -pi -e 's, -L%{_builddir}/\S+,,g' {} \;
find %{buildroot}/%{_libdir}/pkgconfig -type f -name '*pc' -print -exec perl -pi -e 's, -L%{_builddir}/\S+,,g' {} \;
rm -rf %{buildroot}%{_prefix}/include
rm -rf %{buildroot}%{_libdir}/pkgconfig
mkdir %{buildroot}/%{_libdir}/backup
mv %{buildroot}/%{_libdir}/libQtSql*.so.* %{buildroot}/%{_libdir}/backup
rm -f %{buildroot}/%{_libdir}/lib*
mv %{buildroot}/%{_libdir}/backup/libQtSql*.so.* %{buildroot}/%{_libdir}
rmdir %{buildroot}/%{_libdir}/backup
rm -rf %{buildroot}%{_prefix}/bin
for i in %{buildroot}/%plugindir/*; do
  case "$i" in
    *sqldriv*): ;;
    *) rm -rf $i
  esac
done
rm -f %{buildroot}/%{_libdir}/libQtSql*

%files -n libqt4-sql-unixODBC
%defattr(-,root,root,755)
%dir %plugindir/sqldrivers
%plugindir/sqldrivers/libqsqlodbc*.so

%files -n libqt4-sql-postgresql
%defattr(-,root,root,755)
%dir %plugindir/sqldrivers
%plugindir/sqldrivers/libqsqlpsql*.so

%if %{with mysql}
%files -n libqt4-sql-mysql
%defattr(-,root,root,755)
%dir %plugindir/sqldrivers
%plugindir/sqldrivers/libqsqlmysql*.so
%endif

%changelog
openSUSE Build Service is sponsored by