I'd like to enable native Java methods on OS X x86_64. Unfortunately the current configuration code fails to find ffi headers in Apple's standard location (/usr/include/ffi/ffi.h) so I've got a small patch for that:
ceylon:Java $ cvs diff -u configure.in jvm.c Index: configure.in =================================================================== RCS file: /pike/data/cvsroot/Pike/7.8/src/modules/Java/configure.in,v retrieving revision 1.71 diff -u -r1.71 configure.in --- configure.in 18 Jul 2008 20:23:03 -0000 1.71 +++ configure.in 28 Aug 2008 13:36:22 -0000 @@ -313,9 +313,19 @@
PIKE_PKG_CONFIG(libffi)
- AC_CHECK_HEADERS(jni.h winbase.h setjmp.h ffi.h) + # FFI on OS X (10.5 or newer) expects MACOSX defined + DO_IF_OS(Darwin, + [ + AC_SYS_COMPILER_FLAG(-DMACOSX, define_macosx, CPPFLAGS) + ]) + + AC_CHECK_HEADERS(jni.h winbase.h setjmp.h ffi.h ffi/ffi.h) AC_CHECK_TYPES([ffi_arg, ffi_sarg],,,[#ifdef HAVE_FFI_H #include <ffi.h> +#else +#ifdef HAVE_FFI_FFI_H +#include <ffi/ffi.h> +#endif #endif])
pike_cv_java=no @@ -413,7 +423,7 @@
pike_java_ffi=no AC_CHECK_LIB(ffi, ffi_prep_closure, [ - if test "$ac_cv_header_ffi_h" = yes; then + if test "$ac_cv_header_ffi_h" = yes -o "$ac_cv_header_ffi_ffi_h" = yes; then LIBS="-lffi $LIBS" JAVA_LIBS="-lffi ${JAVA_LIBS}" AC_DEFINE(HAVE_FFI) Index: jvm.c =================================================================== RCS file: /pike/data/cvsroot/Pike/7.8/src/modules/Java/jvm.c,v retrieving revision 1.91 diff -u -r1.91 jvm.c --- jvm.c 13 May 2008 16:00:07 -0000 1.91 +++ jvm.c 28 Aug 2008 13:36:22 -0000 @@ -50,6 +50,10 @@
#ifdef HAVE_FFI_H #include <ffi.h> +#else +#ifdef HAVE_FFI_FFI_H +#include <ffi/ffi.h> +#endif /* HAVE_FFI_FFI_H */ #endif /* HAVE_FFI_H */
#ifdef _REENTRANT
Roxen will need it for 7.8 so ok to commit now?
Did you check that Apple's libffi works too? ;-)
(I assume the source dist will have libffi in bundles, so using a system provided one isn't needed, but nice if it works of course.)
Yes, I did. At least it calls the Roxen example module that's written in Java.
I wrote the header inclusion so it only picks ffi/ffi.h if ffi.h cannot be found so it should behave well together with bundles.
pike-devel@lists.lysator.liu.se