u-boot.mk 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.11-config --includes 2>&1 | grep 'python3', \
  25. python3.10-config --includes 2>&1 | grep 'python3', \
  26. python3.9-config --includes 2>&1 | grep 'python3', \
  27. python3.8-config --includes 2>&1 | grep 'python3', \
  28. python3.7-config --includes 2>&1 | grep 'python3', \
  29. python3-config --includes 2>&1 | grep -E 'python3\.([7-9]|[0-9][0-9])\.?'))
  30. $(eval $(call TestHostCommand,python3-setuptools, \
  31. Please install the Python3 setuptools module, \
  32. $(STAGING_DIR_HOST)/bin/python3 -c 'import setuptools'))
  33. $(eval $(call TestHostCommand,swig, \
  34. Please install the swig package, \
  35. swig -version))
  36. endif
  37. export GCC_HONOUR_COPTS=s
  38. define Package/u-boot/install/default
  39. $(CP) $(patsubst %,$(PKG_BUILD_DIR)/%,$(UBOOT_IMAGE)) $(1)/
  40. endef
  41. Package/u-boot/install = $(Package/u-boot/install/default)
  42. define U-Boot/Init
  43. BUILD_TARGET:=
  44. BUILD_SUBTARGET:=
  45. BUILD_DEVICES:=
  46. NAME:=
  47. DEPENDS:=
  48. HIDDEN:=
  49. DEFAULT:=
  50. VARIANT:=$(1)
  51. UBOOT_CONFIG:=$(1)
  52. UBOOT_IMAGE:=u-boot.bin
  53. endef
  54. TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
  55. UBOOT_MAKE_FLAGS = \
  56. PATH=$(STAGING_DIR_HOST)/bin:$(PATH) \
  57. HOSTCC="$(HOSTCC)" \
  58. HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \
  59. HOSTLDFLAGS="$(HOST_LDFLAGS)" \
  60. LOCALVERSION="-OpenWrt-$(REVISION)" \
  61. STAGING_PREFIX="$(STAGING_DIR_HOST)" \
  62. PKG_CONFIG_PATH="$(STAGING_DIR_HOST)/lib/pkgconfig" \
  63. PKG_CONFIG_LIBDIR="$(STAGING_DIR_HOST)/lib/pkgconfig" \
  64. PKG_CONFIG_EXTRAARGS="--static" \
  65. $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
  66. define Build/U-Boot/Target
  67. $(eval $(call U-Boot/Init,$(1)))
  68. $(eval $(call U-Boot/Default,$(1)))
  69. $(eval $(call U-Boot/$(1),$(1)))
  70. define Package/u-boot-$(1)
  71. SECTION:=boot
  72. CATEGORY:=Boot Loaders
  73. TITLE:=U-Boot for $(NAME)
  74. VARIANT:=$(VARIANT)
  75. DEPENDS:=@!IN_SDK $(DEPENDS)
  76. HIDDEN:=$(HIDDEN)
  77. ifneq ($(BUILD_TARGET),)
  78. DEPENDS += @$(TARGET_DEP)
  79. ifneq ($(BUILD_DEVICES),)
  80. DEFAULT := y if ($(TARGET_DEP)_Default \
  81. $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
  82. $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
  83. endif
  84. endif
  85. $(if $(DEFAULT),DEFAULT:=$(DEFAULT))
  86. URL:=http://www.denx.de/wiki/U-Boot
  87. endef
  88. define Package/u-boot-$(1)/install
  89. $$(Package/u-boot/install)
  90. endef
  91. endef
  92. define Build/Configure/U-Boot
  93. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) $(UBOOT_CONFIG)_config
  94. $(if $(strip $(UBOOT_CUSTOMIZE_CONFIG)),
  95. $(PKG_BUILD_DIR)/scripts/config --file $(PKG_BUILD_DIR)/.config $(UBOOT_CUSTOMIZE_CONFIG)
  96. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) oldconfig)
  97. endef
  98. ifndef UBOOT_USE_INTREE_DTC
  99. DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
  100. endif
  101. define Build/Compile/U-Boot
  102. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  103. CROSS_COMPILE=$(TARGET_CROSS) \
  104. $(if $(DTC),DTC="$(DTC)") \
  105. $(UBOOT_MAKE_FLAGS)
  106. endef
  107. define BuildPackage/U-Boot/Defaults
  108. Build/Configure/Default = $$$$(Build/Configure/U-Boot)
  109. Build/Compile/Default = $$$$(Build/Compile/U-Boot)
  110. endef
  111. define BuildPackage/U-Boot
  112. $(eval $(call BuildPackage/U-Boot/Defaults))
  113. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  114. $(eval $(call Build/U-Boot/Target,$(type)))
  115. )
  116. $(eval $(call Build/DefaultTargets))
  117. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  118. $(call BuildPackage,u-boot-$(type))
  119. )
  120. endef