##
##  libgda.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_major 5.1
%define       V_minor 2

#   package information
Name:         libgda
Summary:      GNU Data Access Library
URL:          http://www.gnome-db.org/
Vendor:       The GNOME Project
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Database
License:      GPL/LGPL
Version:      %{V_major}.%{V_minor}
Release:      20131020

#   package options
%option       with_sqlite  yes
%option       with_pgsql   no
%option       with_mysql   no
%option       with_mdb     no
%option       with_odbc    no
%option       with_db      no
%option       with_ldap    no

#   list of sources
Source0:      http://ftp.gnome.org/pub/GNOME/sources/libgda/%{V_major}/libgda-%{version}.tar.xz
Patch0:       libgda.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  glib, libxml, libxslt, perl-xml
PreReq:       glib, libxml, libxslt, perl-xml
%if "%{with_sqlite}" == "yes"
BuildPreReq:  sqlite
PreReq:       sqlite
%endif
%if "%{with_pgsql}" == "yes"
BuildPreReq:  postgresql
PreReq:       postgresql
%endif
%if "%{with_mysql}" == "yes"
BuildPreReq:  mysql
PreReq:       mysql
%endif
%if "%{with_mdb}" == "yes"
BuildPreReq:  mdbtools
PreReq:       mdbtools
%endif
%if "%{with_odbc}" == "yes"
BuildPreReq:  ODBC
PreReq:       ODBC
%endif
%if "%{with_db}" == "yes"
BuildPreReq:  db
PreReq:       db
%endif
%if "%{with_ldap}" == "yes"
BuildPreReq:  openldap
PreReq:       openldap
%endif

%description
    GNU Data Access (GDA) is an attempt to provide uniform access to
    different kinds of data sources (databases, information servers,
    mail spools, etc). It is a complete architecture that provides all
    you need to access data. It is defined by a set of plugin APIs as
    generic as possible (but very powerful at the same time) so that
    any kind of data source can be accessed through them. libgda is an
    interface to the GDA architecture, providing a nice wrapper around
    the GDA interfaces, for both the client and the server parts. It
    also provides a bunch of tools to help you both in the development
    and management of your data sources, all done through the GDA
    model's interfaces.

%track
    prog libgda = {
        version   = %{version}
        url       = http://ftp.gnome.org/pub/GNOME/sources/libgda/%{V_major}/
        regex     = libgda-(__VER__)\.tar\.gz
    }

%prep
    %setup -q
    %patch -p0

%build
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags -O}"
    export CPPFLAGS="%{l_cppflags}"
    export LDFLAGS="%{l_ldflags}"
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
%if "%{with_sqlite}" == "yes"
        --with-sqlite=%{l_prefix} \
%else
        --without-sqlite \
%endif
%if "%{with_pgsql}" == "yes"
        --with-postgres=%{l_prefix} \
%else
        --without-postgres \
%endif
%if "%{with_mysql}" == "yes"
        --with-mysql=%{l_prefix} \
%else
        --without-mysql \
%endif
%if "%{with_mdb}" == "yes"
        --with-mdb=%{l_prefix} \
%else
        --without-mdb \
%endif
%if "%{with_odbc}" == "yes"
        --with-odbc=%{l_prefix} \
%else
        --without-odbc \
%endif
%if "%{with_db}" == "yes"
        --with-bdb=%{l_prefix} \
%else
        --without-bdb \
%endif
%if "%{with_ldap}" == "yes"
        --with-ldap=%{l_prefix} \
%else
        --without-ldap \
%endif
        --disable-rebuilds \
        --enable-shared \
        --enable-static
    %{l_make} %{l_mflags}

%install
    %{l_make} %{l_mflags} install \
        AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
        mkinstalldirs="%{l_shtool} mkdir -f -p -m 755"
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/locale
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/gtk-doc
    rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.s[ol]*
    rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std}

%files -f files

%clean

