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_EXYNOS5420) += mk$(BOARD)spl$(SFX) 58BIN_FILES-$(CONFIG_MX23) += mxsboot$(SFX) 59BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX) 60BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX) 61BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX) 62BIN_FILES-$(CONFIG_KIRKWOOD) += kwboot$(SFX) 63BIN_FILES-y += proftool(SFX) 64BIN_FILES-$(CONFIG_STATIC_RELA) += relocate-rela$(SFX) 65 66# Source files which exist outside the tools directory 67EXT_OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += common/env_embedded.o 68EXT_OBJ_FILES-y += common/image.o 69EXT_OBJ_FILES-$(CONFIG_FIT) += common/image-fit.o 70EXT_OBJ_FILES-y += common/image-sig.o 71EXT_OBJ_FILES-y += lib/crc32.o 72EXT_OBJ_FILES-y += lib/md5.o 73EXT_OBJ_FILES-y += lib/sha1.o 74 75# Source files located in the tools directory 76NOPED_OBJ_FILES-y += aisimage.o 77NOPED_OBJ_FILES-y += default_image.o 78NOPED_OBJ_FILES-y += dumpimage.o 79NOPED_OBJ_FILES-y += fit_image.o 80NOPED_OBJ_FILES-y += image-host.o 81NOPED_OBJ_FILES-y += imximage.o 82NOPED_OBJ_FILES-y += kwbimage.o 83NOPED_OBJ_FILES-y += imagetool.o 84NOPED_OBJ_FILES-y += mkenvimage.o 85NOPED_OBJ_FILES-y += mkimage.o 86NOPED_OBJ_FILES-y += mxsimage.o 87NOPED_OBJ_FILES-y += omapimage.o 88NOPED_OBJ_FILES-y += os_support.o 89NOPED_OBJ_FILES-y += pblimage.o 90NOPED_OBJ_FILES-y += proftool.o 91NOPED_OBJ_FILES-y += ublimage.o 92NOPED_OBJ_FILES-y += relocate-rela.o 93OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o 94OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o 95OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o 96OBJ_FILES-$(CONFIG_EXYNOS_SPL) += mkexynosspl.o 97OBJ_FILES-$(CONFIG_KIRKWOOD) += kwboot.o 98OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o 99OBJ_FILES-$(CONFIG_MX23) += mxsboot.o 100OBJ_FILES-$(CONFIG_MX28) += mxsboot.o 101OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o 102OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o 103OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o 104OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o 105OBJ_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes.o 106 107# Don't build by default 108#ifeq ($(ARCH),ppc) 109#BIN_FILES-y += mpc86x_clk$(SFX) 110#OBJ_FILES-y += mpc86x_clk.o 111#endif 112 113# Flattened device tree objects 114LIBFDT_OBJ_FILES-y += fdt.o 115LIBFDT_OBJ_FILES-y += fdt_ro.o 116LIBFDT_OBJ_FILES-y += fdt_rw.o 117LIBFDT_OBJ_FILES-y += fdt_strerror.o 118LIBFDT_OBJ_FILES-y += fdt_wip.o 119 120# RSA objects 121RSA_OBJ_FILES-$(CONFIG_FIT_SIGNATURE) += rsa-sign.o 122 123# Generated LCD/video logo 124LOGO_H = $(OBJTREE)/include/bmp_logo.h 125LOGO_DATA_H = $(OBJTREE)/include/bmp_logo_data.h 126LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H) 127LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_DATA_H) 128LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) 129LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_DATA_H) 130 131# Generic logo 132ifeq ($(LOGO_BMP),) 133LOGO_BMP= logos/denx.bmp 134 135# Use board logo and fallback to vendor 136ifneq ($(wildcard logos/$(BOARD).bmp),) 137LOGO_BMP= logos/$(BOARD).bmp 138else 139ifneq ($(wildcard logos/$(VENDOR).bmp),) 140LOGO_BMP= logos/$(VENDOR).bmp 141endif 142endif 143 144endif # !LOGO_BMP 145 146# now $(obj) is defined 147HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c)) 148HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c)) 149HOSTSRCS += $(addprefix $(SRCTREE)/lib/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) 150HOSTSRCS += $(addprefix $(SRCTREE)/lib/rsa/,$(RSA_OBJ_FILES-y:.o=.c)) 151BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y))) 152LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y)) 153RSA_OBJS := $(addprefix $(obj),$(RSA_OBJ_FILES-y)) 154 155# We cannot check CONFIG_FIT_SIGNATURE here since it is not set on the host 156FIT_SIG_OBJ_FILES := image-sig.o 157FIT_SIG_OBJS := $(addprefix $(obj),$(FIT_SIG_OBJ_FILES)) 158 159HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y)) 160NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y)) 161 162# 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 166# 167HOSTCPPFLAGS = -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) \ 174 -DUSE_HOSTCC \ 175 -D__KERNEL_STRICT_NAMES \ 176 -D_GNU_SOURCE 177 178 179all: $(obj).depend $(BINS) $(LOGO-y) subdirs 180 181$(obj)bin2header$(SFX): $(obj)bin2header.o 182 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 183 $(HOSTSTRIP) $@ 184 185$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o 186 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 187 $(HOSTSTRIP) $@ 188 189$(obj)proftool(SFX): $(obj)proftool.o 190 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 191 $(HOSTSTRIP) $@ 192 193$(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o 194 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 195 196$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o 197 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 198 $(HOSTSTRIP) $@ 199 200$(obj)img2srec$(SFX): $(obj)img2srec.o 201 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 202 $(HOSTSTRIP) $@ 203 204$(obj)xway-swap-bytes$(SFX): $(obj)xway-swap-bytes.o 205 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 206 $(HOSTSTRIP) $@ 207 208$(obj)dumpimage$(SFX): $(obj)aisimage.o \ 209 $(FIT_SIG_OBJS) \ 210 $(obj)crc32.o \ 211 $(obj)default_image.o \ 212 $(obj)fit_image.o \ 213 $(obj)image-fit.o \ 214 $(obj)image.o \ 215 $(obj)image-host.o \ 216 $(obj)imagetool.o \ 217 $(obj)imximage.o \ 218 $(obj)kwbimage.o \ 219 $(obj)dumpimage.o \ 220 $(obj)md5.o \ 221 $(obj)mxsimage.o \ 222 $(obj)omapimage.o \ 223 $(obj)os_support.o \ 224 $(obj)pblimage.o \ 225 $(obj)sha1.o \ 226 $(obj)ublimage.o \ 227 $(LIBFDT_OBJS) \ 228 $(RSA_OBJS) 229 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS) 230 $(HOSTSTRIP) $@ 231 232$(obj)mkenvimage$(SFX): $(obj)crc32.o $(obj)mkenvimage.o \ 233 $(obj)os_support.o 234 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 235 $(HOSTSTRIP) $@ 236 237$(obj)mkimage$(SFX): $(obj)aisimage.o \ 238 $(FIT_SIG_OBJS) \ 239 $(obj)crc32.o \ 240 $(obj)default_image.o \ 241 $(obj)fit_image.o \ 242 $(obj)image-fit.o \ 243 $(obj)image-host.o \ 244 $(obj)image.o \ 245 $(obj)imagetool.o \ 246 $(obj)imximage.o \ 247 $(obj)kwbimage.o \ 248 $(obj)md5.o \ 249 $(obj)mkimage.o \ 250 $(obj)mxsimage.o \ 251 $(obj)omapimage.o \ 252 $(obj)os_support.o \ 253 $(obj)pblimage.o \ 254 $(obj)sha1.o \ 255 $(obj)ublimage.o \ 256 $(LIBFDT_OBJS) \ 257 $(RSA_OBJS) 258 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS) 259 $(HOSTSTRIP) $@ 260 261$(obj)mk$(BOARD)spl$(SFX): $(obj)mkexynosspl.o 262 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 263 $(HOSTSTRIP) $@ 264 265$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o 266 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 267 $(HOSTSTRIP) $@ 268 269$(obj)mxsboot$(SFX): $(obj)mxsboot.o 270 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 271 $(HOSTSTRIP) $@ 272 273$(obj)ncb$(SFX): $(obj)ncb.o 274 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 275 $(HOSTSTRIP) $@ 276 277$(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o 278 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 279 280$(obj)kwboot$(SFX): $(obj)kwboot.o 281 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 282 $(HOSTSTRIP) $@ 283 284$(obj)relocate-rela$(SFX): $(obj)relocate-rela.o 285 $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ 286 $(HOSTSTRIP) $@ 287 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 $@ $< 291 292$(obj)%.o: $(SRCTREE)/lib/%.c 293 $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $< 294 295$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c 296 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< 297 298$(obj)%.o: $(SRCTREE)/lib/rsa/%.c 299 $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $< 300 301subdirs: 302ifeq ($(TOOLSUBDIRS),) 303 @: 304else 305 @for dir in $(TOOLSUBDIRS) ; do \ 306 $(MAKE) \ 307 HOSTOS=$(HOSTOS) \ 308 HOSTARCH=$(HOSTARCH) \ 309 -C $$dir || exit 1 ; \ 310 done 311endif 312 313$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP) 314 $(obj)./bmp_logo --gen-info $(LOGO_BMP) > $@ 315 316$(LOGO_DATA_H): $(obj)bmp_logo $(LOGO_BMP) 317 $(obj)./bmp_logo --gen-data $(LOGO_BMP) > $@ 318 319######################################################################### 320 321# defines $(obj).depend target 322include $(SRCTREE)/rules.mk 323 324sinclude $(obj).depend 325 326######################################################################### 327