1################################################################################
2#
3# Build the ext2 root filesystem image
4#
5################################################################################
6
7ROOTFS_EXT2_SIZE = $(call qstrip,$(BR2_TARGET_ROOTFS_EXT2_SIZE))
8ifeq ($(BR2_TARGET_ROOTFS_EXT2)-$(ROOTFS_EXT2_SIZE),y-)
9$(error BR2_TARGET_ROOTFS_EXT2_SIZE cannot be empty)
10endif
11
12ROOTFS_EXT2_MKFS_OPTS = $(call qstrip,$(BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS))
13
14# qstrip results in stripping consecutive spaces into a single one. So the
15# variable is not qstrip-ed to preserve the integrity of the string value.
16ROOTFS_EXT2_LABEL = $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_LABEL))
17#" Syntax highlighting... :-/ )
18
19ROOTFS_EXT2_OPTS = \
20	-d $(TARGET_DIR) \
21	-r $(BR2_TARGET_ROOTFS_EXT2_REV) \
22	-N $(BR2_TARGET_ROOTFS_EXT2_INODES) \
23	-m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) \
24	-L "$(ROOTFS_EXT2_LABEL)" \
25	-I $(BR2_TARGET_ROOTFS_EXT2_INODE_SIZE) \
26	$(ROOTFS_EXT2_MKFS_OPTS)
27
28ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs
29
30define ROOTFS_EXT2_CMD
31	rm -f $@
32	$(HOST_DIR)/sbin/mkfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN) $(ROOTFS_EXT2_OPTS) $@ \
33		"$(ROOTFS_EXT2_SIZE)" \
34	|| { ret=$$?; \
35	     echo "*** Maybe you need to increase the filesystem size (BR2_TARGET_ROOTFS_EXT2_SIZE)" 1>&2; \
36	     exit $$ret; \
37	}
38endef
39
40ifneq ($(BR2_TARGET_ROOTFS_EXT2_GEN),2)
41define ROOTFS_EXT2_SYMLINK
42	ln -sf rootfs.ext2$(ROOTFS_EXT2_COMPRESS_EXT) $(BINARIES_DIR)/rootfs.ext$(BR2_TARGET_ROOTFS_EXT2_GEN)$(ROOTFS_EXT2_COMPRESS_EXT)
43endef
44ROOTFS_EXT2_POST_GEN_HOOKS += ROOTFS_EXT2_SYMLINK
45endif
46
47$(eval $(rootfs))
48