You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-osx.txt 8.3KB

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