-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild
More file actions
executable file
·200 lines (167 loc) · 6.28 KB
/
build
File metadata and controls
executable file
·200 lines (167 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
#
# One build script to rule them all
#
# The challenge: Old versions of non komodo coins need old versions of BerkeleyDB and Boost
# Annoyance in previous method: We build bdb for every single coin.. they should all be able to build from the same dependency
#
# Most bitcoin based coins will follow the same build steps
#
# Usage: ./build <coinname>
# e.g.: ./build LTC
#
# @author webworker01
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
if [[ -z ${1-} ]]; then
echo "Usage: build <coinname>"
exit 0
else
coinname=${1^^}
fi
#for git checking - path and remote branch
declare -A bitcoinbased=(
[BTC]="$HOME/bitcoin"
[LTC]="$HOME/litecoin"
[CHIPS]="$HOME/chips gcc9"
[CHIPS3]="$HOME/chips3 gcc9"
[AYA]="$HOME/AYAv2"
[EMC2]="$HOME/einsteinium gcc9"
[SFUSD]="$HOME/sfusd-core"
[MIL]="$HOME/mil gcc9"
)
declare -A komodobased=(
[KMD]="$HOME/komodo"
[VRSC]="$HOME/VerusCoin werror"
[MCL]="$HOME/marmara"
[TOKEL]="$HOME/tokel"
)
bdb_PATH="${HOME}/berkeleydb48"
gccversion=$(gcc --version | head -1 | awk '{print $4}' | cut -d"." -f1)
# Functions
berkeleydb48 () {
if [[ ! -f "${bdb_PATH}/include/db_cxx.h" || ! -f "${bdb_PATH}/lib/libdb_cxx-4.8.a" ]]; then
log "build" "installing BerkeleyDB48"
cd $HOME
mkdir -p $bdb_PATH
wget -N '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 -xzvf db-4.8.30.NC.tar.gz
cat <<-EOL >atomic-builtin-test.cpp
#include <stdint.h>
#include "atomic.h"
int main() {
db_atomic_t *p; atomic_value_t oldval; atomic_value_t newval;
__atomic_compare_exchange(p, oldval, newval);
return 0;
}
EOL
if g++ atomic-builtin-test.cpp -I./db-4.8.30.NC/dbinc -DHAVE_ATOMIC_SUPPORT -DHAVE_ATOMIC_X86_GCC_ASSEMBLY -o atomic-builtin-test 2>/dev/null; then
log "build" "No changes to bdb source are needed ..."
rm atomic-builtin-test 2>/dev/null
else
log "build" "Updating atomic.h file ..."
sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' db-4.8.30.NC/dbinc/atomic.h
fi
cd db-4.8.30.NC/build_unix/
../dist/configure -enable-cxx -disable-shared -with-pic -prefix=$bdb_PATH
make install
#clean up
cd $HOME
rm atomic-builtin-test.cpp
rm db-4.8.30.NC.tar.gz
rm -rf db-4.8.30.NC
else
log "build" "BerkeleyDB 4.8 detected in ${bdb_PATH}"
fi
}
boost165 () {
#check if boost <= 1.71 already installed
cd $scriptpath/c
if make boost; then
boostversion=$(./boost | sed 's/_/./g')
rm boost
else
log "build" "error building boost check" "red"
fi
if (( $(echo "${boostversion-999} > 1.71" | bc -l) )); then
log "build" "installing Boost 1_65_1"
#remove apt installed versions
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
sudo apt autoremove
#remove source installed versions
sudo rm -f /usr/lib/libboost_*
sudo rm -f /usr/local/lib/libboost_*
cd /usr/local/include && sudo rm -rf boost
#build from source if not
cd $HOME
wget http://downloads.sourceforge.net/project/boost/boost/1.65.1/boost_1_65_1.tar.gz
tar -zxvf boost_1_65_1.tar.gz
cd boost_1_65_1
# ./bootstrap.sh --prefix=/usr --with-libraries=atomic,date_time,exception,filesystem,iostreams,locale,program_options,regex,signals,system,test,thread,timer,log
./bootstrap.sh --prefix=/usr --with-libraries=chrono,filesystem,program_options,system,test,thread
sudo ./b2 --with=all -j$(expr $(nproc) - 1) install
#clean up
cd $HOME
rm boost_1_65_1.tar.gz
rm -rf boost_1_65_1
else
log "build" "Valid Boost Version Installed: ${boostversion}"
fi
}
buildBitcoinBased () {
buildflags=${1-}
git pull
make clean
./autogen.sh
if (( gccversion > 9 )) && [[ "${buildflags}" == "gcc9" ]]; then
# install g++ 7 compiler for chips for now
gccflags="CC=gcc-9 CXX=g++-9"
log "build" "using g++9"
fi
./configure LDFLAGS="-L${bdb_PATH}/lib/" CPPFLAGS="-I${bdb_PATH}/include/" ${gccflags-} --with-gui=no --disable-tests --disable-bench --without-miniupnpc --enable-experimental-asm --enable-static --disable-shared
make -j$(expr $(nproc) - 1)
}
buildKomodoBased () {
buildflags=${1-}
git pull
make clean
#patches if gcc > 9
if (( gccversion > 9 )); then
if [[ "${buildflags}" =~ "stdexcept" ]]; then
equihashfile="src/crypto/equihash.h"
if ! grep -q "#include <stdexcept>" ${equihashfile}; then
log "build" "Patching ${equihashfile} for G++ 10" "red"
sed -i 's/#include <exception>/#include <exception>\n#include <stdexcept>/g' ${equihashfile}
else
log "build" "${equihashfile} compatible G++ 10"
fi
fi
if [[ "${buildflags}" =~ "werror" ]]; then
buildfile="zcutil/build.sh"
if grep -q "CPPFLAGS='-g -Wno-builtin-declaration-mismatch -Werror'" ${buildfile}; then
log "build" "Patching ${buildfile} for G++ 10" "red"
sed -i "s/CPPFLAGS='-g -Wno-builtin-declaration-mismatch -Werror'/CPPFLAGS='-g -Wno-builtin-declaration-mismatch'/g" ${buildfile}
else
log "build" "${buildfile} compatible G++ 10"
fi
fi
fi
./zcutil/build.sh -j$(expr $(nproc) - 1)
}
if [[ -v "bitcoinbased[${coinname}]" ]]; then
log "build" "${coinname} - bitcoin based build"
berkeleydb48
boost165
builddata=(${bitcoinbased[${coinname}]})
cd ${builddata[0]}
buildBitcoinBased ${builddata[1]-}
elif [[ -v "komodobased[${coinname}]" ]]; then
log "build" "${coinname} - komodo based build"
builddata=(${komodobased[${coinname}]})
cd ${builddata[0]}
buildKomodoBased ${builddata[1]-}
else
log "build" "${coinname} - invalid coin specified" "red"
fi