From 2d90712ff1af589e34823d13466cdf53798be982 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Wed, 28 Aug 2013 07:31:46 +0200 Subject: [PATCH] Bug 851992 - Allow building against system ICU library. r=glandium f=gaston --- config/Makefile.in | 1 + config/system-headers | 13 ++++++++ configure.in | 16 ++++++++++ js/src/Makefile.in | 12 ++++++- js/src/config/Makefile.in | 1 + js/src/config/system-headers | 13 ++++++++ js/src/configure.in | 57 ++++++++++++++++++++-------------- js/src/gdb/Makefile.in | 4 +++ js/src/jsapi-tests/Makefile.in | 4 +++ js/src/shell/Makefile.in | 3 ++ 10 files changed, 99 insertions(+), 25 deletions(-) diff --git a/config/Makefile.in b/config/Makefile.in index 22f79bf6279..e2fafe28d12 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -98,6 +98,7 @@ export:: $(export-preqs) -DMOZ_NATIVE_JPEG=$(MOZ_NATIVE_JPEG) \ -DMOZ_NATIVE_LIBEVENT=$(MOZ_NATIVE_LIBEVENT) \ -DMOZ_NATIVE_LIBVPX=$(MOZ_NATIVE_LIBVPX) \ + -DMOZ_NATIVE_ICU=$(MOZ_NATIVE_ICU) \ $(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers $(INSTALL) system_wrappers $(DIST) diff --git a/config/system-headers b/config/system-headers index b52aed6a9f6..d99c34cc375 100644 --- a/config/system-headers +++ b/config/system-headers @@ -1132,3 +1132,16 @@ kvm.h spawn.h err.h xlocale.h +#if MOZ_NATIVE_ICU==1 +unicode/locid.h +unicode/numsys.h +unicode/ucal.h +unicode/uclean.h +unicode/ucol.h +unicode/udat.h +unicode/udatpg.h +unicode/uenum.h +unicode/unum.h +unicode/ustring.h +unicode/utypes.h +#endif diff --git a/configure.in b/configure.in index e81138257e9..536c18e067f 100644 --- a/configure.in +++ b/configure.in @@ -4114,6 +4114,22 @@ if test -n "$MOZ_NATIVE_FFI"; then MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_FFI_LIBS" fi +dnl ======================================================== +dnl System ICU Support +dnl ======================================================== +MOZ_NATIVE_ICU= +MOZ_ARG_WITH_BOOL(system-icu, +[ --with-system-icu + Use system ICU (located with pkgconfig)], + MOZ_NATIVE_ICU=1) + +if test -n "$MOZ_NATIVE_ICU"; then + PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1) + MOZ_JS_STATIC_LIBS="$MOZ_JS_STATIC_LIBS $MOZ_ICU_LIBS" +fi + +AC_SUBST(MOZ_NATIVE_ICU) + dnl ======================================================== dnl Java SDK support dnl ======================================================== diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 324e83fc8ed..820f7e8b578 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -225,12 +225,17 @@ endif # ICU headers need to be available whether we build with the complete # Internationalization API or not - ICU stubs rely on them. +ifdef MOZ_NATIVE_ICU +LOCAL_INCLUDES += $(MOZ_ICU_CFLAGS) +else LOCAL_INCLUDES += \ -I$(topsrcdir)/../../intl/icu/source/common \ -I$(topsrcdir)/../../intl/icu/source/i18n \ $(NULL) +endif ifdef ENABLE_INTL_API +ifndef MOZ_NATIVE_ICU ifeq ($(OS_ARCH),WINNT) # Parallel gmake is buggy on Windows @@ -259,6 +264,7 @@ distclean clean:: $(call SUBMAKE,$@,intl/icu) endif +endif # # END ECMAScript Internationalization API @@ -385,7 +391,11 @@ ifneq (,$(MOZ_ZLIB_LIBS)$(MOZ_GLUE_LDFLAGS)) DEFINES += -DUSE_ZLIB endif -SHARED_LIBRARY_LIBS += $(ICU_LIBS) +ifdef MOZ_NATIVE_ICU +EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS) +else +SHARED_LIBRARY_LIBS += $(MOZ_ICU_LIBS) +endif # Prevent floating point errors caused by VC++ optimizations ifdef _MSC_VER diff --git a/js/src/config/Makefile.in b/js/src/config/Makefile.in index 5f60d153439..e1fe1f8898e 100644 --- a/js/src/config/Makefile.in +++ b/js/src/config/Makefile.in @@ -59,6 +59,7 @@ export:: \ $(call mkdir_deps,system_wrappers_js) \ $(NULL) $(PYTHON) $(srcdir)/Preprocessor.py $(DEFINES) $(ACDEFINES) \ + -DMOZ_NATIVE_ICU=$(MOZ_NATIVE_ICU) \ $(srcdir)/system-headers | $(PERL) $(srcdir)/make-system-wrappers.pl system_wrappers_js $(INSTALL) system_wrappers_js $(DIST) diff --git a/js/src/config/system-headers b/js/src/config/system-headers index b52aed6a9f6..d99c34cc375 100644 --- a/js/src/config/system-headers +++ b/js/src/config/system-headers @@ -1132,3 +1132,16 @@ kvm.h spawn.h err.h xlocale.h +#if MOZ_NATIVE_ICU==1 +unicode/locid.h +unicode/numsys.h +unicode/ucal.h +unicode/uclean.h +unicode/ucol.h +unicode/udat.h +unicode/udatpg.h +unicode/uenum.h +unicode/unum.h +unicode/ustring.h +unicode/utypes.h +#endif diff --git a/js/src/configure.in b/js/src/configure.in index 5f17b3a9ca0..decfc56787c 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -4263,6 +4263,16 @@ fi dnl ======================================================== dnl ECMAScript Internationalization API Support (uses ICU) dnl ======================================================== +ICU_LIB_NAMES= +MOZ_NATIVE_ICU= +MOZ_ARG_WITH_BOOL(system-icu, +[ --with-system-icu + Use system ICU (located with pkgconfig)], + MOZ_NATIVE_ICU=1) + +if test -n "$MOZ_NATIVE_ICU"; then + PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1) +fi MOZ_ARG_WITH_STRING(intl-api, [ --with-intl-api, --with-intl-api=build, --without-intl-api @@ -4297,37 +4307,36 @@ fi dnl Settings for the implementation of the ECMAScript Internationalization API if test -n "$ENABLE_INTL_API"; then AC_DEFINE(ENABLE_INTL_API) - # We build ICU as a static library. - AC_DEFINE(U_STATIC_IMPLEMENTATION) - case "$OS_TARGET" in - WINNT) - ICU_LIB_NAMES="icuin icuuc icudt" - ;; - Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD) - ICU_LIB_NAMES="icui18n icuuc icudata" - ;; - *) - AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform]) - esac - - ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/lib)' -else - ICU_LIB_NAMES= - ICU_LIBS= + if test -z "$MOZ_NATIVE_ICU"; then + case "$OS_TARGET" in + WINNT) + ICU_LIB_NAMES="icuin icuuc icudt" + ;; + Darwin|Linux|DragonFly|FreeBSD|NetBSD|OpenBSD) + ICU_LIB_NAMES="icui18n icuuc icudata" + ;; + *) + AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform]) + esac + MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/lib)' + fi fi AC_SUBST(ENABLE_INTL_API) AC_SUBST(ICU_LIB_NAMES) -AC_SUBST(ICU_LIBS) - -dnl Source files that use ICU should have control over which parts of the ICU -dnl namespace they want to use. -AC_DEFINE(U_USING_ICU_NAMESPACE,0) - +AC_SUBST(MOZ_ICU_LIBS) +AC_SUBST(MOZ_NATIVE_ICU) dnl Settings for ICU -if test -n "$ENABLE_INTL_API" ; then +if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then + dnl We build ICU as a static library. + AC_DEFINE(U_STATIC_IMPLEMENTATION) + + dnl Source files that use ICU should have control over which parts of the ICU + dnl namespace they want to use. + AC_DEFINE(U_USING_ICU_NAMESPACE,0) + # Set ICU compile options ICU_CPPFLAGS="" # don't use icu namespace automatically in client code diff --git a/js/src/gdb/Makefile.in b/js/src/gdb/Makefile.in index 288934a4cfb..a582dfe5005 100644 --- a/js/src/gdb/Makefile.in +++ b/js/src/gdb/Makefile.in @@ -19,6 +19,10 @@ LIBS = $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(NSPR_LIBS) $(MOZ_ZLIB_LIB LOCAL_INCLUDES += -I$(topsrcdir) -I.. +ifdef MOZ_NATIVE_ICU +EXTRA_LIBS += $(MOZ_ICU_LIBS) +endif + EXTRA_LIBS += $(MOZ_FFI_LIBS) # Place a GDB Python auto-load file next to the gdb-tests executable, both diff --git a/js/src/jsapi-tests/Makefile.in b/js/src/jsapi-tests/Makefile.in index 5f7d5942a9f..10d70548683 100644 --- a/js/src/jsapi-tests/Makefile.in +++ b/js/src/jsapi-tests/Makefile.in @@ -20,6 +20,10 @@ LIBS = $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(NSPR_LIBS) $(MOZ_ZLI LOCAL_INCLUDES += -I$(topsrcdir) -I.. +ifdef MOZ_NATIVE_ICU +EXTRA_LIBS += $(MOZ_ICU_LIBS) +endif + EXTRA_LIBS += $(MOZ_FFI_LIBS) ifdef QEMU_EXE diff --git a/js/src/shell/Makefile.in b/js/src/shell/Makefile.in index 4868f3d6d2d..05f591ba183 100644 --- a/js/src/shell/Makefile.in +++ b/js/src/shell/Makefile.in @@ -27,6 +27,9 @@ LIBS = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_ ifdef MOZ_NATIVE_FFI EXTRA_LIBS += $(MOZ_FFI_LIBS) endif +ifdef MOZ_NATIVE_ICU +EXTRA_LIBS += $(MOZ_ICU_LIBS) +endif LOCAL_INCLUDES += -I$(topsrcdir) -I..