#!/bin/sh

__BITBAKE_LAST_LINE=0

# Emit a useful diagnostic if something fails:
bb_sh_exit_handler() {
    ret=$?
    if [ "$ret" != 0 ]; then
        echo "WARNING: exit code $ret from a shell command."
    fi
    exit $ret
}

bb_bash_exit_handler() {
    ret=$?
    { set +x; } > /dev/null
    trap "" DEBUG
    if [ "$ret" != 0 ]; then
        echo "WARNING: ${BASH_SOURCE[0]}:${__BITBAKE_LAST_LINE} exit $ret from '$1'"

        echo "WARNING: Backtrace (BB generated script): "
        for i in $(seq 1 $((${#FUNCNAME[@]} - 1))); do
            if [ "$i" -eq 1 ]; then
                echo -e "	#$((i)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ${__BITBAKE_LAST_LINE}"
            else
                echo -e "	#$((i)): ${FUNCNAME[$i]}, ${BASH_SOURCE[$((i-1))]}, line ${BASH_LINENO[$((i-1))]}"
            fi
        done
    fi
    exit $ret
}

bb_bash_debug_handler() {
    local line=${BASH_LINENO[0]}
    # For some reason the DEBUG trap trips with lineno=1 when scripts exit; ignore it
    if [ "$line" -eq 1 ]; then
        return
    fi

    # Track the line number of commands as they execute. This is so we can have access to the failing line number
    # in the EXIT trap. See http://gnu-bash.2382.n7.nabble.com/trap-echo-quot-trap-exit-on-LINENO-quot-EXIT-gt-wrong-linenumber-td3666.html
    if [ "${FUNCNAME[1]}" != "bb_bash_exit_handler" ]; then
        __BITBAKE_LAST_LINE=$line
    fi
}

case $BASH_VERSION in
"") trap 'bb_sh_exit_handler' 0
    set -e
    ;;
*)  trap 'bb_bash_exit_handler "$BASH_COMMAND"' 0
    trap '{ bb_bash_debug_handler; } 2>/dev/null' DEBUG
    set -e
    shopt -s extdebug
    ;;
esac
export AR="aarch64-poky-linux-gcc-ar"
export ARCH="arm64"
export AS="aarch64-poky-linux-as "
export BUILD_AR="ar"
export BUILD_AS="as "
export BUILD_CC="gcc "
export BUILD_CCLD="gcc "
export BUILD_CFLAGS="-isystem/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/include -O2 -pipe"
export BUILD_CPP="gcc  -E"
export BUILD_CPPFLAGS="-isystem/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/include"
export BUILD_CXX="g++ "
export BUILD_CXXFLAGS="-isystem/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/include -O2 -pipe"
export BUILD_FC="gfortran "
export BUILD_LD="ld "
export BUILD_LDFLAGS="-L/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/lib                         -L/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/lib                         -Wl,--enable-new-dtags                         -Wl,-rpath-link,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/lib                         -Wl,-rpath-link,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/lib                         -Wl,-rpath,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/lib                         -Wl,-rpath,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/lib                         -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=/home/sim/yocto/scarthgap/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 -pthread"
export BUILD_NM="nm"
export BUILD_RANLIB="ranlib -D"
export BUILD_STRIP="strip"
export CC="aarch64-poky-linux-gcc  -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot"
export CCLD="aarch64-poky-linux-gcc  -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot"
export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native= "
export CMDLINE_CONSOLE="console=ttyS0"
export CPP="aarch64-poky-linux-gcc -E --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot  -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security"
export CPPFLAGS=""
export CROSS_COMPILE="aarch64-poky-linux-"
export CXX="aarch64-poky-linux-g++  -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot"
export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native=  -fvisibility-inlines-hidden"
export FC="aarch64-poky-linux-gfortran  -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot"
export GIT_CEILING_DIRECTORIES="/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git:/home/sim/yocto/scarthgap/build/tmp"
export HOME="/home/sim"
export KBUILD_BUILD_HOST="oe-host"
export KBUILD_BUILD_USER="oe-user"
export KBUILD_BUILD_VERSION="1"
export LC_ALL="en_US.UTF-8"
export LD="aarch64-poky-linux-ld --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot "
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fcanon-prefix-map  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native=  -Wl,-z,relro,-z,now"
export LOCALVERSION=""
export LOGNAME="sim"
export MAKE="make"
export NM="aarch64-poky-linux-gcc-nm"
export OBJCOPY="aarch64-poky-linux-objcopy"
export OBJDUMP="aarch64-poky-linux-objdump"
export OMP_NUM_THREADS="8"
export OS="linux"
export PATH="/home/sim/yocto/scarthgap/build/tmp/sysroots-uninative/x86_64-linux/usr/bin:/home/sim/yocto/scarthgap/poky/scripts:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/bin/aarch64-poky-linux:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot/usr/bin/crossscripts:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/sbin:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/bin:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/sbin:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/bin:/home/sim/yocto/scarthgap/poky/bitbake/bin:/home/sim/yocto/scarthgap/build/tmp/hosttools"
export PERL_HASH_SEED="0"
export PKG_CONFIG_DIR="/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot/usr/lib/pkgconfig"
export PKG_CONFIG_DISABLE_UNINSTALLED="yes"
export PKG_CONFIG_LIBDIR="/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot/usr/lib/pkgconfig"
export PKG_CONFIG_PATH="/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot/usr/lib/pkgconfig:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot/usr/share/pkgconfig"
export PKG_CONFIG_SYSROOT_DIR="/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot"
export PKG_CONFIG_SYSTEM_INCLUDE_PATH="/usr/include"
export PKG_CONFIG_SYSTEM_LIBRARY_PATH="/usr/lib:/usr/lib"
export PSEUDO_DISABLED="1"
export PSEUDO_UNLOAD="1"
export PYTHONHASHSEED="0"
export RANLIB="aarch64-poky-linux-gcc-ranlib"
export READELF="aarch64-poky-linux-readelf"
unset SHELL
export SOURCE_DATE_EPOCH="1733479805"
export STRINGS="aarch64-poky-linux-strings"
export STRIP="aarch64-poky-linux-strip"
export TZ="UTC"
export UBOOT_ARCH="arm64"
export USER="sim"
export base_bindir="/usr/bin"
export base_libdir="/usr/lib"
export base_prefix=""
export base_sbindir="/usr/sbin"
export bindir="/usr/bin"
export datadir="/usr/share"
export docdir="/usr/share/doc"
export exec_prefix="/usr"
export includedir="/usr/include"
export infodir="/usr/share/info"
export libdir="/usr/lib"
export libexecdir="/usr/libexec"
export localstatedir="/var"
export mandir="/usr/share/man"
export nonarch_base_libdir="/usr/lib"
export nonarch_libdir="/usr/lib"
export prefix="/usr"
export sbindir="/usr/sbin"
export servicedir="/srv"
export sharedstatedir="/com"
export sysconfdir="/etc"
export systemd_system_unitdir="/usr/lib/systemd/system"
export systemd_unitdir="/usr/lib/systemd"
export systemd_user_unitdir="/usr/lib/systemd/user"

# line: 450, file: /home/sim/yocto/scarthgap/poky/meta/classes-recipe/kernel-yocto.bbclass
do_kernel_configme() {
	do_kernel_metadata config

	# translate the kconfig_mode into something that merge_config.sh
	# understands
	case --alldefconfig in
		*allnoconfig)
			config_flags="-n"
			;;
		*alldefconfig)
			config_flags=""
			;;
		*)
			if [ -f /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/defconfig ]; then
				config_flags="-n"
			fi
			;;
	esac

	cd /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source

	meta_dir=$(kgit --meta)
	configs="$(scc --configs -o ${meta_dir})"
	if [ $? -ne 0 ]; then
		bberror "${configs}"
		bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)"
	fi

	CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native=   --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot" HOSTCC="gcc  -isystem/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/include -O2 -pipe -L/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/lib                         -L/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/lib                         -Wl,--enable-new-dtags                         -Wl,-rpath-link,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/lib                         -Wl,-rpath-link,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/lib                         -Wl,-rpath,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/lib                         -Wl,-rpath,/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/lib                         -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=/home/sim/yocto/scarthgap/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 -pthread" HOSTCPP="gcc  -E" CC="aarch64-poky-linux-gcc    -fuse-ld=bfd -fcanon-prefix-map  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build=/usr/src/debug/linux-raspberrypi/6.6.63+git  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot=  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native=   -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/kernel  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source=/usr/src/kernel  -fdebug-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-build-artifacts=/usr/src/kernel  -fmacro-prefix-map=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-build-artifacts=/usr/src/kernel   --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot" LD="aarch64-poky-linux-ld.bfd    --sysroot=/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot" OBJCOPY="aarch64-poky-linux-objcopy " STRIP="aarch64-poky-linux-strip" ARCH=arm64 merge_config.sh -O /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1
	if [ $? -ne 0 -o ! -f /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build/.config ]; then
		bberror "Could not generate a .config for raspberrypi4-64-standard"
		if [ 1 -gt 1 ]; then
			bbfatal_log "`cat ${meta_dir}/cfg/merge_config_build.log`"
		else
			bbfatal_log "Details can be found at: /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/${meta_dir}/cfg/merge_config_build.log"
		fi
	fi

	if [ ! -z "" ]; then
		echo "# Global settings from linux recipe" >> /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build/.config
		echo "CONFIG_LOCALVERSION="\"\" >> /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build/.config
	fi
}

