This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
libmagic configury foobar
- From: Andrew Haley <aph at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 17 Nov 2006 19:47:38 +0000
- Subject: libmagic configury foobar
We were checking for magic.h but not for the linkability of libmagic.
This is wrong: we might well have libmagic headers but not have
libmagic.so for every arch.
Andrew.
2006-11-17 Andrew Haley <aph@redhat.com>
* java/net/natVMURLConnection.cc: Check for HAVE_MAGIC_OPEN.
* configure.ac: Add HAVE_MAGIC_OPEN.
* include/config.h.in: Regenerated.
Index: configure.ac
===================================================================
--- configure.ac (revision 118943)
+++ configure.ac (working copy)
@@ -1216,7 +1216,9 @@
fi
LIBMAGIC=
- AC_CHECK_LIB(magic, magic_open, LIBMAGIC=-lmagic)
+ AC_CHECK_LIB(magic, magic_open, [
+ AC_DEFINE([HAVE_MAGIC_OPEN], 1, [Define if you have magic_open().])
+ LIBMAGIC="-lmagic"])
AC_SUBST(LIBMAGIC)
# Test for Gtk stuff, if asked for.
Index: include/config.h.in
===================================================================
--- include/config.h.in (revision 118943)
+++ include/config.h.in (working copy)
@@ -187,6 +187,9 @@
/* Define to 1 if you have the <magic.h> header file. */
#undef HAVE_MAGIC_H
+/* Define if you have magic_open(). */
+#undef HAVE_MAGIC_OPEN
+
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
Index: java/net/natVMURLConnection.cc
===================================================================
--- java/net/natVMURLConnection.cc (revision 118943)
+++ java/net/natVMURLConnection.cc (working copy)
@@ -12,18 +12,18 @@
#include <gcj/cni.h>
#include <java/lang/UnsupportedOperationException.h>
-#ifdef HAVE_MAGIC_H
+#if defined (HAVE_MAGIC_H) && defined (HAVE_MAGIC_OPEN)
#include <magic.h>
static magic_t cookie;
-#endif /* HAVE_MAGIC_H */
+#endif /* HAVE_MAGIC_H && HAVE_MAGIC_OPEN */
void
java::net::VMURLConnection::init ()
{
-#ifdef HAVE_MAGIC_H
+#if defined (HAVE_MAGIC_H) && defined (HAVE_MAGIC_OPEN)
cookie = magic_open (MAGIC_MIME);
if (cookie == (magic_t) NULL)
return;
@@ -32,14 +32,14 @@
magic_close (cookie);
cookie = (magic_t) NULL;
}
-#endif /* HAVE_MAGIC_H */
+#endif /* HAVE_MAGIC_H && HAVE_MAGIC_OPEN */
}
::java::lang::String *
java::net::VMURLConnection::guessContentTypeFromBuffer (jbyteArray bytes,
jint valid)
{
-#ifdef HAVE_MAGIC_H
+#if defined (HAVE_MAGIC_H) && defined (HAVE_MAGIC_OPEN)
const char *result;
if (cookie == (magic_t) NULL)
@@ -52,5 +52,5 @@
return _Jv_NewStringUTF (result);
#else
return NULL;
-#endif /* HAVE_MAGIC_H */
+#endif /* HAVE_MAGIC_H && HAVE_MAGIC_OPEN */
}