From 4b9bd6ba7d06aabb41bd507fbfeda47fad51b8d6 Mon Sep 17 00:00:00 2001 From: Michael Henning Date: Tue, 19 Aug 2014 00:03:09 -0400 Subject: [PATCH] configure: fix testing for bzip2 on windows --- configure.ac | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index d78dc72222..874285ad30 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 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 ], + [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)