Index: mozilla/config/autoconf.mk.in
===================================================================
RCS file: /cvsroot/mozilla/config/autoconf.mk.in,v
retrieving revision 3.310.2.1
diff -u -8 -p -r3.310.2.1 autoconf.mk.in
--- mozilla/config/autoconf.mk.in	12 Oct 2004 04:13:31 -0000	3.310.2.1
+++ mozilla/config/autoconf.mk.in	11 Jun 2005 04:55:00 -0000
@@ -271,16 +271,17 @@ RANLIB		= @RANLIB@
 WHOAMI		= @WHOAMI@
 UNZIP		= @UNZIP@
 ZIP		= @ZIP@
 XARGS		= @XARGS@
 STRIP		= @STRIP@
 DOXYGEN		= @DOXYGEN@
 MAKE		= @MAKE@
 PBBUILD_BIN	= @PBBUILD@
+SDP		= @SDP@
 
 ifdef MOZ_NATIVE_JPEG
 JPEG_CFLAGS	= @JPEG_CFLAGS@
 JPEG_LIBS	= @JPEG_LIBS@
 JPEG_REQUIRES	=
 else
 JPEG_CFLAGS	= @MOZ_JPEG_CFLAGS@
 JPEG_LIBS	= @MOZ_JPEG_LIBS@
Index: mozilla/configure.in
===================================================================
RCS file: /cvsroot/mozilla/configure.in,v
retrieving revision 1.1335.2.11
diff -u -8 -p -r1.1335.2.11 configure.in
--- mozilla/configure.in	12 Oct 2004 04:13:29 -0000	1.1335.2.11
+++ mozilla/configure.in	11 Jun 2005 04:55:02 -0000
@@ -24,16 +24,18 @@ dnl               Ramiro Estrugo <ramiro
 dnl                 X11 makedepend support
 dnl                 Insure support.
 dnl               Henry Sobotka <sobotka@axess.com>
 dnl                 OS/2 support
 dnl               Dan Mosedale <dmose@mozilla.org>
 dnl                 LDAP support
 dnl               Seth Spitzer <sspitzer@netscape.com>
 dnl                 xpctools support
+dnl               Mark Mentovai <mark@moxienet.com>:
+dnl                 Mac OS X 10.4 support
 dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl ========================================================
 
 AC_PREREQ(2.12)
 AC_INIT(config/config.mk)
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_SYSTEM
@@ -421,36 +423,16 @@ if test "$CC" != "icc" -a -z "$_WIN32_MS
 fi
 
 AC_SUBST(GNU_AS)
 AC_SUBST(GNU_LD)
 AC_SUBST(GNU_CC)
 AC_SUBST(GNU_CXX)
 
 dnl ========================================================
-dnl = Mac OS X SDK support
-dnl ========================================================
-MACOS_SDK_DIR=
-MOZ_ARG_WITH_STRING(macos-sdk,
-[  --with-macos-sdk=dir   Location of platform SDK to use (Mac OS X only)],
-    MACOS_SDK_DIR=$withval)
-
-AC_SUBST(MACOS_SDK_DIR)
-
-if test "$MACOS_SDK_DIR"; then
-  export NEXT_ROOT=$MACOS_SDK_DIR
-  CFLAGS="-I${MACOS_SDK_DIR}/usr/include $CFLAGS"
-  CXXFLAGS="-I${MACOS_SDK_DIR}/usr/include $CXXFLAGS"
-  changequote(,)
-  GCC_VERSION=`echo $CXX_VERSION | perl -pe "s/gcc version ([^ ]*).*/\1/"`
-  changequote([,])
-  LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION} -L${MACOS_SDK_DIR}/usr/lib $LIBS"
-fi
-
-dnl ========================================================
 dnl Checks for programs.
 dnl ========================================================
 AC_PROG_CPP
 AC_PROG_CXXCPP
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PATH_PROGS(PERL, $PERL perl5 perl )
 if test -z "$PERL" || test "$PERL" = ":"; then
