1# 2# (C) Copyright 2000-2006 3# Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4# 5# See file CREDITS for list of people who contributed to this 6# project. 7# 8# This program is free software; you can redistribute it and/or 9# modify it under the terms of the GNU General Public License as 10# published by the Free Software Foundation; either version 2 of 11# the License, or (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program; if not, write to the Free Software 20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21# MA 02111-1307 USA 22# 23 24TOOLSUBDIRS = 25 26# 27# Mac OS X / Darwin's C preprocessor is Apple specific. It 28# generates numerous errors and warnings. We want to bypass it 29# and use GNU C's cpp. To do this we pass the -traditional-cpp 30# option to the compiler. Note that the -traditional-cpp flag 31# DOES NOT have the same semantics as GNU C's flag, all it does 32# is invoke the GNU preprocessor in stock ANSI/ISO C fashion. 33# 34# Apple's linker is similar, thanks to the new 2 stage linking 35# multiple symbol definitions are treated as errors, hence the 36# -multiply_defined suppress option to turn off this error. 37# 38 39HOST_CFLAGS = -Wall 40HOST_LDFLAGS = 41 42ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc) 43HOST_CFLAGS += -traditional-cpp 44HOST_LDFLAGS += -multiply_defined suppress 45else 46HOST_CFLAGS += -pedantic 47endif 48 49ifeq ($(HOSTOS),cygwin) 50HOST_CFLAGS += -ansi 51endif 52 53# 54# toolchains targeting win32 generate .exe files 55# 56ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null))) 57SFX = .exe 58else 59SFX = 60endif 61 62# 63# Include this after HOSTOS HOSTARCH check 64# so that we can act intelligently. 65# 66include $(TOPDIR)/config.mk 67 68# Generated executable files 69BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX) 70BIN_FILES-y += mkimage$(SFX) 71BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX) 72BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX) 73BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX) 74BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX) 75BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX) 76BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX) 77BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX) 78 79# Source files which exist outside the tools directory 80EXT_OBJ_FILES-y += common/env_embedded.o 81EXT_OBJ_FILES-y += lib_generic/crc32.o 82EXT_OBJ_FILES-y += lib_generic/md5.o 83EXT_OBJ_FILES-y += lib_generic/sha1.o 84EXT_OBJ_FILES-y += common/image.o 85 86# Source files located in the tools directory 87OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o 88OBJ_FILES-y += mkimage.o 89OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o 90OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o 91OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o 92OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o 93OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o 94OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o 95OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o 96OBJ_FILES-y += os_support.o 97 98# Don't build by default 99#ifeq ($(ARCH),ppc) 100#BIN_FILES-y += mpc86x_clk$(SFX) 101#OBJ_FILES-y += mpc86x_clk.o 102#endif 103 104# Flattened device tree objects 105LIBFDT_OBJ_FILES-y += fdt.o 106LIBFDT_OBJ_FILES-y += fdt_ro.o 107LIBFDT_OBJ_FILES-y += fdt_rw.o 108LIBFDT_OBJ_FILES-y += fdt_strerror.o 109LIBFDT_OBJ_FILES-y += fdt_wip.o 110 111# Generated LCD/video logo 112LOGO_H = $(OBJTREE)/include/bmp_logo.h 113LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H) 114LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) 115 116ifeq ($(LOGO_BMP),) 117LOGO_BMP= logos/denx.bmp 118endif 119ifeq ($(VENDOR),atmel) 120LOGO_BMP= logos/atmel.bmp 121endif 122 123# now $(obj) is defined 124SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c)) 125SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c)) 126SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) 127BINS := $(addprefix $(obj),$(BIN_FILES-y)) 128LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y)) 129 130# 131# Use native tools and options 132# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps 133# 134CPPFLAGS = -idirafter $(SRCTREE)/include \ 135 -idirafter $(OBJTREE)/include2 \ 136 -idirafter $(OBJTREE)/include \ 137 -I $(SRCTREE)/libfdt \ 138 -I $(SRCTREE)/tools \ 139 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \ 140 -D__KERNEL_STRICT_NAMES 141CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O 142 143# No -pedantic switch to avoid libfdt compilation warnings 144FIT_CFLAGS = -Wall $(CPPFLAGS) -O 145 146AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS) 147CC = $(HOSTCC) 148STRIP = $(HOSTSTRIP) 149MAKEDEPEND = makedepend 150 151all: $(obj).depend $(BINS) $(LOGO-y) subdirs 152 153$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o 154 $(CC) $(CFLAGS) -o $@ $^ 155 156$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o $(obj)os_support.o 157 $(CC) $(CFLAGS) -o $@ $^ 158 159$(obj)img2srec$(SFX): $(obj)img2srec.o 160 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 161 $(STRIP) $@ 162 163$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \ 164 $(obj)sha1.o $(LIBFDT_OBJS) $(obj)os_support.o 165 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 166 $(STRIP) $@ 167 168$(obj)ncb$(SFX): $(obj)ncb.o 169 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 170 $(STRIP) $@ 171 172$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o 173 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 174 $(STRIP) $@ 175 176$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o 177 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 178 $(STRIP) $@ 179 180$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o 181 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 182 $(STRIP) $@ 183 184$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o 185 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 186 $(STRIP) $@ 187 188$(obj)bin2header$(SFX): $(obj)bin2header.o 189 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 190 $(STRIP) $@ 191 192# Some files complain if compiled with -pedantic, use FIT_CFLAGS 193$(obj)image.o: $(SRCTREE)/tools/image.c 194 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 195 196$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c 197 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 198 199$(obj)os_support.o: $(SRCTREE)/tools/os_support.c 200 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 201 202# Some of the tool objects need to be accessed from outside the tools directory 203$(obj)%.o: $(SRCTREE)/common/%.c 204 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 205 206$(obj)%.o: $(SRCTREE)/lib_generic/%.c 207 $(CC) -g $(CFLAGS) -c -o $@ $< 208 209$(LIBFDT_OBJS): 210 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 211 212subdirs: 213ifeq ($(TOOLSUBDIRS),) 214 @: 215else 216 @for dir in $(TOOLSUBDIRS) ; do \ 217 $(MAKE) \ 218 HOSTOS=$(HOSTOS) \ 219 HOSTARCH=$(HOSTARCH) \ 220 HOST_CFLAGS="$(HOST_CFLAGS)" \ 221 HOST_LDFLAGS="$(HOST_LDFLAGS)" \ 222 -C $$dir || exit 1 ; \ 223 done 224endif 225 226$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP) 227 $(obj)./bmp_logo $(LOGO_BMP) >$@ 228 229######################################################################### 230 231# defines $(obj).depend target 232include $(SRCTREE)/rules.mk 233 234sinclude $(obj).depend 235 236######################################################################### 237