Dependencies build scripts unification
[novacoin.git] / mingw64_deps / zlib / 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 # Make build directoriy
42 cp -r ${ROOT}/zlib ${ROOT}/${CROSS}-build-zlib
43
44 # Stage directory
45 mkdir ${ROOT}/${CROSS}
46
47 # Compile zlib
48 cd ${ROOT}/${CROSS}-build-zlib
49 export CC=${CROSS}-gcc
50 export CXX=${CROSS}-g++
51 export LD=${CROSS}-ld
52 export RANLIB=${CROSS}-ranlib
53 export CFLAGS="-fstack-protector-all -D_FORTIFY_SOURCE=2"
54 export CXXFLAGS=${CFLAGS}
55 export LDFLAGS="-fstack-protector-all"
56 ${ROOT}/zlib/configure --prefix=${ROOT}/${CROSS} --static
57 make -j 4
58
59 # Install zlib to our cross-tools directory
60 make install
61
62 # Remove build directory
63 cd ${ROOT}
64 rm -rf ${ROOT}/${CROSS}-build-zlib