forked from rbowler/spinhawk
-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.OSX
57 lines (46 loc) · 2.63 KB
/
README.OSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(The previous contents of this file were removed, as they haven't applied in
years.)
To compile on OS X for another architecture than the one running, or another
OS version, you have to supply several arguments to the configure command.
To force a particular architecture, you need to specify the machine
architecture to the gcc command with the "-arch <architecture>" operand. You
also need to tell configure what environment you're building for, with
--host.
ARCHITECTURE -arch --host
32-bit Intel i386 i686
64-bit Intel x86_64 x86_64
32-bit PowerPC ppc powerpc
64-bit PowerPC ppc64 powerpc64
The argument for --host is the first part of a build triplet, specified as
<architecture>-<vendor>-<OS>. The vendor is apple for all OS X builds. OS is
"darwin8.8.0" for OS X 10.4 (Tiger), and "darwin9.6.0" for OS X 10.5
(Leopard). This makes, for example, building for 64-bit Intel on Leopard use
"--host x86_64-apple-darwin9.6.0". The -arch argument is specified by
overriding the CC (C compiler) value and adding it to the end, as in CC="gcc
-arch x86_64".
If you're building for an OS that's not the one you're running on, you also
need to tell the build environment that you're doing so. For building for
Tiger on Leopard, you need to add two arguments to the configure
invocation: "CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk'
LDFLAGS='-isysroot/Developer/SDKs/MacOSX10.4u.sdk
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'". (All on one line, of
course.) You also need to add an environment variable that's passed to gcc
upon invocation, and this takes adding it to the beginning of the CC value,
as in CC="/usr/bin/env MACOSX_DEPLOYMENT_TARGET=10.4 gcc -arch ix86_64".
This makes a complete invocation for building for 32-bit Intel for Tiger on
Leopard (again, all on one line):
CC="/usr/bin/env MACOSX_DEPLOYMENT_TARGET=10.4 gcc -arch i386"
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.4u.sdk' LDFLAGS='-isysroot
/Developer/SDKs/MacOSX10.4u.sdk
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk' ./configure
--enable-setuid-hercifc --host=i686-apple-darwin8.8.0
Building 32-bit Intel for Leopard on Leopard is easier:
CC="gcc -arch i386" ./configure --enable-setuid-hercifc
--host=i686-apple-darwin9.6.0
(Note that building a 64-bit Intel version on a Mac with a 64-bit Intel
processor still requires explicitly setting the architecture. If you don't,
you'll get a 32-bit Intel version.)
Once you have the various architectures built, you can combine them into one
binary with lipo. This is done by saying "lipo <input-files> -output
<output-file> -create". The best approach is to automate this with a shell
script; I've done this for my own use.