u-boot.mk 4.3 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 $(KBUILD_CFLAGS),KCFLAGS="$(KBUILD_CFLAGS)") \
  66. $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
  67. define Build/U-Boot/Target
  68. $(eval $(call U-Boot/Init,$(1)))
  69. $(eval $(call U-Boot/Default,$(1)))
  70. $(eval $(call U-Boot/$(1),$(1)))
  71. define Package/u-boot-$(1)
  72. SECTION:=boot
  73. CATEGORY:=Boot Loaders
  74. TITLE:=U-Boot for $(NAME)
  75. VARIANT:=$(VARIANT)
  76. DEPENDS:=@!IN_SDK $(DEPENDS)
  77. HIDDEN:=$(HIDDEN)
  78. ifneq ($(BUILD_TARGET),)
  79. DEPENDS += @$(TARGET_DEP)
  80. ifneq ($(BUILD_DEVICES),)
  81. DEFAULT := y if ($(TARGET_DEP)_Default \
  82. $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
  83. $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
  84. endif
  85. endif
  86. $(if $(DEFAULT),DEFAULT:=$(DEFAULT))
  87. URL:=http://www.denx.de/wiki/U-Boot
  88. endef
  89. define Package/u-boot-$(1)/install
  90. $$(Package/u-boot/install)
  91. endef
  92. endef
  93. define Build/Configure/U-Boot
  94. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS) $(UBOOT_CONFIGURE_VARS) $(UBOOT_CONFIG)_config
  95. $(if $(strip $(UBOOT_CUSTOMIZE_CONFIG)),
  96. $(PKG_BUILD_DIR)/scripts/config --file $(PKG_BUILD_DIR)/.config $(UBOOT_CUSTOMIZE_CONFIG)
  97. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS) $(UBOOT_CONFIGURE_VARS) oldconfig)
  98. endef
  99. ifndef UBOOT_USE_INTREE_DTC
  100. DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
  101. endif
  102. define Build/Compile/U-Boot
  103. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  104. CROSS_COMPILE=$(TARGET_CROSS) \
  105. $(if $(DTC),DTC="$(DTC)") \
  106. $(UBOOT_MAKE_FLAGS)
  107. endef
  108. define BuildPackage/U-Boot/Defaults
  109. Build/Configure/Default = $$$$(Build/Configure/U-Boot)
  110. Build/Compile/Default = $$$$(Build/Compile/U-Boot)
  111. endef
  112. define BuildPackage/U-Boot
  113. $(eval $(call BuildPackage/U-Boot/Defaults))
  114. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  115. $(eval $(call Build/U-Boot/Target,$(type)))
  116. )
  117. $(eval $(call Build/DefaultTargets))
  118. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  119. $(call BuildPackage,u-boot-$(type))
  120. )
  121. endef