70b5babf9ff746fa3fe295c02a85ba5032c1ee34
[novacoin.git] / mingw64_deps / zlib / build.sh
1 #!/bin/bash
2
3 CROSS=$1
4 ROOT=$(pwd)
5
6 if [[ ! "${CROSS}" =~ ^(aarch64|x86_64) ]]; then
7 echo "Platform ${CROSS} is not supported"
8 echo "Expected either aarch64 or x86_64."
9 exit 1
10 fi
11
12 if [[ ! $(which ${CROSS}-w64-mingw32-clang) ]]; then
13 echo "llvm-mingw is not installed, please download it from https://github.com/mstorsjo/llvm-mingw/releases"
14 exit 1
15 fi
16
17 if [[ ! $(which make) ]]; then
18 echo "make is not installed, please install buld-essential package"
19 exit 1
20 fi
21
22 # Make build directoriy
23 cp -r ${ROOT}/zlib ${ROOT}/${CROSS}-w64-mingw32-build-zlib
24
25 # Stage directory
26 mkdir ${ROOT}/${CROSS}-w64-mingw32
27
28 # Compile zlib
29 cd ${ROOT}/${CROSS}-w64-mingw32-build-zlib
30 perl -i -pe "s,(PREFIX =)\$,\$1 ${CROSS}-w64-mingw32-," win32/Makefile.gcc
31 perl -i -pe "s,(CFLAGS =.*)\$,\$1 -fstack-protector-all -D_FORTIFY_SOURCE," win32/Makefile.gcc
32 perl -i -pe "s,(LDFLAGS =.*)\$,\$1 -fstack-protector-all," win32/Makefile.gcc
33 make -j 4 -f win32/Makefile.gcc
34
35 # Install zlib to our cross-tools directory
36 make install DESTDIR=${ROOT}/${CROSS}-w64-mingw32 INCLUDE_PATH=/include LIBRARY_PATH=/lib BINARY_PATH=/bin -f win32/Makefile.gcc
37
38 # Remove build directory
39 cd ${ROOT}
40 rm -rf ${ROOT}/${CROSS}-w64-mingw32-build-zlib