%define major	5
%define minor	2
%define micro	4
%define	version	%{major}.%{minor}.%{micro}

%define __libtoolize :
# Default provider build options (MySQL, Postgres & unixODBC)
#
# Package build options:
# --with tds
# --with db2
# --with oracle
# --without sqlite
# --with sybase
# --with mdb
# --without ldap
# --without mysql
# --without odbc
# --without postgres
# 

%define           FREETDS  0
%define           IBMDB2   0
%define           MYSQL    1
%define           ODBC     0
%define           ORACLE   0
%define           POSTGRES 1
%define           SQLITE   1
%define           SYBASE   0
%define 	  MDB      0
%define		  LDAP     0

%{?_with_tds:%define FREETDS 	1}
%{?_with_db2:%define IBMDB2 	1}
%{?_without_ldap:%define LDAP 	0}
%{?_with_mdb:%define MDB 	1}
%{?_with_oracle:%define ORACLE 	1}
%{?_without_sqlite:%define SQLITE 0}
%{?_with_sybase:%define SYBASE 	1}
%{?_without_mysql:%define MYSQL 0}
%{?_without_odbc:%define ODBC 	0}
%{?_without_postgres:%define POSTGRES 	0}

%define libver	5.0

Summary:	A (relatively small) database access library
Name:		libgda
Version:	%{version}
Release:	2%{?_dist_release}
Source:		%{name}-%{version}.tar.xz
URL:		http://www.gnome-db.org/
Group:		System Environment/Libraries
License:	LGPL
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Summary(ja):	比較的小規模なデータベース接続ライブラリ

Patch0:		libgda-4.2.0-disable-mdb.patch

Vendor: Project Vine
Distribution: Vine Linux
Packager: yasumichi

BuildRequires:	pkgconfig	>= 0.8
BuildRequires:	intltool	>= 0.35.5
BuildRequires:	glib2-devel	>= 2.12.0
BuildRequires:	gtk3-devel
BuildRequires:	gobject-introspection-devel
BuildRequires:	libxml2-devel
BuildRequires:	libxslt-devel >= 1.0.9
BuildRequires:	db4-devel ncurses-devel
BuildRequires:	gamin-devel >= 0.1.8
BuildRequires:	libgcrypt-devel >= 1.1.42
BuildRequires:	gtksourceview3-devel
BuildRequires:	libsoup-devel
BuildRequires:	libsecret-devel
BuildRequires:	iso-codes
BuildRequires:	yelp-tools

%if %{FREETDS}
BuildRequires:    freetds-devel
%endif

%if %{MYSQL}
BuildRequires:    MySQL-devel
%endif

%if %{POSTGRES}
BuildRequires:    libpq-devel
%endif

%if %{ODBC}
BuildRequires:    unixODBC-devel
%endif

%if %{SQLITE}
BuildRequires:	  sqlite3-devel
%endif

%if %{MDB}
BuildRequires:	  mdbtools-devel
%endif

%if %{LDAP}
BuildRequires:	  openldap-devel
%endif

%description
Libgda is a (relatively small) database access library:
 - a wrapper like ODBC but with more features to access several database
   engines
 - a meta data extractor (to know all about database objects in a common
   way)
 - comes with an SQL console application (like mysql, psql or sqlite3
   consoles)
 - relies on GLib, coded in C, its API is easy to use
 - at the moment supports SQLite, MySQL, PostgreSQL, MSAccess and Bdb, work
   is in progress for other database types (such as Firebird and Oracle) and
   to wrap JDBC for more wider usage. 
     
Build option is:
 --with mysql postgres sqlite 
 --without tds ibmdb2 ldap mdb odbc oracle sybase 

%package devel
Summary:          Development libraries and header files for libgda.
Group:            Development/Libraries
Requires:         %{name} = %{version}
Requires:         glib2-devel	>= 2.12.0
Requires:         libxml2-devel
Requires:         libxslt-devel >= 1.0.9

%description devel
This package contains the header files and libraries needed to write
or compile programs that use libgda.


#%package sharp
#Summary:          Mono bindings for libgda
#Group:            System Environment/Libraries
#Requires:         %{name} = %{version}-%{release}
#Requires:         mono-core
#
#%description sharp
#This package contains the dll files needed to run (and compile) Mono
#applications which use libgda.


%if %{FREETDS}
%package -n gda-freetds
Summary:	GDA FreeTDS Provider
Group:		System Environment/Libraries
%description -n gda-freetds
This package includes the GDA FreeTDS provider.
%endif

%if %{IBMDB2}
%package -n gda-ibmdb2
Summary:	GDA IBM DB2 Provider
Group:		System Environment/Libraries
%description -n gda-ibmdb2
This package includes the GDA IBM DB2 provider.
%endif

