6 if [[ ! "${CROSS}" =~ ^(aarch64|x86_64) ]]; then
7 echo "Platform ${CROSS} is not supported"
8 echo "Expected either aarch64 or x86_64."
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"
17 if [[ ! $(which make) ]]; then
18 echo "make is not installed, please install buld-essential package"
22 # Make build directoriy
23 cp -r ${ROOT}/zlib ${ROOT}/${CROSS}-w64-mingw32-build-zlib
26 mkdir ${ROOT}/${CROSS}-w64-mingw32
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
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
38 # Remove build directory
40 rm -rf ${ROOT}/${CROSS}-w64-mingw32-build-zlib