Makefile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #
  2. # kbuild file for usr/ - including initramfs image
  3. #
  4. klibcdirs:;
  5. PHONY += klibcdirs
  6. # Find out "preferred" ramdisk compressor. Order of preference is
  7. # 1. bzip2 efficient, and likely to be present
  8. # 2. gzip former default
  9. # 3. lzma
  10. # 4. none
  11. # None of the above
  12. suffix_y =
  13. # Lzma, but no gzip nor bzip2
  14. suffix_$(CONFIG_RD_LZMA) = .lzma
  15. # Gzip, but no bzip2
  16. suffix_$(CONFIG_RD_GZIP) = .gz
  17. # Bzip2
  18. suffix_$(CONFIG_RD_BZIP2) = .bz2
  19. # Generate builtin.o based on initramfs_data.o
  20. obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o
  21. # initramfs_data.o contains the compressed initramfs_data.cpio image.
  22. # The image is included using .incbin, a dependency which is not
  23. # tracked automatically.
  24. $(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE
  25. #####
  26. # Generate the initramfs cpio archive
  27. hostprogs-y := gen_init_cpio
  28. initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
  29. ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
  30. $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
  31. ramfs-args := \
  32. $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
  33. $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
  34. # .initramfs_data.cpio.d is used to identify all files included
  35. # in initramfs and to detect if any files are added/removed.
  36. # Removed files are identified by directory timestamp being updated
  37. # The dependency list is generated by gen_initramfs.sh -l
  38. ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
  39. include $(obj)/.initramfs_data.cpio.d
  40. endif
  41. quiet_cmd_initfs = GEN $@
  42. cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
  43. targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio
  44. # do not try to update files included in initramfs
  45. $(deps_initramfs): ;
  46. $(deps_initramfs): klibcdirs
  47. # We rebuild initramfs_data.cpio if:
  48. # 1) Any included file is newer then initramfs_data.cpio
  49. # 2) There are changes in which files are included (added or deleted)
  50. # 3) If gen_init_cpio are newer than initramfs_data.cpio
  51. # 4) arguments to gen_initramfs.sh changes
  52. $(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
  53. $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
  54. $(call if_changed,initfs)