@@ -484,22 +466,89 @@ AC_PATH_PROGS(ZIP, zip)
 if test -z "$ZIP" || test "$ZIP" = ":"; then
     AC_MSG_ERROR([zip not found in \$PATH])
 fi
 AC_PATH_PROG(SYSTEM_MAKEDEPEND, makedepend)
 AC_PATH_PROG(XARGS, xargs)
 if test -z "$XARGS" || test "$XARGS" = ":"; then
     AC_MSG_ERROR([xargs not found in \$PATH .])
 fi
+
+dnl ========================================================
+dnl = Mac OS X toolchain support
+dnl ========================================================
+
 case "$target_os" in
 darwin*)
+    dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0.
+    dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for
+    dnl the environment and includedir purposes (when using an SDK, below),
+    dnl but remember the full version number for the libdir (SDK).
+    changequote(,)
+    GCC_VERSION_FULL=`echo $CXX_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'`
+    GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'`
+    changequote([,])
+
     AC_PATH_PROGS(PBBUILD, pbbuild xcodebuild pbxbuild)
+
+    dnl sdp was formerly in /Developer/Tools.  As of Mac OS X 10.4 (Darwin 8),
+    dnl it has moved into /usr/bin.
+    AC_PATH_PROG(SDP, sdp, :, [$PATH:/usr/bin:/Developer/Tools])
     ;;
 esac
 
+dnl ========================================================
+dnl = Mac OS X SDK support
+dnl ========================================================
+MACOS_SDK_DIR=
+MOZ_ARG_WITH_STRING(macos-sdk,
+[  --with-macos-sdk=dir   Location of platform SDK to use (Mac OS X only)],
+    MACOS_SDK_DIR=$withval)
+
+AC_SUBST(MACOS_SDK_DIR)
+
+if test "$MACOS_SDK_DIR"; then
+  export NEXT_ROOT=$MACOS_SDK_DIR
+
+  dnl Sync this block with the NEXT_ROOT block in nsprpub/configure.in
+  dnl
+  dnl Changes to the cross environment here need to be accounted for in
+  dnl the libIDL checks (below) and xpidl build.
+
+  GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'`
+  if test "$GCC_VERSION_MAJOR" -lt "4" ; then
+    TARGET_ARCH_LIB="darwin"
+    TARGET_ARCH_INCLUDE="ppc-darwin"
+    SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include -F${MACOS_SDK_DIR}/System/Library/Frameworks"
+  else
+    dnl If gcc >= 4, use powerpc-apple-darwin#, where # is the version of
+    dnl the Darwin release corresponding to the target Mac OS X release.
+    dnl For OS X >= 10.1.1, take the minor version number and add 4 to get
+    dnl the Darwin major version number.  If it can't be determined, use the
+    dnl current Darwin major version number and hope that there's a symlink.
+    TARGET_ARCH_LIB=powerpc-apple-darwin`echo $MACOS_SDK_DIR | $PERL -pe 's/MacOSX10\.([^\.]*)//;if ($1) {$_=$1+4;} else {$_="'${target_os}'";s/(\d+)//;$_=$1;}'`
+    TARGET_ARCH_INCLUDE=$TARGET_ARCH_LIB
+    SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL}/include -isystem ${MACOS_SDK_DIR}/usr/include -F${MACOS_SDK_DIR}/System/Library/Frameworks"
+  fi
+
+  if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then
+    SDK_C_INCLUDE="$SDK_C_INCLUDE -F${MACOS_SDK_DIR}/Library/Frameworks"
+  fi
+
+  SDK_CXX_INCLUDE="-I${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION}/c++ -I${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION}/c++/${TARGET_ARCH_INCLUDE} -I${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION}/c++/backward"
+  CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}"
+  CXXFLAGS="$CXXFLAGS -nostdinc -nostdinc++ ${SDK_CXX_INCLUDE} ${SDK_C_INCLUDE}"
+
+  dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER.
+  CPP="$CPP -nostdinc ${SDK_C_INCLUDE}"
+  CXXCPP="$CXXCPP -nostdinc -nostdinc++ ${SDK_CXX_INCLUDE} ${SDK_C_INCLUDE}"
+
+  LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/${TARGET_ARCH_LIB} -L${MACOS_SDK_DIR}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib $LIBS"
+fi
+
 dnl Be sure the make we use is GNU make.
 dnl on win32, gmake.exe is the generally the wrong version
 case "$target_os" in
 cygwin*|mingw*|mks*|msvc*)
     AC_PATH_PROGS(MAKE, $MAKE make gmake, :)
     ;;
 *)
     AC_PATH_PROGS(MAKE, $MAKE gmake make, :)
