From: Mike Hommey Date: Tue, 9 Mar 2010 09:44:37 +0100 Subject: Allow to build against system libffi https://bugzilla.mozilla.org/show_bug.cgi?id=551138 --- js/src/Makefile.in | 16 ++++++++++++++-- js/src/config/autoconf.mk.in | 4 ++++ js/src/configure.in | 14 +++++++++++++- js/src/shell/Makefile.in | 3 +++ 4 files changed, 34 insertions(+), 3 deletions(-) --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -453,11 +453,20 @@ CPPSRCS += \ Library.cpp \ $(NULL) -LOCAL_INCLUDES = \ - -Ictypes/libffi/include \ +ifdef MOZ_NATIVE_FFI +LOCAL_INCLUDES = $(MOZ_FFI_CFLAGS) +else +LOCAL_INCLUDES = -Ictypes/libffi/include +endif + +LOCAL_INCLUDES += \ -I. \ $(NULL) + +ifdef MOZ_NATIVE_FFI +EXTRA_DSO_LDOPTS += $(MOZ_FFI_LIBS) +else ifeq ($(OS_ARCH),OS2) SHARED_LIBRARY_LIBS += \ ctypes/libffi/.libs/ffi.a \ @@ -467,6 +476,7 @@ SHARED_LIBRARY_LIBS += \ ctypes/libffi/.libs/libffi.$(LIB_SUFFIX) \ $(NULL) endif +endif endif # JS_HAS_CTYPES @@ -546,6 +556,7 @@ endif include $(topsrcdir)/config/rules.mk ifdef JS_HAS_CTYPES +ifndef MOZ_NATIVE_FFI # Build libffi proper as part of the 'exports' target, so things get built # in the right order. export:: @@ -554,6 +565,7 @@ export:: distclean clean:: $(call SUBMAKE,$@,ctypes/libffi) endif +endif ifdef MOZ_SYNC_BUILD_FILES # Because the SpiderMonkey can be distributed and built independently --- a/js/src/config/autoconf.mk.in +++ b/js/src/config/autoconf.mk.in @@ -250,6 +250,10 @@ NSPR_CONFIG = @NSPR_CONFIG@ NSPR_CFLAGS = @NSPR_CFLAGS@ NSPR_LIBS = @NSPR_LIBS@ +MOZ_NATIVE_FFI = @MOZ_NATIVE_FFI@ +MOZ_FFI_LIBS = @MOZ_FFI_LIBS@ +MOZ_FFI_CFLAGS = @MOZ_FFI_CFLAGS@ + USE_DEPENDENT_LIBS = @USE_DEPENDENT_LIBS@ JS_NATIVE_EDITLINE = @JS_NATIVE_EDITLINE@ --- a/js/src/configure.in +++ b/js/src/configure.in @@ -4591,6 +4591,18 @@ if test -n "$MOZ_NATIVE_NSPR"; then CFLAGS=$_SAVE_CFLAGS fi +dnl system libffi Support +dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(system-ffi, +[ --enable-system-ffi Use system libffi (located with pkgconfig)], + MOZ_NATIVE_FFI=1 ) + +if test -n "$MOZ_NATIVE_FFI"; then + PKG_CHECK_MODULES(MOZ_FFI, libffi) +fi + +AC_SUBST(MOZ_NATIVE_FFI) + dnl ======================================================== dnl = dnl = Application @@ -6074,7 +6086,7 @@ AC_MSG_RESULT(invoking make to create js $GMAKE js-config # Build jsctypes if it's enabled. -if test "$JS_HAS_CTYPES"; then +if test "$JS_HAS_CTYPES" -a -z "$MOZ_NATIVE_FFI"; then # Run the libffi 'configure' script. ac_configure_args="--disable-shared --enable-static --disable-raw-api" if test "$MOZ_DEBUG"; then --- a/js/src/shell/Makefile.in +++ b/js/src/shell/Makefile.in @@ -53,6 +53,9 @@ CPPSRCS = \ DEFINES += -DEXPORT_JS_API LIBS = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) +ifdef MOZ_NATIVE_FFI +EXTRA_LIBS += $(MOZ_FFI_LIBS) +endif LOCAL_INCLUDES += -I$(topsrcdir) -I..