summaryrefslogtreecommitdiffstats
path: root/main/haserl/0003-use-pkg-config-to-find-Lua-CFLAGS-and-LIBS.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/haserl/0003-use-pkg-config-to-find-Lua-CFLAGS-and-LIBS.patch')
-rw-r--r--main/haserl/0003-use-pkg-config-to-find-Lua-CFLAGS-and-LIBS.patch120
1 files changed, 120 insertions, 0 deletions
diff --git a/main/haserl/0003-use-pkg-config-to-find-Lua-CFLAGS-and-LIBS.patch b/main/haserl/0003-use-pkg-config-to-find-Lua-CFLAGS-and-LIBS.patch
new file mode 100644
index 000000000..0d4014706
--- /dev/null
+++ b/main/haserl/0003-use-pkg-config-to-find-Lua-CFLAGS-and-LIBS.patch
@@ -0,0 +1,120 @@
+From 8a71fdd71b5496028c92c1aa1bd6a949c13579ca Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Mon, 1 Jul 2013 13:48:45 +0200
+Subject: [PATCH 3/4] use pkg-config to find Lua CFLAGS and LIBS
+
+By default, use pkg-config lua --cflags/--libs but let user override
+the pkg-config name. For example, to build with lua5.2.pc use
+ --with-lua=lua5.2
+
+This fixes situations when both lua5.1 and lua5.2 is available but not
+'lua'.
+---
+ configure.ac | 44 +++++++++-----------------------------------
+ src/Makefile.am | 6 ++++--
+ src/h_lua.h | 1 +
+ 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);
+--
+1.8.3.2
+