1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2006-2020 OpenWrt.org
6 include $(INCLUDE_DIR
)/prereq.mk
7 include $(INCLUDE_DIR
)/kernel.mk
8 include $(INCLUDE_DIR
)/version.mk
9 include $(INCLUDE_DIR
)/image-commands.mk
12 ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS
13 TARGET_PER_DEVICE_ROOTFS
:= 1
17 include $(INCLUDE_DIR
)/feeds.mk
18 include $(INCLUDE_DIR
)/rootfs.mk
20 override MAKE
:=$(_SINGLE
)$(SUBMAKE
)
21 override NO_TRACE_MAKE
:=$(_SINGLE
)$(NO_TRACE_MAKE
)
23 target_params
= $(subst +,$(space
),$*)
24 param_get
= $(patsubst $(1)=%,%,$(filter $(1)=%,$(2)))
25 param_get_default
= $(firstword $(call param_get
,$(1),$(2)) $(3))
26 param_mangle
= $(subst $(space
),_
,$(strip $(1)))
27 param_unmangle
= $(subst _
,$(space
),$(1))
29 mkfs_packages_id
= $(shell echo
$(sort $(1)) |
$(MKHASH
) md5 | cut
-b1-8
)
30 mkfs_target_dir
= $(if
$(call param_get
,pkg
,$(1)),$(KDIR
)/target-dir-
$(call param_get
,pkg
,$(1)),$(TARGET_DIR
))
32 KDIR
=$(KERNEL_BUILD_DIR
)
34 DTS_DIR
:=$(LINUX_DIR
)/arch
/$(LINUX_KARCH
)/boot
/dts
36 IMG_PREFIX_EXTRA
:=$(if
$(EXTRA_IMAGE_NAME
),$(call sanitize
,$(EXTRA_IMAGE_NAME
))-)
37 IMG_PREFIX_VERNUM
:=$(if
$(CONFIG_VERSION_FILENAMES
),$(call sanitize
,$(VERSION_NUMBER
))-)
38 IMG_PREFIX_VERCODE
:=$(if
$(CONFIG_VERSION_CODE_FILENAMES
),$(call sanitize
,$(VERSION_CODE
))-)
40 IMG_PREFIX
:=$(VERSION_DIST_SANITIZED
)-$(IMG_PREFIX_VERNUM
)$(IMG_PREFIX_VERCODE
)$(IMG_PREFIX_EXTRA
)$(BOARD
)$(if
$(SUBTARGET
),-$(SUBTARGET
))
41 IMG_ROOTFS
:=$(IMG_PREFIX
)-rootfs
42 IMG_COMBINED
:=$(IMG_PREFIX
)-combined
43 IMG_PART_SIGNATURE
:=$(shell echo
$(SOURCE_DATE_EPOCH
)$(LINUX_VERMAGIC
) |
$(MKHASH
) md5 | cut
-b1-8
)
44 IMG_PART_DISKGUID
:=$(shell echo
$(SOURCE_DATE_EPOCH
)$(LINUX_VERMAGIC
) |
$(MKHASH
) md5 | sed
-E
's/(.{8})(.{4})(.{4})(.{4})(.{10})../\1-\2-\3-\4-\500/')
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'
78 SQUASHFSOPT
+= $(if
$(CONFIG_SELINUX
),-xattrs
,-no-xattrs
)
80 LZMA_XZ_OPTIONS
:= -Xpreset
9 -Xe
-Xlc
0 -Xlp
2 -Xpb
2
81 ifeq ($(CONFIG_SQUASHFS_XZ
),y
)
82 ifneq ($(filter arm x86 powerpc sparc
,$(LINUX_KARCH
)),)
83 BCJ_FILTER
:=-Xbcj
$(LINUX_KARCH
)
85 SQUASHFSCOMP
:= xz
$(LZMA_XZ_OPTIONS
) $(BCJ_FILTER
)
88 JFFS2_BLOCKSIZE ?
= 64k
128k
90 fs-types-
$(CONFIG_TARGET_ROOTFS_SQUASHFS
) += squashfs
91 fs-types-
$(CONFIG_TARGET_ROOTFS_JFFS2
) += $(addprefix jffs2-
,$(JFFS2_BLOCKSIZE
))
92 fs-types-
$(CONFIG_TARGET_ROOTFS_JFFS2_NAND
) += $(addprefix jffs2-nand-
,$(NAND_BLOCKSIZE
))
93 fs-types-
$(CONFIG_TARGET_ROOTFS_EXT4FS
) += ext4
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 tolower
,$(subst DEVICE_
,,$(subst $(space
),-,$(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
158 -Wno-unit_address_vs_reg \
159 -Wno-simple_bus_reg \
160 -Wno-unit_address_format \
162 -Wno-pci_device_bus_num \
163 -Wno-pci_device_reg \
164 -Wno-avoid_unnecessary_addr_size \
166 -Wno-graph_child_address \
168 -Wno-unique_unit_address
171 dd if
=$(1) of
=$(1).new bs
=$(2) conv
=sync
175 ROOTFS_PARTSIZE
=$(shell echo
$$(($(CONFIG_TARGET_ROOTFS_PARTSIZE
)*1024*1024)))
177 define Image
/pad-root-squashfs
178 $(call Image
/pad-to
,$(KDIR
)/root.squashfs
,$(if
$(1),$(1),$(ROOTFS_PARTSIZE
)))
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) \
194 $(if
$(CONFIG_HAS_DT_OVERLAY_SUPPORT
),-@
) \
199 define Image
/mkfs
/jffs2
/sub-raw
200 $(STAGING_DIR_HOST
)/bin
/mkfs.jffs2 \
202 -e
$(patsubst %k
,%KiB
,$(1)) \
203 -o
$@
-d
$(call mkfs_target_dir
,$(3)) \
204 -v
2>&1 1>/dev
/null | awk
'/^.+$$$$/'
207 define Image
/mkfs
/jffs2
/sub
208 $(call Image
/mkfs
/jffs2
/sub-raw
,$(1),--pad
$(2),$(3))
209 $(call add_jffs2_mark
,$@
)
212 define Image
/mkfs
/jffs2
/template
213 Image
/mkfs
/jffs2-
$(1) = $$(call Image
/mkfs
/jffs2
/sub
,$(1),$(JFFS2OPTS
),$$(1))
214 Image
/mkfs
/jffs2-
$(1)-raw
= $$(call Image
/mkfs
/jffs2
/sub-raw
,$(1),$(JFFS2OPTS
),$$(1))
218 define Image
/mkfs
/jffs2-nand
/template
219 Image
/mkfs
/jffs2-nand-
$(1) = \
220 $$(call Image
/mkfs
/jffs2
/sub
, \
221 $(word 2,$(subst -, ,$(1))), \
222 $(JFFS2OPTS
) --no-cleanmarkers
--pagesize
=$(word 1,$(subst -, ,$(1))),$$(1))
226 $(eval
$(foreach S
,$(JFFS2_BLOCKSIZE
),$(call Image
/mkfs
/jffs2
/template
,$(S
))))
227 $(eval
$(foreach S
,$(NAND_BLOCKSIZE
),$(call Image
/mkfs
/jffs2-nand
/template
,$(S
))))
229 define Image
/mkfs
/squashfs-common
230 $(STAGING_DIR_HOST
)/bin
/mksquashfs4
$(call mkfs_target_dir
,$(1)) $@ \
231 -nopad
-noappend
-root-owned \
232 -comp
$(SQUASHFSCOMP
) $(SQUASHFSOPT
) \
236 ifeq ($(CONFIG_TARGET_ROOTFS_SECURITY_LABELS
),y
)
237 define Image
/mkfs
/squashfs
238 echo
". $(call mkfs_target_dir,$(1))/etc/selinux/config" > $@.fakeroot-script
239 echo
"$(STAGING_DIR_HOST)/bin/setfiles -r" \
240 "$(call mkfs_target_dir,$(1))" \
241 "$(call mkfs_target_dir,$(1))/etc/selinux/\$${SELINUXTYPE}/contexts/files/file_contexts " \
242 "$(call mkfs_target_dir,$(1))" >> $@.fakeroot-script
243 echo
"$(Image/mkfs/squashfs-common)" >> $@.fakeroot-script
244 chmod
+x
$@.fakeroot-script
245 $(FAKEROOT
) "$@.fakeroot-script"
248 define Image
/mkfs
/squashfs
249 $(call Image
/mkfs
/squashfs-common
,$(1))
253 define Image
/mkfs
/ubifs
254 $(STAGING_DIR_HOST
)/bin
/mkfs.ubifs \
255 $(UBIFS_OPTS
) $(call param_unmangle
,$(call param_get
,fs
,$(1))) \
256 $(if
$(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP
),--space-fixup
) \
257 $(if
$(CONFIG_TARGET_UBIFS_COMPRESSION_NONE
),--compr
=none
) \
258 $(if
$(CONFIG_TARGET_UBIFS_COMPRESSION_LZO
),--compr
=lzo
) \
259 $(if
$(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB
),--compr
=zlib
) \
260 $(if
$(shell echo
$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE
)),--jrn-size
=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE
)) \
262 -o
$@
-d
$(call mkfs_target_dir
,$(1))
265 define Image
/mkfs
/ext4
266 $(STAGING_DIR_HOST
)/bin
/make_ext4fs
-L rootfs \
267 -l
$(ROOTFS_PARTSIZE
) -b
$(CONFIG_TARGET_EXT4_BLOCKSIZE
) \
268 $(if
$(CONFIG_TARGET_EXT4_RESERVED_PCT
),-m
$(CONFIG_TARGET_EXT4_RESERVED_PCT
)) \
269 $(if
$(CONFIG_TARGET_EXT4_JOURNAL
),,-J
) \
270 $(if
$(SOURCE_DATE_EPOCH
),-T
$(SOURCE_DATE_EPOCH
)) \
271 $@
$(call mkfs_target_dir
,$(1))/
274 define Image
/Manifest
275 $(call opkg
,$(TARGET_DIR_ORIG
)) list-installed
> \
276 $(BIN_DIR
)/$(IMG_PREFIX
)$(if
$(PROFILE_SANITIZED
),-$(PROFILE_SANITIZED
)).manifest
279 define Image
/gzip-ext4-padded-squashfs
281 define Image
/Build
/squashfs
282 $(call Image
/pad-root-squashfs
)
285 ifneq ($(CONFIG_TARGET_IMAGES_GZIP
),)
286 define Image
/Build
/gzip
/ext4
287 $(call Image
/Build
/gzip
,ext4
)
289 define Image
/Build
/gzip
/squashfs
290 $(call Image
/Build
/gzip
,squashfs
)
296 ifdef CONFIG_TARGET_ROOTFS_TARGZ
297 define Image
/Build
/targz
298 $(TAR
) -cp
--numeric-owner
--owner
=0 --group
=0 --mode
=a-s
--sort=name \
299 $(if
$(SOURCE_DATE_EPOCH
),--mtime
="@$(SOURCE_DATE_EPOCH)") \
300 -C
$(TARGET_DIR
)/ . | gzip
-9n
> $(BIN_DIR
)/$(IMG_PREFIX
)$(if
$(PROFILE_SANITIZED
),-$(PROFILE_SANITIZED
))-rootfs.
tar.gz
304 ifdef CONFIG_TARGET_ROOTFS_CPIOGZ
305 define Image
/Build
/cpiogz
306 ( cd
$(TARGET_DIR
); find . |
$(STAGING_DIR_HOST
)/bin
/cpio
-o
-H newc
-R
0:0 | gzip
-9n
>$(BIN_DIR
)/$(IMG_ROOTFS
).cpio.gz
)
310 mkfs_packages
= $(filter-out @
%,$(PACKAGES_
$(call param_get
,pkg
,pkg
=$(target_params
))))
311 mkfs_packages_add
= $(foreach pkg
,$(filter-out -%,$(mkfs_packages
)),$(pkg
)$(call GetABISuffix
,$(pkg
)))
312 mkfs_packages_remove
= $(foreach pkg
,$(patsubst -%,%,$(filter -%,$(mkfs_packages
))),$(pkg
)$(call GetABISuffix
,$(pkg
)))
313 mkfs_cur_target_dir
= $(call mkfs_target_dir
,pkg
=$(target_params
))
316 $(call opkg
,$(mkfs_cur_target_dir
)) \
317 -f
$(mkfs_cur_target_dir
).conf
320 rm -rf
$(mkfs_cur_target_dir
) $(mkfs_cur_target_dir
).opkg
321 $(CP
) $(TARGET_DIR_ORIG
) $(mkfs_cur_target_dir
)
322 -mv
$(mkfs_cur_target_dir
)/etc
/opkg
$(mkfs_cur_target_dir
).opkg
323 echo
'src default file://$(PACKAGE_DIR_ALL)' > $(mkfs_cur_target_dir
).conf
324 $(if
$(mkfs_packages_remove
), \
325 -$(call opkg
,$(mkfs_cur_target_dir
)) remove \
326 $(mkfs_packages_remove
))
327 $(if
$(call opkg_package_files
,$(mkfs_packages_add
)), \
328 $(opkg_target
) update
&& \
329 $(opkg_target
) install \
330 $(call opkg_package_files
,$(mkfs_packages_add
)))
331 -$(CP
) -T
$(mkfs_cur_target_dir
).opkg
/ $(mkfs_cur_target_dir
)/etc
/opkg
/
332 rm -rf
$(mkfs_cur_target_dir
).opkg
$(mkfs_cur_target_dir
).conf
333 $(call prepare_rootfs
,$(mkfs_cur_target_dir
),$(TOPDIR
)/files
)
335 $(KDIR
)/root.
%: kernel_prepare
336 $(call Image
/mkfs
/$(word 1,$(target_params
)),$(target_params
))
338 define Device
/InitProfile
339 PROFILES
:= $(PROFILE
)
340 DEVICE_TITLE
= $$(DEVICE_VENDOR
) $$(DEVICE_MODEL
)$$(if
$$(DEVICE_VARIANT
), $$(DEVICE_VARIANT
))
341 DEVICE_ALT0_TITLE
= $$(DEVICE_ALT0_VENDOR
) $$(DEVICE_ALT0_MODEL
)$$(if
$$(DEVICE_ALT0_VARIANT
), $$(DEVICE_ALT0_VARIANT
))
342 DEVICE_ALT1_TITLE
= $$(DEVICE_ALT1_VENDOR
) $$(DEVICE_ALT1_MODEL
)$$(if
$$(DEVICE_ALT1_VARIANT
), $$(DEVICE_ALT1_VARIANT
))
343 DEVICE_ALT2_TITLE
= $$(DEVICE_ALT2_VENDOR
) $$(DEVICE_ALT2_MODEL
)$$(if
$$(DEVICE_ALT2_VARIANT
), $$(DEVICE_ALT2_VARIANT
))
347 DEVICE_ALT0_VENDOR
:=
349 DEVICE_ALT0_VARIANT
:=
350 DEVICE_ALT1_VENDOR
:=
352 DEVICE_ALT1_VARIANT
:=
353 DEVICE_ALT2_VENDOR
:=
355 DEVICE_ALT2_VARIANT
:=
357 DEVICE_DESCRIPTION
= Build firmware images for
$$(DEVICE_TITLE
)
363 KERNEL_INITRAMFS
= $$(KERNEL
)
368 DEVICE_IMG_PREFIX
:= $(IMG_PREFIX
)-$(1)
369 DEVICE_IMG_NAME
= $$(DEVICE_IMG_PREFIX
)-$$(1)-$$(2)
371 KERNEL_PREFIX
= $$(DEVICE_IMG_PREFIX
)
372 KERNEL_SUFFIX
:= -kernel.bin
373 KERNEL_INITRAMFS_SUFFIX
= $$(KERNEL_SUFFIX
)
374 KERNEL_IMAGE
= $$(KERNEL_PREFIX
)$$(KERNEL_SUFFIX
)
375 KERNEL_INITRAMFS_PREFIX
= $$(DEVICE_IMG_PREFIX
)-initramfs
376 KERNEL_INITRAMFS_IMAGE
= $$(KERNEL_INITRAMFS_PREFIX
)$$(KERNEL_INITRAMFS_SUFFIX
)
377 KERNEL_INITRAMFS_NAME
= $$(KERNEL_NAME
)-initramfs
379 KERNEL_NAME
:= vmlinux
393 FS_OPTIONS
/ubifs
= $$(MKUBIFS_OPTS
)
398 DEVICE_DTS_OVERLAY
:=
405 DEVICE_COMPAT_VERSION
:= 1.0
406 DEVICE_COMPAT_MESSAGE
:=
407 SUPPORTED_DEVICES
:= $(subst _
,$(comma
),$(1))
410 FILESYSTEMS
:= $(TARGET_FILESYSTEMS
)
412 UBOOT_PATH
:= $(STAGING_DIR_IMAGE
)/uboot-
$(1)
418 DEFAULT_DEVICE_VARS
:= \
419 DEVICE_NAME KERNEL KERNEL_INITRAMFS KERNEL_INITRAMFS_IMAGE KERNEL_SIZE \
420 CMDLINE UBOOTENV_IN_UBI KERNEL_IN_UBI BLOCKSIZE PAGESIZE SUBPAGESIZE \
421 VID_HDR_OFFSET UBINIZE_OPTS UBINIZE_PARTS MKUBIFS_OPTS DEVICE_DTS \
422 DEVICE_DTS_CONFIG DEVICE_DTS_DIR DEVICE_DTS_OVERLAY DEVICE_FDT_NUM \
423 DEVICE_IMG_PREFIX SOC BOARD_NAME UIMAGE_MAGIC UIMAGE_NAME \
424 SUPPORTED_DEVICES IMAGE_METADATA KERNEL_ENTRY KERNEL_LOADADDR \
425 UBOOT_PATH IMAGE_SIZE \
426 DEVICE_PACKAGES DEVICE_COMPAT_VERSION DEVICE_COMPAT_MESSAGE \
427 DEVICE_VENDOR DEVICE_MODEL DEVICE_VARIANT \
428 DEVICE_ALT0_VENDOR DEVICE_ALT0_MODEL DEVICE_ALT0_VARIANT \
429 DEVICE_ALT1_VENDOR DEVICE_ALT1_MODEL DEVICE_ALT1_VARIANT \
430 DEVICE_ALT2_VENDOR DEVICE_ALT2_MODEL DEVICE_ALT2_VARIANT
432 define Device
/ExportVar
433 $(1) : $(2):=$$($(2))
437 $(foreach var
,$(DEVICE_VARS
) $(DEFAULT_DEVICE_VARS
),$(call Device
/ExportVar
,$(1),$(var
)))
438 $(1) : FILESYSTEM
:=$(2)
442 DEVICE_CHECK_PROFILE
= $(filter $(1),DEVICE_
$(PROFILE
) $(PROFILE
))
444 DEVICE_CHECK_PROFILE
= $(CONFIG_TARGET_
$(if
$(CONFIG_TARGET_MULTI_PROFILE
),DEVICE_
)$(call target_conf
,$(BOARD
)$(if
$(SUBTARGET
),_
$(SUBTARGET
)))_
$(1))
447 DEVICE_EXTRA_PACKAGES
= $(call qstrip
,$(CONFIG_TARGET_DEVICE_PACKAGES_
$(call target_conf
,$(BOARD
)$(if
$(SUBTARGET
),_
$(SUBTARGET
)))_DEVICE_
$(1)))
449 define merge_packages
452 $(1) := $$(strip $$(filter-out -$$(patsubst -%,%,$(pkg
)) $$(patsubst -%,%,$(pkg
)),$$($(1))) $(pkg
))
456 define Device
/Check
/Common
457 _PROFILE_SET
= $$(strip $$(foreach profile
,$$(PROFILES
) DEVICE_
$(1),$$(call DEVICE_CHECK_PROFILE
,$$(profile
))))
458 DEVICE_PACKAGES
+= $$(call extra_packages
,$$(DEVICE_PACKAGES
))
459 ifdef TARGET_PER_DEVICE_ROOTFS
460 $$(eval
$$(call merge_packages
,_PACKAGES
,$$(DEVICE_PACKAGES
) $$(call DEVICE_EXTRA_PACKAGES
,$(1))))
461 ROOTFS_ID
/$(1) := $$(if
$$(_PROFILE_SET
),$$(call mkfs_packages_id
,$$(_PACKAGES
)))
462 PACKAGES_
$$(ROOTFS_ID
/$(1)) := $$(_PACKAGES
)
467 $(Device
/Check
/Common
)
468 KDIR_KERNEL_IMAGE
:= $(KDIR
)/$(1)$$(KERNEL_SUFFIX
)
469 _TARGET
:= $$(if
$$(_PROFILE_SET
),install-images
,install-disabled
)
471 _COMPILE_TARGET
:= $$(if
$(CONFIG_IB
)$$(_PROFILE_SET
),compile
,compile-disabled
)
476 define Device
/Build
/initramfs
477 $(call Device
/Export
,$(KDIR
)/tmp
/$$(KERNEL_INITRAMFS_IMAGE
),$(1))
478 $$(_TARGET
): $$(if
$$(KERNEL_INITRAMFS
),$(BIN_DIR
)/$$(KERNEL_INITRAMFS_IMAGE
) \
479 $$(if
$$(CONFIG_JSON_OVERVIEW_IMAGE_INFO
), $(BUILD_DIR
)/json_info_files
/$$(KERNEL_INITRAMFS_IMAGE
).json
,))
481 $(KDIR
)/$$(KERNEL_INITRAMFS_NAME
):: image_prepare
482 $(1)-images
: $$(if
$$(KERNEL_INITRAMFS
),$(BIN_DIR
)/$$(KERNEL_INITRAMFS_IMAGE
))
483 $(BIN_DIR
)/$$(KERNEL_INITRAMFS_IMAGE
): $(KDIR
)/tmp
/$$(KERNEL_INITRAMFS_IMAGE
)
486 $(KDIR
)/tmp
/$$(KERNEL_INITRAMFS_IMAGE
): $(KDIR
)/$$(KERNEL_INITRAMFS_NAME
) $(CURDIR
)/Makefile
$$(KERNEL_DEPENDS
) image_prepare
488 $$(call concat_cmd
,$$(KERNEL_INITRAMFS
))
490 $(call Device
/Export
,$(BUILD_DIR
)/json_info_files
/$$(KERNEL_INITRAMFS_IMAGE
).json
,$(1))
492 $(BUILD_DIR
)/json_info_files
/$$(KERNEL_INITRAMFS_IMAGE
).json
: $(BIN_DIR
)/$$(KERNEL_INITRAMFS_IMAGE
)
493 @mkdir
-p
$$(shell dirname
$$@
)
495 BIN_DIR
="$(BIN_DIR)" \
496 SOURCE_DATE_EPOCH
=$(SOURCE_DATE_EPOCH
) \
497 FILE_NAME
="$$(notdir $$^)" \
499 FILE_FILESYSTEM
="initramfs" \
500 DEVICE_IMG_PREFIX
="$$(DEVICE_IMG_PREFIX)" \
501 DEVICE_VENDOR
="$$(DEVICE_VENDOR)" \
502 DEVICE_MODEL
="$$(DEVICE_MODEL)" \
503 DEVICE_VARIANT
="$$(DEVICE_VARIANT)" \
504 DEVICE_ALT0_VENDOR
="$$(DEVICE_ALT0_VENDOR)" \
505 DEVICE_ALT0_MODEL
="$$(DEVICE_ALT0_MODEL)" \
506 DEVICE_ALT0_VARIANT
="$$(DEVICE_ALT0_VARIANT)" \
507 DEVICE_ALT1_VENDOR
="$$(DEVICE_ALT1_VENDOR)" \
508 DEVICE_ALT1_MODEL
="$$(DEVICE_ALT1_MODEL)" \
509 DEVICE_ALT1_VARIANT
="$$(DEVICE_ALT1_VARIANT)" \
510 DEVICE_ALT2_VENDOR
="$$(DEVICE_ALT2_VENDOR)" \
511 DEVICE_ALT2_MODEL
="$$(DEVICE_ALT2_MODEL)" \
512 DEVICE_ALT2_VARIANT
="$$(DEVICE_ALT2_VARIANT)" \
513 DEVICE_TITLE
="$$(DEVICE_TITLE)" \
514 DEVICE_PACKAGES
="$$(DEVICE_PACKAGES)" \
516 SUBTARGET
="$(if $(SUBTARGET),$(SUBTARGET),generic)" \
517 VERSION_NUMBER
="$(VERSION_NUMBER)" \
518 VERSION_CODE
="$(VERSION_CODE)" \
519 SUPPORTED_DEVICES
="$$(SUPPORTED_DEVICES)" \
520 $(TOPDIR
)/scripts
/json_add_image_info.py
$$@
524 define Device
/Build
/compile
525 $$(_COMPILE_TARGET
): $(KDIR
)/$(1)
526 $(eval
$(call Device
/Export
,$(KDIR
)/$(1)))
528 $$(call concat_cmd
,$(COMPILE
/$(1)))
533 define Device
/Build
/dtb
534 ifndef BUILD_DTS_
$(1)
536 $(KDIR
)/image-
$(1).dtb
: FORCE
537 $(call Image
/BuildDTB
,$(strip $(2))/$(strip $(3)).dts
,$$@
)
539 image_prepare
: $(KDIR
)/image-
$(1).dtb
545 define Device
/Build
/kernel
546 $$(eval
$$(foreach dts
,$$(DEVICE_DTS
) $$(DEVICE_DTS_OVERLAY
), \
547 $$(call Device
/Build
/dtb
,$$(notdir $$(dts
)), \
548 $$(if
$$(DEVICE_DTS_DIR
),$$(DEVICE_DTS_DIR
),$$(DTS_DIR
)), \
553 $(KDIR
)/$$(KERNEL_NAME
):: image_prepare
554 $$(_TARGET
): $$(if
$$(KERNEL_INSTALL
),$(BIN_DIR
)/$$(KERNEL_IMAGE
))
555 $(call Device
/Export
,$$(KDIR_KERNEL_IMAGE
),$(1))
556 $(BIN_DIR
)/$$(KERNEL_IMAGE
): $$(KDIR_KERNEL_IMAGE
)
560 install: $$(KDIR_KERNEL_IMAGE
)
562 $$(KDIR_KERNEL_IMAGE
): $(KDIR
)/$$(KERNEL_NAME
) $(CURDIR
)/Makefile
$$(KERNEL_DEPENDS
) image_prepare
564 $$(call concat_cmd
,$$(KERNEL
))
565 $$(if
$$(KERNEL_SIZE
),$$(call Build
/check-size
,$$(KERNEL_SIZE
)))
569 define Device
/Build
/image
570 GZ_SUFFIX
:= $(if
$(filter %dtb
%gz
,$(2)),,$(if
$(and
$(findstring ext4
,$(1)),$(CONFIG_TARGET_IMAGES_GZIP
)),.gz
))
571 $$(_TARGET
): $(if
$(CONFIG_JSON_OVERVIEW_IMAGE_INFO
), \
572 $(BUILD_DIR
)/json_info_files
/$(call DEVICE_IMG_NAME
,$(1),$(2)).json
, \
573 $(BIN_DIR
)/$(call DEVICE_IMG_NAME
,$(1),$(2))$$(GZ_SUFFIX
))
574 $(eval
$(call Device
/Export
,$(KDIR
)/tmp
/$(call DEVICE_IMG_NAME
,$(1),$(2)),$(1)))
575 $(3)-images
: $(BIN_DIR
)/$(call DEVICE_IMG_NAME
,$(1),$(2))$$(GZ_SUFFIX
)
577 ROOTFS
/$(1)/$(3) := \
578 $(KDIR
)/root.
$(1)$$(strip \
579 $$(if
$$(FS_OPTIONS
/$(1)),+fs
=$$(call param_mangle
,$$(FS_OPTIONS
/$(1)))) \
581 $(if
$(TARGET_PER_DEVICE_ROOTFS
),+pkg
=$$(ROOTFS_ID
/$(3))) \
584 $$(ROOTFS
/$(1)/$(3)): $(if
$(TARGET_PER_DEVICE_ROOTFS
),target-dir-
$$(ROOTFS_ID
/$(3)))
586 $(KDIR
)/tmp
/$(call DEVICE_IMG_NAME
,$(1),$(2)): $$(KDIR_KERNEL_IMAGE
) $$(ROOTFS
/$(1)/$(3))
588 [ -f
$$(word 1,$$^
) -a
-f
$$(word 2,$$^
) ]
589 $$(call concat_cmd
,$(if
$(IMAGE
/$(2)/$(1)),$(IMAGE
/$(2)/$(1)),$(IMAGE
/$(2))))
591 .IGNORE
: $(BIN_DIR
)/$(call DEVICE_IMG_NAME
,$(1),$(2))
593 $(BIN_DIR
)/$(call DEVICE_IMG_NAME
,$(1),$(2)).gz
: $(KDIR
)/tmp
/$(call DEVICE_IMG_NAME
,$(1),$(2))
594 gzip
-c
-9n
$$^
> $$@
596 $(BIN_DIR
)/$(call DEVICE_IMG_NAME
,$(1),$(2)): $(KDIR
)/tmp
/$(call DEVICE_IMG_NAME
,$(1),$(2))
599 $(BUILD_DIR
)/json_info_files
/$(call DEVICE_IMG_NAME
,$(1),$(2)).json
: $(BIN_DIR
)/$(call DEVICE_IMG_NAME
,$(1),$(2))$$(GZ_SUFFIX
)
600 @mkdir
-p
$$(shell dirname
$$@
)
601 DEVICE_ID
="$(DEVICE_NAME)" \
602 BIN_DIR
="$(BIN_DIR)" \
603 SOURCE_DATE_EPOCH
=$(SOURCE_DATE_EPOCH
) \
604 FILE_NAME
="$(DEVICE_IMG_NAME)" \
605 FILE_TYPE
=$(word 1,$(subst .
, ,$(2))) \
606 FILE_FILESYSTEM
="$(1)" \
607 DEVICE_IMG_PREFIX
="$(DEVICE_IMG_PREFIX)" \
608 DEVICE_VENDOR
="$(DEVICE_VENDOR)" \
609 DEVICE_MODEL
="$(DEVICE_MODEL)" \
610 DEVICE_VARIANT
="$(DEVICE_VARIANT)" \
611 DEVICE_ALT0_VENDOR
="$(DEVICE_ALT0_VENDOR)" \
612 DEVICE_ALT0_MODEL
="$(DEVICE_ALT0_MODEL)" \
613 DEVICE_ALT0_VARIANT
="$(DEVICE_ALT0_VARIANT)" \
614 DEVICE_ALT1_VENDOR
="$(DEVICE_ALT1_VENDOR)" \
615 DEVICE_ALT1_MODEL
="$(DEVICE_ALT1_MODEL)" \
616 DEVICE_ALT1_VARIANT
="$(DEVICE_ALT1_VARIANT)" \
617 DEVICE_ALT2_VENDOR
="$(DEVICE_ALT2_VENDOR)" \
618 DEVICE_ALT2_MODEL
="$(DEVICE_ALT2_MODEL)" \
619 DEVICE_ALT2_VARIANT
="$(DEVICE_ALT2_VARIANT)" \
620 DEVICE_TITLE
="$(DEVICE_TITLE)" \
621 DEVICE_PACKAGES
="$(DEVICE_PACKAGES)" \
623 SUBTARGET
="$(if $(SUBTARGET),$(SUBTARGET),generic)" \
624 VERSION_NUMBER
="$(VERSION_NUMBER)" \
625 VERSION_CODE
="$(VERSION_CODE)" \
626 SUPPORTED_DEVICES
="$(SUPPORTED_DEVICES)" \
627 $(TOPDIR
)/scripts
/json_add_image_info.py
$$@
631 define Device
/Build
/artifact
632 $$(_TARGET
): $(if
$(CONFIG_JSON_OVERVIEW_IMAGE_INFO
), \
633 $(BUILD_DIR
)/json_info_files
/$(DEVICE_IMG_PREFIX
)-$(1).json
, \
634 $(BIN_DIR
)/$(DEVICE_IMG_PREFIX
)-$(1))
635 $(eval
$(call Device
/Export
,$(KDIR
)/tmp
/$(DEVICE_IMG_PREFIX
)-$(1)))
636 $(KDIR
)/tmp
/$(DEVICE_IMG_PREFIX
)-$(1): $$(KDIR_KERNEL_IMAGE
) $(2)-images
638 $$(call concat_cmd
,$(ARTIFACT
/$(1)))
640 .IGNORE
: $(BIN_DIR
)/$(DEVICE_IMG_PREFIX
)-$(1)
642 $(BIN_DIR
)/$(DEVICE_IMG_PREFIX
)-$(1): $(KDIR
)/tmp
/$(DEVICE_IMG_PREFIX
)-$(1)
645 $(BUILD_DIR
)/json_info_files
/$(DEVICE_IMG_PREFIX
)-$(1).json
: $(BIN_DIR
)/$(DEVICE_IMG_PREFIX
)-$(1)
646 @mkdir
-p
$$(shell dirname
$$@
)
647 DEVICE_ID
="$(DEVICE_NAME)" \
648 BIN_DIR
="$(BIN_DIR)" \
649 SOURCE_DATE_EPOCH
=$(SOURCE_DATE_EPOCH
) \
650 FILE_NAME
="$(DEVICE_IMG_PREFIX)-$(1)" \
652 DEVICE_IMG_PREFIX
="$(DEVICE_IMG_PREFIX)" \
653 DEVICE_VENDOR
="$(DEVICE_VENDOR)" \
654 DEVICE_MODEL
="$(DEVICE_MODEL)" \
655 DEVICE_VARIANT
="$(DEVICE_VARIANT)" \
656 DEVICE_ALT0_VENDOR
="$(DEVICE_ALT0_VENDOR)" \
657 DEVICE_ALT0_MODEL
="$(DEVICE_ALT0_MODEL)" \
658 DEVICE_ALT0_VARIANT
="$(DEVICE_ALT0_VARIANT)" \
659 DEVICE_ALT1_VENDOR
="$(DEVICE_ALT1_VENDOR)" \
660 DEVICE_ALT1_MODEL
="$(DEVICE_ALT1_MODEL)" \
661 DEVICE_ALT1_VARIANT
="$(DEVICE_ALT1_VARIANT)" \
662 DEVICE_ALT2_VENDOR
="$(DEVICE_ALT2_VENDOR)" \
663 DEVICE_ALT2_MODEL
="$(DEVICE_ALT2_MODEL)" \
664 DEVICE_ALT2_VARIANT
="$(DEVICE_ALT2_VARIANT)" \
665 DEVICE_TITLE
="$(DEVICE_TITLE)" \
666 DEVICE_PACKAGES
="$(DEVICE_PACKAGES)" \
668 SUBTARGET
="$(if $(SUBTARGET),$(SUBTARGET),generic)" \
669 VERSION_NUMBER
="$(VERSION_NUMBER)" \
670 VERSION_CODE
="$(VERSION_CODE)" \
671 SUPPORTED_DEVICES
="$(SUPPORTED_DEVICES)" \
672 $(TOPDIR
)/scripts
/json_add_image_info.py
$$@
677 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),$(call Device
/Build
/initramfs
,$(1)))
678 $(call Device
/Build
/kernel
,$(1))
680 $$(eval
$$(foreach compile
,$$(COMPILE
), \
681 $$(call Device
/Build
/compile
,$$(compile
),$(1))))
683 $$(eval
$$(foreach image
,$$(IMAGES
), \
684 $$(foreach fs
,$$(filter $(TARGET_FILESYSTEMS
),$$(FILESYSTEMS
)), \
685 $$(call Device
/Build
/image
,$$(fs
),$$(image
),$(1)))))
687 $$(eval
$$(foreach artifact
,$$(ARTIFACTS
), \
688 $$(call Device
/Build
/artifact
,$$(artifact
),$(1))))
692 define Device
/DumpInfo
693 Target-Profile
: DEVICE_
$(1)
694 Target-Profile-Name
: $(DEVICE_DISPLAY
)
695 Target-Profile-Packages
: $(DEVICE_PACKAGES
)
696 Target-Profile-hasImageMetadata
: $(if
$(foreach image
,$(IMAGES
),$(findstring append-metadata
,$(IMAGE
/$(image
)))),1,0)
697 Target-Profile-SupportedDevices
: $(SUPPORTED_DEVICES
)
698 $(if
$(BROKEN
),Target-Profile-Broken
: $(BROKEN
))
699 $(if
$(DEFAULT
),Target-Profile-Default
: $(DEFAULT
))
700 Target-Profile-Description
:
701 $(DEVICE_DESCRIPTION
)
702 $(if
$(strip $(DEVICE_ALT0_TITLE
)),Alternative device titles
:
703 - $(DEVICE_ALT0_TITLE
))
704 $(if
$(strip $(DEVICE_ALT1_TITLE
)),- $(DEVICE_ALT1_TITLE
))
705 $(if
$(strip $(DEVICE_ALT2_TITLE
)),- $(DEVICE_ALT2_TITLE
))
711 ifneq ($$(strip $$(DEVICE_ALT0_TITLE
)),)
712 DEVICE_DISPLAY
= $$(DEVICE_ALT0_TITLE
) ($$(DEVICE_TITLE
))
713 $$(info $$(call Device
/DumpInfo
,$(1)))
715 ifneq ($$(strip $$(DEVICE_ALT1_TITLE
)),)
716 DEVICE_DISPLAY
= $$(DEVICE_ALT1_TITLE
) ($$(DEVICE_TITLE
))
717 $$(info $$(call Device
/DumpInfo
,$(1)))
719 ifneq ($$(strip $$(DEVICE_ALT2_TITLE
)),)
720 DEVICE_DISPLAY
= $$(DEVICE_ALT2_TITLE
) ($$(DEVICE_TITLE
))
721 $$(info $$(call Device
/DumpInfo
,$(1)))
723 DEVICE_DISPLAY
= $$(DEVICE_TITLE
)
724 $$(eval
$$(if
$$(DEVICE_TITLE
),$$(info $$(call Device
/DumpInfo
,$(1)))))
728 $(call Device
/InitProfile
,$(1))
729 $(call Device
/Init
,$(1))
730 $(call Device
/Default
,$(1))
731 $(call Device
/$(1),$(1))
732 $(call Device
/Check
,$(1))
733 $(call Device
/$(if
$(DUMP
),Dump
,Build
),$(1))
752 .PHONY
: download prepare compile
clean image_prepare kernel_prepare
install install-images
754 $(call Build
/Compile
)
759 image_prepare
: compile
760 mkdir
-p
$(BIN_DIR
) $(KDIR
)/tmp
761 rm -rf
$(BUILD_DIR
)/json_info_files
762 $(call Image
/Prepare
)
766 mkdir
-p
$(BIN_DIR
) $(KDIR
)/tmp
769 kernel_prepare
: image_prepare
770 $(call Image
/Build
/targz
)
771 $(call Image
/Build
/cpiogz
)
772 $(call Image
/BuildKernel
)
773 $(if
$(CONFIG_TARGET_ROOTFS_INITRAMFS
),$(if
$(IB
),,$(call Image
/BuildKernel
/Initramfs
)))
774 $(call Image
/InstallKernel
)
776 $(foreach device
,$(TARGET_DEVICES
),$(call Device
,$(device
)))
778 install-images
: kernel_prepare
$(foreach fs
,$(filter-out $(if
$(UBIFS_OPTS
),,ubifs
),$(TARGET_FILESYSTEMS
) $(fs-subtypes-y
)),$(KDIR
)/root.
$(fs
))
779 $(foreach fs
,$(TARGET_FILESYSTEMS
),
780 $(call Image
/Build
,$(fs
))
783 install: install-images
784 $(call Image
/Manifest
)