From cb717794aea7e4f7bb5a8b643db97937d2eb2793 Mon Sep 17 00:00:00 2001
From: Aki Tuomi <aki.tuomi@open-xchange.com>
Date: Wed, 8 Jan 2025 16:13:00 +0200
Subject: [PATCH] dovecot.m4: Update from core

---
 m4/dovecot.m4 | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/m4/dovecot.m4 b/m4/dovecot.m4
index aeff3b802..d498f84ac 100644
--- a/m4/dovecot.m4
+++ b/m4/dovecot.m4
@@ -6,7 +6,7 @@ dnl This file is free software; the authors give
 dnl unlimited permission to copy and/or distribute it, with or without
 dnl modifications, as long as this notice is preserved.
 
-# serial 37
+# serial 39
 
 dnl
 dnl Check for support for D_FORTIFY_SOURCE=2
@@ -367,8 +367,10 @@ AC_DEFUN([DC_DOVECOT],[
 	ORIG_BINARY_CFLAGS="$BINARY_CFLAGS"
 	ORIG_BINARY_LDFLAGS="$BINARY_LDFLAGS"
 
-	eval `grep -i '^dovecot_[[a-z_]]*=' "$dovecotdir"/dovecot-config`
-	eval `grep '^LIBDOVECOT[[A-Z0-9_]]*=' "$dovecotdir"/dovecot-config`
+	eval `$GREP -i '^dovecot_[[a-z_]]*=' "$dovecotdir"/dovecot-config`
+	eval `$GREP '^LIBDOVECOT[[A-Z0-9_]]*=' "$dovecotdir"/dovecot-config`
+	eval `$GREP '^DOVECOT_HAVE' "$dovecotdir"/dovecot-config`
+	eval `$GREP '^DOVECOT_PRO' "$dovecotdir"/dovecot-config`
 
         CFLAGS="$ORIG_CFLAGS"
         LDFLAGS="$ORIG_LDFLAGS"
@@ -395,13 +397,17 @@ AC_DEFUN([DC_DOVECOT],[
 
 	AX_SUBST_L([DISTCHECK_CONFIGURE_FLAGS], [dovecotdir], [dovecot_moduledir], [dovecot_installed_moduledir], [dovecot_pkgincludedir], [dovecot_pkglibexecdir], [dovecot_pkglibdir], [dovecot_docdir], [dovecot_statedir])
 	AX_SUBST_L([DOVECOT_INSTALLED], [DOVECOT_CFLAGS], [DOVECOT_LIBS], [DOVECOT_SSL_LIBS], [DOVECOT_SQL_LIBS], [DOVECOT_COMPRESS_LIBS], [DOVECOT_BINARY_CFLAGS], [DOVECOT_BINARY_LDFLAGS])
-	AX_SUBST_L([LIBDOVECOT], [LIBDOVECOT_LOGIN], [LIBDOVECOT_SQL], [LIBDOVECOT_SSL], [LIBDOVECOT_COMPRESS], [LIBDOVECOT_LDA], [LIBDOVECOT_STORAGE], [LIBDOVECOT_DSYNC], [LIBDOVECOT_LIBFTS])
-	AX_SUBST_L([LIBDOVECOT_DEPS], [LIBDOVECOT_LOGIN_DEPS], [LIBDOVECOT_SQL_DEPS], [LIBDOVECOT_SSL_DEPS], [LIBDOVECOT_COMPRESS_DEPS], [LIBDOVECOT_LDA_DEPS], [LIBDOVECOT_STORAGE_DEPS], [LIBDOVECOT_DSYNC_DEPS], [LIBDOVECOT_LIBFTS_DEPS])
+	AX_SUBST_L([LIBDOVECOT], [LIBDOVECOT_LOGIN], [LIBDOVECOT_SQL], [LIBDOVECOT_OPENSSL], [LIBDOVECOT_COMPRESS], [LIBDOVECOT_LDA], [LIBDOVECOT_STORAGE], [LIBDOVECOT_DSYNC], [LIBDOVECOT_LIBFTS])
+	AX_SUBST_L([LIBDOVECOT_DEPS], [LIBDOVECOT_LOGIN_DEPS], [LIBDOVECOT_SQL_DEPS], [LIBDOVECOT_OPENSSL_DEPS], [LIBDOVECOT_COMPRESS_DEPS], [LIBDOVECOT_LDA_DEPS], [LIBDOVECOT_STORAGE_DEPS], [LIBDOVECOT_DSYNC_DEPS], [LIBDOVECOT_LIBFTS_DEPS])
 	AX_SUBST_L([LIBDOVECOT_INCLUDE], [LIBDOVECOT_LDA_INCLUDE], [LIBDOVECOT_AUTH_INCLUDE], [LIBDOVECOT_DOVEADM_INCLUDE], [LIBDOVECOT_SERVICE_INCLUDE], [LIBDOVECOT_STORAGE_INCLUDE], [LIBDOVECOT_LOGIN_INCLUDE], [LIBDOVECOT_SQL_INCLUDE])
 	AX_SUBST_L([LIBDOVECOT_IMAP_LOGIN_INCLUDE], [LIBDOVECOT_CONFIG_INCLUDE], [LIBDOVECOT_IMAP_INCLUDE], [LIBDOVECOT_POP3_INCLUDE], [LIBDOVECOT_SUBMISSION_INCLUDE], [LIBDOVECOT_LMTP_INCLUDE], [LIBDOVECOT_DSYNC_INCLUDE], [LIBDOVECOT_IMAPC_INCLUDE], [LIBDOVECOT_FTS_INCLUDE])
 	AX_SUBST_L([LIBDOVECOT_NOTIFY_INCLUDE], [LIBDOVECOT_PUSH_NOTIFICATION_INCLUDE], [LIBDOVECOT_ACL_INCLUDE], [LIBDOVECOT_LIBFTS_INCLUDE], [LIBDOVECOT_LUA_INCLUDE])
 	AX_SUBST_L([DOVECOT_LUA_LIBS], [DOVECOT_LUA_CFLAGS], [LIBDOVECOT_LUA], [LIBDOVECOT_LUA_DEPS])
+	AX_SUBST_L([DOVECOT_HAVE_MAIL_UTF8])
 
+	AS_IF([test x$DOVECOT_HAVE_MAIL_UTF8 = xyes], [
+		AC_DEFINE([DOVECOT_HAVE_MAIL_UTF8],,"Define if Dovecot has mail utf8 support")
+	])
 	AM_CONDITIONAL(DOVECOT_INSTALLED, test "$DOVECOT_INSTALLED" = "yes")
 
 	DC_PLUGIN_DEPS
@@ -411,7 +417,7 @@ AC_DEFUN([DC_DOVECOT],[
 AC_DEFUN([DC_CC_WRAPPER],[
   AS_IF([test "$want_shared_libs" != "yes"], [
     dnl want_shared_libs=no is for internal use. the liblib.la check is for plugins
-    AS_IF([test "$want_shared_libs" = "no" || echo "$LIBDOVECOT" | grep "/liblib.la" > /dev/null], [
+    AS_IF([test "$want_shared_libs" = "no" || echo "$LIBDOVECOT" | $GREP "/liblib.la" > /dev/null], [
       AS_IF([test "$with_gnu_ld" = yes], [
 	dnl libtool can't handle using whole-archive flags, so we need to do this
 	dnl with a CC wrapper.. shouldn't be much of a problem, since most people
@@ -419,7 +425,7 @@ AC_DEFUN([DC_CC_WRAPPER],[
 	cat > cc-wrapper.sh <<_DC_EOF
 #!/bin/sh
 
-if echo "\$[*]" | grep -- -ldl > /dev/null; then
+if echo "\$[*]" | $GREP -- -export-dynamic > /dev/null; then
   # the binary uses plugins. make sure we include everything from .a libs
   exec $CC -Wl,--whole-archive \$[*] -Wl,--no-whole-archive
 else
@@ -515,7 +521,7 @@ m4_ifval([$2],
 dnl * clang check
 AC_DEFUN([CC_CLANG],[
   AC_MSG_CHECKING([whether $CC is clang 3.3+])
-  AS_IF([$CC -dM -E -x c /dev/null | grep __clang__ > /dev/null 2>&1], [
+  AS_IF([$CC -dM -E -x c /dev/null | $GREP __clang__ > /dev/null 2>&1], [
       AS_VAR_SET([have_clang], [yes])
   ], [
       AS_VAR_SET([have_clang], [no])
-- 
GitLab