# line: 49, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/logging.bbclass
bberror() {
	if [ -p /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433 ] ; then
		printf "%b\0" "bberror $*" > /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433
	else
		echo "ERROR: $*"
	fi
}

# line: 72, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/logging.bbclass
bbfatal_log() {
	if [ -p /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433 ] ; then
		printf "%b\0" "bbfatal_log $*" > /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433
	else
		echo "ERROR: $*"
	fi
	exit 1
}

# line: 113, file: /home/sim/yocto/scarthgap/poky/meta/classes-recipe/kernel-yocto.bbclass
do_kernel_metadata() {
	set +e

	if [ -n "$1" ]; then
		mode="$1"
	else
		mode="patch"
	fi

	cd /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source
	export KMETA=kernel-meta

	bbnote "do_kernel_metadata: for summary/debug, set KCONF_AUDIT_LEVEL > 0"

	# if kernel tools are available in-tree, they are preferred
	# and are placed on the path before any external tools. Unless
	# the external tools flag is set, in that case we do nothing.
	if [ -f "/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/scripts/util/configme" ]; then
		if [ -z "${EXTERNAL_KERNEL_TOOLS}" ]; then
			PATH=/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/scripts/util:/home/sim/yocto/scarthgap/build/tmp/sysroots-uninative/x86_64-linux/usr/bin:/home/sim/yocto/scarthgap/poky/scripts:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/bin/aarch64-poky-linux:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot/usr/bin/crossscripts:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/sbin:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/usr/bin:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/sbin:/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/recipe-sysroot-native/bin:/home/sim/yocto/scarthgap/poky/bitbake/bin:/home/sim/yocto/scarthgap/build/tmp/hosttools
		fi
	fi

	# In a similar manner to the kernel itself:
	#
	#   defconfig: $(obj)/conf
	#   ifeq ($(KBUILD_DEFCONFIG),)
	#	$< --defconfig $(Kconfig)
	#   else
	#	@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
	#	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
	#   endif
	#
	# If a defconfig is specified via the KBUILD_DEFCONFIG variable, we copy it
	# from the source tree, into a common location and normalized "defconfig" name,
	# where the rest of the process will include and incoroporate it into the build
	#
	# If the fetcher has already placed a defconfig in WORKDIR (from the SRC_URI),
	# we don't overwrite it, but instead warn the user that SRC_URI defconfigs take
	# precendence.
	#
	if [ -n "bcm2711_defconfig" ]; then
		if [ -f "/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/arch/arm64/configs/bcm2711_defconfig" ]; then
			if [ -f "/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/defconfig" ]; then
				# If the two defconfig's are different, warn that we overwrote the
				# one already placed in WORKDIR
				cmp "/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/defconfig" "/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/arch/arm64/configs/bcm2711_defconfig"
				if [ $? -ne 0 ]; then
					bbdebug 1 "detected SRC_URI or unpatched defconfig in WORKDIR. bcm2711_defconfig copied over it"
				fi
				cp -f /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/arch/arm64/configs/bcm2711_defconfig /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/defconfig
			else
				cp -f /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/arch/arm64/configs/bcm2711_defconfig /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/defconfig
			fi
			in_tree_defconfig="/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/defconfig"
		else
			bbfatal "A KBUILD_DEFCONFIG 'bcm2711_defconfig' was specified, but not present in the source tree (/home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/arch/arm64/configs/)"
		fi
	fi

	if [ "$mode" = "patch" ]; then
		# was anyone trying to patch the kernel meta data ?, we need to do
		# this here, since the scc commands migrate the .cfg fragments to the
		# kernel source tree, where they'll be used later.
		check_git_config
		patches=""
		if [ -n "$patches" ]; then
		    (
			    cd /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/kernel-meta

			    # take the SRC_URI patches, and create a series file
			    # this is required to support some better processing
			    # of issues with the patches
			    rm -f series
			    for p in $patches; do
				cp $p .
				echo "$(basename $p)" >> series
			    done

			    # process the series with kgit-s2q, which is what is
			    # handling the rest of the kernel. This allows us
			    # more flexibility for handling failures or advanced
			    # mergeing functinoality
			    message=$(kgit-s2q --gen -v --patches /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/kernel-meta 2>&1)
			    if [ $? -ne 0 ]; then
				# setup to try the patch again
				kgit-s2q --prev
				bberror "Problem applying patches to: /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/kernel-meta"
				bbfatal_log "\n($message)"
			    fi
			)
		fi
	fi

	sccs_from_src_uri="/home/sim/yocto/scarthgap/poky/meta-raspberrypi/recipes-kernel/linux/files/powersave.cfg /home/sim/yocto/scarthgap/poky/meta-raspberrypi/recipes-kernel/linux/files/android-drivers.cfg /home/sim/yocto/scarthgap/poky/meta-raspberrypi/recipes-kernel/linux/files/vc4graphics.cfg /home/sim/yocto/scarthgap/poky/meta-raspberrypi/recipes-kernel/linux/files/default-cpu-governor.cfg /home/sim/yocto/scarthgap/poky/meta-raspberrypi/recipes-kernel/linux/files/raspberrypi4/rpi4-nvmem.cfg"
	patches=""
	feat_dirs="kernel-meta"

	# a quick check to make sure we don't have duplicate defconfigs If
	# there's a defconfig in the SRC_URI, did we also have one from the
	# KBUILD_DEFCONFIG processing above ?
	src_uri_defconfig=$(echo $sccs_from_src_uri | awk '(match($0, "defconfig") != 0) { print $0 }' RS=' ')
	# drop and defconfig's from the src_uri variable, we captured it just above here if it existed
	sccs_from_src_uri=$(echo $sccs_from_src_uri | awk '(match($0, "defconfig") == 0) { print $0 }' RS=' ')

	if [ -n "$in_tree_defconfig" ]; then
		sccs_defconfig=$in_tree_defconfig
		if [ -n "$src_uri_defconfig" ]; then
			bbwarn "[NOTE]: defconfig was supplied both via KBUILD_DEFCONFIG and SRC_URI. Dropping SRC_URI entry $src_uri_defconfig"
		fi
	else
		# if we didn't have an in-tree one, make our defconfig the one
		# from the src_uri. Note: there may not have been one from the
		# src_uri, so this can be an empty variable.
		sccs_defconfig=$src_uri_defconfig
	fi
	sccs="$sccs_from_src_uri"

	# check for feature directories/repos/branches that were part of the
	# SRC_URI. If they were supplied, we convert them into include directives
	# for the update part of the process
	for f in ${feat_dirs}; do
		if [ -d "/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/$f/kernel-meta" ]; then
			includes="$includes -I/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/$f/kernel-meta"
		elif [ -d "/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/../oe-local-files/$f" ]; then
			includes="$includes -I/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/../oe-local-files/$f"
	        elif [ -d "/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/$f" ]; then
			includes="$includes -I/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/$f"
		fi
	done
	for s in ${sccs} ${patches}; do
		sdir=$(dirname $s)
		includes="$includes -I${sdir}"
                # if a SRC_URI passed patch or .scc has a subdir of "kernel-meta",
                # then we add it to the search path
                if [ -d "${sdir}/kernel-meta" ]; then
			includes="$includes -I${sdir}/kernel-meta"
                fi
	done

	# expand kernel features into their full path equivalents
	bsp_definition=$(spp ${includes} --find -DKMACHINE=raspberrypi4-64 -DKTYPE=standard)
	if [ -z "$bsp_definition" ]; then
		if [ -z "$sccs_defconfig" ]; then
			bbfatal_log "Could not locate BSP definition for raspberrypi4-64/standard and no defconfig was provided"
		fi
	else
		# if the bsp definition has "define KMETA_EXTERNAL_BSP t",
		# then we need to set a flag that will instruct the next
		# steps to use the BSP as both configuration and patches.
		grep -q KMETA_EXTERNAL_BSP $bsp_definition
		if [ $? -eq 0 ]; then
		    KMETA_EXTERNAL_BSPS="t"
		fi
	fi
	meta_dir=$(kgit --meta)

	KERNEL_FEATURES_FINAL=""
	if [ -n "   cfg/fs/vfat.scc" ]; then
		for feature in    cfg/fs/vfat.scc; do
			feature_found=f
			for d in $includes; do
				path_to_check=$(echo $d | sed 's/^-I//')
				if [ "$feature_found" = "f" ] && [ -e "$path_to_check/$feature" ]; then
				    feature_found=t
				fi
			done
			if [ "$feature_found" = "f" ]; then
				if [ -n "${KERNEL_DANGLING_FEATURES_WARN_ONLY}" ]; then
				    bbwarn "Feature '$feature' not found, but KERNEL_DANGLING_FEATURES_WARN_ONLY is set"
				    bbwarn "This may cause runtime issues, dropping feature and allowing configuration to continue"
				else
				    bberror "Feature '$feature' not found, this will cause configuration failures."
				    bberror "Check the SRC_URI for meta-data repositories or directories that may be missing"
				    bbfatal_log "Set KERNEL_DANGLING_FEATURES_WARN_ONLY to ignore this issue"
				fi
			else
				KERNEL_FEATURES_FINAL="$KERNEL_FEATURES_FINAL $feature"
			fi
		done
        fi

	if [ "$mode" = "config" ]; then
		# run1: pull all the configuration fragments, no matter where they come from
		elements="`echo -n ${bsp_definition} $sccs_defconfig ${sccs} ${patches} $KERNEL_FEATURES_FINAL`"
		if [ -n "${elements}" ]; then
			echo "${bsp_definition}" > /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/${meta_dir}/bsp_definition
			scc --force -o /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/${meta_dir}:cfg,merge,meta ${includes} $sccs_defconfig $bsp_definition $sccs $patches $KERNEL_FEATURES_FINAL
			if [ $? -ne 0 ]; then
				bbfatal_log "Could not generate configuration queue for raspberrypi4-64."
			fi
		fi
	fi

	# if KMETA_EXTERNAL_BSPS has been set, or it has been detected from
	# the bsp definition, then we inject the bsp_definition into the
	# patch phase below.  we'll piggy back on the sccs variable.
	if [ -n "${KMETA_EXTERNAL_BSPS}" ]; then
		sccs="${bsp_definition} ${sccs}"
	fi

	if [ "$mode" = "patch" ]; then
		# run2: only generate patches for elements that have been passed on the SRC_URI
		elements="`echo -n ${sccs} ${patches} $KERNEL_FEATURES_FINAL`"
		if [ -n "${elements}" ]; then
			scc --force -o /home/sim/yocto/scarthgap/build/tmp/work-shared/raspberrypi4-64/kernel-source/${meta_dir}:patch --cmds patch ${includes} ${sccs} ${patches} $KERNEL_FEATURES_FINAL
			if [ $? -ne 0 ]; then
				bbfatal_log "Could not generate configuration queue for raspberrypi4-64."
			fi
		fi
	fi

	if [ 1 -gt 0 ]; then
		bbnote "kernel meta data summary for raspberrypi4-64 (standard):"
		bbnote "======================================================================"
		if [ -n "${KMETA_EXTERNAL_BSPS}" ]; then
			bbnote "Non kernel-cache (external) bsp"
		fi
		bbnote "BSP entry point / definition: $bsp_definition"
		if [ -n "$in_tree_defconfig" ]; then
			bbnote "KBUILD_DEFCONFIG: bcm2711_defconfig"
		fi
		bbnote "Fragments from SRC_URI: $sccs_from_src_uri"
		bbnote "KERNEL_FEATURES: $KERNEL_FEATURES_FINAL"
		bbnote "Final scc/cfg list: $sccs_defconfig $bsp_definition $sccs $KERNEL_FEATURES_FINAL"
	fi

	set -e
}

