Skip to content

Commit e9e7bb9

Browse files
committed
Update mac Makefile and build instructions to use MacPorts
1 parent ff3b235 commit e9e7bb9

File tree

2 files changed

+58
-175
lines changed

2 files changed

+58
-175
lines changed

doc/build-osx.txt

Lines changed: 19 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Copyright (c) 2010 Laszlo Hanyecz
2-
Portions Copyright (c) 2011 Douglas Huff
1+
Copyright (c) 2011 Bitcoin Developers
32
Distributed under the MIT/X11 software license, see the accompanying file
43
license.txt or http://www.opensource.org/licenses/mit-license.php. This
54
product includes software developed by the OpenSSL Project for use in the
@@ -26,163 +25,29 @@ everything is available in /usr not just /Developer I think it comes on the DVD
2625
but you can get the current version from http://developer.apple.com
2726

2827

29-
1. Pick a directory to work inside.. something like ~/bitcoin works. The
30-
structure I use looks like this:
28+
1. Clone the github tree to get the source code:
3129

32-
(~ is your home directory)
30+
git clone git@github.com:bitcoin/bitcoin.git bitcoin
3331

34-
~/bitcoin
35-
~/bitcoin/bitcoin # Upstream source tree
36-
~/bitcoin/src # source code (symlink to ~/bitcoin/bitcoin/src)
37-
~/bitcoin/deps # dependencies.. like libraries and headers needed to compile
32+
2. Download and install MacPorts from http://www.macports.org/
3833

39-
Just execute: mkdir ~/bitcoin
40-
This will create the top dir for you..
34+
3. Install dependencies from MacPorts
4135

42-
WARNING: do not use the ~ notation with the configure scripts.. use the full
43-
name of the directory, for example /Users/james/bitcoin/deps for a user named
44-
'james'. In my examples I am using 'macosuser' so make sure you change that.
36+
sudo port install boost db48 openssl
4537

46-
2. Check out the bitcoin code from github:
38+
Install the right version of miniupnpc:
39+
pushd bitcoin/contrib/minipupnpc; sudo port install; popd
40+
(this will be unnecessary soon, you will just port install miniupnpc
41+
along with the rest of the dependencies).
4742

48-
cd ~/bitcoin
49-
git clone https://github.com/bitcoin/bitcoin.git
50-
ln -s bitcoin/src src
43+
4. Now you should be able to build bitcoind:
5144

52-
This will make ~/bitcoin/bitcoin for you with all the files from git. This puts
53-
the actual sources in ~/bitcoin/bitcoin/src and create a symlink src in
54-
~/bitcoin to this location.
45+
cd bitcoin/src
46+
make -f makefile.osx
5547

