aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-sql/APKBUILD
blob: 0fe0f2ddf336e504eeb17ab7e378f0aa2a6f8d3f (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_luaversions="5.1 5.2 5.3"
_drivers="mysql postgres sqlite3 odbc"

pkgname=lua-sql
_pkgname=luasql
pkgver=2.3.4
pkgrel=0
pkgdesc="Lua SQL drivers"
url="http://keplerproject.github.io/luasql/doc/us/"
arch="all"
license="MIT"
makedepends="mariadb-dev postgresql-dev sqlite-dev unixodbc-dev"
subpackages=""
for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	for _d in $_drivers; do
		subpackages="$subpackages lua$_v-sql-$_d:_subpackage"
	done
done
for _d in $_drivers; do
	subpackages="$subpackages lua-sql-$_d:_meta_subpackage"
done

source="$_pkgname-$pkgver.tar.gz::https://github.com/keplerproject/$_pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare || return 1

	cd "$builddir"

	# The config has DRIVER_INCS but it seems like its not respected
	# so we just fix the .c file.
	sed -i 's:^\#include "mysql.h":\#include <mysql/mysql.h>:' \
		src/ls_mysql.c || return 1

	local lver; for lver in $_luaversions; do
		cp -r "$builddir" "$builddir-$lver" || return 1
	done
}

build() {
	local cflags lver

	for lver in $_luaversions; do
		cflags="$CFLAGS $(pkg-config lua$lver --cflags) -fPIC"

		msg "Building for Lua $lver..."
		cd "$builddir-$lver"

		make CFLAGS="$cflags" DRIVER_LIBS="-lmysqlclient" \
			mysql || return 1

		make CFLAGS="$cflags" DRIVER_LIBS="$(pkg-config --libs libpq)" \
			postgres || return 1

		make CFLAGS="$cflags" DRIVER_LIBS="$(pkg-config --libs sqlite3)" \
			sqlite3 || return 1

		make CFLAGS="$cflags -DUNIXODBC" DRIVER_LIBS="-lodbc" \
			odbc || return 1
	done
}

package() {
	mkdir -p "$pkgdir"
}

_meta_subpackage() {
	local driver="${subpkgname##*-}"
	pkgdesc="$pkgdesc for $driver"

	mkdir -p "$subpkgdir"
}

_subpackage() {
	local lver="${subpkgname:3:3}"
	local driver="${subpkgname##*-}"
	pkgdesc="Lua $lver SQL driver for $driver"
	depends="lua$lver"
	install_if="lua-sql-$driver=$pkgver-r$pkgrel lua$lver"

	cd "$builddir-$lver"
	local install_cmod="$(pkg-config --variable INSTALL_CMOD lua$lver)"
	install -D src/$driver.so \
		"$subpkgdir"/$install_cmod/luasql/$driver.so
}

md5sums="e1219155ac996d45c984add3bba99815  luasql-2.3.4.tar.gz"
sha256sums="690287d1aabceb636ad9be440c6d1717d755d975ab2f6300e15dcf4995cba1bd  luasql-2.3.4.tar.gz"
sha512sums="d43328a4361479848aa34c3fc6b2a9c6c1c28f3ccfa63735700abbdd9137dd80b3ec9bd4e106b226225ebe9760d596714fda34bd0f14681e47d6093f8d1d94b6  luasql-2.3.4.tar.gz"