Skip to content

Commit

Permalink
build: fix Lua build
Browse files Browse the repository at this point in the history
Each of Lua's major versions are incompatible with each other. Ubuntu,
at least, does not provide a single liblua.so or /usr/include/lua; all
SOs and headers are versioned, e.g. liblua5.3.so and
/usr/include/lua5.3. There's already an m4 macro in the GNU collection
to handle this situation, so let's use that.

This allows building with Lua enabled to work on platforms other than
Fedora.

* Move lib/lua.[ch] -> lib/frrlua.[ch] to prevent path conflicts
* Fix configure.ac search for proper CPP and linker flags
* Add Lua include path to AM_CPPFLAGS
* Update vtysh/extract.pl.in

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
  • Loading branch information
qlyoung committed May 10, 2019
1 parent 11056dd commit 5dbb0a7
Show file tree
Hide file tree
Showing 8 changed files with 682 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ AM_CFLAGS = \
# end
AM_CPPFLAGS = \
-I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/lib \
-I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/lib
-I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/lib \
$(LUA_INCLUDE) \
# end
AM_LDFLAGS = \
-export-dynamic \
$(AC_LDFLAGS) \
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "plist.h"
#include "memory.h"
#include "log.h"
#include "lua.h"
#include "frrlua.h"
#ifdef HAVE_LIBPCREPOSIX
#include <pcreposix.h>
#else
Expand Down
9 changes: 6 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,12 @@ elif test "x${enable_dev_build}" = "xyes"; then
AC_C_FLAG([-O0])
fi
if test "x${enable_lua}" = "xyes"; then
AC_CHECK_LIB([lua], [lua_newstate],
[LIBS="$LIBS -llua"])
AC_DEFINE([HAVE_LUA], [1], [Lua enabled for development])
AX_PROG_LUA([5.3])
AX_LUA_HEADERS
AX_LUA_LIBS([
AC_DEFINE([HAVE_LUA], [1], [Have support for Lua interpreter])
LIBS="$LIBS $LUA_LIB"
])
fi
else
if test "x${enable_lua}" = "xyes"; then
Expand Down
2 changes: 1 addition & 1 deletion lib/lua.c → lib/frrlua.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#if defined(HAVE_LUA)
#include "prefix.h"
#include "lua.h"
#include "frrlua.h"
#include "log.h"

static int lua_zlog_debug(lua_State *L)
Expand Down
6 changes: 3 additions & 3 deletions lib/lua.h → lib/frrlua.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

#if defined(HAVE_LUA)

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions lib/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
lib_LTLIBRARIES += lib/libfrr.la
lib_libfrr_la_LDFLAGS = -version-info 0:0:0 -Xlinker -e_libfrr_version
lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS)
lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB)

lib_libfrr_la_SOURCES = \
lib/agg_table.c \
Expand All @@ -21,6 +21,7 @@ lib_libfrr_la_SOURCES = \
lib/distribute.c \
lib/ferr.c \
lib/filter.c \
lib/frrlua.c \
lib/frr_pthread.c \
lib/frrstr.c \
lib/getopt.c \
Expand Down Expand Up @@ -93,7 +94,6 @@ lib_libfrr_la_SOURCES = \
lib/yang_wrappers.c \
lib/zclient.c \
lib/logicalrouter.c \
lib/lua.c \
# end

nodist_lib_libfrr_la_SOURCES = \
Expand Down Expand Up @@ -151,6 +151,7 @@ pkginclude_HEADERS += \
lib/ferr.h \
lib/filter.h \
lib/freebsd-queue.h \
lib/frrlua.h \
lib/frr_pthread.h \
lib/frratomic.h \
lib/frrstr.h \
Expand Down Expand Up @@ -228,7 +229,6 @@ pkginclude_HEADERS += \
lib/zclient.h \
lib/zebra.h \
lib/logicalrouter.h \
lib/lua.h \
lib/pbr.h \
# end

Expand Down
Loading

0 comments on commit 5dbb0a7

Please sign in to comment.