soci.spec.cmake 10.9 KB
Newer Older
Erwan Croze's avatar
Erwan Croze committed
1 2
# -*- rpm-spec -*-

3 4
%define _prefix    @CMAKE_INSTALL_PREFIX@
%define pkg_prefix @BC_PACKAGE_NAME_PREFIX@
Erwan Croze's avatar
Erwan Croze committed
5

6
%define build_number 3
Erwan Croze's avatar
Erwan Croze committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
%define _lib_name soci

%define _is_set() %1 == "YES" || %1 == "ON" || %1 == "TRUE" || %1 == "1" || %1 == "Y"

%if %{_is_set "@WITH_DB2@"}
  %define _with_db2 1
%endif
%if %{_is_set "@WITH_FIREBIRD@"}
  %define _with_firebird 1
%endif
%if %{_is_set "@WITH_MYSQL@"}
  %define _with_mysql 1
%endif
%if %{_is_set "@WITH_ODBC@"}
  %define _with_odbc 1
%endif
%if %{_is_set "@WITH_ORACLE@"}
  %define _with_oracle 1
%endif
%if %{_is_set "@WITH_POSTGRESQL@"}
  %define _with_postgresql 1
%endif
%if %{_is_set "@WITH_SQLITE3@"}
  %define _with_sqlite3 1
%endif

Name:           @CPACK_PACKAGE_NAME@
Version:        @PROJECT_VERSION@
Erwan Croze's avatar
Erwan Croze committed
36 37 38
Release:        %{build_number}%{?dist}
Summary:        The database access library for C++ programmers

39

Erwan Croze's avatar
Erwan Croze committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
Group:          System Environment/Libraries
License:        Boost
URL:            http://soci.sourceforge.net/
Source0:        %{name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot

%description
%{name} is a C++ database access library that provides the
illusion of embedding SQL in regular C++ code, staying entirely within
the C++ standard.


%{?_with_sqlite3:%package        sqlite3
Summary:        SQLite3 back-end for %{name}
Group:          System Environment/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}
BuildRequires:  sqlite-devel

%description    sqlite3
This package contains the SQLite3 back-end for %{name}, i.e.,
dynamic library specific to the SQLite3 database. If you would like to
use %{name} in your programs with SQLite3, you will need to
install %{name}-sqlite3.}

64

Erwan Croze's avatar
Erwan Croze committed
65 66 67 68 69 70 71 72 73 74 75 76
%{?_with_mysql:%package        mysql
Summary:        MySQL back-end for %{name}
Group:          System Environment/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}
BuildRequires:  mysql-devel

%description    mysql
This package contains the MySQL back-end for %{name}, i.e.,
dynamic library specific to the MySQL database. If you would like to
use %{name} in your programs with MySQL, you will need to
install %{name}-mysql.}

77

Erwan Croze's avatar
Erwan Croze committed
78 79 80 81 82 83 84 85 86 87 88 89
%{?_with_postgresql:%package        postgresql
Summary:        PostGreSQL back-end for %{name}
Group:          System Environment/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}
BuildRequires:  postgresql-devel

%description    postgresql
This package contains the PostGreSQL back-end for %{name}, i.e.,
dynamic library specific to the PostGreSQL database. If you would like
to use %{name} in your programs with PostGreSQL, you will need to
install %{name}-postgresql.}

90

Erwan Croze's avatar
Erwan Croze committed
91 92 93 94 95 96 97 98 99 100 101 102
%{?_with_odbc:%package        odbc
Summary:        ODBC back-end for %{name}
Group:          System Environment/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}
BuildRequires:  unixODBC-devel

%description    odbc
This package contains the ODBC back-end for %{name}, i.e.,
dynamic library specific to the ODBC connectors. If you would like to
use %{name} in your programs with ODBC, you will need to
install %{name}-odbc.}

103

Erwan Croze's avatar
Erwan Croze committed
104 105 106 107 108 109 110 111 112 113 114
%{?_with_oracle:%package        oracle
Summary:        Oracle back-end for %{name}
Group:          System Environment/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    oracle
This package contains the Oracle back-end for %{name}, i.e.,
dynamic library specific to the Oracle database. If you would like to
use %{name} in your programs with Oracle, you will need to install
%{name}-oracle.}

115

Erwan Croze's avatar
Erwan Croze committed
116 117 118 119 120 121 122 123 124 125 126
%package        devel
Summary:        Header files, libraries and development documentation for %{name}
Group:          Development/Libraries
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       pkgconfig

%description    devel
This package contains the header files, dynamic libraries and
development documentation for %{name}. If you would like to develop
programs using %{name}, you will need to install %{name}-devel.

127

Erwan Croze's avatar
Erwan Croze committed
128 129 130 131 132 133 134 135 136 137 138 139 140
%{?_with_sqlite3:%package        sqlite3-devel
Summary:        SQLite3 back-end for %{name}
Group:          Development/Libraries
Requires:       %{name}-devel = %{version}-%{release}
Requires:       %{name}-sqlite3 = %{version}-%{release}
Requires:       sqlite-devel

%description    sqlite3-devel
This package contains the SQLite3 back-end for %{name}, i.e., header
files and dynamic libraries specific to the SQLite3 database. If you
would like to develop programs using %{name} and SQLite3, you will need
to install %{name}-sqlite3.}

