File gnatcoll-db.spec of Package gnatcoll-db

%define _pkg_ver_ 26.0.0
%define _src_ver_ 26.0.0

%define VERSION_MAJOR 26
%define VERSION_MINOR .0
%define VERSION_PATCH .0

%define gnatcoll_version %{VERSION_MAJOR}%{VERSION_MINOR}

%define with_sqlite      1
%define with_postgres    1
%define with_xref        1
%define with_gnatinspect 1

%if %{with_gnatinspect}
%define with_xref        1
%endif

Name:          gnatcoll-db
Version:       %{_pkg_ver_}
Release:       6.1
Summary:       The GNAT Components Collection (GNATcoll) - Database packages
License:       GPL-3.0-or-later WITH GCC-exception-3.1
Group:         Development/Libraries/Ada
Source0:       %{name}-%{_src_ver_}.tar.gz
URL:           https://github.com/AdaCore/gnatcoll-db
BuildRequires: gcc-ada
BuildRequires: gprbuild
BuildRequires: python3-Sphinx
BuildRequires: python3-sphinx_rtd_theme
BuildRequires: gnatcoll_projects-devel
BuildRequires: pkg-config
%if %{with_postgres}
BuildRequires: postgresql-devel
%endif
%if %{with_xref}
BuildRequires: gnatcoll_iconv-devel = %{version}
%endif
#!BuildIgnore: gcc-PIE

%description
This is the DB module of the GNAT Components Collection. Please refer to
individual components for more details.

%package -n libgnatcoll_sql
Summary: The GNAT Components Collection (GNATcoll) - SQL
Group:   System/Libraries

%description -n libgnatcoll_sql
This is the SQL component of the GNAT Components Collection.

%package -n gnatcoll_sql-devel
Summary:  The GNAT Components Collection (GNATcoll) - SQL
Requires: libgnatcoll_sql = %{version}
Requires: gnatcoll_projects-devel = %{version}

%description -n gnatcoll_sql-devel
This is the SQL component of the GNAT Components Collection.

This package contains the development files for GNATcoll.

%package -n libgnatcoll_sqlite
Summary: The GNAT Components Collection (GNATcoll) - Sqlite
Group:   System/Libraries

%description -n libgnatcoll_sqlite
This component extends the GNATCOLL.SQL hierarchy for the sqlite3 DBMS.

%package -n gnatcoll_sqlite-devel
Summary:  The GNAT Components Collection (GNATcoll) - Sqlite
Requires: libgnatcoll_sqlite = %{version}
Requires: gnatcoll_sql-devel = %{version}

%description -n gnatcoll_sqlite-devel
This component extends the GNATCOLL.SQL hierarchy for the sqlite3 DBMS.

This package contains the development files for GNATcoll.

%if %{with_postgres}
%package -n libgnatcoll_postgres
Summary: The GNAT Components Collection (GNATcoll) - Postgres
Group:   System/Libraries

%description -n libgnatcoll_postgres
This component extends the GNATCOLL.SQL hierarchy for the PostgreSQL DBMS.

%package -n gnatcoll_postgres-devel
Summary:  The GNAT Components Collection (GNATcoll) - Postgres
Requires: libgnatcoll_postgres = %{version}
Requires: gnatcoll_sql-devel = %{version}
Requires: postgresql-devel

%description -n gnatcoll_postgres-devel
This component extends the GNATCOLL.SQL hierarchy for the PostgreSQL DBMS.

This package contains the development files for GNATcoll.
%endif

%if %{with_xref}
%package -n libgnatcoll_xref
Summary: The GNAT Components Collection (GNATcoll) - Xref
Group:   System/Libraries

%description -n libgnatcoll_xref
This component provides support for parsing the .ali and .gli files that
are generated by GNAT and gcc. In particular, those files contain
information that can be used to do cross-references for entities (going
from references to their declaration for instance).

%package -n gnatcoll_xref-devel
Summary:  The GNAT Components Collection (GNATcoll) - Xref
Requires: libgnatcoll_xref = %{version}
Requires: gnatcoll_sql-devel = %{version}
Requires: gnatcoll_sqlite-devel = %{version}
Requires: gnatcoll_iconv-devel = %{version}

%description -n gnatcoll_xref-devel
This component provides support for parsing the .ali and .gli files that
are generated by GNAT and gcc. In particular, those files contain
information that can be used to do cross-references for entities (going
from references to their declaration for instance).

This package contains the development files for GNATcoll.
%endif

