bug 676589 - configure and xpcom changes for targeting iOS. r=khuey
authorTed Mielczarek <ted.mielczarek@gmail.com>
Tue, 27 Apr 2010 08:57:34 -0400
changeset 75803 4d17fe7b47b6ea39d1d6becebc7b080242fe2691
parent 75802 06defc1b425097d4a95bb28f0ee254d38b186c36
child 75804 00c7432d78839e715a97824f8d0f8b80697c6c08
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerskhuey
bugs676589
milestone9.0a1
bug 676589 - configure and xpcom changes for targeting iOS. r=khuey
config/config.mk
configure.in
js/src/config/config.mk
xpcom/build/XPCOM.h
xpcom/build/XPCOMModule.inc
xpcom/build/nsXPComInit.cpp
xpcom/components/ManifestParser.cpp
xpcom/io/SpecialSystemDirectory.cpp
xpcom/io/SpecialSystemDirectory.h
xpcom/io/nsAppFileLocationProvider.cpp
xpcom/io/nsDirectoryService.cpp
xpcom/io/nsDirectoryServiceAtomList.h
xpcom/io/nsDirectoryServiceDefs.h
xpcom/io/nsLocalFileCommon.cpp
--- a/config/config.mk
+++ b/config/config.mk
@@ -514,21 +514,26 @@ ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
 ifndef MOZ_NO_DEBUG_RTL
 RTL_FLAGS=-MDd         # Dynamically linked, multithreaded MSVC4.0 debug RTL
 endif 
 endif # MOZ_DEBUG || NS_TRACE_MALLOC
 endif # USE_STATIC_LIBS
 endif # WINNT && !GNU_CC
 
 ifeq ($(OS_ARCH),Darwin)
-# Darwin doesn't cross-compile, so just set both types of flags here.
+# Compiling ObjC requires an Apple compiler anyway, so it's ok to set
+# host CMFLAGS here.
 HOST_CMFLAGS += -fobjc-exceptions
 HOST_CMMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
+ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
+OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
+OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
+endif
 endif
 
 COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
 COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
 
 ifndef CROSS_COMPILE
--- a/configure.in
+++ b/configure.in
@@ -2102,17 +2102,27 @@ case "$target" in
     DLL_SUFFIX=".dylib"
     DSO_LDOPTS=''
     STRIP="$STRIP -x -S"
     _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
     # The ExceptionHandling framework is needed for Objective-C exception
     # logging code in nsObjCExceptions.h. Currently we only use that in debug
     # builds.
-    MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"
+    _SAVE_LDFLAGS=$LDFLAGS
+     AC_MSG_CHECKING([for -framework ExceptionHandling])
+    LDFLAGS="$LDFLAGS -framework ExceptionHandling"
+    AC_TRY_LINK(,[return 0;],
+                ac_cv_have_framework_exceptionhandling="yes",
+                ac_cv_have_framework_exceptionhandling="no")
+    AC_MSG_RESULT([$ac_cv_have_framework_exceptionhandling])
+    if test "$ac_cv_have_framework_exceptionhandling" = "yes"; then
+      MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
+    fi
+    LDFLAGS=$_SAVE_LDFLAGS
     # Debug builds should always have frame pointers
     MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer"
 
     if test "x$lto_is_enabled" = "xyes"; then
         echo "Skipping -dead_strip because lto is enabled."
     dnl DTrace and -dead_strip don't interact well. See bug 403132.
     dnl ===================================================================
     elif test "x$enable_dtrace" = "xyes"; then
