blob: 17a513268325d197b76aa36d7c26c337a70b9a4d [file] [log] [blame]
Sam Ravnborgd39a206b2006-04-11 13:24:32 +02001#
2# kbuild file for usr/ - including initramfs image
3#
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Sam Ravnborgd39a206b2006-04-11 13:24:32 +02005klibcdirs:;
Sam Ravnborg48f1f052006-07-23 19:37:44 +02006PHONY += klibcdirs
7
Francisco Blas Izquierdo Riera (klondike)35e669e2016-12-14 15:06:01 -08008suffix_y = $(CONFIG_INITRAMFS_COMPRESSION)
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -07009AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
10
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020011# Generate builtin.o based on initramfs_data.o
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070012obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Alain Knaffa26ee602009-01-07 00:10:27 -080014# initramfs_data.o contains the compressed initramfs_data.cpio image.
Linus Torvalds1da177e2005-04-16 15:20:36 -070015# The image is included using .incbin, a dependency which is not
16# tracked automatically.
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070017$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020019#####
20# Generate the initramfs cpio archive
21
22hostprogs-y := gen_init_cpio
23initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
24ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
Thomas Choua26d79c2006-11-25 11:09:18 -080025 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020026ramfs-args := \
27 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
Nickolayff541712006-06-09 21:24:14 +040028 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020029
Alain Knaffa26ee602009-01-07 00:10:27 -080030# .initramfs_data.cpio.d is used to identify all files included
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020031# in initramfs and to detect if any files are added/removed.
32# Removed files are identified by directory timestamp being updated
33# The dependency list is generated by gen_initramfs.sh -l
Alain Knaffa26ee602009-01-07 00:10:27 -080034ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
35 include $(obj)/.initramfs_data.cpio.d
Linus Torvalds1da177e2005-04-16 15:20:36 -070036endif
37
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020038quiet_cmd_initfs = GEN $@
39 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
P J P9ba4bcb2013-11-12 15:10:22 -080041targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
42 initramfs_data.cpio.lzma initramfs_data.cpio.xz \
43 initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
44 initramfs_data.cpio
Sam Ravnborg58a2f7d2006-08-07 20:58:28 +020045# do not try to update files included in initramfs
46$(deps_initramfs): ;
47
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020048$(deps_initramfs): klibcdirs
Alain Knaffa26ee602009-01-07 00:10:27 -080049# We rebuild initramfs_data.cpio if:
50# 1) Any included file is newer then initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020051# 2) There are changes in which files are included (added or deleted)
Alain Knaffa26ee602009-01-07 00:10:27 -080052# 3) If gen_init_cpio are newer than initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020053# 4) arguments to gen_initramfs.sh changes
Alain Knaffa26ee602009-01-07 00:10:27 -080054$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
55 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020056 $(call if_changed,initfs)