Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #
  2. # kbuild file for usr/ - including initramfs image
  3. #
  4. klibcdirs:;
  5. # Generate builtin.o based on initramfs_data.o
  6. obj-y := initramfs_data.o
  7. # initramfs_data.o contains the initramfs_data.cpio.gz image.
  8. # The image is included using .incbin, a dependency which is not
  9. # tracked automatically.
  10. $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE
  11. #####
  12. # Generate the initramfs cpio archive
  13. hostprogs-y := gen_init_cpio
  14. initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
  15. ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
  16. $(CONFIG_INITRAMFS_SOURCE),-d)
  17. ramfs-args := \
  18. $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
  19. $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \
  20. $(ramfs-input)
  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. $(deps_initramfs): klibcdirs
  32. # We rebuild initramfs_data.cpio.gz if:
  33. # 1) Any included file is newer then initramfs_data.cpio.gz
  34. # 2) There are changes in which files are included (added or deleted)
  35. # 3) If gen_init_cpio are newer than initramfs_data.cpio.gz
  36. # 4) arguments to gen_initramfs.sh changes
  37. $(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
  38. $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d
  39. $(call if_changed,initfs)