Back to home page

LXR

 
 

    


0001 #
0002 # kbuild file for usr/ - including initramfs image
0003 #
0004 
0005 klibcdirs:;
0006 PHONY += klibcdirs
0007 
0008 suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
0009 datafile_y = initramfs_data.cpio$(suffix_y)
0010 AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)"
0011 
0012 
0013 # Generate builtin.o based on initramfs_data.o
0014 obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
0015 
0016 # initramfs_data.o contains the compressed initramfs_data.cpio image.
0017 # The image is included using .incbin, a dependency which is not
0018 # tracked automatically.
0019 $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
0020 
0021 #####
0022 # Generate the initramfs cpio archive
0023 
0024 hostprogs-y := gen_init_cpio
0025 initramfs   := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
0026 ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
0027                         $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
0028 ramfs-args  := \
0029         $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
0030         $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
0031 
0032 # .initramfs_data.cpio.d is used to identify all files included
0033 # in initramfs and to detect if any files are added/removed.
0034 # Removed files are identified by directory timestamp being updated
0035 # The dependency list is generated by gen_initramfs.sh -l
0036 ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
0037         include $(obj)/.initramfs_data.cpio.d
0038 endif
0039 
0040 quiet_cmd_initfs = GEN     $@
0041       cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
0042 
0043 targets := $(datafile_y)
0044 
0045 # do not try to update files included in initramfs
0046 $(deps_initramfs): ;
0047 
0048 $(deps_initramfs): klibcdirs
0049 # We rebuild initramfs_data.cpio if:
0050 # 1) Any included file is newer then initramfs_data.cpio
0051 # 2) There are changes in which files are included (added or deleted)
0052 # 3) If gen_init_cpio are newer than initramfs_data.cpio
0053 # 4) arguments to gen_initramfs.sh changes
0054 $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
0055         $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
0056         $(call if_changed,initfs)