Dependencies build scripts unification
[novacoin.git] / mingw64_deps / openssl / build.sh
1 #!/bin/bash
2
3 TARGET_CPU=$1
4 TARGET_OS=$2
5 ROOT=$(pwd)
6
7 if [[ ! "${TARGET_CPU}" =~ ^(aarch64|x86_64) ]]; then
8 echo "Platform ${TARGET_CPU} is not supported"
9 echo "Expected either aarch64 or x86_64."
10 exit 1
11 fi
12
13 if [[ ! "${TARGET_OS}" =~ ^(w64\-mingw32|linux\-gnu) ]]; then
14 echo "Operation sysrem ${TARGET_OS} is not supported"
15 echo "Expected either w64-mingw32 or linux-gnu."
16 exit 1
17 fi
18
19 # Cross-building prefix
20 CROSS=${TARGET_CPU}-${TARGET_OS}
21
22 if [[ ! $(which ${CROSS}-gcc) ]]; then
23 echo "Target C compiler ${CROSS}-gcc is not found"
24 exit 1
25 fi
26
27 if [[ ! $(which ${CROSS}-g++) ]]; then
28 echo "Target C++ compiler ${CROSS}-g++ is not found"
29 exit 1
30 fi
31
32 if [[ ! $(which make) ]]; then
33 echo "make is not installed, please install buld-essential package"
34 exit 1
35 fi
36
37 if [ "${TARGET_CPU}" == "aarch64" ]; then
38 MUTEX="ARM64/gcc-assembly"
39 fi
40
41 if [ "${TARGET_OS}" == "w64-mingw32" ]; then
42 TARGET_PARAMS="mingw64"
43 else
44 TARGET_PARAMS="linux-generic64"
45 fi
46
47 # Make build directories
48 mkdir ${ROOT}/${CROSS}-build
49
50 # Stage directory
51 mkdir ${ROOT}/${CROSS}
52
53 # Compile BerkeleyDB
54
55 cd ${ROOT}/${CROSS}-build
56 export CFLAGS="-fstack-protector-all -D_FORTIFY_SOURCE=2"
57 export LDFLAGS="-fstack-protector-all"
58 ${ROOT}/openssl/Configure --cross-compile-prefix=${CROSS}- --prefix=${ROOT}/${CROSS} no-shared no-asm ${TARGET_PARAMS} --api=1.1.1
59 make -j 4 build_libs
60 make install_dev
61
62 # Create symlink for compatibility
63 cd ${ROOT}/${CROSS}
64 if [[ -d lib64 ]]; then
65     ln -s lib64 lib
66 fi
67
68 # Remove build directore
69 cd ${ROOT}
70 rm -rf ${ROOT}/${CROSS}-build