Blame view

usr/Makefile 1.99 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  # SPDX-License-Identifier: GPL-2.0
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
2
3
4
  #
  # kbuild file for usr/ - including initramfs image
  #
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5

d39a206bc   Sam Ravnborg   kbuild: rebuild i...
6
  klibcdirs:;
48f1f0589   Sam Ravnborg   kbuild: consisten...
7
  PHONY += klibcdirs
ae30ab4cd   Nicholas Piggin   kbuild: initramfs...
8
  suffix_y = $(subst $\",,$(CONFIG_INITRAMFS_COMPRESSION))
9e3596b0c   Nicholas Piggin   kbuild: initramfs...
9
  datafile_y = initramfs_data.cpio$(suffix_y)
e08b18774   Florian Fainelli   initramfs: fix in...
10
  datafile_d_y = .$(datafile_y).d
9e3596b0c   Nicholas Piggin   kbuild: initramfs...
11
  AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)"
6ae64e428   Hendrik Brueckner   initramfs: genera...
12

d39a206bc   Sam Ravnborg   kbuild: rebuild i...
13
  # Generate builtin.o based on initramfs_data.o
6ae64e428   Hendrik Brueckner   initramfs: genera...
14
  obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15

a26ee60f9   Alain Knaff   bzip2/lzma: fix b...
16
  # initramfs_data.o contains the compressed initramfs_data.cpio image.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
  # The image is included using .incbin, a dependency which is not
  # tracked automatically.
9e3596b0c   Nicholas Piggin   kbuild: initramfs...
19
  $(obj)/initramfs_data.o: $(obj)/$(datafile_y) FORCE
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20

d39a206bc   Sam Ravnborg   kbuild: rebuild i...
21
22
23
24
25
26
  #####
  # 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)), \
a26d79ca8   Thomas Chou   [PATCH] initramfs...
27
  			$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
28
29
  ramfs-args  := \
          $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
ff5417107   Nickolay   kbuild: bugfix wi...
30
          $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
31

e08b18774   Florian Fainelli   initramfs: fix in...
32
  # $(datafile_d_y) is used to identify all files included
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
33
34
35
  # 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
e08b18774   Florian Fainelli   initramfs: fix in...
36
37
  ifneq ($(wildcard $(obj)/$(datafile_d_y)),)
  	include $(obj)/$(datafile_d_y)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
  endif
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
39
40
  quiet_cmd_initfs = GEN     $@
        cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
9e3596b0c   Nicholas Piggin   kbuild: initramfs...
41
  targets := $(datafile_y)
58a2f7d85   Sam Ravnborg   kbuild: do not tr...
42
43
  # do not try to update files included in initramfs
  $(deps_initramfs): ;
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
44
  $(deps_initramfs): klibcdirs
a26ee60f9   Alain Knaff   bzip2/lzma: fix b...
45
46
  # We rebuild initramfs_data.cpio if:
  # 1) Any included file is newer then initramfs_data.cpio
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
47
  # 2) There are changes in which files are included (added or deleted)
a26ee60f9   Alain Knaff   bzip2/lzma: fix b...
48
  # 3) If gen_init_cpio are newer than initramfs_data.cpio
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
49
  # 4) arguments to gen_initramfs.sh changes
9e3596b0c   Nicholas Piggin   kbuild: initramfs...
50
  $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
e08b18774   Florian Fainelli   initramfs: fix in...
51
  	$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y)
d39a206bc   Sam Ravnborg   kbuild: rebuild i...
52
  	$(call if_changed,initfs)