Bug 305782 - "Please allow to use system bzip2 library" [p=mh+mozilla@glandium.org (Mike Hommey) r=bsmedberg a1.9=beltzner]
authorreed@reedloden.com
Sat, 08 Mar 2008 01:53:28 -0800
changeset 12778 da657b116cd01e489b748f67b3913c0b7937834b
parent 12777 e55d42dde361a6d4a9b8e75d126b2287c71f4914
child 12779 34292d5f7e6931691f8e2b06a4cdcfedc1f75a8d
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs305782
milestone1.9b5pre
Bug 305782 - "Please allow to use system bzip2 library" [p=mh+mozilla@glandium.org (Mike Hommey) r=bsmedberg a1.9=beltzner]
config/Makefile.in
config/autoconf.mk.in
config/system-headers
configure.in
extensions/metrics/build/Makefile.in
extensions/metrics/src/Makefile.in
extensions/metrics/test/Makefile.in
toolkit/mozapps/update/src/updater/Makefile.in
toolkit/mozapps/update/src/updater/updater.cpp
toolkit/toolkit-tiers.mk
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -117,16 +117,17 @@ endif
 ifdef WRAP_SYSTEM_INCLUDES
 export::
 	if test ! -d system_wrappers; then mkdir system_wrappers; fi
 	$(PERL) $(topsrcdir)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) \
 		-DBUILD_STATIC_LIBS=$(BUILD_STATIC_LIBS) \
 		-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
 		-DMOZ_ENABLE_LIBXUL=$(MOZ_ENABLE_LIBXUL) \
 		-DMOZ_NATIVE_HUNSPELL=$(MOZ_NATIVE_HUNSPELL) \
+		-DMOZ_NATIVE_BZ2=$(MOZ_NATIVE_BZ2) \
 		-DMOZ_NATIVE_ZLIB=$(MOZ_NATIVE_ZLIB) \
 		-DMOZ_NATIVE_PNG=$(MOZ_NATIVE_PNG) \
 		-DMOZ_NATIVE_JPEG=$(MOZ_NATIVE_JPEG) \
 		-DMOZ_NATIVE_LCMS=$(MOZ_NATIVE_LCMS) \
 		$(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
 	$(INSTALL) system_wrappers $(DIST)/include
 
 GARBAGE_DIRS += system_wrappers
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -207,16 +207,17 @@ NECKO_SMALL_BUFFERS = @NECKO_SMALL_BUFFE
 NECKO_COOKIES = @NECKO_COOKIES@
 MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
 
 MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
 MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
 MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
 
 MOZ_NATIVE_ZLIB	= @SYSTEM_ZLIB@
+MOZ_NATIVE_BZ2	= @SYSTEM_BZ2@
 MOZ_NATIVE_JPEG	= @SYSTEM_JPEG@
 MOZ_NATIVE_PNG	= @SYSTEM_PNG@
 MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
 
 MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
 MOZ_MATHML = @MOZ_MATHML@
 MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
 MOZ_XTF = @MOZ_XTF@
@@ -404,16 +405,26 @@ ZLIB_CFLAGS	= @MOZ_ZLIB_CFLAGS@
 ifdef MOZ_ENABLE_LIBXUL
 MOZ_ZLIB_LIBS = @MOZ_ZLIB_LIBS@
 else
 ZLIB_LIBS = @MOZ_ZLIB_LIBS@
 endif
 ZLIB_REQUIRES	= zlib
 endif
 
+ifdef MOZ_NATIVE_BZ2
+BZ2_CFLAGS	= @BZ2_CFLAGS@
+BZ2_LIBS	= @BZ2_LIBS@
+BZ2_REQUIRES	=
+else
+BZ2_CFLAGS	= @MOZ_BZ2_CFLAGS@
+BZ2_LIBS	= @MOZ_BZ2_LIBS@
+BZ2_REQUIRES	= libbz2
+endif
+
 ifdef MOZ_NATIVE_PNG
 PNG_CFLAGS	= @PNG_CFLAGS@
 PNG_LIBS	= @PNG_LIBS@
 PNG_REQUIRES	=
 else
 PNG_CFLAGS	= @MOZ_PNG_CFLAGS@
 PNG_LIBS	= @MOZ_PNG_LIBS@
 PNG_REQUIRES	= png
--- a/config/system-headers
+++ b/config/system-headers
@@ -966,8 +966,11 @@ libsn/sn-common.h
 libsn/sn-launchee.h
 libsn/sn-launcher.h
 libsn/sn-monitor.h
 libsn/sn-util.h
 #endif
 #if MOZ_NATIVE_HUNSPELL==1
 hunspell.hxx
 #endif
+#if MOZ_NATIVE_BZ2==1
+bzlib.h
+#endif
--- a/configure.in
+++ b/configure.in
@@ -916,16 +916,18 @@ WIN_TOP_SRC=
 MOZ_USER_DIR=".mozilla"
 HOST_AR='$(AR)'
 HOST_AR_FLAGS='$(AR_FLAGS)'
 
 MOZ_JPEG_CFLAGS=
 MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/jpeg)'
 MOZ_ZLIB_CFLAGS=
 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
