aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-sql/APKBUILD
blob: 065425c474a6e33dad1f3b9dab597441ffca8b1c (plain) (blame)
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
# Contributor: Ɓukasz Jendrysik <scadu@yandex.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_luaversions="5.1 5.2 5.3 5.4"
_drivers="mysql postgres sqlite3 odbc"

pkgname=lua-sql
_pkgname=luasql
pkgver=2.6.0
pkgrel=0
pkgdesc="Lua SQL drivers"
url="https://keplerproject.github.io/luasql/"
arch="all"
license="MIT"
makedepends="mariadb-connector-c-dev postgresql-dev sqlite-dev unixodbc-dev"
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/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare

	local lver; for lver in $_luaversions; do
		cp -r "$builddir" "$builddir-$lver"
	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

		make CFLAGS="$CFLAGS" DRIVER_LIBS="$(pkg-config --libs libpq)" \
			postgres

		make CFLAGS="$CFLAGS" DRIVER_LIBS="$(pkg-config --libs sqlite3)" \
			sqlite3

		make CFLAGS="$CFLAGS -DUNIXODBC" DRIVER_LIBS="-lodbc" \
			odbc
	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"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_pkgname/$pkgver-1"

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

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="051438d4f5a9059c2ecf52143a06279469c220117b8b99363ea4fda434f08780794f0c4d54185ea891845238b3f5a307ba06ee7a1e7f4583a3b393c63eed66e9  luasql-2.6.0.tar.gz"