]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
m4: Rewrite want_solr.m4 to use pkg_config
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 8 Jun 2022 09:02:13 +0000 (11:02 +0200)
committerKarl Fleischmann <karl.fleischmann@open-xchange.com>
Mon, 4 Jul 2022 09:43:26 +0000 (11:43 +0200)
Manually checking for headers/libraries requires the user to know and
pass non-default library-paths when configuring the project. Using
pkg_config simplifies the macro and automatically sets the
compiler/linker flags accordingly.

m4/want_solr.m4
src/plugins/fts-solr/Makefile.am

index defee67559c14115639b593edf7bca6853640586..2c8e0bd072e829d840235a92add8733eb70cc841 100644 (file)
@@ -1,21 +1,21 @@
 AC_DEFUN([DOVECOT_WANT_SOLR], [
+  have_expat=no
   have_solr=no
-  if test "$want_solr" != "no"; then
-    dnl need libexpat
-    AC_CHECK_LIB(expat, XML_Parse, [
-      AC_CHECK_HEADER(expat.h, [
-        have_solr=yes
-        fts="$fts solr"
-      ], [
-        if test $want_solr = yes; then
-          AC_MSG_ERROR(cannot build with Solr support: expat.h not found)
-        fi
+
+  AS_IF([test "$want_solr" != "no"], [
+    PKG_CHECK_MODULES([EXPAT], [expat], [have_expat=yes], [
+      have_expat=no
+
+      AS_IF([test "$want_solr" = "yes"], [
+        AC_MSG_ERROR([cannot build with Solr support: expat library not found])
       ])
-    ], [
-      if test $want_solr = yes; then
-        AC_MSG_ERROR(cannot build with Solr support: libexpat not found)
-      fi
     ])
-  fi
+  ])
+
+  AS_IF([test "$have_expat" != "no"], [
+    have_solr=yes
+    fts="$fts solr"
+  ])
+
   AM_CONDITIONAL(BUILD_SOLR, test "$have_solr" = "yes")
 ])
index cd1e17b8b9cba6e272350b0b94f305531b63698f..c3d8175721c7b73fa3510eba619b992e4bf9ada7 100644 (file)
@@ -20,7 +20,7 @@ endif
 
 lib21_fts_solr_plugin_la_LIBADD = \
        $(fts_plugin_dep) \
-       -lexpat
+       $(EXPAT_LIBS)
 
 lib21_fts_solr_plugin_la_SOURCES = \
        fts-backend-solr.c \
@@ -52,7 +52,7 @@ test_solr_response_SOURCES = \
        solr-response.c \
        test-solr-response.c
 test_solr_response_LDADD = \
-       $(test_libs) -lexpat
+       $(test_libs) $(EXPAT_LIBS)
 
 pkginc_libdir=$(pkgincludedir)
 pkginc_lib_HEADERS = $(headers)