]> git.ipfire.org Git - people/ms/u-boot.git/blame - tools/Makefile
Add dumpimage, a tool to extract data from U-Boot images
[people/ms/u-boot.git] / tools / Makefile
CommitLineData
efee1709 1#
f9328639 2# (C) Copyright 2000-2006
efee1709
WD
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
1a459660 5# SPDX-License-Identifier: GPL-2.0+
efee1709
WD
6#
7
30ff8918 8TOOLSUBDIRS = kernel-doc
efee1709 9
a98ae78f
FR
10#
11# Include this after HOSTOS HOSTARCH check
12# so that we can act intelligently.
13#
14include $(TOPDIR)/config.mk
15
efee1709 16#
2f8d396b 17# toolchains targeting win32 generate .exe files
efee1709 18#
2f8d396b 19ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
efee1709
WD
20SFX = .exe
21else
22SFX =
23endif
24
c7c0d542
MF
25# Enable all the config-independent tools
26ifneq ($(HOST_TOOLS_ALL),)
27CONFIG_LCD_LOGO = y
570d7d50 28CONFIG_CMD_LOADS = y
c7c0d542 29CONFIG_CMD_NET = y
60b74bde 30CONFIG_XWAY_SWAP_BYTES = y
c7c0d542
MF
31CONFIG_NETCONSOLE = y
32CONFIG_SHA1_CHECK_UB_IMG = y
33endif
34
2ad6e27d
MF
35# Merge all the different vars for envcrc into one
36ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
37ENVCRC-$(CONFIG_ENV_IS_IN_DATAFLASH) = y
38ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
39ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
40ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
41ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
42ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
43ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
44CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
45
ee3584a5 46# Generated executable files
14821d7d
PW
47BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
48BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
2ad6e27d 49BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
123c48a2 50BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
14821d7d 51BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
60b74bde 52BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
a804b5ce 53BIN_FILES-y += dumpimage$(SFX)
a6337e6f 54BIN_FILES-y += mkenvimage$(SFX)
14821d7d 55BIN_FILES-y += mkimage$(SFX)
ad403e71 56BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
deb0757c 57BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
f29f7e02 58BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
1cd300de 59BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
14821d7d 60BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
d131ad68 61BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
6c887b2a 62BIN_FILES-y += proftool(SFX)
ee3584a5 63
fb8b33c1 64# Source files which exist outside the tools directory
2ad6e27d 65EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
14821d7d 66EXT_OBJ_FILES-y += common/image.o
53fbb7e8 67EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o
3e569a6b 68EXT_OBJ_FILES-y += common/image-sig.o
78acc472
PT
69EXT_OBJ_FILES-y += lib/crc32.o
70EXT_OBJ_FILES-y += lib/md5.o
71EXT_OBJ_FILES-y += lib/sha1.o
ee3584a5
PT
72
73# Source files located in the tools directory
a5f746f3 74NOPED_OBJ_FILES-y += aisimage.o
d984fed0 75NOPED_OBJ_FILES-y += default_image.o
a804b5ce 76NOPED_OBJ_FILES-y += dumpimage.o
d984fed0 77NOPED_OBJ_FILES-y += fit_image.o
604f23dd 78NOPED_OBJ_FILES-y += image-host.o
a5f746f3
MV
79NOPED_OBJ_FILES-y += imximage.o
80NOPED_OBJ_FILES-y += kwbimage.o
f86ed6a8 81NOPED_OBJ_FILES-y += imagetool.o
a6337e6f 82NOPED_OBJ_FILES-y += mkenvimage.o
d984fed0 83NOPED_OBJ_FILES-y += mkimage.o
a5f746f3
MV
84NOPED_OBJ_FILES-y += mxsimage.o
85NOPED_OBJ_FILES-y += omapimage.o
86NOPED_OBJ_FILES-y += os_support.o
87NOPED_OBJ_FILES-y += pblimage.o
88NOPED_OBJ_FILES-y += proftool.o
89NOPED_OBJ_FILES-y += ublimage.o
90OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
91OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
92OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
ad403e71 93OBJ_FILES-$(CONFIG_EXYNOS5250) += mkexynosspl.o
a5f746f3
MV
94OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
95OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
deb0757c 96OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
f29f7e02 97OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
1cd300de 98OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
14821d7d 99OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
a5f746f3
MV
100OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
101OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
102OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
ee3584a5
PT
103
104# Don't build by default
105#ifeq ($(ARCH),ppc)
106#BIN_FILES-y += mpc86x_clk$(SFX)
107#OBJ_FILES-y += mpc86x_clk.o
108#endif
109
110# Flattened device tree objects
111LIBFDT_OBJ_FILES-y += fdt.o
112LIBFDT_OBJ_FILES-y += fdt_ro.o
113LIBFDT_OBJ_FILES-y += fdt_rw.o
114LIBFDT_OBJ_FILES-y += fdt_strerror.o
115LIBFDT_OBJ_FILES-y += fdt_wip.o
116
19c402af 117# RSA objects
29ce737d 118RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o
19c402af 119
335ffe7e 120# Generated LCD/video logo
ee3584a5 121LOGO_H = $(OBJTREE)/include/bmp_logo.h
c270730f 122LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h
335ffe7e 123LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
c270730f 124LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
335ffe7e 125LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
c270730f 126LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
ee3584a5 127
96903dae 128# Generic logo
ee3584a5
PT
129ifeq ($(LOGO_BMP),)
130LOGO_BMP= logos/denx.bmp
96903dae
OS
131
132# Use board logo and fallback to vendor
133ifneq ($(wildcard logos/$(BOARD).bmp),)
134LOGO_BMP= logos/$(BOARD).bmp
135else
136ifneq ($(wildcard logos/$(VENDOR).bmp),)
137LOGO_BMP= logos/$(VENDOR).bmp
ee3584a5 138endif
348de314 139endif
ee3584a5 140
96903dae
OS
141endif # !LOGO_BMP
142
f9328639 143# now $(obj) is defined
d984fed0
SW
144HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
145HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
0de71d50 146HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
19c402af 147HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c))
afcbce07 148BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
ee3584a5 149LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
19c402af 150RSA_OBJS := $(addprefix $(obj),$(RSA_OBJ_FILES-y))
f9328639 151
3e569a6b
SG
152# We cannot check CONFIG_FIT_SIGNATURE here since it is not set on the host
153FIT_SIG_OBJ_FILES := image-sig.o
154FIT_SIG_OBJS := $(addprefix $(obj),$(FIT_SIG_OBJ_FILES))
155
d984fed0
SW
156HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
157NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
158
efee1709
WD
159#
160# Use native tools and options
2f8d396b 161# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
2db1c3fc 162# Define _GNU_SOURCE to obtain the getline prototype from stdio.h
efee1709 163#
669dfc2e
SG
164HOSTCPPFLAGS = -include $(SRCTREE)/include/libfdt_env.h \
165 -idirafter $(SRCTREE)/include \
bb02c536 166 -idirafter $(SRCTREE)/arch/$(ARCH)/include \
f9328639 167 -idirafter $(OBJTREE)/include \
93e14596 168 -I $(SRCTREE)/lib/libfdt \
40b8d909 169 -I $(SRCTREE)/tools \
14d0a02a
WD
170 -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
171 -DUSE_HOSTCC \
2db1c3fc
YS
172 -D__KERNEL_STRICT_NAMES \
173 -D_GNU_SOURCE
8cf30809 174
efee1709 175
335ffe7e 176all: $(obj).depend $(BINS) $(LOGO-y) subdirs
efee1709 177
14821d7d 178$(obj)bin2header$(SFX): $(obj)bin2header.o
d984fed0
SW
179 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
180 $(HOSTSTRIP) $@
efee1709 181
14821d7d 182$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
d984fed0
SW
183 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
184 $(HOSTSTRIP) $@
efee1709 185
6c887b2a
SG
186$(obj)proftool(SFX): $(obj)proftool.o
187 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
188 $(HOSTSTRIP) $@
189
14821d7d 190$(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
d984fed0 191 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
eedcd078 192
f9328639 193$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
d984fed0
SW
194 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
195 $(HOSTSTRIP) $@
efee1709 196
14821d7d 197$(obj)img2srec$(SFX): $(obj)img2srec.o
d984fed0
SW
198 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
199 $(HOSTSTRIP) $@
efee1709 200
60b74bde 201$(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o
d984fed0
SW
202 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
203 $(HOSTSTRIP) $@
3e38691e 204
a804b5ce
GMF
205$(obj)dumpimage$(SFX): $(obj)aisimage.o \
206 $(FIT_SIG_OBJS) \
207 $(obj)crc32.o \
208 $(obj)default_image.o \
209 $(obj)fit_image.o \
210 $(obj)image-fit.o \
211 $(obj)image.o \
212 $(obj)image-host.o \
213 $(obj)imagetool.o \
214 $(obj)imximage.o \
215 $(obj)kwbimage.o \
216 $(obj)dumpimage.o \
217 $(obj)md5.o \
218 $(obj)mxsimage.o \
219 $(obj)omapimage.o \
220 $(obj)os_support.o \
221 $(obj)pblimage.o \
222 $(obj)sha1.o \
223 $(obj)ublimage.o \
224 $(LIBFDT_OBJS) \
225 $(RSA_OBJS)
226 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
227 $(HOSTSTRIP) $@
228
8b6a4952
VY
229$(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o \
230 $(obj)os_support.o
a6337e6f 231 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
30de1014 232 $(HOSTSTRIP) $@
a6337e6f 233
4962e38e 234$(obj)mkimage$(SFX): $(obj)aisimage.o \
a5f746f3 235 $(FIT_SIG_OBJS) \
4962e38e 236 $(obj)crc32.o \
89a4d6b1
PW
237 $(obj)default_image.o \
238 $(obj)fit_image.o \
53fbb7e8 239 $(obj)image-fit.o \
604f23dd 240 $(obj)image-host.o \
a5f746f3 241 $(obj)image.o \
f86ed6a8 242 $(obj)imagetool.o \
8edcde5e 243 $(obj)imximage.o \
aa0c7a86 244 $(obj)kwbimage.o \
89a4d6b1
PW
245 $(obj)md5.o \
246 $(obj)mkimage.o \
a5f746f3 247 $(obj)mxsimage.o \
3decb14a 248 $(obj)omapimage.o \
a5f746f3
MV
249 $(obj)os_support.o \
250 $(obj)pblimage.o \
89a4d6b1 251 $(obj)sha1.o \
7816f2cf 252 $(obj)ublimage.o \
19c402af
SG
253 $(LIBFDT_OBJS) \
254 $(RSA_OBJS)
255 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
d984fed0 256 $(HOSTSTRIP) $@
14821d7d 257
81e35203
CK
258$(obj)mk$(BOARD)spl$(SFX): $(obj)mkexynosspl.o
259 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
260 $(HOSTSTRIP) $@
261
f9328639 262$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
d984fed0
SW
263 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
264 $(HOSTSTRIP) $@
f29f7e02
MV
265
266$(obj)mxsboot$(SFX): $(obj)mxsboot.o
267 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
268 $(HOSTSTRIP) $@
ef1464cc 269
14821d7d 270$(obj)ncb$(SFX): $(obj)ncb.o
d984fed0
SW
271 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
272 $(HOSTSTRIP) $@
0a823aa2 273
14821d7d 274$(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
d984fed0 275 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
2f8d396b 276
d131ad68
LP
277$(obj)kwboot$(SFX): $(obj)kwboot.o
278 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
279 $(HOSTSTRIP) $@
280
b0d4d721 281# Some of the tool objects need to be accessed from outside the tools directory
91081e01 282$(obj)%.o: $(SRCTREE)/common/%.c
d984fed0 283 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
8cf30809 284
91081e01 285$(obj)%.o: $(SRCTREE)/lib/%.c
d984fed0 286 $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
8cf30809 287
0de71d50 288$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
d984fed0 289 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
8cf30809 290
19c402af
SG
291$(obj)%.o: $(SRCTREE)/lib/rsa/%.c
292 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
293
efee1709 294subdirs:
e0ac62d7 295ifeq ($(TOOLSUBDIRS),)
21d28e95 296 @:
e0ac62d7 297else
21d28e95
PT
298 @for dir in $(TOOLSUBDIRS) ; do \
299 $(MAKE) \
300 HOSTOS=$(HOSTOS) \
301 HOSTARCH=$(HOSTARCH) \
21d28e95
PT
302 -C $$dir || exit 1 ; \
303 done
e0ac62d7
WD
304endif
305
f9328639 306$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
c270730f
CLC
307 $(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
308
309$(LOGO_DATA_H): $(obj)bmp_logo $(LOGO_BMP)
310 $(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
efee1709
WD
311
312#########################################################################
313
f9328639
MB
314# defines $(obj).depend target
315include $(SRCTREE)/rules.mk
efee1709 316
f9328639 317sinclude $(obj).depend
efee1709
WD
318
319#########################################################################