%package -n gnatinspect
Summary: The GNAT Components Collection (GNATCOLL) - gnatinspect
Group:   Development/Tools/Other

%description -n gnatinspect
The gnatinspect tool - query cross-references on source code.

%package -n gnatcoll_db2ada
Summary: The GNAT Components Collection (GNATCOLL) - gnatcoll_db2ada
Group:   Development/Tools/Other

%description -n gnatcoll_db2ada
This is the DB module of the GNAT Components Collection.
This package provides the gnatcoll_db2ada tools that generates an Ada package
from a SQL schema.

%package doc
Summary:   Documentation for GNATcoll Database packages
Group:     Documentation/HTML
BuildArch: noarch

%description doc
This is the DB module of the GNAT Components Collection.
This package provides the documentation in HTML.

%prep
%setup -q -n %{name}-%{_src_ver_}
echo "%{VERSION_MAJOR}%{VERSION_MINOR}" > version_information

# PQprepare is supported only in protocol 3.0 and later connections.
# The version 3.0 of the protocol, implemented in PostgreSQL 7.4 and later.
%if %{with_postgres}
%define gnatcoll_haspqprepare no
%define _libpq_ver_ %(pkg-config libpq --modversion)
%if %{lua:print(rpm.vercmp(rpm.expand("%{_libpq_ver_}"), "7.4"))} >= 0
%define gnatcoll_haspqprepare yes
%endif
%endif

%build
unset GPR_PROJECT_PATH_FILE
unset GPR_PROJECT_PATH
# SQL
#__make -C sql
for kind in static static-pic relocatable; do
  gprbuild -R -p -m \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    sql/gnatcoll_sql.gpr
done
# SQLITE
#__make -C sqlite
for kind in static static-pic relocatable; do
  gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    -XGNATCOLL_SQLITE=embedded \
    sqlite/gnatcoll_sqlite.gpr
done
# POSTRGES
%if %{with_postgres}
#__make -C postgres
for kind in static static-pic relocatable; do
  gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    -XGNATCOLL_HASPQPREPARE=%{gnatcoll_haspqprepare} \
    postgres/gnatcoll_postgres.gpr
done
%endif
#XREF
%if %{with_xref}
#__make -C xref
for kind in static static-pic relocatable; do
  gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/sqlite \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    xref/gnatcoll_xref.gpr
done
%endif
# GNATINSPECT
#__make -C gnatinspect
gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/sqlite \
    -aP %{_builddir}/%{?buildsubdir}/xref \
    -XBUILD=PROD -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=static -XGPR_BUILD=static -XXMLADA_BUILD=static \
    gnatinspect/gnatinspect.gpr
# DB2ADA
gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/sqlite \
    -XBUILD=PROD -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=static -XGPR_BUILD=static -XXMLADA_BUILD=static \
    gnatcoll_db2ada/gnatcoll_db2ada.gpr
gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/sqlite \
    -XBUILD=PROD -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=static -XGPR_BUILD=static -XXMLADA_BUILD=static \
    gnatcoll_db2ada/gnatcoll_sqlite2ada.gpr
%if %{with_postgres}
gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/postgres \
    -XBUILD=PROD -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=static -XGPR_BUILD=static -XXMLADA_BUILD=static \
    gnatcoll_db2ada/gnatcoll_postgres2ada.gpr
%endif
%if %{with_sqlite} && %{with_postgres}
gprbuild -R -p -m \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/sqlite \
    -aP %{_builddir}/%{?buildsubdir}/postgres \
    -XBUILD=PROD -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=static -XGPR_BUILD=static -XXMLADA_BUILD=static \
    gnatcoll_db2ada/gnatcoll_all2ada.gpr
%endif
# DOCS
%__make html -C docs

%install
unset GPR_PROJECT_PATH_FILE
unset GPR_PROJECT_PATH
# SQL
#__make prefix=%{buildroot}%{_prefix} -C sql install
for kind in static static-pic relocatable; do
  gprinstall -p \
    --prefix=%{buildroot}%{_prefix} \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    --sources-subdir=include/gnatcoll_sql \
    --lib-subdir=%{_lib}/gnatcoll_sql.$kind \
    --link-lib-subdir=%{_lib} \
    --build-name=$kind \
    --build-var=LIBRARY_TYPE \
    --no-manifest \
    sql/gnatcoll_sql.gpr
