summaryrefslogtreecommitdiffstats
path: root/fs/common.mk
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2010-06-13 19:19:38 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2010-06-22 21:20:28 +0200
commitf507921d391bb2578261a9e45c003e72302dc67a (patch)
treeae071e5efda5cd4c1e5f69f375d79ac2d9a482e4 /fs/common.mk
parent4944e8c883efd0e11cc9e7585905e89941eb825b (diff)
downloadbuildroot-novena-f507921d391bb2578261a9e45c003e72302dc67a.tar.gz
buildroot-novena-f507921d391bb2578261a9e45c003e72302dc67a.zip
linux: add support for initramfs
In Buildroot, the kernel is built and installed *before* the root filesystems are built. This allows the root filesystem to correctly contain the kernel modules that have been installed. However, in the initramfs case, the root filesystem is part of the kernel. Therefore, the kernel should be built *after* the root filesystem (which, in the initramfs case simply builds a text file listing all files/directories/devices/symlinks that should be part of the initramfs). However, this isn't possible as the initramfs text file would lack all kernel modules. So, the solution choosen here is to keep the normal order: kernel is built before the root filesystem is generated, and to add a little quirk to retrigger a kernel compilation after the root filesystem generation. To do so, we add a ROOTFS_$(FSTYPE)_POST_TARGETS variable to the fs/common.mk infrastructure. This allows individual filesystems to set a target name that we should depend on *after* generating the root filesystem itself (contrary to normal ROOTFS_$(FSTYPE)_DEPENDENCIES, on which we depend *before* generating the root filesystem). The initramfs code in fs/initramfs/initramfs.mk uses this to add a dependency on 'linux26-rebuild-with-initramfs'. In linux/linux.mk, we do various things : * If BR2_TARGET_ROOTFS_INITRAMFS is enabled (i.e if initramfs is enabled as a root filesystem type), then we create an empty rootfs.initramfs file (remember that at this point, the root filesystem hasn't been generated) and we adjust the kernel configuration to include an initramfs. Of course, in the initial kernel build, this initramfs will be empty. * In the linux26-rebuild-with-initramfs target, we retrigger a compilation of the kernel image, after removing the initramfs in the kernel sources to make sure it gets properly rebuilt (we've experienced cases were modifying the rootfs.initramfs file wouldn't retrigger the generation of the initramfs at the kernel level). This is fairly quirky, but initramfs really is a special case, so in one way or another, we need a little quirk to solve its specialness. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'fs/common.mk')
-rw-r--r--fs/common.mk6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/common.mk b/fs/common.mk
index 50dc97425..74e9ce060 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -19,6 +19,10 @@
# ROOTFS_$(FSTYPE)_POST_GEN_HOOKS, a list of hooks to call after
# generating the filesystem image
#
+# ROOTFS_$(FSTYPE)_POST_TARGETS, the list of targets that should be
+# run after running the main filesystem target. This is useful for
+# initramfs, to rebuild the kernel once the initramfs is generated.
+#
# In terms of configuration option, this macro assumes that the
# BR2_TARGET_ROOTFS_$(FSTYPE) config option allows to enable/disable
# the generation of a filesystem image of a particular type. If
@@ -60,7 +64,7 @@ endif
$(1)-root-show-depends:
@echo $(ROOTFS_$(2)_DEPENDENCIES) host-fakeroot host-makedevs $(if $(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma)
-$(1)-root: $(BINARIES_DIR)/rootfs.$(1)
+$(1)-root: $(BINARIES_DIR)/rootfs.$(1) $(ROOTFS_$(2)_POST_TARGETS)
ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
TARGETS += $(1)-root