#!/bin/bash
#
# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#
# This file is a part of the Armbian build script
# https://github.com/armbian/build/
QEMU_BINARY="qemu-aarch64-static"
ARCHITECTURE=arm64
ARCH=arm64
KERNEL_IMAGE_TYPE=Image
CAN_BUILD_STRETCH=yes
GIT_SERVER="https://github.com/orangepi-xunlong"
[[ -z $GITEE_SERVER ]] && GITEE_SERVER=no

[[ -z $INITRD_ARCH ]] && INITRD_ARCH=arm64

if [[ $BOARD =~ orangepipch5|orangepioneh5 ]]; then
	ARCH=armhf
	QEMU_BINARY="qemu-arm-static"
fi

if [ "$(uname -m)" = "aarch64" ]; then
	[[ $ATF_COMPILE != "no" && -z $ATF_COMPILER ]] && ATF_COMPILER="aarch64-linux-gnu-"
	[[ -z $UBOOT_COMPILER ]] && UBOOT_COMPILER="aarch64-linux-gnu-"
	[[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER="aarch64-linux-gnu-"
else
	[[ $ATF_COMPILE != "no" && -z $ATF_COMPILER ]] && ATF_COMPILER="aarch64-none-linux-gnu-"
	[[ -z $UBOOT_COMPILER ]] && UBOOT_COMPILER="aarch64-none-linux-gnu-"
	[[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER="aarch64-none-linux-gnu-"
fi

[[ $ATF_COMPILE != "no" && -z $ATFSOURCE ]] && ATFSOURCE='https://github.com/ARM-software/arm-trusted-firmware'
[[ $ATF_COMPILE != "no" && -z $ATFDIR ]] && ATFDIR='arm-trusted-firmware-sunxi-mainline'
[[ $ATF_COMPILE != "no" && -z $ATFBRANCH ]] && ATFBRANCH='branch:master'
[[ $ATF_COMPILE != "no" && -z $ATF_USE_GCC ]] && ATF_USE_GCC='> 8.0'

[[ -z $UBOOT_USE_GCC ]]		&& UBOOT_USE_GCC='> 8.0'
[[ -z $BOOTSOURCE ]]		&& BOOTSOURCE="${GIT_SERVER}/u-boot-orangepi.git"
[[ -z $BOOTDIR ]]		&& BOOTDIR="${SRC}/u-boot"
[[ -z $BOOTBRANCH ]]		&& BOOTBRANCH='branch:v2020.04'

[[ -z $KERNEL_USE_GCC ]]	&& KERNEL_USE_GCC='> 8.0'
[[ -z $KERNELDIR ]]		&& KERNELDIR="${SRC}/kernel"
[[ -z $KERNELSOURCE ]]		&& KERNELSOURCE="${GIT_SERVER}/linux-orangepi.git"
[[ -z $KERNELBRANCH ]]		&& KERNELBRANCH='branch:orange-pi-5.4'
