[libgsf PATCH] Support cross-compilation under Fedora MinGW
Richard W.M. Jones
rjones at redhat.com
Sat Nov 22 21:55:51 UTC 2008
Hi,
I'm from the Fedora MinGW project (http://fedoraproject.org/wiki/MinGW),
and we are cross-compiling a number of Linux libraries, from Fedora
targeting Windows. So I hope this is the right place to post a couple
of libgsf patches which enable libgsf to be cross-compiled using
Fedora MinGW cross-compiler.
The first patch changes the way that libbz2 / bzlib.h is detected. It
is my understanding that both the library and the header file are
needed in order to enable BZ2 support. However autoconf's
AC_CHECK_LIB cannot be used to check whether -lbz2 works on its own on
Windows, for rather complex reasons which are better explained by
referring to this thread:
http://www.nabble.com/failed-tests-AC_CHECK_LIB-td19588119.html#a19589469
So the first patch replaces the pair of tests with an invocation of
AC_LINK_IFELSE that tries to compile and link a program with both the
header file and a call to the sentinel library function.
The second patch, considerably simpler, enables deprecated functions
in glib, because otherwise G_WIN32_DLLMAIN_FOR_DLL_NAME isn't defined
in gsf/gsf-utils.c. I'm not really familiar with what this macro
does, and maybe a better solution is just to not use it if the macro
isn't defined.
Here is our development repository:
http://hg.et.redhat.com/misc/fedora-mingw--devel
If we make any updates then you can get the latest specfile and
patches by clicking 'manifest', then 'libgsf'.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
Read my OCaml programming blog: http://camltastic.blogspot.com/
Fedora now supports 68 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
-------------- next part --------------
--- libgsf-1.14.10.orig/configure.in 2008-10-19 13:37:35.000000000 +0100
+++ libgsf-1.14.10.mingw/configure.in 2008-11-22 17:04:10.000000000 +0000
@@ -321,30 +321,36 @@
with_bz2=false
if test "x$test_bz2" = xtrue ; then
- AC_CHECK_LIB(bz2, BZ2_bzDecompressInit,
- bz2_ok=yes,
- bz2_ok=no
- AC_MSG_WARN(*** BZ2 support disabled (BZ2 library not found) ***))
-
- if test "$bz2_ok" = yes; then
- AC_MSG_CHECKING([for bzlib.h])
- AC_PREPROC_IFELSE(
- [AC_LANG_SOURCE(
+ dnl AC_CHECK_LIB doesn't work with the Windows port of libbz2 because
+ dnl it uses the __stdcall calling convention where the callee cleans
+ dnl up the stack. You have to include <bzlib.h> in order to get the
+ dnl right calling convention, and the link fails if not. Since we
+ dnl require both -lbz2 and <bzlib.h>, just test if a program which
+ dnl uses both can be compiled.
+
+ old_LIBS="$LIBS"
+ LIBS="-lbz2 $LIBS"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(
[[#include <stdio.h>
- #undef PACKAGE
- #undef VERSION
- #undef HAVE_STDLIB_H
- #include <bzlib.h>]])],
- bz2_ok=yes,
- bz2_ok=no)
- AC_MSG_RESULT($bz2_ok)
- fi
+ #undef PACKAGE
+ #undef VERSION
+ #undef HAVE_STDLIB_H
+ #include <bzlib.h>
+ main ()
+ {
+ return BZ2_bzDecompressInit (NULL, 0, 0);
+ }
+ ]])],
+ bz2_ok=yes,
+ bz2_ok=no)
+ LIBS="$old_LIBS"
if test "$bz2_ok" = yes; then
AC_DEFINE(HAVE_BZ2, 1, [Is bzip2 available and enabled])
BZ2_LIBS="-lbz2"
else
- AC_MSG_WARN(*** BZ2 support disabled (BZ2 header not found) ***)
+ AC_MSG_WARN(*** BZ2 support disabled (BZ2 header or library not found) ***)
fi
else
AC_MSG_WARN([BZ2 support disabled, as requested (Use --with-bz2 to enable)])
-------------- next part --------------
--- libgsf-1.14.10.orig/gsf/gsf-utils.c 2008-07-01 13:56:53.000000000 +0100
+++ libgsf-1.14.10.mingw/gsf/gsf-utils.c 2008-11-22 17:01:35.000000000 +0000
@@ -19,6 +19,11 @@
* USA
*/
+/* Needed for G_WIN32_DLLMAIN_FOR_DLL_NAME below. Maybe a better
+ * solution would be to remove that macro use instead.
+ */
+#undef G_DISABLE_DEPRECATED
+
#include <gsf-config.h>
#include <gsf/gsf-utils.h>
#include <gsf/gsf-input.h>
More information about the mingw
mailing list