barebox.mk 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. ################################################################################
  2. #
  3. # barebox
  4. #
  5. ################################################################################
  6. ################################################################################
  7. # inner-barebox-package -- generates the KConfig logic and make targets needed
  8. # to support a barebox package. All barebox packages are built from the same
  9. # source (origin, version and patches). The remainder of the package
  10. # configuration is unique to each barebox package.
  11. #
  12. # argument 1 is the uppercase package name (used for variable name-space)
  13. ################################################################################
  14. define inner-barebox-package
  15. $(1)_VERSION = $$(call qstrip,$$(BR2_TARGET_BAREBOX_VERSION))
  16. ifeq ($$($(1)_VERSION),custom)
  17. # Handle custom Barebox tarballs as specified by the configuration
  18. $(1)_TARBALL = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_TARBALL_LOCATION))
  19. $(1)_SITE = $$(patsubst %/,%,$$(dir $$($(1)_TARBALL)))
  20. $(1)_SOURCE = $$(notdir $$($(1)_TARBALL))
  21. else ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_GIT),y)
  22. $(1)_SITE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_GIT_REPO_URL))
  23. $(1)_SITE_METHOD = git
  24. else
  25. # Handle stable official Barebox versions
  26. $(1)_SOURCE = barebox-$$($(1)_VERSION).tar.bz2
  27. $(1)_SITE = http://www.barebox.org/download
  28. endif
  29. $(1)_DEPENDENCIES = host-lzop
  30. $(1)_LICENSE = GPL-2.0 with exceptions
  31. $(1)_LICENSE_FILES = COPYING
  32. $(1)_CUSTOM_EMBEDDED_ENV_PATH = $$(call qstrip,$$(BR2_TARGET_$(1)_CUSTOM_EMBEDDED_ENV_PATH))
  33. ifneq ($$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR)),)
  34. define $(1)_APPLY_CUSTOM_PATCHES
  35. $$(APPLY_PATCHES) $$(@D) \
  36. $$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR) \*.patch
  37. endef
  38. $(1)_POST_PATCH_HOOKS += $(1)_APPLY_CUSTOM_PATCHES
  39. endif
  40. $(1)_INSTALL_IMAGES = YES
  41. ifneq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
  42. $(1)_INSTALL_TARGET = NO
  43. endif
  44. ifeq ($$(KERNEL_ARCH),i386)
  45. $(1)_ARCH = x86
  46. else ifeq ($$(KERNEL_ARCH),x86_64)
  47. $(1)_ARCH = x86
  48. else ifeq ($$(KERNEL_ARCH),powerpc)
  49. $(1)_ARCH = ppc
  50. else ifeq ($$(KERNEL_ARCH),arm64)
  51. $(1)_ARCH = arm
  52. else
  53. $(1)_ARCH = $$(KERNEL_ARCH)
  54. endif
  55. $(1)_MAKE_FLAGS = ARCH=$$($(1)_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)"
  56. $(1)_MAKE_ENV = $$(TARGET_MAKE_ENV)
  57. ifeq ($$(BR2_TARGET_$(1)_USE_DEFCONFIG),y)
  58. $(1)_KCONFIG_DEFCONFIG = $$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))_defconfig
  59. else ifeq ($$(BR2_TARGET_$(1)_USE_CUSTOM_CONFIG),y)
  60. $(1)_KCONFIG_FILE = $$(call qstrip,$$(BR2_TARGET_$(1)_CUSTOM_CONFIG_FILE))
  61. endif
  62. $(1)_KCONFIG_FRAGMENT_FILES = $$(call qstrip,$$(BR2_TARGET_$(1)_CONFIG_FRAGMENT_FILES))
  63. $(1)_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
  64. $(1)_KCONFIG_OPTS = $$($(1)_MAKE_FLAGS)
  65. ifeq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
  66. define $(1)_BUILD_BAREBOXENV_CMDS
  67. $$(TARGET_CC) $$(TARGET_CFLAGS) $$(TARGET_LDFLAGS) -o $$(@D)/bareboxenv \
  68. $$(@D)/scripts/bareboxenv.c
  69. endef
  70. endif
  71. ifeq ($$(BR2_TARGET_$(1)_CUSTOM_ENV),y)
  72. $(1)_ENV_NAME = $$(notdir $$(call qstrip,\
  73. $$(BR2_TARGET_$(1)_CUSTOM_ENV_PATH)))
  74. define $(1)_BUILD_CUSTOM_ENV
  75. $$(@D)/scripts/bareboxenv -s \
  76. $$(call qstrip, $$(BR2_TARGET_$(1)_CUSTOM_ENV_PATH)) \
  77. $$(@D)/$$($(1)_ENV_NAME)
  78. endef
  79. define $(1)_INSTALL_CUSTOM_ENV
  80. cp $$(@D)/$$($(1)_ENV_NAME) $$(BINARIES_DIR)
  81. endef
  82. endif
  83. ifneq ($$($(1)_CUSTOM_EMBEDDED_ENV_PATH),)
  84. define $(1)_KCONFIG_FIXUP_CMDS
  85. $$(call KCONFIG_ENABLE_OPT,CONFIG_DEFAULT_ENVIRONMENT,$$(@D)/.config)
  86. $$(call KCONFIG_SET_OPT,CONFIG_DEFAULT_ENVIRONMENT_PATH,"$$($(1)_CUSTOM_EMBEDDED_ENV_PATH)",$$(@D)/.config)
  87. endef
  88. endif
  89. define $(1)_BUILD_CMDS
  90. $$($(1)_BUILD_BAREBOXENV_CMDS)
  91. $$(TARGET_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D)
  92. $$($(1)_BUILD_CUSTOM_ENV)
  93. endef
  94. $(1)_IMAGE_FILES = $$(call qstrip,$$(BR2_TARGET_$(1)_IMAGE_FILE))
  95. define $(1)_INSTALL_IMAGES_CMDS
  96. if test -n "$$($(1)_IMAGE_FILES)"; then \
  97. cp -L $$(foreach image,$$($(1)_IMAGE_FILES),$$(@D)/$$(image)) $$(BINARIES_DIR) ; \
  98. elif test -h $$(@D)/barebox-flash-image ; then \
  99. cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/barebox.bin ; \
  100. else \
  101. cp $$(@D)/barebox.bin $$(BINARIES_DIR);\
  102. fi
  103. $$($(1)_INSTALL_CUSTOM_ENV)
  104. endef
  105. ifeq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
  106. define $(1)_INSTALL_TARGET_CMDS
  107. cp $$(@D)/bareboxenv $$(TARGET_DIR)/usr/bin
  108. endef
  109. endif
  110. # Checks to give errors that the user can understand
  111. # Must be before we call to kconfig-package
  112. ifeq ($$(BR2_TARGET_$(1))$$(BR_BUILDING),yy)
  113. # We must use the user-supplied kconfig value, because
  114. # $(1)_KCONFIG_DEFCONFIG will at least contain the
  115. # trailing _defconfig
  116. ifeq ($$(or $$($(1)_KCONFIG_FILE),$$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))),)
  117. $$(error No Barebox config. Check your BR2_TARGET_$(1)_BOARD_DEFCONFIG or BR2_TARGET_$(1)_CUSTOM_CONFIG_FILE settings)
  118. endif
  119. endif
  120. $$(eval $$(kconfig-package))
  121. endef
  122. ################################################################################
  123. # barebox-package -- the target generator macro for barebox packages
  124. ################################################################################
  125. barebox-package=$(call inner-barebox-package,$(call UPPERCASE,$(pkgname)))
  126. include boot/barebox/barebox/barebox.mk
  127. include boot/barebox/barebox-aux/barebox-aux.mk
  128. ifeq ($(BR2_TARGET_BAREBOX)$(BR2_TARGET_BAREBOX_LATEST_VERSION),y)
  129. BR_NO_CHECK_HASH_FOR += $(BAREBOX_SOURCE)
  130. endif