summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 171b5a0d99d80e1e8c87f457bbfdcf26e7ed4015 (plain)
1
2
3
4
5
6
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Maintainer: Martchus <martchus@gmx.net>
# Contributor: ant32 <antreimer@gmail.com>

# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
# you also find the URL of a binary repository.

# All patches are managed at https://github.com/Martchus/mariadb-connector-c

pkgname=mingw-w64-mariadb-connector-c
pkgver=2.3.3
pkgrel=1
pkgdesc='MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases (mingw-w64)'
arch=('any')
url='https://mariadb.com/kb/en/mariadb/about-mariadb-connector-c'
license=('LGPL')
replaces=('mingw-w64-libmariadbclient')
conflicts=('mingw-w64-libmariadbclient')
provides=("mingw-w64-libmariadbclient=$pkgver")
depends=('mingw-w64-crt' 'mingw-w64-openssl' 'mingw-w64-zlib')
makedepends=('mingw-w64-cmake')
options=('!strip' '!buildflags' 'staticlibs')
source=("https://downloads.mariadb.org/interstitial/connector-c-${pkgver}/mariadb-connector-c-${pkgver}-src.tar.gz"
        '0001-Fix-libnames-for-mingw-w64.patch'
        '0002-Fix-_SIZE_T_DEFINED-under-mingw-w64.patch'
        '0003-Use-fopen-rather-than-fopen_s-for-XP-compatibility.patch')
sha1sums=('6fbf541a4465cd729c7f790a3d9cd337e8dd2666'
          '12a2d0b8d521dc097cecc3ea32efcaee0e7f9781'
          'f07a59cdd02ad89e60edcb18a1cdc3ccda93fc2b'
          '3aa503bb7ad9b84c21cdef94f3a55d96a7fa8811')

_architectures='i686-w64-mingw32 x86_64-w64-mingw32'

prepare() {
  cd "$srcdir/mariadb-connector-c-$pkgver-src/"
  for patch in "$srcdir/"*.patch; do
    patch -p1 -i "$patch"
  done
}

build() {
  unset LDFLAGS
  cd "$srcdir/mariadb-connector-c-$pkgver-src/"
  for _arch in ${_architectures}; do
    mkdir -p build-${_arch} && pushd build-${_arch}
    ${_arch}-cmake \
      -DCMAKE_BUILD_TYPE=RELEASE \
      -DWITH_EXTERNAL_ZLIB=ON \
      -DWITH_SQLITE=OFF \
      -DWITH_OPENSSL=ON \
      -DLIB_EAY=/usr/${_arch}/lib/libcrypto.dll.a \
      -DSSL_EAY=/usr/${_arch}/lib/libssl.dll.a \
      -DWITH_MYSQLCOMPAT=ON \
      ..
    make
    popd
  done
}

package() {
  for _arch in ${_architectures}; do
    cd "${srcdir}/mariadb-connector-c-$pkgver-src/build-${_arch}"
    make DESTDIR="${pkgdir}" install
    ln -s mariadb "$pkgdir"/usr/${_arch}/include/mysql
    # Creation of symlinks in CMake project file doesn't work for some reason.
    # Probably a couple more symlinks that should be created.
    ln -s libmariadb.dll.a "$pkgdir"/usr/${_arch}/lib/libmysql.dll.a
    ln -s libmariadbclient.a "$pkgdir"/usr/${_arch}/lib/libmysqlclient.a
    ln -s libmariadb.dll "$pkgdir"/usr/${_arch}/bin/libmysql.dll
    ln -s libmariadb.dll "$pkgdir"/usr/${_arch}/bin/libmysqlclient.dll
    ln -s libmariadb.dll "$pkgdir"/usr/${_arch}/bin/libmysqlclient_r.dll
    ${_arch}-strip --strip-unneeded "$pkgdir"/usr/${_arch}/bin/*.dll
    ${_arch}-strip --strip-unneeded "$pkgdir"/usr/${_arch}/lib/plugin/*.dll
    ${_arch}-strip -g "$pkgdir"/usr/${_arch}/lib/*.a
    ${_arch}-strip -g "$pkgdir"/usr/${_arch}/lib/plugin/*.a
  done
}