1 dnl lz4.m4: Tinc autoconf integration for the LZ4 codec.
2 dnl Copyright 2015 Darik Horn <dajhorn@vanadac.com>.
4 dnl This program is free software; you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation; either version 2 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License along
15 dnl with this program; if not, write to the Free Software Foundation, Inc.,
16 dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 AC_DEFUN([tinc_LZ4], [
22 AS_HELP_STRING([--disable-lz4], [disable all lz4 compression support])
25 AC_ARG_ENABLE([lz4-builtin],
26 AS_HELP_STRING([--disable-lz4-builtin], [required to link an lz4 library])
30 AS_HELP_STRING([--with-lz4=DIR], [lz4 shared library prefix (eg: /usr/local)]),
31 [lz4="$withval" CPPFLAGS="$CPPFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib"]
34 AC_ARG_WITH(lz4-include,
35 AS_HELP_STRING([--with-lz4-include=DIR], [lz4 shared header directory]),
36 [lz4_include="$withval" CPPFLAGS="$CPPFLAGS -I$withval"]
40 AS_HELP_STRING([--with-lz4-lib=DIR], [lz4 shared object directory]),
41 [lz4_lib="$withval" LDFLAGS="$LDFLAGS -L$withval"]
44 dnl Calling this early prevents autoconf lint.
45 AM_CONDITIONAL([CONFIGURE_LZ4_BUILTIN], [test "$enable_lz4_builtin" != 'no'])
47 AS_IF([test "$enable_lz4" != 'no' -a "$enable_lz4_builtin" != 'no' ], [
48 AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 support.])
49 AC_DEFINE(HAVE_LZ4_BUILTIN, 1, [Enable lz4 builtin.])
50 AC_DEFINE(HAVE_LZ4_STATE, 1, [Enable lz4 external state features.])
52 [LZ4_compress_shim(a, b, c, d)],
53 [LZ4_compress_fast_extState(lz4_wrkmem, a, b, c, d, 0)],
54 [This is the best interface for the lz4 builtin.]
57 AS_IF([test "$enable_lz4" != 'no'], [
58 AC_CHECK_HEADERS(lz4.h, [
59 AC_DEFINE(LZ4_H, [<lz4.h>], [Location of lz4.h])
61 AC_CHECK_LIB(lz4, LZ4_compress_fast_extState, [
63 AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 compression support.])
64 AC_DEFINE(HAVE_LZ4_STATE, 1, [Enable lz4 external state features.])
66 [LZ4_compress_shim(a, b, c, d)],
67 [LZ4_compress_fast_extState(lz4_wrkmem, a, b, c, d, 0)],
68 [The lz4-r129 library interface.]
73 AC_CHECK_LIB(lz4, LZ4_compress_default, [
75 AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 compression support.])
77 [LZ4_compress_shim(a, b, c, d)],
78 [LZ4_compress_default(a, b, c, d)],
79 [The lz4-r128 library interface.]
84 AC_CHECK_LIB(lz4, LZ4_compress_limitedOutput, [
86 AC_DEFINE(HAVE_LZ4, 1, [Enable lz4 compression support.])
88 [LZ4_compress_shim(a, b, c, d)],
89 [LZ4_compress_limitedOutput(a, b, c, d)],
90 [The lz4-r59 library interface.]
92 AC_MSG_WARN("Using deprecated lz4-r59 interface.")
97 AC_MSG_ERROR("lz4.h header file not found.")