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