tdlight-java-natives/scripts/core/setup-variables.sh

104 lines
3.6 KiB
Bash
Raw Normal View History

2021-09-11 12:27:22 +02:00
#!/bin/bash -e
2021-09-14 15:03:15 +02:00
if [[ "$CORE_VARIABLES_SET" != "YES" ]]; then
echo "====== Setup variables ======"
if [[ "$OPERATING_SYSTEM_NAME" != "osx" ]]; then
echo "Current root directory:"
realpath "."
fi
echo "============================="
2021-09-14 15:03:15 +02:00
# ====== CPU Architecture Variables
if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then
export CPU_ARCH_JAVA="arm64"
export CPU_ARCH_JAVA_INTERNAL="aarch64"
export CPU_ARCH_DPKG="arm64"
export CPU_ARCH_CMAKE="aarch64"
export CLANG_TRIPLE="aarch64-linux-gnu"
export CPU_COMPILATION_TOOL="gnu"
elif [[ "$CPU_ARCHITECTURE_NAME" == "armhf" ]]; then
export CPU_ARCH_JAVA="armhf"
export CPU_ARCH_JAVA_INTERNAL="arm"
export CPU_ARCH_DPKG="armhf"
export CPU_ARCH_CMAKE="arm"
export CLANG_TRIPLE="arm-linux-gnueabihf"
export CPU_COMPILATION_TOOL="gnueabihf"
elif [[ "$CPU_ARCHITECTURE_NAME" == "s390x" ]]; then
export CPU_ARCH_JAVA="s390x"
export CPU_ARCH_JAVA_INTERNAL="s390x"
export CPU_ARCH_DPKG="s390x"
export CPU_ARCH_CMAKE="s390x"
export CLANG_TRIPLE="s390x-linux-gnu"
export CPU_COMPILATION_TOOL="gnu"
elif [[ "$CPU_ARCHITECTURE_NAME" == "386" ]]; then
export CPU_ARCH_JAVA="386"
export CPU_ARCH_JAVA_INTERNAL="i386"
export CPU_ARCH_DPKG="i386"
export CPU_ARCH_CMAKE="i686"
export CLANG_TRIPLE="i386-linux-gnu"
export CPU_COMPILATION_TOOL="gnu"
elif [[ "$CPU_ARCHITECTURE_NAME" == "amd64" ]]; then
export CPU_ARCH_JAVA="amd64"
export CPU_ARCH_JAVA_INTERNAL="amd64"
export CPU_ARCH_DPKG="amd64"
export CPU_ARCH_CMAKE="x86_64"
export CLANG_TRIPLE="x86_64-linux-gnu"
export CPU_COMPILATION_TOOL="gnu"
elif [[ "$CPU_ARCHITECTURE_NAME" == "ppc64le" ]]; then
export CPU_ARCH_JAVA="ppc64le"
export CPU_ARCH_JAVA_INTERNAL="ppc64le"
export CPU_ARCH_DPKG="ppc64el"
export CPU_ARCH_CMAKE="powerpc64le"
export CLANG_TRIPLE="powerpc64-linux-gnu"
export CPU_COMPILATION_TOOL="gnu"
else
echo "Unrecognized cpu arch: $CPU_ARCHITECTURE_NAME"
exit 1
fi
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
export CPU_CORES_NUM="2"
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
unset CROSS_BUILD_DEPS_DIR
if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
if [[ "$CPU_ARCHITECTURE_NAME" == "aarch64" ]]; then
export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS"
else
export CMAKE_EXTRA_ARGUMENTS="$CMAKE_EXTRA_ARGUMENTS -DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\""
fi
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
if [[ "$CPU_ARCHITECTURE_NAME" == "386" ]] || [[ "$CPU_ARCHITECTURE_NAME" == "armhf" ]]; then
export CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -latomic"
export LDFLAGS="$LDFLAGS -latomic"
export CXXFLAGS="$CXXFLAGS -latomic"
fi
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
export CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++"
export CC="gcc"
export CXX="g++"
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
export CROSS_CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++"
export CROSS_CC="${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-gcc"
export CROSS_CXX="${CPU_ARCH_CMAKE}-linux-${CPU_COMPILATION_TOOL}-g++"
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
CROSS_BUILD_DEPS_DIR="$(realpath "../../")/.cache/tdlib-build-cross-${CPU_ARCH_DPKG}/"
export CROSS_BUILD_DEPS_DIR
fi
2021-09-11 12:27:22 +02:00
2021-09-14 15:03:15 +02:00
# ====== Print variables
echo "========= Variables ========="
echo "Variables"
echo "CPU_ARCH_JAVA=${CPU_ARCH_JAVA}"
echo "CPU_ARCH_DPKG=${CPU_ARCH_DPKG}"
echo "CPU_ARCH_CMAKE=${CPU_ARCH_CMAKE}"
echo "CLANG_TRIPLE=${CLANG_TRIPLE}"
echo "CC=${CC}"
echo "CXX=${CXX}"
echo "CXXFLAGS=${CXXFLAGS}"
echo "CMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}"
echo "CMAKE_EXTRA_ARGUMENTS=${CMAKE_EXTRA_ARGUMENTS}"
echo "CROSS_BUILD_DEPS_DIR=${CROSS_BUILD_DEPS_DIR}"
echo "============================="
2021-09-14 15:03:15 +02:00
export CORE_VARIABLES_SET="YES"
fi