Index: build/premake/extern_libs4.lua
===================================================================
--- build/premake/extern_libs4.lua	(revision 14784)
+++ build/premake/extern_libs4.lua	(working copy)
@@ -562,38 +562,41 @@
 	},
 	spidermonkey = {
 		compile_settings = function()
-			if _OPTIONS["with-system-mozjs185"] then
-				if not _OPTIONS["android"] then
-					pkgconfig_cflags("mozjs185")
-				end
-				defines { "WITH_SYSTEM_MOZJS185" }
+			if _OPTIONS["with-system-mozjs24"] then
+				-- to be implemented when such system packages exist
+				--if not _OPTIONS["android"] then
+				--	pkgconfig_cflags("mozjs24")
+				--end
+				--defines { "WITH_SYSTEM_MOZJS24" }
 			else
 				if os.is("windows") then
 					include_dir = "include-win32"
 				elseif os.is("macosx") then
 					include_dir = "include"
 				else
-					include_dir = "include-unix"
+					include_dir = "include"
 				end
 				configuration "Debug"
-					includedirs { libraries_source_dir.."spidermonkey/"..include_dir }
+					includedirs { libraries_source_dir.."spidermonkey/"..include_dir.."/mozjs-24/" }
+					defines { "DEBUG" }
 				configuration "Release"
-					includedirs { libraries_source_dir.."spidermonkey/"..include_dir }
+					includedirs { libraries_source_dir.."spidermonkey/"..include_dir.."/mozjs-24/" }
 				configuration { }
 			end
 		end,
 		link_settings = function()
-			if _OPTIONS["with-system-mozjs185"] then
-				if _OPTIONS["android"] then
-					links { "mozjs185-1.0" }
-				else
-					pkgconfig_libs("mozjs185")
-				end
+			if _OPTIONS["with-system-mozjs24"] then
+				-- to be implemented when such system packages exist
+				--if _OPTIONS["android"] then
+				--	links { "mozjs185-1.0" }
+				--else
+				--	pkgconfig_libs("mozjs185")
+				--end
 			else
 				configuration "Debug"
-					links { "mozjs185-ps-debug" }
+					links { "mozjs24-ps-debug" }
 				configuration "Release"
-					links { "mozjs185-ps-release" }
+					links { "mozjs24-ps-release" }
 				configuration { }
 				add_source_lib_paths("spidermonkey")
 			end
Index: build/premake/premake4.lua
===================================================================
--- build/premake/premake4.lua	(revision 14784)
+++ build/premake/premake4.lua	(working copy)
@@ -15,7 +15,7 @@
 newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" }
 newoption { trigger = "with-system-enet", description = "Search standard paths for libenet, instead of using bundled copy" }
 newoption { trigger = "with-system-miniupnpc", description = "Search standard paths for libminiupnpc, instead of using bundled copy" }
-newoption { trigger = "with-system-mozjs185", description = "Search standard paths for libmozjs185, instead of using bundled copy" }
+newoption { trigger = "with-system-mozjs24", description = "Search standard paths for libmozjs24, instead of using bundled copy" }
 newoption { trigger = "with-c++11", description = "Enable C++11 on GCC" }
 newoption { trigger = "sysroot", description = "Set compiler system root path, used for building against a non-system SDK. For example /usr/local becomes SYSROOT/user/local" }
 newoption { trigger = "macosx-version-min", description = "Set minimum required version of the OS X API, the build will possibly fail if an older SDK is used, while newer API functions will be weakly linked (i.e. resolved at runtime)" }
Index: build/workspaces/update-workspaces.sh
===================================================================
--- build/workspaces/update-workspaces.sh	(revision 14784)
+++ build/workspaces/update-workspaces.sh	(working copy)
@@ -37,7 +37,7 @@
 with_system_nvtt=false
 with_system_enet=false
 with_system_miniupnpc=false
-with_system_mozjs185=false
+with_system_mozjs24=false
 enable_atlas=true
 
 for i in "$@"
@@ -47,7 +47,7 @@
     --with-system-nvtt ) with_system_nvtt=true; premake_args="${premake_args} --with-system-nvtt" ;;
     --with-system-enet ) with_system_enet=true; premake_args="${premake_args} --with-system-enet" ;;
     --with-system-miniupnpc ) with_system_miniupnpc=true; premake_args="${premake_args} --with-system-miniupnpc" ;;
-    --with-system-mozjs185 ) with_system_mozjs185=true; premake_args="${premake_args} --with-system-mozjs185" ;;
+    --with-system-mozjs24 ) with_system_mozjs24=true; premake_args="${premake_args} --with-system-mozjs24" ;;
     --enable-atlas ) enable_atlas=true ;;
     --disable-atlas ) enable_atlas=false ;;
     -j* ) JOBS=$i ;;
@@ -81,7 +81,7 @@
   # Build/update bundled external libraries
   (cd ../../libraries/source/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed"
   echo
-  if [ "$with_system_mozjs185" = "false" ]; then
+  if [ "$with_system_mozjs24" = "false" ]; then
     (cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
   fi
   echo
Index: libraries/osx/build-osx-libs.sh
===================================================================
--- libraries/osx/build-osx-libs.sh	(revision 14784)
+++ libraries/osx/build-osx-libs.sh	(working copy)
@@ -524,9 +524,9 @@
 # --------------------------------------------------------------------
 echo -e "Building Spidermonkey..."
 
-LIB_VERSION="js185-1.0.0"
-LIB_ARCHIVE="$LIB_VERSION.tar.gz"
-LIB_DIRECTORY="js-1.8.5"
+LIB_VERSION="mozjs-24.2.0"
+LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
+LIB_DIRECTORY="mozjs24"
 
 pushd ../source/spidermonkey/ > /dev/null
 
@@ -538,6 +538,7 @@
   rm -f lib/*.a
   rm -rf $LIB_DIRECTORY
   tar -xf $LIB_ARCHIVE
+  mv mozjs-24.2.0 mozjs24
   pushd $LIB_DIRECTORY/js/src
 
   # We want separate debug/release versions of the library, so change their install name in the Makefile
@@ -555,7 +556,7 @@
 
   mkdir -p build-debug
   pushd build-debug
-  (CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-debug --disable-optimize && make ${JOBS} && make install) || die "Spidermonkey build failed"
+  (CC="clang -arch $ARCH" CXX="clang++ -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-debug --disable-optimize && make ${JOBS} && make install) || die "Spidermonkey build failed"
   popd
   mv Makefile.in.bak Makefile.in
   
@@ -563,7 +564,7 @@
 
   mkdir -p build-release
   pushd build-release
-  (CC="$CC -arch $ARCH" CXX="$CXX -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS && make ${JOBS} && make install) || die "Spidermonkey build failed"
+  (CC="clang -arch $ARCH" CXX="clang++ -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" --enable-optimize && make ${JOBS} && make install) || die "Spidermonkey build failed"
   popd
   mv Makefile.in.bak Makefile.in
