Snow Leopard and Lion

64-bit Compilation

As noted on the Build Page, Snow Leopard and Lion if not told otherwise will build 64-bit binaries. The latest version of gtk-osx-build-setup.sh has rearranged things so that this isn't a problem, but if you're using gtk-mac-menu, you'll have to switch to using GtkOSXApplication (also part of gtk-mac-integration). See Integration.

Building

So, how do you manage this? It's pretty easy. Make sure that you have the latest modulesets and jhbuildrc by running

gtk-osx-build-setup.sh

again. Then include the following in your .jhbuildrc-custom:

setup_sdk("10.6", "10.6", ["i386"])

That will build 32-bit Intel binaries using MacOSX10.6.sdk with MACOSX_DEPLOYMENT_TARGET=10.6. Python programmers will notice that the architecture argument is in a list, but don't call it directly with more than one architecture. There's a function for building universal libraries, setup_universal_build(), and one for cross-compiling PPC libraries on an Intel machine, but gtk+ doesn't cooperate, crashing when it tries to load icons. You can safely pass either "i386" or "x86_64" if you're building on an Intel box, or "ppc" or "ppc64" if on a PPC machine. Setup_sdk() will take care of all sorts of details like skipping ige-mac-integration for a 64-bit build.

XCode4

If you upgrade to XCode4, there's a wee gotcha: Apple has removed PPC cross-compilation support. That wouldn't normally bother us because Gtk+ doesn't like to be cross-compiled anyway. (It fails when it tries to precompile its icon cache because of endianness.) But we build two Perl modules, and one of them (XML::Parser) wants to cross-compile its XS module, and that fails. There are two workarounds: You can restore the ppc functionality or you can override the compilation flags as follows:

When the XML-parser build fails, open a shell (select "4").

$ mkdir hints
$ cat > hints/darwin.pl
      $self->{CCFLAGS} = q(-arch i386 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include)
^D (That's control-D, to complete the "cat".)
$ mkdir Expat/hints
$ cp hints/darwin.pl Expat/hints
^D (To exit the shell)

Select "1" (to rerun build)

Lion's XCode, 4.1, doesn't have PPC support, but neither do the installed Python and Perl interpreters, so that's not a problem. Lion provides SDKs only for itself and Snow Leopard, though, and that is a problem if you want to maintain compatibility with Leopard and Tiger, because the versions in the unix libraries (the ones in SDK/usr/lib) are versioned, and dyld will refuse to link with earlier versions at program load. For the moment, that means that to build Leopard or Tiger compatible programs you must build with Snow Leopard or earlier.

If you want x86_64, you can add an -arch flag for it (or change the i386 one) in the hints file.

PyGtk

PyGtk users and developers should note that Snow Leopard provides a bunch of pythons, with the default being 2.6. On a 64-bit processor (core2duo or xeon), it defaults to 64 bit, and unless you've managed to get PyGtk built for 64 bits, it won't work. Fortunately, you can easily get python to run in 32-bit mode by default: defaults write com.apple.versioner.python Prefer-32-Bit -bool yes or export VERSIONER_PYTHON_PREFER_32_BIT=yes. jhbuildrc already sets the environment variable when appropriate, so if you work in a jhbuild shell, you're covered. See man python for more details on this, or for how to switch between the installed Python versions.

Snow Leopard's pythons are all build with MACOSX_DEPLOYMENT_TARGET=10.6, so if you want to support older OSX versions (via setup_sdk(), of course), you'll need to build python from gtk-osx-python.modules. (The problem with the Apple pythons, which configure hides, is that the Apple-provided pythons encounter the MACOSX_DEPLOYMENT_TARGET difference and quit, so the include directory doesn't get set and gcc can't find Python.h -- which is the error that configure reports.)

Note the autogenargs for python. Python's configure sets its own CFLAGS, so in order to get something other than an x86_64 build on SL, we have to tell it to build universal. "32-bit" builds ppc and i386; "3-way" builds ppc, i386, and x86_64. Don't build x86_64 unless you're also building everything else x86_64, or it won't run on Snow Leopard without specifying "arch -i386" in front of any command you run. This python lacks Apple's "versioner" magic, so setting that in the environment or in defaults won't do anything for us. If you're building against 10.4u.sdk, you don't need the enable-universalsdk argument, as that's the default in Python. If you're building against another SDK (even if it's 10.6 or the installed default) you need this. (Obviously set it to whatever you're actually using. If you're using the installed libraries, set it to "/". See Python-2.7.1/Mac/README for more details about building Python for Macs.

Projects/GTK+/OSX/SnowLeopard (last edited 2013-11-22 15:36:59 by WilliamJonMcCann)