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# 38ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc) 39HOST_CFLAGS = -traditional-cpp -Wall 40HOST_LDFLAGS =-multiply_defined suppress 41 42else 43ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc) 44HOST_CFLAGS = -Wall -pedantic 45HOST_LDFLAGS = 46 47# 48# Everyone else 49# 50else 51HOST_CFLAGS = -Wall -pedantic 52HOST_LDFLAGS = 53endif 54endif 55 56# 57# Cygwin needs .exe files :-( 58# 59ifeq ($(HOSTOS),cygwin) 60SFX = .exe 61HOST_CFLAGS += -ansi 62else 63SFX = 64endif 65 66# 67# Include this after HOSTOS HOSTARCH check 68# so that we can act intelligently. 69# 70include $(TOPDIR)/config.mk 71 72# Generated executable files 73BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX) 74BIN_FILES-y += mkimage$(SFX) 75BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX) 76BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX) 77BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX) 78BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX) 79BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX) 80BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX) 81BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX) 82 83# Source files which exist outside the tools directory 84EXT_OBJ_FILES-y += common/env_embedded.o 85EXT_OBJ_FILES-y += lib_generic/crc32.o 86EXT_OBJ_FILES-y += lib_generic/md5.o 87EXT_OBJ_FILES-y += lib_generic/sha1.o 88EXT_OBJ_FILES-y += common/image.o 89 90# Source files located in the tools directory 91OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o 92OBJ_FILES-y += mkimage.o 93OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o 94OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o 95OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o 96OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o 97OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o 98OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o 99OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o 100 101# Don't build by default 102#ifeq ($(ARCH),ppc) 103#BIN_FILES-y += mpc86x_clk$(SFX) 104#OBJ_FILES-y += mpc86x_clk.o 105#endif 106 107# Flattened device tree objects 108LIBFDT_OBJ_FILES-y += fdt.o 109LIBFDT_OBJ_FILES-y += fdt_ro.o 110LIBFDT_OBJ_FILES-y += fdt_rw.o 111LIBFDT_OBJ_FILES-y += fdt_strerror.o 112LIBFDT_OBJ_FILES-y += fdt_wip.o 113 114# Generated LCD/video logo 115LOGO_H = $(OBJTREE)/include/bmp_logo.h 116LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H) 117LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) 118 119ifeq ($(LOGO_BMP),) 120LOGO_BMP= logos/denx.bmp 121endif 122ifeq ($(VENDOR),atmel) 123LOGO_BMP= logos/atmel.bmp 124endif 125 126# now $(obj) is defined 127SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c)) 128SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c)) 129SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c)) 130BINS := $(addprefix $(obj),$(BIN_FILES-y)) 131LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y)) 132 133# 134# Use native tools and options 135# 136CPPFLAGS = -idirafter $(SRCTREE)/include \ 137 -idirafter $(OBJTREE)/include2 \ 138 -idirafter $(OBJTREE)/include \ 139 -I $(SRCTREE)/libfdt \ 140 -I $(SRCTREE)/tools \ 141 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC 142CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O 143 144# No -pedantic switch to avoid libfdt compilation warnings 145FIT_CFLAGS = -Wall $(CPPFLAGS) -O 146 147AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS) 148CC = $(HOSTCC) 149STRIP = $(HOSTSTRIP) 150MAKEDEPEND = makedepend 151 152all: $(obj).depend $(BINS) $(LOGO-y) subdirs 153 154$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o 155 $(CC) $(CFLAGS) -o $@ $^ 156 157$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o 158 $(CC) $(CFLAGS) -o $@ $^ 159 160$(obj)img2srec$(SFX): $(obj)img2srec.o 161 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 162 $(STRIP) $@ 163 164$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \ 165 $(obj)sha1.o $(LIBFDT_OBJS) 166 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 167 $(STRIP) $@ 168 169$(obj)ncb$(SFX): $(obj)ncb.o 170 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 171 $(STRIP) $@ 172 173$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o 174 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 175 $(STRIP) $@ 176 177$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o 178 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 179 $(STRIP) $@ 180 181$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o 182 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 183 $(STRIP) $@ 184 185$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o 186 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 187 $(STRIP) $@ 188 189$(obj)bin2header$(SFX): $(obj)bin2header.o 190 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ 191 $(STRIP) $@ 192 193# image.c and mkimage.c require FIT_CFLAGS instead of standard CFLAGS 194$(obj)image.o: $(SRCTREE)/tools/image.c 195 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 196 197$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c 198 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 199 200# Some of the tool objects need to be accessed from outside the tools directory 201$(obj)%.o: $(SRCTREE)/common/%.c 202 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 203 204$(obj)%.o: $(SRCTREE)/lib_generic/%.c 205 $(CC) -g $(CFLAGS) -c -o $@ $< 206 207$(LIBFDT_OBJS): 208 $(CC) -g $(FIT_CFLAGS) -c -o $@ $< 209 210subdirs: 211ifeq ($(TOOLSUBDIRS),) 212 @: 213else 214 @for dir in $(TOOLSUBDIRS) ; do \ 215 $(MAKE) \ 216 HOSTOS=$(HOSTOS) \ 217 HOSTARCH=$(HOSTARCH) \ 218 HOST_CFLAGS="$(HOST_CFLAGS)" \ 219 HOST_LDFLAGS="$(HOST_LDFLAGS)" \ 220 -C $$dir || exit 1 ; \ 221 done 222endif 223 224$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP) 225 $(obj)./bmp_logo $(LOGO_BMP) >$@ 226 227######################################################################### 228 229# defines $(obj).depend target 230include $(SRCTREE)/rules.mk 231 232sinclude $(obj).depend 233 234######################################################################### 235