1 # SPDX-License-Identifier: GPL-2.0+
3 # (C) Copyright 2000-2006
4 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 # A note on target vs host configuration:
8 # Host tools can be used across multiple targets, or different configurations
9 # of the same target. Thus, host tools must be able to handle any combination
10 # of target configurations. To prevent having different variations of the same
11 # tool, the tool build options may not depend on target configuration.
13 # Some linux distributions package these utilities as u-boot-tools, and it
14 # would be unmaintainable to have a different tool variation for each
15 # arch or configuration.
17 # A couple of simple rules:
19 # 1) Do not use target CONFIG_* options to enable or disable features in host
20 # tools. Only use the configs from tools/Kconfig
21 # 2) It's okay to use target configs to disable building specific tools.
22 # That's as long as the features of those tools aren't modified.
25 # Enable all the config-independent tools
26 ifneq ($(HOST_TOOLS_ALL),)
27 CONFIG_ARCH_KIRKWOOD = y
31 CONFIG_XWAY_SWAP_BYTES = y
33 CONFIG_SHA1_CHECK_UB_IMG = y
37 subdir-$(HOST_TOOLS_ALL) += gdb
39 # Merge all the different vars for envcrc into one
40 ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
41 ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
42 ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
43 ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
44 ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
45 ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
46 ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
47 CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
49 hostprogs-$(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER) += atmel_pmecc_params
51 hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo
52 hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
53 HOSTCFLAGS_bmp_logo.o := -pedantic
55 hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc
56 envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
58 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
59 HOSTCFLAGS_gen_eth_addr.o := -pedantic
61 hostprogs-$(CONFIG_CMD_NET) += gen_ethaddr_crc
62 gen_ethaddr_crc-objs := gen_ethaddr_crc.o lib/crc8.o
63 HOSTCFLAGS_gen_ethaddr_crc.o := -pedantic
65 hostprogs-$(CONFIG_CMD_LOADS) += img2srec
66 HOSTCFLAGS_img2srec.o := -pedantic
68 hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes
69 HOSTCFLAGS_xway-swap-bytes.o := -pedantic
71 hostprogs-y += mkenvimage
72 mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
74 hostprogs-y += dumpimage mkimage
75 hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign
77 hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include
79 FIT_OBJS-y := fit_common.o fit_image.o image-host.o boot/image-fit.o
80 FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o boot/image-fit-sig.o
81 FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := boot/image-cipher.o
83 # The following files are synced with upstream DTC.
84 # Use synced versions from scripts/dtc/libfdt/.
85 LIBFDT_OBJS := $(addprefix libfdt/, fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o \
86 fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o)
88 RSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/rsa/, \
89 rsa-sign.o rsa-verify.o \
92 ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/ecdsa/, ecdsa-libcrypto.o)
94 AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/aes/, \
95 aes-encrypt.o aes-decrypt.o)
97 # Cryptographic helpers and image types that depend on openssl/libcrypto
98 LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := \
102 ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
104 # common objs for dumpimage and mkimage
105 dumpimage-mkimage-objs := aisimage.o \
109 $(FIT_CIPHER_OBJS-y) \
114 lib/fdtdec_common.o \
136 lib/hash-checksum.o \
145 $(LIBCRYPTO_OBJS-y) \
154 dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o
155 mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o
156 fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o
157 fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o
158 file2include-objs := file2include.o
160 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)
161 # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
162 # the mxsimage support within tools/mxsimage.c .
163 HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS
166 ifdef CONFIG_TOOLS_LIBCRYPTO
167 # This affects include/image.h, but including the board config file
168 # is tricky, so manually define this options here.
169 HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE
170 HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0xffffffff
171 HOST_EXTRACFLAGS += -DCONFIG_FIT_CIPHER
174 # MXSImage needs LibSSL
175 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCRYPTO),)
176 HOSTCFLAGS_kwbimage.o += \
177 $(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "")
178 HOSTLDLIBS_mkimage += \
179 $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
181 # OS X deprecate openssl in favour of CommonCrypto, supress deprecation
182 # warnings on those systems
183 ifeq ($(HOSTOS),darwin)
184 HOSTCFLAGS_mxsimage.o += -Wno-deprecated-declarations
185 HOSTCFLAGS_image-sig.o += -Wno-deprecated-declarations
186 HOSTCFLAGS_rsa-sign.o += -Wno-deprecated-declarations
190 HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\"
192 HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage)
193 HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage)
194 HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage)
196 hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
197 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
198 HOSTCFLAGS_mkexynosspl.o := -pedantic
200 HOSTCFLAGS_kwboot.o += -pthread
201 HOSTLDLIBS_kwboot += -pthread -ltinfo
203 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
204 hostprogs-$(CONFIG_X86) += ifdtool
206 ifwitool-objs := ifwitool.o
207 hostprogs-$(CONFIG_X86)$(CONFIG_SANDBOX) += ifwitool
209 hostprogs-$(CONFIG_MX23) += mxsboot
210 hostprogs-$(CONFIG_MX28) += mxsboot
211 HOSTCFLAGS_mxsboot.o := -pedantic
213 hostprogs-$(CONFIG_ARCH_SUNXI) += mksunxiboot
214 hostprogs-$(CONFIG_ARCH_SUNXI) += sunxi-spl-image-builder
215 sunxi-spl-image-builder-objs := sunxi-spl-image-builder.o lib/bch.o
217 hostprogs-$(CONFIG_NETCONSOLE) += ncb
218 hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1
220 ubsha1-objs := os_support.o ubsha1.o lib/sha1.o
222 HOSTCFLAGS_ubsha1.o := -pedantic
224 hostprogs-$(CONFIG_ARCH_KIRKWOOD) += kwboot
225 hostprogs-$(CONFIG_ARCH_MVEBU) += kwboot
226 hostprogs-y += proftool
227 hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
228 hostprogs-$(CONFIG_RISCV) += prelink-riscv
230 hostprogs-$(CONFIG_ARCH_OCTEON) += update_octeon_header
231 update_octeon_header-objs := update_octeon_header.o lib/crc32.o
233 hostprogs-y += fdtgrep
234 fdtgrep-objs += $(LIBFDT_OBJS) boot/fdt_region.o fdtgrep.o
236 ifneq ($(TOOLS_ONLY),y)
237 hostprogs-y += spl_size_limit
240 hostprogs-$(CONFIG_MIPS) += mips-relocs
242 hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler
243 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
245 HOSTLDLIBS_mkeficapsule += -lgnutls -luuid
246 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
248 # We build some files with extra pedantic flags to try to minimize things
249 # that won't build on some weird host compiler -- though there are lots of
250 # exceptions for files that aren't complaint.
251 HOSTCFLAGS_crc32.o := -pedantic
252 HOSTCFLAGS_crc8.o := -pedantic
253 HOSTCFLAGS_md5.o := -pedantic
254 HOSTCFLAGS_sha1.o := -pedantic
255 HOSTCFLAGS_sha256.o := -pedantic
256 HOSTCFLAGS_sha512.o := -pedantic -DCONFIG_SHA512 -DCONFIG_SHA384
258 quiet_cmd_wrap = WRAP $@
259 cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
261 $(obj)/boot/%.c $(obj)/common/%.c $(obj)/env/%.c $(obj)/lib/%.c:
264 clean-dirs := lib common
266 always := $(hostprogs-y)
268 # Generated LCD/video logo
269 LOGO_H = $(objtree)/include/bmp_logo.h
270 LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
271 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
272 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
273 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
274 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
278 LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp
280 # Use board logo and fallback to vendor
281 ifneq ($(wildcard $(srctree)/$(src)/logos/$(BOARD).bmp),)
282 LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
284 ifneq ($(wildcard $(srctree)/$(src)/logos/$(VENDOR).bmp),)
285 LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
292 # Use native tools and options
293 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
294 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
296 HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
297 $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
298 -I$(srctree)/scripts/dtc/libfdt \
301 -D__KERNEL_STRICT_NAMES \
306 $(LOGO_H): $(obj)/bmp_logo $(LOGO_BMP)
307 $(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
309 ifeq ($(CONFIG_DM_VIDEO),y)
310 $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
311 $(obj)/bmp_logo --gen-bmp $(LOGO_BMP) > $@
313 $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
314 $(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
318 # Let clean descend into subdirs
321 ifneq ($(CROSS_BUILD_TOOLS),)
322 override HOSTCC = $(CC)
323 override HOSTCFLAGS = $(CFLAGS)
325 quiet_cmd_crosstools_strip = STRIP $^
326 cmd_crosstools_strip = $(STRIP) $^; touch $@
327 $(obj)/.strip: $(call objectify,$(filter $(always),$(hostprogs-y)))
328 $(call cmd,crosstools_strip)
332 clean-files += .strip