Merge branch 'master' of git://git.denx.de/u-boot-i2c
[kernel/u-boot.git] / tools / Makefile
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
8 TOOLSUBDIRS = kernel-doc
9
10 #
11 # Include this after HOSTOS HOSTARCH check
12 # so that we can act intelligently.
13 #
14 include $(TOPDIR)/config.mk
15
16 #
17 # toolchains targeting win32 generate .exe files
18 #
19 ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
20 SFX = .exe
21 else
22 SFX =
23 endif
24
25 # Enable all the config-independent tools
26 ifneq ($(HOST_TOOLS_ALL),)
27 CONFIG_LCD_LOGO = y
28 CONFIG_CMD_LOADS = y
29 CONFIG_CMD_NET = y
30 CONFIG_XWAY_SWAP_BYTES = y
31 CONFIG_NETCONSOLE = y
32 CONFIG_SHA1_CHECK_UB_IMG = y
33 endif
34
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)
45
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 += mkenvimage$(SFX)
54 BIN_FILES-y += mkimage$(SFX)
55 BIN_FILES-$(CONFIG_SMDK5250) += mksmdk5250spl$(SFX)
56 BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX)
57 BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX)
58 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
59 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
60 BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX)
61 BIN_FILES-y += proftool(SFX)
62
63 # Source files which exist outside the tools directory
64 EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o
65 EXT_OBJ_FILES-y += common/image.o
66 EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o
67 EXT_OBJ_FILES-y += common/image-sig.o
68 EXT_OBJ_FILES-y += lib/crc32.o
69 EXT_OBJ_FILES-y += lib/md5.o
70 EXT_OBJ_FILES-y += lib/sha1.o
71
72 # Source files located in the tools directory
73 NOPED_OBJ_FILES-y += aisimage.o
74 NOPED_OBJ_FILES-y += default_image.o
75 NOPED_OBJ_FILES-y += fit_image.o
76 NOPED_OBJ_FILES-y += image-host.o
77 NOPED_OBJ_FILES-y += imximage.o
78 NOPED_OBJ_FILES-y += kwbimage.o
79 NOPED_OBJ_FILES-y += mkenvimage.o
80 NOPED_OBJ_FILES-y += mkimage.o
81 NOPED_OBJ_FILES-y += mxsimage.o
82 NOPED_OBJ_FILES-y += omapimage.o
83 NOPED_OBJ_FILES-y += os_support.o
84 NOPED_OBJ_FILES-y += pblimage.o
85 NOPED_OBJ_FILES-y += proftool.o
86 NOPED_OBJ_FILES-y += ublimage.o
87 OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
88 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
89 OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
90 OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o
91 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
92 OBJ_FILES-$(CONFIG_MX23) += mxsboot.o
93 OBJ_FILES-$(CONFIG_MX28) += mxsboot.o
94 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
95 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
96 OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o
97 OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
98 OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o
99
100 # Don't build by default
101 #ifeq ($(ARCH),ppc)
102 #BIN_FILES-y += mpc86x_clk$(SFX)
103 #OBJ_FILES-y += mpc86x_clk.o
104 #endif
105
106 # Flattened device tree objects
107 LIBFDT_OBJ_FILES-y += fdt.o
108 LIBFDT_OBJ_FILES-y += fdt_ro.o
109 LIBFDT_OBJ_FILES-y += fdt_rw.o
110 LIBFDT_OBJ_FILES-y += fdt_strerror.o
111 LIBFDT_OBJ_FILES-y += fdt_wip.o
112
113 # RSA objects
114 RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o
115
116 # Generated LCD/video logo
117 LOGO_H = $(OBJTREE)/include/bmp_logo.h
118 LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h
119 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
120 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H)
121 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
122 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H)
123
124 # Generic logo
125 ifeq ($(LOGO_BMP),)
126 LOGO_BMP= logos/denx.bmp
127
128 # Use board logo and fallback to vendor
129 ifneq ($(wildcard logos/$(BOARD).bmp),)
130 LOGO_BMP= logos/$(BOARD).bmp
131 else
132 ifneq ($(wildcard logos/$(VENDOR).bmp),)
133 LOGO_BMP= logos/$(VENDOR).bmp
134 endif
135 endif
136
137 endif # !LOGO_BMP
138
139 # now $(obj) is defined
140 HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
141 HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
142 HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
143 HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c))
144 BINS    := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
145 LIBFDT_OBJS     := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
146 RSA_OBJS        := $(addprefix $(obj),$(RSA_OBJ_FILES-y))
147
148 # We cannot check CONFIG_FIT_SIGNATURE here since it is not set on the host
149 FIT_SIG_OBJ_FILES       := image-sig.o
150 FIT_SIG_OBJS            := $(addprefix $(obj),$(FIT_SIG_OBJ_FILES))
151
152 HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
153 NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
154
155 #
156 # Use native tools and options
157 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
158 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
159 #
160 HOSTCPPFLAGS =  -include $(SRCTREE)/include/libfdt_env.h \
161                 -idirafter $(SRCTREE)/include \
162                 -idirafter $(OBJTREE)/include2 \
163                 -idirafter $(OBJTREE)/include \
164                 -I $(SRCTREE)/lib/libfdt \
165                 -I $(SRCTREE)/tools \
166                 -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
167                 -DUSE_HOSTCC \
168                 -D__KERNEL_STRICT_NAMES \
169                 -D_GNU_SOURCE
170
171
172 all:    $(obj).depend $(BINS) $(LOGO-y) subdirs
173
174 $(obj)bin2header$(SFX): $(obj)bin2header.o
175         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
176         $(HOSTSTRIP) $@
177
178 $(obj)bmp_logo$(SFX):   $(obj)bmp_logo.o
179         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
180         $(HOSTSTRIP) $@
181
182 $(obj)proftool(SFX):    $(obj)proftool.o
183         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
184         $(HOSTSTRIP) $@
185
186 $(obj)envcrc$(SFX):     $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
187         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
188
189 $(obj)gen_eth_addr$(SFX):       $(obj)gen_eth_addr.o
190         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
191         $(HOSTSTRIP) $@
192
193 $(obj)img2srec$(SFX):   $(obj)img2srec.o
194         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
195         $(HOSTSTRIP) $@
196
197 $(obj)xway-swap-bytes$(SFX):    $(obj)xway-swap-bytes.o
198         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
199         $(HOSTSTRIP) $@
200
201 $(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o \
202         $(obj)os_support.o
203         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
204         $(HOSTSTRIP) $@
205
206 $(obj)mkimage$(SFX):    $(obj)aisimage.o \
207                         $(FIT_SIG_OBJS) \
208                         $(obj)crc32.o \
209                         $(obj)default_image.o \
210                         $(obj)fit_image.o \
211                         $(obj)image-fit.o \
212                         $(obj)image-host.o \
213                         $(obj)image.o \
214                         $(obj)imximage.o \
215                         $(obj)kwbimage.o \
216                         $(obj)md5.o \
217                         $(obj)mkimage.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)mk$(BOARD)spl$(SFX):      $(obj)mkexynosspl.o
230         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
231         $(HOSTSTRIP) $@
232
233 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
234         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
235         $(HOSTSTRIP) $@
236
237 $(obj)mxsboot$(SFX):    $(obj)mxsboot.o
238         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
239         $(HOSTSTRIP) $@
240
241 $(obj)ncb$(SFX):        $(obj)ncb.o
242         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
243         $(HOSTSTRIP) $@
244
245 $(obj)ubsha1$(SFX):     $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
246         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
247
248 $(obj)kwboot$(SFX): $(obj)kwboot.o
249         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
250         $(HOSTSTRIP) $@
251
252 # Some of the tool objects need to be accessed from outside the tools directory
253 $(obj)%.o: $(SRCTREE)/common/%.c
254         $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
255
256 $(obj)%.o: $(SRCTREE)/lib/%.c
257         $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
258
259 $(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
260         $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
261
262 $(obj)%.o: $(SRCTREE)/lib/rsa/%.c
263         $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
264
265 subdirs:
266 ifeq ($(TOOLSUBDIRS),)
267         @:
268 else
269         @for dir in $(TOOLSUBDIRS) ; do \
270             $(MAKE) \
271                 HOSTOS=$(HOSTOS) \
272                 HOSTARCH=$(HOSTARCH) \
273                 -C $$dir || exit 1 ; \
274         done
275 endif
276
277 $(LOGO_H):      $(obj)bmp_logo $(LOGO_BMP)
278         $(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@
279
280 $(LOGO_DATA_H): $(obj)bmp_logo $(LOGO_BMP)
281         $(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@
282
283 #########################################################################
284
285 # defines $(obj).depend target
286 include $(SRCTREE)/rules.mk
287
288 sinclude $(obj).depend
289
290 #########################################################################