Fixes to build in mock.
[fedora-mingw.git] / libgsf / mingw32-libgsf-1.14.10-better-bz2-detection.patch
1 --- libgsf-1.14.10.orig/configure.in    2008-10-19 13:37:35.000000000 +0100
2 +++ libgsf-1.14.10.mingw/configure.in   2008-11-22 17:04:10.000000000 +0000
3 @@ -321,30 +321,36 @@
4  
5  with_bz2=false
6  if test "x$test_bz2" = xtrue ; then
7 -   AC_CHECK_LIB(bz2, BZ2_bzDecompressInit, 
8 -               bz2_ok=yes,
9 -               bz2_ok=no
10 -               AC_MSG_WARN(*** BZ2 support disabled (BZ2 library not found) ***))
11 -
12 -   if test "$bz2_ok" = yes; then
13 -      AC_MSG_CHECKING([for bzlib.h])
14 -      AC_PREPROC_IFELSE(
15 -       [AC_LANG_SOURCE(
16 +   dnl AC_CHECK_LIB doesn't work with the Windows port of libbz2 because
17 +   dnl it uses the __stdcall calling convention where the callee cleans
18 +   dnl up the stack.  You have to include <bzlib.h> in order to get the
19 +   dnl right calling convention, and the link fails if not.  Since we
20 +   dnl require both -lbz2 and <bzlib.h>, just test if a program which
21 +   dnl uses both can be compiled.
22 +
23 +   old_LIBS="$LIBS"
24 +   LIBS="-lbz2 $LIBS"
25 +   AC_LINK_IFELSE(
26 +     [AC_LANG_SOURCE(
27         [[#include <stdio.h>
28 -       #undef PACKAGE
29 -       #undef VERSION
30 -       #undef HAVE_STDLIB_H
31 -       #include <bzlib.h>]])],
32 -        bz2_ok=yes,
33 -        bz2_ok=no)
34 -      AC_MSG_RESULT($bz2_ok)
35 -   fi
36 +         #undef PACKAGE
37 +         #undef VERSION
38 +         #undef HAVE_STDLIB_H
39 +         #include <bzlib.h>
40 +          main ()
41 +          {
42 +            return BZ2_bzDecompressInit (NULL, 0, 0);
43 +          }
44 +        ]])],
45 +     bz2_ok=yes,
46 +     bz2_ok=no)
47 +   LIBS="$old_LIBS"
48  
49     if test "$bz2_ok" = yes; then
50         AC_DEFINE(HAVE_BZ2, 1, [Is bzip2 available and enabled])
51         BZ2_LIBS="-lbz2"
52     else
53 -       AC_MSG_WARN(*** BZ2 support disabled (BZ2 header not found) ***)
54 +       AC_MSG_WARN(*** BZ2 support disabled (BZ2 header or library not found) ***)
55     fi
56  else
57     AC_MSG_WARN([BZ2 support disabled, as requested (Use --with-bz2 to enable)])