Enable p8-pore-binutils as an external toolchain

Create the infrastructure necessary to bundle the p8-pore-binutils as
part of the sdk build, allowing it to be re-inserted as part of an
external sdk.

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
diff --git a/ci/build-all-defconfigs.sh b/ci/build-all-defconfigs.sh
index f21b847..c9bb98b 100755
--- a/ci/build-all-defconfigs.sh
+++ b/ci/build-all-defconfigs.sh
@@ -67,6 +67,11 @@
 	echo -n "${major}"
 }
 
+function sha1sum_dir
+{
+	echo -n "$(find $1 -type f -print0 | sort -z | xargs -0 sha1sum | sed -e 's/ .*//' | tr -d '[:space:]' | sha1sum | sed -e 's/ .*//')"
+}
+
 function build_sdk
 {
 # $1 is the defconfig
@@ -100,6 +105,12 @@
 		--disable ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV \
 		--enable INSTALL_LIBSTDCPP
 
+	# Enable toolchains we'll need to be built as part of the SDK, and make sure we
+	# consider them to make the sdk unique
+	buildroot/utils/config --file $SDK_BUILD_DIR/.config --package \
+		--enable P8_PORE_TOOLCHAIN  --enable HOST_P8_PORE_BINUTILS
+	HASH_PROPERTIES="$HASH_PROPERTIES $(sha1sum_dir openpower/package/p8-pore-binutils/)"
+
 	# As we are disabling BR2_LINUX_KERNEL, capture Kernel version if any
 	# to prevent it from defaulting to the last on olddefconfig
 	KERNEL_VER=$(buildroot/utils/config --file $SDK_BUILD_DIR/.config --state LINUX_KERNEL_CUSTOM_VERSION_VALUE)
@@ -250,6 +261,16 @@
 		buildroot/utils/config --file $O/.config --enable TOOLCHAIN_EXTERNAL_CXX
 	fi
 
+	# Our SDK will always have p8-pore-toolchain enabled, but
+	# only use it if we require it
+	P8_PORE_REQUIRED=$(buildroot/utils/config --file $O/.config --package --state P8_PORE_TOOLCHAIN)
+	if [ "$P8_PORE_REQUIRED" = "y" ]; then
+		buildroot/utils/config --file $O/.config --enable PACKAGE_P8_PORE_TOOLCHAIN_EXTERNAL \
+			--set-str P8_PORE_TOOLCHAIN_EXTERNAL_PATH $SDK_DIR/host
+	fi
+
+
+
 	# The Kernel Headers requested MUST be the same as the one
 	# provided by the SDK (i.e., it's part of the hash)
 	HEADERS_VER=$(buildroot/utils/config --file $O/.config --state TOOLCHAIN_HEADERS_AT_LEAST)