summaryrefslogtreecommitdiff
blob: 7cd81e53cea9d98c783242ca794769d2fc098acc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
diff --git a/Makefile.am b/Makefile.am
index e0dbfc8..e595cb7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -80,7 +80,9 @@ libraft_la_LDFLAGS += $(LZ4_LIBS)
 endif # LZ4_AVAILABLE
 if LZ4_ENABLED
 test_unit_core_CFLAGS += -DLZ4_ENABLED
+test_unit_core_LDFLAGS = $(LZ4_LIBS)
 libraft_la_CFLAGS += -DLZ4_ENABLED
+libraft_la_LDFLAGS += $(LZ4_LIBS)
 endif # LZ4_ENABLED
 
 if FIXTURE_ENABLED
@@ -210,6 +212,7 @@ test_integration_uv_LDFLAGS += $(LZ4_LIBS)
 endif # LZ4_AVAILABLE
 if LZ4_ENABLED
 test_integration_uv_CFLAGS += -DLZ4_ENABLED
+test_integration_uv_LDFLAGS += $(LZ4_LIBS)
 endif # LZ4_ENABLED
 
 endif # UV_ENABLED
diff --git a/configure.ac b/configure.ac
index df7bea9..0e2949f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,47 +23,13 @@ AM_CONDITIONAL(UV_ENABLED, test "x$have_uv" = "xyes")
 # explicitly disabled.
 AC_ARG_ENABLE(lz4, AS_HELP_STRING([--disable-lz4], [do not use lz4 compression]))
 
-# Thanks to the OpenVPN configure.ac file for this part.
-# If this fails, we will do another test next.
-# We also add set LZ4_LIBS otherwise linker will not know about the lz4 library
-PKG_CHECK_MODULES(LZ4, [liblz4 >= 1.7.1], [have_lz4="yes"], [LZ4_LIBS="-llz4"])
-if test "${have_lz4}" != "yes" ; then
-    AC_CHECK_HEADERS([lz4.h],
-                     [have_lz4h="yes"],
-                     [])
-    if test "${have_lz4h}" = "yes" ; then
-        AC_MSG_CHECKING([additionally if system LZ4 version >= 1.7.1])
-        AC_COMPILE_IFELSE(
-        [AC_LANG_PROGRAM([[
-#include <lz4.h>
-                         ]],
-                         [[
-/* Version encoding: MMNNPP (Major miNor Patch) - see lz4.h for details */
-#if LZ4_VERSION_NUMBER < 10701L
-#error LZ4 is too old
-#endif
-                         ]]
-                        )],
-         [
-             AC_MSG_RESULT([ok])
-             have_lz4="yes"
-         ],
-         [
-             AC_MSG_RESULT([system LZ4 library is too old])
-             have_lz4="no"
-         ]
-        )
-    fi
-fi
-
-AS_IF([test "x$enable_lz4" != "xno" -a "x$have_lz4" != "xyes"],
-      [AC_MSG_ERROR([liblz4 required but not found])], [])
-# LZ4 Can be available without being enabled, this allows a user to activate
-# it at a later stage through an API call.
-AM_CONDITIONAL(LZ4_AVAILABLE, test "x$have_lz4" = "xyes")
+AS_IF([test "x$enable_lz4" != "xno"], [
+	PKG_CHECK_MODULES(LZ4, [liblz4 >= 1.7.1], [LZ4_LIBS="-llz4"])
+])
 # `LZ4_ENABLED` will cause the libuv snapshot implementation to use lz4
 # compression by default.
-AM_CONDITIONAL(LZ4_ENABLED, test "x$enable_lz4" != "xno" -a "x$have_lz4" = "xyes")
+AM_CONDITIONAL(LZ4_ENABLED, test "x$enable_lz4" != "xno")
+AM_CONDITIONAL(LZ4_AVAILABLE, test "x$enable_lz4" != "xno")
 
 # The fake I/O implementation and associated fixture is built by default, unless
 # explicitly disabled.