summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-06-27 19:58:20 +0000
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-06-27 19:58:20 +0000
commitb2aa00ac464259d7b3149badc81451f24d3456d1 (patch)
treed51ca81a8eefe4250d9ed9565ba43c23197f477b
parent56c17ed3bba25d04a4c9a07e902bb7fd9aa98134 (diff)
buildroot: build a second pass kernel if initramfs is enabled
If initramfs is enabled, build a second pass kernel containing the CPIO rootfs, preliminary work to get non exclusive enabling of initramfs. Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@37047 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--include/kernel-build.mk1
-rw-r--r--include/kernel-defaults.mk35
2 files changed, 30 insertions, 6 deletions
diff --git a/include/kernel-build.mk b/include/kernel-build.mk
index 095940c570..27c7aee17a 100644
--- a/include/kernel-build.mk
+++ b/include/kernel-build.mk
@@ -32,6 +32,7 @@ endef
define Kernel/CompileImage
$(call Kernel/CompileImage/Default)
+ $(call Kernel/CompileImage/Initramfs)
endef
define Kernel/Clean
diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
index 8ad31dd73a..9a5eefdf2c 100644
--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -83,12 +83,13 @@ ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
echo -e "$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),CONFIG_INITRAMFS_COMPRESSION_XZ=y\nCONFIG_RD_XZ=y,# CONFIG_INITRAMFS_COMPRESSION_XZ is not set\n# CONFIG_RD_XZ is not set)" >> $(LINUX_DIR)/.config
endef
else
- define Kernel/SetInitramfs
+endif
+
+define Kernel/SetNoInitramfs
mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
- endef
-endif
+endef
define Kernel/Configure/Default
$(LINUX_CONF_CMD) > $(LINUX_DIR)/.config.target
@@ -100,12 +101,16 @@ define Kernel/Configure/Default
echo "# CONFIG_KPROBES is not set" >> $(LINUX_DIR)/.config.target
$(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config > $(LINUX_DIR)/.config.override
$(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
- $(call Kernel/SetInitramfs)
+ $(call Kernel/SetNoInitramfs)
rm -rf $(KERNEL_BUILD_DIR)/modules
[ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
$(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic
endef
+define Kernel/Configure/Initramfs
+ $(call Kernel/SetInitramfs)
+endef
+
define Kernel/CompileModules/Default
rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map
+$(MAKE) $(KERNEL_MAKEOPTS) modules
@@ -113,13 +118,31 @@ endef
OBJCOPY_STRIP = -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
+define Kernel/CopyImage
+ $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)$(1)
+ $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).elf
+endef
+
define Kernel/CompileImage/Default
$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),,rm -f $(TARGET_DIR)/init)
+$(MAKE) $(KERNEL_MAKEOPTS) $(subst ",,$(KERNELNAME))
#")
- $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
- $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
+ $(call Kernel/CopyImage)
+endef
+
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+define Kernel/CompileImage/Initramfs
+ $(call Kernel/Configure/Initramfs)
+ $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),,rm -f $(TARGET_DIR)/init)
+ +$(MAKE) $(KERNEL_MAKEOPTS) $(subst ",,$(KERNELNAME))
+ #")
+ #")
+ $(call Kernel/CopyImage,-initramfs)
endef
+else
+define Kernel/CompileImage/Initramfs
+endef
+endif
define Kernel/Clean/Default
rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured