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