@@ -3779,82 +3828,92 @@ dnl ====================================
 if test -n "$USE_GSSAPI" && test `echo "$MOZ_EXTENSIONS" | grep -c negotiateauth` -ne 0; then
     dnl
     dnl Check for alternative location for GSSAPI libraries.
     dnl
     MOZ_ARG_WITH_STRING(gssapi,
         [  --with-gssapi=PFX	   Location of GSSAPI libraries],
         GSSAPI_DIR=$withval)
 
-    dnl
-    dnl If not specified, assume GSSAPI lives under /usr
-    dnl
     if test -z "$GSSAPI_DIR"; then
         dnl
         dnl RedHat Linux 7, 8, and 9 install GSSAPI headers and libraries under
         dnl /usr/kerberos -- perhaps other platforms do the same.  If not, then
         dnl we count on the default search paths.  Fedora Core 1, at least,
         dnl puts the headers and libraries under /usr, but it still has
         dnl /usr/kerberos for the other KRB5 components.
         dnl
         if test -d "/usr/kerberos/include"; then
             GSSAPI_DIR="/usr/kerberos"
-        else
-            GSSAPI_DIR="/usr"
         fi
     fi
 
+    dnl
+    dnl If not specified, assume GSSAPI is in the system directories
+    dnl
+    if test -n "$GSSAPI_DIR"; then
+        _GSSAPI_INC="-I$GSSAPI_DIR/include"
+        _GSSAPI_LIB="-L$GSSAPI_DIR/lib"
+    else
+        _GSSAPI_INC=
+        _GSSAPI_LIB=
+    fi
+
     _SAVE_CPPFLAGS="$CPPFLAGS"
     _SAVE_LDFLAGS="$LDFLAGS"
     _SAVE_LIBS="$LIBS"
 
-    CPPFLAGS="$CPPFLAGS -I$GSSAPI_DIR/include"
-    LDFLAGS="$LDFLAGS -L$GSSAPI_DIR/lib"
+    CPPFLAGS="$CPPFLAGS $_GSSAPI_INC"
+    LDFLAGS="$LDFLAGS $_GSSAPI_LIB"
 
     dnl
     dnl Try to set GSSAPI_INCLUDES ...
     dnl
     AC_CHECK_HEADERS(gssapi.h,
-        [GSSAPI_INCLUDES="-I$GSSAPI_DIR/include"])
+        [GSSAPI_INCLUDES="$_GSSAPI_INC"])
     if test -z "$GSSAPI_INCLUDES" ; then
         AC_CHECK_HEADERS(gssapi/gssapi.h,
-            [GSSAPI_INCLUDES="-I$GSSAPI_DIR/include"])
+            [GSSAPI_INCLUDES="$_GSSAPI_INC"])
     fi
     CPPFLAGS="$_SAVE_CPPFLAGS $GSSAPI_INCLUDES"
 
     dnl
     dnl Try to set GSSAPI_LIBS ...
     dnl
     AC_CHECK_LIB(gss, gss_init_sec_context,
-        [GSSAPI_LIBS="-L$GSSAPI_DIR/lib -lgss"],)
+        [GSSAPI_LIBS="$_GSSAPI_LIB -lgss"],)
 
     dnl
     dnl If libgss was not found, look for the MIT Kerberos V5 GSSAPI
     dnl libraries instead.
     dnl
     if test -z "$GSSAPI_LIBS" ; then
         dnl
         dnl We only need to link to libgssapi_krb5.so
         dnl
