summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac44
-rw-r--r--src/Makefile.am6
-rw-r--r--src/h_lua.h1
3 files changed, 14 insertions, 37 deletions
diff --git a/configure.ac b/configure.ac
index 74560c5..a854642 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,13 +40,6 @@ AC_DEFINE([_GNU_SOURCE], [], [Enable GNU Extensions])
dnl **************************************************************
-AC_ARG_WITH(lua-headers,
- [ --with-lua-headers=DIR lua include files location],
- [LUA_HDR_DIR="$withval"]
- [CFLAGS="$CFLAGS -I$withval"]
-)
-
-
dnl Checks for lua
luashell=false
@@ -54,36 +47,17 @@ luacshell=false
ac_report_have_lua=disabled
ac_report_bash_extensions=disabled
+AC_ARG_WITH([lua],
+ AS_HELP_STRING([--with-lua], [Specify lua pkg-config name (default is 'lua')]))
-AC_ARG_WITH(lua,
- AS_HELP_STRING([--with-lua[[=DIR]]],[use lua in DIR]),
-[ case "$withval" in
- no) ac_report_have_lua=disabled
- ;;
- *) AC_SEARCH_LIBS(dlopen, dl)
- # ubuntu has lua5.1 rather than just lua
- if pkg-config --exists lua5.1; then
- LUALIB=lua5.1
- else
- LUALIB=lua
- fi
- if test -z "$LUA_HDR_DIR"; then
- CFLAGS="$CFLAGS `pkg-config $LUALIB --cflags`"
- fi
- LIBS="$LIBS -lm"
- LDFLAGS="$LDFLAGS -Wl,-E -L$withval"
- AC_DEFINE(USE_LUA, , [Enable Lua])
-
- AC_CHECK_LIB($LUALIB, luaL_newstate, , [
- AC_MSG_ERROR([The Lua runtime library cannot be found!])
- ], $LIBS)
- luashell=true
- luacshell=true
- ac_report_have_lua=enabled
- ;;
- esac ], [
- ac_report_have_lua=disabled
+AS_IF([test "x$with_lua" = "xyes"], [with_lua=lua])
+AS_IF([test "x$with_lua" != "xno"], [
+ luashell=true
+ luacshell=true
+ ac_report_have_lua=enabled
+ PKG_CHECK_MODULES([LUA], [$with_lua])
])
+
AM_CONDITIONAL(USE_LUA, test x$ac_report_have_lua = xenabled)
# If Lua is enabled, the user can choose between two different shells
diff --git a/src/Makefile.am b/src/Makefile.am
index 245d92e..c3e220a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,8 +27,8 @@ if USE_LUA
# lua2c_LIBS ?= -llua -ldl -lm
lua2c_LDFLAGS ?= -Wl,-E
lua2c: lua2c.c
- $(CC_FOR_BUILD) $(CFLAGS) $(LDFLAGS) $(lua2c_LDFLAGS) \
- -o $@ $^ $(LIBS)
+ $(CC_FOR_BUILD) $(CFLAGS) $(LUA_CFLAGS) $(LDFLAGS) $(lua2c_LDFLAGS) \
+ -o $@ $^ $(LIBS) $(LUA_LIBS)
haserl_lualib.inc : haserl_lualib.lua lua2c
if ! ./lua2c haserl_lualib haserl_lualib.lua >$@; then \
@@ -45,6 +45,8 @@ bin_PROGRAMS = haserl
haserl_SOURCES = common.c common.h sliding_buffer.c sliding_buffer.h \
h_error.c h_error.h h_script.c h_script.h rfc2388.c rfc2388.h \
$(BASHSOURCE) $(LUASOURCE) haserl.c haserl.h
+haserl_CFLAGS = $(LUA_CFLAGS)
+haserl_LDADD = $(LUA_LIBS)
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
diff --git a/src/h_lua.h b/src/h_lua.h
index f85efdc..e8984e5 100644
--- a/src/h_lua.h
+++ b/src/h_lua.h
@@ -21,6 +21,7 @@
#ifndef H_LUA_H
#define H_LUA_H 1
+#include <lua.h>
void lua_exec(buffer_t *buf, char *str);
void lua_echo(buffer_t *buf, char *str, size_t len);