Browse Source

Fix various Mac OS X bugs and build issues

rdb 10 years ago
parent
commit
f624cdcac0

+ 1 - 1
dtool/src/dtoolutil/executionEnvironment.cxx

@@ -60,7 +60,7 @@ extern char **environ;
 #include <sys/sysctl.h>
 #include <sys/sysctl.h>
 #endif
 #endif
 
 
-#if defined(IS_LINUX) || defined(IS_OSX) || defined(IS_FREEBSD)
+#if defined(IS_LINUX) || defined(IS_FREEBSD)
 // For link_map and dlinfo.
 // For link_map and dlinfo.
 #include <link.h>
 #include <link.h>
 #include <dlfcn.h>
 #include <dlfcn.h>

+ 31 - 9
makepanda/makepanda.py

@@ -139,8 +139,8 @@ def usage(problem):
     print("  --outputdir X     (use the specified directory instead of 'built')")
     print("  --outputdir X     (use the specified directory instead of 'built')")
     print("  --host URL        (set the host url (runtime build only))")
     print("  --host URL        (set the host url (runtime build only))")
     print("  --threads N       (use the multithreaded build system. see manual)")
     print("  --threads N       (use the multithreaded build system. see manual)")
-    print("  --osxtarget N     (the OSX version number to build for (OSX only))")
-    print("  --universal       (build universal binaries (OSX only))")
+    print("  --osxtarget N     (the OS X version number to build for (OS X only))")
+    print("  --universal       (build universal binaries (OS X only))")
     print("  --override \"O=V\"  (override dtool_config/prc option value)")
     print("  --override \"O=V\"  (override dtool_config/prc option value)")
     print("  --static          (builds libraries for static linking)")
     print("  --static          (builds libraries for static linking)")
     print("  --target X        (experimental cross-compilation (android only))")
     print("  --target X        (experimental cross-compilation (android only))")
@@ -261,6 +261,13 @@ def parseopts(args):
             OSXTARGET = "10.%d" % (int(OSXTARGET[-1]))
             OSXTARGET = "10.%d" % (int(OSXTARGET[-1]))
         except:
         except:
             usage("Invalid setting for OSXTARGET")
             usage("Invalid setting for OSXTARGET")
+
+    if UNIVERSAL:
+        if not OSXTARGET:
+            exit("--universal requires --osxtarget")
+        if target_arch:
+            exit("--universal is incompatible with --arch")
+
     try:
     try:
         SetOptimize(int(optimize))
         SetOptimize(int(optimize))
         assert GetOptimize() in [1, 2, 3, 4]
         assert GetOptimize() in [1, 2, 3, 4]
@@ -670,7 +677,7 @@ if (COMPILER=="GCC"):
     elif (RTDIST or RUNTIME):
     elif (RTDIST or RUNTIME):
         # We don't support Cocoa in the runtime yet.
         # We don't support Cocoa in the runtime yet.
         PkgDisable("COCOA")
         PkgDisable("COCOA")
-    elif (not UNIVERSAL and GetTargetArch() == 'x86_64'):
+    elif (UNIVERSAL or GetTargetArch() == 'x86_64'):
         # 64-bits OS X doesn't have Carbon.
         # 64-bits OS X doesn't have Carbon.
         PkgDisable("CARBON")
         PkgDisable("CARBON")
 
 
@@ -1084,10 +1091,15 @@ def CompileCxx(obj,src,opts):
             if (OSXTARGET != None):
             if (OSXTARGET != None):
                 cmd += " -isysroot " + SDK["MACOSX"]
                 cmd += " -isysroot " + SDK["MACOSX"]
                 cmd += " -mmacosx-version-min=" + OSXTARGET
                 cmd += " -mmacosx-version-min=" + OSXTARGET
+
             if UNIVERSAL:
             if UNIVERSAL:
                 cmd += " -arch i386"
                 cmd += " -arch i386"
-                if ("NOPPC" not in opts):
-                    cmd += " -arch ppc"
+                if OSXTARGET:
+                    osxver = int(OSXTARGET[-1])
+                    if "NOPPC" not in opts and int(OSXTARGET[-1]) < 6:
+                        cmd += " -arch ppc"
+                    if int(OSXTARGET[-1]) >= 5:
+                        cmd += " -arch x86_64"
             elif HasTargetArch():
             elif HasTargetArch():
                 cmd += " -arch %s" % (GetTargetArch())
                 cmd += " -arch %s" % (GetTargetArch())
 
 
