• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0+
2#
3# (C) Copyright 2000-2006
4# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5
6# Enable all the config-independent tools
7ifneq ($(HOST_TOOLS_ALL),)
8CONFIG_KIRKWOOD = y
9CONFIG_LCD_LOGO = y
10CONFIG_CMD_LOADS = y
11CONFIG_CMD_NET = y
12CONFIG_XWAY_SWAP_BYTES = y
13CONFIG_NETCONSOLE = y
14CONFIG_SHA1_CHECK_UB_IMG = y
15CONFIG_ARCH_SUNXI = y
16endif
17
18subdir-$(HOST_TOOLS_ALL) += gdb
19
20# Merge all the different vars for envcrc into one
21ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
22ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
23ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
24ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
25ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
26ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
27ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
28CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
29
30hostprogs-$(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER) += atmel_pmecc_params
31
32hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo
33hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
34HOSTCFLAGS_bmp_logo.o := -pedantic
35
36hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc
37envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
38
39hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
40HOSTCFLAGS_gen_eth_addr.o := -pedantic
41
42hostprogs-$(CONFIG_CMD_NET) += gen_ethaddr_crc
43gen_ethaddr_crc-objs := gen_ethaddr_crc.o lib/crc8.o
44HOSTCFLAGS_gen_ethaddr_crc.o := -pedantic
45
46hostprogs-$(CONFIG_CMD_LOADS) += img2srec
47HOSTCFLAGS_img2srec.o := -pedantic
48
49hostprogs-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes
50HOSTCFLAGS_xway-swap-bytes.o := -pedantic
51
52hostprogs-y += mkenvimage
53mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
54
55hostprogs-y += dumpimage mkimage
56hostprogs-$(CONFIG_FIT_SIGNATURE) += fit_info fit_check_sign
57
58hostprogs-$(CONFIG_CMD_BOOTEFI_SELFTEST) += file2include
59
60FIT_OBJS-$(CONFIG_FIT) := fit_common.o fit_image.o image-host.o common/image-fit.o
61FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o
62
63# The following files are synced with upstream DTC.
64# Use synced versions from scripts/dtc/libfdt/.
65LIBFDT_SRCS_SYNCED := fdt.c fdt_wip.c fdt_sw.c fdt_rw.c \
66		fdt_strerror.c fdt_empty_tree.c fdt_addresses.c fdt_overlay.c
67# The following files are locally modified for U-Boot (unfotunately).
68# Use U-Boot own versions from lib/libfdt/.
69LIBFDT_SRCS_UNSYNCED := fdt_ro.c fdt_region.c
70
71LIBFDT_OBJS := $(addprefix libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_SYNCED))) \
72	       $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_UNSYNCED)))
73
74RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
75					rsa-sign.o rsa-verify.o rsa-checksum.o \
76					rsa-mod-exp.o)
77
78ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
79
80# common objs for dumpimage and mkimage
81dumpimage-mkimage-objs := aisimage.o \
82			atmelimage.o \
83			$(FIT_OBJS-y) \
84			$(FIT_SIG_OBJS-y) \
85			common/bootm.o \
86			lib/crc32.o \
87			default_image.o \
88			lib/fdtdec_common.o \
89			lib/fdtdec.o \
90			common/image.o \
91			imagetool.o \
92			imximage.o \
93			imx8image.o \
94			imx8mimage.o \
95			kwbimage.o \
96			lib/md5.o \
97			lpc32xximage.o \
98			mxsimage.o \
99			omapimage.o \
100			os_support.o \
101			pblimage.o \
102			pbl_crc32.o \
103			vybridimage.o \
104			stm32image.o \
105			$(ROCKCHIP_OBS) \
106			socfpgaimage.o \
107			lib/crc16.o \
108			lib/sha1.o \
109			lib/sha256.o \
110			common/hash.o \
111			ublimage.o \
112			zynqimage.o \
113			zynqmpimage.o \
114			zynqmpbif.o \
115			$(LIBFDT_OBJS) \
116			gpimage.o \
117			gpimage-common.o \
118			mtk_image.o \
119			$(RSA_OBJS-y)
120
121dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o
122mkimage-objs   := $(dumpimage-mkimage-objs) mkimage.o
123fit_info-objs   := $(dumpimage-mkimage-objs) fit_info.o
124fit_check_sign-objs   := $(dumpimage-mkimage-objs) fit_check_sign.o
125file2include-objs := file2include.o
126
127ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),)
128# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
129# the mxsimage support within tools/mxsimage.c .
130HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS
131endif
132
133ifdef CONFIG_FIT_SIGNATURE
134# This affects include/image.h, but including the board config file
135# is tricky, so manually define this options here.
136HOST_EXTRACFLAGS	+= -DCONFIG_FIT_SIGNATURE
137HOST_EXTRACFLAGS	+= -DCONFIG_FIT_SIGNATURE_MAX_SIZE=$(CONFIG_FIT_SIGNATURE_MAX_SIZE)
138endif
139
140ifdef CONFIG_SYS_U_BOOT_OFFS
141HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS)
142endif
143
144ifneq ($(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X),)
145HOSTCFLAGS_kwbimage.o += -DCONFIG_KWB_SECURE
146endif
147
148# MXSImage needs LibSSL
149ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X)$(CONFIG_FIT_SIGNATURE),)
150HOSTCFLAGS_kwbimage.o += \
151	$(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "")
152HOSTLOADLIBES_mkimage += \
153	$(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
154
155# OS X deprecate openssl in favour of CommonCrypto, supress deprecation
156# warnings on those systems
157ifeq ($(HOSTOS),darwin)
158HOSTCFLAGS_mxsimage.o += -Wno-deprecated-declarations
159HOSTCFLAGS_image-sig.o += -Wno-deprecated-declarations
160HOSTCFLAGS_rsa-sign.o += -Wno-deprecated-declarations
161endif
162endif
163
164HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\"
165
166HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage)
167HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage)
168HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage)
169
170hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
171hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
172HOSTCFLAGS_mkexynosspl.o := -pedantic
173
174ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
175hostprogs-$(CONFIG_X86) += ifdtool
176
177ifwitool-objs := ifwitool.o
178hostprogs-$(CONFIG_X86)$(CONFIG_SANDBOX) += ifwitool
179
180hostprogs-$(CONFIG_MX23) += mxsboot
181hostprogs-$(CONFIG_MX28) += mxsboot
182HOSTCFLAGS_mxsboot.o := -pedantic
183
184hostprogs-$(CONFIG_ARCH_SUNXI) += mksunxiboot
185hostprogs-$(CONFIG_ARCH_SUNXI) += sunxi-spl-image-builder
186sunxi-spl-image-builder-objs := sunxi-spl-image-builder.o lib/bch.o
187
188hostprogs-$(CONFIG_NETCONSOLE) += ncb
189hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1
190
191ubsha1-objs := os_support.o ubsha1.o lib/sha1.o
192
193HOSTCFLAGS_ubsha1.o := -pedantic
194
195hostprogs-$(CONFIG_KIRKWOOD) += kwboot
196hostprogs-$(CONFIG_ARCH_MVEBU) += kwboot
197hostprogs-y += proftool
198hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
199hostprogs-$(CONFIG_RISCV) += prelink-riscv
200
201hostprogs-y += fdtgrep
202fdtgrep-objs += $(LIBFDT_OBJS) fdtgrep.o
203
204ifneq ($(TOOLS_ONLY),y)
205hostprogs-y += spl_size_limit
206endif
207
208hostprogs-$(CONFIG_MIPS) += mips-relocs
209
210hostprogs-$(CONFIG_ASN1_COMPILER)	+= asn1_compiler
211HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
212
213# We build some files with extra pedantic flags to try to minimize things
214# that won't build on some weird host compiler -- though there are lots of
215# exceptions for files that aren't complaint.
216HOSTCFLAGS_crc32.o := -pedantic
217HOSTCFLAGS_crc8.o := -pedantic
218HOSTCFLAGS_md5.o := -pedantic
219HOSTCFLAGS_sha1.o := -pedantic
220HOSTCFLAGS_sha256.o := -pedantic
221
222quiet_cmd_wrap = WRAP    $@
223cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
224
225$(obj)/lib/%.c $(obj)/common/%.c $(obj)/env/%.c:
226	$(call cmd,wrap)
227
228clean-dirs := lib common
229
230always := $(hostprogs-y)
231
232# Generated LCD/video logo
233LOGO_H = $(objtree)/include/bmp_logo.h
234LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
235LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
236LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
237LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
238LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
239
240# Generic logo
241ifeq ($(LOGO_BMP),)
242LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp
243
244# Use board logo and fallback to vendor
245ifneq ($(wildcard $(srctree)/$(src)/logos/$(BOARD).bmp),)
246LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
247else
248ifneq ($(wildcard $(srctree)/$(src)/logos/$(VENDOR).bmp),)
249LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
250endif
251endif
252
253endif # !LOGO_BMP
254
255#
256# Use native tools and options
257# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
258# Define _GNU_SOURCE to obtain the getline prototype from stdio.h
259#
260HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
261		$(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
262		-I$(srctree)/scripts/dtc/libfdt \
263		-I$(srctree)/tools \
264		-DUSE_HOSTCC \
265		-D__KERNEL_STRICT_NAMES \
266		-D_GNU_SOURCE \
267		-std=gnu99
268
269__build:	$(LOGO-y)
270
271$(LOGO_H):	$(obj)/bmp_logo $(LOGO_BMP)
272	$(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
273
274ifeq ($(CONFIG_DM_VIDEO),y)
275$(LOGO_DATA_H):	$(obj)/bmp_logo $(LOGO_BMP)
276	$(obj)/bmp_logo --gen-bmp $(LOGO_BMP) > $@
277else
278$(LOGO_DATA_H):	$(obj)/bmp_logo $(LOGO_BMP)
279	$(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
280#endif
281endif
282
283# Let clean descend into subdirs
284subdir- += env
285
286ifneq ($(CROSS_BUILD_TOOLS),)
287override HOSTCC = $(CC)
288override HOSTCFLAGS = $(CFLAGS)
289
290quiet_cmd_crosstools_strip = STRIP   $^
291      cmd_crosstools_strip = $(STRIP) $^; touch $@
292$(obj)/.strip: $(call objectify,$(filter $(always),$(hostprogs-y)))
293	$(call cmd,crosstools_strip)
294
295always += .strip
296endif
297clean-files += .strip
298