From: Karl Fleischmann Date: Wed, 8 Jun 2022 09:01:41 +0000 (+0200) Subject: m4: Rewrite want_lz4.m4 to use pkg_config X-Git-Tag: 2.4.0~3865 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6845b0cb50866630f5410f10ca00a454dcd1bd49;p=thirdparty%2Fdovecot%2Fcore.git m4: Rewrite want_lz4.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_lz4.m4 b/m4/want_lz4.m4 index 1139a900f3..8387285681 100644 --- a/m4/want_lz4.m4 +++ b/m4/want_lz4.m4 @@ -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) + ]) ])