@@ -1539,10 +1551,15 @@ def CompileLink(dll, obj, opts):
             if OSXTARGET != None:
             if OSXTARGET != None:
                 cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"]
                 cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"]
                 cmd += " -mmacosx-version-min=" + OSXTARGET
                 cmd += " -mmacosx-version-min=" + OSXTARGET
+
             if UNIVERSAL:
             if UNIVERSAL:
                 cmd += " -arch i386"
                 cmd += " -arch i386"
-                if ("NOPPC" not in opts):
-                    cmd += " -arch ppc"
+                if OSXTARGET:
+                    osxver = int(OSXTARGET[-1])
+                    if "NOPPC" not in opts and int(OSXTARGET[-1]) < 6:
+                        cmd += " -arch ppc"
+                    if int(OSXTARGET[-1]) >= 5:
+                        cmd += " -arch x86_64"
             elif HasTargetArch():
             elif HasTargetArch():
                 cmd += " -arch %s" % (GetTargetArch())
                 cmd += " -arch %s" % (GetTargetArch())
 
 
@@ -6621,10 +6638,15 @@ def MakeInstallerOSX():
         if not os.path.isdir("dstroot/" + pkg):
         if not os.path.isdir("dstroot/" + pkg):
             os.makedirs("dstroot/" + pkg)
             os.makedirs("dstroot/" + pkg)
 
 
+        if OSXTARGET:
+            target = '--target %s' % (OSXTARGET)
+        else:
+            target = ''
+
         if os.path.exists("/Developer/usr/bin/packagemaker"):
         if os.path.exists("/Developer/usr/bin/packagemaker"):
-            cmd = '/Developer/usr/bin/packagemaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg --target 10.4 --domain system --root dstroot/' + pkg + '/ --no-relocate'
+            cmd = '/Developer/usr/bin/packagemaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate'
         elif os.path.exists("/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"):
         elif os.path.exists("/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"):
-            cmd = '/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg --target 10.4 --domain system --root dstroot/' + pkg + '/ --no-relocate'
+            cmd = '/Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS/PackageMaker --info /tmp/Info_plist --version ' + VERSION + ' --out dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg --target ' + target + ' --domain system --root dstroot/' + pkg + '/ --no-relocate'
         elif os.path.exists("/Developer/Tools/packagemaker"):
         elif os.path.exists("/Developer/Tools/packagemaker"):
             cmd = '/Developer/Tools/packagemaker -build -f dstroot/' + pkg + '/ -p dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg -i /tmp/Info_plist'
             cmd = '/Developer/Tools/packagemaker -build -f dstroot/' + pkg + '/ -p dstroot/Panda3D/Panda3D.mpkg/Contents/Packages/' + pkg + '.pkg -i /tmp/Info_plist'
         else:
         else:

+ 1 - 1
panda/src/cocoadisplay/cocoaGraphicsPipe.mm

