[at91] Add support for FOXGM carrier board
[openwrt.git] / include / image.mk
1 #
2 # Copyright (C) 2006-2010 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 override TARGET_BUILD=
9 include $(INCLUDE_DIR)/prereq.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/host.mk
12
13 .NOTPARALLEL:
14 override MAKEFLAGS=
15 override MAKE:=$(SUBMAKE)
16 KDIR=$(KERNEL_BUILD_DIR)
17
18 IMG_PREFIX:=openwrt-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
19
20 ifneq ($(CONFIG_BIG_ENDIAN),)
21 JFFS2OPTS := --pad --big-endian --squash -v
22 SQUASHFS_OPTS := -be
23 else
24 JFFS2OPTS := --pad --little-endian --squash -v
25 SQUASHFS_OPTS := -le
26 endif
27
28 ifeq ($(CONFIG_JFFS2_RTIME),y)
29 JFFS2OPTS += -X rtime
30 endif
31 ifeq ($(CONFIG_JFFS2_ZLIB),y)
32 JFFS2OPTS += -X zlib
33 endif
34 ifeq ($(CONFIG_JFFS2_LZMA),y)
35 JFFS2OPTS += -X lzma --compression-mode=size
36 endif
37 ifneq ($(CONFIG_JFFS2_RTIME),y)
38 JFFS2OPTS += -x rtime
39 endif
40 ifneq ($(CONFIG_JFFS2_ZLIB),y)
41 JFFS2OPTS += -x zlib
42 endif
43 ifneq ($(CONFIG_JFFS2_LZMA),y)
44 JFFS2OPTS += -x lzma
45 endif
46
47 ifneq ($(CONFIG_LINUX_2_6_25),)
48 USE_SQUASHFS3 := y
49 endif
50
51 ifneq ($(USE_SQUASHFS3),)
52 MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs-lzma
53 else
54 MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs4
55 SQUASHFS_OPTS := -comp lzma -processors 1
56 endif
57
58 JFFS2_BLOCKSIZE ?= 64k 128k
59
60 define add_jffs2_mark
61 echo -ne '\xde\xad\xc0\xde' >> $(1)
62 endef
63
64 # pad to 4k, 8k, 64k, 128k and add jffs2 end-of-filesystem mark
65 define prepare_generic_squashfs
66 dd if=$(1) of=$(KDIR)/tmpfile.0 bs=4k conv=sync
67 $(call add_jffs2_mark,$(KDIR)/tmpfile.0)
68 dd if=$(KDIR)/tmpfile.0 of=$(KDIR)/tmpfile.1 bs=4k conv=sync
69 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
70 dd if=$(KDIR)/tmpfile.1 of=$(KDIR)/tmpfile.2 bs=64k conv=sync
71 $(call add_jffs2_mark,$(KDIR)/tmpfile.2)
72 dd if=$(KDIR)/tmpfile.2 of=$(1) bs=64k conv=sync
73 $(call add_jffs2_mark,$(1))
74 rm -f $(KDIR)/tmpfile.*
75 endef
76
77
78 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
79
80 define Image/BuildKernel
81 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.elf
82 $(call Image/Build/Initramfs)
83 endef
84
85 else
86
87 ifneq ($(CONFIG_TARGET_ROOTFS_JFFS2),)
88 define Image/mkfs/jffs2/sub
89 # FIXME: removing this line will cause strange behaviour in the foreach loop below
90 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
91 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
92 $(call Image/Build,jffs2-$(1))
93 endef
94 define Image/mkfs/jffs2
95 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
96 endef
97 endif
98
99 ifneq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),)
100 define Image/mkfs/squashfs
101 @mkdir -p $(TARGET_DIR)/overlay
102 $(MKSQUASHFS_CMD) $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
103 $(call Image/Build,squashfs)
104 endef
105 endif
106
107 ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
108 define Image/mkfs/ubifs
109 $(CP) ./ubinize.cfg $(KDIR)
110 $(STAGING_DIR_HOST)/bin/mkfs.ubifs $(UBIFS_OPTS) -o $(KDIR)/root.ubifs -d $(TARGET_DIR)
111 (cd $(KDIR); \
112 $(STAGING_DIR_HOST)/bin/ubinize $(UBINIZE_OPTS) -o $(KDIR)/root.ubi ubinize.cfg)
113 $(call Image/Build,ubi)
114 endef
115 endif
116
117 endif
118
119 ifneq ($(CONFIG_TARGET_ROOTFS_CPIOGZ),)
120 define Image/mkfs/cpiogz
121 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz )
122 endef
123 endif
124
125 ifneq ($(CONFIG_TARGET_ROOTFS_TARGZ),)
126 define Image/mkfs/targz
127 $(TAR) -zcf $(BIN_DIR)/$(IMG_PREFIX)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
128 endef
129 endif
130
131 ifneq ($(CONFIG_TARGET_ROOTFS_EXT2FS),)
132 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024)))
133
134 define Image/mkfs/ext2
135 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -N $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext2
136 $(call Image/Build,ext2)
137 endef
138 endif
139
140 ifneq ($(CONFIG_TARGET_ROOTFS_ISO),)
141 define Image/mkfs/iso
142 $(call Image/Build,iso)
143 endef
144 endif
145
146
147 define Image/mkfs/prepare/default
148 - $(FIND) $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' -print0 | $(XARGS) -0 chmod 0644
149 - $(FIND) $(TARGET_DIR) -type f -perm +0100 -print0 | $(XARGS) -0 chmod 0755
150 - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod 0755
151 $(INSTALL_DIR) $(TARGET_DIR)/tmp
152 chmod 0777 $(TARGET_DIR)/tmp
153 endef
154
155 define Image/mkfs/prepare
156 $(call Image/mkfs/prepare/default)
157 endef
158
159
160 define Image/Checksum
161 ( cd ${BIN_DIR} ; \
162 $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | sort | xargs \
163 md5sum --binary > md5sums \
164 )
165 endef
166
167
168 define BuildImage
169
170 download:
171 prepare:
172
173 ifeq ($(IB),)
174 compile: compile-targets FORCE
175 $(call Build/Compile)
176 else
177 compile:
178 endif
179
180 ifeq ($(IB),)
181 install: compile install-targets FORCE
182 $(call Image/Prepare)
183 $(call Image/mkfs/prepare)
184 $(call Image/BuildKernel)
185 $(call Image/mkfs/cpiogz)
186 $(call Image/mkfs/targz)
187 $(call Image/mkfs/ext2)
188 $(call Image/mkfs/iso)
189 $(call Image/mkfs/jffs2)
190 $(call Image/mkfs/squashfs)
191 $(call Image/mkfs/ubifs)
192 $(call Image/Checksum)
193 else
194 install: compile install-targets
195 $(call Image/BuildKernel)
196 $(call Image/mkfs/cpiogz)
197 $(call Image/mkfs/targz)
198 $(call Image/mkfs/ext2)
199 $(call Image/mkfs/iso)
200 $(call Image/mkfs/jffs2)
201 $(call Image/mkfs/squashfs)
202 $(call Image/mkfs/ubifs)
203 $(call Image/Checksum)
204 endif
205
206 ifeq ($(IB),)
207 clean: clean-targets
208 $(call Build/Clean)
209 else
210 clean:
211 endif
212
213 compile-targets:
214 install-targets:
215 clean-targets:
216
217 endef
This page took 0.053351 seconds and 5 git commands to generate.