or will be generating the tarball on your own), Buildroot also allows
you to just prepare the SDK with +make prepare-sdk+ without actually
generating a tarball.
+
+For your convenience, by selecting the option
++BR2_PACKAGE_HOST_ENVIRONMENT_SETUP+, you can get a
++setup-environment+ script installed in +output/host/+ and therefore
+in your SDK. This script can be sourced with
++. your/sdk/path/environment-setup+ to export a number of environment
+variables that will help cross-compile your projects using the
+Buildroot SDK: the +PATH+ will contain the SDK binaries, standard
+_autotools_ variables will be defined with the appropriate values, and
++CONFIGURE_FLAGS+ will contain basic +./configure+ options to
+cross-compile _autotools_ projects. Note however that once this script
+is sourced, the environment is setup only for cross-compilation, and
+no longer for native compilation.
source "package/dtc/Config.in.host"
source "package/e2fsprogs/Config.in.host"
source "package/e2tools/Config.in.host"
+ source "package/environment-setup/Config.in.host"
source "package/erofs-utils/Config.in.host"
source "package/eudev/Config.in.host"
source "package/exfatprogs/Config.in.host"
--- /dev/null
+config BR2_PACKAGE_HOST_ENVIRONMENT_SETUP
+ bool "host environment-setup"
+ help
+ Install an helper script to setup a build environment
+ based on Buildroot. It's useful when you export an sdk
+ and want to use Buildroot to build an external project.
--- /dev/null
+cat <<'EOF'
+ _ _ _ _ _
+| |__ _ _(_) | __| |_ __ ___ ___ | |_
+| '_ \| | | | | |/ _` | '__/ _ \ / _ \| __|
+| |_) | |_| | | | (_| | | | (_) | (_) | |_
+|_.__/ \__,_|_|_|\__,_|_| \___/ \___/ \__|
+
+ Making embedded Linux easy!
+
+Some tips:
+* PATH now contains the SDK utilities
+* Standard autotools variables (CC, LD, CFLAGS) are exported
+* To configure do "./configure $CONFIGURE_FLAGS"
+
+EOF
+SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}"))
--- /dev/null
+################################################################################
+#
+# environment-setup
+#
+################################################################################
+
+ENVIRONMENT_SETUP_FILE = $(HOST_DIR)/environment-setup
+
+define HOST_ENVIRONMENT_SETUP_INSTALL_CMDS
+ cp package/environment-setup/environment-setup $(ENVIRONMENT_SETUP_FILE)
+ for var in $(TARGET_CONFIGURE_OPTS); do \
+ printf "export \"$$var\"\n" >> $(ENVIRONMENT_SETUP_FILE); \
+ done
+ printf "export \"CROSS_COMPILE=$(TARGET_CROSS)\"\n" >> $(ENVIRONMENT_SETUP_FILE)
+ printf "export \"CONFIGURE_FLAGS=--target=$(GNU_TARGET_NAME) \
+ --host=$(GNU_TARGET_NAME) \
+ --build=$(GNU_HOST_NAME) \
+ --prefix=/usr \
+ --exec-prefix=/usr \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --program-prefix=\"\n" >> $(ENVIRONMENT_SETUP_FILE)
+ $(SED) 's%$(HOST_DIR)%\$$SDK_PATH%g' \
+ -e 's%$(HOST_DIR)/bin/%%g' \
+ -e '/^export "PATH=/c\' \
+ $(ENVIRONMENT_SETUP_FILE)
+ printf "export \"PATH=\$$SDK_PATH/bin:\$$SDK_PATH/sbin:\$$PATH\"\n" \
+ >> $(ENVIRONMENT_SETUP_FILE)
+endef
+
+$(eval $(host-generic-package))