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