Update mac Makefile and build instructions to use MacPorts

This commit is contained in:
Gavin Andresen 2011-10-05 11:09:28 -04:00
parent ff3b235580
commit e9e7bb968b
2 changed files with 58 additions and 175 deletions

View file

@ -1,5 +1,4 @@
Copyright (c) 2010 Laszlo Hanyecz Copyright (c) 2011 Bitcoin Developers
Portions Copyright (c) 2011 Douglas Huff
Distributed under the MIT/X11 software license, see the accompanying file Distributed under the MIT/X11 software license, see the accompanying file
license.txt or http://www.opensource.org/licenses/mit-license.php. This license.txt or http://www.opensource.org/licenses/mit-license.php. This
product includes software developed by the OpenSSL Project for use in the 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
but you can get the current version from http://developer.apple.com but you can get the current version from http://developer.apple.com
1. Pick a directory to work inside.. something like ~/bitcoin works. The 1. Clone the github tree to get the source code:
structure I use looks like this:
(~ is your home directory) git clone git@github.com:bitcoin/bitcoin.git bitcoin
~/bitcoin 2. Download and install MacPorts from http://www.macports.org/
~/bitcoin/bitcoin # Upstream source tree
~/bitcoin/src # source code (symlink to ~/bitcoin/bitcoin/src)
~/bitcoin/deps # dependencies.. like libraries and headers needed to compile
Just execute: mkdir ~/bitcoin 3. Install dependencies from MacPorts
This will create the top dir for you..
WARNING: do not use the ~ notation with the configure scripts.. use the full sudo port install boost db48 openssl
name of the directory, for example /Users/james/bitcoin/deps for a user named
'james'. In my examples I am using 'macosuser' so make sure you change that.
2. Check out the bitcoin code from github: Install the right version of miniupnpc:
pushd bitcoin/contrib/minipupnpc; sudo port install; popd
(this will be unnecessary soon, you will just port install miniupnpc
along with the rest of the dependencies).
cd ~/bitcoin 4. Now you should be able to build bitcoind:
git clone https://github.com/bitcoin/bitcoin.git
ln -s bitcoin/src src
This will make ~/bitcoin/bitcoin for you with all the files from git. This puts cd bitcoin/src
the actual sources in ~/bitcoin/bitcoin/src and create a symlink src in make -f makefile.osx
~/bitcoin to this location.
3. Get and build the dependencies Run:
./bitcoind --help # for a list of command-line options.
Run
Boost ./bitcoind -daemon # to start the bitcoin daemon.
----- Run
./bitcoind help # When the daemon is running, to get a list of RPC commands
Download from http://www.boost.org/users/download/
I'm assuming it ended up in ~/Downloads..
mkdir ~/bitcoin/deps
cd ~/bitcoin/deps
tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
cd boost_1_42_0
./bootstrap.sh
./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
If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X
version instead of 10.5.
This part takes a while.. use your judgement and fix it if something doesn't
build for some reason.
Change the prefix to whatever your directory is (my username in this example
is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change
to 10.5 if you're using leopard.
This is what my output looked like at the end:
...failed updating 2 targets...
...skipped 144 targets...
...updated 8074 targets...
OpenSSL
-------
(System or MacPorts openssl will work fine. Optional.)
Download from http://www.openssl.org/source/
We would like to build this as a 32 bit/64 bit library so we actually build it
2 times and join it together here.. If you downloaded with safari it already
uncompressed it so it will just be a tar not a tar.gz
cd ~/bitcoin/deps
tar xvf ~/Downloads/openssl-1.0.0.tar
mv openssl-1.0.0 openssl-1.0.0-i386
tar xvf ~/Downloads/openssl-1.0.0.tar
mv openssl-1.0.0 openssl-1.0.0-x86_64
# build i386 (32 bit intel) binary
cd openssl-1.0.0-i386
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make
make install # only do this on one of the architectures, to install the headers
cd ..
# build x86_64 (64 bit intel) binary
cd openssl-1.0.0-x86_64
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make
cd ..
# combine the libs
cd ~/bitcoin/deps
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
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
Verify your binaries
file lib/libcrypto.a
output should look like this:
lib/libcrypto.a: Mach-O universal binary with 2 architectures
lib/libcrypto.a (for architecture i386): current ar archive random library
lib/libcrypto.a (for architecture x86_64): current ar archive random library
miniupnpc
---------
(MacPorts miniupnpc package works fine. You will need to modify makefile.)
The process for miniupnpc (optional) is similar to that of OpenSSL.
Download from http://miniupnp.tuxfamily.org/files/.
cd ~/bitcoin/deps
tar xvf ~/Downloads/miniupnpc-1.6.tar
mv miniupnpc-1.6 miniupnpc-1.6-x86_64
tar xvf ~/Downloads/miniupnpc-1.6.tar
mv miniupnpc-1.6 miniupnpc-1.6-i386
# build x86_64 (64 bit intel) binary
cd miniupnpc-1.6-x86_64
export CFLAGS="-arch x86_64"
export LDFLAGS="-arch x86_64"
export PREFIX="/Users/macuser/bitcoin/deps"
make && make install
# build i386 (32 bit intel) binary
cd miniupnpc-1.6-i386
export CFLAGS="-arch i386"
export LDFLAGS="-arch i386"
export PREFIX="/Users/macuser/bitcoin/deps"
make
# combine the libs
cd ~/bitcoin/deps
lipo -arch i386 miniupnpc-1.6-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.6-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create
Verify your binaries
file lib/libminiupnpc.a
output should look like this:
lib/libminiupnpc.a: Mach-O universal binary with 2 architectures
lib/libminiupnpc.a (for architecture i386): current ar archive random library
lib/libminiupnpc.a (for architecture x86_64): current ar archive random library
Berkeley DB
-----------
(System or MacPorts version work fine.)
Download from http://freshmeat.net/projects/berkeleydb/
cd ~/bitcoin/deps
tar xvf ~/Downloads/db-4.8.30.tar
cd db-4.8.30/build_unix
../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
Now you should be able to build bitcoind:
cd ~/bitcoin/src
make -f makefile.osx bitcoind

View file

@ -1,35 +1,38 @@
# Copyright (c) 2010 Laszlo Hanyecz # -*- mode: Makefile; -*-
# Copyright (c) 2011 Bitcoin Developers
# Distributed under the MIT/X11 software license, see the accompanying # Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php. # file license.txt or http://www.opensource.org/licenses/mit-license.php.
# Mac OS X makefile for bitcoin # Mac OS X makefile for bitcoin
# Laszlo Hanyecz (solar@heliacal.net) # Originally by Laszlo Hanyecz (solar@heliacal.net)
CXX=llvm-g++ CXX=llvm-g++
DEPSDIR=/Users/macosuser/bitcoin/deps DEPSDIR=/opt/local
INCLUDEPATHS= \ INCLUDEPATHS= \
-I"$(DEPSDIR)/include" -I"$(DEPSDIR)/include" \
-I"$(DEPSDIR)/include/db48"
LIBPATHS= \ LIBPATHS= \
-L"$(DEPSDIR)/lib" -L"$(DEPSDIR)/lib" \
-L"$(DEPSDIR)/lib/db48"
USE_UPNP:=0 USE_UPNP:=1
LIBS= -dead_strip \ LIBS= -dead_strip \
$(DEPSDIR)/lib/libdb_cxx-4.8.a \ -ldb_cxx-4.8 \
$(DEPSDIR)/lib/libboost_system.a \ -lboost_system-mt \
$(DEPSDIR)/lib/libboost_filesystem.a \ -lboost_filesystem-mt \
$(DEPSDIR)/lib/libboost_program_options.a \ -lboost_program_options-mt \
$(DEPSDIR)/lib/libboost_thread.a \ -lboost_thread-mt \
$(DEPSDIR)/lib/libssl.a \ -lssl \
$(DEPSDIR)/lib/libcrypto.a -lcrypto
DEFS=-D__WXMAC_OSX__ -DNOPCH -DMSG_NOSIGNAL=0 -DUSE_SSL DEFS=-DMSG_NOSIGNAL=0 -DUSE_SSL
DEBUGFLAGS=-g DEBUGFLAGS=-g
# ppc doesn't work because we don't support big-endian # ppc doesn't work because we don't support big-endian
CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) CFLAGS=-mmacosx-version-min=10.5 -arch i386 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS = \ HEADERS = \
base58.h \ base58.h \
bignum.h \ bignum.h \
@ -67,27 +70,42 @@ OBJS= \
obj/wallet.o obj/wallet.o
ifdef USE_UPNP ifdef USE_UPNP
LIBS += $(DEPSDIR)/lib/libminiupnpc.a LIBS += -lminiupnpc
DEFS += -DUSE_UPNP=$(USE_UPNP) DEFS += -DUSE_UPNP=$(USE_UPNP)
endif endif
all: bitcoind all: bitcoind
obj/nogui/%.o: %.cpp $(HEADERS) # auto-generated dependencies:
$(CXX) -c $(CFLAGS) -o $@ $< -include obj/nogui/*.P
-include obj/test/*.P
obj/nogui/%.o: %.cpp
$(CXX) -c $(CFLAGS) -MMD -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
bitcoind: $(OBJS:obj/%=obj/nogui/%) bitcoind: $(OBJS:obj/%=obj/nogui/%)
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) obj/test/%.o: test/%.cpp
$(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp $(CXX) -c $(CFLAGS) -MMD -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
clean: clean:
-rm -f bitcoind test_bitcoin -rm -f bitcoind test_bitcoin
-rm -f obj/*.o -rm -f obj/*.o
-rm -f obj/nogui/*.o -rm -f obj/nogui/*.o
-rm -f obj/test/*.o -rm -f obj/test/*.o
-rm -f obj/*.P
-rm -f obj/nogui/*.P
-rm -f obj/test/*.P