@@ -3267,17 +3277,17 @@ MOZ_CHECK_HEADERS(gnu/libc-version.h nl_
 MOZ_CHECK_HEADERS(malloc.h)
 MOZ_CHECK_HEADERS(X11/XKBlib.h)
 MOZ_CHECK_HEADERS(io.h)
 
 dnl These are all the places some variant of statfs can be hiding.
 MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
 
 dnl Quota support
-MOZ_CHECK_HEADERS(sys/quota.h)
+MOZ_CHECK_HEADERS(sys/quota.h sys/sysmacros.h)
 MOZ_CHECK_HEADERS(linux/quota.h)
 
 dnl Try for MMX support
 dnl NB - later gcc versions require -mmmx for this header to be successfully
 dnl included (or another option which implies it, such as -march=pentium-mmx)
 MOZ_CHECK_HEADERS(mmintrin.h)
 
 dnl Check whether the compiler supports the new-style C++ standard
@@ -4991,23 +5001,37 @@ cairo-os2)
     MOZ_WIDGET_TOOLKIT=os2
     USE_FC_FREETYPE=1
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
     MOZ_PDF_PRINTING=1
     ;;
 
 cairo-cocoa)
-    MOZ_WIDGET_TOOLKIT=cocoa
-    AC_DEFINE(MOZ_WIDGET_COCOA)
+    # Check if we have the Cocoa framework, or if we're targeting Cocoa Touch
+    _SAVE_LDFLAGS=$LDFLAGS
+    LDFLAGS="$LDFLAGS -framework Cocoa"
+    AC_TRY_LINK(,[return 0;],_HAVE_FRAMEWORK_COCOA=1,_HAVE_FRAMEWORK_COCOA=)
+    if test -z "$_HAVE_FRAMEWORK_COCOA"; then
+        LDFLAGS="$_SAVE_LDFLAGS -framework UIKit";
+        AC_TRY_LINK(,[return 0;],_HAVE_FRAMEWORK_UIKIT=1,
+                    AC_MSG_ERROR([Neither Cocoa nor UIKit frameworks were found. Are you using the correct SDK?]))
+        MOZ_WIDGET_TOOLKIT=uikit
+      AC_DEFINE(MOZ_WIDGET_UIKIT)
+      TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
+    else
+      MOZ_WIDGET_TOOLKIT=cocoa
+      AC_DEFINE(MOZ_WIDGET_COCOA)
+      TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
+    fi
     MOZ_USER_DIR="Mozilla"
     AC_DEFINE(XP_MACOSX)
-    TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
+
     TK_CFLAGS="-DNO_X11"
-    LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
+    LDFLAGS="$LDFLAGS -lobjc"
     CFLAGS="$CFLAGS $TK_CFLAGS"
     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
     MOZ_FS_LAYOUT=bundle
     MOZ_WEBGL=1
     MOZ_INSTRUMENT_EVENT_LOOP=1
     ;;
 
@@ -8013,16 +8037,17 @@ if test "$_PEDANTIC"; then
     esac
 fi
 
 dnl ========================================================
 dnl Test for correct temporary object destruction order
 dnl ========================================================
 dnl We want to make sure the compiler follows the C++ spec here as 
 dnl xpcom and the string classes depend on it (bug 235381).
+if test -z "$CROSS_COMPILE"; then
 AC_MSG_CHECKING([for correct temporary object destruction order])
 AC_TRY_RUN([ class A {
              public:  A(int& x) : mValue(x) {}
                       ~A() { mValue--; }
                       operator char**() { return 0; }
              private:  int& mValue;
              };
              void func(char **arg) {}
@@ -8037,16 +8062,17 @@ AC_TRY_RUN([ class A {
              }
              ],
      result="yes", result="no", result="maybe")
 AC_MSG_RESULT([$result])
 
 if test "$result" = "no"; then
     AC_MSG_ERROR([Your compiler does not follow the C++ specification for temporary object destruction order.])
 fi
+fi
 
 dnl ========================================================
 dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
 dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
 dnl raw pointers in nsCOMPtr.h.  (VC++ has the same bug.)
 dnl ========================================================
 _SAVE_CXXFLAGS=$CXXFLAGS
 CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
@@ -8520,17 +8546,17 @@ if test "$MOZ_TREE_CAIRO"; then
         FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
         MOZ_ENABLE_CAIRO_FT=1
         CAIRO_FT_CFLAGS="$FT2_CFLAGS"
     fi
     case "$MOZ_WIDGET_TOOLKIT" in
       qt)
         QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
         ;;
-      cocoa)
+      cocoa | uikit)
         QUARTZ_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_SURFACE 1"
         QUARTZ_IMAGE_SURFACE_FEATURE="#define CAIRO_HAS_QUARTZ_IMAGE_SURFACE 1"
         QUARTZ_FONT_FEATURE="#define CAIRO_HAS_QUARTZ_FONT 1"
         ;;
       windows)
         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
         if test "$MOZ_WINSDK_TARGETVER" -ge "06010000"; then
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -514,21 +514,26 @@ ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
 ifndef MOZ_NO_DEBUG_RTL
 RTL_FLAGS=-MDd         # Dynamically linked, multithreaded MSVC4.0 debug RTL
 endif 
 endif # MOZ_DEBUG || NS_TRACE_MALLOC
 endif # USE_STATIC_LIBS
 endif # WINNT && !GNU_CC
 
 ifeq ($(OS_ARCH),Darwin)
