2 # Copyright (C) 2006-2010 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
9 include $(INCLUDE_DIR
)/prereq.mk
10 include $(INCLUDE_DIR
)/kernel.mk
11 include $(INCLUDE_DIR
)/version.mk
12 include $(INCLUDE_DIR
)/image-commands.mk
15 ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS
16 TARGET_PER_DEVICE_ROOTFS
:= 1
20 include $(INCLUDE_DIR
)/image-legacy.mk
21 include $(INCLUDE_DIR
)/feeds.mk
22 include $(INCLUDE_DIR
)/rootfs.mk
24 override MAKE
:=$(_SINGLE
)$(SUBMAKE
)
25 override NO_TRACE_MAKE
:=$(_SINGLE
)$(NO_TRACE_MAKE
)
27 target_params
= $(subst +,$(space
),$*)
28 param_get
= $(patsubst $(1)=%,%,$(filter $(1)=%,$(2)))
29 param_get_default
= $(firstword $(call param_get
,$(1),$(2)) $(3))
30 param_mangle
= $(subst $(space
),_
,$(strip $(1)))
31 param_unmangle
= $(subst _
,$(space
),$(1))
33 mkfs_packages_id
= $(shell echo
$(sort $(1)) | mkhash md5 | head
-c
8)
34 mkfs_target_dir
= $(if
$(call param_get
,pkg
,$(1)),$(KDIR
)/target-dir-
$(call param_get
,pkg
,$(1)),$(TARGET_DIR
))
36 KDIR
=$(KERNEL_BUILD_DIR
)
38 DTS_DIR
:=$(LINUX_DIR
)/arch
/$(LINUX_KARCH
)/boot
/dts
40 IMG_PREFIX_EXTRA
:=$(if
$(EXTRA_IMAGE_NAME
),$(call sanitize
,$(EXTRA_IMAGE_NAME
))-)
41 IMG_PREFIX_VERNUM
:=$(if
$(CONFIG_VERSION_FILENAMES
),$(call sanitize
,$(VERSION_NUMBER
))-)
42 IMG_PREFIX_VERCODE
:=$(if
$(CONFIG_VERSION_CODE_FILENAMES
),$(call sanitize
,$(VERSION_CODE
))-)
44 IMG_PREFIX
:=$(VERSION_DIST_SANITIZED
)-$(IMG_PREFIX_VERNUM
)$(IMG_PREFIX_VERCODE
)$(IMG_PREFIX_EXTRA
)$(BOARD
)$(if
$(SUBTARGET
),-$(SUBTARGET
))
46 MKFS_DEVTABLE_OPT
:= -D
$(INCLUDE_DIR
)/device_table.txt
48 ifneq ($(CONFIG_BIG_ENDIAN
),)
49 JFFS2OPTS
:= --big-endian
--squash-uids
-v
51 JFFS2OPTS
:= --little-endian
--squash-uids
-v
54 ifeq ($(CONFIG_JFFS2_RTIME
),y
)
57 ifeq ($(CONFIG_JFFS2_ZLIB
),y
)
60 ifeq ($(CONFIG_JFFS2_LZMA
),y
)
61 JFFS2OPTS
+= -X lzma
--compression-mode
=size
63 ifneq ($(CONFIG_JFFS2_RTIME
),y
)
66 ifneq ($(CONFIG_JFFS2_ZLIB
),y
)
69 ifneq ($(CONFIG_JFFS2_LZMA
),y
)
73 JFFS2OPTS
+= $(MKFS_DEVTABLE_OPT
)
75 SQUASHFS_BLOCKSIZE
:= $(CONFIG_TARGET_SQUASHFS_BLOCK_SIZE
)k
76 SQUASHFSOPT
:= -b
$(SQUASHFS_BLOCKSIZE
)
77 SQUASHFSOPT
+= -p
'/dev d 755 0 0' -p
'/dev/console c 600 0 0 5 1'
79 LZMA_XZ_OPTIONS
:= -Xpreset
9 -Xe
-Xlc
0 -Xlp
2 -Xpb
2
80 ifeq ($(CONFIG_SQUASHFS_XZ
),y
)
81 ifneq ($(filter arm x86 powerpc sparc
,$(LINUX_KARCH
)),)
82 BCJ_FILTER
:=-Xbcj
$(LINUX_KARCH
)
84 SQUASHFSCOMP
:= xz
$(LZMA_XZ_OPTIONS
) $(BCJ_FILTER
)
87 JFFS2_BLOCKSIZE ?
= 64k
128k
89 fs-types-
$(CONFIG_TARGET_ROOTFS_SQUASHFS
) += squashfs
90 fs-types-
$(CONFIG_TARGET_ROOTFS_JFFS2
) += $(addprefix jffs2-
,$(JFFS2_BLOCKSIZE
))
91 fs-types-
$(CONFIG_TARGET_ROOTFS_JFFS2_NAND
) += $(addprefix jffs2-nand-
,$(NAND_BLOCKSIZE
))
92 fs-types-
$(CONFIG_TARGET_ROOTFS_EXT4FS
) += ext4
93 fs-types-
$(CONFIG_TARGET_ROOTFS_ISO
) += iso
94 fs-types-
$(CONFIG_TARGET_ROOTFS_UBIFS
) += ubifs
95 fs-subtypes-
$(CONFIG_TARGET_ROOTFS_JFFS2
) += $(addsuffix -raw
,$(addprefix jffs2-
,$(JFFS2_BLOCKSIZE
)))
97 TARGET_FILESYSTEMS
:= $(fs-types-y
)
99 FS_64K
:= $(filter-out jffs2-
%,$(TARGET_FILESYSTEMS
)) jffs2-64k
100 FS_128K
:= $(filter-out jffs2-
%,$(TARGET_FILESYSTEMS
)) jffs2-128k
101 FS_256K
:= $(filter-out jffs2-
%,$(TARGET_FILESYSTEMS
)) jffs2-256k
103 define add_jffs2_mark
104 echo
-ne
'\xde\xad\xc0\xde' >> $(1)
107 PROFILE_SANITIZED
:= $(call sanitize
,$(PROFILE
))
112 $(subst $(space
),^
,$(1))), \
113 $(call
$(2),$(strip $(subst ^
,$(space
),$(data
)))))
117 $(if
$(Build
/$(word 1,$(1))),,$(error Missing Build
/$(word 1,$(1))))
118 $(call Build
/$(word 1,$(1)),$(wordlist
2,$(words $(1)),$(1)))
123 $(call split_args
,$(1),build_cmd
)
126 # pad to 4k, 8k, 16k, 64k, 128k, 256k and add jffs2 end-of-filesystem mark
127 define prepare_generic_squashfs
128 $(STAGING_DIR_HOST
)/bin
/padjffs2
$(1) 4 8 16 64 128 256
131 define Image
/BuildKernel
/Initramfs
132 $(call Image
/Build
/Initramfs
)
135 define Image
/BuildKernel
/MkuImage
136 mkimage
-A
$(ARCH
) -O linux
-T kernel
-C
$(1) -a
$(2) -e
$(3) \
137 -n
'$(call toupper,$(ARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' -d
$(4) $(5)
140 define Image
/BuildKernel
/MkFIT
141 $(TOPDIR
)/scripts
/mkits.sh \
142 -D
$(1) -o
$(KDIR
)/fit-
$(1).its
-k
$(2) $(if
$(3),-d
$(3)) -C
$(4) -a
$(5) -e
$(6) \
143 -c
$(if
$(DEVICE_DTS_CONFIG
),$(DEVICE_DTS_CONFIG
),"config@1") \
144 -A
$(LINUX_KARCH
) -v
$(LINUX_VERSION
)
145 PATH
=$(LINUX_DIR
)/scripts
/dtc
:$(PATH
) mkimage
-f
$(KDIR
)/fit-
$(1).its
$(KDIR
)/fit-
$(1)$(7).itb
148 ifdef CONFIG_TARGET_IMAGES_GZIP
156 # Disable noisy checks by default as in upstream
157 ifeq ($(strip $(call kernel_patchver_ge
,4.6.0)),1)
158 DTC_FLAGS
+= -Wno-unit_address_vs_reg
160 ifeq ($(strip $(call kernel_patchver_ge
,4.11.0)),1)
162 -Wno-unit_address_vs_reg \
163 -Wno-simple_bus_reg \
164 -Wno-unit_address_format \
166 -Wno-pci_device_bus_num \
169 ifeq ($(strip $(call kernel_patchver_ge
,4.16.0)),1)
171 -Wno-avoid_unnecessary_addr_size \
174 ifeq ($(strip $(call kernel_patchver_ge
,4.17.0)),1)
176 -Wno-graph_child_address \
178 -Wno-unique_unit_address
181 # $(1) source dts file
182 # $(2) target dtb file
183 # $(3) extra CPP flags
184 # $(4) extra DTC flags
185 define Image
/BuildDTB
186 $(TARGET_CROSS
)cpp -nostdinc
-x assembler-with-cpp \
188 -I
$(DTS_DIR
)/include \
189 -I
$(LINUX_DIR
)/include/ \
190 -undef
-D__DTS__
$(3) \
192 $(LINUX_DIR
)/scripts
/dtc
/dtc
-O dtb \
193 -i
$(dir $(1)) $(DTC_FLAGS
) $(4) \
198 define Image
/mkfs
/jffs2
/sub-raw
199 $(STAGING_DIR_HOST
)/bin
/mkfs.jffs2 \
201 -e
$(patsubst %k
,%KiB
,$(1)) \
202 -o
$@
-d
$(call mkfs_target_dir
,$(3)) \
203 -v
2>&1 1>/dev
/null | awk
'/^.+$$$$/'
206 define Image
/mkfs
/jffs2
/sub
207 $(call Image
/mkfs
/jffs2
/sub-raw
,$(1),--pad
$(2),$(3))
208 $(call add_jffs2_mark
,$@
)
211 define Image
/mkfs
/jffs2
/template
212 Image
/mkfs
/jffs2-
$(1) = $$(call Image
/mkfs
/jffs2
/sub
,$(1),$(JFFS2OPTS
),$$(1))
213 Image
/mkfs
/jffs2-
$(1)-raw
= $$(call Image
/mkfs
/jffs2
/sub-raw
,$(1),$(JFFS2OPTS
),$$(1))
217 define Image
/mkfs
/jffs2-nand
/template
218 Image
/mkfs
/jffs2-nand-
$(1) = \
219 $$(call Image
/mkfs
/jffs2
/sub
, \
220 $(word 2,$(subst -, ,$(1))), \
221 $(JFFS2OPTS
) --no-cleanmarkers
--pagesize
=$(word 1,$(subst -, ,$(1))),$$(1))
225 $(eval
$(foreach S
,$(JFFS2_BLOCKSIZE
),$(call Image
/mkfs
/jffs2
/template
,$(S
))))
226 $(eval
$(foreach S
,$(NAND_BLOCKSIZE
),$(call Image
/mkfs
/jffs2-nand
/template
,$(S
))))
228 define Image
/mkfs
/squashfs
229 $(STAGING_DIR_HOST
)/bin
/mksquashfs4
$(call mkfs_target_dir
,$(1)) $@ \
230 -nopad
-noappend
-root-owned \
231 -comp
$(SQUASHFSCOMP
) $(SQUASHFSOPT
) \
233 $(if
$(SOURCE_DATE_EPOCH
),-fixed-time
$(SOURCE_DATE_EPOCH
))
239 # $(4): compat string
240 ifneq ($(CONFIG_NAND_SUPPORT
),)
241 define Image
/Build
/SysupgradeNAND
242 mkdir
-p
"$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/"
243 echo
"BOARD=$(if $(4),$(4),$(1))" > "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/CONTROL"
244 [ -z
"$(2)" ] ||
$(CP
) "$(KDIR)/root.$(2)" "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/root"
245 [ -z
"$(3)" ] ||
$(CP
) "$(3)" "$(KDIR_TMP)/sysupgrade-$(if $(4),$(4),$(1))/kernel"
246 (cd
"$(KDIR_TMP)"; $(TAR
) cvf \
247 "$(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(2)-sysupgrade.tar" sysupgrade-
$(if
$(4),$(4),$(1)) \
248 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="@$(SOURCE_DATE_EPOCH)") \
253 # $(2) ubinize-image options (e.g. --uboot-env and/or --kernel kernelimage)
254 # $(3) rootfstype (e.g. squashfs or ubifs)
255 # $(4) options to pass-through to ubinize (i.e. $($(PROFILE)_UBI_OPTS)))
256 define Image
/Build
/UbinizeImage
257 sh
$(TOPDIR
)/scripts
/ubinize-image.sh
$(2) \
258 "$(KDIR)/root.$(3)" \
259 "$(KDIR)/$(IMG_PREFIX)-$(1)-$(3)-ubinized.bin" \
265 define Image
/mkfs
/ubifs
266 $(STAGING_DIR_HOST
)/bin
/mkfs.ubifs \
267 $(UBIFS_OPTS
) $(call param_unmangle
,$(call param_get
,fs
,$(1))) \
268 $(if
$(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP
),--space-fixup
) \
269 $(if
$(CONFIG_TARGET_UBIFS_COMPRESSION_NONE
),--compr
=none
) \
270 $(if
$(CONFIG_TARGET_UBIFS_COMPRESSION_LZO
),--compr
=lzo
) \
271 $(if
$(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB
),--compr
=zlib
) \
272 $(if
$(shell echo
$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE
)),--jrn-size
=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE
)) \
274 -o
$@
-d
$(call mkfs_target_dir
,$(1))
277 E2SIZE
=$(shell echo
$$(($(CONFIG_TARGET_ROOTFS_PARTSIZE
)*1024*1024)))
279 define Image
/mkfs
/ext4
280 $(STAGING_DIR_HOST
)/bin
/make_ext4fs \
281 -l
$(E2SIZE
) -b
$(CONFIG_TARGET_EXT4_BLOCKSIZE
) \
282 $(if
$(CONFIG_TARGET_EXT4_RESERVED_PCT
),-m
$(CONFIG_TARGET_EXT4_RESERVED_PCT
)) \
283 $(if
$(CONFIG_TARGET_EXT4_JOURNAL
),,-J
) \
284 $(if
$(SOURCE_DATE_EPOCH
),-T
$(SOURCE_DATE_EPOCH
)) \
285 $@
$(call mkfs_target_dir
,$(1))/
288 define Image
/Manifest
289 $(call opkg
,$(TARGET_DIR_ORIG
)) list-installed
> \
290 $(BIN_DIR
)/$(IMG_PREFIX
)$(if
$(PROFILE_SANITIZED
),-$(PROFILE_SANITIZED
)).manifest
293 ifdef CONFIG_TARGET_ROOTFS_TARGZ
294 define Image
/Build
/targz
295 $(TAR
) -cp
--numeric-owner
--owner
=0 --group
=0 --sort=name \
296 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="@$(SOURCE_DATE_EPOCH)") \
297 -C
$(TARGET_DIR
)/ . | gzip
-9n
> $(BIN_DIR
)/$(IMG_PREFIX
)$(if
$(PROFILE_SANITIZED
),-$(PROFILE_SANITIZED
))-rootfs.
tar.gz
301 ifdef CONFIG_TARGET_ROOTFS_CPIOGZ
302 define Image
/Build
/cpiogz
303 ( cd
$(TARGET_DIR
); find . | cpio
-o
-H newc
-R root
:root | gzip
-9n
>$(BIN_DIR
)/$(IMG_PREFIX
)-rootfs.cpio.gz
)
307 mkfs_packages
= $(filter-out @
%,$(PACKAGES_
$(call param_get
,pkg
,pkg
=$(target_params
))))
308 mkfs_packages_add
= $(foreach pkg
,$(filter-out -%,$(mkfs_packages
)),$(pkg
)$(call GetABISuffix
,$(pkg
)))
309 mkfs_packages_remove
= $(foreach pkg
,$(patsubst -%,%,$(filter -%,$(mkfs_packages
))),$(pkg
)$(call GetABISuffix
,$(pkg
)))
310 mkfs_cur_target_dir
= $(call mkfs_target_dir
,pkg
=$(target_params
))
313 $(call opkg
,$(mkfs_cur_target_dir
)) \
314 -f
$(mkfs_cur_target_dir
).conf
317 rm -rf
$(mkfs_cur_target_dir
) $(mkfs_cur_target_dir
).opkg
318 $(CP
) $(TARGET_DIR_ORIG
) $(mkfs_cur_target_dir
)
319 -mv
$(mkfs_cur_target_dir
)/etc
/opkg
$(mkfs_cur_target_dir
).opkg
320 echo
'src default file://$(PACKAGE_DIR_ALL)' > $(mkfs_cur_target_dir
).conf
321 $(if
$(mkfs_packages_remove
), \
322 -$(call opkg
,$(mkfs_cur_target_dir
)) remove \
323 $(mkfs_packages_remove
))
324 $(if
$(call opkg_package_files
,$(mkfs_packages_add
)), \
325 $(opkg_target
) update
&& \
326 $(opkg_target
) install \
327 $(call opkg_package_files
,$(mkfs_packages_add
)))
328 -$(CP
) -T
$(mkfs_cur_target_dir
).opkg
/ $(mkfs_cur_target_dir
)/etc
/opkg
/
329 rm -rf
$(mkfs_cur_target_dir
).opkg
$(mkfs_cur_target_dir
).conf
330 $(call prepare_rootfs
,$(mkfs_cur_target_dir
),$(TOPDIR
)/files
)
332 $(KDIR
)/root.
%: kernel_prepare
333 $(call Image
/mkfs
/$(word 1,$(target_params
)),$(target_params
))
335 define Device
/InitProfile
336 PROFILES
:= $(PROFILE
)
339 DEVICE_DESCRIPTION
= Build firmware images for
$$(DEVICE_TITLE
)
345 KERNEL_INITRAMFS
= $$(KERNEL
)
351 IMAGE_PREFIX
:= $(IMG_PREFIX
)-$(1)
352 IMAGE_NAME
= $$(IMAGE_PREFIX
)-$$(1)-$$(2)
353 KERNEL_PREFIX
= $$(IMAGE_PREFIX
)
354 KERNEL_SUFFIX
:= -kernel.bin
355 KERNEL_INITRAMFS_SUFFIX
= $$(KERNEL_SUFFIX
)
356 KERNEL_IMAGE
= $$(KERNEL_PREFIX
)$$(KERNEL_SUFFIX
)
357 KERNEL_INITRAMFS_PREFIX
= $$(IMAGE_PREFIX
)-initramfs
358 KERNEL_INITRAMFS_IMAGE
= $$(KERNEL_INITRAMFS_PREFIX
)$$(KERNEL_INITRAMFS_SUFFIX
)
359 KERNEL_INITRAMFS_NAME
= $$(KERNEL_NAME
)-initramfs
361 KERNEL_NAME
:= vmlinux
375 FS_OPTIONS
/ubifs
= $$(MKUBIFS_OPTS
)
386 FILESYSTEMS
:= $(TARGET_FILESYSTEMS
)
389 DEFAULT_DEVICE_VARS
:= \
390 DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_INITRAMFS_IMAGE KERNEL_SIZE \
391 CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \
392 VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
393 DEVICE_DTS_CONFIG DEVICE_DTS_DIR BOARD_NAME UIMAGE_NAME SUPPORTED_DEVICES \
394 IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR
396 define Device
/ExportVar
397 $(1) : $(2):=$$($(2))
401 $(foreach var
,$(DEVICE_VARS
) $(DEFAULT_DEVICE_VARS
),$(call Device
/ExportVar
,$(1),$(var
)))
402 $(1) : FILESYSTEM
:=$(2)
406 DEVICE_CHECK_PROFILE
= $(filter $(1),DEVICE_
$(PROFILE
) $(PROFILE
))
408 DEVICE_CHECK_PROFILE
= $(CONFIG_TARGET_
$(if
$(CONFIG_TARGET_MULTI_PROFILE
),DEVICE_
)$(call target_conf
,$(BOARD
)$(if
$(SUBTARGET
),_
$(SUBTARGET
)))_
$(1))
411 DEVICE_EXTRA_PACKAGES
= $(call qstrip
,$(CONFIG_TARGET_DEVICE_PACKAGES_
$(call target_conf
,$(BOARD
)$(if
$(SUBTARGET
),_
$(SUBTARGET
)))_DEVICE_
$(1)))
413 define merge_packages
416 $(1) := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg
)) $$(patsubst -%,%,$(pkg
)),$$($(1))) $(pkg
))
420 define Device
/Check
/Common
421 _PROFILE_SET
= $$(strip $$(foreach profile
,$$(PROFILES
) DEVICE_
$(1),$$(call DEVICE_CHECK_PROFILE
,$$(profile
))))
422 DEVICE_PACKAGES
+= $$(call extra_packages
,$$(DEVICE_PACKAGES
))
423 ifdef TARGET_PER_DEVICE_ROOTFS
424 $$(eval
$$(call merge_packages
,_PACKAGES
,$$(DEVICE_PACKAGES
) $$(call DEVICE_EXTRA_PACKAGES
,$(1))))
425 ROOTFS_ID
/$(1) := $$(if
$$(_PROFILE_SET
),$$(call mkfs_packages_id
,$$(_PACKAGES
)))
426 PACKAGES_
$$(ROOTFS_ID
/$(1)) := $$(_PACKAGES
)
431 $(Device
/Check
/Common
)
432 KDIR_KERNEL_IMAGE
:= $(KDIR
)/$(1)$$(KERNEL_SUFFIX
)
433 _TARGET
:= $$(if
$$(_PROFILE_SET
),install-images
,install-disabled
)
435 _COMPILE_TARGET
:= $$(if
$(CONFIG_IB
)$$(_PROFILE_SET
),compile
,compile-disabled
)
440 define Device
/Build
/initramfs
441 $(call Device
/Export
,$(KDIR
)/tmp
/$$(KERNEL_INITRAMFS_IMAGE
),$(1))
442 $$(_TARGET
): $$(if
$$(KERNEL_INITRAMFS
),$(BIN_DIR
)/$$(KERNEL_INITRAMFS_IMAGE
))
444 $(KDIR
)/$$(KERNEL_INITRAMFS_NAME
):: image_prepare
445 $(BIN_DIR
)/$$(KERNEL_INITRAMFS_IMAGE
): $(KDIR
)/tmp
/$$(KERNEL_INITRAMFS_IMAGE
)
448 $(KDIR
)/tmp
/$$(KERNEL_INITRAMFS_IMAGE
): $(KDIR
)/$$(KERNEL_INITRAMFS_NAME
) $(CURDIR
)/Makefile
$$(KERNEL_DEPENDS
) image_prepare
450 $$(call concat_cmd
,$$(KERNEL_INITRAMFS
))
454 define Device
/Build
/compile
455 $$(_COMPILE_TARGET
): $(KDIR
)/$(1)
456 $(eval
$(call Device
/Export
,$(KDIR
)/$(1)))
458 $$(call concat_cmd
,$(COMPILE
/$(1)))
463 define Device
/Build
/dtb
464 ifndef BUILD_DTS_
$(1)
466 $(KDIR
)/image-
$(1).dtb
: FORCE
467 $(call Image
/BuildDTB
,$(strip $(2))/$(strip $(3)).dts
,$$@
)
469 image_prepare
: $(KDIR
)/image-
$(1).dtb
475 define Device
/Build
/kernel
476 $$(eval
$$(foreach dts
,$$(DEVICE_DTS
), \
477 $$(call Device
/Build
/dtb
,$$(notdir $$(dts
)), \
478 $$(if
$$(DEVICE_DTS_DIR
),$$(DEVICE_DTS_DIR
),$$(DTS_DIR
)), \
483 $(KDIR
)/$$(KERNEL_NAME
):: image_prepare
484 $$(_TARGET
): $$(if
$$(KERNEL_INSTALL
),$(BIN_DIR
)/$$(KERNEL_IMAGE
))
485 $(call Device
/Export
,$$(KDIR_KERNEL_IMAGE
),$(1))
486 $(BIN_DIR
)/$$(KERNEL_IMAGE
): $$(KDIR_KERNEL_IMAGE
)
490 install: $$(KDIR_KERNEL_IMAGE
)
492 $$(KDIR_KERNEL_IMAGE
): $(KDIR
)/$$(KERNEL_NAME
) $(CURDIR
)/Makefile
$$(KERNEL_DEPENDS
) image_prepare
494 $$(call concat_cmd
,$$(KERNEL
))
495 $$(if
$$(KERNEL_SIZE
),$$(call Build
/check-size
,$$(KERNEL_SIZE
)))
499 define Device
/Build
/image
500 GZ_SUFFIX
:= $(if
$(filter %dtb
%gz
,$(2)),,$(if
$(and
$(findstring ext4
,$(1)),$(CONFIG_TARGET_IMAGES_GZIP
)),.gz
))
501 $$(_TARGET
): $(BIN_DIR
)/$(call IMAGE_NAME
,$(1),$(2))$$(GZ_SUFFIX
)
502 $(eval
$(call Device
/Export
,$(KDIR
)/tmp
/$(call IMAGE_NAME
,$(1),$(2)),$(1)))
503 ROOTFS
/$(1)/$(3) := \
504 $(KDIR
)/root.
$(1)$$(strip \
505 $$(if
$$(FS_OPTIONS
/$(1)),+fs
=$$(call param_mangle
,$$(FS_OPTIONS
/$(1)))) \
507 $(if
$(TARGET_PER_DEVICE_ROOTFS
),+pkg
=$$(ROOTFS_ID
/$(3))) \
510 $$(ROOTFS
/$(1)/$(3)): $(if
$(TARGET_PER_DEVICE_ROOTFS
),target-dir-
$$(ROOTFS_ID
/$(3)))
512 $(KDIR
)/tmp
/$(call IMAGE_NAME
,$(1),$(2)): $$(KDIR_KERNEL_IMAGE
) $$(ROOTFS
/$(1)/$(3))
514 [ -f
$$(word 1,$$^
) -a
-f
$$(word 2,$$^
) ]
515 $$(call concat_cmd
,$(if
$(IMAGE
/$(2)/$(1)),$(IMAGE
/$(2)/$(1)),$(IMAGE
/$(2))))
517 .IGNORE
: $(BIN_DIR
)/$(call IMAGE_NAME
,$(1),$(2))
519 $(BIN_DIR
)/$(call IMAGE_NAME
,$(1),$(2)).gz
: $(KDIR
)/tmp
/$(call IMAGE_NAME
,$(1),$(2))
520 gzip
-c
-9n
$$^
> $$@
522 $(BIN_DIR
)/$(call IMAGE_NAME
,$(1),$(2)): $(KDIR
)/tmp
/$(call IMAGE_NAME
,$(1),$(2))
527 define Device
/Build
/artifact
528 $$(_TARGET
): $(BIN_DIR
)/$(IMAGE_PREFIX
)-$(1)
529 $(eval
$(call Device
/Export
,$(KDIR
)/tmp
/$(IMAGE_PREFIX
)-$(1)))
530 $(KDIR
)/tmp
/$(IMAGE_PREFIX
)-$(1): $$(KDIR_KERNEL_IMAGE
)
532 $$(call concat_cmd
,$(ARTIFACT
/$(1)))
534 .IGNORE
: $(BIN_DIR
)/$(IMAGE_PREFIX
)-$(1)
536 $(BIN_DIR
)/$(IMAGE_PREFIX
)-$(1): $(KDIR
)/tmp
/$(IMAGE_PREFIX
)-$(1)
542 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),$(call Device
/Build
/initramfs
,$(1)))
543 $(call Device
/Build
/kernel
,$(1))
545 $$(eval
$$(foreach compile
,$$(COMPILE
), \
546 $$(call Device
/Build
/compile
,$$(compile
),$(1))))
548 $$(eval
$$(foreach image
,$$(IMAGES
), \
549 $$(foreach fs
,$$(filter $(TARGET_FILESYSTEMS
),$$(FILESYSTEMS
)), \
550 $$(call Device
/Build
/image
,$$(fs
),$$(image
),$(1)))))
552 $$(eval
$$(foreach artifact
,$$(ARTIFACTS
), \
553 $$(call Device
/Build
/artifact
,$$(artifact
))))
557 define Device
/DumpInfo
558 Target-Profile
: DEVICE_
$(1)
559 Target-Profile-Name
: $(DEVICE_TITLE
)
560 Target-Profile-Packages
: $(DEVICE_PACKAGES
)
561 Target-Profile-Description
:
562 $(DEVICE_DESCRIPTION
)
568 $$(eval
$$(if
$$(DEVICE_TITLE
),$$(info $$(call Device
/DumpInfo
,$(1)))))
572 $(call Device
/InitProfile
,$(1))
573 $(call Device
/Init
,$(1))
574 $(call Device
/Default
,$(1))
575 $(call Device
/$(1),$(1))
576 $(call Device
/Check
,$(1))
577 $(call Device
/$(if
$(DUMP
),Dump
,Build
),$(1))
593 legacy-images-prepare
:
598 .PHONY
: download prepare compile
clean image_prepare kernel_prepare
install install-images
600 $(call Build
/Compile
)
605 image_prepare
: compile
606 mkdir
-p
$(BIN_DIR
) $(KDIR
)/tmp
607 $(call Image
/Prepare
)
609 legacy-images-prepare-make
: image_prepare
610 $(MAKE
) legacy-images-prepare BIN_DIR
="$(BIN_DIR)"
614 mkdir
-p
$(BIN_DIR
) $(KDIR
)/tmp
617 kernel_prepare
: image_prepare
618 $(call Image
/Build
/targz
)
619 $(call Image
/Build
/cpiogz
)
620 $(call Image
/BuildKernel
)
621 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),$(if
$(IB
),,$(call Image
/BuildKernel
/Initramfs
)))
622 $(call Image
/InstallKernel
)
624 $(foreach device
,$(TARGET_DEVICES
),$(call Device
,$(device
)))
625 $(foreach device
,$(LEGACY_DEVICES
),$(call LegacyDevice
,$(device
)))
627 install-images
: kernel_prepare
$(foreach fs
,$(filter-out $(if
$(UBIFS_OPTS
),,ubifs
),$(TARGET_FILESYSTEMS
) $(fs-subtypes-y
)),$(KDIR
)/root.
$(fs
))
628 $(foreach fs
,$(TARGET_FILESYSTEMS
),
629 $(call Image
/Build
,$(fs
))
632 legacy-images-make
: install-images
633 $(call Image
/mkfs
/ubifs
/legacy
)
634 $(MAKE
) legacy-images BIN_DIR
="$(BIN_DIR)"
636 install: install-images
637 $(call Image
/Manifest
)