barebox: Allow to pass a custom configuration file
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Sat, 3 Nov 2012 06:05:10 +0000 (06:05 +0000)
committerPeter Korsgaard <jacmet@sunsite.dk>
Sat, 3 Nov 2012 16:20:15 +0000 (17:20 +0100)
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
boot/barebox/Config.in
boot/barebox/barebox.mk

index bd70e58b81a86e89940b4426e47dc846228d3cdf..d6ce8dd6805678cbcbd42fa189c8950197f09418 100644 (file)
@@ -67,12 +67,33 @@ config BR2_TARGET_BAREBOX_CUSTOM_GIT_VERSION
 
 endif
 
+
+choice
+       prompt "Barebox configuration"
+       default BR2_TARGET_BAREBOX_USE_DEFCONFIG
+
+config BR2_TARGET_BAREBOX_USE_DEFCONFIG
+       bool "Using a defconfig"
+
+config BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG
+       bool "Using a custom config file"
+
+endchoice
+
 config BR2_TARGET_BAREBOX_BOARD_DEFCONFIG
        string "board defconfig"
+       depends on BR2_TARGET_BAREBOX_USE_DEFCONFIG
        help
          Name of the board for which Barebox should be built, without
          the _defconfig suffix.
 
+
+config BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
+       string "Configuration file path"
+       depends on BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG
+       help
+         Path to the barebox configuration file
+
 config BR2_TARGET_BAREBOX_BAREBOXENV
        bool "bareboxenv tool in target"
        help
index ee84831c6c478bd2a300730720819915f3393099..a025d5f4a3eba81104ddeb45bfc0f5f6b25c4ec3 100644 (file)
@@ -37,8 +37,6 @@ ifneq ($(BR2_TARGET_BAREBOX_BAREBOXENV),y)
 BAREBOX_INSTALL_TARGET = NO
 endif
 
-BAREBOX_BOARD_DEFCONFIG = $(call qstrip,$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))
-
 ifeq ($(KERNEL_ARCH),i386)
 BAREBOX_ARCH=x86
 else ifeq ($(KERNEL_ARCH),powerpc)
@@ -49,8 +47,16 @@ endif
 
 BAREBOX_MAKE_FLAGS = ARCH=$(BAREBOX_ARCH) CROSS_COMPILE="$(CCACHE) $(TARGET_CROSS)"
 
+
+ifeq ($(BR2_TARGET_BAREBOX_USE_DEFCONFIG),y)
+BAREBOX_SOURCE_CONFIG = $(@D)/arch/$(BAREBOX_ARCH)/configs/$(call qstrip,$(BR2_TARGET_BAREBOX_BOARD_DEFCONFIG))_defconfig
+else ifeq ($(BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG),y)
+BAREBOX_SOURCE_CONFIG = $(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE)
+endif
+
 define BAREBOX_CONFIGURE_CMDS
-       $(MAKE) $(BAREBOX_MAKE_FLAGS) -C $(@D) $(BAREBOX_BOARD_DEFCONFIG)_defconfig
+       cp $(BAREBOX_SOURCE_CONFIG) $(@D)/arch/$(BAREBOX_ARCH)/configs/buildroot_defconfig
+       $(MAKE) $(BAREBOX_MAKE_FLAGS) -C $(@D) buildroot_defconfig
 endef
 
 ifeq ($(BR2_TARGET_BAREBOX_BAREBOXENV),y)
@@ -80,8 +86,8 @@ $(eval $(generic-package))
 ifeq ($(BR2_TARGET_BAREBOX),y)
 # we NEED a board defconfig file unless we're at make source
 ifeq ($(filter source,$(MAKECMDGOALS)),)
-ifeq ($(BAREBOX_BOARD_DEFCONFIG),)
-$(error No Barebox defconfig file. Check your BR2_TARGET_BAREBOX_BOARD_DEFCONFIG setting)
+ifeq ($(BAREBOX_SOURCE_CONFIG),)
+$(error No Barebox config file. Check your BR2_TARGET_BAREBOX_BOARD_DEFCONFIG or BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE settings)
 endif
 endif
 
@@ -94,4 +100,14 @@ barebox-savedefconfig: barebox-configure
        $(MAKE) $(BAREBOX_MAKE_FLAGS) -C $(BAREBOX_DIR) \
                $(subst barebox-,,$@)
 
+ifeq ($(BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG),y)
+barebox-update-config: barebox-configure $(BAREBOX_DIR)/.config
+       cp -f $(BAREBOX_DIR)/.config $(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE)
+
+barebox-update-defconfig: barebox-savedefconfig
+       cp -f $(BAREBOX_DIR)/defconfig $(BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE)
+else
+barebox-update-config: ;
+barebox-update-defconfig: ;
+endif
 endif