]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
configure: prepare for Redis
authorDaniel Salzman <daniel.salzman@nic.cz>
Fri, 24 Jan 2025 07:31:43 +0000 (08:31 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Fri, 12 Sep 2025 14:50:41 +0000 (16:50 +0200)
Makefile.am
configure.ac
src/redis/Makefile.am [new file with mode: 0644]

index f6cab44e4ec67d9afd0217ad7cf58fc4bc8a1046..e0960c73873ec30e047c7e084bac8745f85b1a9c 100644 (file)
@@ -1,5 +1,5 @@
 ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = src tests tests-fuzz python samples distro doc
+SUBDIRS = src src/redis tests tests-fuzz python samples distro doc
 
 EXTRA_DIST = README.md
 
index 1cacd0826b4e0e9f26989d8d42e882867463b7f6..58121cebf5bf38a9727bcbbddd424d0760135211 100644 (file)
@@ -135,6 +135,8 @@ AM_CONDITIONAL([HAVE_DOCS], [test "$enable_documentation" != "no"])
 AM_CONDITIONAL([HAVE_SPHINX], [test "$SPHINXBUILD" != "false"])
 AM_CONDITIONAL([HAVE_PDFLATEX], test "$PDFLATEX" != "false")
 
+link_mode=$(test "$enable_shared" = "yes" && echo "shared" || echo "static")
+
 ######################
 # Generic dependencies
 ######################
@@ -257,6 +259,35 @@ AS_CASE([$enable_reuseport],
 AS_IF([test "$enable_reuseport" = yes],[
    AC_DEFINE([ENABLE_REUSEPORT], [1], [Use SO_REUSEPORT(_LB).])])
 
+# Redis zone backend support
+AC_ARG_ENABLE([redis],
+   AS_HELP_STRING([--enable-redis=auto|yes|no], [enable Redis support [default=auto]]),
+   [], [enable_redis=auto])
+
+PKG_CHECK_MODULES([hiredis], [hiredis], [have_hiredis=yes], [have_hiredis=no])
+
+AS_CASE([$enable_redis],
+   [auto], [AS_IF([test "$have_hiredis" = "yes"], [enable_redis=yes], [enable_redis=no])],
+   [yes],  [AS_IF([test "$have_hiredis" = "yes"], [enable_redis=yes], [AC_MSG_ERROR([libhiredis not available])])],
+   [no], [],
+   [*], [AC_MSG_ERROR([Invalid value of --enable-redis.])]
+)
+AM_CONDITIONAL([ENABLE_REDIS], [test "$enable_redis" != "no"])
+AM_CONDITIONAL([ENABLE_REDIS_MODULE], [test "$enable_redis" != "no" && test "$enable_shared" = "yes"])
+
+AS_IF([test "$enable_redis" = yes],[
+   AC_DEFINE([ENABLE_REDIS], [1], [Enable Redis support.])
+   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <hiredis/hiredis.h>
+                                     #if (HIREDIS_MAJOR < 1) || (HIREDIS_MAJOR == 1 && HIREDIS_MINOR < 1)
+                                     #error "No TLS support in Redis (need >= 1.1.0)"
+                                     #endif]])],
+                  [AC_DEFINE([ENABLE_REDIS_TLS], [1], [Enable Redis TLS support.])],
+                  [enable_redis="yes (no TLS)"])
+   AS_IF([test "$enable_shared" = yes],[
+      enable_redis="${enable_redis} module"
+   ])
+])
+
 #########################################
 # Dependencies needed for Knot DNS daemon
 #########################################
@@ -763,7 +794,7 @@ result_msg_base="
     Static modules: ${static_modules}
     Shared modules: ${shared_modules}
 
-    Knot DNS libraries:     yes
+    Knot DNS libraries:     ${link_mode}
     Knot DNS daemon:        ${enable_daemon}
     Knot DNS utilities:     ${enable_utilities}
     Knot DNS documentation: ${enable_documentation}
@@ -772,6 +803,7 @@ result_msg_base="
     Use SO_REUSEPORT(_LB):  ${enable_reuseport}
     XDP support:            ${enable_xdp}
     DoQ support:            ${enable_quic}
+    Redis support:          ${enable_redis}
     Socket polling:         ${socket_polling}
     Atomic support:         ${atomic_type}
     Memory allocator:       ${with_memory_allocator}
@@ -811,6 +843,7 @@ AC_CONFIG_FILES([Makefile
                  python/libknot/setup.py
                  python/libknot/libknot/__init__.py
                  src/Makefile
+                 src/redis/Makefile
                  src/libknot/xdp/Makefile
                  src/knot/modules/static_modules.h
                  ])
diff --git a/src/redis/Makefile.am b/src/redis/Makefile.am
new file mode 100644 (file)
index 0000000..3cea3c8
--- /dev/null
@@ -0,0 +1,12 @@
+AM_CPPFLAGS = -include $(top_builddir)/src/config.h
+AM_LDFLAGS = $(LT_NO_UNDEFINED)
+
+pkglibdir = ${libdir}/knot/redis
+
+if ENABLE_REDIS_MODULE
+pkglib_LTLIBRARIES = knot.la
+knot_la_SOURCES = knot.c
+
+knot_la_CPPFLAGS = $(AM_CPPFLAGS)
+knot_la_LDFLAGS  = $(AM_LDFLAGS) -module -shared -avoid-version
+endif