|
|
f2d475 |
# SPDX-License-Identifier: GPL-2.0
|
|
|
f2d475 |
#
|
|
|
f2d475 |
# kbuild file for usr/ - including initramfs image
|
|
|
f2d475 |
#
|
|
|
f2d475 |
|
|
|
f2d475 |
klibcdirs:;
|
|
|
f2d475 |
PHONY += klibcdirs
|
|
|
f2d475 |
|
|
|
f2d475 |
suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
|
|
|
f2d475 |
datafile_y = initramfs_data.cpio$(suffix_y)
|
|
|
f2d475 |
datafile_d_y = .$(datafile_y).d
|
|
|
f2d475 |
AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)"
|
|
|
f2d475 |
|
|
|
f2d475 |
|
|
|
f2d475 |
# Generate builtin.o based on initramfs_data.o
|
|
|
f2d475 |
obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
|
|
|
f2d475 |
|
|
|
f2d475 |
# initramfs_data.o contains the compressed initramfs_data.cpio image.
|
|
|
f2d475 |
# The image is included using .incbin, a dependency which is not
|
|
|
f2d475 |
# tracked automatically.
|
|
|
f2d475 |
$(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
|
|
|
f2d475 |
|
|
|
f2d475 |
#####
|
|
|
f2d475 |
# Generate the initramfs cpio archive
|
|
|
f2d475 |
|
|
|
f2d475 |
hostprogs-y := gen_init_cpio
|
|
|
f2d475 |
initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
|
|
|
f2d475 |
ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
|
|
|
f2d475 |
$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
|
|
|
f2d475 |
ramfs-args := \
|
|
|
f2d475 |
$(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
|
|
|
f2d475 |
$(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
|
|
|
f2d475 |
|
|
|
f2d475 |
# $(datafile_d_y) is used to identify all files included
|
|
|
f2d475 |
# in initramfs and to detect if any files are added/removed.
|
|
|
f2d475 |
# Removed files are identified by directory timestamp being updated
|
|
|
f2d475 |
# The dependency list is generated by gen_initramfs.sh -l
|
|
|
f2d475 |
ifneq ($(wildcard $(obj)/$(datafile_d_y)),)
|
|
|
f2d475 |
include $(obj)/$(datafile_d_y)
|
|
|
f2d475 |
endif
|
|
|
f2d475 |
|
|
|
f2d475 |
quiet_cmd_initfs = GEN $@
|
|
|
f2d475 |
cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
|
|
|
f2d475 |
|
|
|
f2d475 |
targets := $(datafile_y)
|
|
|
f2d475 |
|
|
|
f2d475 |
# do not try to update files included in initramfs
|
|
|
f2d475 |
$(deps_initramfs): ;
|
|
|
f2d475 |
|
|
|
f2d475 |
$(deps_initramfs): klibcdirs
|
|
|
f2d475 |
# We rebuild initramfs_data.cpio if:
|
|
|
f2d475 |
# 1) Any included file is newer then initramfs_data.cpio
|
|
|
f2d475 |
# 2) There are changes in which files are included (added or deleted)
|
|
|
f2d475 |
# 3) If gen_init_cpio are newer than initramfs_data.cpio
|
|
|
f2d475 |
# 4) arguments to gen_initramfs.sh changes
|
|
|
f2d475 |
$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
|
|
|
f2d475 |
$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y)
|
|
|
f2d475 |
$(call if_changed,initfs)
|