#!/bin/bash -eu

. debian/debian.env

# Override config settings (in the annotations) which are not applicable in the
# 22-04/Jammy environment when using GCC-11.
GCC=$(grep "export gcc.=" debian/rules.d/0-common-vars.mk | cut -d= -f2)
GCCV=$(${CHROOT:-} $GCC --version | grep ^gcc | cut -d" " -f3 | cut -d. -f1)

if [ "$GCCV" = "11" ]; then
	sed -i 	-e "/CONFIG_INIT_STACK_ALL_ZERO/s/'y'/'-'/g" \
		-e "/CONFIG_SHADOW_CALL_STACK/s/'y'/'-'/g" \
		"${DEBIAN}/config/annotations"
fi

# Override options in rules.d/hooks.mk (normally master does not have this
# file but it got added for generic annotations enforcement.
cat <<EOD >>"${DEBIAN}/rules.d/hooks.mk"
do_libc_dev_package	= false
do_doc_package		= false
do_tools_common		= false
do_tools_host		= false
EOD

