File mongo-c-driver.spec of Package mongo-c-driver
#
# spec file for package mongo-c-driver
#
# Copyright (c) 2018 SUSE LINUX 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/
#
%define DriverName mongo-c-driver
%define MongocName libmongoc-1_0-0
%define BsonName libbson-1_0-0
Name: %{MongocName}
Version: 1.13.0
Release: 0
Summary: MongoDB C Driver
License: Apache-2.0
Group: System/Libraries
URL: https://github.com/mongodb/mongo-c-driver
Source0: %{DriverName}-%{version}.tar.xz
BuildRequires: cmake
BuildRequires: cyrus-sasl-devel
BuildRequires: libtool
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: python3
BuildRequires: python3-Sphinx
BuildRequires: python3-xml
BuildRequires: snappy-devel
Provides: %{DriverName} = %{version}
Provides: libmongoc-1.0
Requires: %{BsonName} = %{version}
%description
mongo-c-driver is a library for building high-performance
applications that communicate with the MongoDB NoSQL
database in the C language.
It can also be used to write fast client implementations in
languages such as Python, Ruby, or Perl.
%package -n %{MongocName}-devel
Summary: Development files for mongo-c-driver
Group: Development/Libraries/C and C++
Requires: %{MongocName} = %{version}
%description -n %{MongocName}-devel
The %{MongocName}-devel package contains libraries and header files for
developing applications that use %{DriverName}.
%package -n %{BsonName}
Summary: A library for parsing and generating BSON documents
Group: System/Libraries
Provides: libbson-1.0
%description -n %{BsonName}
Libbson is a library providing useful routines related to
building, parsing, and iterating BSON documents.
%package -n %{BsonName}-devel
Summary: Development files for libbson
Group: Development/Libraries/C and C++
Requires: %{BsonName} = %{version}
%description -n %{BsonName}-devel
The %{BsonName}-devel package contains libraries and header files for
developing applications that use %{BsonName}.
%prep
%setup -q -n %{DriverName}-%{version}
%define ver %(echo %{version} | cut -d g -f1)
%define major %(echo %{ver} | cut -d . -f1)
%define minor %(echo %{ver} | cut -d . -f2)
%define micro %(echo %{ver} | cut -d . -f3)
%define short_version %{major}.%{minor}.%{micro}
sed -i 's/BUILD_VERSION \"0.0.0\"/BUILD_VERSION \"%{short_version}\"/' CMakeLists.txt
sed -i 's/MONGOC_MAJOR_VERSION \"0\"/MONGOC_MAJOR_VERSION \"%{major}\"/' CMakeLists.txt ||:
sed -i 's/MONGOC_MINOR_VERSION \"0\"/MONGOC_MINOR_VERSION \"%{minor}\"/' CMakeLists.txt ||:
sed -i 's/MONGOC_MICRO_VERSION \"0\"/MONGOC_MICRO_VERSION \"%{micro}\"/' CMakeLists.txt ||:
sed -i 's/BSON_MAJOR_VERSION \"0\"/BSON_MAJOR_VERSION \"%{major}\"/' src/libbson/CMakeLists.txt ||:
sed -i 's/BSON_MINOR_VERSION \"0\"/BSON_MINOR_VERSION \"%{minor}\"/' src/libbson/CMakeLists.txt ||:
sed -i 's/BSON_MICRO_VERSION \"0\"/BSON_MICRO_VERSION \"%{micro}\"/' src/libbson/CMakeLists.txt ||:
%build
%cmake \
-DENABLE_BSON=ON \
-DBUILD_SHARED_AND_STATIC_LIBS=ON \
-DENABLE_STATIC=OFF \
-DENABLE_TESTS=OFF
make %{?_smp_mflags}
%install
%cmake_install
rm -R %{buildroot}/%{_datadir}/%{DriverName} ||:
sed -i 's/\/lib/\/%{_lib}/' %{buildroot}/%{_libdir}/pkgconfig/libmongoc-1.0.pc
sed -i 's/\/lib/\/%{_lib}/' %{buildroot}/%{_libdir}/pkgconfig/libmongoc-ssl-1.0.pc
sed -i 's/\/lib/\/%{_lib}/' %{buildroot}/%{_libdir}/pkgconfig/libbson-1.0.pc
sed -i 's/0.0.0/%{short_version}/' %{buildroot}/%{_libdir}/pkgconfig/libmongoc-1.0.pc ||:
sed -i 's/0.0.0/%{short_version}/' %{buildroot}/%{_libdir}/pkgconfig/libmongoc-ssl-1.0.pc ||:
sed -i 's/0.0.0/%{short_version}/' %{buildroot}/%{_libdir}/pkgconfig/libbson-1.0.pc ||:
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%post -n %{BsonName} -p /sbin/ldconfig
%postun -n %{BsonName} -p /sbin/ldconfig
%files
%{_libdir}/libmongoc-1.0.so.*
%files -n %{BsonName}
%{_libdir}/libbson-1.0.so.*
%files -n %{MongocName}-devel
%dir %{_includedir}/libmongoc-1.0*
%{_includedir}/libmongoc-1.0/mongoc*
%{_libdir}/libmongoc-1.0.so
%{_libdir}/libmongoc*.la
%{_libdir}/pkgconfig/libmongoc-1.0.pc
%{_libdir}/pkgconfig/libmongoc-ssl-1.0.pc
%{_libdir}/cmake/mongoc-1.0
%{_libdir}/cmake/libmongoc-1.0
%{_bindir}/mongoc-stat
%files -n %{BsonName}-devel
%dir %{_includedir}/libbson-1.0*
%{_includedir}/libbson-1.0/bson*
%{_libdir}/libbson-1.0.so
%{_libdir}/libbson*.la
%{_libdir}/pkgconfig/libbson-1.0.pc
%{_libdir}/cmake/bson-1.0
%{_libdir}/cmake/libbson-1.0
%changelog