krata/hack/build/target.sh

85 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/sh
set -e
2024-03-21 21:31:10 +00:00
if [ -z "${TARGET_LIBC}" ] || [ "${KRATA_TARGET_IGNORE_LIBC}" = "1" ]
then
2024-03-21 21:31:10 +00:00
TARGET_LIBC="gnu"
fi
if [ -z "${TARGET_ARCH}" ]
then
TARGET_ARCH="$(uname -m)"
fi
2024-03-22 01:16:04 +00:00
if [ "${TARGET_ARCH}" = "arm64" ]
then
2024-03-22 01:16:04 +00:00
TARGET_ARCH="aarch64"
fi
if [ -z "${TARGET_OS}" ]
then
TARGET_OS="$(uname -s)"
TARGET_OS="$(echo "${TARGET_OS}" | tr '[:upper:]' '[:lower:]')"
fi
if [ "${TARGET_OS}" = "darwin" ]
then
if [ -z "${RUST_TARGET}" ]
then
2024-03-22 01:16:04 +00:00
if [ "${TARGET_ARCH}" = "x86_64" ]
then
RUST_TARGET="x86_64-apple-darwin"
fi
2024-03-22 01:16:04 +00:00
if [ "${TARGET_ARCH}" = "aarch64" ]
then
RUST_TARGET="aarch64-apple-darwin"
fi
fi
else
if [ -z "${RUST_TARGET}" ]
then
2024-03-22 01:16:04 +00:00
if [ "${TARGET_ARCH}" = "x86_64" ]
then
RUST_TARGET="x86_64-unknown-linux-${TARGET_LIBC}"
fi
if [ "${TARGET_ARCH}" = "aarch64" ]
then
RUST_TARGET="aarch64-unknown-linux-${TARGET_LIBC}"
fi
fi
fi
2024-03-21 21:31:10 +00:00
if [ -z "${C_TARGET}" ]
then
2024-03-21 21:31:10 +00:00
if [ "${TARGET_ARCH}" = "x86_64" ]
then
C_TARGET="x86_64-linux-${TARGET_LIBC}"
fi
if [ "${TARGET_ARCH}" = "aarch64" ]
then
C_TARGET="aarch64-linux-${TARGET_LIBC}"
fi
fi
2024-03-21 21:31:10 +00:00
if [ "${KRATA_TARGET_C_MODE}" = "1" ]
then
if [ -z "${C_TARGET}" ]
then
2024-03-22 01:16:04 +00:00
echo "ERROR: Unable to determine C_TARGET, your os or architecture may not be supported by krata." > /dev/stderr
2024-03-21 21:31:10 +00:00
exit 1
fi
echo "${C_TARGET}"
else
if [ -z "${RUST_TARGET}" ]
then
2024-03-22 01:16:04 +00:00
echo "ERROR: Unable to determine RUST_TARGET, your os or architecture may not be supported by krata." > /dev/stderr
2024-03-21 21:31:10 +00:00
exit 1
fi
echo "${RUST_TARGET}"
fi