9c1e9f0b |
1 | Mac OS X build instructions\r |
2 | Laszlo Hanyecz (solar@heliacal.net)\r |
3 | \r |
4 | \r |
5 | Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.\r |
6 | \r |
7 | All of the commands should be executed in Terminal.app.. it's in\r |
8 | /Applications/Utilities\r |
9 | \r |
10 | You need to install XCode with all the options checked so that the compiler\r |
11 | and everything is available in /usr not just /Developer\r |
12 | I think it comes on the DVD but you can get the current version from\r |
13 | http://developer.apple.com\r |
14 | \r |
15 | \r |
16 | 1. Pick a directory to work inside.. something like ~/bitcoin works. The\r |
17 | structure I use looks like this:\r |
18 | (~ is your home directory)\r |
19 | \r |
20 | ~/bitcoin\r |
21 | ~/bitcoin/trunk # source code\r |
22 | ~/bitcoin/deps # dependencies.. like libraries and headers needed to compile\r |
23 | ~/bitcoin/Bitcoin.app # the application bundle where you can run the app\r |
24 | \r |
25 | Just execute: mkdir ~/bitcoin\r |
26 | This will create the top dir for you..\r |
27 | \r |
28 | WARNING: do not use the ~ notation with the configure scripts.. use the full\r |
29 | name of the directory, for example /Users/james/bitcoin/deps for a user named\r |
30 | 'james'. In my examples I am using 'macosuser' so make sure you change that.\r |
31 | \r |
32 | 2. Check out the trunk version of the bitcoin code from subversion:\r |
33 | \r |
34 | cd ~/bitcoin\r |
35 | svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk\r |
36 | \r |
37 | This will make ~/bitcoin/trunk for you with all the files from subversion. \r |
38 | \r |
39 | 3. Get and build the dependencies\r |
40 | \r |
41 | \r |
42 | Boost\r |
43 | -----\r |
44 | \r |
45 | Download from http://www.boost.org/users/download/\r |
46 | I'm assuming it ended up in ~/Downloads..\r |
47 | \r |
48 | mkdir ~/bitcoin/deps\r |
49 | cd ~/bitcoin/deps\r |
50 | tar xvjf ~/Downloads/boost_1_42_0.tar.bz2\r |
51 | cd boost_1_42_0\r |
52 | ./bootstrap.sh\r |
53 | ./bjam architecture=combined address-model=32_64 macosx-version=10.6 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install\r |
54 | \r |
55 | This part takes a while.. use your judgement and fix it if something doesn't\r |
56 | build for some reason.\r |
57 | \r |
58 | Change the prefix to whatever your directory is (my username in this example\r |
59 | is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change\r |
60 | to 10.5 if you're using leopard.\r |
61 | \r |
62 | This is what my output looked like at the end:\r |
63 | ...failed updating 2 targets...\r |
64 | ...skipped 144 targets...\r |
65 | ...updated 8074 targets...\r |
66 | \r |
67 | \r |
68 | OpenSSL\r |
69 | -------\r |
70 | \r |
71 | Download from http://www.openssl.org/source/\r |
72 | \r |
73 | We would like to build this as a 32 bit/64 bit library so we actually build it\r |
74 | 2 times and join it together here.. If you downloaded with safari it already\r |
75 | uncompressed it so it will just be a tar not a tar.gz\r |
76 | \r |
77 | cd ~/bitcoin/deps\r |
78 | tar xvf ~/Downloads/openssl-1.0.0.tar\r |
79 | mv openssl-1.0.0 openssl-1.0.0-i386\r |
80 | tar xvf ~/Downloads/openssl-1.0.0.tar\r |
81 | mv openssl-1.0.0 openssl-1.0.0-x86_64\r |
82 | # build i386 (32 bit intel) binary\r |
83 | cd openssl-1.0.0-i386\r |
84 | ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin-i386-cc && make\r |
85 | make install # only do this on one of the architectures, to install the headers\r |
86 | cd ..\r |
87 | # build x86_64 (64 bit intel) binary\r |
88 | cd openssl-1.0.0-x86_64\r |
89 | ./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin64-x86_64-cc && make\r |
90 | cd ..\r |
91 | \r |
92 | # combine the libs\r |
93 | cd ~/bitcoin/deps\r |
94 | lipo -arch i386 openssl-1.0.0-i386/libcrypto.a -arch x86_64 openssl-1.0.0-x86_64/libcrypto.a -o lib/libcrypto.a -create\r |
95 | lipo -arch i386 openssl-1.0.0-i386/libssl.a -arch x86_64 openssl-1.0.0-x86_64/libssl.a -o lib/libssl.a -create\r |
96 | \r |
97 | Verify your binaries\r |
98 | \r |
99 | file lib/libcrypto.a\r |
100 | \r |
101 | output should look like this:\r |
102 | \r |
103 | ib/libcrypto.a: Mach-O universal binary with 2 architectures\r |
104 | lib/libcrypto.a (for architecture i386): current ar archive random library\r |
105 | lib/libcrypto.a (for architecture x86_64): current ar archive random library\r |
106 | \r |
107 | \r |
108 | Berkeley DB\r |
109 | -----------\r |
110 | \r |
111 | Download from http://freshmeat.net/projects/berkeleydb/\r |
112 | \r |
113 | cd ~/bitcoin/deps\r |
114 | tar xvf ~/Downloads/db-4.8.26.tar\r |
115 | cd db-4.8.26/build_unix\r |
116 | ../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install\r |
117 | \r |
118 | \r |
119 | wxWidgets\r |
120 | ---------\r |
121 | \r |
122 | This is the big one..\r |
123 | \r |
124 | Check it out from svn\r |
125 | \r |
126 | cd ~/bitcoin/deps\r |
127 | svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk\r |
128 | \r |
129 | This will make a wxWidgets-trunk directory in deps.\r |
130 | \r |
131 | Use this script snippet, change your prefix to whatever your dir is:\r |
132 | \r |
133 | PREFIX=~/bitcoin/deps\r |
134 | SRCDIR="$PREFIX/wxWidgets-trunk"\r |
135 | BUILDDIR="$SRCDIR/macbuild"\r |
136 | \r |
137 | cd "$PREFIX" &&\r |
138 | #svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&\r |
139 | cd "$SRCDIR" &&\r |
140 | \r |
141 | [ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&\r |
142 | sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&\r |
143 | \r |
144 | [ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&\r |
145 | sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&\r |
146 | \r |
147 | \r |
148 | \r |
149 | rm -vrf "$BUILDDIR" &&\r |
150 | mkdir "$BUILDDIR" &&\r |
151 | cd "$BUILDDIR" &&\r |
152 | \r |
153 | ../configure --prefix="$PREFIX" \\r |
154 | --with-osx_cocoa \\r |
155 | --disable-shared \\r |
156 | --disable-debug_flag \\r |
157 | --with-macosx-version-min=10.5 \\r |
158 | --enable-stl \\r |
159 | --enable-utf8 \\r |
160 | --enable-universal_binary \\r |
161 | --with-libjpeg=builtin \\r |
162 | --with-libpng=builtin \\r |
163 | --with-regex=builtin \\r |
164 | --with-libtiff=builtin \\r |
165 | --with-zlib=builtin \\r |
166 | --with-expat=builtin \\r |
167 | --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&\r |
168 | \r |
169 | \r |
170 | find . -name Makefile | \r |
171 | while read i; do \r |
172 | echo $i; \r |
173 | sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new && \r |
174 | mv "$i" "$i".old && \r |
175 | mv "$i".new "$i"; \r |
176 | done\r |
177 | \r |
178 | \r |
179 | \r |
180 | make && \r |
181 | make install\r |
182 | \r |
183 | \r |
184 | \r |
185 | Now you should be able to build bitcoin\r |
186 | \r |
187 | cd ~/bitcoin/trunk\r |
188 | make -f makefile.osx bitcoin\r |
189 | \r |
190 | Before you can run it, you need to create an application bundle for Mac OS.\r |
191 | Create the directories in terminal using mkdir and copy the files into place.\r |
192 | They are available at http://heliacal.net/~solar/bitcoin/mac-build/\r |
193 | You need the Info.plist and the .ins file. The Contents/MacOS/bitcoin file is\r |
194 | the output of the build.\r |
195 | Your directory structure should look like this:\r |
196 | \r |
197 | Bitcoin.app\r |
198 | Bitcoin.app/Contents\r |
199 | Bitcoin.app/Contents/Info.plist\r |
200 | Bitcoin.app/Contents/MacOS\r |
201 | Bitcoin.app/Contents/MacOS/bitcoin\r |
202 | Bitcoin.app/Contents/Resources\r |
203 | Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns\r |
204 | \r |
205 | To run it you can just click the Bitcoin.app in Finder, or just do open\r |
206 | ~/bitcoin/Bitcoin.app\r |
207 | If you want to run it with arguments you can just run it without backgrounding\r |
208 | by specifying the full name in terminal:\r |
209 | ~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66\r |