Makefile 1.8 KB

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