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