Browse Source

add support for providing an externel kernel configuration file

Signed-off-by: Mario Haustein <mario.haustein@hrz.tu-chemnitz.de>
Mario Haustein 7 years ago
parent
commit
6bbb8cf19c
4 changed files with 33 additions and 2 deletions
  1. 1 1
      Config.in
  2. 20 1
      mk/kernel-build.mk
  3. 4 0
      target/Makefile
  4. 8 0
      target/config/Config.in.kernelcfg

+ 1 - 1
Config.in

@@ -50,7 +50,7 @@ source "target/config/Config.in.kernelcfg"
 source "target/linux/config/Config.in.compression"
 
 menu "Kernel configuration"
-	visible if ADK_TARGET_OS_LINUX && ADK_TARGET_KERNEL_CUSTOMISING && !ADK_APPLIANCE_TOOLCHAIN && !ADK_TARGET_CHOOSE_ARCH && !ADK_TARGET_KERNEL_USE_DEFCONFIG
+	visible if ADK_TARGET_OS_LINUX && ADK_TARGET_KERNEL_CUSTOMISING && !ADK_APPLIANCE_TOOLCHAIN && !ADK_TARGET_CHOOSE_ARCH && !ADK_TARGET_KERNEL_USE_DEFCONFIG && !ADK_TARGET_KERNEL_USE_CUSTOMCONFIG
 source "target/linux/Config.in"
 endmenu
 

+ 20 - 1
mk/kernel-build.mk

@@ -6,7 +6,11 @@ include $(ADK_TOPDIR)/mk/kernel-ver.mk
 include $(ADK_TOPDIR)/mk/linux.mk
 include $(ADK_TOPDIR)/mk/kernel-vars.mk
 
+ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
+KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH))
+else
 KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
+endif
 
 KERNEL_FILE:=$(ADK_TARGET_KERNEL)
 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
@@ -38,12 +42,27 @@ $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PK
 	mkdir -p $(LINUX_BUILD_DIR)/kmod-control
 	touch $@
 
-$(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared $(BUILD_DIR)/.kernelconfig
+ifeq ($(ADK_TARGET_KERNEL_USE_MINICONFIG),y)
+$(LINUX_DIR)/.config: $(BUILD_DIR)/.kernelconfig
+endif
+
+ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
+$(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH):
+$(LINUX_DIR)/.config: $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH)
+endif
+
+$(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared
 	$(START_TRACE) "target/$(ADK_TARGET_ARCH)-kernel-configure.. "
 	-for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done
 	echo "-${KERNEL_RELEASE}" >${LINUX_DIR}/localversion
 ifeq ($(ADK_TARGET_KERNEL_USE_DEFCONFIG),y)
 	${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} $(ADK_TARGET_KERNEL_DEFCONFIG) $(MAKE_TRACE)
+else ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
+	@if [ ! -f $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) ];then \
+		echo "no kernel configuration found in $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH)"; \
+		exit 1; \
+	fi
+	${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=$(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH) allnoconfig $(MAKE_TRACE)
 else
 	$(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
 	${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)

+ 4 - 0
target/Makefile

@@ -4,7 +4,11 @@
 include $(ADK_TOPDIR)/rules.mk
 include $(ADK_TOPDIR)/mk/rootfs.mk
 
+ifeq ($(ADK_TARGET_KERNEL_USE_CUSTOMCONFIG),y)
+KERNEL_MODULES_USED:=$(shell grep -s =m $(ADK_TOPDIR)/$(ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH))
+else
 KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
+endif
 
 all: install
 

+ 8 - 0
target/config/Config.in.kernelcfg

@@ -14,6 +14,9 @@ config ADK_TARGET_KERNEL_USE_MINICONFIG
 config ADK_TARGET_KERNEL_USE_DEFCONFIG
 	bool "Use defconfig from Linux kernel"
 
+config ADK_TARGET_KERNEL_USE_CUSTOMCONFIG
+	bool "Use custom Linux kernel configuration file"
+
 endchoice
 
 config ADK_TARGET_KERNEL_DEFCONFIG
@@ -30,3 +33,8 @@ config ADK_TARGET_KERNEL_DEFCONFIG
 	default "orca_defconfig" if ADK_TARGET_SYSTEM_ANDES_AG101P
 	default "bb.org_defconfig" if ADK_TARGET_SYSTEM_BEAGLEBONE_BLACK
 
+config ADK_TARGET_KERNEL_CUSTOMCONFIG_PATH
+	string "Kernel configuration file location"
+	depends on ADK_TARGET_KERNEL_USE_CUSTOMCONFIG
+	default ".kernelconfig"
+