diff options
Diffstat (limited to 'repo/system/lua-lpeg')
-rw-r--r-- | repo/system/lua-lpeg/build-static-lib.patch | 29 | ||||
-rw-r--r-- | repo/system/lua-lpeg/lua-lpeg.xibuild | 50 | ||||
-rw-r--r-- | repo/system/lua-lpeg/test-fix-setlocale.patch | 20 |
3 files changed, 99 insertions, 0 deletions
diff --git a/repo/system/lua-lpeg/build-static-lib.patch b/repo/system/lua-lpeg/build-static-lib.patch new file mode 100644 index 0000000..d8a8f8c --- /dev/null +++ b/repo/system/lua-lpeg/build-static-lib.patch @@ -0,0 +1,29 @@ +--- a/makefile ++++ b/makefile +@@ -24,12 +24,15 @@ + + CFLAGS = $(CWARNS) $(COPT) -std=c99 -I$(LUADIR) -fPIC + CC = gcc ++AR = ar ++RANLIB = ranlib + + FILES = lpvm.o lpcap.o lptree.o lpcode.o lpprint.o + + # For Linux + linux: + $(MAKE) lpeg.so "DLLFLAGS = -shared -fPIC" ++ $(MAKE) lpeg.a + + # For Mac OS + macosx: +@@ -37,6 +40,10 @@ + + lpeg.so: $(FILES) + env $(CC) $(DLLFLAGS) $(FILES) -o lpeg.so ++ ++lpeg.a: $(FILES) ++ env $(AR) rc lpeg.a $(FILES) ++ env $(RANLIB) lpeg.a + + $(FILES): makefile + diff --git a/repo/system/lua-lpeg/lua-lpeg.xibuild b/repo/system/lua-lpeg/lua-lpeg.xibuild new file mode 100644 index 0000000..f2b3b4d --- /dev/null +++ b/repo/system/lua-lpeg/lua-lpeg.xibuild @@ -0,0 +1,50 @@ +#!/bin/sh + +MAKEDEPS="make tar patch lua lua5-1" +DEPS="musl" + +PKG_VER=1.0.2 +SOURCE=http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-$PKG_VER.tar.gz +DESC="Pattern-matching library for Lua" +ADDITIONAL=" + build-static-lib.patch + test-fix-setlocale.patch +" + +luaversions="5.1 5.4" + +prepare () { + apply_patches + +# lver=$(lua -v | cut -d" " -f2 | cut -d. -f-2) + sed -i -e 's/^CFLAGS =/CFLAGS +=/' \ + -e 's/^COPT =/# COPT =/' \ + makefile + + for lver in $luaversions; do + tar xf lpeg-$PKG_VER.tar.gz + mv lpeg-$PKG_VER build-$lver + done +} + +build () { + for lver in $luaversions; do + echo building for $lver + make -C build-$lver LUADIR=/usr/include/lua$lver + done +} + +package () { + for lver in $luaversions; do + cd build-$lver + install -Dm755 lpeg.so \ + $PKG_DEST/usr/lib/lua/$lver/lpeg.so + install -Dm644 re.lua \ + $PKG_DEST/usr/share/lua/$lver/re.lua + + local rockdir="$PKG_DEST/usr/lib/luarocks/rocks-$lver/lua-lpeg/$PKG_VER-1" + mkdir -p "$rockdir" + echo 'rock_manifest = {}' > "$rockdir"/rock_manifest + cd .. + done +} diff --git a/repo/system/lua-lpeg/test-fix-setlocale.patch b/repo/system/lua-lpeg/test-fix-setlocale.patch new file mode 100644 index 0000000..028c18c --- /dev/null +++ b/repo/system/lua-lpeg/test-fix-setlocale.patch @@ -0,0 +1,20 @@ +os.setlocale just calls setlocale() from libc and musl's implementation +behaves a bit differently in comparison with BSD libc or glibc. + +When particular locales for all categories are the same, e.g. "C", +`setlocale(LC_ALL, "")` returns just "C" on BSD libc (tested on macOS) +and glibc, but musl returns "C;C;C;C;C;C". When some locale is different, +e.g. LC_CTYPE, then on macOS you get "C/en_US.UTF-8/C/C/C/C", on glibc +"LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;...", on musl "en_US.UTF-8;C;C;C;C;C". + +--- a/test.lua ++++ b/test.lua +@@ -1428,7 +1428,7 @@ + + + -- testing pre-defined names +-assert(os.setlocale("C") == "C") ++assert(os.setlocale("C"):sub(1, 1) == "C") + + function eqlpeggsub (p1, p2) + local s1 = cs2str(re.compile(p1)) |