From: Karl Fleischmann Date: Wed, 8 Jun 2022 09:02:13 +0000 (+0200) Subject: m4: Rewrite want_solr.m4 to use pkg_config X-Git-Tag: 2.4.0~3864 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e145eebc9d565b36677ac9c7d20a79b6dacea0fe;p=thirdparty%2Fdovecot%2Fcore.git m4: Rewrite want_solr.m4 to use pkg_config 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. --- diff --git a/m4/want_solr.m4 b/m4/want_solr.m4 index defee67559..2c8e0bd072 100644 --- a/m4/want_solr.m4 +++ b/m4/want_solr.m4 @@ -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") ]) diff --git a/src/plugins/fts-solr/Makefile.am b/src/plugins/fts-solr/Makefile.am index cd1e17b8b9..c3d8175721 100644 --- a/src/plugins/fts-solr/Makefile.am +++ b/src/plugins/fts-solr/Makefile.am @@ -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)