-# Darwin doesn't cross-compile, so just set both types of flags here.
+# Compiling ObjC requires an Apple compiler anyway, so it's ok to set
+# host CMFLAGS here.
 HOST_CMFLAGS += -fobjc-exceptions
 HOST_CMMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMFLAGS += -fobjc-exceptions
 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
+ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
+OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
+OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
+endif
 endif
 
 COMPILE_CFLAGS	= $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
 COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
 
 ifndef CROSS_COMPILE
--- a/xpcom/build/XPCOM.h
+++ b/xpcom/build/XPCOM.h
@@ -135,17 +135,17 @@
 
 // interfaces that include something above
 
 #include "nsILocalFileWin.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsIPipe.h"
 
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 #include "nsILocalFileMac.h"
 #include "nsIMacUtils.h"
 #endif
 
 #ifdef XP_OS2
 #include "nsILocalFileOS2.h"
 #endif
 
--- a/xpcom/build/XPCOMModule.inc
+++ b/xpcom/build/XPCOMModule.inc
@@ -69,16 +69,16 @@
     COMPONENT(HASH_PROPERTY_BAG, nsHashPropertyBagConstructor)
 
     COMPONENT(UUID_GENERATOR, nsUUIDGeneratorConstructor)
 
 #if defined(XP_WIN)
     COMPONENT(WINDOWSREGKEY, nsWindowsRegKeyConstructor)
 #endif
 
-#ifdef XP_MACOSX
+#if defined(MOZ_WIDGET_COCOA)
     COMPONENT(MACUTILSIMPL, nsMacUtilsImplConstructor)
 #endif
 
     COMPONENT(SYSTEMINFO, nsSystemInfoConstructor)
     COMPONENT(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor)
     COMPONENT(IOUTIL, nsIOUtilConstructor)
     COMPONENT(CYCLE_COLLECTOR_LOGGER, nsCycleCollectorLoggerConstructor)
--- a/xpcom/build/nsXPComInit.cpp
+++ b/xpcom/build/nsXPComInit.cpp
@@ -123,17 +123,17 @@ extern nsresult nsStringInputStreamConst
 #include "nsRecyclingAllocator.h"
 
 #include "SpecialSystemDirectory.h"
 
 #if defined(XP_WIN)
 #include "nsWindowsRegKey.h"
 #endif
 
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 #include "nsMacUtilsImpl.h"
 #endif
 
 #include "nsSystemInfo.h"
 #include "nsMemoryReporterManager.h"
 
 #include <locale.h>
 #include "mozilla/Services.h"
@@ -210,17 +210,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariant
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRecyclingAllocatorImpl)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHashPropertyBag, Init)
 
 NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsProperties, Init)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init)
 
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl)
 #endif
 
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemoryReporterManager, Init)
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIOUtil)
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -39,17 +39,17 @@
 #include "ManifestParser.h"
 
 #include <string.h>
 
 #include "prio.h"
 #include "prprf.h"
 #if defined(XP_WIN)
 #include <windows.h>
