Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #
  2. # kbuild file for usr/ - including initramfs image
  3. #
  4. klibcdirs:;
  5. PHONY += klibcdirs
  6. suffix_y = $(CONFIG_INITRAMFS_COMPRESSION)
  7. AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
  8. # Generate builtin.o based on initramfs_data.o
  9. obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
  10. # initramfs_data.o contains the compressed initramfs_data.cpio image.
  11. # The image is included using .incbin, a dependency which is not
  12. # tracked automatically.
  13. $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
  14. #####
  15. # Generate the initramfs cpio archive
  16. hostprogs-y := gen_init_cpio
  17. initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
  18. ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
  19. $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
  20. ramfs-args := \
  21. $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
  22. $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
  23. # .initramfs_data.cpio.d is used to identify all files included
  24. # in initramfs and to detect if any files are added/removed.
  25. # Removed files are identified by directory timestamp being updated
  26. # The dependency list is generated by gen_initramfs.sh -l
  27. ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
  28. include $(obj)/.initramfs_data.cpio.d
  29. endif
  30. quiet_cmd_initfs = GEN $@
  31. cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
  32. targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
  33. initramfs_data.cpio.lzma initramfs_data.cpio.xz \
  34. initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
  35. initramfs_data.cpio
  36. # do not try to update files included in initramfs
  37. $(deps_initramfs): ;
  38. $(deps_initramfs): klibcdirs
  39. # We rebuild initramfs_data.cpio if:
  40. # 1) Any included file is newer then initramfs_data.cpio
  41. # 2) There are changes in which files are included (added or deleted)
  42. # 3) If gen_init_cpio are newer than initramfs_data.cpio
  43. # 4) arguments to gen_initramfs.sh changes
  44. $(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
  45. $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
  46. $(call if_changed,initfs)