Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. # .initramfs_data.cpio.gz.d is used to identify all files included
  21. # in initramfs and to detect if any files are added/removed.
  22. # Removed files are identified by directory timestamp being updated
  23. # The dependency list is generated by gen_initramfs.sh -l
  24. ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),)
  25. include $(obj)/.initramfs_data.cpio.gz.d
  26. endif
  27. quiet_cmd_initfs = GEN $@
  28. cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
  29. targets := initramfs_data.cpio.gz
  30. # do not try to update files included in initramfs
  31. $(deps_initramfs): ;
  32. $(deps_initramfs): klibcdirs
  33. # We rebuild initramfs_data.cpio.gz if:
  34. # 1) Any included file is newer then initramfs_data.cpio.gz
  35. # 2) There are changes in which files are included (added or deleted)
  36. # 3) If gen_init_cpio are newer than initramfs_data.cpio.gz
  37. # 4) arguments to gen_initramfs.sh changes
  38. $(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
  39. $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d
  40. $(call if_changed,initfs)