blob: 029ffe6cd0d8c309404b81626d1ee5d7f62ce1a0 [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
Robert P. J. Day0bc9f9e2009-07-05 09:46:19 -04009# Gzip
Alain Knaffab76f3d2009-02-19 13:43:51 -080010suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz
Alain Knaffa26ee602009-01-07 00:10:27 -080011
12# Bzip2
Alain Knaffab76f3d2009-02-19 13:43:51 -080013suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2
Alain Knaffa26ee602009-01-07 00:10:27 -080014
Alain Knaffab76f3d2009-02-19 13:43:51 -080015# Lzma
16suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020017
Lasse Collin3ebe1242011-01-12 17:01:23 -080018# XZ
19suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ) = .xz
20
Albin Tonnerre2a2a4002010-05-26 14:44:28 -070021# Lzo
22suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo
23
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070024AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
25
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020026# Generate builtin.o based on initramfs_data.o
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070027obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Alain Knaffa26ee602009-01-07 00:10:27 -080029# initramfs_data.o contains the compressed initramfs_data.cpio image.
Linus Torvalds1da177e2005-04-16 15:20:36 -070030# The image is included using .incbin, a dependency which is not
31# tracked automatically.
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070032$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020034#####
35# Generate the initramfs cpio archive
36
37hostprogs-y := gen_init_cpio
38initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
39ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
Thomas Choua26d79c2006-11-25 11:09:18 -080040 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020041ramfs-args := \
42 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
Nickolayff541712006-06-09 21:24:14 +040043 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020044
Alain Knaffa26ee602009-01-07 00:10:27 -080045# .initramfs_data.cpio.d is used to identify all files included
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020046# in initramfs and to detect if any files are added/removed.
47# Removed files are identified by directory timestamp being updated
48# The dependency list is generated by gen_initramfs.sh -l
Alain Knaffa26ee602009-01-07 00:10:27 -080049ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
50 include $(obj)/.initramfs_data.cpio.d
Linus Torvalds1da177e2005-04-16 15:20:36 -070051endif
52
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020053quiet_cmd_initfs = GEN $@
54 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Lasse Collin3ebe1242011-01-12 17:01:23 -080056targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.xz initramfs_data.cpio.lzo initramfs_data.cpio
Sam Ravnborg58a2f7d2006-08-07 20:58:28 +020057# do not try to update files included in initramfs
58$(deps_initramfs): ;
59
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020060$(deps_initramfs): klibcdirs
Alain Knaffa26ee602009-01-07 00:10:27 -080061# We rebuild initramfs_data.cpio if:
62# 1) Any included file is newer then initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020063# 2) There are changes in which files are included (added or deleted)
Alain Knaffa26ee602009-01-07 00:10:27 -080064# 3) If gen_init_cpio are newer than initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020065# 4) arguments to gen_initramfs.sh changes
Alain Knaffa26ee602009-01-07 00:10:27 -080066$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
67 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020068 $(call if_changed,initfs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069