Compiling ScummVM/Mac OS X Crosscompiling
If you're building ScummVM on Mac OS X for your own use only, then just doing things the 'normal' way works fine and you can ignore the below.
However, if it's a build you're planning to release to anyone else, there's some things you need to be aware of!
Mac OS X 10.2.x vs 10.3.x vs 10.4.x vs 10.5.x
To support all the above versions of Mac OS X, we basically need to build two copies of ScummVM, and merge them together.
- Our first build is a PPC build, which we'll compile using the 10.2 SDK
- The second build is an Intel build, which we'll compile against the 10.4u SDK.
PPC build
For our PPC build to work on all PPC versions of Mac OS X above 10.2, there's a few requirements:
- We need to use GCC 3.3
- We need to compile against the 10.2 SDK
- All the libraries we make use of also need to be compiled using the above.
First, make sure you've installed the 10.2 SDK. This is part of the XCode distribution, but needs to be specifically installed.
Then, there's some environmental variables you need to define. Remember to do this both before you run ./configure, and before make!
export CC='gcc-3.3' export CXX='g++-3.3' export GCC_VERSION='g++-3.3' export CPP='cpp-3.3' export CXXFLAGS='-arch ppc' export CFLAGS='-arch ppc' export SDK="/Developer/SDKs/MacOSX10.2.8.sdk" export LDFLAGS="-L$SDK/usr/lib/gcc/darwin/3.3 -arch ppc" export CPPFLAGS="-I$SDK/usr/include -arch ppc -F$SDK/System/Library/Frameworks" export NEXT_ROOT="$SDK" export MACOSX_DEPLOYMENT_TARGET='10.2'
Basically we're forcing the configure scripts, and make, to use GCC 3.3, and to use all the libraries and include files that are in the 10.2 SDK, instead of the system ones.
The above is actually the same, no matter whether you're compiling this version on an Intel machine or PPC machine. If you specify the above, you'll output a PPC binary in either case.
Now, first we'll have to download and build the dependency libs we're needing for our build. SDL is the only required one, plus whatever optional libs you want, like libMAD, Ogg Vorbis, etc, etc. If you include zlib, there's some special instructions below.
The twist here, is that you should install these libs to a seperate location from the regular system libraries. Since we're compiling PPC 10.2 specific versions, we don't want to overwrite our regular libraries. I went with /opt/1028libs/. Just set this with the --prefix option to the ./configure script, for all the libraries you're including. Do this, and make sure you've defined the above environmental libraries both when you do ./configure and when you do make, and you should be set.
Once you've set up all the dependency libraries, you're ready to build ScummVM itself.
First, there's a couple of minor changes we have to do to the ScummVM Makefile.
Find the line that says:
OSXOPT=/sw
Change this to whatever root you used to install the dependency libraries. In my case, I've changed it to:
OSXOPT=/opt/1028libs
Next, find the section that starts with:
scummvm-static: $(OBJS)
This is the part of the makefile that compiles our static binary (so we can distribute it to others without them having to have all the libraries installed) In this section, find and remove this line:
-lSystemStubs \
Also, if want to include zlib, change the line:
-lz
to
$(OSXOPT)/lib/libz.a
This will ensure we link zlib in statically instead of dynamically, which avoids some obscure problems we've had on 10.2.x.
At this point, we also need to make sure that the configure script finds the correct version of sdl-config (In other words, the one we compiled ourselves and put, for example, in /opt/1028libs.
We do this thusly: export PATH="/opt/1028libs/bin:$PATH" When you've done the above, it's time to run ./configure. For each library you want to include, you have to tell ScummVM where it can find it. So, for me, that would be:
./configure \ --with-sdl-prefix=/opt/1028libs/bin \ --with-mpeg2-prefix=/opt/1028libs --with-mad-prefix=/opt/1028libs \ --with-ogg-prefix=/opt/1028libs --with-vorbis-prefix=/opt/1028libs \ --with-flac-prefix=/opt/1028libs
When that's done, run make as usual (as always, make sure you've defined the environmental variables that enable cross compiling), and you're done.
Intel build
Similarly to the PPC build, there's a few requirements for making an Intel build that'll work on both 10.4 and 10.5
- Compile using GCC 4.0 (In fact, you can't even compile Intel binaries using GCC 3.3)
- Compile against the 10.4u SDK
- Same for all dependency libraries.
Also note that you should run ./configure with --disable-nasm. The x86 assembly versions of the HQ2x and HQ3x scalers don't work properly on Mac OS X. Since Intel Macs are, by default, fast enough not to need them in either case, it's not a very big deal.
Compiling on an 10.4.x Intel box
If you're using 10.4.x and have an Intel CPU, you basically don't have to do anything special at all. Just compile ScummVM like you normally would, and use MacPorts or Fink for the dependency libraries.
Compiling on an 10.5.x Intel box
First, install the 10.4u SDK. Then define these environmental variables:
export CXXFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk' export CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk'
Compile all the libraries using the above, and then ScummVM itself (specifying where to find the libraries, like we did for the PPC build above).
Compiling on a PPC box
I don't do this myself, so I can't tell you the exact steps to do here. It shouldn't be much more than adding '-arch intel' to the CFLAGS and CXXFLAGS used above.
Putting it all together
Now we want to put merge the two binaries together, and make a package for distribution.
- Run 'make bundle' for your PPC build, using all the PPC settings.
- Do the same for the Intel build, using all the Intel settings.
- Pick one of the build directories
- Copy 'scummvm-static' from the PPC build directory, to a file called 'scummvm-static-ppc' in whatever build directory you chose.
- Copy 'scummvm-static' from the Intel build directory, to 'scummvm-static-x86' in the same directory.
- Run 'strip' on both of the above files to remove debugging info (otherwise the files will be tens of megabytes large).
- Run 'lipo -create scummvm-static-x86 scummvm-static-ppc -output scummvm-static'
- Run 'make osxsnap'
Tada! The resulting ScummVM-snapshot.dmg is a package of ScummVM that should work on Mac OS X 10.2, 10.3, 10.4, 10.5, both Intel and PPC builds.