blob: b84894b3929d4ad4b2e029b17370cef2c7332836 [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 Knaffab76f3d2009-02-19 13:43:51 -08009# No compression
10suffix_$(CONFIG_INITRAMFS_COMPRESSION_NONE) =
Alain Knaffa26ee602009-01-07 00:10:27 -080011
12# Gzip, but no bzip2
Alain Knaffab76f3d2009-02-19 13:43:51 -080013suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz
Alain Knaffa26ee602009-01-07 00:10:27 -080014
15# Bzip2
Alain Knaffab76f3d2009-02-19 13:43:51 -080016suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2
Alain Knaffa26ee602009-01-07 00:10:27 -080017
Alain Knaffab76f3d2009-02-19 13:43:51 -080018# Lzma
19suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020020
21# Generate builtin.o based on initramfs_data.o
Alain Knaffa26ee602009-01-07 00:10:27 -080022obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Alain Knaffa26ee602009-01-07 00:10:27 -080024# initramfs_data.o contains the compressed initramfs_data.cpio image.
Linus Torvalds1da177e2005-04-16 15:20:36 -070025# The image is included using .incbin, a dependency which is not
26# tracked automatically.
Alain Knaffa26ee602009-01-07 00:10:27 -080027$(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020029#####
30# Generate the initramfs cpio archive
31
32hostprogs-y := gen_init_cpio
33initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
34ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
Thomas Choua26d79c2006-11-25 11:09:18 -080035 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020036ramfs-args := \
37 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
Nickolayff541712006-06-09 21:24:14 +040038 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020039
Alain Knaffa26ee602009-01-07 00:10:27 -080040# .initramfs_data.cpio.d is used to identify all files included
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020041# in initramfs and to detect if any files are added/removed.
42# Removed files are identified by directory timestamp being updated
43# The dependency list is generated by gen_initramfs.sh -l
Alain Knaffa26ee602009-01-07 00:10:27 -080044ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
45 include $(obj)/.initramfs_data.cpio.d
Linus Torvalds1da177e2005-04-16 15:20:36 -070046endif
47
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020048quiet_cmd_initfs = GEN $@
49 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Alain Knaffa26ee602009-01-07 00:10:27 -080051targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio
Sam Ravnborg58a2f7d2006-08-07 20:58:28 +020052# do not try to update files included in initramfs
53$(deps_initramfs): ;
54
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020055$(deps_initramfs): klibcdirs
Alain Knaffa26ee602009-01-07 00:10:27 -080056# We rebuild initramfs_data.cpio if:
57# 1) Any included file is newer then initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020058# 2) There are changes in which files are included (added or deleted)
Alain Knaffa26ee602009-01-07 00:10:27 -080059# 3) If gen_init_cpio are newer than initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020060# 4) arguments to gen_initramfs.sh changes
Alain Knaffa26ee602009-01-07 00:10:27 -080061$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
62 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020063 $(call if_changed,initfs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064