include linux/linux.mk
include fs/common.mk
+# If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variable
+# is also present in the .config file. Since .config is included after
+# we defined BR2_EXTERNAL_$(NAME)_PATH in the Makefile, the value in
+# that variable is quoted. We just include the generated Makefile fragment
+# .br2-external.mk a third time, which will set that variable to the
+# un-quoted value.
+include $(BR2_EXTERNAL_FILE)
+
# Nothing to include if no BR2_EXTERNAL tree in use
include $(BR2_EXTERNAL_MK)
KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
BR2_CONFIG=$(BR2_CONFIG) \
- BR2_EXTERNAL=$(BR2_EXTERNAL) \
HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
BUILD_DIR=$(BUILD_DIR) \
SKIP_LEGACY=
@$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
$$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
endef
-$(eval $(foreach d,$(TOPDIR) $(BR2_EXTERNAL),$(call percent_defconfig,$(d))$(sep)))
+$(eval $(foreach d,$(TOPDIR) $(if $(BR2_EXTERNAL_NAME),$(BR2_EXTERNAL_$(BR2_EXTERNAL_NAME)_PATH)),$(call percent_defconfig,$(d))$(sep)))
savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
@$(COMMON_CONFIG_ENV) $< \
@echo 'Built-in configs:'
@$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
-ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
+ifneq ($(BR2_EXTERNAL_NAME),)
+ifneq ($(wildcard $(BR2_EXTERNAL_$(BR2_EXTERNAL_NAME)_PATH)/configs/*_defconfig),)
@echo
@echo 'User-provided configs:'
- @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
+ @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL_$(BR2_EXTERNAL_NAME)_PATH)/configs/*_defconfig))), \
printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
+endif
endif
@echo
@echo $(BR2_VERSION_FULL)
include docs/manual/manual.mk
--include $(BR2_EXTERNAL)/docs/*/*.mk
+-include $(if $(BR2_EXTERNAL_NAME),$(BR2_EXTERNAL_$(BR2_EXTERNAL_NAME)_PATH)/docs/*/*.mk)
.PHONY: $(noconfig_targets)
invalid. This option sets the barebox Kconfig option
CONFIG_DEFAULT_ENVIRONMENT_PATH to the specified path. This
way it is possible to use Buildroot variables like
- BR2_EXTERNAL, TOPDIR etc. to refer to the custom
- environment.
+ TOPDIR etc. to refer to the custom environment.
Depending on your setup, the custom embedded environment
will probably be based on either the content of the
invalid. This option sets the barebox Kconfig option
CONFIG_DEFAULT_ENVIRONMENT_PATH to the specified path. This
way it is possible to use Buildroot variables like
- BR2_EXTERNAL, TOPDIR etc. to refer to the custom
- environment.
+ TOPDIR etc. to refer to the custom environment.
Depending on your setup, the custom embedded environment
will probably be based on either the content of the
EXTRA_ENV = \
PATH=$(BR_PATH) \
BR2_DL_DIR=$(BR2_DL_DIR) \
- BUILD_DIR=$(BUILD_DIR) \
- BR2_EXTERNAL=$(BR2_EXTERNAL)
+ BUILD_DIR=$(BUILD_DIR)
################################################################################
# settings we need to pass to configure
# kernel case, the bootloaders case, and the normal packages case.
ifeq ($(1),linux)
$(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
-else ifneq ($$(filter boot/% $(BR2_EXTERNAL)/boot/%,$(pkgdir)),)
+else ifneq ($$(filter boot/% $$(if $$(BR2_EXTERNAL_NAME),$$(BR2_EXTERNAL_$$(BR2_EXTERNAL_NAME)_PATH)/boot/%),$(pkgdir)),)
$(2)_KCONFIG_VAR = BR2_TARGET_$(2)
-else ifneq ($$(filter toolchain/% $(BR2_EXTERNAL)/toolchain/%,$(pkgdir)),)
+else ifneq ($$(filter toolchain/% $$(if $$(BR2_EXTERNAL_NAME),$$(BR2_EXTERNAL_$$(BR2_EXTERNAL_NAME)_PATH)/toolchain/%),$(pkgdir)),)
$(2)_KCONFIG_VAR = BR2_$(2)
else
$(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
#!/bin/bash
set -e
-# The location of the br2-external tree, once validated.
+# The name and location of the br2-external tree, once validated.
+declare BR2_NAME
declare BR2_EXT
main() {
#
do_validate() {
local br2_ext="${1}"
+ local br2_name n
# No br2-external tree is valid
if [ -z "${br2_ext}" ]; then
if [ ! -r "${br2_ext}" -o ! -x "${br2_ext}" ]; then
error "'%s': permission denied\n" "${br2_ext}"
fi
+ if [ ! -f "${br2_ext}/external.desc" ]; then
+ error "'%s': does not have a name (in 'external.desc')\n" "${br2_ext}"
+ fi
+ br2_name="$(sed -r -e '/^name: +(.*)$/!d; s//\1/' "${br2_ext}/external.desc")"
+ if [ -z "${br2_name}" ]; then
+ error "'%s/external.desc': does not define the name\n" "${br2_ext}"
+ fi
+ # Only ASCII chars in [A-Za-z0-9_] are permitted
+ n="$(sed -r -e 's/[A-Za-z0-9_]//g' <<<"${br2_name}" )"
+ if [ -n "${n}" ]; then
+ # Escape '$' so that it gets printed
+ error "'%s': name '%s' contains invalid chars: '%s'\n" \
+ "${br2_ext}" "${br2_name//\$/\$\$}" "${n//\$/\$\$}"
+ fi
if [ ! -f "${br2_ext}/external.mk" ]; then
error "'%s/external.mk': no such file or directory\n" "${br2_ext}"
fi
error "'%s/Config.in': no such file or directory\n" "${br2_ext}"
fi
+ BR2_NAME="${br2_name}"
BR2_EXT="$(cd "${br2_ext}"; pwd -P )"
}
# Generate the .mk snippet that defines makefile variables
# for the br2-external tree
do_mk() {
- local BR2_EXT="${1}"
-
printf '#\n# Automatically generated file; DO NOT EDIT.\n#\n'
printf '\n'
printf 'BR2_EXTERNAL ?= %s\n' "${BR2_EXT}"
+ printf 'BR2_EXTERNAL_NAME = \n'
printf 'BR2_EXTERNAL_MK =\n'
printf '\n'
- if [ -z "${BR2_EXT}" ]; then
+ if [ -z "${BR2_NAME}" ]; then
printf '# No br2-external tree defined.\n'
return
fi
+ printf 'BR2_EXTERNAL_NAME = %s\n' "${BR2_NAME}"
printf 'BR2_EXTERNAL_MK = %s/external.mk\n' "${BR2_EXT}"
+ printf 'BR2_EXTERNAL_%s_PATH = %s\n' "${BR2_NAME}" "${BR2_EXT}"
}
# Generate the kconfig snippet for the br2-external tree.
printf '#\n# Automatically generated file; DO NOT EDIT.\n#\n'
printf '\n'
- if [ -z "${BR2_EXT}" ]; then
+ if [ -z "${BR2_NAME}" ]; then
printf '# No br2-external tree defined.\n'
return
fi
- printf 'config BR2_EXTERNAL\n'
+ printf 'menu "User-provided options"\n'
+ printf '\n'
+ printf 'comment "%s (in %s)"\n' "${BR2_NAME}" "${BR2_EXT}"
+ printf '\n'
+ printf 'config BR2_EXTERNAL_%s_PATH\n' "${BR2_NAME}"
printf '\tstring\n'
printf '\tdefault "%s"\n' "${BR2_EXT}"
printf '\n'
- printf 'menu "User-provided options"\n'
- printf '\n'
- printf 'source "%s/Config.in"\n' "${BR2_EXT}"
+ printf 'source "$BR2_EXTERNAL_%s_PATH/Config.in"\n' "${BR2_NAME}"
printf '\n'
printf "endmenu # User-provided options\n"
}