141

Erwan Croze's avatar
Erwan Croze committed
142 143 144 145 146 147 148 149 150 151 152 153 154
%{?_with_mysql:%package        mysql-devel
Summary:        MySQL back-end for %{name}
Group:          Development/Libraries
Requires:       %{name}-devel = %{version}-%{release}
Requires:       %{name}-mysql = %{version}-%{release}
Requires:       mysql-devel

%description    mysql-devel
This package contains the MySQL back-end for %{name}, i.e., header
files and dynamic libraries specific to the MySQL database. If you
would like to develop programs using %{name} and MySQL, you will need
to install %{name}-mysql.}

155

Erwan Croze's avatar
Erwan Croze committed
156 157 158 159 160 161 162 163 164 165 166 167 168
%{?_with_postgresql:%package        postgresql-devel
Summary:        PostGreSQL back-end for %{name}
Group:          Development/Libraries
Requires:       %{name}-devel = %{version}-%{release}
Requires:       %{name}-postgresql = %{version}-%{release}
Requires:       postgresql-devel

%description    postgresql-devel
This package contains the PostGreSQL back-end for %{name}, i.e., header
files and dynamic libraries specific to the PostGreSQL database. If
you would like to develop programs using %{name} and PostGreSQL, you
will need to install %{name}-postgresql.}

169

Erwan Croze's avatar
Erwan Croze committed
170 171 172 173 174 175 176 177 178 179 180 181 182
%{?_with_odbc:%package        odbc-devel
Summary:        ODBC back-end for %{name}
Group:          Development/Libraries
Requires:       %{name}-devel = %{version}-%{release}
Requires:       %{name}-odbc = %{version}-%{release}
Requires:       unixODBC-devel

%description    odbc-devel
This package contains the Odbc back-end for %{name}, i.e., header
files and dynamic libraries specific to the Odbc database. If you
would like to develop programs using %{name} and Odbc, you will need
to install %{name}-odbc.}

183

Erwan Croze's avatar
Erwan Croze committed
184 185 186 187 188 189 190 191 192 193 194 195
%{?_with_oracle:%package        oracle-devel
Summary:        Oracle back-end for %{name}
Group:          Development/Libraries
Requires:       %{name}-devel = %{version}-%{release}
Requires:       %{name}-oracle = %{version}-%{release}

%description    oracle-devel
This package contains the Oracle back-end for %{name}, i.e., header
files and dynamic libraries specific to the Oracle database. If you
would like to develop programs using %{name} and Oracle, you will need
to install %{name}-oracle.}

196

Erwan Croze's avatar
Erwan Croze committed
197 198 199 200 201 202 203 204 205 206 207 208 209
%package        doc
Summary:        HTML documentation for the %{name} library
Group:          Documentation
%if 0%{?fedora} || 0%{?rhel} > 5
BuildArch:      noarch
%endif
#BuildRequires:  tex(latex)
#BuildRequires:  doxygen, ghostscript

%description    doc
This package contains the documentation in the HTML format of the %{name}
library. The documentation is the same as at the %{name} web page.

210

Erwan Croze's avatar
Erwan Croze committed
211 212 213 214 215 216
%if 0%{?rhel} && 0%{?rhel} <= 7
%global cmake_name cmake3
%else
%global cmake_name cmake
%endif

Erwan Croze's avatar
Erwan Croze committed
217 218 219 220 221 222 223 224 225 226
%prep
%setup -n %{name}-%{version}

mv README.md README
mv CHANGES ChangeLog
echo "2017-12-06:" > NEWS
echo "- Version 4.0.0" >> NEWS
echo "- See the ChangeLog file for more details." >> NEWS

%build
Erwan Croze's avatar
Erwan Croze committed
227
%{expand:%%%cmake_name} . \
228 229 230 231 232 233 234 235 236 237 238 239 240
  -DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@ \
  -DCMAKE_PREFIX_PATH:PATH=%{_prefix} \
  -DSOCI_CXX_C11=ON \
  -DSOCI_EMPTY=OFF \
  -DSOCI_TESTS=OFF \
  -DWITH_DB2=@WITH_DB2@ \
  -DWITH_FIREBIRD=@WITH_FIREBIRD@ \
  -DWITH_MYSQL=@WITH_MYSQL@ \
  -DWITH_ODBC=@WITH_ODBC@ \
  -DWITH_ORACLE=@WITH_ORACLE@ \
  -DWITH_POSTGRESQL=@WITH_POSTGRESQL@ \
  -DWITH_SQLITE3=@WITH_SQLITE3@
make %{?_smp_mflags}
Erwan Croze's avatar
Erwan Croze committed
241 242