56-
3. Get and build the dependencies
57-
58-
59-
Boost
60-
-----
61-
62-
Download from http://www.boost.org/users/download/
63-
I'm assuming it ended up in ~/Downloads..
64-
65-
mkdir ~/bitcoin/deps
66-
cd ~/bitcoin/deps
67-
tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
68-
cd boost_1_42_0
69-
./bootstrap.sh
70-
./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
71-
72-
If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X
73-
version instead of 10.5.
74-
75-
This part takes a while.. use your judgement and fix it if something doesn't
76-
build for some reason.
77-
78-
Change the prefix to whatever your directory is (my username in this example
79-
is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change
80-
to 10.5 if you're using leopard.
81-
82-
This is what my output looked like at the end:
83-
...failed updating 2 targets...
84-
...skipped 144 targets...
85-
...updated 8074 targets...
86-
87-
88-
OpenSSL
89-
-------
90-
91-
(System or MacPorts openssl will work fine. Optional.)
92-
93-
Download from http://www.openssl.org/source/
94-
95-
We would like to build this as a 32 bit/64 bit library so we actually build it
96-
2 times and join it together here.. If you downloaded with safari it already
97-
uncompressed it so it will just be a tar not a tar.gz
98-
99-
cd ~/bitcoin/deps
100-
tar xvf ~/Downloads/openssl-1.0.0.tar
101-
mv openssl-1.0.0 openssl-1.0.0-i386
102-
tar xvf ~/Downloads/openssl-1.0.0.tar
103-
mv openssl-1.0.0 openssl-1.0.0-x86_64
104-
# build i386 (32 bit intel) binary
105-
cd openssl-1.0.0-i386
106-
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make
107-
make install # only do this on one of the architectures, to install the headers
108-
cd ..
109-
# build x86_64 (64 bit intel) binary
110-
cd openssl-1.0.0-x86_64
111-
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make
112-
cd ..
113-
114-
# combine the libs
115-
cd ~/bitcoin/deps
116-
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
117-
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
118-
119-
Verify your binaries
120-
121-
file lib/libcrypto.a
122-
123-
output should look like this:
124-
125-
lib/libcrypto.a: Mach-O universal binary with 2 architectures
126-
lib/libcrypto.a (for architecture i386): current ar archive random library
127-
lib/libcrypto.a (for architecture x86_64): current ar archive random library
128-
129-
130-
miniupnpc
131-
---------
132-
133-
(MacPorts miniupnpc package works fine. You will need to modify makefile.)
134-
135-
The process for miniupnpc (optional) is similar to that of OpenSSL.
136-
137-
Download from http://miniupnp.tuxfamily.org/files/.
138-
139-
cd ~/bitcoin/deps
140-
tar xvf ~/Downloads/miniupnpc-1.6.tar
141-
mv miniupnpc-1.6 miniupnpc-1.6-x86_64
142-
tar xvf ~/Downloads/miniupnpc-1.6.tar
143-
mv miniupnpc-1.6 miniupnpc-1.6-i386
144-
# build x86_64 (64 bit intel) binary
145-
cd miniupnpc-1.6-x86_64
146-
export CFLAGS="-arch x86_64"
147-
export LDFLAGS="-arch x86_64"
148-
export PREFIX="/Users/macuser/bitcoin/deps"
149-
make && make install
150-
# build i386 (32 bit intel) binary
151-
cd miniupnpc-1.6-i386
152-
export CFLAGS="-arch i386"
153-
export LDFLAGS="-arch i386"
154-
export PREFIX="/Users/macuser/bitcoin/deps"
155-
make
156-
157-
# combine the libs
158-
cd ~/bitcoin/deps
159-
lipo -arch i386 miniupnpc-1.6-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.6-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create
160-
161-
Verify your binaries
162-
163-
file lib/libminiupnpc.a
164-
165-
output should look like this:
166-
167-
lib/libminiupnpc.a: Mach-O universal binary with 2 architectures
168-
lib/libminiupnpc.a (for architecture i386): current ar archive random library
169-
lib/libminiupnpc.a (for architecture x86_64): current ar archive random library
170-
171-
172-
Berkeley DB
173-
-----------
174-
175-
(System or MacPorts version work fine.)
176-
177-
Download from http://freshmeat.net/projects/berkeleydb/
178-
179-
cd ~/bitcoin/deps
180-
tar xvf ~/Downloads/db-4.8.30.tar
181-
cd db-4.8.30/build_unix
182-
../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
183-
184-
185-
Now you should be able to build bitcoind:
186-
187-
cd ~/bitcoin/src
188-
make -f makefile.osx bitcoind
48+
Run:
49+
./bitcoind --help # for a list of command-line options.
50+
Run
51+
./bitcoind -daemon # to start the bitcoin daemon.
52+
Run
53+
./bitcoind help # When the daemon is running, to get a list of RPC commands

src/makefile.osx

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
# Copyright (c) 2010 Laszlo Hanyecz
1+
# -*- mode: Makefile; -*-
2+
# Copyright (c) 2011 Bitcoin Developers
23
# Distributed under the MIT/X11 software license, see the accompanying
34
# file license.txt or http://www.opensource.org/licenses/mit-license.php.
45

56
# Mac OS X makefile for bitcoin
6-
# Laszlo Hanyecz (solar@heliacal.net)
7+
# Originally by Laszlo Hanyecz (solar@heliacal.net)
78

89
CXX=llvm-g++
9-
DEPSDIR=/Users/macosuser/bitcoin/deps
10+
DEPSDIR=/opt/local
1011

1112
INCLUDEPATHS= \
12-
-I"$(DEPSDIR)/include"
13+
-I"$(DEPSDIR)/include" \
14+
-I"$(DEPSDIR)/include/db48"
1315

1416
LIBPATHS= \
15-
-L"$(DEPSDIR)/lib"
17+
-L"$(DEPSDIR)/lib" \
18+
-L"$(DEPSDIR)/lib/db48"
1619

17-
USE_UPNP:=0
20+
USE_UPNP:=1
1821

1922
LIBS= -dead_strip \
20-
$(DEPSDIR)/lib/libdb_cxx-4.8.a \
21-
$(DEPSDIR)/lib/libboost_system.a \
22-
$(DEPSDIR)/lib/libboost_filesystem.a \
23-
$(DEPSDIR)/lib/libboost_program_options.a \
24-
$(DEPSDIR)/lib/libboost_thread.a \
25-
$(DEPSDIR)/lib/libssl.a \
26-
$(DEPSDIR)/lib/libcrypto.a
23+
-ldb_cxx-4.8 \
24+
-lboost_system-mt \
25+
-lboost_filesystem-mt \
26+
-lboost_program_options-mt \
27+
-lboost_thread-mt \
28+
-lssl \
29+
-lcrypto
2730

28-
DEFS=-D__WXMAC_OSX__ -DNOPCH -DMSG_NOSIGNAL=0 -DUSE_SSL
31+
DEFS=-DMSG_NOSIGNAL=0 -DUSE_SSL
2932

3033
DEBUGFLAGS=-g
3134
# ppc doesn't work because we don't support big-endian
32-
CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
35+
CFLAGS=-mmacosx-version-min=10.5 -arch i386 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
3336
HEADERS = \
3437
base58.h \
3538
bignum.h \
@@ -67,27 +70,42 @@ OBJS= \
6770
obj/wallet.o
6871

6972
ifdef USE_UPNP
70-
LIBS += $(DEPSDIR)/lib/libminiupnpc.a
73+
LIBS += -lminiupnpc
7174
DEFS += -DUSE_UPNP=$(USE_UPNP)
7275
endif
7376

7477

7578
all: bitcoind
7679

77-
obj/nogui/%.o: %.cpp $(HEADERS)
78-
$(CXX) -c $(CFLAGS) -o $@ $<
80+
# auto-generated dependencies:
81+
-include obj/nogui/*.P
82+
-include obj/test/*.P
83+
84+
obj/nogui/%.o: %.cpp
85+
$(CXX) -c $(CFLAGS) -MMD -o $@ $<
86+
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
87+
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
88+
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
89+
rm -f $(@:%.o=%.d)
7990

8091
bitcoind: $(OBJS:obj/%=obj/nogui/%)
8192
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
8293

83-
obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
84-
$(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp
94+
obj/test/%.o: test/%.cpp
95+
$(CXX) -c $(CFLAGS) -MMD -o $@ $<
96+
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
97+
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
98+
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
99+
rm -f $(@:%.o=%.d)
85100

86101
test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
87-
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework
102+
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
88103

89104
clean:
90105
-rm -f bitcoind test_bitcoin
91106
-rm -f obj/*.o
92107
-rm -f obj/nogui/*.o
93108
-rm -f obj/test/*.o
109+
-rm -f obj/*.P
110+
-rm -f obj/nogui/*.P
111+
-rm -f obj/test/*.P

0 commit comments

Comments
 (0)