system.mk 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 cases
  33. ifeq ($(BR2_ROOTFS_MERGED_USR),y)
  34. define SYSTEM_USR_SYMLINKS_OR_DIRS
  35. ln -snf usr/bin $(1)/bin
  36. ln -snf usr/sbin $(1)/sbin
  37. ln -snf usr/lib $(1)/lib
  38. endef
  39. else
  40. define SYSTEM_USR_SYMLINKS_OR_DIRS
  41. $(INSTALL) -d -m 0755 $(1)/bin
  42. $(INSTALL) -d -m 0755 $(1)/sbin
  43. $(INSTALL) -d -m 0755 $(1)/lib
  44. endef
  45. endif
  46. # This function rsyncs the skeleton directory in $(1) to the destination
  47. # in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
  48. define SYSTEM_RSYNC
  49. rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
  50. --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
  51. $(1)/ $(2)/
  52. endef
  53. # Make a symlink lib32->lib or lib64->lib as appropriate.
  54. # MIPS64/n32 requires lib32 even though it's a 64-bit arch. However, since gcc
  55. # 5.1.0 internal compiler paths in sysroot are relative to lib64, so we must
  56. # create both.
  57. # $(1): base dir (either staging or target)
  58. ifeq ($(BR2_MIPS_NABI32),y)
  59. define SYSTEM_LIB_SYMLINK
  60. ln -snf lib $(1)/lib64
  61. ln -snf lib $(1)/usr/lib64
  62. ln -snf lib $(1)/lib32
  63. ln -snf lib $(1)/usr/lib32
  64. endef
  65. else ifeq ($(BR2_ARCH_IS_64),y)
  66. define SYSTEM_LIB_SYMLINK
  67. ln -snf lib $(1)/lib64
  68. ln -snf lib $(1)/usr/lib64
  69. endef
  70. else
  71. define SYSTEM_LIB_SYMLINK
  72. ln -snf lib $(1)/lib32
  73. ln -snf lib $(1)/usr/lib32
  74. endef
  75. endif
  76. SYSTEM_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
  77. SYSTEM_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
  78. SYSTEM_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
  79. SYSTEM_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
  80. ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
  81. # Find commented line, if any, and remove leading '#'s
  82. define SYSTEM_REMOUNT_ROOT_INITTAB
  83. $(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
  84. endef
  85. else
  86. # Find uncommented line, if any, and add a leading '#'
  87. define SYSTEM_REMOUNT_ROOT_INITTAB
  88. $(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
  89. endef
  90. endif
  91. ifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
  92. $(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
  93. endif