Blob Blame History Raw
From bfd5de1744c89345a15cc1c9202d9c9a0a99d9f8 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Wed, 27 Apr 2016 07:53:30 +0200
Subject: [PATCH] configure: properly detect lzma_stream_encoder_mt

This caused issues when building against lzma 5.1alpha.
---
 configure.ac | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d0e8dac..ee42313 100644
--- a/configure.ac
+++ b/configure.ac
@@ -369,7 +369,20 @@ AC_ARG_WITH([lzma],
 if test "x$with_lzma" != "xno"; then
   AC_CHECK_HEADERS([lzma.h])
   AC_CHECK_LIB(lzma,lzma_stream_decoder)
-  AC_CHECK_FUNCS([lzma_stream_encoder_mt])
+
+  # Simply checking by AC_CHECK_LIB (or it's alternative) is not sufficient
+  # here because some pr-release (widely distributed, however) versions of xz
+  # provided the lzma_stream_encoder_mt function already.  The *_mt
+  # functionality was compiled in, but it was disabled  unless calling code
+  # explicitly declared LZMA_UNSTABLE macro (thus the AC_CHECK_LIB would
+  # succeed but the compilation would fail in the end).
+  AC_CACHE_CHECK(
+    [whether we have multithread support in lzma],
+    ac_cv_lzma_has_mt,
+    [AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[#include <lzma.h>]],
+                      [[lzma_stream_encoder_mt(0, 0);]])],
+      [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
 fi
 
 AC_ARG_WITH([lzo2],
-- 
2.5.5