aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-sqlite/APKBUILD
blob: 7d41e4db789570f9f4924540c2b104ec8ff24352 (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
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=lua-sqlite
_rockname=lsqlite3
pkgver=0.9.5
_uuid="fsl_9y"
[ "$pkgver" != "0.9.5" ] && die "Please update uuid!"
_luaversions="5.1 5.2 5.3"
pkgrel=2
pkgdesc="Sqlite3 Binding for Lua"
url="http://lua.sqlite.org/index.cgi/home"
arch="all"
license="MIT"
depends=""
makedepends="sqlite-dev"
install=""
subpackages=""
# the uuid determines the archive version and the filename the target directory
source="$pkgname-$pkgver.zip::http://lua.sqlite.org/index.cgi/zip/$pkgname-$pkgver.zip?uuid=$_uuid"

builddir="$srcdir"/$pkgname-$pkgver

for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_package"
done

prepare() {
	default_prepare || return 1

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

build() {
	local lver
	for lver in $_luaversions; do
		cd "$builddir-$lver"
		msg "Building for Lua $lver..."
		${CC:-gcc} ${CFLAGS} $(pkg-config --cflags sqlite3) \
			$(pkg-config --cflags lua$lver) -shared -fPIC \
			-DLSQLITE_VERSION=\"$pkgver\" -o lsqlite3.so lsqlite3.c \
			$(pkg-config --libs sqlite3) || return 1
	done
}

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

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_pkgname/$pkgver-1"

	cd "$builddir-$lver"
	install -Dm755 lsqlite3.so \
		"$subpkgdir"/usr/lib/lua/$lver/lsqlite3.so || return 1

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

sha512sums="3d66a0e7250bada97f753c8204f6ca27142c2c8d3b4a3fba433200f5a90726f4b8ba7317886e11b819ac10bc3c002470e3039509870d0ebd9ff3835d3cff53e5  lua-sqlite-0.9.5.zip"