system.mk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ################################################################################
  2. #
  3. # system-related variables and macros
  4. #
  5. ################################################################################
  6. # This file exists to define variables and macros that pertain to the system
  7. # settings, like rsyncing a directory for skeletons, or the /lib vs. /usr/lib
  8. # symlink handling.
  9. #
  10. # Some variables may be used as conditions in Makefile code, so they must be
  11. # defined properly before they are used; this file is included early, before
  12. # any package is.
  13. # - SYSTEM_USR_SYMLINKS_OR_DIRS
  14. # create /lib, /bin and /sbin, either as directories or as symlinks to
  15. # their /usr conterparts
  16. #
  17. # - SYSTEM_RSYNC
  18. # rsync $(1) to $(2), with proper exclusions and rights
  19. #
  20. # - SYSTEM_LIB_SYMLINK
  21. # create the appropriate /lib{32,64} symlinks
  22. #
  23. # - SYSTEM_GETTY_PORT
  24. # - SYSTEM_GETTY_BAUDRATE
  25. # - SYSTEM_GETTY_TERM
  26. # - SYSTEM_GETTY_OPTIONS
  27. # the un-quoted getty setting
  28. #
  29. # - SYSTEM_REMOUNT_ROOT_INITTAB
  30. # set inittab to remount root read-write or read-only
  31. #
  32. # This function handles the merged or non-merged /usr, and merged or
  33. # non-merged /usr/bin cases
  34. ifeq ($(BR2_ROOTFS_MERGED_USR),y)
  35. ifeq ($(BR2_ROOTFS_MERGED_BIN),y)
  36. define SYSTEM_SBIN_SYMLINKS_OR_DIRS
  37. ln -snf bin $(1)/usr/sbin
  38. endef
  39. else
  40. define SYSTEM_SBIN_SYMLINKS_OR_DIRS
  41. $(INSTALL) -d -m 0755 $(1)/usr/sbin
  42. endef
  43. endif
  44. define SYSTEM_USR_SYMLINKS_OR_DIRS
  45. ln -snf usr/bin $(1)/bin
  46. ln -snf usr/sbin $(1)/sbin
  47. ln -snf usr/lib $(1)/lib
  48. $(SYSTEM_SBIN_SYMLINKS_OR_DIRS)
  49. endef
  50. else
  51. define SYSTEM_USR_SYMLINKS_OR_DIRS
  52. $(INSTALL) -d -m 0755 $(1)/bin
  53. $(INSTALL) -d -m 0755 $(1)/sbin
  54. $(INSTALL) -d -m 0755 $(1)/lib
  55. $(INSTALL) -d -m 0755 $(1)/usr/sbin
  56. endef
  57. endif
  58. # This function rsyncs the skeleton directory in $(1) to the destination
  59. # in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
  60. define SYSTEM_RSYNC
  61. rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
  62. --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
  63. $(1)/ $(2)/
  64. endef
  65. # Make a symlink lib32->lib or lib64->lib as appropriate.
  66. # MIPS64/n32 requires lib32 even though it's a 64-bit arch. However, since gcc
  67. # 5.1.0 internal compiler paths in sysroot are relative to lib64, so we must
  68. # create both.
  69. # $(1): base dir (either staging or target)
  70. ifeq ($(BR2_MIPS_NABI32),y)
  71. define SYSTEM_LIB_SYMLINK
  72. ln -snf lib $(1)/lib64
  73. ln -snf lib $(1)/usr/lib64
  74. ln -snf lib $(1)/lib32
  75. ln -snf lib $(1)/usr/lib32
  76. endef
  77. else ifeq ($(BR2_ARCH_IS_64),y)
  78. define SYSTEM_LIB_SYMLINK
  79. ln -snf lib $(1)/lib64
  80. ln -snf lib $(1)/usr/lib64
  81. endef
  82. else
  83. define SYSTEM_LIB_SYMLINK
  84. ln -snf lib $(1)/lib32
  85. ln -snf lib $(1)/usr/lib32
  86. endef
  87. endif
  88. SYSTEM_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
  89. SYSTEM_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
  90. SYSTEM_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
  91. SYSTEM_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
  92. ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
  93. # Find commented line, if any, and remove leading '#'s
  94. define SYSTEM_REMOUNT_ROOT_INITTAB
  95. $(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
  96. endef
  97. else
  98. # Find uncommented line, if any, and add a leading '#'
  99. define SYSTEM_REMOUNT_ROOT_INITTAB
  100. $(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
  101. endef
  102. endif
  103. ifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
  104. $(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
  105. endif