Makefile (2fc2991175bf77395e6b15fe6b2304d3bf72da40) | Makefile (d39a206bc35d46a3b2eb98cd4f34e340d5e56a50) |
---|---|
1# 2# kbuild file for usr/ - including initramfs image 3# |
|
1 | 4 |
5klibcdirs:; 6 7# Generate builtin.o based on initramfs_data.o |
|
2obj-y := initramfs_data.o 3 | 8obj-y := initramfs_data.o 9 |
4hostprogs-y := gen_init_cpio 5 6clean-files := initramfs_data.cpio.gz initramfs_list 7 | |
8# initramfs_data.o contains the initramfs_data.cpio.gz image. 9# The image is included using .incbin, a dependency which is not 10# tracked automatically. 11$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE 12 | 10# initramfs_data.o contains the initramfs_data.cpio.gz image. 11# The image is included using .incbin, a dependency which is not 12# tracked automatically. 13$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE 14 |
13ifdef CONFIG_INITRAMFS_ROOT_UID 14gen_initramfs_args += -u $(CONFIG_INITRAMFS_ROOT_UID) 15endif | 15##### 16# Generate the initramfs cpio archive |
16 | 17 |
17ifdef CONFIG_INITRAMFS_ROOT_GID 18gen_initramfs_args += -g $(CONFIG_INITRAMFS_ROOT_GID) 19endif | 18hostprogs-y := gen_init_cpio 19initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh 20ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ 21 $(CONFIG_INITRAMFS_SOURCE),-d) 22ramfs-args := \ 23 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ 24 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \ 25 $(ramfs-input) |
20 | 26 |
21# The $(shell echo $(CONFIG_INITRAMFS_SOURCE)) is to remove the 22# gratuitous begin and end quotes from the Kconfig string type. 23# Internal, escaped quotes in the Kconfig string will loose the 24# escape and become active quotes. 25quotefixed_initramfs_source := $(shell echo $(CONFIG_INITRAMFS_SOURCE)) 26 27filechk_initramfs_list = $(CONFIG_SHELL) \ 28 $(srctree)/scripts/gen_initramfs_list.sh $(gen_initramfs_args) $(quotefixed_initramfs_source) 29 30$(obj)/initramfs_list: $(obj)/Makefile FORCE 31 $(call filechk,initramfs_list) 32 33quiet_cmd_cpio = CPIO $@ 34 cmd_cpio = ./$< $(obj)/initramfs_list > $@ 35 36 37# Check if the INITRAMFS_SOURCE is a cpio archive 38ifneq (,$(findstring .cpio,$(quotefixed_initramfs_source))) 39 40# INITRAMFS_SOURCE has a cpio archive - verify that it's a single file 41ifneq (1,$(words $(quotefixed_initramfs_source))) 42$(error Only a single file may be specified in CONFIG_INITRAMFS_SOURCE (="$(quotefixed_initramfs_source)") when a cpio archive is directly specified.) | 27# .initramfs_data.cpio.gz.d is used to identify all files included 28# in initramfs and to detect if any files are added/removed. 29# Removed files are identified by directory timestamp being updated 30# The dependency list is generated by gen_initramfs.sh -l 31ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),) 32 include $(obj)/.initramfs_data.cpio.gz.d |
43endif | 33endif |
44# Now use the cpio archive directly 45initramfs_data_cpio = $(quotefixed_initramfs_source) 46targets += $(quotefixed_initramfs_source) | |
47 | 34 |
48else | 35quiet_cmd_initfs = GEN $@ 36 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) |
49 | 37 |
50# INITRAMFS_SOURCE is not a cpio archive - create one 51$(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio \ 52 $(initramfs-y) $(obj)/initramfs_list FORCE 53 $(call if_changed,cpio) | 38targets := initramfs_data.cpio.gz 39$(deps_initramfs): klibcdirs 40# We rebuild initramfs_data.cpio.gz if: 41# 1) Any included file is newer then initramfs_data.cpio.gz 42# 2) There are changes in which files are included (added or deleted) 43# 3) If gen_init_cpio are newer than initramfs_data.cpio.gz 44# 4) arguments to gen_initramfs.sh changes 45$(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs 46 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d 47 $(call if_changed,initfs) |
54 | 48 |
55targets += initramfs_data.cpio 56initramfs_data_cpio = $(obj)/initramfs_data.cpio 57 58endif 59 60 61$(obj)/initramfs_data.cpio.gz: $(initramfs_data_cpio) FORCE 62 $(call if_changed,gzip) 63 64targets += initramfs_data.cpio.gz 65 | |