aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-rex/APKBUILD
blob: 81015c922d367587c59d5e19445a159e24611efd (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
88
89
90
91
92
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_luaversions="5.1 5.2 5.3"
pkgname=lua-rex
pkgver=2.9.0
pkgrel=0
pkgdesc="Lua bindings to regular expression library pcre and posix"
url="http://lrexlib.luaforge.net/"
arch="all"
license="MIT"
depends="lua-rex-pcre lua-rex-posix"
makedepends="pcre-dev"
install=
subpackages="$pkgname-pcre:_pcre $pkgname-posix:_posix"

for _i in $_luaversions; do
	makedepends="$makedepends lua$_i-dev lua$_i"
	subpackages="$subpackages lua$_i-rex-pcre:_pcre_${_i/./_}
		lua$_i-rex-posix:_posix_${_i/./_}"

	eval "_pcre_${_i/./_}() { _split $_i pcre; }"
	eval "_posix_${_i/./_}() { _split $_i posix; }"
done

source="$pkgname-$pkgver.tar.gz::https://github.com/rrthomas/lrexlib/archive/rel-${pkgver//./-}.tar.gz"

_builddir="$srcdir"/lrexlib-rel-${pkgver//./-}

prepare() {
	local _ver
	for _ver in $_luaversions; do
		cp -r "$_builddir" "$srcdir"/build-$_ver
	done
}

_build_variant() {
	local _ver=$1
	local _obj=$2
	local _flags="$3"

	${CC:-gcc} \
		${CFLAGS} \
		$(pkg-config --cflags lua$_ver) \
		-shared \
		-fPIC \
		-o $_obj.${pkgver%.*} \
		$_flags \
		-DVERSION=\"$pkgver\" \
		-DLUA_COMPAT_5_2 || return 1
	ln -s $_obj.${pkgver%.*} $_obj || return 1
}

build() {
	local _ver
	for _ver in $_luaversions; do
		msg "build for Lua $_ver"
		cd "$srcdir"/build-$_ver
		_build_variant $_ver rex_pcre.so \
			'src/common.c src/pcre/lpcre.c src/pcre/lpcre_f.c
			-lpcre' || return 1
		_build_variant $_ver rex_posix.so \
			'src/common.c src/posix/lposix.c' || return 1
	done
}

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

_pcre() {
	pkgdesc="Lua bindings to pcre regular expressions library"
	depends=
	mkdir -p "$subpkgdir"
}

_posix() {
	pkgdesc="Lua bindings to posix regular expressions library"
	depends=
	mkdir -p "$subpkgdir"
}

_split() {
	local _ver=$1
	local _lib=$2
	pkgdesc="Lua $_ver bindings to $_lib regular expressions library"
	install_if="lua$_ver lua-rex-$_lib=$pkgver-r$pkgrel"
	depends=
	install -d "$subpkgdir"/usr/lib/lua/$_ver || return 1
	cp -a "$srcdir"/build-$_ver/rex_$_lib.so* \
		"$subpkgdir"/usr/lib/lua/$_ver || return 1
}

sha512sums="f37e6170595f1ce90f0ccdddbb0fc3c3d93378bdd48467d38705a3a4aec2eff640756fe96105cbccbdb9448bdf7476a88ac46cbf5214877dfe289ef19176f568  lua-rex-2.9.0.tar.gz"