File mingw64-mysql-connector-c.spec of Package mingw64-mysql-connector-c
#
# spec file for package mingw64-mysql-connector-c
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#
Name: mingw64-mysql-connector-c
Version: 6.1.11
Release: 0
Summary: MySQL client C API
License: SUSE-GPL-2.0-with-FLOSS-exception
Group: Development/Libraries/C and C++
URL: http://mysql.com/
Source: http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-%version-src.tar.gz
Source5: rpmlintrc
Patch1: mingw-w64.patch
Patch2: mingw-gen-dll-fix.patch
Patch3: mingw64-native-build-fix.patch
BuildRequires: mingw64-cross-cmake
BuildRequires: gcc-c++
BuildRequires: pkgconfig(libssl) pkgconfig(libcrypto)
BuildRequires: mingw64-cross-gcc-c++
BuildRequires: mingw64-cross-pkg-config
BuildRequires: mingw64-filesystem
BuildRequires: mingw64-libressl-devel
BuildRequires: mingw64-winpthreads-devel
BuildArch: noarch
%_mingw64_package_header_debug
#!BuildIgnore: post-build-checks
%description
MySQL Connector/C is a C client library for client/server
communication. It is a standalone variant of the MySQL Client Library
shipped with the MySQL Server.
%package -n mingw64-libmysqlclient18
Summary: MinGW Windows port of the MySQL C Connector library
Group: System/Libraries
Provides: mingw64-mysql-connector-c = %{version}
Obsoletes: mingw64-mysql-connector-c < %{version}
%description -n mingw64-libmysqlclient18
MySQL Connector/C is a C client library for client/server
communication. It is a standalone variant of the MySQL Client Library
shipped with the MySQL Server.
%package devel
Summary: Development files for the MySQL C Connector
Group: Development/Libraries/C and C++
%description devel
Development files for the MySQL C Connector.
%_mingw64_debug_package
%prep
%autosetup -p1 -n mysql-connector-c-%version-src
%build
# Build required host tool first
mkdir native
pushd native/
# %%cmake could not be used here
cmake -DPOSIX_BUILD=1 -DMINGW=0 -DWITH_SSL=bundled ..
make %{?_smp_mflags} comp_err
export PATH="$PATH:$PWD/extra"
popd
P=$(pwd)
cat >mysql-mingw-defs.h <<-EOF
/* Do not let headers fall over themselves */
#undef WIN32_LEAN_AND_MEAN
/* Import localtime_r */
#define _DEFAULT_SOURCE
#define _POSIX_C_SOURCE 200809L
/* Avoid currently-broken printf */
#define __USE_MINGW_ANSI_STDIO 0
/* MySQL defines its own timespec :( */
#define _TIMESPEC_DEFINED
/* MSVC extensions */
#define __try if (1)
#define __except(cond) else if (0)
EOF
export MINGW64_CFLAGS="-include $P/mysql-mingw-defs.h"
export MINGW64_CXXFLAGS="$MINGW64_CFLAGS"
%_mingw64_cmake -DPOSIX_BUILD=1 -DMINGW=1 \
-DHAVE_C_FLOATING_POINT_OPTIMIZATION_PROBLEMS=TRUE \
-DHAVE_CXX_FLOATING_POINT_OPTIMIZATION_PROBLEMS=TRUE \
-DSTACK_DIRECTION=-1 -DHAVE_LLVM_LIBCPP_EXITCODE=0 -DVERBOSE=1 ..
%_mingw64_cmake_build
%install
b=%buildroot
%_mingw64_cmake_install
mkdir -p "$b/%_mingw64_docdir/%name"
rm "$b/%_mingw64_prefix"/{COPYING-*,README-*}
mv "$b/%_mingw64_prefix"/{COPYING,README,docs/*} "$b/%_mingw64_docdir/%name/"
rm -rf "$b/%_mingw64_bindir"
pushd "$b/%_mingw64_libdir"
rm -f libmysqlclient.a libmysqlclient_r.a
mkdir -p "$b/%_mingw64_bindir"
# .dll.debug may be there, or it may be not. mv files such that
# we do not explicitly test for it.
mv *.dll* "$b/%_mingw64_bindir"
mv "$b/%_mingw64_bindir"/*.dll.a .
ln -s libmysqlclient-18.dll.a libmysqlclient.dll.a
ln -s libmysqlclient-18.dll.a libmysqlclient_r.dll.a
popd
# add dllimport decoration to installed header
gawk -i inplace '$0 ~ /STDCALL / && $0 !~ /define/ { $0 = "__declspec(dllimport) " $0 } { print $0}' %{buildroot}%{_mingw64_includedir}/mysql.h
%files -n mingw64-libmysqlclient18
%defattr(-,root,root)
%_mingw64_bindir/libmysqlclient*-18.dll
%files devel
%defattr(-,root,root)
%_mingw64_includedir/
%_mingw64_libdir/libmysql*
%_mingw64_docdir/%name/
%changelog