Skip to content

Commit

Permalink
build: Add support for linking against a system lua5.1
Browse files Browse the repository at this point in the history
Add a new USE_SYSTEM_LUA make variable to select whether to link
against the system liblua5.1, liblua5.1-bitop and liblua5.1-cjson.

FIXME: Missing liblua5.1-struct and liblua5.1-cmsgpack in Debian.
  https://luarocks.org/modules/luarocks/struct
  https://luarocks.org/modules/antirez/lua-cmsgpack
  • Loading branch information
guillemj committed Mar 23, 2024
1 parent 657229a commit 5bbff3c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 76 deletions.
2 changes: 2 additions & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ ifneq ($(USE_SYSTEM_HIREDIS),yes)
-(cd hiredis && $(MAKE) clean) > /dev/null || true
endif
-(cd linenoise && $(MAKE) clean) > /dev/null || true
ifneq ($(USE_SYSTEM_LUA),yes)
-(cd lua && $(MAKE) clean) > /dev/null || true
endif
ifneq ($(USE_SYSTEM_JEMALLOC),yes)
-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
endif
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion pkg/deb/debian_dh9/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
#debian-packaging/0003-dpkg-buildflags.patch
#debian-packaging/0007-Set-Debian-configuration-defaults.patch
#0010-Use-get_current_dir_name-over-PATHMAX-etc.patch
#0011-Add-support-for-a-USE_SYSTEM_LUA-flag.patch
#test
22 changes: 18 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh')
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
OPTIMIZATION?=-O2 -flto
DEPENDENCY_TARGETS=linenoise lua hdr_histogram
DEPENDENCY_TARGETS=linenoise hdr_histogram
NODEPS:=clean distclean

# Default settings
Expand Down Expand Up @@ -274,8 +274,8 @@ ifdef OPENSSL_PREFIX
endif

# Include paths to dependencies
FINAL_CFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram
FINAL_CXXFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram
FINAL_CFLAGS+= -I../deps/linenoise -I../deps/hdr_histogram
FINAL_CXXFLAGS+= -I../deps/linenoise -I../deps/hdr_histogram

ifeq ($(USE_SYSTEM_CONCURRENTQUEUE),yes)
FINAL_CXXFLAGS+= -I/usr/include/concurrentqueue/moodycamel
Expand Down Expand Up @@ -379,6 +379,19 @@ endif
endif
endif

ifeq ($(USE_SYSTEM_LUA),yes)
LUA_PC = lua5.1 lua5.1-bitop lua5.1-cjson
LUA_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(LUA_PC))
FINAL_CFLAGS+= $(LUA_CFLAGS)
FINAL_CXXFLAGS+= $(LUA_CFLAGS)
SERVER_LIBS+= $(shell $(PKG_CONFIG) --libs $(LUA_PC))
else
DEPENDENCY_TARGETS+= lua
FINAL_CFLAGS+= -I../deps/lua/src
FINAL_CXXFLAGS+= -I../deps/lua/src
SERVER_LIBS+= ../deps/lua/src/liblua.a
endif

ifndef V
define MAKE_INSTALL
@printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$(1)$(ENDCOLOR) 1>&2
Expand Down Expand Up @@ -456,6 +469,7 @@ persist-settings: distclean
echo BUILD_TLS=$(BUILD_TLS) >> .make-settings
echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings
echo USE_SYSTEM_HIREDIS=$(USE_SYSTEM_HIREDIS) >> .make-settings
echo USE_SYSTEM_LUA=$(USE_SYSTEM_LUA) >> .make-settings
echo CFLAGS=$(CFLAGS) >> .make-settings
echo CXXFLAGS=$(CXXFLAGS) >> .make-settings
echo LDFLAGS=$(LDFLAGS) >> .make-settings
Expand Down Expand Up @@ -485,7 +499,7 @@ endif

# keydb-server
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) $(KEYDB_SERVER_OBJ)
$(REDIS_LD) -o $@ $^ ../deps/lua/src/liblua.a $(FINAL_LIBS)
$(REDIS_LD) -o $@ $^ $(SERVER_LIBS) $(FINAL_LIBS)

# keydb-sentinel
$(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME)
Expand Down

0 comments on commit 5bbff3c

Please sign in to comment.