%if %{MYSQL}
%package -n gda-mysql
Summary:	GDA MySQL Provider
Group:		System Environment/Libraries
%description -n gda-mysql
This package includes the GDA MySQL provider.
%endif

%if %{ODBC}
%package -n gda-odbc
Summary:	GDA ODBC Provider
Group:		System Environment/Libraries
%description -n gda-odbc
This package includes the GDA ODBC provider.
%endif

%if %{ORACLE}
%package -n gda-oracle
Summary:	GDA Oracle Provider
Group:		System Environment/Libraries
%description -n gda-oracle
This package includes the GDA Oracle provider.
%endif

%if %{POSTGRES}
%package -n gda-postgres
Summary:	GDA PostgreSQL Provider
Group:		System Environment/Libraries
%description -n gda-postgres
This package includes the GDA PostgreSQL provider.
%endif

%if %{SQLITE}
%package -n gda-sqlite
Summary:	GDA SQLite Provider
Group:		System Environment/Libraries
%description -n gda-sqlite
This package includes the GDA SQLite provider.
%endif

%if %{SYBASE}
%package -n gda-sybase
Summary:	GDA Sybase Provider
Group:		System Environment/Libraries
%description -n gda-sybase
This package includes the GDA Sybase provider.
%endif

%if %{MDB}
%package -n gda-mdb
Summary:	GDA MDB Provider
Group:		System Environment/Libraries
%description -n gda-mdb
This package includes the GDA MDB provider.
%endif

%if %{LDAP}
%package -n gda-ldap
Summary:	GDA LDAP Provider
Group:		System Environment/Libraries
%description -n gda-ldap
This package includes the GDA LDAP provider.
%endif

%prep
%setup -q -n %{name}-%{version}
%patch0 -p1 -b .mdb

%build
%if %{FREETDS}
CONFIG="$CONFIG --with-tds"
%else
CONFIG="$CONFIG --without-tds"
%endif

%if %{IBMDB2}
CONFIG="$CONFIG --with-ibmdb2"
%else
CONFIG="$CONFIG --without-ibmdb2"
%endif

%if %{MYSQL}
CONFIG="$CONFIG --with-mysql"
%else
CONFIG="$CONFIG --without-mysql"
%endif

%if %{POSTGRES}
CONFIG="$CONFIG --with-postgres"
%else
CONFIG="$CONFIG --without-postgres"
%endif

%if %{ODBC}
CONFIG="$CONFIG --with-odbc"
%else
CONFIG="$CONFIG --without-odbc"
%endif

%if %{ORACLE}
CONFIG="$CONFIG --with-oracle"
%else
CONFIG="$CONFIG --without-oracle"
%endif

%if %{SQLITE}
CONFIG="$CONFIG --with-sqlite"
%else
CONFIG="$CONFIG --without-sqlite"
%endif

%if %{SYBASE}
CONFIG="$CONFIG --with-sybase"
%else
CONFIG="$CONFIG --without-sybase"
%endif

%if %{MDB}
CONFIG="$CONFIG --with-mdb"
%else
CONFIG="$CONFIG --without-mdb"
%endif

%if %{LDAP}
CONFIG="$CONFIG --with-ldap"
%else
CONFIG="$CONFIG --without-ldap"
%endif

%configure $CONFIG \
	--disable-static \
	--enable-introspection \
	--disable-gtk-doc \
	--with-libdir-name=%{_lib}
make

%install
rm -rf $RPM_BUILD_ROOT
#makeinstall LIBGDA_DTDDIR=%{buildroot}%{_datadir}/libgda/dtd
make install DESTDIR=$RPM_BUILD_ROOT

#fixup mono / sharp related files install
#mkdir -p %{buildroot}/%{_datadir}/gapi-2.0
#mv %{buildroot}/%{_libdir}/libgda/gda-api.xml %{buildroot}/%{_datadir}/gapi-2.0
#mkdir -p %{buildroot}/usr/lib/mono/gda-sharp-2.0
#mv %{buildroot}/%{_libdir}/libgda/* %{buildroot}/usr/lib/mono/gda-sharp-2.0
#rmdir %{buildroot}/%{_libdir}/libgda

# Cleanup unnecessary, unpackaged files
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} \;
rm -f %{buildroot}/%{_sysconfdir}/libgda-%{libver}/sales_test.db

