Makefile 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. #
  2. # (C) Copyright 2000-2006
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. # Enable all the config-independent tools
  8. ifneq ($(HOST_TOOLS_ALL),)
  9. CONFIG_LCD_LOGO = y
  10. CONFIG_CMD_LOADS = y
  11. CONFIG_CMD_NET = y
  12. CONFIG_XWAY_SWAP_BYTES = y
  13. CONFIG_NETCONSOLE = y
  14. CONFIG_SHA1_CHECK_UB_IMG = y
  15. CONFIG_ARCH_SUNXI = y
  16. endif
  17. subdir-$(HOST_TOOLS_ALL) += easylogo
  18. subdir-$(HOST_TOOLS_ALL) += gdb
  19. # Merge all the different vars for envcrc into one
  20. ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
  21. ENVCRC-$(CONFIG_ENV_IS_IN_DATAFLASH) = y
  22. ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
  23. ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
  24. ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
  25. ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
  26. ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
  27. ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
  28. CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
  29. hostprogs-$(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER) += atmel_pmecc_params
  30. hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo
  31. hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
  32. HOSTCFLAGS_bmp_logo.o := -pedantic
  33. hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc
  34. envcrc-objs := envcrc.o lib/crc32.o common/env_embedded.o lib/sha1.o
  35. hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
  36. HOSTCFLAGS_gen_eth_addr.o := -pedantic
  37. hostprogs-$(CONFIG_CMD_NET) += gen_ethaddr_crc
  38. gen_ethaddr_crc-objs := gen_ethaddr_crc.o lib/crc8.o
  39. HOSTCFLAGS_gen_ethaddr_crc.o := -pedantic
  40. hostprogs-$(CONFIG_CMD_LOADS) += img2srec
  41. HOSTCFLAGS_img2srec.o := -pedantic
  42. hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes
  43. HOSTCFLAGS_xway-swap-bytes.o := -pedantic
  44. hostprogs-y += mkenvimage
  45. mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
  46. hostprogs-y += dumpimage mkimage
  47. hostprogs-$(CONFIG_FIT_SIGNATURE) += fit_info fit_check_sign
  48. FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o
  49. # Flattened device tree objects
  50. LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \
  51. fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \
  52. fdt_region.c
  53. # Unfortunately setup.py below cannot handle srctree being ".." which it often
  54. # is. It fails with an error like:
  55. # Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
  56. # No such file or directory
  57. # To fix this, use an absolute path.
  58. libfdt_tree := $(shell readlink -f $(srctree)/lib/libfdt)
  59. LIBFDT_SRCS := $(addprefix $(libfdt_tree)/, $(LIBFDT_CSRCS))
  60. LIBFDT_SWIG := $(addprefix $(libfdt_tree)/, pylibfdt/libfdt.i)
  61. LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS)))
  62. RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
  63. rsa-sign.o rsa-verify.o rsa-checksum.o \
  64. rsa-mod-exp.o)
  65. ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
  66. # common objs for dumpimage and mkimage
  67. dumpimage-mkimage-objs := aisimage.o \
  68. atmelimage.o \
  69. $(FIT_SIG_OBJS-y) \
  70. common/bootm.o \
  71. lib/crc32.o \
  72. default_image.o \
  73. lib/fdtdec_common.o \
  74. lib/fdtdec.o \
  75. fit_common.o \
  76. fit_image.o \
  77. common/image-fit.o \
  78. image-host.o \
  79. common/image.o \
  80. imagetool.o \
  81. imximage.o \
  82. kwbimage.o \
  83. lib/md5.o \
  84. lpc32xximage.o \
  85. mxsimage.o \
  86. omapimage.o \
  87. os_support.o \
  88. pblimage.o \
  89. pbl_crc32.o \
  90. vybridimage.o \
  91. $(ROCKCHIP_OBS) \
  92. socfpgaimage.o \
  93. lib/sha1.o \
  94. lib/sha256.o \
  95. common/hash.o \
  96. ublimage.o \
  97. zynqimage.o \
  98. zynqmpimage.o \
  99. $(LIBFDT_OBJS) \
  100. gpimage.o \
  101. gpimage-common.o \
  102. $(RSA_OBJS-y)
  103. dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o
  104. mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o
  105. fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o
  106. fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o
  107. # Unfortunately setup.py (or actually the Python distutil implementation)
  108. # puts files into the same directory as the .i file. We cannot touch the source
  109. # directory, so we copy the .i file into the tools/ build subdirectory before
  110. # calling setup. This directory is safe to write to. This ensures that we get
  111. # all three files in $(obj)/tools: _libfdt.so, libfdt.py and libfdt_wrap.c
  112. # The latter is a temporary file which we could actually remove.
  113. tools/_libfdt.so: $(LIBFDT_SRCS) $(LIBFDT_SWIG)
  114. cp $(LIBFDT_SWIG) tools/.
  115. unset CC; \
  116. unset CROSS_COMPILE; \
  117. LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= VERSION="u-boot-$(UBOOTVERSION)" \
  118. CPPFLAGS="$(_hostc_flags)" OBJDIR=tools \
  119. SOURCES="$(LIBFDT_SRCS) tools/libfdt.i" \
  120. SWIG_OPTS="-I$(srctree)/lib/libfdt -I$(srctree)/lib" \
  121. $(libfdt_tree)/pylibfdt/setup.py --quiet build_ext \
  122. --build-lib tools
  123. ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
  124. # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
  125. # the mxsimage support within tools/mxsimage.c .
  126. HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS
  127. endif
  128. ifdef CONFIG_FIT_SIGNATURE
  129. # This affects include/image.h, but including the board config file
  130. # is tricky, so manually define this options here.
  131. HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE
  132. endif
  133. ifdef CONFIG_SYS_U_BOOT_OFFS
  134. HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS)
  135. endif
  136. ifneq ($(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X),)
  137. HOSTCFLAGS_kwbimage.o += -DCONFIG_KWB_SECURE
  138. endif
  139. # MXSImage needs LibSSL
  140. ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X)$(CONFIG_FIT_SIGNATURE),)
  141. HOSTLOADLIBES_mkimage += \
  142. $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
  143. # OS X deprecate openssl in favour of CommonCrypto, supress deprecation
  144. # warnings on those systems
  145. ifeq ($(HOSTOS),darwin)
  146. HOSTCFLAGS_mxsimage.o += -Wno-deprecated-declarations
  147. HOSTCFLAGS_image-sig.o += -Wno-deprecated-declarations
  148. HOSTCFLAGS_rsa-sign.o += -Wno-deprecated-declarations
  149. endif
  150. endif
  151. HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(DTC)\"
  152. HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage)
  153. HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage)
  154. HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage)
  155. hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
  156. hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
  157. HOSTCFLAGS_mkexynosspl.o := -pedantic
  158. ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
  159. hostprogs-$(CONFIG_X86) += ifdtool
  160. hostprogs-$(CONFIG_MX23) += mxsboot
  161. hostprogs-$(CONFIG_MX28) += mxsboot
  162. HOSTCFLAGS_mxsboot.o := -pedantic
  163. hostprogs-$(CONFIG_ARCH_SUNXI) += mksunxiboot
  164. hostprogs-$(CONFIG_ARCH_SUNXI) += sunxi-spl-image-builder
  165. sunxi-spl-image-builder-objs := sunxi-spl-image-builder.o lib/bch.o
  166. hostprogs-$(CONFIG_NETCONSOLE) += ncb
  167. hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1
  168. ubsha1-objs := os_support.o ubsha1.o lib/sha1.o
  169. HOSTCFLAGS_ubsha1.o := -pedantic
  170. hostprogs-$(CONFIG_KIRKWOOD) += kwboot
  171. hostprogs-$(CONFIG_ARCH_MVEBU) += kwboot
  172. hostprogs-y += proftool
  173. hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
  174. hostprogs-y += fdtgrep
  175. fdtgrep-objs += $(LIBFDT_OBJS) fdtgrep.o
  176. hostprogs-$(CONFIG_MIPS) += mips-relocs
  177. # We build some files with extra pedantic flags to try to minimize things
  178. # that won't build on some weird host compiler -- though there are lots of
  179. # exceptions for files that aren't complaint.
  180. HOSTCFLAGS_crc32.o := -pedantic
  181. HOSTCFLAGS_crc8.o := -pedantic
  182. HOSTCFLAGS_md5.o := -pedantic
  183. HOSTCFLAGS_sha1.o := -pedantic
  184. HOSTCFLAGS_sha256.o := -pedantic
  185. quiet_cmd_wrap = WRAP $@
  186. cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
  187. $(obj)/lib/%.c $(obj)/common/%.c:
  188. $(call cmd,wrap)
  189. clean-dirs := lib common
  190. always := $(hostprogs-y)
  191. # Build a libfdt Python module if swig is available
  192. # Use 'sudo apt-get install swig libpython-dev' to enable this
  193. always += $(if $(shell which swig 2> /dev/null),_libfdt.so)
  194. # Generated LCD/video logo
  195. LOGO_H = $(objtree)/include/bmp_logo.h
  196. LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
  197. LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
  198. LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
  199. LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
  200. LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
  201. # Generic logo
  202. ifeq ($(LOGO_BMP),)
  203. LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp
  204. # Use board logo and fallback to vendor
  205. ifneq ($(wildcard $(srctree)/$(src)/logos/$(BOARD).bmp),)
  206. LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
  207. else
  208. ifneq ($(wildcard $(srctree)/$(src)/logos/$(VENDOR).bmp),)
  209. LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
  210. endif
  211. endif
  212. endif # !LOGO_BMP
  213. #
  214. # Use native tools and options
  215. # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
  216. # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
  217. #
  218. HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
  219. $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
  220. -I$(srctree)/lib/libfdt \
  221. -I$(srctree)/tools \
  222. -DUSE_HOSTCC \
  223. -D__KERNEL_STRICT_NAMES \
  224. -D_GNU_SOURCE
  225. __build: $(LOGO-y)
  226. $(LOGO_H): $(obj)/bmp_logo $(LOGO_BMP)
  227. $(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
  228. $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
  229. $(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
  230. # Let clean descend into subdirs
  231. subdir- += env
  232. ifneq ($(CROSS_BUILD_TOOLS),)
  233. override HOSTCC = $(CC)
  234. quiet_cmd_crosstools_strip = STRIP $^
  235. cmd_crosstools_strip = $(STRIP) $^; touch $@
  236. $(obj)/.strip: $(call objectify,$(filter $(always),$(hostprogs-y)))
  237. $(call cmd,crosstools_strip)
  238. always += .strip
  239. endif
  240. clean-files += .strip