-#elif defined(XP_MACOSX)
+#elif defined(MOZ_WIDGET_COCOA)
 #include <CoreServices/CoreServices.h>
 #elif defined(MOZ_WIDGET_GTK2)
 #include <gtk/gtk.h>
 #endif
 
 #ifdef ANDROID
 #include "AndroidBridge.h"
 #endif
@@ -481,17 +481,17 @@ ParseManifestCommon(NSLocationType aType
   nsAutoString osVersion;
 #if defined(XP_WIN)
   OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
   if (GetVersionEx(&info)) {
     nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
                                          info.dwMajorVersion,
                                          info.dwMinorVersion);
   }
-#elif defined(XP_MACOSX)
+#elif defined(MOZ_WIDGET_COCOA)
   SInt32 majorVersion, minorVersion;
   if ((Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr) &&
       (Gestalt(gestaltSystemVersionMinor, &minorVersion) == noErr)) {
     nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
                                          majorVersion,
                                          minorVersion);
   }
 #elif defined(MOZ_WIDGET_GTK2)
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -558,17 +558,17 @@ GetSpecialSystemDirectory(SystemDirector
                 }
             }
             nsCString tString = nsDependentCString(tPath);
             if (tString.Find("/", PR_FALSE, 0, -1)) {
                 tString.ReplaceChar('/','\\');
             }
             return NS_NewNativeLocalFile(tString, PR_TRUE, aFile);
         }
-#elif defined(XP_MACOSX)
+#elif defined(MOZ_WIDGET_COCOA)
         {
             return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile);
         }
 
 #elif defined(XP_UNIX)
         {
             static const char *tPath = nsnull;
             if (!tPath) {
@@ -892,17 +892,17 @@ GetSpecialSystemDirectory(SystemDirector
         }
 #endif
         default:
             break;
     }
     return NS_ERROR_NOT_AVAILABLE;
 }
 
-#if defined (XP_MACOSX)
+#if defined (MOZ_WIDGET_COCOA)
 nsresult
 GetOSXFolderType(short aDomain, OSType aFolderType, nsILocalFile **localFile)
 {
     OSErr err;
     FSRef fsRef;
     nsresult rv = NS_ERROR_FAILURE;
 
     err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef);
--- a/xpcom/io/SpecialSystemDirectory.h
+++ b/xpcom/io/SpecialSystemDirectory.h
@@ -39,17 +39,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _SPECIALSYSTEMDIRECTORY_H_
 #define _SPECIALSYSTEMDIRECTORY_H_
 
 #include "nscore.h"
 #include "nsILocalFile.h"
 
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 #include <Carbon/Carbon.h>
 #include "nsILocalFileMac.h"
 #include "prenv.h"
 #endif
 
 extern void StartupSpecialSystemDirectory();
 extern void ShutdownSpecialSystemDirectory();
 
@@ -126,14 +126,14 @@ enum SystemDirectories {
   OS2_OS2Directory          =   402,   
   OS2_DesktopDirectory      =   403,   
   OS2_HomeDirectory         =   404
 };
 
 nsresult
 GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
                           nsILocalFile** aFile);
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 nsresult
 GetOSXFolderType(short aDomain, OSType aFolderType, nsILocalFile **localFile);
 #endif
 
 #endif
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -43,17 +43,17 @@
 #include "nsIAtom.h"
 #include "nsILocalFile.h"
 #include "nsString.h"
 #include "nsXPIDLString.h"
 #include "nsISimpleEnumerator.h"
 #include "prenv.h"
 #include "nsCRT.h"
 
-#if defined(XP_MACOSX)
+#if defined(MOZ_WIDGET_COCOA)
 #include <Carbon/Carbon.h>
 #include "nsILocalFileMac.h"
 #elif defined(XP_OS2)
 #define INCL_DOSPROCESS
 #define INCL_DOSMODULEMGR
 #include <os2.h>
 #elif defined(XP_WIN)
 #include <windows.h>