+MOZ_BZ2_CFLAGS=
+MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
 MOZ_PNG_CFLAGS=
 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)'
 
 MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
 DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core'
 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin'
 XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom'
 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
@@ -4055,16 +4057,45 @@ CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
 if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
     ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
     ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
 fi
 
+dnl system BZIP2 Support
+dnl ========================================================
+MOZ_ARG_WITH_STRING(system-bz2,
+[  --with-system-bz2[=PFX]
+                          Use system libbz2 [installed at prefix PFX]],
+    BZ2_DIR=$withval)
+
+_SAVE_CFLAGS=$CFLAGS
+_SAVE_LDFLAGS=$LDFLAGS
+_SAVE_LIBS=$LIBS
+if test -n "${BZ2_DIR}" -a "${BZ2_DIR}" != "yes"; then
+    CFLAGS="-I${BZ2_DIR}/include $CFLAGS"
+    LDFLAGS="-L${BZ2_DIR}/lib $LDFLAGS"
+fi
+if test -z "$BZ2_DIR" -o "$BZ2_DIR" = no; then
+    SYSTEM_BZ2=
+else
+    AC_CHECK_LIB(bz2, BZ2_bzread, [SYSTEM_BZ2=1 BZ2_LIBS="-lbz2"],
+	[SYSTEM_BZ2= BZ2_CFLAGS= BZ2_LIBS=], $BZ2_LIBS)
+fi
+CFLAGS=$_SAVE_CFLAGS
+LDFLAGS=$_SAVE_LDFLAGS
+LIBS=$_SAVE_LIBS
+
+if test "${BZ2_DIR}" -a -d "${BZ2_DIR}" -a "$SYSTEM_BZ2" = 1; then
+    BZ2_CFLAGS="-I${BZ2_DIR}/include"
+    BZ2_LIBS="-L${BZ2_DIR}/lib ${MOZ_BZ2_LIBS}"
+fi
+
 dnl system PNG Support
 dnl ========================================================
 MOZ_ARG_WITH_STRING(system-png, 
 [  --with-system-png[=PFX]
                           Use system libpng [installed at prefix PFX]],
     PNG_DIR=$withval)
 
 _SAVE_CFLAGS=$CFLAGS
