]> Git Repo - J-u-boot.git/blob - tools/Makefile
console: Use only 0x00 as line separator for console recording
[J-u-boot.git] / tools / Makefile
1 # SPDX-License-Identifier: GPL-2.0+
2 #
3 # (C) Copyright 2000-2006
4 # Wolfgang Denk, DENX Software Engineering, [email protected].
5
6 # A note on target vs host configuration:
7 #
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.
12 #
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.
16 #
17 # A couple of simple rules:
18 #
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.
23 #
24
25 # Enable all the config-independent tools
26 ifneq ($(HOST_TOOLS_ALL),)
27 CONFIG_ARCH_KIRKWOOD = y
28 CONFIG_CMD_LOADS = y
29 CONFIG_CMD_NET = y
30 CONFIG_NETCONSOLE = y
31 CONFIG_ARCH_SUNXI = y
32 endif
33
34 subdir-$(HOST_TOOLS_ALL) += gdb
35
36 # Merge all the different vars for envcrc into one
37 ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
38 ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
39 ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
40 ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
41 ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
42 ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
43 BUILD_ENVCRC ?= $(ENVCRC-y)
44
45 hostprogs-$(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER) += atmel_pmecc_params
46
47 hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
48 HOSTCFLAGS_bmp_logo.o := -pedantic
49
50 hostprogs-$(BUILD_ENVCRC) += envcrc
51 envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
52
53 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
54 HOSTCFLAGS_gen_eth_addr.o := -pedantic
55
56 hostprogs-$(CONFIG_CMD_NET) += gen_ethaddr_crc
57 gen_ethaddr_crc-objs := gen_ethaddr_crc.o lib/crc8.o
58 HOSTCFLAGS_gen_ethaddr_crc.o := -pedantic
59
60 hostprogs-$(CONFIG_CMD_LOADS) += img2srec
61 HOSTCFLAGS_img2srec.o := -pedantic
62
63 hostprogs-y += mkenvimage
64 mkenvimage-objs := mkenvimage.o os_support.o lib/crc32.o
65
66 hostprogs-y += dumpimage mkimage
67 hostprogs-$(CONFIG_TOOLS_LIBCRYPTO) += fit_info fit_check_sign
68
69 ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST)$(CONFIG_FWU_MDATA_GPT_BLK),)
70 hostprogs-y += file2include
71 endif
72
73 FIT_OBJS-y := fit_common.o fit_image.o image-host.o boot/image-fit.o
74 FIT_SIG_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := image-sig-host.o boot/image-fit-sig.o
75 FIT_CIPHER_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := boot/image-cipher.o
76
77 # The following files are synced with upstream DTC.
78 # Use synced versions from scripts/dtc/libfdt/.
79 LIBFDT_OBJS := $(addprefix libfdt/, fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o \
80                 fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o)
81
82 RSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/rsa/, \
83                                         rsa-sign.o rsa-verify.o \
84                                         rsa-mod-exp.o)
85
86 ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/ecdsa/, ecdsa-libcrypto.o)
87
88 AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/aes/, \
89                                         aes-encrypt.o aes-decrypt.o)
90
91 # Cryptographic helpers and image types that depend on openssl/libcrypto
92 LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := \
93                         lib/fdt-libcrypto.o \
94                         sunxi_toc0.o
95
96 ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o
97
98 # common objs for dumpimage and mkimage
99 dumpimage-mkimage-objs := aisimage.o \
100                         atmelimage.o \
101                         $(FIT_OBJS-y) \
102                         $(FIT_SIG_OBJS-y) \
103                         $(FIT_CIPHER_OBJS-y) \
104                         boot/fdt_region.o \
105                         boot/bootm.o \
106                         lib/crc32.o \
107                         default_image.o \
108                         lib/fdtdec_common.o \
109                         lib/fdtdec.o \
110                         boot/image.o \
111                         boot/image-host.o \
112                         imagetool.o \
113                         imximage.o \
114                         imx8image.o \
115                         imx8mimage.o \
116                         kwbimage.o \
117                         lib/md5.o \
118                         lpc32xximage.o \
119                         mxsimage.o \
120                         omapimage.o \
121                         os_support.o \
122                         pblimage.o \
123                         pbl_crc32.o \
124                         vybridimage.o \
125                         stm32image.o \
126                         $(ROCKCHIP_OBS) \
127                         socfpgaimage.o \
128                         sunxi_egon.o \
129                         lib/crc16-ccitt.o \
130                         lib/hash-checksum.o \
131                         lib/sha1.o \
132                         lib/sha256.o \
133                         lib/sha512.o \
134                         common/hash.o \
135                         ublimage.o \
136                         zynqimage.o \
137                         zynqmpimage.o \
138                         zynqmpbif.o \
139                         $(LIBCRYPTO_OBJS-y) \
140                         $(LIBFDT_OBJS) \
141                         gpimage.o \
142                         gpimage-common.o \
143                         mtk_image.o \
144                         mtk_nand_headers.o \
145                         $(ECDSA_OBJS-y) \
146                         $(RSA_OBJS-y) \
147                         $(AES_OBJS-y)
148
149 dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o
150 mkimage-objs   := $(dumpimage-mkimage-objs) mkimage.o
151 fit_info-objs   := $(dumpimage-mkimage-objs) fit_info.o
152 fit_check_sign-objs   := $(dumpimage-mkimage-objs) fit_check_sign.o
153 file2include-objs := file2include.o
154
155 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),)
156 # Add CFG_MXS into host CFLAGS, so we can check whether or not register
157 # the mxsimage support within tools/mxsimage.c .
158 HOSTCFLAGS_mxsimage.o += -DCFG_MXS
159 endif
160
161 ifdef CONFIG_TOOLS_LIBCRYPTO
162 # This affects include/image.h, but including the board config file
163 # is tricky, so manually define this options here.
164 HOST_EXTRACFLAGS        += -DCONFIG_FIT_SIGNATURE
165 HOST_EXTRACFLAGS        += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0xffffffff
166 HOST_EXTRACFLAGS        += -DCONFIG_FIT_CIPHER
167 endif
168
169 # MXSImage needs LibSSL
170 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCRYPTO),)
171 HOSTCFLAGS_kwbimage.o += \
172         $(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "")
173 HOSTLDLIBS_mkimage += \
174         $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto")
175
176 # OS X deprecate openssl in favour of CommonCrypto, supress deprecation
177 # warnings on those systems
178 ifeq ($(HOSTOS),darwin)
179 HOSTCFLAGS_mxsimage.o += -Wno-deprecated-declarations
180 HOSTCFLAGS_image-sig.o += -Wno-deprecated-declarations
181 HOSTCFLAGS_rsa-sign.o += -Wno-deprecated-declarations
182 endif
183 endif
184
185 HOSTCFLAGS_fit_image.o += -DMKIMAGE_DTC=\"$(CONFIG_MKIMAGE_DTC_PATH)\"
186
187 HOSTLDLIBS_dumpimage := $(HOSTLDLIBS_mkimage)
188 HOSTLDLIBS_fit_info := $(HOSTLDLIBS_mkimage)
189 HOSTLDLIBS_fit_check_sign := $(HOSTLDLIBS_mkimage)
190
191 hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
192 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
193 HOSTCFLAGS_mkexynosspl.o := -pedantic
194
195 HOSTCFLAGS_kwboot.o += -pthread
196 HOSTLDLIBS_kwboot += -pthread
197 HOSTLDLIBS_kwboot += \
198         $(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
199
200 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
201 hostprogs-$(CONFIG_X86) += ifdtool
202
203 ifwitool-objs := ifwitool.o
204 hostprogs-$(CONFIG_X86)$(CONFIG_SANDBOX) += ifwitool
205
206 hostprogs-$(CONFIG_MX23) += mxsboot
207 hostprogs-$(CONFIG_MX28) += mxsboot
208 HOSTCFLAGS_mxsboot.o := -pedantic
209
210 hostprogs-$(CONFIG_ARCH_SUNXI) += mksunxiboot
211 hostprogs-$(CONFIG_ARCH_SUNXI) += sunxi-spl-image-builder
212 sunxi-spl-image-builder-objs := sunxi-spl-image-builder.o lib/bch.o
213
214 hostprogs-$(CONFIG_NETCONSOLE) += ncb
215
216 hostprogs-$(CONFIG_ARCH_KIRKWOOD) += kwboot
217 hostprogs-$(CONFIG_ARCH_MVEBU) += kwboot
218
219 hostprogs-y += proftool
220 proftool-objs = proftool.o lib/abuf.o
221
222 hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
223 hostprogs-$(CONFIG_RISCV) += prelink-riscv
224
225 hostprogs-$(CONFIG_ARCH_OCTEON) += update_octeon_header
226 update_octeon_header-objs := update_octeon_header.o lib/crc32.o
227
228 hostprogs-y += fdtgrep
229 fdtgrep-objs += $(LIBFDT_OBJS) boot/fdt_region.o fdtgrep.o
230
231 ifneq ($(TOOLS_ONLY),y)
232 hostprogs-y += spl_size_limit
233 endif
234
235 hostprogs-$(CONFIG_MIPS) += mips-relocs
236
237 hostprogs-$(CONFIG_ASN1_COMPILER)       += asn1_compiler
238 HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
239
240 HOSTCFLAGS_mkeficapsule.o += \
241         $(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
242 HOSTCFLAGS_mkeficapsule.o += \
243         $(shell pkg-config --cflags uuid 2> /dev/null || echo "")
244 HOSTLDLIBS_mkeficapsule += \
245         $(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls")
246 HOSTLDLIBS_mkeficapsule += \
247         $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid")
248 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
249
250 # We build some files with extra pedantic flags to try to minimize things
251 # that won't build on some weird host compiler -- though there are lots of
252 # exceptions for files that aren't complaint.
253 HOSTCFLAGS_crc32.o := -pedantic
254 HOSTCFLAGS_crc8.o := -pedantic
255 HOSTCFLAGS_md5.o := -pedantic
256 HOSTCFLAGS_sha1.o := -pedantic
257 HOSTCFLAGS_sha256.o := -pedantic
258 HOSTCFLAGS_sha512.o := -pedantic -DCONFIG_SHA512 -DCONFIG_SHA384
259
260 quiet_cmd_wrap = WRAP    $@
261 cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
262
263 $(obj)/boot/%.c $(obj)/common/%.c $(obj)/env/%.c $(obj)/lib/%.c:
264         $(call cmd,wrap)
265
266 clean-dirs := lib common
267
268 always := $(hostprogs-y)
269
270 # Host tool to dump the currently configured default environment,
271 # build it on demand, i.e. not add it to 'always'.
272 hostprogs-y += printinitialenv
273
274 # Generated LCD/video logo
275 LOGO_H = $(objtree)/include/bmp_logo.h
276 LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
277 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
278 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
279
280 # Generic logo
281 ifeq ($(LOGO_BMP),)
282 LOGO_BMP= $(srctree)/$(src)/logos/denx.bmp
283
284 # Use board logo and fallback to vendor
285 ifneq ($(wildcard $(srctree)/$(src)/logos/$(BOARD).bmp),)
286 LOGO_BMP= $(srctree)/$(src)/logos/$(BOARD).bmp
287 else
288 ifneq ($(wildcard $(srctree)/$(src)/logos/$(VENDOR).bmp),)
289 LOGO_BMP= $(srctree)/$(src)/logos/$(VENDOR).bmp
290 endif
291 endif
292
293 endif # !LOGO_BMP
294
295 #
296 # Use native tools and options
297 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
298 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
299 #
300 HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
301                 $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
302                 -I$(srctree)/scripts/dtc/libfdt \
303                 -I$(srctree)/tools \
304                 -DUSE_HOSTCC \
305                 -D__KERNEL_STRICT_NAMES \
306                 -D_GNU_SOURCE
307
308 __build:        $(LOGO-y)
309
310 $(LOGO_H):      $(obj)/bmp_logo $(LOGO_BMP)
311         $(obj)/bmp_logo --gen-info $(LOGO_BMP) > $@
312
313 ifeq ($(CONFIG_VIDEO),y)
314 $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
315         $(obj)/bmp_logo --gen-bmp $(LOGO_BMP) > $@
316 else
317 $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
318         $(obj)/bmp_logo --gen-data $(LOGO_BMP) > $@
319 #endif
320 endif
321
322 # Let clean descend into subdirs
323 subdir- += env
324
325 ifneq ($(CROSS_BUILD_TOOLS),)
326 override HOSTCC = $(CC)
327 override HOSTCFLAGS = $(CFLAGS)
328
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)
333
334 always += .strip
335 endif
336 clean-files += .strip
This page took 0.048739 seconds and 4 git commands to generate.