[gimp] configure: fix testing for bzip2 on windows



commit 4b9bd6ba7d06aabb41bd507fbfeda47fad51b8d6
Author: Michael Henning <drawoc darkrefraction com>
Date:   Tue Aug 19 00:03:09 2014 -0400

    configure: fix testing for bzip2 on windows

 configure.ac |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d78dc72..874285a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1274,14 +1274,25 @@ AC_SUBST(Z_LIBS)
 # Check for libbzip2
 ####################
 
+gimp_save_LIBS=$LIBS
+LIBS="$LIBS -lbz2"
+
 if test -z "$BZIP2_LIBS"; then
-  AC_CHECK_LIB(bz2, BZ2_bzCompress,
-    [AC_CHECK_HEADER(bzlib.h,
-      BZIP2_LIBS='-lbz2',
-      AC_MSG_ERROR([libbzip2 header files not found]))],
-    AC_MSG_ERROR([libbzip2 library not found]))
+  # We used to use AC_CHECK_LIB, but bz2 uses the WINAPI calling convention on
+  # windows, so the test needs to #include <bzlib.h> to be able to link properly
+  AC_CHECK_HEADER(bzlib.h,
+    [AC_MSG_CHECKING([for BZ2_bzCompress in -lbz2]);
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+        [#include <bzlib.h>],
+        [BZ2_bzCompress (NULL, 0);])],
+      [AC_MSG_RESULT([yes]); BZIP2_LIBS='-lbz2'],
+      AC_MSG_ERROR([libbzip2 library not found]))],
+    AC_MSG_ERROR([libbzip2 header files not found]))
 fi
 
+LIBS=$gimp_save_LIBS
+
 AC_SUBST(BZIP2_LIBS)
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]