summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2010-03-09 23:11:58 (GMT)
committer Thomas Petazzoni <thomas.petazzoni@free-electrons.com>2010-04-09 09:04:34 (GMT)
commit21f3bcc1868022e990c0d7ec4171727722b41fd9 (patch)
treeaac11d39d30cd0e4d6cc3b70d8de856d5f14a3d8
parentb605699f1f365c55d094c47737d3f5f7e38c1f61 (diff)
downloadbuildroot-21f3bcc1868022e990c0d7ec4171727722b41fd9.tar.gz
buildroot-21f3bcc1868022e990c0d7ec4171727722b41fd9.tar.bz2
target: Add new infrastructure for filesystem generation
In order to avoid code duplication between the different filesystem generation makefile, we introduce a ROOTFS_TARGET macro. Documentation for this macro is contained in the patch. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-rw-r--r--target/Makefile.in1
-rw-r--r--target/common.mk68
2 files changed, 69 insertions, 0 deletions
diff --git a/target/Makefile.in b/target/Makefile.in
index df980b4..38993e5 100644
--- a/target/Makefile.in
+++ b/target/Makefile.in
@@ -63,6 +63,7 @@ include target/u-boot/Makefile.in
endif
# and finally build the filesystems/tarballs
+include target/common.mk
include target/*/*.mk
# kernel rules
diff --git a/target/common.mk b/target/common.mk
new file mode 100644
index 0000000..c7eff74
--- /dev/null
+++ b/target/common.mk
@@ -0,0 +1,68 @@
+#
+# Macro that builds the needed Makefile target to create a root
+# filesystem image.
+#
+# The following variable must be defined before calling this macro
+#
+# ROOTFS_$(FSTYPE)_CMD, the command that generates the root
+# filesystem image. A single command is allowed. The filename of the
+# filesystem image that it must generate is $$@.
+#
+# The following variables can optionaly be defined
+#
+# ROOTFS_$(FSTYPE)_DEPENDENCIES, the list of dependencies needed to
+# build the root filesystem (usually host tools)
+#
+# ROOTFS_$(FSTYPE)_PRE_GEN_HOOKS, a list of hooks to call before
+# generating the filesystem image
+#
+# ROOTFS_$(FSTYPE)_POST_GEN_HOOKS, a list of hooks to call after
+# generating the filesystem image
+#
+# 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
+# configura options BR2_TARGET_ROOTFS_$(FSTYPE)_GZIP,
+# BR2_TARGET_ROOTFS_$(FSTYPE)_BZIP2 or
+# BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
+# macro will automatically generate a compressed filesystem image.
+
+FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
+
+define ROOTFS_TARGET_INTERNAL
+
+$(IMAGE).$(1): $(ROOTFS_$(2)_DEPENDENCIES) host-fakeroot makedevs $(if $(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma)
+ @$(call MESSAGE,"Generating root filesystem image $(IMAGE).$(1)")
+ $(foreach hook,$(ROOTFS_$(2)_PRE_GEN_HOOKS),$(call $(hook))$(sep))
+ rm -f $(FAKEROOT_SCRIPT)
+ touch $(BUILD_DIR)/.fakeroot.00000
+ cat $(BUILD_DIR)/.fakeroot* > $(FAKEROOT_SCRIPT)
+ echo "chown -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
+ifneq ($(TARGET_DEVICE_TABLE),)
+ echo "$(HOST_DIR)/usr/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
+endif
+ echo "$(ROOTFS_$(2)_CMD)" >> $(FAKEROOT_SCRIPT)
+ chmod a+x $(FAKEROOT_SCRIPT)
+ $(HOST_DIR)/usr/bin/fakeroot -- $(FAKEROOT_SCRIPT)
+ -@rm -f $(FAKEROOT_SCRIPT)
+ $(foreach hook,$(ROOTFS_$(2)_POST_GEN_HOOKS),$(call $(hook))$(sep))
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
+ gzip -9 -c $$@ > $$@.gz
+endif
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y)
+ bzip2 -9 -c $$@ > $$@.bz2
+endif
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
+ $(LZMA) -9 -c $$@ > $$@.lzma
+endif
+
+$(1)-root: $(IMAGE).$(1)
+
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
+TARGETS += $(1)-root
+endif
+endef
+
+define ROOTFS_TARGET
+$(call ROOTFS_TARGET_INTERNAL,$(1),$(call UPPERCASE,$(1)))
+endef \ No newline at end of file