X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=m4%2Flz4.m4;h=9d79d2ec1034de7835933696f57e3877ea70b821;hb=7c87cfa7c9efe4ff70c023278129b9de09014be9;hp=f1128857c7f27e1ab3b75fd4f066c336abc16893;hpb=0f18410ebaf1c503e5d0ca9624b24df930561d7d;p=tinc diff --git a/m4/lz4.m4 b/m4/lz4.m4 index f1128857..9d79d2ec 100644 --- a/m4/lz4.m4 +++ b/m4/lz4.m4 @@ -19,87 +19,58 @@ dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. AC_DEFUN([tinc_LZ4], [ AC_ARG_ENABLE([lz4], - AS_HELP_STRING([--disable-lz4], [disable all lz4 compression support]) - ) + AS_HELP_STRING([--disable-lz4], [disable lz4 compression support])) AC_ARG_ENABLE([lz4-builtin], - AS_HELP_STRING([--disable-lz4-builtin], [required to link an lz4 library]) - ) + AS_HELP_STRING([--disable-lz4-builtin], [do not use lz4 builtin])) - AC_ARG_WITH(lz4, - AS_HELP_STRING([--with-lz4=DIR], [lz4 shared library prefix (eg: /usr/local)]), - [lz4="$withval" CPPFLAGS="$CPPFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib"] - ) + AS_IF([test "x$enable_lz4" != "xno"], [ + AC_DEFINE(HAVE_LZ4, 1, [enable lz4 compression support]) - AC_ARG_WITH(lz4-include, - AS_HELP_STRING([--with-lz4-include=DIR], [lz4 shared header directory]), - [lz4_include="$withval" CPPFLAGS="$CPPFLAGS -I$withval"] - ) - - AC_ARG_WITH(lz4-lib, - AS_HELP_STRING([--with-lz4-lib=DIR], [lz4 shared object directory]), - [lz4_lib="$withval" LDFLAGS="$LDFLAGS -L$withval"] - ) - - dnl Calling this early prevents autoconf lint. - AM_CONDITIONAL([CONFIGURE_LZ4_BUILTIN], [test "$enable_lz4_builtin" != 'no']) - - AS_IF([test "$enable_lz4" != 'no' -a "$enable_lz4_builtin" != 'no' ], [ - AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 support.]) - AC_DEFINE(HAVE_LZ4_BUILTIN, 1, [Enable lz4 builtin.]) - AC_DEFINE(HAVE_LZ4_STATE, 1, [Enable lz4 external state features.]) - AC_DEFINE( - [LZ4_compress_shim(a, b, c, d)], - [LZ4_compress_fast_extState(lz4_wrkmem, a, b, c, d, 0)], - [This is the best interface for the lz4 builtin.] + AC_ARG_WITH(lz4, + AS_HELP_STRING([--with-lz4=DIR], [lz4 shared library prefix (eg: /usr/local)]), + [lz4="$withval" + CPPFLAGS="$CPPFLAGS-I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib"] ) - ],[ - AS_IF([test "$enable_lz4" != 'no'], [ - AC_CHECK_HEADERS(lz4.h, [ - AC_DEFINE(LZ4_H, [], [Location of lz4.h]) - AC_CHECK_LIB(lz4, LZ4_compress_fast_extState, [ - LIBS="$LIBS -llz4" - AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 compression support.]) - AC_DEFINE(HAVE_LZ4_STATE, 1, [Enable lz4 external state features.]) - AC_DEFINE( - [LZ4_compress_shim(a, b, c, d)], - [LZ4_compress_fast_extState(lz4_wrkmem, a, b, c, d, 0)], - [The lz4-r129 library interface.] - ) - break - ]) - - AC_CHECK_LIB(lz4, LZ4_compress_default, [ - LIBS="$LIBS -llz4" - AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 compression support.]) - AC_DEFINE( - [LZ4_compress_shim(a, b, c, d)], - [LZ4_compress_default(a, b, c, d)], - [The lz4-r128 library interface.] - ) - break - ]) + AC_ARG_WITH(lz4-include, + AS_HELP_STRING([--with-lz4-include=DIR], [lz4 shared header directory]), + [lz4_include="$withval" + CPPFLAGS="$CPPFLAGS -I$withval"] + ) - AC_CHECK_LIB(lz4, LZ4_compress_limitedOutput, [ - LIBS="$LIBS -llz4" - AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 compression support.]) - AC_DEFINE( - [LZ4_compress_shim(a, b, c, d)], - [LZ4_compress_limitedOutput(a, b, c, d)], - [The lz4-r59 library interface.] - ) - AC_MSG_WARN("Using deprecated lz4-r59 interface.") - break - ]) + AC_ARG_WITH(lz4-lib, + AS_HELP_STRING([--with-lz4-lib=DIR], [lz4 shared object directory]), + [lz4_lib="$withval" + LDFLAGS="$LDFLAGS -L$withval"] + ) - ],[ - AC_MSG_ERROR("lz4.h header file not found.") - break + dnl First we check the system copy of the library + AS_IF([test "x$enable_lz4_builtin" != 'xyes'], [ + AC_CHECK_HEADERS(lz4.h, [ + AC_CHECK_LIB(lz4, LZ4_compress_fast_extState, + [lz4_header='' + LIBS="$LIBS -llz4"]) ]) + ]) + + dnl If it was not found or is too old, fallback to the built-in copy + AS_IF([test "x$enable_lz4_builtin" != 'xno' -a "x$lz4_header" = 'x'], [ + lz4_header='"lib/lz4/lz4.h"' + lz4_builtin=1 + AC_DEFINE(HAVE_LZ4_BUILTIN, 1, [Enable lz4 builtin.]) + ]) + dnl If the first one failed and the second one is disabled, there's nothing more we can do + AS_IF([test "x$lz4_header" = 'x'], [ + AC_MSG_ERROR("lz4 library was not found and fallback to builtin is disabled."); ]) ]) + AC_DEFINE_UNQUOTED(LZ4_H, [$lz4_header], [Location of lz4.h]) + + AM_CONDITIONAL([CONFIGURE_LZ4_BUILTIN], [test "x$lz4_builtin" = 'x1']) + ])