-        _GSS_LIBS="-L$GSSAPI_DIR/lib -lgssapi_krb5"
+        _GSS_LIBS="$_GSSAPI_LIB -lgssapi_krb5"
         LIBS="$LIBS $_GSS_LIBS"
         AC_CHECK_FUNC(gss_init_sec_context, 
             [GSSAPI_LIBS="$_GSS_LIBS"],)
         LIBS="$_SAVE_LIBS"
     fi
 
     dnl
     dnl If GSS libs were STILL not found, try looking for Heimdal
     dnl Kerberos V5 libraries.
     dnl
     if test -z "$GSSAPI_LIBS" ; then
-        if test -x "$GSSAPI_DIR/bin/krb5-config" ; then
-            krb5cfg="$GSSAPI_DIR/bin/krb5-config"
-            TMP_GSSAPI_LIBS=`$krb5cfg --libs gssapi 2>/dev/null`
-            TMP_GSSAPI_INCLUDES=`$krb5cfg --cflags gssapi 2>/dev/null`
+        if test -n "$GSSAPI_DIR" ; then
+            AC_PATH_PROG(KRB5CONFIG, krb5-config, :, [$GSSAPI_DIR/bin:$PATH:/usr/bin])
+        else
+            AC_PATH_PROG(KRB5CONFIG, krb5-config, :, [$PATH:/usr/bin])
+        fi
+        if test -n "$KRB5CONFIG" -a -x "$KRB5CONFIG" ; then
+            TMP_GSSAPI_LIBS=`$KRB5CONFIG --libs gssapi 2>/dev/null`
+            TMP_GSSAPI_INCLUDES=`$KRB5CONFIG --cflags gssapi 2>/dev/null`
 
             LIBS="$LIBS $TMP_GSSAPI_LIBS"
             AC_CHECK_LIB(gssapi, gss_init_sec_context,
                 [GSSAPI_LIBS="$TMP_GSSAPI_LIBS"
                  GSSAPI_INCLUDES="$TMP_GSSAPI_INCLUDES"],
                 [GSSAPI_LIBS=""])
 
             CPPFLAGS="$_SAVE_CPPFLAGS $GSSAPI_INCLUDES"
@@ -5064,17 +5123,23 @@ dnl = Allow users to disable libIDL chec
 MOZ_ARG_WITHOUT_BOOL(libIDL,
 [  --without-libIDL        Skip check for libIDL (standalone modules only)],
 	SKIP_IDL_CHECK="yes")
 
 if test "$SKIP_IDL_CHECK" = "no"
 then
     _LIBIDL_FOUND=
     if test "$MACOS_SDK_DIR"; then 
+      dnl xpidl, and therefore libIDL, is only needed on the build host.
+      dnl Don't build it against the SDK, as that causes problems.
+      _MACSAVE_CFLAGS="$CFLAGS"
+      _MACSAVE_LIBS="$LIBS"
+      _MACSAVE_NEXT_ROOT="$NEXT_ROOT"
       changequote(,)
+      CFLAGS=`echo $CFLAGS|sed -E -e "s%((-I|-isystem )${MACOS_SDK_DIR}/usr/(include|lib/gcc)[^ ]*)|-F${MACOS_SDK_DIR}(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*%%g"`
       LIBS=`echo $LIBS|sed -e "s?-L${MACOS_SDK_DIR}/usr/lib[^ ]*??g"`
       changequote([,])
       unset NEXT_ROOT
     fi
 
     if test "$MOZ_ENABLE_GTK2"; then
         PKG_CHECK_MODULES(LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1)
     fi
