2
1

common.mk 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #
  2. # Macro that builds the needed Makefile target to create a root
  3. # filesystem image.
  4. #
  5. # The following variable must be defined before calling this macro
  6. #
  7. # ROOTFS_$(FSTYPE)_CMD, the command that generates the root
  8. # filesystem image. A single command is allowed. The filename of the
  9. # filesystem image that it must generate is $$@.
  10. #
  11. # The following variables can optionaly be defined
  12. #
  13. # ROOTFS_$(FSTYPE)_DEPENDENCIES, the list of dependencies needed to
  14. # build the root filesystem (usually host tools)
  15. #
  16. # ROOTFS_$(FSTYPE)_PRE_GEN_HOOKS, a list of hooks to call before
  17. # generating the filesystem image
  18. #
  19. # ROOTFS_$(FSTYPE)_POST_GEN_HOOKS, a list of hooks to call after
  20. # generating the filesystem image
  21. #
  22. # In terms of configuration option, this macro assumes that the
  23. # BR2_TARGET_ROOTFS_$(FSTYPE) config option allows to enable/disable
  24. # the generation of a filesystem image of a particular type. If
  25. # configura options BR2_TARGET_ROOTFS_$(FSTYPE)_GZIP,
  26. # BR2_TARGET_ROOTFS_$(FSTYPE)_BZIP2 or
  27. # BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
  28. # macro will automatically generate a compressed filesystem image.
  29. FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
  30. define ROOTFS_TARGET_INTERNAL
  31. $(BINARIES_DIR)/rootfs.$(1): $(ROOTFS_$(2)_DEPENDENCIES) host-fakeroot makedevs $(if $(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma)
  32. @$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
  33. $(foreach hook,$(ROOTFS_$(2)_PRE_GEN_HOOKS),$(call $(hook))$(sep))
  34. rm -f $(FAKEROOT_SCRIPT)
  35. touch $(BUILD_DIR)/.fakeroot.00000
  36. cat $(BUILD_DIR)/.fakeroot* > $(FAKEROOT_SCRIPT)
  37. echo "chown -R 0:0 $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
  38. ifneq ($(TARGET_DEVICE_TABLE),)
  39. echo "$(HOST_DIR)/usr/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
  40. endif
  41. echo "$(ROOTFS_$(2)_CMD)" >> $(FAKEROOT_SCRIPT)
  42. chmod a+x $(FAKEROOT_SCRIPT)
  43. $(HOST_DIR)/usr/bin/fakeroot -- $(FAKEROOT_SCRIPT)
  44. -@rm -f $(FAKEROOT_SCRIPT)
  45. $(foreach hook,$(ROOTFS_$(2)_POST_GEN_HOOKS),$(call $(hook))$(sep))
  46. ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
  47. gzip -9 -c $$@ > $$@.gz
  48. endif
  49. ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y)
  50. bzip2 -9 -c $$@ > $$@.bz2
  51. endif
  52. ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
  53. $(LZMA) -9 -c $$@ > $$@.lzma
  54. endif
  55. $(1)-root: $(BINARIES_DIR)/rootfs.$(1)
  56. ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
  57. TARGETS += $(1)-root
  58. endif
  59. endef
  60. define ROOTFS_TARGET
  61. $(call ROOTFS_TARGET_INTERNAL,$(1),$(call UPPERCASE,$(1)))
  62. endef
  63. include fs/*/*.mk