u-boot.mk 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. PKG_NAME ?= u-boot
  2. ifndef PKG_SOURCE_PROTO
  3. PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
  4. PKG_SOURCE_URL = \
  5. https://mirror.cyberbits.eu/u-boot \
  6. https://ftp.denx.de/pub/u-boot \
  7. ftp://ftp.denx.de/pub/u-boot
  8. endif
  9. PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
  10. PKG_TARGETS := bin
  11. PKG_FLAGS:=nonshared
  12. PKG_LICENSE:=GPL-2.0 GPL-2.0+
  13. PKG_LICENSE_FILES:=Licenses/README
  14. PKG_BUILD_PARALLEL:=1
  15. export GCC_HONOUR_COPTS=s
  16. define Package/u-boot/install/default
  17. $(CP) $(patsubst %,$(PKG_BUILD_DIR)/%,$(UBOOT_IMAGE)) $(1)/
  18. endef
  19. Package/u-boot/install = $(Package/u-boot/install/default)
  20. define U-Boot/Init
  21. BUILD_TARGET:=
  22. BUILD_SUBTARGET:=
  23. BUILD_DEVICES:=
  24. NAME:=
  25. DEPENDS:=
  26. HIDDEN:=
  27. DEFAULT:=
  28. VARIANT:=$(1)
  29. UBOOT_CONFIG:=$(1)
  30. UBOOT_IMAGE:=u-boot.bin
  31. endef
  32. TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
  33. UBOOT_MAKE_FLAGS = \
  34. HOSTCC="$(HOSTCC)" \
  35. HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \
  36. HOSTLDFLAGS="$(HOST_LDFLAGS)" \
  37. LOCALVERSION="-libreCMC-$(REVISION)" \
  38. STAGING_PREFIX="$(STAGING_DIR_HOST)" \
  39. PKG_CONFIG_PATH="$(STAGING_DIR_HOST)/lib/pkgconfig" \
  40. PKG_CONFIG_LIBDIR="$(STAGING_DIR_HOST)/lib/pkgconfig" \
  41. PKG_CONFIG_EXTRAARGS="--static" \
  42. $(if $(findstring c,$(LIBRECMC_VERBOSE)),V=1,V='')
  43. define Build/U-Boot/Target
  44. $(eval $(call U-Boot/Init,$(1)))
  45. $(eval $(call U-Boot/Default,$(1)))
  46. $(eval $(call U-Boot/$(1),$(1)))
  47. define Package/u-boot-$(1)
  48. SECTION:=boot
  49. CATEGORY:=Boot Loaders
  50. TITLE:=U-Boot for $(NAME)
  51. VARIANT:=$(VARIANT)
  52. DEPENDS:=@!IN_SDK $(DEPENDS)
  53. HIDDEN:=$(HIDDEN)
  54. ifneq ($(BUILD_TARGET),)
  55. DEPENDS += @$(TARGET_DEP)
  56. ifneq ($(BUILD_DEVICES),)
  57. DEFAULT := y if ($(TARGET_DEP)_Default \
  58. $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
  59. $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
  60. endif
  61. endif
  62. $(if $(DEFAULT),DEFAULT:=$(DEFAULT))
  63. URL:=http://www.denx.de/wiki/U-Boot
  64. endef
  65. define Package/u-boot-$(1)/install
  66. $$(Package/u-boot/install)
  67. endef
  68. endef
  69. define Build/Configure/U-Boot
  70. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) $(UBOOT_CONFIG)_config
  71. $(if $(strip $(UBOOT_CUSTOMIZE_CONFIG)),
  72. $(PKG_BUILD_DIR)/scripts/config --file $(PKG_BUILD_DIR)/.config $(UBOOT_CUSTOMIZE_CONFIG)
  73. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) oldconfig)
  74. endef
  75. DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
  76. define Build/Compile/U-Boot
  77. +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
  78. CROSS_COMPILE=$(TARGET_CROSS) \
  79. $(if $(DTC),DTC="$(DTC)") \
  80. $(UBOOT_MAKE_FLAGS)
  81. endef
  82. define BuildPackage/U-Boot/Defaults
  83. Build/Configure/Default = $$$$(Build/Configure/U-Boot)
  84. Build/Compile/Default = $$$$(Build/Compile/U-Boot)
  85. endef
  86. define BuildPackage/U-Boot
  87. $(eval $(call BuildPackage/U-Boot/Defaults))
  88. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  89. $(eval $(call Build/U-Boot/Target,$(type)))
  90. )
  91. $(eval $(call Build/DefaultTargets))
  92. $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
  93. $(call BuildPackage,u-boot-$(type))
  94. )
  95. endef