Makefile 2.3 KB
Newer Older
1 2 3
#
# kbuild file for usr/ - including initramfs image
#
L
Linus Torvalds 已提交
4

5
klibcdirs:;
6 7
PHONY += klibcdirs

8

9
# Gzip
10
suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP)   = .gz
11 12

# Bzip2
13
suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2)  = .bz2
14

15 16
# Lzma
suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA)   = .lzma
L
Linus Torvalds 已提交
17

18 19 20
# XZ
suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ)     = .xz

21 22 23
# Lzo
suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO)   = .lzo

24 25
AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"

26
# Generate builtin.o based on initramfs_data.o
27
obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
L
Linus Torvalds 已提交
28

29
# initramfs_data.o contains the compressed initramfs_data.cpio image.
L
Linus Torvalds 已提交
30 31
# The image is included using .incbin, a dependency which is not
# tracked automatically.
32
$(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
L
Linus Torvalds 已提交
33

34 35 36 37 38 39
#####
# Generate the initramfs cpio archive

hostprogs-y := gen_init_cpio
initramfs   := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
40
			$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
41 42
ramfs-args  := \
        $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
N
Nickolay 已提交
43
        $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
44

45
# .initramfs_data.cpio.d is used to identify all files included
46 47 48
# in initramfs and to detect if any files are added/removed.
# Removed files are identified by directory timestamp being updated
# The dependency list is generated by gen_initramfs.sh -l
49 50
ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
	include $(obj)/.initramfs_data.cpio.d
L
Linus Torvalds 已提交
51 52
endif

53 54 55
quiet_cmd_initfs = GEN     $@
      cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)

56
targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio.xz initramfs_data.cpio.lzo initramfs_data.cpio
57 58 59
# do not try to update files included in initramfs
$(deps_initramfs): ;

60
$(deps_initramfs): klibcdirs
61 62
# We rebuild initramfs_data.cpio if:
# 1) Any included file is newer then initramfs_data.cpio
63
# 2) There are changes in which files are included (added or deleted)
64
# 3) If gen_init_cpio are newer than initramfs_data.cpio
65
# 4) arguments to gen_initramfs.sh changes
66 67
$(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
68
	$(call if_changed,initfs)
L
Linus Torvalds 已提交
69