blob: 1e6a9e4a72cc627fb4d0e4863dabdbc15f709274 [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
18# Generate builtin.o based on initramfs_data.o
Alain Knaffa26ee602009-01-07 00:10:27 -080019obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Alain Knaffa26ee602009-01-07 00:10:27 -080021# initramfs_data.o contains the compressed initramfs_data.cpio image.
Linus Torvalds1da177e2005-04-16 15:20:36 -070022# The image is included using .incbin, a dependency which is not
23# tracked automatically.
Alain Knaffa26ee602009-01-07 00:10:27 -080024$(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020026#####
27# Generate the initramfs cpio archive
28
29hostprogs-y := gen_init_cpio
30initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
31ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
Thomas Choua26d79c2006-11-25 11:09:18 -080032 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020033ramfs-args := \
34 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
Nickolayff541712006-06-09 21:24:14 +040035 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020036
Alain Knaffa26ee602009-01-07 00:10:27 -080037# .initramfs_data.cpio.d is used to identify all files included
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020038# in initramfs and to detect if any files are added/removed.
39# Removed files are identified by directory timestamp being updated
40# The dependency list is generated by gen_initramfs.sh -l
Alain Knaffa26ee602009-01-07 00:10:27 -080041ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
42 include $(obj)/.initramfs_data.cpio.d
Linus Torvalds1da177e2005-04-16 15:20:36 -070043endif
44
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020045quiet_cmd_initfs = GEN $@
46 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Alain Knaffa26ee602009-01-07 00:10:27 -080048targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio
Sam Ravnborg58a2f7d2006-08-07 20:58:28 +020049# do not try to update files included in initramfs
50$(deps_initramfs): ;
51
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020052$(deps_initramfs): klibcdirs
Alain Knaffa26ee602009-01-07 00:10:27 -080053# We rebuild initramfs_data.cpio if:
54# 1) Any included file is newer then initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020055# 2) There are changes in which files are included (added or deleted)
Alain Knaffa26ee602009-01-07 00:10:27 -080056# 3) If gen_init_cpio are newer than initramfs_data.cpio
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020057# 4) arguments to gen_initramfs.sh changes
Alain Knaffa26ee602009-01-07 00:10:27 -080058$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
59 $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
Sam Ravnborgd39a206b2006-04-11 13:24:32 +020060 $(call if_changed,initfs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061