Friday, October 22, 2010

Porting Windstille to MacOSX

Some notes on porting Windstille to MacOSX:
  • PPC iBooks don't support booting from USB, good luck reinstalling a OS when your internal drive breaks
  • everything earlier then MacOSX 10.4 Tiger seems completely unusable by now, as almost all software won't run on it, no support for building universal binaries either, OSX seems to go obsolete a lot faster then Windows
  • MacPorts provides a good and up to date selection of software, you can almost find anything that you might need to build your software there, but MacPorts requires to compile everything from source, so installing a full build environment can take quite a few hours
  • Flink provides binaries, but is outdated enough to be of not much use
  • some include directives need changes, for example GL/gl.h to OpenGL/gl.h, AL/al.h to OpenAL/al.h
  • native MacOSX libraries come in the form of frameworks, which bypass the usual -I, -l and -L flags and use a "-framework SDL" flag for gcc
  • SDL comes as a native precompiled OSX framework library
  • using the SDL framework requires to hardcode the include path or doing #ifdef's, as there is no sdl-config and the way frameworks requires you to include SDL_image with , which is incompatible with the way things are done in Linux
  • using g++ with -isystem DIR instead of -IDIR results in "error: template with C linkage", so don't do that on older MacOSXs
  • otool is the equivalent of ldd on MacOSX
  • building a standard MacOSX software bundle requires some fudging with the hard compiled path variables
  • Gtk+ is by far the most troublesome piece of software to get up and running, it doesn't come in binary form but only in a fragile jhbuild
  • MacOSX specific code can be isolated with a #ifdef __APPLE__ or on the Python side with a sys.platform == "darwin"
Overall porting Windstille to MacOSX went far smoother then expected, at least as far as Windstille itself is concerned, at first I struggled a bit with manually building many software packages, but once I learned about MacPorts, I switched over to that and had a smooth ride after that. SDL comes as standard MacOSX framework and most of the other dependencies I could grab directly from MacPorts. xcftools was the only exception and that had to be build manually. The Windstille SCons build scripts however need some bigger changes to handle the different naming of some libraries on MacOSX. Building the Windstille Editor is a different story, so far I haven't managed to do that, as that depends on Gtk+, Gtkmm and GtkGLExtmm and all of those depend on dozens of other libraries themselves. I think the Gtk+ libraries in MacPorts all depend on X11 and aren't native, but so far I haven't tried them.

PS: While porting Windstille over to MacOSX I also fixed a few issues with the render path for older hardware, so it should be able to run (or crawl) again on Geforce2MX style hardware.

No comments: