u-boot.mk 2.6 KB

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