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