u-boot.mk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. include $(INCLUDE_DIR)/prereq.mk
  2. PKG_NAME ?= u-boot
  3. ifndef PKG_SOURCE_PROTO
  4. PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
  5. PKG_SOURCE_URL = \
  6. https://mirror.cyberbits.eu/u-boot \
  7. https://ftp.denx.de/pub/u-boot \
  8. ftp://ftp.denx.de/pub/u-boot
  9. endif
  10. PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
  11. PKG_TARGETS := bin
  12. PKG_FLAGS:=nonshared
  13. PKG_LICENSE:=GPL-2.0 GPL-2.0+
  14. PKG_LICENSE_FILES:=Licenses/README
  15. PKG_BUILD_PARALLEL ?= 1
  16. ifdef UBOOT_USE_BINMAN
  17. $(eval $(call TestHostCommand,python3-pyelftools, \
  18. Please install the Python3 elftools module, \
  19. $(STAGING_DIR_HOST)/bin/python3 -c 'import elftools'))
  20. endif
  21. ifdef UBOOT_USE_INTREE_DTC
  22. $(eval $(call TestHostCommand,python3-dev, \
  23. Please install the python3-dev package, \
  24. python3.13-config --includes 2>&1 | grep 'python3', \
  25. python3.12-config --includes 2>&1 | grep 'python3', \
  26. python3.11-config --includes 2>&1 | grep 'python3', \
  27. python3.10-config --includes 2>&1 | grep 'python3', \
  28. python3.9-config --includes 2>&1 | grep 'python3', \
  29. python3.8-config --includes 2>&1 | grep 'python3', \
  30. python3.7-config --includes 2>&1 | grep 'python3', \
  31. python3-config --includes 2>&1 | grep -E 'python3\.([7-9]|[0-9][0-9])\.?'))
  32. $(eval $(call TestHostCommand,python3-setuptools, \
  33. Please install the Python3 setuptools module, \
  34. $(STAGING_DIR_HOST)/bin/python3 -c 'import setuptools'))
  35. $(eval $(call TestHostCommand,swig, \
  36. Please install the swig package, \
  37. swig -version))
  38. endif
  39. export GCC_HONOUR_COPTS=s
  40. define Package/u-boot/install/default
  41. $(CP) $(patsubst %,$(PKG_BUILD_DIR)/%,$(UBOOT_IMAGE)) $(1)/
  42. endef
  43. Package/u-boot/install = $(Package/u-boot/install/default)
  44. define U-Boot/Init
  45. BUILD_TARGET:=
  46. BUILD_SUBTARGET:=
  47. BUILD_DEVICES:=
  48. NAME:=
  49. DEPENDS:=
  50. HIDDEN:=
  51. DEFAULT:=
  52. VARIANT:=$(1)
  53. UBOOT_CONFIG:=$(1)
  54. UBOOT_IMAGE:=u-boot.bin
  55. endef
  56. TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
  57. UBOOT_MAKE_FLAGS = \
  58. PATH=$(STAGING_DIR_HOST)/bin:$(PATH) \
  59. HOSTCC="$(HOSTCC)" \
  60. HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \
  61. HOSTLDFLAGS="$(HOST_LDFLAGS)" \
  62. LOCALVERSION="-OpenWrt-$(REVISION)" \
  63. STAGING_PREFIX="$(STAGING_DIR_HOST)" \
  64. PKG_CONFIG_PATH="$(STAGING_DIR_HOST)/lib/pkgconfig" \
  65. PKG_CONFIG_LIBDIR="$(STAGING_DIR_HOST)/lib/pkgconfig" \
  66. PKG_CONFIG_EXTRAARGS="--static" \
  67. $(if $(KBUILD_CFLAGS),KCFLAGS="$(KBUILD_CFLAGS)") \
  68. $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
  69. define Build/U-Boot/Target
  70. $(eval $(call U-Boot/Init,$(1)))
  71. $(eval $(call U-Boot/Default,$(1)))
  72. $(eval $(call U-Boot/$(1),$(1)))
  73. define Package/u-boot-$(1)
  74. SECTION:=boot
  75. CATEGORY:=Boot Loaders
  76. TITLE:=U-Boot for $(NAME)
  77. VARIANT:=$(VARIANT)
  78. DEPENDS:=@!IN_SDK $(DEPENDS)
  79. HIDDEN:=$(HIDDEN)
  80. ifneq ($(BUILD_TARGET),)
  81. DEPENDS += @$(TARGET_DEP)
  82. ifneq ($(BUILD_DEVICES),)
  83. DEFAULT := y if ($(TARGET_DEP)_Default \
  84. $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
  85. $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
  86. endif
  87. endif
  88. $(if $(DEFAULT),DEFAULT:=$(DEFAULT))
  89. URL:=http://www.denx.de/wiki/U-Boot
  90. endef
  91. define Package/u-boot-$(1)/install
  92. $$(Package/u-boot/install)
  93. endef
  94. endef
  95. define Build/Configure/U-Boot
  96. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  97. CROSS_COMPILE=$(TARGET_CROSS) \
  98. $(UBOOT_CONFIGURE_VARS) \
  99. $(firstword $(UBOOT_CONFIG))_config \
  100. $(wordlist 2,$(words $(UBOOT_CONFIG)),$(UBOOT_CONFIG:%=%.config))
  101. $(if $(strip $(UBOOT_CUSTOMIZE_CONFIG)),
  102. $(PKG_BUILD_DIR)/scripts/config --file $(PKG_BUILD_DIR)/.config $(UBOOT_CUSTOMIZE_CONFIG)
  103. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS) $(UBOOT_CONFIGURE_VARS) oldconfig)
  104. endef
  105. ifndef UBOOT_USE_INTREE_DTC
  106. DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
  107. endif
  108. define Build/Compile/U-Boot
  109. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  110. CROSS_COMPILE=$(TARGET_CROSS) \
  111. $(if $(DTC),DTC="$(DTC)") \
  112. $(UBOOT_MAKE_FLAGS)
  113. endef
  114. define BuildPackage/U-Boot/Defaults
  115. Build/Configure/Default = $$$$(Build/Configure/U-Boot)
  116. Build/Compile/Default = $$$$(Build/Compile/U-Boot)
  117. endef
  118. define BuildPackage/U-Boot
  119. $(eval $(call BuildPackage/U-Boot/Defaults))
  120. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  121. $(eval $(call Build/U-Boot/Target,$(type)))
  122. )
  123. $(eval $(call Build/DefaultTargets))
  124. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  125. $(call BuildPackage,u-boot-$(type))
  126. )
  127. endef