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
Source99:       %{DriverName}-rpmlintrc
BuildRequires:  gcc
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 libmongoc-devel
Summary:        Development files for mongo-c-driver
Group:          Development/Libraries/C and C++
Requires:       %{MongocName} = %{version}
Requires:       libbson-devel = %{version}

%description -n libmongoc-devel
The %{MongocName}-devel package contains libraries and header files for
developing applications that use %{DriverName}.

%package -n libmongoc-static-devel
Summary:        Development files for libbson
Group:          Development/Libraries/C and C++
Requires:       libmongoc-devel = %{version}
Requires:       libbson-static-devel = %{version}

%description -n libmongoc-static-devel
This package adds static libraries to the libmongoc-devel package.

%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 libbson-devel
Summary:        Development files for libbson
Group:          Development/Libraries/C and C++
Requires:       %{BsonName} = %{version}

%description -n libbson-devel
The libbson-devel package contains libraries and header files for
developing applications that use %{BsonName}.

%package -n libbson-static-devel
Summary:        Development files for libbson
Group:          Development/Libraries/C and C++
Requires:       libbson-devel = %{version}

%description -n libbson-static-devel
This package adds static libraries to the libbson-devel package.

%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 ||:
echo %{version} > VERSION_CURRENT

%build

%cmake \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_C_FLAGS="$RPM_OPT_FLAGS -flto -ffat-lto-objects" \
  -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \
  -DENABLE_BSON=ON \
  -DBUILD_SHARED_LIBS=ON \
  -DBUILD_SHARED_AND_STATIC_LIBS=ON \
  -DCMAKE_SKIP_RPATH=ON \
  -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-static-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 ||:
sed -i 's/0.0.0/%{short_version}/' %{buildroot}/%{_libdir}/pkgconfig/libbson-static-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 libmongoc-devel
%dir %{_includedir}/libmongoc-1.0*
%{_includedir}/libmongoc-1.0/mongoc*
%{_libdir}/libmongoc-1.0.so
%{_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 libmongoc-static-devel
%{_libdir}/libmongoc*.a
%{_libdir}/pkgconfig/libmongoc-static-1.0.pc
%{_libdir}/cmake/libmongoc-static-1.0

%files -n libbson-devel
%dir %{_includedir}/libbson-1.0*
%{_includedir}/libbson-1.0/bson*
%{_libdir}/libbson-1.0.so
%{_libdir}/pkgconfig/libbson-1.0.pc
%{_libdir}/cmake/bson-1.0
%{_libdir}/cmake/libbson-1.0

%files -n libbson-static-devel
%{_libdir}/libbson*.a
%{_libdir}/pkgconfig/libbson-static-1.0.pc
%{_libdir}/cmake/libbson-static-1.0

%changelog
openSUSE Build Service is sponsored by