Add ability to use system hiredict

Co-authored-by: Chris Lamb <lamby@debian.org>
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
This commit is contained in:
Maytham Alsudany 2024-04-14 11:52:21 +03:00
parent a7654a251b
commit ffb9f03106
No known key found for this signature in database
GPG Key ID: D597897206C5F07F
2 changed files with 24 additions and 5 deletions

2
deps/Makefile vendored
View File

@ -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)

View File

@ -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)