2 # (C) Copyright 2000-2006
5 # SPDX-License-Identifier: GPL-2.0+
8 TOOLSUBDIRS = kernel-doc
11 # Include this after HOSTOS HOSTARCH check
12 # so that we can act intelligently.
14 include $(TOPDIR)/config.mk
17 # toolchains targeting win32 generate .exe files
19 ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
25 # Enable all the config-independent tools
26 ifneq ($(HOST_TOOLS_ALL),)
30 CONFIG_XWAY_SWAP_BYTES = y
32 CONFIG_SHA1_CHECK_UB_IMG = y
35 # Merge all the different vars for envcrc into one
36 ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
37 ENVCRC-$(CONFIG_ENV_IS_IN_DATAFLASH) = y
38 ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
39 ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
40 ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
41 ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
42 ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
43 ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
44 CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
46 # Generated executable files
47 BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
48 BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
49 BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
50 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
51 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
52 BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
53 BIN_FILES-y += dumpimage$(SFX)
54 BIN_FILES-y += mkenvimage$(SFX)
55 BIN_FILES-y += mkimage$(SFX)
56 BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
57 BIN_FILES-$(CONFIG_EXYNOS5420) += mk$(BOARD)spl$(SFX)
58 BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
59 BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
60 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
61 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
62 BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
63 BIN_FILES-y += proftool(SFX)
64 BIN_FILES-$(CONFIG_STATIC_RELA) += relocate-rela$(SFX)
66 # Source files which exist outside the tools directory
67 EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
68 EXT_OBJ_FILES-y += common/image.o
69 EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o
70 EXT_OBJ_FILES-y += common/image-sig.o
71 EXT_OBJ_FILES-y += lib/crc32.o
72 EXT_OBJ_FILES-y += lib/md5.o
73 EXT_OBJ_FILES-y += lib/sha1.o
75 # Source files located in the tools directory
76 NOPED_OBJ_FILES-y += aisimage.o
77 NOPED_OBJ_FILES-y += default_image.o
78 NOPED_OBJ_FILES-y += dumpimage.o
79 NOPED_OBJ_FILES-y += fit_image.o
80 NOPED_OBJ_FILES-y += image-host.o
81 NOPED_OBJ_FILES-y += imximage.o
82 NOPED_OBJ_FILES-y += kwbimage.o
83 NOPED_OBJ_FILES-y += imagetool.o
84 NOPED_OBJ_FILES-y += mkenvimage.o
85 NOPED_OBJ_FILES-y += mkimage.o
86 NOPED_OBJ_FILES-y += mxsimage.o
87 NOPED_OBJ_FILES-y += omapimage.o
88 NOPED_OBJ_FILES-y += os_support.o
89 NOPED_OBJ_FILES-y += pblimage.o
90 NOPED_OBJ_FILES-y += proftool.o
91 NOPED_OBJ_FILES-y += ublimage.o
92 NOPED_OBJ_FILES-y += relocate-rela.o
93 OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
94 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
95 OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
96 OBJ_FILES-$(CONFIG_EXYNOS_SPL) += mkexynosspl.o
97 OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
98 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
99 OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
100 OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
101 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
102 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
103 OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
104 OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
105 OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
107 # Don't build by default
109 #BIN_FILES-y += mpc86x_clk$(SFX)
110 #OBJ_FILES-y += mpc86x_clk.o
113 # Flattened device tree objects
114 LIBFDT_OBJ_FILES-y += fdt.o
115 LIBFDT_OBJ_FILES-y += fdt_ro.o
116 LIBFDT_OBJ_FILES-y += fdt_rw.o
117 LIBFDT_OBJ_FILES-y += fdt_strerror.o
118 LIBFDT_OBJ_FILES-y += fdt_wip.o
121 RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o
123 # Generated LCD/video logo
124 LOGO_H = $(OBJTREE)/include/bmp_logo.h
125 LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h
126 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
127 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
128 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
129 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
133 LOGO_BMP= logos/denx.bmp
135 # Use board logo and fallback to vendor
136 ifneq ($(wildcard logos/$(BOARD).bmp),)
137 LOGO_BMP= logos/$(BOARD).bmp
139 ifneq ($(wildcard logos/$(VENDOR).bmp),)
140 LOGO_BMP= logos/$(VENDOR).bmp
146 # now $(obj) is defined
147 HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
148 HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
149 HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
150 HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c))
151 BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
152 LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
153 RSA_OBJS := $(addprefix $(obj),$(RSA_OBJ_FILES-y))
155 # We cannot check CONFIG_FIT_SIGNATURE here since it is not set on the host
156 FIT_SIG_OBJ_FILES := image-sig.o
157 FIT_SIG_OBJS := $(addprefix $(obj),$(FIT_SIG_OBJ_FILES))
159 HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
160 NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
163 # Use native tools and options
164 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
165 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
167 HOSTCPPFLAGS = -include $(SRCTREE)/include/libfdt_env.h \
168 -idirafter $(SRCTREE)/include \
169 -idirafter $(SRCTREE)/arch/$(ARCH)/include \
170 -idirafter $(OBJTREE)/include \
171 -I $(SRCTREE)/lib/libfdt \
172 -I $(SRCTREE)/tools \
173 -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
175 -D__KERNEL_STRICT_NAMES \
179 all: $(obj).depend $(BINS) $(LOGO-y) subdirs
181 $(obj)bin2header$(SFX): $(obj)bin2header.o
182 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
185 $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
186 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
189 $(obj)proftool(SFX): $(obj)proftool.o
190 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
193 $(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
194 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
196 $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
197 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
200 $(obj)img2srec$(SFX): $(obj)img2srec.o
201 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
204 $(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o
205 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
208 $(obj)dumpimage$(SFX): $(obj)aisimage.o \
211 $(obj)default_image.o \
229 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
232 $(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o \
234 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
237 $(obj)mkimage$(SFX): $(obj)aisimage.o \
240 $(obj)default_image.o \
258 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
261 $(obj)mk$(BOARD)spl$(SFX): $(obj)mkexynosspl.o
262 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
265 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
266 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
269 $(obj)mxsboot$(SFX): $(obj)mxsboot.o
270 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
273 $(obj)ncb$(SFX): $(obj)ncb.o
274 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
277 $(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
278 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
280 $(obj)kwboot$(SFX): $(obj)kwboot.o
281 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
284 $(obj)relocate-rela$(SFX): $(obj)relocate-rela.o
285 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
288 # Some of the tool objects need to be accessed from outside the tools directory
289 $(obj)%.o: $(SRCTREE)/common/%.c
290 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
292 $(obj)%.o: $(SRCTREE)/lib/%.c
293 $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
295 $(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
296 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
298 $(obj)%.o: $(SRCTREE)/lib/rsa/%.c
299 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
302 ifeq ($(TOOLSUBDIRS),)
305 @for dir in $(TOOLSUBDIRS) ; do \
308 HOSTARCH=$(HOSTARCH) \
309 -C $$dir || exit 1 ; \
313 $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
314 $(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
316 $(LOGO_DATA_H): $(obj)bmp_logo $(LOGO_BMP)
317 $(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
319 #########################################################################
321 # defines $(obj).depend target
322 include $(SRCTREE)/rules.mk
324 sinclude $(obj).depend
326 #########################################################################