7 if [[ ! "${TARGET_CPU}" =~ ^(aarch64|x86_64) ]]; then
8 echo "Platform ${TARGET_CPU} is not supported"
9 echo "Expected either aarch64 or x86_64."
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."
19 # Cross-building prefix
20 CROSS=${TARGET_CPU}-${TARGET_OS}
22 if [[ ! $(which ${CROSS}-gcc) ]]; then
23 echo "Target C compiler ${CROSS}-gcc is not found"
27 if [[ ! $(which ${CROSS}-g++) ]]; then
28 echo "Target C++ compiler ${CROSS}-g++ is not found"
32 if [[ ! $(which make) ]]; then
33 echo "make is not installed, please install buld-essential package"
37 if [ "${TARGET_CPU}" == "aarch64" ]; then
38 MUTEX="ARM64/gcc-assembly"
41 # Make build directoriy
42 cp -r ${ROOT}/zlib ${ROOT}/${CROSS}-build-zlib
45 mkdir ${ROOT}/${CROSS}
48 cd ${ROOT}/${CROSS}-build-zlib
49 export CC=${CROSS}-gcc
50 export CXX=${CROSS}-g++
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
59 # Install zlib to our cross-tools directory
62 # Remove build directory
64 rm -rf ${ROOT}/${CROSS}-build-zlib