build: add support for parameter passing to mkfs from devices
[openwrt/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 include $(INCLUDE_DIR)/version.mk
13 include $(INCLUDE_DIR)/image-commands.mk
14 include $(INCLUDE_DIR)/image-legacy.mk
15
16 override MAKE:=$(_SINGLE)$(SUBMAKE)
17 override NO_TRACE_MAKE:=$(_SINGLE)$(NO_TRACE_MAKE)
18
19 param_get = $(patsubst $(1)=%,%,$(filter $(1)=%,$(2)))
20 param_mangle = $(subst $(space),_,$(strip $(1)))
21 param_unmangle = $(subst _,$(space),$(1))
22
23 KDIR=$(KERNEL_BUILD_DIR)
24 KDIR_TMP=$(KDIR)/tmp
25 DTS_DIR:=$(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts
26
27 EXTRA_NAME_SANITIZED=$(call sanitize,$(EXTRA_IMAGE_NAME))
28
29 IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(if $(EXTRA_NAME_SANITIZED),$(EXTRA_NAME_SANITIZED)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
30
31 MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
32
33 ifneq ($(CONFIG_BIG_ENDIAN),)
34 JFFS2OPTS := --big-endian --squash-uids -v
35 else
36 JFFS2OPTS := --little-endian --squash-uids -v
37 endif
38
39 ifeq ($(CONFIG_JFFS2_RTIME),y)
40 JFFS2OPTS += -X rtime
41 endif
42 ifeq ($(CONFIG_JFFS2_ZLIB),y)
43 JFFS2OPTS += -X zlib
44 endif
45 ifeq ($(CONFIG_JFFS2_LZMA),y)
46 JFFS2OPTS += -X lzma --compression-mode=size
47 endif
48 ifneq ($(CONFIG_JFFS2_RTIME),y)
49 JFFS2OPTS += -x rtime
50 endif
51 ifneq ($(CONFIG_JFFS2_ZLIB),y)
52 JFFS2OPTS += -x zlib
53 endif
54 ifneq ($(CONFIG_JFFS2_LZMA),y)
55 JFFS2OPTS += -x lzma
56 endif
57
58 JFFS2OPTS += $(MKFS_DEVTABLE_OPT)
59
60 SQUASHFS_BLOCKSIZE := $(CONFIG_TARGET_SQUASHFS_BLOCK_SIZE)k
61 SQUASHFSOPT := -b $(SQUASHFS_BLOCKSIZE)
62 SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
63 SQUASHFSCOMP := gzip
64 LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
65 ifeq ($(CONFIG_SQUASHFS_XZ),y)
66 ifneq ($(filter arm x86 powerpc sparc,$(LINUX_KARCH)),)
67 BCJ_FILTER:=-Xbcj $(LINUX_KARCH)
68 endif
69 SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS) $(BCJ_FILTER)
70 endif
71
72 JFFS2_BLOCKSIZE ?= 64k 128k
73
74 fs-types-$(CONFIG_TARGET_ROOTFS_SQUASHFS) += squashfs
75 fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addprefix jffs2-,$(JFFS2_BLOCKSIZE))
76 fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BLOCKSIZE))
77 fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4
78 fs-types-$(CONFIG_TARGET_ROOTFS_ISO) += iso
79 fs-types-$(CONFIG_TARGET_ROOTFS_UBIFS) += ubifs
80 fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE)))
81 fs-subtypes-$(CONFIG_TARGET_ROOTFS_CPIOGZ) += cpiogz
82 fs-subtypes-$(CONFIG_TARGET_ROOTFS_TARGZ) += targz
83
84 TARGET_FILESYSTEMS := $(fs-types-y)
85
86 FS_64K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-64k
87 FS_128K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-128k
88 FS_256K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-256k
89
90 define add_jffs2_mark
91 echo -ne '\xde\xad\xc0\xde' >> $(1)
92 endef
93
94 PROFILE_SANITIZED := $(call sanitize,$(PROFILE))
95
96 define split_args
97 $(foreach data, \
98 $(subst |,$(space),\
99 $(subst $(space),^,$(1))), \
100 $(call $(2),$(strip $(subst ^,$(space),$(data)))))
101 endef
102
103 define build_cmd
104 $(if $(Build/$(word 1,$(1))),,$(error Missing Build/$(word 1,$(1))))
105 $(call Build/$(word 1,$(1)),$(wordlist 2,$(words $(1)),$(1)))
106
107 endef
108
109 define concat_cmd
110 $(call split_args,$(1),build_cmd)
111 endef
112
113 # pad to 4k, 8k, 16k, 64k, 128k, 256k and add jffs2 end-of-filesystem mark
114 define prepare_generic_squashfs
115 $(STAGING_DIR_HOST)/bin/padjffs2 $(1) 4 8 16 64 128 256
116 endef
117
118 define Image/BuildKernel/Initramfs
119 $(call Image/Build/Initramfs)
120 endef
121
122 define Image/BuildKernel/MkuImage
123 mkimage -A $(ARCH) -O linux -T kernel -C $(1) -a $(2) -e $(3) \
124 -n '$(call toupper,$(ARCH)) LEDE Linux-$(LINUX_VERSION)' -d $(4) $(5)
125 endef
126
127 define Image/BuildKernel/MkFIT
128 $(TOPDIR)/scripts/mkits.sh \
129 -D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \
130 -A $(ARCH) -v $(LINUX_VERSION)
131 PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
132 endef
133
134 # $(1) source dts file
135 # $(2) target dtb file
136 # $(3) extra CPP flags
137 # $(4) extra DTC flags
138 define Image/BuildDTB
139 $(TARGET_CROSS)cpp -nostdinc -x assembler-with-cpp \
140 -I$(DTS_DIR) \
141 -I$(DTS_DIR)/include \
142 -undef -D__DTS__ $(3) \
143 -o $(2).tmp $(1)
144 $(LINUX_DIR)/scripts/dtc/dtc -O dtb \
145 -i$(dir $(1)) $(4) \
146 -o $(2) $(2).tmp
147 $(RM) $(2).tmp
148 endef
149
150 define Image/mkfs/jffs2/sub
151 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) --pad -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
152 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(2))
153 endef
154
155 define Image/mkfs/jffs2/sub-raw
156 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2)-raw -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
157 endef
158
159 define Image/mkfs/jffs2/template
160 Image/mkfs/jffs2-$(1) = $$(call Image/mkfs/jffs2/sub,$(1),$(1),$(JFFS2OPTS))
161 Image/mkfs/jffs2-$(1)-raw = $$(call Image/mkfs/jffs2/sub-raw,$(1),$(1),$(JFFS2OPTS))
162
163 endef
164
165 define Image/mkfs/jffs2-nand/template
166 Image/mkfs/jffs2-nand-$(1) = \
167 $$(call Image/mkfs/jffs2/sub, \
168 $(word 2,$(subst -, ,$(1))),nand-$(1), \
169 $(JFFS2OPTS) --no-cleanmarkers --pagesize=$(word 1,$(subst -, ,$(1))))
170
171 endef
172
173 $(eval $(foreach S,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/template,$(S))))
174 $(eval $(foreach S,$(NAND_BLOCKSIZE),$(call Image/mkfs/jffs2-nand/template,$(S))))
175
176 define Image/mkfs/squashfs
177 $(STAGING_DIR_HOST)/bin/mksquashfs4 $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned -comp $(SQUASHFSCOMP) $(SQUASHFSOPT) -processors $(if $(CONFIG_PKG_BUILD_JOBS),$(CONFIG_PKG_BUILD_JOBS),1) $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
178 endef
179
180 # $(1): board name
181 # $(2): rootfs type
182 # $(3): kernel image
183 ifneq ($(CONFIG_NAND_SUPPORT),)
184 define Image/Build/SysupgradeNAND
185 mkdir -p "$(KDIR_TMP)/sysupgrade-$(1)/"
186 echo "BOARD=$(1)" > "$(KDIR_TMP)/sysupgrade-$(1)/CONTROL"
187 [ -z "$(2)" ] || $(CP) "$(KDIR)/root.$(2)" "$(KDIR_TMP)/sysupgrade-$(1)/root"
188 [ -z "$(3)" ] || $(CP) "$(3)" "$(KDIR_TMP)/sysupgrade-$(1)/kernel"
189 (cd "$(KDIR_TMP)"; $(TAR) cvf \
190 "$(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(2)-sysupgrade.tar" sysupgrade-$(1) \
191 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
192 )
193 endef
194
195 # $(1) board name
196 # $(2) ubinize-image options (e.g. --uboot-env and/or --kernel kernelimage)
197 # $(3) rootfstype (e.g. squashfs or ubifs)
198 # $(4) options to pass-through to ubinize (i.e. $($(PROFILE)_UBI_OPTS)))
199 define Image/Build/UbinizeImage
200 sh $(TOPDIR)/scripts/ubinize-image.sh $(2) \
201 "$(KDIR)/root.$(3)" \
202 "$(KDIR)/$(IMG_PREFIX)-$(1)-$(3)-ubinized.bin" \
203 $(4)
204 endef
205
206 endif
207
208 define Image/mkfs/ubifs
209 $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
210 $(UBIFS_OPTS) $(call param_unmangle,$(call param_get,fs,$(1))) \
211 $(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \
212 $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--force-compr=none) \
213 $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--force-compr=lzo) \
214 $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--force-compr=zlib) \
215 $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
216 --squash-uids \
217 -o $@ -d $(TARGET_DIR)
218 endef
219
220 define Image/mkfs/cpiogz
221 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz )
222 endef
223
224 define Image/mkfs/targz
225 $(TAR) -cp --numeric-owner --owner=0 --group=0 --sort=name \
226 $(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
227 -C $(TARGET_DIR)/ . | gzip -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz
228 endef
229
230 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024*1024)))
231
232 define Image/mkfs/ext4
233 $(STAGING_DIR_HOST)/bin/make_ext4fs \
234 -l $(E2SIZE) -b $(CONFIG_TARGET_EXT4_BLOCKSIZE) \
235 -i $(CONFIG_TARGET_EXT4_MAXINODE) \
236 -m $(CONFIG_TARGET_EXT4_RESERVED_PCT) \
237 $(if $(CONFIG_TARGET_EXT4_JOURNAL),,-J) \
238 $(if $(SOURCE_DATE_EPOCH),-T $(SOURCE_DATE_EPOCH)) \
239 $(KDIR)/root.ext4 $(TARGET_DIR)/
240 endef
241
242 define Image/mkfs/prepare/default
243 # Use symbolic permissions to avoid clobbering SUID/SGID/sticky bits
244 - $(FIND) $(TARGET_DIR) -type f -not -perm /0100 -not -name 'ssh_host*' -not -name 'shadow' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
245 - $(FIND) $(TARGET_DIR) -type f -perm /0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
246 - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
247 $(INSTALL_DIR) $(TARGET_DIR)/tmp $(TARGET_DIR)/overlay
248 chmod 1777 $(TARGET_DIR)/tmp
249 endef
250
251 define Image/mkfs/prepare
252 $(call Image/mkfs/prepare/default)
253 endef
254
255
256 define Image/Checksum
257 ( cd ${BIN_DIR} ; \
258 $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | sort | xargs $1 > $2 \
259 )
260 endef
261
262 $(KDIR)/root.%: kernel_prepare
263 $(call Image/mkfs/$(word 1,$(subst +,$(space),$*)),$(subst +,$(space),$*))
264
265 define Device/InitProfile
266 PROFILES := $(PROFILE)
267 DEVICE_TITLE :=
268 DEVICE_PACKAGES :=
269 DEVICE_DESCRIPTION = Build firmware images for $$(DEVICE_TITLE)
270 endef
271
272 define Device/Init
273 DEVICE_NAME := $(1)
274 KERNEL:=
275 KERNEL_INITRAMFS = $$(KERNEL)
276 KERNEL_SIZE:=
277 CMDLINE:=
278
279 IMAGE_PREFIX := $(IMG_PREFIX)-$(1)
280 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
281 KERNEL_PREFIX = $$(IMAGE_PREFIX)
282 KERNEL_SUFFIX := -kernel.bin
283 KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
284 KERNEL_IMAGE = $$(KERNEL_PREFIX)$$(KERNEL_SUFFIX)
285 KERNEL_INITRAMFS_PREFIX = $$(IMAGE_PREFIX)-initramfs
286 KERNEL_INITRAMFS_IMAGE = $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_INITRAMFS_SUFFIX)
287 KERNEL_INITRAMFS_NAME = $$(KERNEL_NAME)-initramfs
288 KERNEL_INSTALL :=
289 KERNEL_NAME := vmlinux
290 KERNEL_DEPENDS :=
291 KERNEL_SIZE :=
292
293 UBOOTENV_IN_UBI :=
294 KERNEL_IN_UBI :=
295 BLOCKSIZE :=
296 PAGESIZE :=
297 SUBPAGESIZE :=
298 UBINIZE_OPTS := -E 5
299 MKUBIFS_OPTS :=
300
301 FS_OPTIONS/ubifs = $$(MKUBIFS_OPTS)
302
303 DEVICE_DTS :=
304 DEVICE_DTS_DIR :=
305
306 FILESYSTEMS := $(TARGET_FILESYSTEMS)
307 endef
308
309 DEFAULT_DEVICE_VARS := \
310 DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_INITRAMFS_IMAGE \
311 DEVICE_DTS DEVICE_DTS_DIR \
312 UBOOTENV_IN_UBI KERNEL_IN_UBI \
313 BLOCKSIZE PAGESIZE SUBPAGESIZE \
314 UBINIZE_OPTS
315
316 define Device/ExportVar
317 $(1) : $(2):=$$($(2))
318
319 endef
320 define Device/Export
321 $(foreach var,$(DEVICE_VARS) $(DEFAULT_DEVICE_VARS),$(call Device/ExportVar,$(1),$(var)))
322 $(1) : FILESYSTEM:=$(2)
323 endef
324
325 ifdef IB
326 DEVICE_CHECK_PROFILE = $(filter $(1),$(PROFILE))
327 else
328 DEVICE_CHECK_PROFILE = $(CONFIG_TARGET_$(if $(CONFIG_TARGET_MULTI_PROFILE),DEVICE_)$(call target_conf,$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET)))_$(1))
329 endif
330
331 define Device/Check
332 _PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile))))
333 _TARGET := $$(if $$(_PROFILE_SET),install-images,install-disabled)
334 ifndef IB
335 _COMPILE_TARGET := $$(if $(CONFIG_IB)$$(_PROFILE_SET),compile,compile-disabled)
336 endif
337 endef
338
339 ifndef IB
340 define Device/Build/initramfs
341 $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1))
342 $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE))
343
344 $(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare
345 $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE)
346 cp $$^ $$@
347
348 $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS)
349 @rm -f $$@
350 $$(call concat_cmd,$$(KERNEL_INITRAMFS))
351 endef
352 endif
353
354 define Device/Build/check_size
355 @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -ge "$$(stat -c%s $@)" ] || { \
356 echo "WARNING: Image file $@ is too big" >&2; \
357 rm -f $@; \
358 }
359 endef
360
361 define Device/Build/compile
362 $$(_COMPILE_TARGET): $(KDIR)/$(1)
363 $(eval $(call Device/Export,$(KDIR)/$(1)))
364 $(KDIR)/$(1):
365 $$(call concat_cmd,$(COMPILE/$(1)))
366
367 endef
368
369 define Device/Build/kernel
370 _KERNEL_IMAGES += $(KDIR)/$$(KERNEL_NAME)
371 $(KDIR)/$$(KERNEL_NAME):: image_prepare
372 $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
373 $(call Device/Export,$(KDIR)/$$(KERNEL_IMAGE),$(1))
374 $(BIN_DIR)/$$(KERNEL_IMAGE): $(KDIR)/$$(KERNEL_IMAGE)
375 cp $$^ $$@
376 ifndef IB
377 ifdef CONFIG_IB
378 install: $(KDIR)/$$(KERNEL_IMAGE)
379 endif
380 $(KDIR)/$$(KERNEL_IMAGE): $(KDIR)/$$(KERNEL_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS)
381 @rm -f $$@
382 $$(call concat_cmd,$$(KERNEL))
383 $$(if $$(KERNEL_SIZE),$$(call Device/Build/check_size,$$(KERNEL_SIZE)))
384 endif
385 endef
386
387 define Device/Build/image
388 $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
389 $(eval $(call Device/Export,$(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)),$(1)))
390 $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/$$(KERNEL_IMAGE) $(KDIR)/root.$(1)$$(if $$(FS_OPTIONS/$(1)),+fs=$$(call param_mangle,$$(FS_OPTIONS/$(1))))
391 @rm -f $$@
392 [ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ]
393 $$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2))))
394
395 .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
396 $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
397 cp $$^ $$@
398
399 endef
400
401 define Device/Build
402 $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
403 $(call Device/Build/kernel,$(1))
404
405 $$(eval $$(foreach compile,$$(COMPILE), \
406 $$(call Device/Build/compile,$$(compile),$(1))))
407
408 $$(eval $$(foreach image,$$(IMAGES), \
409 $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
410 $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
411 endef
412
413 define Device/DumpInfo
414 Target-Profile: DEVICE_$(1)
415 Target-Profile-Name: $(DEVICE_TITLE)
416 Target-Profile-Packages: $(DEVICE_PACKAGES)
417 Target-Profile-Description:
418 $(DEVICE_DESCRIPTION)
419 @@
420
421 endef
422
423 define Device/Dump
424 $$(eval $$(if $$(DEVICE_TITLE),$$(info $$(call Device/DumpInfo,$(1)))))
425 endef
426
427 define Device
428 $(call Device/InitProfile,$(1))
429 $(call Device/Init,$(1))
430 $(call Device/Default,$(1))
431 $(call Device/$(1),$(1))
432 $(call Device/Check,$(1))
433 $(call Device/$(if $(DUMP),Dump,Build),$(1))
434
435 endef
436
437 define BuildImage
438
439 ifneq ($(DUMP),)
440 all: dumpinfo
441 dumpinfo: FORCE
442 @true
443 endif
444
445 download:
446 prepare:
447 compile:
448 clean:
449 legacy-images-prepare:
450 legacy-images:
451 image_prepare:
452
453 ifeq ($(IB),)
454 .PHONY: download prepare compile clean image_prepare mkfs_prepare kernel_prepare install install-images
455 compile:
456 $(call Build/Compile)
457
458 clean:
459 $(call Build/Clean)
460
461 image_prepare: compile
462 mkdir -p $(BIN_DIR) $(KDIR)/tmp
463 $(call Image/Prepare)
464
465 legacy-images-prepare-make: image_prepare
466 $(MAKE) legacy-images-prepare
467
468 else
469 image_prepare:
470 mkdir -p $(BIN_DIR) $(KDIR)/tmp
471 endif
472
473 mkfs_prepare: image_prepare
474 $(call Image/mkfs/prepare)
475
476 kernel_prepare: mkfs_prepare
477 $(call Image/BuildKernel)
478 $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs)))
479 $(call Image/InstallKernel)
480
481 $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
482 $(foreach device,$(LEGACY_DEVICES),$(call LegacyDevice,$(device)))
483
484 install-images: kernel_prepare $(foreach fs,$(filter-out ubifs,$(TARGET_FILESYSTEMS) $(fs-subtypes-y)),$(KDIR)/root.$(fs))
485 $(foreach fs,$(TARGET_FILESYSTEMS),
486 $(call Image/Build,$(fs))
487 )
488
489 legacy-images-make: install-images
490 $(call Image/mkfs/ubifs/legacy)
491 $(MAKE) legacy-images
492
493 install: install-images
494 $(call Image/Checksum,md5sum --binary,md5sums)
495 $(call Image/Checksum,openssl dgst -sha256,sha256sums)
496
497 endef