#!/bin/bash # Simple Bash script to compile Bitcoin Core # on Ubuntu Linux. # PREREQUISITES: # Example for bitcoin version 23.0 # Download bitcoin-23.0.tar.gz from: # https://bitcoincore.org/bin/bitcoin-core-23.0 # and unpack in the home directory ($HOME): # tar -zxvf bitcoin-23.0.tar.gz # # Then execute this script in: $HOME/bitcoin-23.0 # # You'll find bitcoind and bitcoin-cli in $HOME/bitcoin-23.0/src # and bitcoin-qt in $HOME/bitcoin-23.0/src/qt # # Set variable "do" or "download" to 1 or 0 # to execute or not execute a specific part of the code clear VERSION=$(basename `pwd`) # Should return the current version. echo "Is $VERSION the right version to compile?" echo "Sleeping 30 s, press CTRL-C to interupt." sleep 30 do=1 # install packages (if do = 1) if [ $do = 1 ] then sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libboost-all-dev build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 doxygen fi do=0 download=1 # download berkeley-db (if download = 1) do=1 # compile and install berkeley-db (if do = 1) if [ $do = 1 ] then cd $HOME if [ $download = 1 ] then wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz' | sha256sum -c tar -xvf db-4.8.30.NC.tar.gz fi # This error needs to be corrected, see: # https://www.fsanmartin.co/compiling-berkeley-db-4-8-30-in-ubuntu-19/ cd db-4.8.30.NC mv dbinc/atomic.h dbinc/atomic.h_orig cat dbinc/atomic.h_orig | sed 's/__atomic_compare_exchange/__atomic_compare_exchange_db/' > dbinc/atomic.h cd build_unix mkdir -p build BDB_PREFIX="$HOME/db-4.8.30.NC/build_unix/build/" echo BDB $BDB_PREFIX ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX make install fi do=0 do=1 # compile Bitcoin Core (if do = 1) if [ $do = 1 ] then # Execute in the Bitcoin directory: cd $HOME/$VERSION/ BDB_PREFIX="$HOME/db-4.8.30.NC/build_unix/build" echo BDB $BDB_PREFIX ./autogen.sh ./configure CPPFLAGS="-I$BDB_PREFIX/include/" LDFLAGS="-L$BDB_PREFIX/lib/" --with-gui make # find bitcoind and bitcoin-cli in src, bitcoin-qt in src/qt fi do=0 do=0 # install Bitcoin Core (if do = 1) if [ $do = 1 ] then cd $HOME/$VERSION/ sudo make install fi do=0 do=1 # test Bitcoin Core (if do = 1) if [ $do = 1 ] then cd $HOME/$VERSION/src/test ./test_bitcoin cd $HOME/$VERSION/src/qt/test ./test_bitcoin-qt fi do=0