disable reserved blocks for checkpointing in yaffs2 on rb532 and adm5120
[openwrt.git] / include / image.mk
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(INCLUDE_DIR)/prereq.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 include $(INCLUDE_DIR)/host.mk
11 KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
12
13 ifneq ($(CONFIG_BIG_ENDIAN),y)
14 JFFS2OPTS := --pad --little-endian --squash
15 SQUASHFS_OPTS := -le
16 else
17 JFFS2OPTS := --pad --big-endian --squash
18 SQUASHFS_OPTS := -be
19 endif
20
21 JFFS2_BLOCKSIZE ?= 64k 128k
22
23 define add_jffs2_mark
24 echo -ne '\xde\xad\xc0\xde' >> $(1)
25 endef
26
27 # pad to 64k and add jffs2 end-of-filesystem mark
28 # do this twice to make sure that this works with 128k blocksize as well
29 define prepare_generic_squashfs
30 dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
31 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
32 dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
33 $(call add_jffs2_mark,$(1))
34 endef
35
36 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
37 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
38 define Image/mkfs/jffs2/sub
39 @# FIXME: removing this line will cause the foreach loop below to execute the next statement only on the first iteration, don't ask why ;)
40 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(BUILD_DIR)/root
41 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
42 $(call Image/Build,jffs2-$(1))
43 endef
44 define Image/mkfs/jffs2
45 rm -rf $(BUILD_DIR)/root/jffs
46 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
47 endef
48 endif
49
50 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
51 define Image/mkfs/squashfs
52 @mkdir -p $(BUILD_DIR)/root/jffs
53 $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
54 $(call Image/Build,squashfs)
55 endef
56 endif
57
58 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
59 define Image/mkfs/tgz
60 $(TAR) -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
61 endef
62 endif
63 else
64 define Image/BuildKernel
65 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
66 $(call Image/Build/Initramfs)
67 endef
68 endif
69
70
71 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
72 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
73
74 define Image/mkfs/ext2
75 $(STAGING_DIR)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
76 $(call Image/Build,ext2)
77 endef
78 endif
79
80
81 define Image/mkfs/prepare/default
82 find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' | $(XARGS) chmod 0644
83 find $(BUILD_DIR)/root -type f -perm +0100 | $(XARGS) chmod 0755
84 find $(BUILD_DIR)/root -type d | $(XARGS) chmod 0755
85 mkdir -p $(BUILD_DIR)/root/tmp
86 chmod 0777 $(BUILD_DIR)/root/tmp
87 endef
88
89 define Image/mkfs/prepare
90 $(call Image/mkfs/prepare/default)
91 endef
92
93 define BuildImage
94 download:
95 prepare:
96 ifneq ($(IB),1)
97 compile: compile-targets
98 $(call Build/Compile)
99 else
100 compile:
101 endif
102
103 ifneq ($(IB),1)
104 install: compile install-targets
105 $(call Image/Prepare)
106 $(call Image/mkfs/prepare)
107 $(call Image/BuildKernel)
108 $(call Image/mkfs/jffs2)
109 $(call Image/mkfs/squashfs)
110 $(call Image/mkfs/tgz)
111 $(call Image/mkfs/ext2)
112 else
113 install: compile install-targets
114 $(call Image/BuildKernel)
115 $(call Image/mkfs/jffs2)
116 $(call Image/mkfs/squashfs)
117 $(call Image/mkfs/tgz)
118 $(call Image/mkfs/ext2)
119 endif
120
121 ifneq ($(IB),1)
122 clean: clean-targets
123 $(call Build/Clean)
124 else
125 clean:
126 endif
127
128 compile-targets:
129 install-targets:
130 clean-targets:
131 endef
132
133
This page took 0.048764 seconds and 5 git commands to generate.