Skip to content

Commit 1a0f897

Browse files
committed
Use different check for libbz2 on Windows.
Windows port of libbz2 cannot use AC_CHECK_LIB. See https://mail.gnome.org/archives/gnumeric-list/2008-November/msg00038.html for an explanation.
1 parent 66648f8 commit 1a0f897

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

configure.ac

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,29 @@ AC_ARG_WITH([bz2lib],
247247

248248
if test "x$with_bz2lib" != "xno"; then
249249
AC_CHECK_HEADERS([bzlib.h])
250-
AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
250+
case "$host_os" in
251+
*mingw* | *cygwin*)
252+
dnl AC_CHECK_LIB cannot be used on the Windows port of libbz2, therefore
253+
dnl use AC_LINK_IFELSE.
254+
AC_MSG_CHECKING([for BZ2_bzDecompressInit in -lbz2])
255+
old_LIBS="$LIBS"
256+
LIBS="-lbz2 $LIBS"
257+
AC_LINK_IFELSE(
258+
[AC_LANG_SOURCE(#include <bzlib.h>
259+
int main() { return BZ2_bzDecompressInit(NULL, 0, 0); })],
260+
[ac_cv_lib_bz2_BZ2_bzDecompressInit=yes],
261+
[ac_cv_lib_bz2_BZ2_bzDecompressInit=no])
262+
LIBS="$old_LIBS"
263+
AC_MSG_RESULT($ac_cv_lib_bz2_BZ2_bzDecompressInit)
264+
if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = xyes; then
265+
AC_DEFINE([HAVE_LIBBZ2], [1], [Define to 1 if you have the `bz2' library (-lbz2).])
266+
LIBS="-lbz2 $LIBS"
267+
fi
268+
;;
269+
*)
270+
AC_CHECK_LIB(bz2,BZ2_bzDecompressInit)
271+
;;
272+
esac
251273
fi
252274

253275
AC_ARG_WITH([lzmadec],

0 commit comments

Comments
 (0)