system.mk 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.
  55. # $(1): base dir (either staging or target)
  56. ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
  57. define SYSTEM_LIB_SYMLINK
  58. ln -snf lib $(1)/lib64
  59. ln -snf lib $(1)/usr/lib64
  60. endef
  61. else
  62. define SYSTEM_LIB_SYMLINK
  63. ln -snf lib $(1)/lib32
  64. ln -snf lib $(1)/usr/lib32
  65. endef
  66. endif
  67. SYSTEM_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
  68. SYSTEM_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
  69. SYSTEM_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
  70. SYSTEM_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
  71. ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
  72. # Find commented line, if any, and remove leading '#'s
  73. define SYSTEM_REMOUNT_ROOT_INITTAB
  74. $(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
  75. endef
  76. else
  77. # Find uncommented line, if any, and add a leading '#'
  78. define SYSTEM_REMOUNT_ROOT_INITTAB
  79. $(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
  80. endef
  81. endif
  82. ifeq ($(BR_BUILDING)$(BR2_SYSTEM_DEFAULT_PATH),y"")
  83. $(error BR2_SYSTEM_DEFAULT_PATH can't be empty)
  84. endif