%find_lang libgda-%{libver}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LIB ChangeLog README NEWS
%dir %{_sysconfdir}/libgda-%{libver}
%config(noreplace) %{_sysconfdir}/libgda-%{libver}/config
%{_bindir}/*
%{_libdir}/*.so.*
%{_libdir}/girepository-1.0/Gda-5.0.typelib

%dir %{_libdir}/libgda-%{libver}
%dir %{_libdir}/libgda-%{libver}/plugins
%{_libdir}/libgda-%{libver}/plugins/*.xml
%{_libdir}/libgda-%{libver}/plugins/libgda-ui-plugins.so
%dir %{_libdir}/libgda-%{libver}/providers
%{_libdir}/libgda-%{libver}/providers/libgda-bdb.so
%{_libdir}/libgda-%{libver}/providers/libgda-sqlcipher.so
%{_libdir}/libgda-%{libver}/providers/libgda-web.so

%{_datadir}/appdata/gda-browser-5.0.appdata.xml
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/*/*/*
%{_datadir}/pixmaps/gda-browser-5.0.png
%{_datadir}/help/*/gda-browser

%dir %{_datadir}/libgda-%{libver}
%{_datadir}/libgda-%{libver}/demo
%{_datadir}/libgda-%{libver}/dtd
%{_datadir}/libgda-%{libver}/gda_trml2html
%{_datadir}/libgda-%{libver}/gda_trml2pdf
%{_datadir}/libgda-%{libver}/icons
%{_datadir}/libgda-%{libver}/language-specs/gda-sql.lang
%{_datadir}/libgda-%{libver}/php
%{_datadir}/libgda-%{libver}/pixmaps
%{_datadir}/libgda-%{libver}/server_operation.glade
%{_datadir}/libgda-%{libver}/ui
%{_datadir}/libgda-%{libver}/*.xml
%{_datadir}/libgda-%{libver}/web

%{_mandir}/man1/*
%{_datadir}/locale/*/LC_MESSAGES/*

%files devel
%defattr(-,root,root)
%{_includedir}/libgda-%{libver}
%{_libdir}/*.so
%{_libdir}/pkgconfig/*
%{_datadir}/gir-1.0/Gda-5.0.gir
%{_datadir}/gtk-doc/html/*

#files sharp
#defattr(-,root,root)
#{_datadir}/gapi-2.0
#/usr/lib/mono/gda-sharp-2.0
#{_libdir}/pkgconfig/gda-sharp-2.0.pc

%if %{FREETDS}
%files -n gda-freetds
%{_libdir}/libgda-%{libver}/providers/libgda-freetds.so
%endif

%if %{IBMDB2}
%files -n gda-ibmdb2
%{_libdir}/libgda-%{libver}/providers/libgda-ibmdb2.so
%endif

%if %{MYSQL}
%files -n gda-mysql
%{_libdir}/libgda-%{libver}/providers/libgda-mysql.so
%{_datadir}/libgda-%{libver}/mysql_*.xml
%endif

%if %{ODBC}
%files -n gda-odbc
%{_libdir}/libgda-%{libver}/providers/libgda-odbc.so
%{_datadir}/libgda-%{libver}/odbc_*.xml
%endif

%if %{ORACLE}
%files -n gda-oracle
%{_libdir}/libgda-%{libver}/providers/libgda-oracle.so
%endif

%if %{POSTGRES}
%files -n gda-postgres
%{_libdir}/libgda-%{libver}/providers/libgda-postgres.so
%{_datadir}/libgda-%{libver}/postgres_*.xml
%endif

%if %{SQLITE}
%files -n gda-sqlite
%{_libdir}/libgda-%{libver}/providers/libgda-sqlite.so
%{_datadir}/libgda-%{libver}/sqlite_*.xml
%endif

%if %{SYBASE}
%files -n gda-sybase
%{_libdir}/libgda-%{libver}/providers/libgda-sybase.so
%endif

%if %{MDB}
%files -n gda-mdb
%{_libdir}/libgda-%{libver}/providers/libgda-mdb.so
%endif

%if %{LDAP}
%files -n gda-ldap
%{_libdir}/libgda-%{libver}/providers/libgda-ldap.so
%{_datadir}/libgda-%{libver}/ldap_*.xml
%endif


%changelog
* Sun May 15 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.2.4-2
- rebuild with openssl-1.0.2

* Sun Nov 01 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.2.4-1
- new upstream release

* Sat Jul 19 2014 Yasumichi Akahoshi <yasumichi@vinelinux.org> 5.2.2-2
- rebuild with libpq-devel instead of postgresql-devel

* Sat Jan 04 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.2.2-1
- new upstream release

* Sat Nov 30 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.2.1-1
- new upstream release
- add BuildRequires: yelp-tools

* Sun Apr 21 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.1.2-1
- new upstream release

* Sun Sep 30 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.1.1-1
- new upstream release
- add BuildRequires: gtksourceview3-devel, libsoup-devel, libsecret-devel
- remove BuildRequires: gcr-devel

* Tue Apr 17 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.0.3-1
- new upstream release
- add BuildRequires: gtk3-devel, gobject-introspection-devel, gcr-devel, iso-codes

* Wed Dec 28 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.12-1
- new upstream release

* Mon Nov 21 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.11-1
- new upstream release

* Fri Sep 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.9-1
- new upstream release

* Tue Aug 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.8-1
- new upstream release

* Sat Oct 09 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.2.0-1
- new upstream release
- add Patch0 (libgda-4.2.0-disable-mdb.patch)
- change %%{libver}

* Sat Sep 25 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.0.9-2
- rebuild with rpm-4.8.1 for pkg-config file

* Mon Jun 21 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.0.9-1
- new upstream release

* Sun Mar 14 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 4.0.8-1
- new upstream release

* Mon Nov 02 2009 Yasumichi Akahoshi <yasumichi@vinelinux.org> 4.0.5-1
- new upstream release
- remove gnome-vfs2-devel from BR.(use gio-2.0)
- add Vendor, Distribution and Packager.
- update summary and description.

* Wed Jul 08 2009 Shu KONNO <owa@bg.wakwak.com> 4.0.2-3
- rebuilt with postgresql-8.4.0

* Fri May 22 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.0.2-2
- added intltool to BuildRequires.
- rebuilt with MySQL-5.1.34.

* Wed Apr 29 2009 Yasumichi Akahoshi <yasumichi@vinelinux.org> 4.0.2-1
- update from upstream.
- update description and files.
- ODBC,LDAP outdated

* Sat Jul 05 2008 Shu KONNO <owa@bg.wakwak.com> 3.1.4-2
- rebuilt with postgresql-8.3.3

* Sun Jun 22 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.1.4-1
- new upstream release
- not build sharp subpackage
- built with db4-4.6.21, MySQL-5.0.51a

* Tue Jan 08 2008 Shu KONNO <owa@bg.wakwak.com> 1.9.100-0vl8
- rebuilt with postgresql-8.2.6

* Wed Sep 19 2007 Shu KONNO <owa@bg.wakwak.com> 1.9.100-0vl7
- rebuilt with postgresql-8.2.5

* Sun May 20 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.9.100-0vl6
- rebuilt with new toolchain

* Wed Nov  1 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.9.100-0vl5
- rebuilt with openldap 2.3.27, MySQL 5.0.27
- added Patch0 from Fedora

* Mon Aug 28 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.9.100-0vl4
- rebuilt with openldap-devel-2.3.24-0vl4

* Sat Jun 17 2006 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.9.100-0vl3
- rebuilt with gamin-devel in place of fam-devel

* Sun Apr 30 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.9.100-0vl2
- rebuilt with readline 5.1
- added subpackage for Mono binding

* Mon Jan  9 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.9.100-0vl1
- new upstream release

* Tue May 31 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2.1-0vl1
- new upstream release
- rebuild with postgresql-devel-8.0.3-0vl2 and sqlite3-devel 

* Fri Feb 11 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2.0-0vl1
- new upstream release
- fixed %files on devel package

* Sun Aug 22 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.1.6-0vl1
- new upstream release
- re-define __libtoolize to compile shared object
- updated summary
- make sqlite package by default

* Sun Mar 28 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.3-0vl1
- new upstream release
- build with new MySQL
- make ldap package by default

* Sat Dec  6 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.2-0vl1
- new upstream release

* Fri Oct 17 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.1-0vl1
- new upstream release

* Thu Sep 25 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.0.0-1vl1
- updated to 1.0.0
- based on original spec
- disabled smp_flag at compile time

* Sun Apr 20 2003 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.2.96-0vl3
- added BuildPreReq: bonobo >= 1.0.9
  (0.2.96-0vl2 seems to be lost by accident, so putting again here)

* Sun Mar  9 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.2.96-0vl1
- New upstream release.
- use gcc-2.95.3 and g++-2.95.3

* Thu Jan 24 2002 Akira TAGOH <tagoh@gnome.gr.jp> 0.2.94-0vl1
- New upstream release.

* Fri Jan  4 2002 Akira TAGOH <tagoh@gnome.gr.jp> 0.2.93-0vl1
- Rebuild for Vine.

* Thu May 31 2001 Serge Pavlovsky <pal@re.com.ua>
- Cleaned

* Sat Sep 2 2000 Rodrigo Moya <rodrigo@linuxave.net>
- Initial spec imported from old GNOME-DB spec

