[SDL] Mac OS X vs. (Open)Darwin
Anders F Björklund
afb at algonet.se
Thu Sep 8 04:49:38 PDT 2005
As a test for running on plain "vanilla" Darwin,
I tried building just the X11 driver and disabled
the Cocoa ("Quartz") and Carbon ("toolbox") drivers.
It didn't work too good. :-P
It seems like the current autotools and source code
is a little confused on what is Darwin (or "Mach-O")
and what is Mac OS X (i.e. proprietary/closed source)
As a start, I differed between two different ARCHes:
- TARGET_MACOSX, which is: Darwin + Carbon / Cocoa
- TARGET_DARWIN, which is: Darwin with X11 and GLX
For Darwin - I'm running the usual test for GL and X11,
but for Mac OS X - I am instead checking for the Apple:
OpenGL.framework and defaulting the X11 driver to "off"
This worked OK, I only had to give the directories for
X11 _explicitly_ since the "/usr/include/X11" symlink
is messing up the later <GL/gl.h> detection code...
(Mac X11 SDK has: /usr/include/X11 -> ../X11R6/include/X11,
which makes autoconf "think" that it doesn't need to any
special -I for X11, since it could find <X11/Intrinsic.h>)
So I changed the Darwin X defaults to instead be:
I also had to conditionalize AudioUnit, and add an
explicit CoreFoundation next to the IOKit framework
(since those two *are* present in the Darwin install)
Also checked -lSystem before -ldl, for the dlfcn stuff.
(just a cosmetic issue, as the libdl.dylib is a symlink)
But there are still a few places/drivers left to fix...
(especially: joystick [only "NewPtr"], cdrom and audio)
Main Problem is:
#if defined(__APPLE__) && defined(__MACH__) ==> any Darwin
#if defined(MACOSX) ==> Mac OS X, including the frameworks
(where __APPLE__ and __MACH__ are added by the gcc compiler)
But Cocoa.framework, Carbon.framework and OpenGL.framework
are *not* available on Darwin - just on the "full" Mac OS X.
So those frameworks really should use "MACOSX" macro instead:
#include <OpenGL/gl.h> /* Header File For The OpenGL Library */
#include <OpenGL/glu.h> /* Header File For The GLU Library */
#include <GL/gl.h> /* Header File For The OpenGL Library */
#include <GL/glu.h> /* Header File For The GLU Library */
Unfortunately this macro is not added by default, by autotools. :-(
(I simply defined it as: TARGET_MACOSX = HAVE_COCOA || HAVE_CARBON)
Does anyone have a *good* solution to this, save from adding -DMACOSX ?
As I see it, there are three major SDL drivers for the current Macs:
- MACOSX Cocoa ("Quartz") [Mac OS X's default]
- MACOSX Carbon ("toolbox") [Mac OS 9's default]
- DARWIN X11/GLX ("x11") [OpenDarwin default]
And I'm cleaning up the "other two" in this large old Macintosh
(as usual, I haven't actually tried it on a real Darwin installation
The full patch for configure.in will come later, after some more
It would also be _really_ cool if someone else could add the support
for building the SDL.framework from autotools, and not having to use
Xcode to do that... Nothing wrong with Xcode, but it would be useful ?
Here are the remaining symbols to clear out:
ld: Undefined symbols:
They all go away if you disable "cdrom" and "audio".
(so they will need alternate Darwin implementations)
Replacing NewPtr/DisposePtr with malloc/free was easier:
More information about the SDL