done
# SQLITE
#__make prefix=%{buildroot}%{_prefix} -C sqlite install
for kind in static static-pic relocatable; do
  gprinstall -p \
    --prefix=%{buildroot}%{_prefix} \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -XGNATCOLL_SQLITE=embedded \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    --sources-subdir=include/gnatcoll_sqlite \
    --lib-subdir=%{_lib}/gnatcoll_sqlite.$kind \
    --link-lib-subdir=%{_lib} \
    --build-name=$kind \
    --build-var=LIBRARY_TYPE \
    --no-manifest \
    sqlite/gnatcoll_sqlite.gpr
done
# POSTGRES
%if %{with_postgres}
#__make prefix=%{buildroot}%{_prefix} -C postgres install
for kind in static static-pic relocatable; do
  gprinstall -p \
    --prefix=%{buildroot}%{_prefix} \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -XGNATCOLL_HASPQPREPARE=%{gnatcoll_haspqprepare} \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    --sources-subdir=include/gnatcoll_postgres \
    --lib-subdir=%{_lib}/gnatcoll_postgres.$kind \
    --link-lib-subdir=%{_lib} \
    --build-name=$kind \
    --build-var=LIBRARY_TYPE \
    --no-manifest \
    postgres/gnatcoll_postgres.gpr
done
%endif
# XREF
%if %{with_xref}
#__make prefix=%{buildroot}%{_prefix} -C xref install
for kind in static static-pic relocatable; do
  gprinstall -p \
    --prefix=%{buildroot}%{_prefix} \
    -aP %{_builddir}/%{?buildsubdir}/sql \
    -aP %{_builddir}/%{?buildsubdir}/sqlite \
    -XBUILD=PROD \
    -XGNATCOLL_VERSION=%{gnatcoll_version} \
    -XLIBRARY_TYPE=$kind \
    -XGPR_BUILD=$kind \
    -XXMLADA_BUILD=$kind \
    --sources-subdir=include/gnatcoll_xref \
    --lib-subdir=%{_lib}/gnatcoll_xref.$kind \
    --link-lib-subdir=%{_lib} \
    --build-name=$kind \
    --build-var=LIBRARY_TYPE \
    --no-manifest \
    xref/gnatcoll_xref.gpr
