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