[Fire HD 8 and HD 10 Original Android Development] kingladar:
It turns out I have a script for that too. But like my other one, it should copile, but I don't know if it will generate a bootable image.

#!/bin/bash -e
# Monitor the output.
# bash -i -c 'tput setab 1 ; tail -F $HOME/android-build.log ' ; tput sgr0
cd $HOME && rm -rf device_manifest.xml android-build.log .gitconfig .repo_.gitconfig.json .repoconfig/ .gnupg/ .cache/ android/ cache/ temp/ && sudo sync
mkdir -p $HOME/temp && mkdir -p $HOME/cache && mkdir -p $HOME/android/lineage
cat <<-EOF > $HOME/device_manifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!-- Device Tree -->
<project name="mt8163/android_device_amazon_karnak" path="device/amazon/karnak" remote="github" revision="lineage-18.1"/>

<!-- Kernel sources -->
<project name="mt8163/android_kernel_amazon_karnak_4.9" path="kernel/amazon/karnak" remote="github" revision="lineage-18.1"/>
<project name="mt8163/android_kernel_mediatek_mt8163_4.9" path="kernel/mediatek/mt8163/4.9" remote="github" revision="lineage-17.1"/>

<!-- Vendor trees -->
<project name="mt8163/android_vendor_amazon_karnak" path="vendor/amazon/karnak" remote="github" revision="lineage-18.1"/>
<project name="mt8163/android_vendor_amazon_mt8163" path="vendor/amazon/mt8163" remote="github" revision="lineage-18.1"/>
<project name="mt8163/android_vendor_raffy" path="vendor/raffy" remote="github" revision="lineage-18.1"/>
</manifest>
EOF
cd $HOME/android/lineage
git config --global user.name "Ladar Levison"
git config --global user.email "ladar@lavabit.com"
git config --global color.ui false
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64

export LANG=en_US.UTF-8
export VENDOR=amazon
export DEVICE=karnak
export BRANCH=lineage-18.1
export TMPDIR="$HOME/temp"
export USE_CCACHE=1
export CCACHE_COMPRESS=1
export BUILD_UUID=$(uuidgen)
export CCACHE_DIR="$HOME/cache"
export ANDROID_QUIET_BUILD=true
export BUILDSTAMP=`date --utc +'%Y%m%d'`
export CCACHE_EXEC="prebuilts/misc/linux-x86/ccache/ccache"
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx8G"
# export OVERRIDE_TARGET_FLATTEN_APEX=true
# export ANDROID_JACK_EXTRA_ARGS="--verbose debug --sanity-checks on -D sched.runner=single-threaded"
repo init -u git://github.com/LineageOS/android.git -b lineage-18.1
mkdir -p .repo/local_manifests/
mv $HOME/device_manifest.xml .repo/local_manifests/device_manifest.xml
repo sync --jobs=32 --current-branch --no-clone-bundle --no-tags || exit 1

# GCC 7.5.0
mkdir -p prebuilts/linaro/linux-x86/aarch64/aarch64-linux-gnu/
curl -Lo $HOME/gcc-linaro-7.5.0-x86_64_aarch64-linux-gnu.tar.xz https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz
echo "3b6465fb91564b54bbdf9578b4cc3aa198dd363f7a43820eab06ea2932c8e0bf $HOME/gcc-linaro-7.5.0-x86_64_aarch64-linux-gnu.tar.xz" | sha256sum -c || exit 1
tar -x -J --strip-components=1 -C prebuilts/linaro/linux-x86/aarch64/aarch64-linux-gnu/ -f $HOME/gcc-linaro-7.5.0-x86_64_aarch64-linux-gnu.tar.xz
rm -f $HOME/gcc-linaro-7.5.0-x86_64_aarch64-linux-gnu.tar.xz

sed -i 's/const const struct/const struct/g' kernel/amazon/karnak/drivers/pinctrl/mediatek/pinctrl-mtk-common.h
sed -i 's/CONFIG_FRAME_WARN=1500/CONFIG_FRAME_WARN=1520/g' kernel/amazon/karnak/arch/arm64/configs/lineageos_karnak_defconfig
sed -i 's/CONFIG_FRAME_WARN,COMMON,,,1500,1500,1500,1500,1500,1500/CONFIG_FRAME_WARN,COMMON,,,1520,1520,1520,1520,1520,1520/g' kernel/amazon/karnak/scripts/kcrs/correct_config.csv

#####
# export PYTHONDONTWRITEBYTECODE=true
# export BUILD_ENFORCE_SELINUX=1
# export OVERRIDE_TARGET_FLATTEN_APEX=true
# # convert this to a runtime check, grep "sse4_2.*popcnt" /proc/cpuinfo
# export CPU_SSE42=false
#####

# Set the output label.
LINEAGE_BUILDTYPE="UPSTREAM"

source build/envsetup.sh
if [ ! -x "$CCACHE_EXEC" ]; then
export CCACHE_EXEC="$(which ccache)"
fi
"$CCACHE_EXEC" -M 20G

croot
rm -rf out
set +e

printf "Breakfast starting.\n" | tee -a $HOME/android-build.log

breakfast karnak &>> $HOME/android-build.log
if [[ "$TARGET_PRODUCT" != lineage_* ]]; then
printf "\n\nBuild karnak failed. (breakfast)\n\n\n" | tee -a $HOME/android-build.log
exit 1
fi

printf "Lunch starting.\n" | tee -a $HOME/android-build.log

lunch lineage_karnak-userdebug &>> $HOME/android-build.log
if [[ "$?" != "0" ]]; then
printf "\n\nBuild karnak failed. (lunch)\n\n\n" | tee -a $HOME/android-build.log
exit 1
fi

printf "Build starting.\n" | tee -a $HOME/android-build.log

cmka &>> $HOME/android-build.log
if [[ "$?" != "0" ]]; then
printf "\n\nBuild karnak failed. (cmka)\n\n\n" | tee -a $HOME/android-build.log
exit 1
fi

printf "Dist starting.\n" | tee -a $HOME/android-build.log

mka otatools-package target-files-package dist &>> $HOME/android-build.log
if [[ "$?" != "0" ]]; then
printf "\n\nBuild karnak failed. (dist)\n\n\n" | tee -a $HOME/android-build.log
exit 1
fi

printf "Finished.\n" | tee -a $HOME/android-build.log