Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # kbuild file for usr/ - including initramfs image
  3. #
  4. klibcdirs:;
  5. PHONY += klibcdirs
  6. # Bzip2
  7. suffix_$(CONFIG_RD_BZIP2) = .bz2
  8. # Lzma
  9. suffix_$(CONFIG_RD_LZMA) = .lzma
  10. # XZ
  11. suffix_$(CONFIG_RD_XZ) = .xz
  12. # Lzo
  13. suffix_$(CONFIG_RD_LZO) = .lzo
  14. # Lz4
  15. suffix_$(CONFIG_RD_LZ4) = .lz4
  16. # Gzip
  17. suffix_$(CONFIG_RD_GZIP) = .gz
  18. AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
  19. # Generate builtin.o based on initramfs_data.o
  20. obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.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.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 \
  44. initramfs_data.cpio.lzma initramfs_data.cpio.xz \
  45. initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
  46. initramfs_data.cpio
  47. # do not try to update files included in initramfs
  48. $(deps_initramfs): ;
  49. $(deps_initramfs): klibcdirs
  50. # We rebuild initramfs_data.cpio if:
  51. # 1) Any included file is newer then initramfs_data.cpio
  52. # 2) There are changes in which files are included (added or deleted)
  53. # 3) If gen_init_cpio are newer than initramfs_data.cpio
  54. # 4) arguments to gen_initramfs.sh changes
  55. $(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
  56. $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d
  57. $(call if_changed,initfs)