Dependencies build scripts unification
[novacoin.git] / mingw64_deps / db / build.sh
1 #!/bin/bash
2
3 TARGET_CPU=$1
4 TARGET_OS=$2
5 ROOT=$(pwd)
6 MUTEX="x86_64/gcc-assembly"
7
8 if [[ ! "${TARGET_CPU}" =~ ^(aarch64|x86_64) ]]; then
9 echo "Platform ${TARGET_CPU} is not supported"
10 echo "Expected either aarch64 or x86_64."
11 exit 1
12 fi
13
14 if [[ ! "${TARGET_OS}" =~ ^(w64\-mingw32|linux\-gnu) ]]; then
15 echo "Operation sysrem ${TARGET_OS} is not supported"
16 echo "Expected either w64-mingw32 or linux-gnu."
17 exit 1
18 fi
19
20 # Cross-building prefix
21 CROSS=${TARGET_CPU}-${TARGET_OS}
22
23 if [[ ! $(which ${CROSS}-gcc) ]]; then
24 echo "Target C compiler ${CROSS}-gcc is not found"
25 exit 1
26 fi
27
28 if [[ ! $(which ${CROSS}-g++) ]]; then
29 echo "Target C++ compiler ${CROSS}-g++ is not found"
30 exit 1
31 fi
32
33 if [[ ! $(which make) ]]; then
34 echo "make is not installed, please install buld-essential package"
35 exit 1
36 fi
37
38 if [ "${TARGET_CPU}" == "aarch64" ]; then
39 MUTEX="ARM64/gcc-assembly"
40 fi
41
42 if [ "${TARGET_OS}" == "w64-mingw32" ]; then
43 MINGW32_PARAMS="--enable-mingw"
44 fi
45
46 # Make build directories
47 mkdir ${ROOT}/${CROSS}-build
48
49 # Stage directory
50 mkdir ${ROOT}/${CROSS}
51
52 # Compile BerkeleyDB
53
54 cd ${ROOT}/${CROSS}-build
55 export CFLAGS="-fstack-protector-all -D_FORTIFY_SOURCE=2"
56 export CXXFLAGS=${CFLAGS}
57 export LDFLAGS="-fstack-protector-all"
58 ${ROOT}/libdb/dist/configure --prefix=${ROOT}/${CROSS} --enable-smallbuild --enable-cxx --disable-shared --disable-replication --with-mutex=${MUTEX} ${MINGW32_PARAMS} --host=${CROSS}
59 make -j 4 library_build
60 make library_install
61
62 # Remove build directore
63 cd ${ROOT}
64 rm -rf ${ROOT}/${CROSS}-build