xref: /openbmc/u-boot/tools/Makefile (revision 755e08f0)
1#
2# (C) Copyright 2000-2006
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
5# SPDX-License-Identifier:	GPL-2.0+
6#
7
8TOOLSUBDIRS = kernel-doc
9
10#
11# Include this after HOSTOS HOSTARCH check
12# so that we can act intelligently.
13#
14include $(TOPDIR)/config.mk
15
16#
17# toolchains targeting win32 generate .exe files
18#
19ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
20SFX = .exe
21else
22SFX =
23endif
24
25# Enable all the config-independent tools
26ifneq ($(HOST_TOOLS_ALL),)
27CONFIG_LCD_LOGO = y
28CONFIG_CMD_LOADS = y
29CONFIG_CMD_NET = y
30CONFIG_XWAY_SWAP_BYTES = y
31CONFIG_NETCONSOLE = y
32CONFIG_SHA1_CHECK_UB_IMG = y
33endif
34
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
46# Generated executable files
47BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
48BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
49BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
50BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
51BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
52BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
53BIN_FILES-y += dumpimage$(SFX)
54BIN_FILES-y += mkenvimage$(SFX)
55BIN_FILES-y += mkimage$(SFX)
56BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
57BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
58BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
59BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
60BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
61BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
62BIN_FILES-y += proftool(SFX)
63
64# Source files which exist outside the tools directory
65EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
66EXT_OBJ_FILES-y += common/image.o
67EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o
68EXT_OBJ_FILES-y += common/image-sig.o
69EXT_OBJ_FILES-y += lib/crc32.o
70EXT_OBJ_FILES-y += lib/md5.o
71EXT_OBJ_FILES-y += lib/sha1.o
72
73# Source files located in the tools directory
74NOPED_OBJ_FILES-y += aisimage.o
75NOPED_OBJ_FILES-y += default_image.o
76NOPED_OBJ_FILES-y += dumpimage.o
77NOPED_OBJ_FILES-y += fit_image.o
78NOPED_OBJ_FILES-y += image-host.o
79NOPED_OBJ_FILES-y += imximage.o
80NOPED_OBJ_FILES-y += kwbimage.o
81NOPED_OBJ_FILES-y += imagetool.o
82NOPED_OBJ_FILES-y += mkenvimage.o
83NOPED_OBJ_FILES-y += mkimage.o
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
93OBJ_FILES-$(CONFIG_EXYNOS5250) += mkexynosspl.o
94OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
95OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
96OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
97OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
98OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
99OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
100OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
101OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
102OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
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
117# RSA objects
118RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o
119
120# Generated LCD/video logo
121LOGO_H = $(OBJTREE)/include/bmp_logo.h
122LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h
123LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
124LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
125LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
126LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
127
128# Generic logo
129ifeq ($(LOGO_BMP),)
130LOGO_BMP= logos/denx.bmp
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
138endif
139endif
140
141endif # !LOGO_BMP
142
143# now $(obj) is defined
144HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
145HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
146HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
147HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c))
148BINS	:= $(addprefix $(obj),$(sort $(BIN_FILES-y)))
149LIBFDT_OBJS	:= $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
150RSA_OBJS	:= $(addprefix $(obj),$(RSA_OBJ_FILES-y))
151
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
156HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
157NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
158
159#
160# Use native tools and options
161# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
162# Define _GNU_SOURCE to obtain the getline prototype from stdio.h
163#
164HOSTCPPFLAGS =	-include $(SRCTREE)/include/libfdt_env.h \
165		-idirafter $(SRCTREE)/include \
166		-idirafter $(SRCTREE)/arch/$(ARCH)/include \
167		-idirafter $(OBJTREE)/include \
168		-I $(SRCTREE)/lib/libfdt \
169		-I $(SRCTREE)/tools \
170		-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
171		-DUSE_HOSTCC \
172		-D__KERNEL_STRICT_NAMES \
173		-D_GNU_SOURCE
174
175
176all:	$(obj).depend $(BINS) $(LOGO-y) subdirs
177
178$(obj)bin2header$(SFX): $(obj)bin2header.o
179	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
180	$(HOSTSTRIP) $@
181
182$(obj)bmp_logo$(SFX):	$(obj)bmp_logo.o
183	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
184	$(HOSTSTRIP) $@
185
186$(obj)proftool(SFX):	$(obj)proftool.o
187	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
188	$(HOSTSTRIP) $@
189
190$(obj)envcrc$(SFX):	$(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
191	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
192
193$(obj)gen_eth_addr$(SFX):	$(obj)gen_eth_addr.o
194	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
195	$(HOSTSTRIP) $@
196
197$(obj)img2srec$(SFX):	$(obj)img2srec.o
198	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
199	$(HOSTSTRIP) $@
200
201$(obj)xway-swap-bytes$(SFX):	$(obj)xway-swap-bytes.o
202	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
203	$(HOSTSTRIP) $@
204
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
229$(obj)mkenvimage$(SFX):	$(obj)crc32.o $(obj)mkenvimage.o \
230	$(obj)os_support.o
231	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
232	$(HOSTSTRIP) $@
233
234$(obj)mkimage$(SFX):	$(obj)aisimage.o \
235			$(FIT_SIG_OBJS) \
236			$(obj)crc32.o \
237			$(obj)default_image.o \
238			$(obj)fit_image.o \
239			$(obj)image-fit.o \
240			$(obj)image-host.o \
241			$(obj)image.o \
242			$(obj)imagetool.o \
243			$(obj)imximage.o \
244			$(obj)kwbimage.o \
245			$(obj)md5.o \
246			$(obj)mkimage.o \
247			$(obj)mxsimage.o \
248			$(obj)omapimage.o \
249			$(obj)os_support.o \
250			$(obj)pblimage.o \
251			$(obj)sha1.o \
252			$(obj)ublimage.o \
253			$(LIBFDT_OBJS) \
254			$(RSA_OBJS)
255	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
256	$(HOSTSTRIP) $@
257
258$(obj)mk$(BOARD)spl$(SFX):	$(obj)mkexynosspl.o
259	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
260	$(HOSTSTRIP) $@
261
262$(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
263	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
264	$(HOSTSTRIP) $@
265
266$(obj)mxsboot$(SFX):	$(obj)mxsboot.o
267	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
268	$(HOSTSTRIP) $@
269
270$(obj)ncb$(SFX):	$(obj)ncb.o
271	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
272	$(HOSTSTRIP) $@
273
274$(obj)ubsha1$(SFX):	$(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
275	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
276
277$(obj)kwboot$(SFX): $(obj)kwboot.o
278	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
279	$(HOSTSTRIP) $@
280
281# Some of the tool objects need to be accessed from outside the tools directory
282$(obj)%.o: $(SRCTREE)/common/%.c
283	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
284
285$(obj)%.o: $(SRCTREE)/lib/%.c
286	$(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
287
288$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
289	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
290
291$(obj)%.o: $(SRCTREE)/lib/rsa/%.c
292	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
293
294subdirs:
295ifeq ($(TOOLSUBDIRS),)
296	@:
297else
298	@for dir in $(TOOLSUBDIRS) ; do \
299	    $(MAKE) \
300		HOSTOS=$(HOSTOS) \
301		HOSTARCH=$(HOSTARCH) \
302		-C $$dir || exit 1 ; \
303	done
304endif
305
306$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
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) > $@
311
312#########################################################################
313
314# defines $(obj).depend target
315include $(SRCTREE)/rules.mk
316
317sinclude $(obj).depend
318
319#########################################################################
320