@@ -343,7 +343,7 @@ make_output(const string &name,
       if (!cocoagsg->_supports_framebuffer_object ||
       if (!cocoagsg->_supports_framebuffer_object ||
           cocoagsg->_glDrawBuffers == NULL) {
           cocoagsg->_glDrawBuffers == NULL) {
         return NULL;
         return NULL;
-      } else {
+      } else if (fb_prop.is_basic()) {
         // Early success - if we are sure that this buffer WILL
         // Early success - if we are sure that this buffer WILL
         // meet specs, we can precertify it.
         // meet specs, we can precertify it.
         precertify = true;
         precertify = true;

+ 2 - 1
panda/src/cocoadisplay/cocoaGraphicsWindow.mm

@@ -1592,7 +1592,8 @@ handle_key_event(NSEvent *event) {
     if ([str canBeConvertedToEncoding: NSASCIIStringEncoding]) {
     if ([str canBeConvertedToEncoding: NSASCIIStringEncoding]) {
       // Nhm, ascii character perhaps?
       // Nhm, ascii character perhaps?
       str = [str lowercaseString];
       str = [str lowercaseString];
-      button = KeyboardButton::ascii_key([str cStringUsingEncoding: NSASCIIStringEncoding]);
+      const char *c_str = [str cStringUsingEncoding: NSASCIIStringEncoding];
+      button = KeyboardButton::ascii_key(c_str[0]);
     }
     }
   }
   }
 
 

+ 3 - 0
panda/src/cocoadisplay/config_cocoadisplay.h

@@ -17,8 +17,11 @@
 
 
 #include "pandabase.h"
 #include "pandabase.h"
 #include "notifyCategoryProxy.h"
 #include "notifyCategoryProxy.h"
+#include "configVariableBool.h"
 
 
 NotifyCategoryDecl(cocoadisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
 NotifyCategoryDecl(cocoadisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
+
+extern ConfigVariableBool gl_support_fbo;
   
   
 extern EXPCL_PANDAGL void init_libcocoadisplay();
 extern EXPCL_PANDAGL void init_libcocoadisplay();
 
 

+ 6 - 0
panda/src/cocoadisplay/config_cocoadisplay.mm

@@ -27,6 +27,12 @@ ConfigureFn(config_cocoadisplay) {
   init_libcocoadisplay();
   init_libcocoadisplay();
 }
 }
 
 
+ConfigVariableBool gl_support_fbo
+  ("gl-support-fbo", true,
+   PRC_DESC("Configure this false if your GL's implementation of "
+            "EXT_framebuffer_object is broken.  The system might still be "
+            "able to create buffers using pbuffers or the like."));
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libcocoadisplay
 //     Function: init_libcocoadisplay
 //  Description: Initializes the library.  This must be called at
 //  Description: Initializes the library.  This must be called at

+ 1 - 1
panda/src/osxdisplay/osxGraphicsPipe.cxx

@@ -433,7 +433,7 @@ make_output(const string &name,
       if (!posixgsg->_supports_framebuffer_object ||
       if (!posixgsg->_supports_framebuffer_object ||
           posixgsg->_glDrawBuffers == NULL) {
           posixgsg->_glDrawBuffers == NULL) {
         return NULL;
         return NULL;
-      } else {
+      } else if (fb_prop.is_basic()) {
         // Early success - if we are sure that this buffer WILL
         // Early success - if we are sure that this buffer WILL
         // meet specs, we can precertify it.
         // meet specs, we can precertify it.
         precertify = true;
         precertify = true;

+ 20 - 12
panda/src/pnmimage/convert_srgb.cxx

@@ -14,17 +14,6 @@
 
 
 #include "convert_srgb.h"
 #include "convert_srgb.h"
 
 
-#ifdef __GNUC__
-#include <cpuid.h>
-#endif
-
-#ifdef _WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-#include <windows.h>
-#endif
-
 // Lookup tables for converting from unsigned char formats.
 // Lookup tables for converting from unsigned char formats.
 ALIGN_64BYTE const
 ALIGN_64BYTE const
 unsigned char to_srgb8_table[256] = { 0x00, 0x0d, 0x16, 0x1c, 0x22, 0x26, 0x2a,
 unsigned char to_srgb8_table[256] = { 0x00, 0x0d, 0x16, 0x1c, 0x22, 0x26, 0x2a,
@@ -119,9 +108,20 @@ has_sse2_sRGB_encode() {
   return true;
   return true;
 }
 }
 
 
-#else
+#elif defined(__i386__) || defined(_M_IX86)
 // SSE2 support not guaranteed.  Use a runtime detection mechanism.
 // SSE2 support not guaranteed.  Use a runtime detection mechanism.
 
 
+#ifdef __GNUC__
+#include <cpuid.h>
+#endif
+
+#ifdef _WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+#endif
+
 bool
 bool
 has_sse2_sRGB_encode() {
 has_sse2_sRGB_encode() {
 #if defined(__GNUC__)
 #if defined(__GNUC__)
@@ -162,4 +162,12 @@ has_sse2_sRGB_encode() {
   return has_support;
   return has_support;
 }
 }
 
 
+#else
+// Other architectures don't support SSE2 at all.
+
+bool
+has_sse2_sRGB_encode() {
+  return false;
+}
+
 #endif  // __SSE2__
 #endif  // __SSE2__

+ 1 - 1
panda/src/tinydisplay/tinyOsxGraphicsWindow.mm

@@ -1192,7 +1192,7 @@ OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, E
 
 
   if (keyDown) {
   if (keyDown) {
     if ((newModifiers & cmdKey) != 0) {
     if ((newModifiers & cmdKey) != 0) {
-      if (button == KeyboardButton::ascii_key("q") || button == KeyboardButton::ascii_key("w")) {
+      if (button == KeyboardButton::ascii_key('q') || button == KeyboardButton::ascii_key('w')) {
         // Command-Q or Command-W: quit the application or close the
         // Command-Q or Command-W: quit the application or close the
         // window, respectively.  For now, we treat them both the
         // window, respectively.  For now, we treat them both the
         // same: close the window.
         // same: close the window.