From ffb9f03106de48a2a09d60f691a8852a0cf917ad Mon Sep 17 00:00:00 2001 From: Maytham Alsudany Date: Sun, 14 Apr 2024 11:52:21 +0300 Subject: [PATCH] Add ability to use system hiredict Co-authored-by: Chris Lamb Signed-off-by: Maytham Alsudany --- deps/Makefile | 2 ++ src/Makefile | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 345e1f703..e071cfa03 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -36,7 +36,9 @@ ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'), endif distclean: +ifneq ($(USE_SYSTEM_HIREDICT),yes) -(cd hiredict && $(MAKE) clean) > /dev/null || true +endif -(cd linenoise && $(MAKE) clean) > /dev/null || true -(cd lua && $(MAKE) clean) > /dev/null || true ifneq ($(USE_SYSTEM_JEMALLOC),yes) diff --git a/src/Makefile b/src/Makefile index fbcc20f02..8ca30a6df 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,7 +24,7 @@ endif ifneq ($(OPTIMIZATION),-O0) OPTIMIZATION+=-fno-omit-frame-pointer endif -DEPENDENCY_TARGETS=hiredict linenoise lua hdr_histogram fpconv +DEPENDENCY_TARGETS=linenoise lua hdr_histogram fpconv NODEPS:=clean distclean # Default settings @@ -226,7 +226,7 @@ ifdef OPENSSL_PREFIX endif # Include paths to dependencies -FINAL_CFLAGS+= -I../deps/hiredict -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv +FINAL_CFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv # Determine systemd support and/or build preference (defaulting to auto-detection) BUILD_WITH_SYSTEMD=no @@ -277,6 +277,15 @@ else endif endif +ifeq ($(USE_SYSTEM_HIREDICT),yes) + FINAL_LIBS+= $(shell $(PKG_CONFIG) --libs hiredict) + FINAL_CFLAGS+= $(shell $(PKG_CONFIG) --cflags hiredict) +else + DEPENDENCY_TARGETS += hiredict + FINAL_LIBS+= ../deps/hiredict/libhiredict.a + FINAL_CFLAGS+= -I../deps/hiredict +endif + # LIBSSL & LIBCRYPTO LIBSSL_LIBS= LIBSSL_PKGCONFIG := $(shell $(PKG_CONFIG) --exists libssl && echo $$?) @@ -299,15 +308,23 @@ BUILD_MODULE:=2 ifeq ($(BUILD_TLS),yes) FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_YES) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_NO) FINAL_LDFLAGS+=$(OPENSSL_LDFLAGS) +ifeq ($(USE_SYSTEM_HIREDICT),yes) + FINAL_LIBS += $(shell $(PKG_CONFIG) --libs hiredict_ssl) $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS) +else FINAL_LIBS += ../deps/hiredict/libhiredict_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS) endif +endif TLS_MODULE= TLS_MODULE_NAME:=redict-tls$(PROG_SUFFIX).so TLS_MODULE_CFLAGS:=$(FINAL_CFLAGS) ifeq ($(BUILD_TLS),module) FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) +ifeq ($(USE_SYSTEM_HIREDICT),yes) + TLS_CLIENT_LIBS = $(shell $(PKG_CONFIG) --libs hiredict_ssl) $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS) +else TLS_CLIENT_LIBS = ../deps/hiredict/libhiredict_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS) +endif TLS_MODULE=$(TLS_MODULE_NAME) TLS_MODULE_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_MODULE) endif @@ -406,7 +423,7 @@ endif # redict-server $(REDICT_SERVER_NAME): $(REDICT_SERVER_OBJ) - $(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS) + $(REDICT_LD) -o $@ $^ ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS) # redict-sentinel $(REDICT_SENTINEL_NAME): $(REDICT_SERVER_NAME) @@ -426,11 +443,11 @@ $(TLS_MODULE_NAME): $(REDICT_SERVER_NAME) # redict-cli $(REDICT_CLI_NAME): $(REDICT_CLI_OBJ) - $(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS) + $(REDICT_LD) -o $@ $^ ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS) # redict-benchmark $(REDICT_BENCHMARK_NAME): $(REDICT_BENCHMARK_OBJ) - $(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS) + $(REDICT_LD) -o $@ $^ ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS) DEP = $(REDICT_SERVER_OBJ:%.o=%.d) $(REDICT_CLI_OBJ:%.o=%.d) $(REDICT_BENCHMARK_OBJ:%.o=%.d) -include $(DEP)