@@ -63,33 +63,33 @@
 #include <stdlib.h>
 #include <sys/param.h>
 #endif
 
 
 // WARNING: These hard coded names need to go away. They need to
 // come from localizable resources
 
-#if defined(XP_MACOSX)
+#if defined(MOZ_WIDGET_COCOA)
 #define APP_REGISTRY_NAME NS_LITERAL_CSTRING("Application Registry")
 #define ESSENTIAL_FILES   NS_LITERAL_CSTRING("Essential Files")
 #elif defined(XP_WIN) || defined(XP_OS2)
 #define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat")
 #else
 #define APP_REGISTRY_NAME NS_LITERAL_CSTRING("appreg")
 #endif
 
 // define default product directory
 #define DEFAULT_PRODUCT_DIR NS_LITERAL_CSTRING(MOZ_USER_DIR)
 
 // Locally defined keys used by nsAppDirectoryEnumerator
 #define NS_ENV_PLUGINS_DIR          "EnvPlugins"    // env var MOZ_PLUGIN_PATH
 #define NS_USER_PLUGINS_DIR         "UserPlugins"
 
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 #define NS_MACOSX_USER_PLUGIN_DIR   "OSXUserPlugins"
 #define NS_MACOSX_LOCAL_PLUGIN_DIR  "OSXLocalPlugins"
 #define NS_MACOSX_JAVA2_PLUGIN_DIR  "OSXJavaPlugins"
 #elif XP_UNIX
 #define NS_SYSTEM_PLUGINS_DIR       "SysPlugins"
 #endif
 
 #define DEFAULTS_DIR_NAME           NS_LITERAL_CSTRING("defaults")
@@ -123,17 +123,17 @@ nsAppFileLocationProvider::GetFile(const
 {
     nsCOMPtr<nsILocalFile>  localFile;
     nsresult rv = NS_ERROR_FAILURE;
 
     NS_ENSURE_ARG(prop);
     *_retval = nsnull;
     *persistent = PR_TRUE;
 
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
     FSRef fileRef;
     nsCOMPtr<nsILocalFileMac> macFile;
 #endif
     
     if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0)
     {
         rv = GetProductDirectory(getter_AddRefs(localFile));
     }
@@ -189,17 +189,17 @@ nsAppFileLocationProvider::GetFile(const
             rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
     }
     else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
     {
         rv = CloneMozBinDirectory(getter_AddRefs(localFile));
         if (NS_SUCCEEDED(rv))
             rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
     }
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
     else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0)
     {
         if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
             rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile));
             if (NS_SUCCEEDED(rv))
                 localFile = macFile;
         }
     }
@@ -319,17 +319,17 @@ NS_METHOD nsAppFileLocationProvider::Clo
 NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFile, PRBool aLocal)
 {
     NS_ENSURE_ARG_POINTER(aLocalFile);
 
     nsresult rv;
     PRBool exists;
     nsCOMPtr<nsILocalFile> localDir;
 
-#if defined(XP_MACOSX)
+#if defined(MOZ_WIDGET_COCOA)
     FSRef fsRef;
     OSType folderType = aLocal ? (OSType) kCachedDataFolderType : (OSType) kDomainLibraryFolderType;
     OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
     if (err) return NS_ERROR_FAILURE;
     NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localDir));
     if (!localDir) return NS_ERROR_FAILURE;
     nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir));
     rv = localDirMac->InitWithFSRef(&fsRef);
@@ -390,17 +390,17 @@ NS_METHOD nsAppFileLocationProvider::Get
     NS_ENSURE_ARG_POINTER(aLocalFile);
 
     nsresult rv;
     nsCOMPtr<nsILocalFile> localDir;
 
     rv = GetProductDirectory(getter_AddRefs(localDir), aLocal);
     if (NS_FAILED(rv)) return rv;
 
-#if defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_WIN)
+#if defined(MOZ_WIDGET_COCOA) || defined(XP_OS2) || defined(XP_WIN)
     // These 3 platforms share this part of the path - do them as one
     rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
     if (NS_FAILED(rv)) return rv;
 
     PRBool exists;
     rv = localDir->Exists(&exists);
     if (NS_SUCCEEDED(rv) && !exists)
         rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
