aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile25
-rw-r--r--Makefile8
-rwxr-xr-xconfigure52
-rw-r--r--vis-lua.c2
4 files changed, 68 insertions, 19 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 48bf182..a225931 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -19,10 +19,8 @@ LIBTERMKEY_SHA1 = 0a78ba7aaa2f3b53f2273268366fef349c9be4ab
#LIBLUA = lua-5.3.1
#LIBLUA_SHA1 = 1676c6a041d90b6982db8cef1e5fb26000ab6dee
-#LIBLUA_LPEG_SHA1 = aaa6df78cf5e2e31d690d96c6cd9f960f80f4347
LIBLUA = lua-5.2.4
LIBLUA_SHA1 = ef15259421197e3d85b7d6e4871b8c26fd82c1cf
-LIBLUA_LPEG_SHA1 = 459d7cd7dd1e3096096d55ebd4475bc8f4da6927
#LIBLUA = lua-5.1.5
#LIBLUA_SHA1 = b3882111ad02ecc6b972f8c1241647905cb2e3fc
@@ -113,17 +111,7 @@ dependency/build/liblua-extract: dependency/sources/$(LIBLUA).tar.gz | dependenc
tar xzf $< -C $(dir $@)
touch $@
-dependency/sources/lua-%-lpeg.patch1: | dependency/sources
- wget -c -O $@.part http://www.brain-dump.org/projects/vis/$(LIBLUA)-lpeg.patch1
- mv $@.part $@
- [ -z $(LIBLUA_LPEG_SHA1) ] || (echo '$(LIBLUA_LPEG_SHA1) $@' | sha1sum -c)
-
-dependency/build/liblua-patch: dependency/build/liblua-extract dependency/sources/$(LIBLUA)-lpeg.patch1 dependency/build/liblpeg-extract
- cd $(dir $<)/$(LIBLUA) && patch -p1 < ../../sources/$(LIBLUA)-lpeg.patch1
- cp $(dir $<)/$(LIBLPEG)/*.[ch] $(dir $<)/$(LIBLUA)/src
- touch $@
-
-dependency/build/liblua-build: dependency/build/liblua-patch
+dependency/build/liblua-build: dependency/build/liblua-extract
$(MAKE) -C $(dir $<)/$(LIBLUA)/src all CC=$(CC) MYCFLAGS="-DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -fPIC" MYLIBS="-Wl,-E -ldl -lm"
#$(MAKE) -C $(dir $<)/$(LIBLUA) posix CC=$(CC)
touch $@
@@ -141,7 +129,16 @@ dependency/build/liblpeg-extract: dependency/sources/$(LIBLPEG).tar.gz | depende
tar xzf $< -C $(dir $@)
touch $@
-dependencies-common: dependency/build/libtermkey-install dependency/build/liblua-install
+dependency/build/liblpeg-build: dependency/build/liblpeg-extract dependency/build/liblua-extract
+ cd $(dir $<)/$(LIBLPEG) && $(MAKE) LUADIR="../$(LIBLUA)/src"
+ cd $(dir $<)/$(LIBLPEG) && ar rcu liblpeg.a lpvm.o lpcap.o lptree.o lpcode.o lpprint.o && ranlib liblpeg.a
+ touch $@
+
+dependency/build/liblpeg-install: dependency/build/liblpeg-build
+ cd $(dir $<)/$(LIBLPEG) && cp liblpeg.a $(DEPS_LIB)
+ touch $@
+
+dependencies-common: dependency/build/libtermkey-install dependency/build/liblua-install dependency/build/liblpeg-install
dependency/build/local: dependencies-common
touch $@
diff --git a/Makefile b/Makefile
index 2311f3d..dd6fd85 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ MANPREFIX ?= ${PREFIX}/man
VERSION = $(shell git describe --always 2>/dev/null || echo "0.2")
CONFIG_LUA ?= 1
-CONFIG_BUILTIN_LPEG ?= 0
+CONFIG_LPEG ?= 0
CONFIG_ACL ?= 0
CONFIG_SELINUX ?= 0
@@ -25,17 +25,17 @@ CFLAGS_STD += -DVERSION=\"${VERSION}\"
LDFLAGS_STD ?= -lc
CFLAGS_VIS = $(CFLAGS_AUTO) $(CFLAGS_TERMKEY) $(CFLAGS_CURSES) $(CFLAGS_ACL) \
- $(CFLAGS_SELINUX) $(CFLAGS_LUA) $(CFLAGS_STD)
+ $(CFLAGS_SELINUX) $(CFLAGS_LUA) $(CFLAGS_LPEG) $(CFLAGS_STD)
CFLAGS_VIS += -DVIS_PATH=\"${SHAREPREFIX}/vis\"
CFLAGS_VIS += -DCONFIG_LUA=${CONFIG_LUA}
-CFLAGS_VIS += -DCONFIG_BUILTIN_LPEG=${CONFIG_BUILTIN_LPEG}
+CFLAGS_VIS += -DCONFIG_LPEG=${CONFIG_LPEG}
CFLAGS_VIS += -DCONFIG_SELINUX=${CONFIG_SELINUX}
CFLAGS_VIS += -DCONFIG_ACL=${CONFIG_ACL}
CFLAGS_VIS += ${CFLAGS_DEBUG}
LDFLAGS_VIS = $(LDFLAGS_AUTO) $(LDFLAGS_TERMKEY) $(LDFLAGS_CURSES) $(LDFLAGS_ACL) \
- $(LDFLAGS_SELINUX) $(LDFLAGS_LUA) $(LDFLAGS_STD)
+ $(LDFLAGS_SELINUX) $(LDFLAGS_LUA) $(LDFLAGS_LPEG) $(LDFLAGS_STD)
CFLAGS_DEBUG_ENABLE = -U_FORTIFY_SOURCE -UNDEBUG -O0 -g -ggdb -Wall -Wextra -pedantic \
-Wno-missing-field-initializers -Wno-unused-parameter
diff --git a/configure b/configure
index b100b48..73f2eba 100755
--- a/configure
+++ b/configure
@@ -26,6 +26,7 @@ Fine tuning of the installation directories:
Optional features:
--enable-lua build with Lua support [auto]
+ --enable-lpeg build with built-in LPeg support [auto]
--enable-selinux build with SELinux support [auto]
--enable-acl build with POSIX ACL support [auto]
@@ -115,6 +116,7 @@ SHAREDIR='$(PREFIX)/share'
MANDIR='$(PREFIX)/share/man'
lua=auto
+lpeg=auto
selinux=auto
acl=auto
@@ -131,6 +133,8 @@ case "$arg" in
--static) static=yes ;;
--enable-lua|--enable-lua=yes) lua=yes ;;
--disable-lua|--enable-lua=no) lua=no ;;
+--enable-lpeg|--enable-lpeg=yes) lpeg=yes ;;
+--disable-lpeg|--enable-lpeg=no) lpeg=no ;;
--enable-selinux|--enable-selinux=yes) selinux=yes ;;
--disable-selinux|--enable-selinux=no) selinux=no ;;
--enable-acl|--enable-acl=yes) acl=yes ;;
@@ -352,6 +356,10 @@ fi
CONFIG_LUA=0
+# enabling builtin lpeg requires lua support
+test "$lpeg" = "yes" -a "$lua" = "no" && fail "$0: need lua support for built-in lpeg"
+test "$lpeg" = "yes" && lua=yes
+
if test "$lua" != "no" ; then
printf "checking for liblua >= 5.2 ...\n"
@@ -408,6 +416,47 @@ EOF
fi
fi
+CONFIG_LPEG=0
+
+if test "$lpeg" != "no" ; then
+
+ printf "checking for liblpeg ... "
+
+cat > "$tmpc" <<EOF
+#include <lua.h>
+#include <lauxlib.h>
+
+int main(int argc, char *argv[]) {
+ lua_State *L = luaL_newstate();
+ luaL_openlibs(L);
+ extern int luaopen_lpeg(lua_State *L);
+ lua_getglobal(L, "package");
+ lua_getfield(L, -1, "preload");
+ lua_pushcfunction(L, luaopen_lpeg);
+ lua_setfield(L, -2, "lpeg");
+ lua_pop(L, 2);
+ lua_close(L);
+ return 0;
+}
+EOF
+
+ CFLAGS_LPEG=""
+ LDFLAGS_LPEG="-llpeg"
+
+ if $CC $CFLAGS $CFLAGS_LUA $CFLAGS_LPEG "$tmpc" \
+ $LDFLAGS $LDFLAGS_LUA $LDFLAGS_LPEG -o "$tmpo" >/dev/null 2>&1 ; then
+ CONFIG_LPEG=1
+ printf "yes\n"
+ break
+ else
+ printf "no\n"
+ CFLAGS_LPEG=""
+ LDFLAGS_LPEG=""
+ fi
+
+ test "$lpeg" = "yes" -a $CONFIG_LPEG -ne 1 && fail "$0: cannot find liblpeg"
+fi
+
CONFIG_ACL=0
if test "$OS" = "Linux" -a "$acl" != "no"; then
@@ -492,6 +541,9 @@ LDFLAGS_TERMKEY = $LDFLAGS_TERMKEY
CONFIG_LUA = $CONFIG_LUA
CFLAGS_LUA = $CFLAGS_LUA
LDFLAGS_LUA = $LDFLAGS_LUA
+CONFIG_LPEG = $CONFIG_LPEG
+CFLAGS_LPEG = $CFLAGS_LPEG
+LDFLAGS_LPEG = $LDFLAGS_LPEG
CONFIG_ACL = $CONFIG_ACL
CFLAGS_ACL = $CFLAGS_ACL
LDFLAGS_ACL = $LDFLAGS_ACL
diff --git a/vis-lua.c b/vis-lua.c
index 95cfe6e..301d719 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1889,7 +1889,7 @@ void vis_lua_init(Vis *vis) {
vis->lua = L;
luaL_openlibs(L);
-#if CONFIG_BUILTIN_LPEG
+#if CONFIG_LPEG
extern int luaopen_lpeg(lua_State *L);
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");