]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
m4: want_mysql.m4 - Add shim for CentOS7
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Thu, 9 Jun 2022 16:11:32 +0000 (18:11 +0200)
committerKarl Fleischmann <karl.fleischmann@open-xchange.com>
Mon, 4 Jul 2022 09:43:26 +0000 (11:43 +0200)
This commit adds manual gathering of compile/link-flags for older
distributions (namely CentOS7) that don't supply a pkg-check file in
their core repository package for mysql/mariadb.

m4/want_mysql.m4

index 5e02bd24913a0e922441e2ee867e5453aca1b945..50e84cd071fee4b1571394b968f5adbfda145dea 100644 (file)
@@ -3,9 +3,14 @@ AC_DEFUN([DOVECOT_WANT_MYSQL], [
   have_mariadb=no
 
   dnl Check mysql driver to use:
-  dnl - use mysqlclient library by default, fall back to mariadb (in which
-  dnl   case print a message that mariadb is used),
-  dnl - if neither can be found print error.
+  dnl - use mysqlclient library by default, this might be libmariadb in
+  dnl   which case the library and headers are wrappers and can be used by
+  dnl   the "incorrect" name of mysql,
+  dnl - use libmariadb as a fallback and print a message that this
+  dnl   alternative is used for transparency reasons,
+  dnl - if neither can be found check manually, (which is currently necessary
+  dnl   on CentOS7),
+  dnl - if all else fails, print error and exit.
   mysql_driver=""
   AS_IF([test "$want_mysql" != "no"], [
     PKG_CHECK_MODULES([MYSQL], [mysqlclient], [have_mysql=yes], [have_mysql=no])
@@ -22,6 +27,43 @@ AC_DEFUN([DOVECOT_WANT_MYSQL], [
         mysql_driver="libmariadb"
         MYSQL_LIBS="$MARIADB_LIBS"
         MYSQL_CFLAGS="$MARIADB_CFLAGS"
+      ])
+    ])
+
+    dnl Obsolete manual check for library/header location, currently
+    dnl only necessary for CentOS7.
+    dnl TODO: Make sure to remove this next block as soon as this is not
+    dnl       officially supported anymore.
+    dnl Based on code from PHP.
+    AS_IF([test "$have_mysql" = "no"], [
+      AC_MSG_CHECKING([for libmysqlclient library in expected file paths])
+
+      AC_SUBST(MYSQL_CFLAGS)
+      AC_SUBST(MYSQL_LIBS)
+      for i in /usr /usr/local /usr/local/mysql; do
+        for j in include include/mysql ""; do
+          if test -r "$i/$j/mysql.h"; then
+            MYSQL_INCLUDE="-I$i/$j"
+          fi
+        done
+        for j in lib lib/mysql lib64 lib64/mysql ""; do
+          if test -f "$i/$j/libmysqlclient.so" || test -f "$i/$j/libmysqlclient.a"; then
+            MYSQL_LIBS="-L$i/$j -lmysqlclient"
+          fi
+        done
+      done
+
+      AS_IF([test "$MYSQL_INCLUDE" != "" && test "$MYSQL_LIBS" != ""], [
+        AC_MSG_RESULT([using MYSQL_CFLAGS="$MYSQL_CFLAGS" and MYSQL_LIBS="$MYSQL_LIBS"])
+
+        AC_CHECK_LIB(mysqlclient, mysql_init, [
+          have_mysql=yes
+
+          MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_INCLUDE"
+        ],, $MYSQL_LIBS)
+      ], [
+        AC_MSG_RESULT([none found])
+      ])
     ])
 
     AS_IF([test "$want_mysql" = "yes" && test "$have_mysql" = no], [