File opendbx.spec of Package opendbx

Name:           opendbx
Version:        1.4.6
Release:        0
%define pkg_name opendbx
#
License:        LGPL-2.1-or-later
Group:          Development/Libraries/C and C++
#
%if 0%{?suse_version} > 1000 || 0%{?sle_version} >= 150000
  %define with_opendbx_sqlite3 1
  %define with_opendbx_mysql   1
%endif

%if 0%{?sles_version} > 0 && 0%{?sles_version} < 11
  %define with_opendbx_sqlite2 1
%endif

#
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  gcc-c++ pkgconfig
BuildRequires:  readline-devel
%if 0%{?with_opendbx_mysql}
BuildRequires:  mysql-devel
%endif
BuildRequires:  postgresql-devel
%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150200 
BuildRequires:  postgresql-server-devel
%endif

%if 0%{?with_opendbx_sqlite3}
  %if 0%{?suse_version} >= 1500
BuildRequires:  sqlite3-devel
  %else
BuildRequires:  sqlite-devel > 3
  %endif
%endif
%if 0%{?with_opendbx_sqlite2}
  %if 0%{?sles_version} == 9
BuildRequires:  sqlite-devel
  %else
BuildRequires:  sqlite2-devel
  %endif
%endif

Requires:       %{pkg_name}_backend
#
Url:            http://www.linuxnetworks.de/doc/index.php/OpenDBX
Source:         http://www.linuxnetworks.de/opendbx/download/%{pkg_name}-%{version}.tar.gz
#
Summary:        A single C interface to various database backends
%description
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

 Authors:
----------
    Norbert Sendetzky

%define pkg_libname libopendbx1
%package -n %{pkg_libname}
Group:          Development/Libraries/C and C++
#
Summary:        Shared library of OpenDBX
%description -n %{pkg_libname}
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the shared library from opendbx.

 Authors:
----------
    Norbert Sendetzky

%define pkg_plus_libname libopendbxplus1
%package -n %{pkg_plus_libname}
Group:          Development/Libraries/C and C++
#
Summary:        Shared C++ library of OpenDBX
%description -n %{pkg_plus_libname}
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the shared C++ library from opendbx.

 Authors:
----------
    Norbert Sendetzky

%package -n libopendbx-devel
Group:          Development/Libraries/C and C++
#
Requires:       %{pkg_libname} = %{version}
Requires:       %{pkg_plus_libname} = %{version}
Requires:       glibc-devel
Provides:       opendbx-devel = %{version}-%{release}
Obsoletes:      opendbx-devel < %{version}
#
Summary:        Development files for opendbx
%description -n libopendbx-devel
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the development files for opendbx.

 Authors:
----------
    Norbert Sendetzky

%if 0%{?with_opendbx_mysql}
%package backend-mysql
Group:          Development/Libraries/C and C++
#
Requires:       %{pkg_libname} = %{version}
Provides:       %{pkg_name}_backend = %{version}-%{release}
#
Summary:        MySQL backend for opendbx
%description backend-mysql
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the MySQL backend for opendbx.

 Authors:
----------
    Norbert Sendetzky

%endif

%package backend-pgsql
Group:          Development/Libraries/C and C++
#
Requires:       %{pkg_libname} = %{version}
Provides:       %{pkg_name}_backend = %{version}-%{release}
#
Summary:        PgSQL backend for opendbx
%description backend-pgsql
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the pgSQL backend for opendbx.

 Authors:
----------
    Norbert Sendetzky

%if 0%{?with_opendbx_sqlite3}
%package backend-sqlite3
Group:          Development/Libraries/C and C++
#
Requires:       %{pkg_libname} = %{version}
Provides:       %{pkg_name}_backend = %{version}-%{release}
#
Summary:        SQLite 3 backend for opendbx
%description backend-sqlite3
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the SQLite 3 backend for opendbx.

 Authors:
----------
    Norbert Sendetzky
%endif

%if 0%{?with_opendbx_sqlite2}
%package backend-sqlite2
Group:          Development/Libraries/C and C++
#
Requires:       %{pkg_libname} = %{version}
Provides:       %{pkg_name}_backend = %{version}-%{release}
#
Summary:        SQLite 2 backend for opendbx.
%description backend-sqlite2
OpenDBX is an extremely lightweight but extensible C library for accessing
databases with a single API. It provides a clean and simple interface across
all supported databases that leads to an elegant code design automatically.
Currently MySQL, PostgreSQL and SQLite are supported and backends for more
native database APIs can be written easily. If you want your application to
support different databases with little effort, this is definitively the right
thing for you!

This package holds the SQLite 2 backend for opendbx.

 Authors:
----------
    Norbert Sendetzky

%endif

%prep
%setup

%build
export CFLAGS="%{optflags} \
%if 0%{?with_opendbx_mysql}
  $(%{_bindir}/mysql_config --include) \
%endif
  -I$(/usr/bin/pg_config --includedir) -fno-strict-aliasing"
export CPPFLAGS="$CFLAGS --std=c++14"
%configure \
  --with-pic \
  --disable-static \
  --with-backends="\
%if 0%{?with_opendbx_mysql}
mysql \
%endif
pgsql \
%if 0%{?with_opendbx_sqlite2}
sqlite \
%endif
%if 0%{?with_opendbx_sqlite3}
sqlite3 \
%endif
"
make %{?_smp_mflags}

%install
%makeinstall
find %{buildroot} -type f -name \*.la -print0 | xargs -r0 rm -v
%find_lang %{pkg_name}
%find_lang opendbx-utils

%post   -n %{pkg_libname}      -p /sbin/ldconfig
%postun -n %{pkg_libname}      -p /sbin/ldconfig

%post   -n %{pkg_plus_libname} -p /sbin/ldconfig
%postun -n %{pkg_plus_libname} -p /sbin/ldconfig

%files -f opendbx-utils.lang
%defattr(-,root,root,-)
%{_bindir}/odbx-sql

%files -n %{pkg_libname} -f %{pkg_name}.lang
%defattr(-,root,root,-)
%{_libdir}/lib%{pkg_name}.so.1*
%dir %{_libdir}/%{pkg_name}
%{_datadir}/opendbx/

%files -n %{pkg_plus_libname}
%defattr(-,root,root,-)
%{_libdir}/libopendbxplus.so.1*

%files -n libopendbx-devel
%defattr(-,root,root,-)
%{_includedir}/odbx.h
%{_includedir}/opendbx/
%{_libdir}/libopendbx.so
%{_libdir}/libopendbxplus.so
%{_libdir}/pkgconfig/opendbx.pc
%{_libdir}/pkgconfig/opendbxplus.pc

%if 0%{?with_opendbx_mysql}
%files backend-mysql
%defattr(-,root,root,-)
%{_libdir}/%{pkg_name}/libmysqlbackend.so*
%endif

%files backend-pgsql
%defattr(-,root,root,-)
%{_libdir}/%{pkg_name}/libpgsqlbackend.so*

%if 0%{?with_opendbx_sqlite3}
%files backend-sqlite3
%defattr(-,root,root,-)
%{_libdir}/%{pkg_name}/libsqlite3backend.so*
%endif

%if 0%{?with_opendbx_sqlite2}
%files backend-sqlite2
%defattr(-,root,root,-)
%{_libdir}/%{pkg_name}/libsqlitebackend.so*
%endif

%changelog
openSUSE Build Service is sponsored by