@@ -5098,18 +5163,19 @@ then
             _LIBIDL_FOUND=1
         fi
     fi
     if test -z "$_LIBIDL_FOUND"; then
         AC_MSG_ERROR([libIDL not found.
         libIDL $LIBIDL_VERSION or higher is required.])
     fi
     if test "$MACOS_SDK_DIR"; then
-      LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION} -L${MACOS_SDK_DIR}/usr/lib $LIBS"
-      export NEXT_ROOT=$MACOS_SDK_DIR
+      CFLAGS="$_MACSAVE_CFLAGS"
+      LIBS="$_MACSAVE_LIBS"
+      export NEXT_ROOT="$_MACSAVE_NEXT_ROOT"
     fi
 fi
 
 if test -n "$CROSS_COMPILE"; then
     if test -z "$HOST_LIBIDL_CONFIG"; then
         HOST_LIBIDL_CONFIG="$LIBIDL_CONFIG"
     fi
     if test -n "$HOST_LIBIDL_CONFIG"; then
Index: mozilla/gfx/src/mac/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/gfx/src/mac/Makefile.in,v
retrieving revision 1.29.4.1
diff -u -8 -p -r1.29.4.1 Makefile.in
--- mozilla/gfx/src/mac/Makefile.in	7 Jun 2004 18:37:02 -0000	1.29.4.1
+++ mozilla/gfx/src/mac/Makefile.in	11 Jun 2005 04:55:02 -0000
@@ -73,19 +73,19 @@ CPPSRCS = \
 
 SHARED_LIBRARY_LIBS = $(DIST)/lib/$(LIB_PREFIX)gfxshared_s.$(LIB_SUFFIX)
 EXTRA_DSO_LIBS = mozutil_s gkgfx
 EXTRA_DEPS = $(DIST)/lib/$(LIB_PREFIX)mozutil_s.$(LIB_SUFFIX)
 
 EXTRA_DSO_LDOPTS = \
 	$(LIBS_DIR) \
 	$(EXTRA_DSO_LIBS) \