# line: 87, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/logging.bbclass
bbdebug() {
	USAGE='Usage: bbdebug [123] "message"'
	if [ $# -lt 2 ]; then
		bbfatal "$USAGE"
	fi

	# Strip off the debug level and ensure it is an integer
	DBGLVL=$1; shift
	NONDIGITS=$(echo "$DBGLVL" | tr -d "[:digit:]")
	if [ "$NONDIGITS" ]; then
		bbfatal "$USAGE"
	fi

	# All debug output is printed to the logs
	if [ -p /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433 ] ; then
		printf "%b\0" "bbdebug $DBGLVL $*" > /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433
	else
		echo "DEBUG: $*"
	fi
}

# line: 60, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/logging.bbclass
bbfatal() {
	if [ -p /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433 ] ; then
		printf "%b\0" "bbfatal $*" > /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433
	else
		echo "ERROR: $*"
	fi
	exit 1
}

# line: 27, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/logging.bbclass
bbnote() {
	if [ -p /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433 ] ; then
		printf "%b\0" "bbnote $*" > /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433
	else
		echo "NOTE: $*"
	fi
}

# line: 38, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/logging.bbclass
bbwarn() {
	if [ -p /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433 ] ; then
		printf "%b\0" "bbwarn $*" > /home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/temp/fifo.3072433
	else
		echo "WARNING: $*"
	fi
}

# line: 362, file: /home/sim/yocto/scarthgap/poky/meta/classes-global/utils.bbclass
check_git_config() {
	if ! git config user.email > /dev/null ; then
		git config --local user.email "oe.patch@oe"
	fi
	if ! git config user.name > /dev/null ; then
		git config --local user.name "OpenEmbedded"
	fi
}

cd '/home/sim/yocto/scarthgap/build/tmp/work/raspberrypi4_64-poky-linux/linux-raspberrypi/6.6.63+git/linux-raspberrypi4_64-standard-build'
do_kernel_configme

# cleanup
ret=$?
trap '' 0
exit $ret
