]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
configure: Try to detect LZO with pkg-config
authorFrank Lichtenheld <frank@lichtenheld.com>
Wed, 26 Jun 2024 16:19:21 +0000 (18:19 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 26 Jun 2024 16:27:07 +0000 (18:27 +0200)
On most systems this should work just fine.

v2:
 - simplify code by removing -llzo special handling
v3:
 - reintroduce support for autodetection without pkg-config,
   no need to break backwards compatibility right now
v7:
 - Handle case correctly where lzo/lzo1x.h can not be included
   at all. On most distros this works even though the .pc
   file suggests to use it without. We had some partly
   solution for that but it wasn't really working.
v8:
 - Handle systems that do not implicitly include limits.h
   in configure test builds.
   lzodefs.h usually relies on lzoconf.h to include it.

Change-Id: I1c038dc4ec80d3499582d81eee61fee74f26e693
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240626161921.179301-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28848.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
config.h.cmake.in
configure.ac
src/openvpn/lzo.h

index effca2a5c80d764c9fdd9fb564f38435ca4b6b37..720d679c8671a84cf1ff5db19a31e8c8f9c4979c 100644 (file)
@@ -178,9 +178,6 @@ don't. */
 /* Define to 1 if you have the <linux/types.h> header file. */
 #cmakedefine HAVE_LINUX_TYPES_H
 
-/* Define to 1 if you have the <lzoconf.h> header file. */
-#define HAVE_LZO_CONF_H
-
 /* Define to 1 if you have the <lzo1x.h> header file. */
 #define HAVE_LZO1X_H 1
 
index c01ad093d1c9ea0354d6d90c5284acec0ce8964f..555c97e75e5f66ea9e40b631edfe38880096ca50 100644 (file)
@@ -1143,8 +1143,17 @@ fi
 
 AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
 AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
-have_lzo="yes"
-if test -z "${LZO_LIBS}"; then
+if test -z "${LZO_CFLAGS}" -a -z "${LZO_LIBS}"; then
+    # if the user did not explicitly specify flags, try to autodetect
+    PKG_CHECK_MODULES([LZO],
+               [lzo2],
+               [have_lzo="yes"],
+               []
+    )
+
+    if test "${have_lzo}" != "yes"; then
+       # try to detect without pkg-config
+       have_lzo="yes"
        AC_CHECK_LIB(
                [lzo2],
                [lzo1x_1_15_compress],
@@ -1156,6 +1165,10 @@ if test -z "${LZO_LIBS}"; then
                        [have_lzo="no"]
                )]
        )
+    fi
+else
+    # assume the user configured it correctly
+    have_lzo="yes"
 fi
 if test "${have_lzo}" = "yes"; then
        saved_CFLAGS="${CFLAGS}"
@@ -1166,8 +1179,11 @@ if test "${have_lzo}" = "yes"; then
                [AC_CHECK_HEADERS(
                        [lzo1x.h],
                        ,
-                       [AC_MSG_ERROR([lzo1x.h is missing])]
-               )]
+                       [AC_MSG_ERROR([lzo1x.h is missing])],
+                        [#include <limits.h>
+                         #include <lzodefs.h>
+                         #include <lzoconf.h>]
+               )],
        )
        CFLAGS="${saved_CFLAGS}"
 fi
index 62d73a1b36b2f70f19cd333dbf226880cd82c94a..c271527697ed208a0a5014fb5872476b50dce02a 100644 (file)
  * @addtogroup compression
  * @{
  */
-#if defined(HAVE_LZO_CONF_H)
+#if defined(HAVE_LZO_LZO1X_H)
+#include <lzo/lzo1x.h>
+#elif defined(HAVE_LZO1X_H)
 /* The lzo.h magic gets confused and still wants
  * to include lzo/lzoconf.h even if our include paths
  * are setup to include the paths without lzo/
  */
 #include <lzodefs.h>
 #include <lzoconf.h>
-#endif
-#if defined(HAVE_LZO_LZO1X_H)
-#include <lzo/lzo1x.h>
-#elif defined(HAVE_LZO1X_H)
 #include <lzo1x.h>
 #endif