blob: e767f019accfa6a90374a270056739d09e93b920 [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
Alain Knaffa26ee602009-01-07 00:10:27 -08008
Alain Knaffa26ee602009-01-07 00:10:27 -08009# Bzip2
P J P9ba4bcb2013-11-12 15:10:22 -080010suffix_$(CONFIG_RD_BZIP2) = .bz2
Alain Knaffa26ee602009-01-07 00:10:27 -080011
Alain Knaffab76f3d2009-02-19 13:43:51 -080012# Lzma
P J P9ba4bcb2013-11-12 15:10:22 -080013suffix_$(CONFIG_RD_LZMA) = .lzma
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020014
Lasse Collin3ebe1242011-01-12 17:01:23 -080015# XZ
P J P9ba4bcb2013-11-12 15:10:22 -080016suffix_$(CONFIG_RD_XZ) = .xz
Lasse Collin3ebe1242011-01-12 17:01:23 -080017
Albin Tonnerre2a2a4002010-05-26 14:44:28 -070018# Lzo
P J P9ba4bcb2013-11-12 15:10:22 -080019suffix_$(CONFIG_RD_LZO) = .lzo
20
21# Lz4
22suffix_$(CONFIG_RD_LZ4) = .lz4
23
24# Gzip
25suffix_$(CONFIG_RD_GZIP) = .gz
Albin Tonnerre2a2a4002010-05-26 14:44:28 -070026
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070027AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
28
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020029# Generate builtin.o based on initramfs_data.o
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070030obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Alain Knaffa26ee602009-01-07 00:10:27 -080032# initramfs_data.o contains the compressed initramfs_data.cpio image.
Linus Torvalds1da177e2005-04-16 15:20:36 -070033# The image is included using .incbin, a dependency which is not
34# tracked automatically.
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070035$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020037#####
38# Generate the initramfs cpio archive
39
40hostprogs-y := gen_init_cpio
41initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
42ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
Thomas Choua26d79c2006-11-25 11:09:18 -080043 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020044ramfs-args := \
45 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
Nickolayff541712006-06-09 21:24:14 +040046 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020047
Alain Knaffa26ee602009-01-07 00:10:27 -080048# .initramfs_data.cpio.d is used to identify all files included
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020049# in initramfs and to detect if any files are added/removed.
50# Removed files are identified by directory timestamp being updated
51# The dependency list is generated by gen_initramfs.sh -l
Alain Knaffa26ee602009-01-07 00:10:27 -080052ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
53 include $(obj)/.initramfs_data.cpio.d
Linus Torvalds1da177e2005-04-16 15:20:36 -070054endif
55
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020056quiet_cmd_initfs = GEN $@
57 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
P J P9ba4bcb2013-11-12 15:10:22 -080059targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
60 initramfs_data.cpio.lzma initramfs_data.cpio.xz \
61 initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
62 initramfs_data.cpio
Sam Ravnborg58a2f7d2006-08-07 20:58:28 +020063# do not try to update files included in initramfs
64$(deps_initramfs): ;
65
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020066$(deps_initramfs): klibcdirs
Alain Knaffa26ee602009-01-07 00:10:27 -080067# We rebuild initramfs_data.cpio if:
68# 1) Any included file is newer then initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020069# 2) There are changes in which files are included (added or deleted)
Alain Knaffa26ee602009-01-07 00:10:27 -080070# 3) If gen_init_cpio are newer than initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020071# 4) arguments to gen_initramfs.sh changes
Alain Knaffa26ee602009-01-07 00:10:27 -080072$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
73 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020074 $(call if_changed,initfs)