]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
m4: Rewrite want_lz4.m4 to use pkg_config
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 8 Jun 2022 09:01:41 +0000 (11:01 +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_lz4.m4

index 1139a900f35d9c265bd0ced326dcd7f0e46f6f90..838728568187178ae4af7dcc8bb315d4521b3fc6 100644 (file)
@@ -1,24 +1,25 @@
 AC_DEFUN([DOVECOT_WANT_LZ4], [
+  have_lz4=no
+
   AS_IF([test "$want_lz4" != "no"], [
-    AC_CHECK_HEADER(lz4.h, [
-      AC_CHECK_LIB(lz4, LZ4_compress, [
-        have_lz4=yes
-        have_compress_lib=yes
-        AC_DEFINE(HAVE_LZ4,, [Define if you have lz4 library])
-        COMPRESS_LIBS="$COMPRESS_LIBS -llz4"
-      ], [
-        AS_IF([test "$want_lz4" = "yes"], [
-          AC_MSG_ERROR(cannot build with lz4 support: liblz4 not found)
-        ])
-      ])
-      AC_CHECK_LIB(lz4, LZ4_compress_default, [
-        AC_DEFINE(HAVE_LZ4_COMPRESS_DEFAULT,,
-          [Define if you have LZ4_compress_default])
-      ])
-    ], [
+    PKG_CHECK_MODULES([LZ4], [liblz4], [have_lz4=yes], [
+      have_lz4=no
+
       AS_IF([test "$want_lz4" = "yes"], [
-        AC_MSG_ERROR(cannot build with lz4 support: lz4.h not found)
+        AC_MSG_ERROR([cannot build with LZ4 support: lz4 library (liblz4) not found])
       ])
     ])
   ])
+
+  AS_IF([test "$have_lz4" != "no"], [
+    have_compress_lib=yes
+    COMPRESS_LIBS="$COMPRESS_LIBS $LZ4_LIBS"
+    AC_DEFINE(HAVE_LZ4,, [Define if you have lz4 library])
+
+    AC_CHECK_LIB(lz4, LZ4_compress_default, [
+      AC_DEFINE(HAVE_LZ4_COMPRESS_DEFAULT,, [
+        Define if you have LZ4_compress_default
+      ])
+    ],, $LZ4_LIBS)
+  ])
 ])