done
%endif
# GNATINSPECT
#__make prefix=%{buildroot}%{_prefix} -C gnatinspect install
%__install -m 0755 -d %{buildroot}%{_bindir}
%__install -m 0755 gnatinspect/obj/gnatinspect %{buildroot}%{_bindir}
# DB2ADA
%__install -m 0755 -d %{buildroot}%{_bindir}
%__install -m 0755 gnatcoll_db2ada/obj/gnatcoll_*2ada %{buildroot}%{_bindir}
%__install -m 0755 -d %{buildroot}%{_datadir}/gnatcoll
%__install -m 0644 gnatcoll_db2ada/dborm.py %{buildroot}%{_datadir}/gnatcoll
# DOCS
%__mkdir -p %{buildroot}%{_datadir}/doc/%{name}
%__cp -r docs/_build/html %{buildroot}%{_datadir}/doc/%{name}
# EXAMPLES
%__mkdir -p %{buildroot}%{_datadir}/examples/%{name}
%__cp -r examples/* %{buildroot}%{_datadir}/examples/%{name}


%post -n libgnatcoll_sql
%run_ldconfig
%postun -n libgnatcoll_sql
%run_ldconfig

%post -n libgnatcoll_sqlite
%run_ldconfig
%postun -n libgnatcoll_sqlite
%run_ldconfig

%if %{with_postgres}
%post -n libgnatcoll_postgres
%run_ldconfig
%postun -n libgnatcoll_postgres
%run_ldconfig
%endif

%if %{with_xref}
%post -n libgnatcoll_xref
%run_ldconfig
%postun -n libgnatcoll_xref
%run_ldconfig
%endif

%files -n libgnatcoll_sql
%license COPYING*
%dir %{_libdir}/gnatcoll_sql.relocatable
%{_libdir}/gnatcoll_sql.relocatable/libgnatcoll_sql.so.*
%{_libdir}/libgnatcoll_sql.so.*

%files -n gnatcoll_sql-devel
%defattr(-, root, root)
%{_includedir}/gnatcoll_sql
%dir %{_libdir}/gnatcoll_sql.*
%{_libdir}/gnatcoll_sql.static/*.ali
%{_libdir}/gnatcoll_sql.static/libgnatcoll_sql.a
%{_libdir}/gnatcoll_sql.static-pic/*.ali
%{_libdir}/gnatcoll_sql.static-pic/libgnatcoll_sql.a
%{_libdir}/gnatcoll_sql.relocatable/*.ali
%{_libdir}/gnatcoll_sql.relocatable/libgnatcoll_sql.so
%{_libdir}/libgnatcoll_sql.so
%{_datadir}/gpr/gnatcoll_sql.gpr

%files -n libgnatcoll_sqlite
%license COPYING*
%dir %{_libdir}/gnatcoll_sqlite.relocatable
%{_libdir}/gnatcoll_sqlite.relocatable/libgnatcoll_sqlite.so.*
%{_libdir}/libgnatcoll_sqlite.so.*

%files -n gnatcoll_sqlite-devel
%defattr(-, root, root)
%doc sqlite/README.md
%{_includedir}/gnatcoll_sqlite
%dir %{_libdir}/gnatcoll_sqlite.*
%{_libdir}/gnatcoll_sqlite.static/*.ali
%{_libdir}/gnatcoll_sqlite.static/libgnatcoll_sqlite.a
%{_libdir}/gnatcoll_sqlite.static-pic/*.ali
%{_libdir}/gnatcoll_sqlite.static-pic/libgnatcoll_sqlite.a
%{_libdir}/gnatcoll_sqlite.relocatable/*.ali
%{_libdir}/gnatcoll_sqlite.relocatable/libgnatcoll_sqlite.so
%{_libdir}/libgnatcoll_sqlite.so
%{_datadir}/gpr/gnatcoll_sqlite.gpr

%if %{with_postgres}
%files -n libgnatcoll_postgres
%license COPYING*
%dir %{_libdir}/gnatcoll_postgres.relocatable
%{_libdir}/gnatcoll_postgres.relocatable/libgnatcoll_postgres.so.*
%{_libdir}/libgnatcoll_postgres.so.*

%files -n gnatcoll_postgres-devel
%defattr(-, root, root)
%doc postgres/README.md
%{_includedir}/gnatcoll_postgres
%dir %{_libdir}/gnatcoll_postgres.*
%{_libdir}/gnatcoll_postgres.static/*.ali
%{_libdir}/gnatcoll_postgres.static/libgnatcoll_postgres.a
%{_libdir}/gnatcoll_postgres.static-pic/*.ali
%{_libdir}/gnatcoll_postgres.static-pic/libgnatcoll_postgres.a
%{_libdir}/gnatcoll_postgres.relocatable/*.ali
%{_libdir}/gnatcoll_postgres.relocatable/libgnatcoll_postgres.so
%{_libdir}/libgnatcoll_postgres.so
%{_datadir}/gpr/gnatcoll_postgres.gpr
%endif

%if %{with_xref}
%files -n libgnatcoll_xref
%license COPYING*
%dir %{_libdir}/gnatcoll_xref.relocatable
%{_libdir}/gnatcoll_xref.relocatable/libgnatcoll_xref.so.*
%{_libdir}/libgnatcoll_xref.so.*

%files -n gnatcoll_xref-devel
%defattr(-, root, root)
%doc xref/README.md
%{_includedir}/gnatcoll_xref
%dir %{_libdir}/gnatcoll_xref.*
%{_libdir}/gnatcoll_xref.static/*.ali
%{_libdir}/gnatcoll_xref.static/libgnatcoll_xref.a
%{_libdir}/gnatcoll_xref.static-pic/*.ali
%{_libdir}/gnatcoll_xref.static-pic/libgnatcoll_xref.a
%{_libdir}/gnatcoll_xref.relocatable/*.ali
%{_libdir}/gnatcoll_xref.relocatable/libgnatcoll_xref.so
%{_libdir}/libgnatcoll_xref.so
%{_datadir}/gpr/gnatcoll_xref.gpr
%endif

%files -n gnatinspect
%defattr(-, root, root)
%doc gnatinspect/README.md
%license COPYING*
%{_bindir}/gnatinspect

%files -n gnatcoll_db2ada
%defattr(-, root, root)
%doc gnatcoll_db2ada/README.md gnatcoll_db2ada/dbschema.txt
%license COPYING*
%{_bindir}/gnatcoll_*2ada
%dir %{_datadir}/gnatcoll
%{_datadir}/gnatcoll/dborm.py

%files doc
%defattr(-, root, root)
%dir %{_datadir}/doc/%{name}
%{_datadir}/doc/%{name}/html
%dir %{_datadir}/examples
%dir %{_datadir}/examples/%{name}
%{_datadir}/examples/%{name}/*

%changelog
openSUSE Build Service is sponsored by