@@ -547,17 +547,17 @@ NS_IMETHODIMP
 nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
 {
     NS_ENSURE_ARG_POINTER(_retval);
     *_retval = nsnull;
     nsresult rv = NS_ERROR_FAILURE;
     
     if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
     {
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
         // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on
         // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/.  Java
         // Plugin2 is still present and usable, but there are no longer any links to it in the
         // "normal" locations.  So we won't be able to find it unless we look in the "non-normal"
         // location where it actually is.  Safari can use the WebKit-specific JavaPluginCocoa.bundle,
         // which (of course) is still fully supported on OS X 10.5.  But we have no alternative to
         // using Java Plugin2.  For more information see bug 668639.
         static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR,
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -56,34 +56,34 @@
 #include <shlobj.h>
 #include <stdlib.h>
 #include <stdio.h>
 #elif defined(XP_UNIX)
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/param.h>
 #include "prenv.h"
-#ifdef XP_MACOSX
+#ifdef MOZ_WIDGET_COCOA
 #include <CoreServices/CoreServices.h>
 #include <Carbon/Carbon.h>
 #endif
 #elif defined(XP_OS2)
 #define MAX_PATH _MAX_PATH
 #endif
 
 #include "SpecialSystemDirectory.h"
 #include "nsAppFileLocationProvider.h"
 
 #define COMPONENT_DIRECTORY     NS_LITERAL_CSTRING("components")
 
 // define home directory
 // For Windows platform, We are choosing Appdata folder as HOME
 #if defined (XP_WIN)
 #define HOME_DIR NS_WIN_APPDATA_DIR
-#elif defined (XP_MACOSX)
+#elif defined (MOZ_WIDGET_COCOA)
 #define HOME_DIR NS_OSX_HOME_DIR
 #elif defined (XP_UNIX)
 #define HOME_DIR NS_UNIX_HOME_DIR
 #elif defined (XP_OS2)
 #define HOME_DIR NS_OS2_HOME_DIR
 #endif
 
 //----------------------------------------------------------------------------------------
@@ -134,17 +134,17 @@ nsDirectoryService::GetCurrentProcessDir
         if (lastSlash)
             *(lastSlash + 1) = L'\0';
 
         localFile->InitWithPath(nsDependentString(buf));
         *aFile = localFile;
         return NS_OK;
     }
 
-#elif defined(XP_MACOSX)
+#elif defined(MOZ_WIDGET_COCOA)
     // Works even if we're not bundled.
     CFBundleRef appBundle = CFBundleGetMainBundle();
     if (appBundle != nsnull)
     {
         CFURLRef bundleURL = CFBundleCopyExecutableURL(appBundle);
         if (bundleURL != nsnull)
         {
             CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, bundleURL);
@@ -610,17 +610,17 @@ nsDirectoryService::GetFile(const char *
     {
         rv = GetSpecialSystemDirectory(OS_CurrentProcessDirectory, getter_AddRefs(localFile)); 
     }
     else if (inAtom == nsDirectoryService::sOS_CurrentWorkingDirectory)
     {
         rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); 
     }
        
-#if defined(XP_MACOSX)
+#if defined(MOZ_WIDGET_COCOA)
     else if (inAtom == nsDirectoryService::sDirectory)
     {
         rv = GetOSXFolderType(kClassicDomain, kSystemFolderType, getter_AddRefs(localFile));
     }
     else if (inAtom == nsDirectoryService::sTrashDirectory)
     {
         rv = GetOSXFolderType(kClassicDomain, kTrashFolderType, getter_AddRefs(localFile));
     }
--- a/xpcom/io/nsDirectoryServiceAtomList.h
+++ b/xpcom/io/nsDirectoryServiceAtomList.h
@@ -40,17 +40,17 @@ DIR_ATOM(sCurrentProcess, NS_XPCOM_CURRE
 DIR_ATOM(sGRE_Directory, NS_GRE_DIR)
 DIR_ATOM(sOS_DriveDirectory, NS_OS_DRIVE_DIR)
 DIR_ATOM(sOS_TemporaryDirectory, NS_OS_TEMP_DIR)
 DIR_ATOM(sOS_CurrentProcessDirectory, NS_OS_CURRENT_PROCESS_DIR)
 DIR_ATOM(sOS_CurrentWorkingDirectory, NS_OS_CURRENT_WORKING_DIR)
 DIR_ATOM(sOS_HomeDirectory, NS_OS_HOME_DIR)
 DIR_ATOM(sOS_DesktopDirectory, NS_OS_DESKTOP_DIR)
 DIR_ATOM(sInitCurrentProcess_dummy, NS_XPCOM_INIT_CURRENT_PROCESS_DIR)
-#if defined (XP_MACOSX)
+#if defined (MOZ_WIDGET_COCOA)
 DIR_ATOM(sDirectory, NS_OS_SYSTEM_DIR)
 DIR_ATOM(sTrashDirectory, NS_MAC_TRASH_DIR)
 DIR_ATOM(sStartupDirectory, NS_MAC_STARTUP_DIR)
 DIR_ATOM(sShutdownDirectory, NS_MAC_SHUTDOWN_DIR)
 DIR_ATOM(sAppleMenuDirectory, NS_MAC_APPLE_MENU_DIR)
 DIR_ATOM(sControlPanelDirectory, NS_MAC_CONTROL_PANELS_DIR)
 DIR_ATOM(sExtensionDirectory, NS_MAC_EXTENSIONS_DIR)
 DIR_ATOM(sFontsDirectory, NS_MAC_FONTS_DIR)
--- a/xpcom/io/nsDirectoryServiceDefs.h
+++ b/xpcom/io/nsDirectoryServiceDefs.h
@@ -81,21 +81,21 @@
 /* Property will return the current location of the the GRE directory.  
  * If no GRE is used, this propery will behave like 
  * NS_XPCOM_CURRENT_PROCESS_DIR.
  */
 #define NS_GRE_DIR                              "GreD"
 
 /* Platform Specific Locations */
 
-#if !defined (XP_UNIX) || defined(XP_MACOSX)
+#if !defined (XP_UNIX) || defined(MOZ_WIDGET_COCOA)
     #define NS_OS_SYSTEM_DIR                    "SysD"
 #endif
 
-#if defined (XP_MACOSX)
+#if defined (MOZ_WIDGET_COCOA)
     #define NS_MAC_DESKTOP_DIR                  NS_OS_DESKTOP_DIR
     #define NS_MAC_TRASH_DIR                    "Trsh"
     #define NS_MAC_STARTUP_DIR                  "Strt"
     #define NS_MAC_SHUTDOWN_DIR                 "Shdwn"
     #define NS_MAC_APPLE_MENU_DIR               "ApplMenu"
     #define NS_MAC_CONTROL_PANELS_DIR           "CntlPnl"
     #define NS_MAC_EXTENSIONS_DIR               "Exts"
     #define NS_MAC_FONTS_DIR                    "Fnts"
--- a/xpcom/io/nsLocalFileCommon.cpp
+++ b/xpcom/io/nsLocalFileCommon.cpp
@@ -58,17 +58,17 @@ void NS_StartupLocalFile()
     nsLocalFile::GlobalInit();
 }
 
 void NS_ShutdownLocalFile()
 {
     nsLocalFile::GlobalShutdown();
 }
 
-#if !defined(XP_MACOSX) && !defined(XP_WIN)
+#if !defined(MOZ_WIDGET_COCOA) && !defined(XP_WIN)
 NS_IMETHODIMP
 nsLocalFile::InitWithFile(nsILocalFile *aFile)
 {
     NS_ENSURE_ARG(aFile);
     
     nsCAutoString path;
     aFile->GetNativePath(path);
     if (path.IsEmpty())