@@ -7679,28 +7710,33 @@ COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
 	$_DEPEND_CFLAGS \
     $COMPILE_CXXFLAGS`
 
 AC_SUBST(SYSTEM_MAKEDEPEND)
 AC_SUBST(SYSTEM_JPEG)
 AC_SUBST(SYSTEM_PNG)
 AC_SUBST(SYSTEM_ZLIB)
+AC_SUBST(SYSTEM_BZ2)
 
 AC_SUBST(JPEG_CFLAGS)
 AC_SUBST(JPEG_LIBS)
 AC_SUBST(ZLIB_CFLAGS)
 AC_SUBST(ZLIB_LIBS)
+AC_SUBST(BZ2_CFLAGS)
+AC_SUBST(BZ2_LIBS)
 AC_SUBST(PNG_CFLAGS)
 AC_SUBST(PNG_LIBS)
 
 AC_SUBST(MOZ_JPEG_CFLAGS)
 AC_SUBST(MOZ_JPEG_LIBS)
 AC_SUBST(MOZ_ZLIB_CFLAGS)
 AC_SUBST(MOZ_ZLIB_LIBS)
+AC_SUBST(MOZ_BZ2_CFLAGS)
+AC_SUBST(MOZ_BZ2_LIBS)
 AC_SUBST(MOZ_PNG_CFLAGS)
 AC_SUBST(MOZ_PNG_LIBS)
 
 AC_SUBST(NSPR_CFLAGS)
 AC_SUBST(NSPR_LIBS)
 AC_SUBST(MOZ_NATIVE_NSPR)
 
 AC_SUBST(NSS_CFLAGS)
--- a/extensions/metrics/build/Makefile.in
+++ b/extensions/metrics/build/Makefile.in
@@ -56,28 +56,28 @@ REQUIRES	= \
 		$(NULL)
 
 CPPSRCS		= \
 		nsMetricsModule.cpp \
 		$(NULL)
 
 SHARED_LIBRARY_LIBS = \
 		../src/$(LIB_PREFIX)metrics_s.$(LIB_SUFFIX) \
-		$(DEPTH)/modules/libbz2/src/$(LIB_PREFIX)bz2.$(LIB_SUFFIX) \
 		$(NULL)
 
 EXTRA_DSO_LDOPTS = $(XPCOM_GLUE_LDOPTS) \
 		   $(NSPR_LIBS) \
+		   $(BZ2_LIBS) \
 		   $(NULL)
 
 LOCAL_INCLUDES	= \
 		-I$(srcdir)/../src \
 		-I$(DIST)/public/nss \
 		-I$(DIST)/private/nss \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
   LDFLAGS += -NODEFAULTLIB:MSVCRT
 endif
 
-
+CXXFLAGS += $(BZ2_CFLAGS)
--- a/extensions/metrics/src/Makefile.in
+++ b/extensions/metrics/src/Makefile.in
@@ -52,17 +52,17 @@ REQUIRES	= xpcom \
 		  string \
 		  necko \
 		  pref \
 		  uriloader \
 		  dom \
 		  docshell \
 		  layout \
 		  widget \
-		  libbz2 \
+		  $(BZ2_REQUIRES) \
 		  xulapp \
 		  extensions \
 		  rdf \
 		  plugin \
 		  content \
 		  autocomplete \
 		  places \
 		  toolkitcomps \
--- a/extensions/metrics/test/Makefile.in
+++ b/extensions/metrics/test/Makefile.in
@@ -62,25 +62,27 @@ LOCAL_INCLUDES	= \
 		-I$(srcdir)/../src \
 		-I$(srcdir)/../build \
 		-I$(DIST)/public/nss \
 		-I$(DIST)/private/nss \
 		$(NULL)
 
 LIBS		= \
 		../src/$(LIB_PREFIX)metrics_s.$(LIB_SUFFIX) \
-		$(DEPTH)/modules/libbz2/src/$(LIB_PREFIX)bz2.$(LIB_SUFFIX) \
+		$(BZ2_LIBS) \
 		$(XPCOM_GLUE_LDOPTS) \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 XPCSHELL_TESTS = unit
 
 include $(topsrcdir)/config/rules.mk
 
+CXXFLAGS += $(BZ2_CFLAGS)
+
 # Give the unit tests absolute paths to the data and temp directories.
 # For cygwin, we need to convert the paths to native Windows paths.
 ifdef CYGWIN_WRAPPER
 TESTDATA_DIR := `cygpath -wa $(srcdir)/data`
 TEST_TMPDIR := `cygpath -wa .`
 else
 TESTDATA_DIR := `cd $(srcdir)/data; pwd`
 TEST_TMPDIR := `pwd`
--- a/toolkit/mozapps/update/src/updater/Makefile.in
+++ b/toolkit/mozapps/update/src/updater/Makefile.in
@@ -49,22 +49,22 @@ CPPSRCS = \
 	bspatch.cpp \
 	archivereader.cpp \
 	$(NULL)
 
 PROGRAM = updater$(BIN_SUFFIX)
 
 REQUIRES	= \
 		libmar \
-		libbz2 \
+		$(BZ2_REQUIRES) \
 		$(NULL)
 
 LIBS += \
 	$(DEPTH)/modules/libmar/src/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \
-	$(DEPTH)/modules/libbz2/src/$(LIB_PREFIX)bz2.$(LIB_SUFFIX) \
+	$(BZ2_LIBS) \
 	$(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 USE_STATIC_LIBS = 1
 HAVE_PROGRESSUI = 1
 RCINCLUDE = updater.rc
 CPPSRCS += progressui_win.cpp
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32 shell32)
@@ -125,8 +125,10 @@ libs::
 	rm -f $(DIST)/bin/updater
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 # Pick up nsWindowsRestart.cpp
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
 REQUIRES += string
 endif
+
+CXXFLAGS += $(BZ2_CFLAGS)
--- a/toolkit/mozapps/update/src/updater/updater.cpp
+++ b/toolkit/mozapps/update/src/updater/updater.cpp
@@ -133,17 +133,21 @@ void LaunchChild(int argc, char **argv);
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
 #define USE_EXECV
 #endif
 
 //-----------------------------------------------------------------------------
 
 // This variable lives in libbz2.  It's declared in bzlib_private.h, so we just
 // declare it here to avoid including that entire header file.
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
+extern "C"  __attribute__((visibility("default"))) unsigned int BZ2_crc32Table[256];
+#else
 extern "C" unsigned int BZ2_crc32Table[256];
+#endif
 
 static unsigned int
 crc32(const unsigned char *buf, unsigned int len)
 {
   unsigned int crc = 0xffffffffL;
 
   const unsigned char *end = buf + len;
   for (; buf != end; ++buf)
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -59,17 +59,19 @@ tier_external_dirs	+= jpeg
 endif
 
 # Installer needs standalone libjar, hence standalone zlib
 ifdef MOZ_INSTALLER
 tier_external_dirs	+= modules/zlib/standalone
 endif
 
 ifdef MOZ_UPDATER
+ifndef MOZ_NATIVE_BZ2
 tier_external_dirs += modules/libbz2
+endif
 tier_external_dirs += modules/libmar
 endif
 
 ifndef MOZ_NATIVE_LCMS
 tier_external_dirs	+= modules/lcms
 endif
 
 #