diff --git a/.hgtags b/.hgtags
index 47f5717f8af38090ad98db9a77479557c1836ca5..75b5671e194679c755146e483d134652bc70d4eb 100755
--- a/.hgtags
+++ b/.hgtags
@@ -303,3 +303,4 @@ b1dbb1a83f48f93f6f878cff9e52d2cb635e145c 3.4.0-beta2
 6dfb0fba782c9233dd95f24ec48146db0d3f210b DRTVWR-199
 7c9102fb998885621919f2474a002c35b583539b 3.3.4-release2
 7649a3dff5ec22d3727377e5f02efd0f421e4cb5 DRTVWR-201
+de3be913f68813a9bac7d1c671fef96d1159bcd6 DRTVWR-202
diff --git a/autobuild.xml b/autobuild.xml
index 2f6e67ad653f84ca1cc3bb465203364bcb09ef0e..a86c8fd866b9f71dfd668ad1a3c1774ffd208738 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -2183,6 +2183,8 @@
                 <array>
                   <string>-configuration Release</string>
                   <string>-project SecondLife.xcodeproj</string>
+                  <string>-DENABLE_SIGNING:BOOL=YES</string>
+                  <string>-DSIGNING_IDENTITY:STRING="Developer ID Application: Linden Research, Inc."</string>
                 </array>
               </map>
               <key>configure</key>
@@ -2210,6 +2212,8 @@
                 <array>
                   <string>-configuration Release</string>
                   <string>-project SecondLife.xcodeproj</string>
+                  <string>-DENABLE_SIGNING:BOOL=YES</string>
+                  <string>-DSIGNING_IDENTITY:STRING="Developer ID Application: Linden Research, Inc."</string>
                 </array>
               </map>
               <key>configure</key>
diff --git a/doc/contributions.txt b/doc/contributions.txt
index 3218624f76e3882494938c555332de4b692c1db8..e20b7b83c5e3a0b8126e7ef747fc7f7a3939d14b 100644
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -401,6 +401,7 @@ Gaberoonie Zanzibar
 Ganymedes Costagravas
 Geenz Spad
 	STORM-1823
+	STORM-1900
 Gene Frostbite
 GeneJ Composer
 Geneko Nemeth
@@ -657,6 +658,8 @@ Kage Pixel
 	VWR-11
 Kagehi Kohn
 Kaimen Takahe
+Katharine Berry
+	STORM-1900
 Keklily Longfall
 Ken Lavender
 Ken March
diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 487b58105683d2fef3775ab4c9f8a74cc80d5741..21cb87237ddf312ecd31ca2ff0ee36945c58ee37 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -207,6 +207,10 @@ if (DARWIN)
   # NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O0 ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
   set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O0 ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+  if (XCODE_VERSION GREATER 4.2)
+    set(ENABLE_SIGNING TRUE)
+    set(SIGNING_IDENTITY "Developer ID Application: Linden Research, Inc.")
+  endif (XCODE_VERSION GREATER 4.2)
 endif (DARWIN)
 
 
diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 56ced20abf68c32cd4a56fa1df22e3f4343fce87..4b459f1a486195758e3caf1a4f9917c7ef66e276 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -99,10 +99,20 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   set(DARWIN 1)
   
+  execute_process(
+    COMMAND sh -c "xcodebuild -version | grep Xcode  | cut -d ' ' -f2 | cut -d'.' -f1-2"
+    OUTPUT_VARIABLE XCODE_VERSION )
+
   # To support a different SDK update these Xcode settings:
-  set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
+  if (XCODE_VERSION GREATER 4.2)
+    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
+  else (XCODE_VERSION GREATER 4.2)
+    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
+  endif (XCODE_VERSION GREATER 4.2)
+
   set(CMAKE_OSX_SYSROOT macosx10.6)
   set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
+      
   set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym)
 
   # NOTE: To attempt an i386/PPC Universal build, add this on the configure line:
@@ -134,6 +144,11 @@ set(VIEWER ON CACHE BOOL "Build Second Life viewer.")
 set(VIEWER_CHANNEL "LindenDeveloper" CACHE STRING "Viewer Channel Name")
 set(VIEWER_LOGIN_CHANNEL ${VIEWER_CHANNEL} CACHE STRING "Fake login channel for A/B Testing")
 
+if (XCODE_VERSION GREATER 4.2)
+  set(ENABLE_SIGNING OFF CACHE BOOL "Enable signing the viewer")
+  set(SIGNING_IDENTITY "" CACHE STRING "Specifies the signing identity to use, if necessary.")
+endif (XCODE_VERSION GREATER 4.2)
+
 set(VERSION_BUILD "0" CACHE STRING "Revision number passed in from the outside")
 set(STANDALONE OFF CACHE BOOL "Do not use Linden-supplied prebuilt libraries.")
 set(UNATTENDED OFF CACHE BOOL "Should be set to ON for building with VC Express editions.")
diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py
index a4fb77357c68a7397607e02bfa8127a3a1b7ea9d..bfcb2597094c8acfbbd547d6855938d667aa4d71 100644
--- a/indra/lib/python/indra/util/llmanifest.py
+++ b/indra/lib/python/indra/util/llmanifest.py
@@ -167,7 +167,12 @@ def get_channel(srctree):
     dict(name='version',
          description="""This specifies the version of Second Life that is
         being packaged up.""",
-         default=get_default_version)
+         default=get_default_version),
+    dict(name='signature',
+         description="""This specifies an identity to sign the viewer with, if any.
+        If no value is supplied, the default signature will be used, if any. Currently
+        only used on Mac OS X.""",
+         default=None)
     ]
 
 def usage(srctree=""):
diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h
index a0727b8686dbbb2661a70b6e88a91d163c28924f..509de51f4dfc4261ab7c22cf47cb817288dbd189 100644
--- a/indra/llrender/llglheaders.h
+++ b/indra/llrender/llglheaders.h
@@ -993,7 +993,12 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
 }
 #endif
 
+#if __MAC_OS_X_VERSION_MAX_ALLOWED <= 1070
+#include <OpenGL/gl.h>
+#else
 #include <AGL/gl.h>
+#endif
+
 
 #endif // LL_MESA / LL_WINDOWS / LL_DARWIN
 
diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h
index 5ee8bdb542da2ebc4ee3d10ce114a7df3c1e20b6..3b1883b5d8bc26080ee2e7c9f53c567eb7a2d185 100644
--- a/indra/llvfs/lldir.h
+++ b/indra/llvfs/lldir.h
@@ -1,4 +1,4 @@
-/** 
+/**  
  * @file lldir.h
  * @brief Definition of directory utilities class
  *
diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp
index 489bc3e4a779be382e3ea620be9bef326cb0f539..9f60111275af2a461ad0f8c7e2d66594d137f97d 100644
--- a/indra/llvfs/lldir_mac.cpp
+++ b/indra/llvfs/lldir_mac.cpp
@@ -22,7 +22,7 @@
  * 
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
- */
+ */ 
 
 #if LL_DARWIN
 
diff --git a/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h
index d190d70be4a596231e6b595a0409eaa89e761228..64e9485757dd601e55a97ba53029834e1bf75cee 100644
--- a/indra/llvfs/lldir_mac.h
+++ b/indra/llvfs/lldir_mac.h
@@ -22,7 +22,7 @@
  * 
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
- */
+ */ 
 
 #if !LL_DARWIN
 #error This header must not be included when compiling for any target other than Mac OS. Consider including lldir.h instead.
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 3cd03f86415ff69ef5eec8dbeb6963c2ff996b92..0031362210c1b9e7b02087331a4ec01a0b6659f5 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1955,6 +1955,12 @@ if (DARWIN)
     )
 
   add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit mac-updater mac-crash-logger)
+  
+  if (ENABLE_SIGNING)
+      set(SIGNING_SETTING "--signature=${SIGNING_IDENTITY}")
+  else (ENABLE_SIGNING)
+      set(SIGNING_SETTING "")
+  endif (ENABLE_SIGNING)
 
   if (PACKAGE)
       add_custom_target(package ALL DEPENDS ${VIEWER_BINARY_NAME})
@@ -1974,6 +1980,7 @@ if (DARWIN)
           --login_channel=${VIEWER_LOGIN_CHANNEL}
           --source=${CMAKE_CURRENT_SOURCE_DIR}
           --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched
+          ${SIGNING_SETTING}
         DEPENDS
           ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py
       )
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
old mode 100755
new mode 100644
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index d1c952ac3bd275fdc410bffe2996327e46a4f902..3c3aba23f8ca6a54a2e67b52a7f77b85971c7d7d 100644
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -816,6 +816,30 @@ def copy_finish(self):
             self.run_command("chmod +x %r" % os.path.join(self.get_dst_prefix(), script))
 
     def package_finish(self):
+        # Sign the app if requested.
+        if 'signature' in self.args:
+            identity = self.args['signature']
+            if identity == '':
+                identity = 'Developer ID Application'
+
+            # Look for an environment variable set via build.sh when running in Team City.
+            try:
+                build_secrets_checkout = os.environ['build_secrets_checkout']
+            except KeyError:
+                pass
+            else:
+                # variable found so use it to unlock keyvchain followed by codesign
+                home_path = os.environ['HOME']
+                keychain_pwd_path = os.path.join(build_secrets_checkout,'code-signing-osx','password.txt')
+                keychain_pwd = open(keychain_pwd_path).read().rstrip()
+
+                self.run_command('security unlock-keychain -p "%s" "%s/Library/Keychains/viewer.keychain"' % ( keychain_pwd, home_path ) )
+                self.run_command('codesign --verbose --force --keychain "%(home_path)s/Library/Keychains/viewer.keychain" --sign %(identity)r %(bundle)r' % {
+                                 'home_path' : home_path,
+                                 'identity': identity,
+                                 'bundle': self.get_dst_prefix()
+                })
+
         channel_standin = 'Second Life Viewer'  # hah, our default channel is not usable on its own
         if not self.default_channel():
             channel_standin = self.channel()