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 common/image-fit.o
80 FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o common/image-fit-sig.o
81 FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := common/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 that depend on openssl/libcrypto
98 LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/, \
101 ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
103 # common objs for dumpimage and mkimage
104 dumpimage-mkimage-objs := aisimage.o \
108 $(FIT_CIPHER_OBJS-y) \
109 common/fdt_region.o \
113 lib/fdtdec_common.o \
134 lib/hash-checksum.o \
143 $(LIBCRYPTO_OBJS-y) \
152 dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o
153 mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o
154 fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o
155 fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o
156 file2include-objs := file2include.o
158 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)
159 # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
160 # the mxsimage support within tools/mxsimage.c .
161 HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS
164 ifdef CONFIG_TOOLS_LIBCRYPTO
165 # This affects include/image.h, but including the board config file
166 # is tricky, so manually define this options here.
167 HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE
168 HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0xffffffff
169 HOST_EXTRACFLAGS += -DCONFIG_FIT_CIPHER
172 ifneq ($(CONFIG_SYS_U_BOOT_OFFS),)
173 HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS)
176 ifneq ($(CONFIG_ARMADA_38X),)
177 HOSTCFLAGS_kwbimage.o += -DCONFIG_KWB_SECURE
180 # MXSImage needs LibSSL
181 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCRYPTO),)
182 HOSTCFLAGS_kwbimage.o += \
183 $(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "")
184 HOSTLDLIBS_mkimage += \
185 $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
187 # OS X deprecate openssl in favour of CommonCrypto, supress deprecation
188 # warnings on those systems
189 ifeq ($(HOSTOS),darwin)
190 HOSTCFLAGS_mxsimage.o += -Wno-deprecated-declarations
191 HOSTCFLAGS_image-sig.o += -Wno-deprecated-declarations
192 HOSTCFLAGS_rsa-sign.o += -Wno-deprecated-declarations
196 HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\"
198 HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage)
199 HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage)
200 HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage)
202 hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
203 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
204 HOSTCFLAGS_mkexynosspl.o := -pedantic
206 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
207 hostprogs-$(CONFIG_X86) += ifdtool
209 ifwitool-objs := ifwitool.o
210 hostprogs-$(CONFIG_X86)$(CONFIG_SANDBOX) += ifwitool
212 hostprogs-$(CONFIG_MX23) += mxsboot
213 hostprogs-$(CONFIG_MX28) += mxsboot
214 HOSTCFLAGS_mxsboot.o := -pedantic
216 hostprogs-$(CONFIG_ARCH_SUNXI) += mksunxiboot
217 hostprogs-$(CONFIG_ARCH_SUNXI) += sunxi-spl-image-builder
218 sunxi-spl-image-builder-objs := sunxi-spl-image-builder.o lib/bch.o
220 hostprogs-$(CONFIG_NETCONSOLE) += ncb
221 hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1
223 ubsha1-objs := os_support.o ubsha1.o lib/sha1.o
225 HOSTCFLAGS_ubsha1.o := -pedantic
227 hostprogs-$(CONFIG_ARCH_KIRKWOOD) += kwboot
228 hostprogs-$(CONFIG_ARCH_MVEBU) += kwboot
229 hostprogs-y += proftool
230 hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
231 hostprogs-$(CONFIG_RISCV) += prelink-riscv
233 hostprogs-$(CONFIG_ARCH_OCTEON) += update_octeon_header
234 update_octeon_header-objs := update_octeon_header.o lib/crc32.o
236 hostprogs-y += fdtgrep
237 fdtgrep-objs += $(LIBFDT_OBJS) common/fdt_region.o fdtgrep.o
239 ifneq ($(TOOLS_ONLY),y)
240 hostprogs-y += spl_size_limit
243 hostprogs-$(CONFIG_MIPS) += mips-relocs
245 hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler
246 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
248 mkeficapsule-objs := mkeficapsule.o $(LIBFDT_OBJS)
249 hostprogs-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += mkeficapsule
251 # We build some files with extra pedantic flags to try to minimize things
252 # that won't build on some weird host compiler -- though there are lots of
253 # exceptions for files that aren't complaint.
254 HOSTCFLAGS_crc32.o := -pedantic
255 HOSTCFLAGS_crc8.o := -pedantic
256 HOSTCFLAGS_md5.o := -pedantic
257 HOSTCFLAGS_sha1.o := -pedantic
258 HOSTCFLAGS_sha256.o := -pedantic
259 HOSTCFLAGS_sha512.o := -pedantic -DCONFIG_SHA512 -DCONFIG_SHA384
261 quiet_cmd_wrap = WRAP $@
262 cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
264 $(obj)/lib/%.c $(obj)/common/%.c $(obj)/env/%.c:
267 clean-dirs := lib common
269 always := $(hostprogs-y)
271 # Generated LCD/video logo
272 LOGO_H = $(objtree)/include/bmp_logo.h
273 LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
274 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
275 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
276 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
277 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
281 LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp
283 # Use board logo and fallback to vendor
284 ifneq ($(wildcard $(srctree)/$(src)/logos/$(BOARD).bmp),)
285 LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
287 ifneq ($(wildcard $(srctree)/$(src)/logos/$(VENDOR).bmp),)
288 LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
295 # Use native tools and options
296 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
297 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
299 HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
300 $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
301 -I$(srctree)/scripts/dtc/libfdt \
304 -D__KERNEL_STRICT_NAMES \
310 $(LOGO_H): $(obj)/bmp_logo $(LOGO_BMP)
311 $(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
313 ifeq ($(CONFIG_DM_VIDEO),y)
314 $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
315 $(obj)/bmp_logo --gen-bmp $(LOGO_BMP) > $@
317 $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
318 $(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
322 # Let clean descend into subdirs
325 ifneq ($(CROSS_BUILD_TOOLS),)
326 override HOSTCC = $(CC)
327 override HOSTCFLAGS = $(CFLAGS)
329 quiet_cmd_crosstools_strip = STRIP $^
330 cmd_crosstools_strip = $(STRIP) $^; touch $@
331 $(obj)/.strip: $(call objectify,$(filter $(always),$(hostprogs-y)))
332 $(call cmd,crosstools_strip)
336 clean-files += .strip