blob: 6faa444b7087bc947e431221d64c843db00b3177 [file] [log] [blame]
Sam Ravnborgd39a2062006-04-11 13:24:32 +02001#
2# kbuild file for usr/ - including initramfs image
3#
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
Sam Ravnborgd39a2062006-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 Ravnborgd39a2062006-04-11 13:24:32 +020017
Albin Tonnerre2a2a4002010-05-26 14:44:28 -070018# Lzo
19suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo
20
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070021AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
22
Sam Ravnborgd39a2062006-04-11 13:24:32 +020023# Generate builtin.o based on initramfs_data.o
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070024obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Alain Knaffa26ee602009-01-07 00:10:27 -080026# initramfs_data.o contains the compressed initramfs_data.cpio image.
Linus Torvalds1da177e2005-04-16 15:20:36 -070027# The image is included using .incbin, a dependency which is not
28# tracked automatically.
Hendrik Brueckner6ae64e42010-09-17 15:24:09 -070029$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Sam Ravnborgd39a2062006-04-11 13:24:32 +020031#####
32# Generate the initramfs cpio archive
33
34hostprogs-y := gen_init_cpio
35initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
36ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
Thomas Choua26d79c2006-11-25 11:09:18 -080037 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
Sam Ravnborgd39a2062006-04-11 13:24:32 +020038ramfs-args := \
39 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
Nickolayff541712006-06-09 21:24:14 +040040 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Sam Ravnborgd39a2062006-04-11 13:24:32 +020041
Alain Knaffa26ee602009-01-07 00:10:27 -080042# .initramfs_data.cpio.d is used to identify all files included
Sam Ravnborgd39a2062006-04-11 13:24:32 +020043# in initramfs and to detect if any files are added/removed.
44# Removed files are identified by directory timestamp being updated
45# The dependency list is generated by gen_initramfs.sh -l
Alain Knaffa26ee602009-01-07 00:10:27 -080046ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
47 include $(obj)/.initramfs_data.cpio.d
Linus Torvalds1da177e2005-04-16 15:20:36 -070048endif
49
Sam Ravnborgd39a2062006-04-11 13:24:32 +020050quiet_cmd_initfs = GEN $@
51 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Albin Tonnerre2a2a4002010-05-26 14:44:28 -070053targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.lzo initramfs_data.cpio
Sam Ravnborg58a2f7d2006-08-07 20:58:28 +020054# do not try to update files included in initramfs
55$(deps_initramfs): ;
56
Sam Ravnborgd39a2062006-04-11 13:24:32 +020057$(deps_initramfs): klibcdirs
Alain Knaffa26ee602009-01-07 00:10:27 -080058# We rebuild initramfs_data.cpio if:
59# 1) Any included file is newer then initramfs_data.cpio
Sam Ravnborgd39a2062006-04-11 13:24:32 +020060# 2) There are changes in which files are included (added or deleted)
Alain Knaffa26ee602009-01-07 00:10:27 -080061# 3) If gen_init_cpio are newer than initramfs_data.cpio
Sam Ravnborgd39a2062006-04-11 13:24:32 +020062# 4) arguments to gen_initramfs.sh changes
Alain Knaffa26ee602009-01-07 00:10:27 -080063$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
64 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
Sam Ravnborgd39a2062006-04-11 13:24:32 +020065 $(call if_changed,initfs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066