@@ -332,7 +332,7 @@ TARGET_SKELETON = $(TOPDIR)/system/skeleton
# Location of a file giving a big fat warning that output/target
# should not be used as the root filesystem.
-TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
+TARGET_DIR_WARNING_FILE = THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
ifeq ($(BR2_CCACHE),y)
CCACHE := $(HOST_DIR)/usr/bin/ccache
@@ -1,5 +1,30 @@
menu "Filesystem images"
+config BR2_BUILD_SUB_FILESYSTEMS
+ bool "Build sub-filesystems"
+ help
+ Normally, all target files will be put into a single root filesystem.
+ Choosing this option allows sub-directories of the root filesystem
+ to be split into sub-filesystems, possible of different types.
+ These filesystems can then be written to different devices and
+ mounted at boot time to create the original view of the root
+ filesystem.
+
+ Note that this will split up the root filesystems based on the
+ concatenation of filesystems listed under all filesystems types.
+ So, if "/ and /usr" are listed under cpio and "/ /usr/share" are
+ listed under JFFS2, four filesystem images will be created:
+ o rootfs.cpio: A cpio image containing everything under the
+ original root filesystem except for /usr
+ o rootfs.jffs: A JFFS2 image with everything under the original
+ root filesystem except for /usr, i.e the same contents as
+ rootfs.cpio, but as a different filesystem image type.
+ o rootfs-usrfs.cpio: Everything under the original /usr directory
+ except for files under /usr/share, but including the /usr/share
+ directory.
+ o rootfs-usr-sharefs.jffs2: Everything under the original
+ /usr/share directory.
+
source "fs/cloop/Config.in"
source "fs/cpio/Config.in"
source "fs/cramfs/Config.in"
@@ -8,3 +8,15 @@ config BR2_TARGET_ROOTFS_CLOOP
compressed filesystem like a block device and seamlessly
decompress its data while accessing it. The majority of the
software on an LNX-BBC is accessed in this fashion.
+
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_CLOOP_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with cloop"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_CLOOP
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
new file mode 100644
@@ -0,0 +1,13 @@
+################################################################################
+#
+# Build the compressed loop root filesystem image
+#
+################################################################################
+
+ROOTFS_CLOOP_DEPENDENCIES = host-cloop host-cdrkit
+
+define ROOTFS_CLOOP_CMD
+ $(HOST_DIR)/usr/bin/genisoimage -r $(1) | $(HOST_DIR)/usr/bin/create_compressed_fs - 65536 > $@
+endef
+
+$(eval $(call ROOTFS_TARGETS,cloop,$(CLOOP_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define cloop filesystems
+#
+################################################################################
+
+CLOOP_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_CLOOP_SUB_FILESYSTEMS),/)
@@ -28,6 +28,7 @@
# BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
# macro will automatically generate a compressed filesystem image.
+SUBFS_DIR = $(BINARIES_DIR)/subfs
FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
@@ -35,6 +36,149 @@ ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
USERS_TABLE = $(BUILD_DIR)/_users_table.txt
ROOTFS_USERS_TABLES = $(call qstrip,$(BR2_ROOTFS_USERS_TABLES))
+# A complete list of filesystems to be built
+include $(sort $(wildcard fs/*/*-pre.mk))
+ALL_FILESYSTEMS = $(sort $(call qstrip,\
+ $(CLOOP_SUBFS) \
+ $(CPIO_SUBFS) \
+ $(CRAMFS_SUBFS) \
+ $(EXT2_SUBFS) \
+ $(JFFS2_SUBFS) \
+ $(ROMFS_SUBFS) \
+ $(SQUASHFS_SUBFS) \
+ $(TAR_SUBFS) \
+ $(UBIFS_SUBFS) \
+ $(UBI_SUBFS) \
+ $(YAFFS2_SUBFS)))
+
+# Translate from a full pathname to a tag.
+# $(1) Pathname. This must start with a slash
+define SUBFS_TAG
+$(if $(findstring $(1),/),,$(subst /,-,$(1)))
+endef
+
+# Add a leading slash to each of the subdirectory names
+# slashes
+# $(1) List of directories to which the leading slash should be added
+define ADD_LEADING_SLASH
+$(patsubst //,/,$(addprefix /,$(1)))
+endef
+
+# Add a trailing slash to each of the subdirectory names
+# slashes
+# $(1) List of directories to which the trailing slash should be added
+define ADD_TRAILING_SLASH
+$(patsubst //,/,$(addsuffix /,$(1)))
+endef
+
+# Pull out all of the subdirectories of a given directory and make them
+# relative to the given directory, using normalized directory names. Normalized
+# directory names all end with exactly one trailing slash
+# $(1) Directory
+# $(2) List of possible subdirectories
+define SUB_FILESYSTEMS_NORMALIZED
+$(call ADD_LEADING_SLASH,$(patsubst $(1)%,%,$(filter $(1)%,$(2))))
+endef
+
+# This is given a list of directory names and a starting directory. It pulls
+# out all of the directories properly under the starting directory and makes
+# The result is a list of relative pathnames, each of which ends with a slash.
+# $(1) Root directory, must start with slash (/)
+define SUB_FILESYSTEMS
+$(patsubst //%,/%,$(call SUB_FILESYSTEMS_NORMALIZED,$(call ADD_TRAILING_SLASH,$(1)),\
+$(call ADD_TRAILING_SLASH,$(sort $(ALL_FILESYSTEMS)))))
+endef
+
+# Create a "-prune" clause for the find command to prune the list of
+# subdirectories.
+# $(1) List of subdirectories. These are relative pathnames, so they must no
+# start with a slash (/) but must end with a slash.
+define FIND_PRUNE_SUBDIRECTORIES
+$(if $(1),\( \( $(subst |-o ,,|$(addprefix -o -path '.,$(addsuffix *',$(1)))) \) -prune \),-false)
+endef
+
+# Put together a set of options to the find command that can be used to
+# prune off subdirectories
+# $(1) Directory at which to start. This must start with a slash (/) character
+# We do a little odd processing to remove the -o from the first name; a
+# better way would be welcome.
+define FIND_PRUNE
+$(call FIND_PRUNE_SUBDIRECTORIES,$(call SUB_FILESYSTEMS,$(1)))
+endef
+
+# Message about sub-filesystem pruning
+# $(1) Directory being generated
+define PRUNING_MSG
+$(if $(strip $(1)),$(1),nothing)
+endef
+
+# Generate rules for one sub-filesystem target
+# $(1) Filesystem image type
+# $(2) Uppercase version of $(1)
+# $(3) Directory for which to generate the filesystem image
+# $(4) Location in which to place the directory tree
+define GEN_SUBFS_RULES_TAGGED
+
+$$(BINARIES_DIR)/root$(call SUBFS_TAG,$(3))fs.$(1): \
+ $(SUBFS_DIR)/root-all-$(1)
+ @echo
+ @echo "Creating $(1) directory tree for $(3)" \
+ "(pruning $(call PRUNING_MSG,$(call SUB_FILESYSTEMS,$(3))))"
+ rm -f $$(FAKEROOT_SCRIPT)
+ echo "set -e" >> $$(FAKEROOT_SCRIPT)
+ifeq ($$(ALL_FILESYSTEMS),/)
+ echo "$$(call ROOTFS_$(2)_CMD,$(TARGET_DIR))" >> $$(FAKEROOT_SCRIPT)
+else
+ echo "rm -f $(4)/$$(TARGET_DIR_WARNING_FILE)" >> $$(FAKEROOT_SCRIPT)
+ echo "cd $$(TARGET_DIR)$(3)" >> $$(FAKEROOT_SCRIPT)
+ echo "rm -rf $$@.tmp" >> $$(FAKEROOT_SCRIPT)
+ echo "mkdir -p $(4).tmp" >> $$(FAKEROOT_SCRIPT)
+ echo "find $(call FIND_PRUNE,$(3)) -o -print |" \
+ "cpio --quiet -p --make-directories $(4).tmp" \
+ >> $$(FAKEROOT_SCRIPT)
+ echo "mv $(4).tmp $(4)" >> $$(FAKEROOT_SCRIPT)
+ echo "cd - >/dev/null" >> $$(FAKEROOT_SCRIPT)
+ echo "$$(call ROOTFS_$(2)_CMD,$(4))" >> $$(FAKEROOT_SCRIPT)
+endif
+ chmod a+x $$(FAKEROOT_SCRIPT)
+ PATH=$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -s $$(FAKEROOT_$(2)_ENV) \
+ -i $$(FAKEROOT_$(2)_ENV) -- $$(FAKEROOT_SCRIPT)
+ifneq ($$(ROOTFS_$(2)_COMPRESS_CMD),)
+ $$(ROOTFS_$(2)_COMPRESS_CMD) $$@ > $$@$$(ROOTFS_$(2)_COMPRESS_EXT)
+endif
+ if [ '$$(ALL_FILESYSTEMS)' != '/' ]; then \
+ $(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
+ $(4)/$$(TARGET_DIR_WARNING_FILE); \
+ fi
+endef
+
+# Generate rules for one sub-filesystem target
+# $(1) Filesystem image type
+# $(2) Uppercase version of $(1)
+# $(3) Directory for which to generate the filesystem image
+define GEN_SUBFS_RULES
+$(call GEN_SUBFS_RULES_TAGGED,$(1),$(2),$(3),$(SUBFS_DIR)/root$(call SUBFS_TAG,$(3))fs-$(1))
+endef
+
+# Generate rules for a list of sub-filesystem targets
+# $(1) Filesystem image type
+# $(2) Uppercase version of $(1)
+# $(3) Directories at the top of filesystems
+define GEN_SUBFS_RULES_LIST
+$(foreach fs,$(3),$(call GEN_SUBFS_RULES,$(1),$(2),$(fs)))
+endef
+
+# List of all of the generated images for a given type
+# $(1) Image type
+# $(2) List of all of the filesystems for this type
+define SUBFS_ALL
+$(foreach subfs,$(2),$$(BINARIES_DIR)/root$(call SUBFS_TAG,$(subfs))fs.$(1))
+endef
+
+# Define targets for building a filesystem image of a particular type
+# $(1) Filesystem image type
+# $(2) Uppercased $(1)
+# $(3) Directories to build
define ROOTFS_TARGET_INTERNAL
# extra deps
@@ -64,47 +208,85 @@ ROOTFS_$(2)_COMPRESS_EXT = .xz
ROOTFS_$(2)_COMPRESS_CMD = $$(XZ) -9 -C crc32 -c
endif
-$$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES)
- @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
+FAKEROOT_$(2)_ENV := $$(SUBFS_DIR)/fakeroot-env-$(1)
+
+$(SUBFS_DIR)/root-all-$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES) \
+ $(SUBFS_DIR)
+ @$$(call MESSAGE,"Generating $(1) filesystem image/images")
$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),$$(call $$(hook))$$(sep))
rm -f $$(FAKEROOT_SCRIPT)
- rm -f $$(TARGET_DIR_WARNING_FILE)
+ rm -f $(TARGET_DIR)/$$(TARGET_DIR_WARNING_FILE)
rm -f $(USERS_TABLE)
- echo "chown -R 0:0 $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
+ # Create the device tables
ifneq ($$(ROOTFS_DEVICE_TABLES),)
- cat $$(ROOTFS_DEVICE_TABLES) > $$(FULL_DEVICE_TABLE)
+ cat $$(ROOTFS_DEVICE_TABLES) >> $$(FULL_DEVICE_TABLE)
ifeq ($$(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
- printf '$$(subst $$(sep),\n,$$(PACKAGES_DEVICES_TABLE))' >> $$(FULL_DEVICE_TABLE)
+ printf '$$(subst $$(sep),\n,$$(PACKAGES_DEVICES_TABLE))' \
+ >> $$(FULL_DEVICE_TABLE)
endif
- printf '$$(subst $$(sep),\n,$$(PACKAGES_PERMISSIONS_TABLE))' >> $$(FULL_DEVICE_TABLE)
- echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
+ printf '$$(subst $$(sep),\n,$$(PACKAGES_PERMISSIONS_TABLE))' \
+ >> $$(FULL_DEVICE_TABLE)
endif
+ # Create the users table
ifneq ($$(ROOTFS_USERS_TABLES),)
cat $$(ROOTFS_USERS_TABLES) >> $(USERS_TABLE)
endif
printf '$(subst $(sep),\n,$(PACKAGES_USERS))' >> $(USERS_TABLE)
- PATH=$(BR_PATH) $(TOPDIR)/support/scripts/mkusers $(USERS_TABLE) $(TARGET_DIR) >> $(FAKEROOT_SCRIPT)
- echo "$$(ROOTFS_$(2)_CMD)" >> $$(FAKEROOT_SCRIPT)
- chmod a+x $$(FAKEROOT_SCRIPT)
- PATH=$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT)
- $(INSTALL) -m 0644 support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE)
- -@rm -f $$(FAKEROOT_SCRIPT) $$(FULL_DEVICE_TABLE)
-ifneq ($$(ROOTFS_$(2)_COMPRESS_CMD),)
- $$(ROOTFS_$(2)_COMPRESS_CMD) $$@ > $$@$$(ROOTFS_$(2)_COMPRESS_EXT)
+ # Create the script to be run under fakeroot
+ echo "set -e" >> $(FAKEROOT_SCRIPT)
+ echo "chown -R 0:0 $$(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
+ifneq ($$(ROOTFS_DEVICE_TABLES),)
+ echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE)" \
+ "$$(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
endif
+ PATH=$(BR_PATH) $(TOPDIR)/support/scripts/mkusers $(USERS_TABLE) \
+ $(TARGET_DIR) >> $(FAKEROOT_SCRIPT)
+ chmod a+x $$(FAKEROOT_SCRIPT)
+ PATH=$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -s \
+ $$(FAKEROOT_$(2)_ENV) -- $$(FAKEROOT_SCRIPT)
rootfs-$(1)-show-depends:
@echo $$(ROOTFS_$(2)_DEPENDENCIES)
-rootfs-$(1): $$(BINARIES_DIR)/rootfs.$(1) $$(ROOTFS_$(2)_POST_TARGETS)
+$(call GEN_SUBFS_RULES_LIST,$(1),$(2),$(3))
+
+fs-finish-$(1):
+ $(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
+ $(TARGET_DIR)/$$(TARGET_DIR_WARNING_FILE)
+ -@rm -f $$(FAKEROOT_SCRIPT) $$(FULL_DEVICE_TABLE)
+
+rootfs-$(1): $(call SUBFS_ALL,$(1),$(3)) fs-finish-$(1) \
+ $$(ROOTFS_$(2)_POST_TARGETS)
ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
TARGETS_ROOTFS += rootfs-$(1)
endif
endef
-define ROOTFS_TARGET
-$(call ROOTFS_TARGET_INTERNAL,$(1),$(call UPPERCASE,$(1)))
+# This is the directory in which all of the non-final work produces are
+# placed
+$(SUBFS_DIR):
+ mkdir -p $(SUBFS_DIR)
+
+# Make sure all filesystems specified start with / and do not end with /
+# $(1) Filesystem image type
+# $(2) Filesystem directory names
+define VALIDATE_FILESYSTEM_NAMES
+$(if $(2),
+$(if $(filter-out /%,$(2)),
+$(error All $(1) filesystem directory names ($(2))
+must start with slash character))
+$(if $(filter %/,$(filter-out /,$(2))),
+$(error No $(1) filesystem directory names ($(2))
+may end with slash character)))
+endef
+
+# Make the root filesystem image and all sub-filesystems of a given type
+# $(1) Filesystem image type
+# $(2) List of directories for which filesystem images are to be made
+define ROOTFS_TARGETS
+$(call VALIDATE_FILESYSTEM_NAMES,$(1),$(call qstrip,$(2)))
+$(if $(2),$(call ROOTFS_TARGET_INTERNAL,$(1),$(call UPPERCASE,$(1)),$(sort $(call qstrip,$(2)))))
endef
-include $(sort $(wildcard fs/*/*.mk))
+include $(sort $(wildcard fs/*/*-post.mk))
@@ -5,6 +5,18 @@ config BR2_TARGET_ROOTFS_CPIO
used for an initial RAM filesystem that is passed to the kernel
by the bootloader.
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_CPIO_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with cpio"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_CPIO
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
+
if BR2_TARGET_ROOTFS_CPIO
choice
new file mode 100644
@@ -0,0 +1,43 @@
+################################################################################
+#
+# cpio to archive target filesystem
+#
+################################################################################
+
+ifeq ($(BR2_ROOTFS_DEVICE_CREATION_STATIC),y)
+
+define ROOTFS_CPIO_ADD_INIT
+ if [ ! -e $(TARGET_DIR)/init ]; then \
+ ln -sf sbin/init $(TARGET_DIR)/init; \
+ fi
+endef
+
+else
+# devtmpfs does not get automounted when initramfs is used.
+# Add a pre-init script to mount it before running init
+define ROOTFS_CPIO_ADD_INIT
+ if [ ! -e $(TARGET_DIR)/init ]; then \
+ $(INSTALL) -m 0755 fs/cpio/init $(TARGET_DIR)/init; \
+ fi
+endef
+
+PACKAGES_PERMISSIONS_TABLE += /dev/console c 622 0 0 5 1 - - -$(sep)
+
+endif # BR2_ROOTFS_DEVICE_CREATION_STATIC
+
+ROOTFS_CPIO_PRE_GEN_HOOKS += ROOTFS_CPIO_ADD_INIT
+
+define ROOTFS_CPIO_CMD
+ cd $(1) && find . | cpio --quiet -o -H newc > $@
+endef
+
+$(BINARIES_DIR)/rootfs.cpio.uboot: $(BINARIES_DIR)/rootfs.cpio host-uboot-tools
+ $(MKIMAGE) -A $(MKIMAGE_ARCH) -T ramdisk \
+ -C none -d $<$(ROOTFS_CPIO_COMPRESS_EXT) $@
+
+ifeq ($(BR2_TARGET_ROOTFS_CPIO_UIMAGE),y)
+ROOTFS_CPIO_POST_TARGETS += $(BINARIES_DIR)/rootfs.cpio.uboot
+endif
+
+$(info $(call ROOTFS_TARGETS,cpio,$(CPIO_SUBFS)))
+$(eval $(call ROOTFS_TARGETS,cpio,$(CPIO_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define cpio filesystems
+#
+################################################################################
+
+CPIO_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_CPIO_SUB_FILESYSTEMS),/)
@@ -4,3 +4,15 @@ config BR2_TARGET_ROOTFS_CRAMFS
Build a cramfs root filesystem
http://sourceforge.net/projects/cramfs/
+
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_CRAMFS_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with cramfs"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_CRAMFS
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
new file mode 100644
@@ -0,0 +1,19 @@
+################################################################################
+#
+# Build the cramfs root filesystem image
+#
+################################################################################
+
+ifeq ($(BR2_ENDIAN),"BIG")
+CRAMFS_OPTS = -b
+else
+CRAMFS_OPTS = -l
+endif
+
+define ROOTFS_CRAMFS_CMD
+ $(HOST_DIR)/usr/bin/mkcramfs $(CRAMFS_OPTS) $(1) $@
+endef
+
+ROOTFS_CRAMFS_DEPENDENCIES = host-cramfs
+
+$(eval $(call ROOTFS_TARGETS,cramfs,$(CRAMFS_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define cramfs filesystems
+#
+################################################################################
+
+CRAMFS_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_CRAMFS_SUB_FILESYSTEMS),/)
@@ -5,6 +5,18 @@ config BR2_TARGET_ROOTFS_EXT2
help
Build an ext2/3/4 root filesystem
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_EXT2_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with ext2/3/4"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_EXT2
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
+
if BR2_TARGET_ROOTFS_EXT2
config BR2_TARGET_ROOTFS_EXT2_2
new file mode 100644
@@ -0,0 +1,37 @@
+################################################################################
+#
+# Build the ext2 root filesystem image
+#
+################################################################################
+
+EXT2_OPTS :=
+
+ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
+EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)
+endif
+
+ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0)
+EXT2_OPTS += -N $(BR2_TARGET_ROOTFS_EXT2_INODES)
+endif
+
+ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0)
+EXT2_OPTS += -m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)
+endif
+
+ROOTFS_EXT2_DEPENDENCIES = host-genext2fs host-e2fsprogs
+
+EXT2_ENV = GEN=$(BR2_TARGET_ROOTFS_EXT2_GEN)
+EXT2_ENV += REV=$(BR2_TARGET_ROOTFS_EXT2_REV)
+
+define ROOTFS_EXT2_CMD
+ PATH=$(BR_PATH) $(EXT2_ENV) fs/ext2/genext2fs.sh -d $(1) $(EXT2_OPTS) $@
+endef
+
+rootfs-ext2-symlink:
+ ln -sf rootfs.ext2$(ROOTFS_EXT2_COMPRESS_EXT) $(BINARIES_DIR)/rootfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN)$(ROOTFS_EXT2_COMPRESS_EXT)
+
+ifneq ($(BR2_TARGET_ROOTFS_EXT2_GEN),2)
+ROOTFS_EXT2_POST_TARGETS += rootfs-ext2-symlink
+endif
+
+$(eval $(call ROOTFS_TARGETS,ext2,$(EXT2_SUBFS)))
new file mode 100644
@@ -0,0 +1,6 @@
+################################################################################
+#
+# Define ext2/3/4 filesystems
+#
+################################################################################
+EXT2_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_EXT2_SUB_FILESYSTEMS),/)
new file mode 100644
@@ -0,0 +1,22 @@
+################################################################################
+#
+# Build a kernel with an integrated initial ramdisk
+# filesystem based on cpio.
+#
+################################################################################
+
+ROOTFS_INITRAMFS_DEPENDENCIES += rootfs-cpio
+
+ROOTFS_INITRAMFS_POST_TARGETS += linux26-rebuild-with-initramfs
+
+
+# The generic fs infrastructure isn't very useful here.
+
+rootfs-initramfs: $(ROOTFS_INITRAMFS_DEPENDENCIES) $(ROOTFS_INITRAMFS_POST_TARGETS)
+
+rootfs-initramfs-show-depends:
+ @echo $(ROOTFS_INITRAMFS_DEPENDENCIES)
+
+ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
+TARGETS_ROOTFS += rootfs-initramfs
+endif
new file mode 100644
@@ -0,0 +1,5 @@
+################################################################################
+#
+# Define initramfs filesystems, which doesn't really fit in quite right
+#
+################################################################################
new file mode 100644
@@ -0,0 +1,51 @@
+################################################################################
+#
+# Build the iso96600 root filesystem image
+#
+# Cannot be converted to the ROOTFS_TARGET infrastructure, because of
+# the temporary construction in ISO9660_TARGET_DIR.
+#
+################################################################################
+
+ISO9660_TARGET_DIR = $(BUILD_DIR)/iso9660
+ISO9660_BOOT_MENU := $(call qstrip,$(BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU))
+
+$(BINARIES_DIR)/rootfs.iso9660: host-cdrkit host-fakeroot linux rootfs-cpio grub
+ @$(call MESSAGE,"Generating root filesystem image rootfs.iso9660")
+ mkdir -p $(ISO9660_TARGET_DIR)
+ mkdir -p $(ISO9660_TARGET_DIR)/boot/grub
+ cp $(GRUB_DIR)/stage2/stage2_eltorito $(ISO9660_TARGET_DIR)/boot/grub/
+ cp $(ISO9660_BOOT_MENU) $(ISO9660_TARGET_DIR)/boot/grub/menu.lst
+ifeq ($(BR2_TARGET_GRUB_SPLASH),)
+ $(SED) '/^splashimage/d' $(ISO9660_TARGET_DIR)/boot/grub/menu.lst
+else
+ cp boot/grub/splash.xpm.gz $(ISO9660_TARGET_DIR)/
+endif
+ cp $(LINUX_IMAGE_PATH) $(ISO9660_TARGET_DIR)/kernel
+ifeq ($(BR2_TARGET_ROOTFS_INITRAMFS),y)
+ $(SED) '/initrd/d' $(ISO9660_TARGET_DIR)/boot/grub/menu.lst
+else
+ cp $(BINARIES_DIR)/rootfs.cpio$(ROOTFS_CPIO_COMPRESS_EXT) $(ISO9660_TARGET_DIR)/initrd
+endif
+ # Use fakeroot to pretend all target binaries are owned by root
+ rm -f $(FAKEROOT_SCRIPT)
+ echo "chown -R 0:0 $(ISO9660_TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
+ # Use fakeroot so mkisofs believes the previous fakery
+ echo "$(HOST_DIR)/usr/bin/genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot " \
+ "-boot-load-size 4 -boot-info-table -o $@ $(ISO9660_TARGET_DIR)" \
+ >> $(FAKEROOT_SCRIPT)
+ chmod a+x $(FAKEROOT_SCRIPT)
+ $(HOST_DIR)/usr/bin/fakeroot -- $(FAKEROOT_SCRIPT)
+ -@rm -f $(FAKEROOT_SCRIPT)
+ -@rm -rf $(ISO9660_TARGET_DIR)
+
+rootfs-iso9660: $(BINARIES_DIR)/rootfs.iso9660
+
+################################################################################
+#
+# Toplevel Makefile options
+#
+################################################################################
+ifeq ($(BR2_TARGET_ROOTFS_ISO9660),y)
+TARGETS_ROOTFS += rootfs-iso9660
+endif
new file mode 100644
@@ -0,0 +1,9 @@
+################################################################################
+#
+# Build ISO9660 filesystems
+#
+# Cannot be converted to the ROOTFS_TARGET infrastructure, because of
+# the temporary construction in ISO9660_TARGET_DIR.
+#
+################################################################################
+
@@ -3,6 +3,18 @@ config BR2_TARGET_ROOTFS_JFFS2
help
Build a jffs2 root filesystem
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_JFFS2_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with JFFS2"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_JFFS2
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
+
if BR2_TARGET_ROOTFS_JFFS2
choice
new file mode 100644
@@ -0,0 +1,49 @@
+################################################################################
+#
+# Build the jffs2 root filesystem image
+#
+################################################################################
+
+JFFS2_OPTS := -e $(BR2_TARGET_ROOTFS_JFFS2_EBSIZE)
+SUMTOOL_OPTS := $(JFFS2_OPTS)
+
+ifeq ($(BR2_TARGET_ROOTFS_JFFS2_PAD),y)
+ifneq ($(strip $(BR2_TARGET_ROOTFS_JFFS2_PADSIZE)),0x0)
+JFFS2_OPTS += --pad=$(strip $(BR2_TARGET_ROOTFS_JFFS2_PADSIZE))
+else
+JFFS2_OPTS += -p
+endif
+SUMTOOL_OPTS += -p
+endif
+
+ifeq ($(BR2_TARGET_ROOTFS_JFFS2_LE),y)
+JFFS2_OPTS += -l
+SUMTOOL_OPTS += -l
+endif
+
+ifeq ($(BR2_TARGET_ROOTFS_JFFS2_BE),y)
+JFFS2_OPTS += -b
+SUMTOOL_OPTS += -b
+endif
+
+JFFS2_OPTS += -s $(BR2_TARGET_ROOTFS_JFFS2_PAGESIZE)
+ifeq ($(BR2_TARGET_ROOTFS_JFFS2_NOCLEANMARKER),y)
+JFFS2_OPTS += -n
+SUMTOOL_OPTS += -n
+endif
+
+ROOTFS_JFFS2_DEPENDENCIES = host-mtd
+
+ifneq ($(BR2_TARGET_ROOTFS_JFFS2_SUMMARY),)
+define ROOTFS_JFFS2_CMD
+ $(MKFS_JFFS2) $(JFFS2_OPTS) -d $(1) -o $@.nosummary && \
+ $(SUMTOOL) $(SUMTOOL_OPTS) -i $@.nosummary -o $@ && \
+ rm $@.nosummary
+endef
+else
+define ROOTFS_JFFS2_CMD
+ $(MKFS_JFFS2) $(JFFS2_OPTS) -d $(TARGET_DIR) -o $@
+endef
+endif
+
+$(eval $(call ROOTFS_TARGETS,jffs2,$(JFFS2_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define JFFS2 filesystems
+#
+################################################################################
+
+JFFS2_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_JFFS2_SUB_FILESYSTEMS),/)
@@ -2,3 +2,15 @@ config BR2_TARGET_ROOTFS_ROMFS
bool "romfs root filesystem"
help
Build a romfs image of the root filesystem.
+
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_ROMFS_SUB_FILESYSTEMS
+ string "Sub-filesystems to build as a ROMFS filesystem"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_ROMFS
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
new file mode 100644
@@ -0,0 +1,15 @@
+################################################################################
+#
+# Build the romfs root filesystem image
+#
+################################################################################
+
+ROMFS_TARGET=$(IMAGE).romfs
+
+ROOTFS_ROMFS_DEPENDENCIES = host-genromfs
+
+define ROOTFS_ROMFS_CMD
+ $(HOST_DIR)/usr/bin/genromfs -d $(1) -f $@
+endef
+
+$(eval $(call ROOTFS_TARGETS,romfs,$(ROMFS_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define romfs filesystems
+#
+################################################################################
+
+ROMFS_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_ROMFS_SUB_FILESYSTEMS),/)
@@ -3,6 +3,18 @@ config BR2_TARGET_ROOTFS_SQUASHFS
help
Build a squashfs root filesystem
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_SQUASHFS_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with squashfs"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_SQUASHFS
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
+
if BR2_TARGET_ROOTFS_SQUASHFS
choice
new file mode 100644
@@ -0,0 +1,29 @@
+################################################################################
+#
+# Build the squashfs root filesystem image
+#
+################################################################################
+
+ROOTFS_SQUASHFS_DEPENDENCIES = host-squashfs
+
+ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS4_LZO),y)
+ROOTFS_SQUASHFS_ARGS += -comp lzo
+else
+ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS4_LZMA),y)
+ROOTFS_SQUASHFS_ARGS += -comp lzma
+else
+ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS4_XZ),y)
+ROOTFS_SQUASHFS_ARGS += -comp xz
+else
+ROOTFS_SQUASHFS_ARGS += -comp gzip
+endif
+endif
+endif
+
+define ROOTFS_SQUASHFS_CMD
+ $(HOST_DIR)/usr/bin/mksquashfs $(1) $@ -noappend \
+ $(ROOTFS_SQUASHFS_ARGS) && \
+ chmod 0644 $@
+endef
+
+$(eval $(call ROOTFS_TARGETS,squashfs,$(SQUASHFS_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define squashfs filesystems
+#
+################################################################################
+
+SQUASHFS_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_SQUASHFS_SUB_FILESYSTEMS),/)
@@ -4,6 +4,18 @@ config BR2_TARGET_ROOTFS_TAR
help
Build a tar archive of the root filesystem
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_TAR_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with tar"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_TAR
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
+
choice
prompt "Compression method"
default BR2_TARGET_ROOTFS_TAR_NONE
new file mode 100644
@@ -0,0 +1,13 @@
+################################################################################
+#
+# tar to archive target filesystem
+#
+################################################################################
+
+TAR_OPTS := $(BR2_TARGET_ROOTFS_TAR_OPTIONS)
+
+define ROOTFS_TAR_CMD
+ tar -c$(TAR_OPTS)f $@ -C $(1) .
+endef
+
+$(eval $(call ROOTFS_TARGETS,tar,$(TAR_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define tar-archived filesystems
+#
+################################################################################
+
+TAR_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_TAR_SUB_FILESYSTEMS),/)
@@ -3,6 +3,18 @@ config BR2_TARGET_ROOTFS_UBIFS
help
Build a ubifs root filesystem
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_UBIFS_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with ubifs"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_UBIFS
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
+
if BR2_TARGET_ROOTFS_UBIFS
config BR2_TARGET_ROOTFS_UBIFS_LEBSIZE
new file mode 100644
@@ -0,0 +1,30 @@
+################################################################################
+#
+# Embed the ubifs image into an ubi image
+#
+################################################################################
+
+UBI_UBINIZE_OPTS := -m $(BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE)
+UBI_UBINIZE_OPTS += -p $(BR2_TARGET_ROOTFS_UBI_PEBSIZE)
+ifneq ($(BR2_TARGET_ROOTFS_UBI_SUBSIZE),0)
+UBI_UBINIZE_OPTS += -s $(BR2_TARGET_ROOTFS_UBI_SUBSIZE)
+endif
+
+UBI_UBINIZE_OPTS += $(call qstrip,$(BR2_TARGET_ROOTFS_UBI_OPTS))
+
+ROOTFS_UBI_DEPENDENCIES = rootfs-ubifs
+
+ifeq ($(BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG),y)
+UBINIZE_CONFIG_FILE_PATH = $(call qstrip,$(BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE))
+else
+UBINIZE_CONFIG_FILE_PATH = fs/ubifs/ubinize.cfg
+endif
+
+define ROOTFS_UBI_CMD
+ $(INSTALL) -m 0644 $(UBINIZE_CONFIG_FILE_PATH) $(BUILD_DIR)/ubinize.cfg ;\
+ $(SED) 's;BR2_ROOTFS_UBIFS_PATH;$@fs;' $(BUILD_DIR)/ubinize.cfg ;\
+ $(HOST_DIR)/usr/sbin/ubinize -o $@ $(UBI_UBINIZE_OPTS) $(BUILD_DIR)/ubinize.cfg ;\
+ rm $(BUILD_DIR)/ubinize.cfg
+endef
+
+$(eval $(call ROOTFS_TARGETS,ubi,$(UBI_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define embedded UBI filesystems
+#
+################################################################################
+
+UBI_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_UBI_SUB_FILESYSTEMS),/)
new file mode 100644
@@ -0,0 +1,27 @@
+################################################################################
+#
+# Build the ubifs root filesystem image
+#
+################################################################################
+
+UBIFS_OPTS := -e $(BR2_TARGET_ROOTFS_UBIFS_LEBSIZE) -c $(BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT) -m $(BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE)
+
+ifeq ($(BR2_TARGET_ROOTFS_UBIFS_RT_ZLIB),y)
+UBIFS_OPTS += -x zlib
+endif
+ifeq ($(BR2_TARGET_ROOTFS_UBIFS_RT_LZO),y)
+UBIFS_OPTS += -x lzo
+endif
+ifeq ($(BR2_TARGET_ROOTFS_UBIFS_RT_NONE),y)
+UBIFS_OPTS += -x none
+endif
+
+UBIFS_OPTS += $(call qstrip,$(BR2_TARGET_ROOTFS_UBIFS_OPTS))
+
+ROOTFS_UBIFS_DEPENDENCIES = host-mtd
+
+define ROOTFS_UBIFS_CMD
+ $(HOST_DIR)/usr/sbin/mkfs.ubifs -d $(1) $(UBIFS_OPTS) -o $@
+endef
+
+$(eval $(call ROOTFS_TARGETS,ubifs,$(UBIFS_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define ubifs filesystems
+#
+################################################################################
+
+UBIFS_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_UBIFS_SUB_FILESYSTEMS),/)
@@ -2,3 +2,15 @@ config BR2_TARGET_ROOTFS_YAFFS2
bool "yaffs2 root filesystem"
help
Build a yaffs2 root filesystem
+
+if BR2_BUILD_SUB_FILESYSTEMS
+config BR2_YAFFS2_SUB_FILESYSTEMS
+ string "Sub-filesystems to build with YAFFS2"
+ default "/"
+ depends on BR2_TARGET_ROOTFS_YAFFS2
+ help
+ Provide a space-separated list of the root directories of all
+ filesystems. For example to build a root filesystem with a
+ separate /usr filesystem, enter:
+ / /usr
+endif # BR2_BUILD_SUB_FILESYSTEMS
new file mode 100644
@@ -0,0 +1,13 @@
+################################################################################
+#
+# Build the yaffs2 root filesystem image
+#
+################################################################################
+
+ROOTFS_YAFFS2_DEPENDENCIES = host-yaffs2utils
+
+define ROOTFS_YAFFS2_CMD
+ $(HOST_DIR)/usr/bin/mkyaffs2 --all-root $(1) $@
+endef
+
+$(eval $(call ROOTFS_TARGETS,yaffs2,$(YAFFS2_SUBFS)))
new file mode 100644
@@ -0,0 +1,7 @@
+################################################################################
+#
+# Define YAFFS2 filesystems
+#
+################################################################################
+
+YAFFS2_SUBFS = $(if $(BR2_BUILD_SUB_FILESYSTEMS),$(BR2_YAFFS2_SUB_FILESYSTEMS),/)