%install
243
make install DESTDIR=%{buildroot}
Erwan Croze's avatar
Erwan Croze committed
244 245 246
#  Remove unpackaged files from the buildroot
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
rm -f $RPM_BUILD_ROOT%{_includedir}/soci/soci-config.h.in
247 248
rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/empty

Erwan Croze's avatar
Erwan Croze committed
249
%{!?_with_db2:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/db2}
250
%{!?_with_firebird:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/firebird}
Erwan Croze's avatar
Erwan Croze committed
251 252 253
%{!?_with_mysql:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/mysql}
%{!?_with_odbc:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/odbc}
%{!?_with_oracle:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/oracle}
254 255 256 257 258
%{!?_with_postgresql:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/postgresql}
%{!?_with_sqlite3:rm -rf $RPM_BUILD_ROOT%{_includedir}/soci/sqlite3}

%clean
rm -rf $RPM_BUILD_ROOT
Erwan Croze's avatar
Erwan Croze committed
259 260 261 262

%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
263 264
%{_libdir}/lib%{_lib_name}_core.so.*
%{?_with_empty:%{_libdir}/lib%{_lib_name}_empty.so.*}
Erwan Croze's avatar
Erwan Croze committed
265 266 267 268

%{?_with_sqlite3:%files sqlite3
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
269
%{_libdir}/lib%{_lib_name}_sqlite3.so.*}
Erwan Croze's avatar
Erwan Croze committed
270 271 272 273

%{?_with_mysql:%files mysql
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
274
%{_libdir}/lib%{_lib_name}_mysql.so.*}
Erwan Croze's avatar
Erwan Croze committed
275 276 277 278

%{?_with_postgresql:%files postgresql
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
279
%{_libdir}/lib%{_lib_name}_postgresql.so.*}
Erwan Croze's avatar
Erwan Croze committed
280 281 282 283

%{?_with_odbc:%files odbc
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
284
%{_libdir}/lib%{_lib_name}_odbc.so.*}
Erwan Croze's avatar
Erwan Croze committed
285 286 287 288

%{?_with_oracle:%files oracle
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
289
%{_libdir}/lib%{_lib_name}_oracle.so.*}
Erwan Croze's avatar
Erwan Croze committed
290 291 292 293 294 295


%files devel
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
%{_prefix}/cmake/*
Erwan Croze's avatar
Erwan Croze committed
296 297 298 299 300
%dir %{_includedir}/%{_lib_name}/
%{_includedir}/%{_lib_name}/*.h
%{?_with_empty:%{_includedir}/%{_lib_name}/empty/}
%{_libdir}/lib%{_lib_name}_core.so
%{?_with_empty:%{_libdir}/lib%{_lib_name}_empty.so}
Erwan Croze's avatar
Erwan Croze committed
301 302 303 304

%{?_with_sqlite3:%files sqlite3-devel
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
305 306 307
%dir %{_includedir}/%{_lib_name}
%{_includedir}/%{_lib_name}/sqlite3/
%{_libdir}/lib%{_lib_name}_sqlite3.so}
Erwan Croze's avatar
Erwan Croze committed
308 309 310 311

%{?_with_mysql:%files mysql-devel
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
312 313 314
%dir %{_includedir}/%{_lib_name}
%{_includedir}/%{_lib_name}/mysql
%{_libdir}/lib%{_lib_name}_mysql.so}
Erwan Croze's avatar
Erwan Croze committed
315 316 317 318

%{?_with_postgresql:%files postgresql-devel
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
319 320 321
%dir %{_includedir}/%{_lib_name}
%{_includedir}/%{_lib_name}/postgresql
%{_libdir}/lib%{_lib_name}_postgresql.so}
Erwan Croze's avatar
Erwan Croze committed
322 323 324 325

%{?_with_odbc:%files odbc-devel
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
326 327 328
%dir %{_includedir}/%{_lib_name}
%{_includedir}/%{_lib_name}/odbc/
%{_libdir}/lib%{_lib_name}_odbc.so}
Erwan Croze's avatar
Erwan Croze committed
329 330 331 332

%{?_with_oracle:%files oracle-devel
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README
Erwan Croze's avatar
Erwan Croze committed
333 334 335
%dir %{_includedir}/%{_lib_name}
%{_includedir}/%{_lib_name}/oracle
%{_libdir}/lib%{_lib_name}_oracle.so}
Erwan Croze's avatar
Erwan Croze committed
336 337 338 339 340 341

%files doc
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING NEWS README docs

%changelog
342 343 344 345

* Tue Nov 27 2018 ronan.abhamon <ronan.abhamon@belledonne-communications.com>
- Do not set CMAKE_INSTALL_LIBDIR and never with _libdir!

346 347 348
* Tue Oct 30 2018 ronan.abhamon <ronan.abhamon@belledonne-communications.com>
- Use CPack.

Erwan Croze's avatar
Erwan Croze committed
349 350
* Wed Dec 6 2017 erwan.croze <erwan.croze@belledonne.communications.com>
- Initial RPM release.