-	$(TK_LIBS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(MOZ_UNICHARUTIL_LIBS) \
+	$(TK_LIBS) \
 	$(NULL)
 
 LOCAL_INCLUDES	= \
 		-I$(srcdir)/../shared \
 		-I$(srcdir)/.. \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
Index: mozilla/modules/libreg/src/vr_stubs.c
===================================================================
RCS file: /cvsroot/mozilla/modules/libreg/src/vr_stubs.c,v
retrieving revision 3.34
diff -u -8 -p -r3.34 vr_stubs.c
--- mozilla/modules/libreg/src/vr_stubs.c	21 Sep 2003 04:53:14 -0000	3.34
+++ mozilla/modules/libreg/src/vr_stubs.c	11 Jun 2005 04:55:02 -0000
@@ -503,31 +503,31 @@ extern int nr_RenameFile(char *from, cha
         errno = err;
 #endif
     return (err == noErr ? 0 : -1);
 }
 #endif
 
 
 #ifdef STANDALONE_REGISTRY
+#ifndef XP_MACOSX
 char *strdup(const char *source)
 {
         char    *newAllocation;
         size_t  stringLength;
 
         stringLength = strlen(source) + 1;
 
         newAllocation = (char *)XP_ALLOC(stringLength);
         if (newAllocation == NULL)
                 return NULL;
         BlockMoveData(source, newAllocation, stringLength);
         return newAllocation;
 }
 
-#ifndef XP_MACOSX
 int strcasecmp(const char *str1, const char *str2)
 {
     char    currentChar1, currentChar2;
 
     while (1) {
     
         currentChar1 = *str1;
         currentChar2 = *str2;
Index: mozilla/modules/plugin/samples/default/mac/DefaultPlugin.pbproj/project.pbxproj
===================================================================
RCS file: /cvsroot/mozilla/modules/plugin/samples/default/mac/DefaultPlugin.pbproj/project.pbxproj,v
retrieving revision 1.2
diff -u -8 -p -r1.2 project.pbxproj
--- mozilla/modules/plugin/samples/default/mac/DefaultPlugin.pbproj/project.pbxproj	4 Apr 2003 22:47:00 -0000	1.2
+++ mozilla/modules/plugin/samples/default/mac/DefaultPlugin.pbproj/project.pbxproj	11 Jun 2005 04:55:02 -0000
@@ -30,17 +30,16 @@
 			isa = PBXGroup;
 			name = MRJPlugin;
 			refType = 4;
 		};
 		089C1671FE841209C02AAC07 = {
 			children = (
 				F5A7D3AB036E359F01A96660,
 				08EA7FFBFE8413EDC02AAC07,
-				F51A400C0299CD65012FC976,
 			);
 			isa = PBXGroup;
 			name = "External Frameworks and Libraries";
 			refType = 4;
 		};
 		089C1673FE841209C02AAC07 = {
 			buildPhases = (
 				089C1674FE841209C02AAC07,
@@ -120,17 +119,16 @@
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 		089C1677FE841209C02AAC07 = {
 			buildActionMask = 2147483647;
 			files = (
 				08EA7FFCFE8413EDC02AAC07,
-				F51A400D0299CD65012FC976,
 				F5A7D695036E35A001A96660,
 			);
 			isa = PBXFrameworksBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 		089C1679FE841209C02AAC07 = {
 			buildActionMask = 2147483647;
 			files = (
@@ -281,28 +279,16 @@
 			);
 			buildSettings = {
 				COPY_PHASE_STRIP = NO;
 				DEBUGGING_SYMBOLS = YES;
 			};
 			isa = PBXBuildStyle;
 			name = DeploymentSymbols;
 		};
-		F51A400C0299CD65012FC976 = {
-			isa = PBXFileReference;
-			name = "libstdc++.a";
-			path = "/usr/lib/libstdc++.a";
-			refType = 0;
-		};
-		F51A400D0299CD65012FC976 = {
-			fileRef = F51A400C0299CD65012FC976;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
 		F59D147102AC328B01000104 = {
 			buildArgumentsString = "$ACTION resources";
 			buildPhases = (
 			);
 			buildSettings = {
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = "";
 				OTHER_REZFLAGS = "";
Index: mozilla/modules/plugin/samples/default/mac/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/modules/plugin/samples/default/mac/Makefile.in,v
retrieving revision 1.6
diff -u -8 -p -r1.6 Makefile.in
--- mozilla/modules/plugin/samples/default/mac/Makefile.in	17 Jan 2004 00:07:54 -0000	1.6
+++ mozilla/modules/plugin/samples/default/mac/Makefile.in	11 Jun 2005 04:55:02 -0000
@@ -55,16 +55,23 @@ endif
 endif
 
 TARGET		= "Default Plugin"
 
 PACKAGE_FILE = npnul.pkg
 
 include $(topsrcdir)/config/rules.mk
 
+ifneq (,$(findstring xcodebuild,$(PBBUILD)))
+# Tell Xcode 2.1 to put its build products where earlier versions of Xcode
+# and Project Builder did.  This gets set when using earlier Xcodes as well,
+# but "build" is the default in that case.
+PBBUILD_SETTINGS = TARGET_BUILD_DIR=build BUILT_PRODUCTS_DIR=build
+endif # PBBUILD contains "xcodebuild"
+
 # decodes resource files from AppleSingle to Resource Manager format.
 ASDECODE = $(DIST)/bin/asdecode
 RESOURCE_FILES = _NullPlugin.rsrc
 
 # for objdir builds, copy the project, and symlink the sources
 ABS_topsrcdir   := $(shell cd $(topsrcdir); pwd)
 ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
 export::
@@ -76,21 +83,21 @@ export::
 endif
 
 all:: build-plugin
 
 libs install:: install-plugin
 
 install-plugin: build-plugin
 	$(INSTALL) "build/Default Plugin.plugin" $(DIST)/bin/plugins
-	$(INSTALL) "build/DefaultPlugin.build/Default Plugin.build/PkgInfo" "$(DIST)/bin/plugins/Default Plugin.plugin/Contents"
 
 resources: $(RESOURCE_FILES)
 
 build-plugin: resources
-	$(PBBUILD) -target $(TARGET) -buildstyle $(BUILDSTYLE)
+	$(PBBUILD) -target $(TARGET) -buildstyle $(BUILDSTYLE) $(PBBUILD_SETTINGS)
+	echo -n NSPLMOSS > "build/Default Plugin.plugin/Contents/PkgInfo"
 
 _%.rsrc: %.rsrc
 	$(ASDECODE) $< $@
 
 clean clobber::
 	rm -f $(RESOURCE_FILES)
 	rm -rf build
Index: mozilla/xpcom/MoreFiles/MoreFilesX.c
===================================================================
RCS file: /cvsroot/mozilla/xpcom/MoreFiles/MoreFilesX.c,v
retrieving revision 1.4
diff -u -8 -p -r1.4 MoreFilesX.c
--- mozilla/xpcom/MoreFiles/MoreFilesX.c	16 Dec 2003 09:51:35 -0000	1.4
+++ mozilla/xpcom/MoreFiles/MoreFilesX.c	11 Jun 2005 04:55:03 -0000
@@ -2119,18 +2119,22 @@ BadParameter:
 }
 
 /*****************************************************************************/
 
 #pragma mark ----- Shared Environment Routines -----
 
 /*****************************************************************************/
 
+/* Renamed from FSLockRange to MFX_FSLockRange to avoid a conflict with
+ * the FSLockRange function present in the system library since Mac OS X
+ * 10.4. */
+
 OSErr
-FSLockRange(
+MFX_FSLockRange(
 	SInt16 refNum,
 	SInt32 rangeLength,
 	SInt32 rangeStart)
 {
 	OSErr			result;
 	ParamBlockRec	pb;
 
 	pb.ioParam.ioRefNum = refNum;
@@ -2142,18 +2146,22 @@ FSLockRange(
 	
 PBLockRangeSync:
 
 	return ( result );
 }
 
 /*****************************************************************************/
 
+/* Renamed from FSUnlockRange to MFX_FSUnlockRange to avoid a conflict with
+ * the FSUnlockRange function present in the system library since Mac OS X
+ * 10.4. */
+
 OSErr
-FSUnlockRange(
+MFX_FSUnlockRange(
 	SInt16 refNum,
 	SInt32 rangeLength,
 	SInt32 rangeStart)
 {
 	OSErr			result;
 	ParamBlockRec	pb;
 
 	pb.ioParam.ioRefNum = refNum;
Index: mozilla/xpcom/MoreFiles/MoreFilesX.h
===================================================================
RCS file: /cvsroot/mozilla/xpcom/MoreFiles/MoreFilesX.h,v
retrieving revision 1.3
diff -u -8 -p -r1.3 MoreFilesX.h
--- mozilla/xpcom/MoreFiles/MoreFilesX.h	9 Sep 2003 00:13:29 -0000	1.3
+++ mozilla/xpcom/MoreFiles/MoreFilesX.h	11 Jun 2005 04:55:03 -0000
@@ -1327,20 +1327,23 @@ FSExchangeObjectsCompat(
 */
 
 /*****************************************************************************/
 
 #pragma mark ----- Shared Environment Routines -----
 
 /*****************************************************************************/
 
-#pragma mark FSLockRange
+#pragma mark MFX_FSLockRange
+/* Renamed from FSLockRange to MFX_FSLockRange to avoid a conflict with
+ * the FSLockRange function present in the system library since Mac OS X
+ * 10.4. */
 
 OSErr
-FSLockRange(
+MFX_FSLockRange(
 	SInt16 refNum,
 	SInt32 rangeLength,
 	SInt32 rangeStart);
 
 /*
 	The LockRange function locks (denies access to) a portion of a file
 	that was opened with shared read/write permission.
 
@@ -1350,20 +1353,23 @@ FSLockRange(
 
 	__________
 
 	Also see:	UnlockRange
 */
 
 /*****************************************************************************/
 
-#pragma mark FSUnlockRange
+#pragma mark MFX_FSUnlockRange
+/* Renamed from FSUnlockRange to MFX_FSUnlockRange to avoid a conflict with
+ * the FSUnlockRange function present in the system library since Mac OS X
+ * 10.4. */
 
 OSErr
-FSUnlockRange(
+MFX_FSUnlockRange(
 	SInt16 refNum,
 	SInt32 rangeLength,
 	SInt32 rangeStart);
 
 /*
 	The UnlockRange function unlocks (allows access to) a previously locked
 	portion of a file that was opened with shared read/write permission.
 
Index: mozilla/xpcom/typelib/xpidl/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/xpcom/typelib/xpidl/Makefile.in,v
retrieving revision 1.36
diff -u -8 -p -r1.36 Makefile.in
--- mozilla/xpcom/typelib/xpidl/Makefile.in	20 Feb 2004 22:14:13 -0000	1.36
+++ mozilla/xpcom/typelib/xpidl/Makefile.in	11 Jun 2005 04:55:03 -0000
@@ -75,14 +75,17 @@ HOST_LIBS	= $(DIST)/host/lib/libhostxpt.
 HOST_EXTRA_DEPS	= $(wildcard $(DIST)/host/lib/libhostxpt.*)
 
 ifdef HOST_NSPR_MDCPUCFG
 HOST_CFLAGS	+= -DMDCPUCFG=$(HOST_NSPR_MDCPUCFG)
 endif
 endif
 
 ifdef MACOS_SDK_DIR
+# xpidl is for the build host, pull out the cross-compilation stuff
 NEXT_ROOT=
+OS_CFLAGS := $(shell echo $(OS_CFLAGS)|sed -E -e "s%((-I|-isystem )$(MACOS_SDK_DIR)/usr/(include|lib/gcc)[^ ]*)|-F$(MACOS_SDK_DIR)(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*%%g")
+OS_CFLAGS := $(patsubst -I$(MACOS_SDK_DIR)%,-I%,$(OS_CFLAGS))
 OS_LIBS := $(patsubst -L$(MACOS_SDK_DIR)/usr/lib%,,$(OS_LIBS))
 endif
 
 export::
 	@$(MAKE) libs
Index: mozilla/xpfe/bootstrap/appleevents/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/xpfe/bootstrap/appleevents/Makefile.in,v
retrieving revision 1.5
diff -u -8 -p -r1.5 Makefile.in
--- mozilla/xpfe/bootstrap/appleevents/Makefile.in	29 Jan 2004 20:18:14 -0000	1.5
+++ mozilla/xpfe/bootstrap/appleevents/Makefile.in	11 Jun 2005 04:55:03 -0000
@@ -80,17 +80,17 @@ LOCAL_INCLUDES	= \
 	-I$(srcdir)/.. \
 	-I$(srcdir)/../../appshell/src/ \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 
 # convert AppleScript dictionary .sdef file into .r format, and thence to .rsrc
-SDP_TOOL = /Developer/Tools/sdp
+SDP_TOOL = $(SDP)
 REZ_TOOL = /Developer/Tools/Rez
 SDEF_SRC = $(srcdir)/mozilla.sdef
 RES_DEST = mozillaSuite.r
 RSRC_DEST = mozillaSuite.rsrc
 PACKAGE_DIR = $(DIST)/package
 
 $(RSRC_DEST): $(SDEF_SRC) $(PACKAGE_DIR)
 	NEXT_ROOT= $(SDP_TOOL) -fa -o $(RES_DEST) $(SDEF_SRC) 
