File mingw32-mysql-connector-c.spec of Package mingw32-mysql-connector-c

#
# spec file for package mingw32-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:           mingw32-mysql-connector-c
Version:        6.1.6
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.diff
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(libssl) pkgconfig(libcrypto)
BuildRequires:  mingw32-cross-gcc-c++
BuildRequires:  mingw32-cross-pkg-config
BuildRequires:  mingw32-filesystem
BuildRequires:  mingw32-libressl-devel
BuildRequires:  mingw32-winpthreads-devel
BuildRoot:      %_tmppath/%name-%version-build
BuildArch:      noarch
%_mingw32_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 mingw32-libmysqlclient18
Summary:        MinGW Windows port of the MySQL C Connector library
Group:          System/Libraries
Obsoletes:      mingw32-mysql-connector-c

%description -n mingw32-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.

%_mingw32_debug_package

%prep
%setup -q -n mysql-connector-c-%version-src
%patch1 -p1

%build
# Build required host tool first
mkdir native
pushd native/
# FIXME: you should use %%cmake macros
cmake -DPOSIX_BUILD=1 -DMINGW=0 -DWITH_SSL=system ..
make %{?_smp_mflags} comp_err
export PATH="$PATH:$PWD/extra"
popd

mkdir build
pushd build/
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 MINGW32_CFLAGS="-include $PWD/mysql-mingw-defs.h"
export MINGW32_CXXFLAGS="$MINGW32_CFLAGS"
%_mingw32_cmake -DPOSIX_BUILD=1 -DMINGW=1 \
	-DSTACK_DIRECTION=-1 -DHAVE_LLVM_LIBCPP_EXITCODE=0 -DVERBOSE=1 ..
make %{?_smp_mflags} -j1
popd

%install
b=%buildroot

pushd build/
make install DESTDIR="$b"
mkdir -p "$b/%_mingw32_docdir/%name"
mv "$b/%_mingw32_prefix"/{COPYING,README,docs/*} "$b/%_mingw32_docdir/%name/"
rm -rf "$b/%_mingw32_bindir"
popd

pushd "$b/%_mingw32_libdir"
rm -f libmysqlclient.a libmysqlclient_r.a
mkdir -p "$b/%_mingw32_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/%_mingw32_bindir"
mv "$b/%_mingw32_bindir"/*.dll.a .
ln -s libmysqlclient-18.dll.a libmysqlclient.dll.a
ln -s libmysqlclient-18.dll.a libmysqlclient_r.dll.a
popd

%files -n mingw32-libmysqlclient18
%defattr(-,root,root)
%_mingw32_bindir/libmysqlclient*-18.dll

%files devel
%defattr(-,root,root)
%_mingw32_includedir/
%_mingw32_libdir/libmysql*
%_mingw32_docdir/%name/

%changelog
openSUSE Build Service is sponsored by