blob: d5c23fd7ee9acfe1c693c834561374b5a07cdc5b [file] [log] [blame]
wdenkefee1702002-07-20 20:14:13 +00001#
Marian Balakowiczf9328632006-09-01 19:49:50 +02002# (C) Copyright 2000-2006
wdenkefee1702002-07-20 20:14:13 +00003# 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
wdenkefee1702002-07-20 20:14:13 +000024TOOLSUBDIRS =
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#
Peter Tysere50abf62009-03-13 18:54:50 -050038
Mike Frysinger9aef7382009-07-19 15:17:03 -040039HOSTCFLAGS = -Wall
Peter Tysere50abf62009-03-13 18:54:50 -050040HOST_LDFLAGS =
41
wdenkefee1702002-07-20 20:14:13 +000042ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
Mike Frysinger9aef7382009-07-19 15:17:03 -040043HOSTCFLAGS += -traditional-cpp
Peter Tysere50abf62009-03-13 18:54:50 -050044HOST_LDFLAGS += -multiply_defined suppress
wdenkefee1702002-07-20 20:14:13 +000045else
Mike Frysinger9aef7382009-07-19 15:17:03 -040046HOSTCFLAGS += -pedantic
wdenkefee1702002-07-20 20:14:13 +000047endif
48
wdenkefee1702002-07-20 20:14:13 +000049ifeq ($(HOSTOS),cygwin)
Mike Frysinger9aef7382009-07-19 15:17:03 -040050HOSTCFLAGS += -ansi
Peter Tyser2f8d3962009-03-13 18:54:51 -050051endif
52
53#
54# toolchains targeting win32 generate .exe files
55#
56ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
57SFX = .exe
wdenkefee1702002-07-20 20:14:13 +000058else
59SFX =
60endif
61
wdenkefee1702002-07-20 20:14:13 +000062#
63# Include this after HOSTOS HOSTARCH check
64# so that we can act intelligently.
65#
66include $(TOPDIR)/config.mk
67
Peter Tyseree3584a2009-03-13 18:54:34 -050068# Generated executable files
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053069BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
70BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
Peter Tyser4d93a0a2009-03-13 18:54:39 -050071BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
Mike Frysinger2d8d2ad2009-06-14 21:35:16 -040072BIN_FILES-$(CONFIG_ENV_IS_IN_DATAFLASH) += envcrc$(SFX)
Wolfgang Denkf63728c2009-04-05 00:18:44 +020073BIN_FILES-$(CONFIG_ENV_IS_IN_EEPROM) += envcrc$(SFX)
Wolfgang Denkafcbce02009-04-04 16:10:40 +020074BIN_FILES-$(CONFIG_ENV_IS_IN_FLASH) += envcrc$(SFX)
Mike Frysinger2d8d2ad2009-06-14 21:35:16 -040075BIN_FILES-$(CONFIG_ENV_IS_IN_ONENAND) += envcrc$(SFX)
76BIN_FILES-$(CONFIG_ENV_IS_IN_NAND) += envcrc$(SFX)
Wolfgang Denkf63728c2009-04-05 00:18:44 +020077BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
Mike Frysinger2d8d2ad2009-06-14 21:35:16 -040078BIN_FILES-$(CONFIG_ENV_IS_IN_SPI_FLASH) += envcrc$(SFX)
Peter Tyser123c48a2009-03-13 18:54:40 -050079BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053080BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
Peter Tysercd26a312009-03-13 18:54:38 -050081BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053082BIN_FILES-y += mkimage$(SFX)
Peter Tyser1cd300d2009-03-13 18:54:41 -050083BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053084BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
Peter Tyseree3584a2009-03-13 18:54:34 -050085
Peter Tyserfb8b33c2009-03-13 18:54:47 -050086# Source files which exist outside the tools directory
87EXT_OBJ_FILES-y += common/env_embedded.o
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053088EXT_OBJ_FILES-y += common/image.o
Peter Tyserfb8b33c2009-03-13 18:54:47 -050089EXT_OBJ_FILES-y += lib_generic/crc32.o
90EXT_OBJ_FILES-y += lib_generic/md5.o
91EXT_OBJ_FILES-y += lib_generic/sha1.o
Peter Tyseree3584a2009-03-13 18:54:34 -050092
93# Source files located in the tools directory
Peter Tyser335ffe72009-03-13 18:54:35 -050094OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
95OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
Prafulla Wadaskardb588c72009-09-07 14:59:06 +053096OBJ_FILES-y += default_image.o
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053097OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
Prafulla Wadaskardb588c72009-09-07 14:59:06 +053098OBJ_FILES-y += fit_image.o
Prafulla Wadaskar34e00592009-08-10 20:44:06 +053099OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
100OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
Peter Tysercd26a312009-03-13 18:54:38 -0500101OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530102OBJ_FILES-y += mkimage.o
Peter Tyser1cd300d2009-03-13 18:54:41 -0500103OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
Peter Tyser2f8d3962009-03-13 18:54:51 -0500104OBJ_FILES-y += os_support.o
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530105OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
Peter Tyseree3584a2009-03-13 18:54:34 -0500106
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
Peter Tyser335ffe72009-03-13 18:54:35 -0500120# Generated LCD/video logo
Peter Tyseree3584a2009-03-13 18:54:34 -0500121LOGO_H = $(OBJTREE)/include/bmp_logo.h
Peter Tyser335ffe72009-03-13 18:54:35 -0500122LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
123LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
Peter Tyseree3584a2009-03-13 18:54:34 -0500124
125ifeq ($(LOGO_BMP),)
126LOGO_BMP= logos/denx.bmp
127endif
128ifeq ($(VENDOR),atmel)
129LOGO_BMP= logos/atmel.bmp
130endif
Ilko Ilievf0a2c7b2009-04-16 21:30:48 +0200131ifeq ($(VENDOR),ronetix)
132LOGO_BMP= logos/ronetix.bmp
133endif
Peter Tyseree3584a2009-03-13 18:54:34 -0500134
Marian Balakowiczf9328632006-09-01 19:49:50 +0200135# now $(obj) is defined
Peter Tyserfb8b33c2009-03-13 18:54:47 -0500136SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
Peter Tyserb0d4d722009-03-13 18:54:49 -0500137SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
Peter Tysereed07332009-03-13 18:54:46 -0500138SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
Wolfgang Denkafcbce02009-04-04 16:10:40 +0200139BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
Peter Tyseree3584a2009-03-13 18:54:34 -0500140LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
Marian Balakowiczf9328632006-09-01 19:49:50 +0200141
wdenkefee1702002-07-20 20:14:13 +0000142#
143# Use native tools and options
Peter Tyser2f8d3962009-03-13 18:54:51 -0500144# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
wdenkefee1702002-07-20 20:14:13 +0000145#
Marian Balakowiczf9328632006-09-01 19:49:50 +0200146CPPFLAGS = -idirafter $(SRCTREE)/include \
147 -idirafter $(OBJTREE)/include2 \
148 -idirafter $(OBJTREE)/include \
Peter Tyser45d6bdf2009-03-13 18:54:44 -0500149 -I $(SRCTREE)/libfdt \
Peter Tyser40b8d902009-03-13 18:54:42 -0500150 -I $(SRCTREE)/tools \
Peter Tyser2f8d3962009-03-13 18:54:51 -0500151 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
152 -D__KERNEL_STRICT_NAMES
Mike Frysinger9aef7382009-07-19 15:17:03 -0400153CFLAGS = $(HOSTCFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100154
155# No -pedantic switch to avoid libfdt compilation warnings
156FIT_CFLAGS = -Wall $(CPPFLAGS) -O
157
wdenkefee1702002-07-20 20:14:13 +0000158AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
159CC = $(HOSTCC)
160STRIP = $(HOSTSTRIP)
161MAKEDEPEND = makedepend
162
Peter Tyser335ffe72009-03-13 18:54:35 -0500163all: $(obj).depend $(BINS) $(LOGO-y) subdirs
wdenkefee1702002-07-20 20:14:13 +0000164
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530165$(obj)bin2header$(SFX): $(obj)bin2header.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500166 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
167 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000168
Marian Balakowiczf9328632006-09-01 19:49:50 +0200169$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500170 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
171 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000172
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530173$(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
174 $(CC) $(CFLAGS) -o $@ $^
175
176$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
177 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
178 $(STRIP) $@
179
180$(obj)img2srec$(SFX): $(obj)img2srec.o
181 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
182 $(STRIP) $@
183
Marian Balakowiczf9328632006-09-01 19:49:50 +0200184$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500185 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
186 $(STRIP) $@
wdenk3e386912003-04-05 00:53:31 +0000187
Prafulla Wadaskarc7138922009-08-19 17:36:46 +0530188$(obj)mkimage$(SFX): $(obj)crc32.o \
189 $(obj)default_image.o \
190 $(obj)fit_image.o \
191 $(obj)image.o \
192 $(obj)md5.o \
193 $(obj)mkimage.o \
194 $(obj)os_support.o \
195 $(obj)sha1.o \
196 $(LIBFDT_OBJS)
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530197 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
198 $(STRIP) $@
199
Marian Balakowiczf9328632006-09-01 19:49:50 +0200200$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500201 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
202 $(STRIP) $@
wdenkef1464c2003-10-08 22:14:02 +0000203
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530204$(obj)ncb$(SFX): $(obj)ncb.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500205 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
206 $(STRIP) $@
Harald Welte0a823aa2008-07-09 22:30:30 +0800207
Prafulla Wadaskar34e00592009-08-10 20:44:06 +0530208$(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
209 $(CC) $(CFLAGS) -o $@ $^
210
Peter Tyser2f8d3962009-03-13 18:54:51 -0500211# Some files complain if compiled with -pedantic, use FIT_CFLAGS
Prafulla Wadaskarc7138922009-08-19 17:36:46 +0530212$(obj)default_image.o: $(SRCTREE)/tools/default_image.c
213 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
214
215$(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c
216 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
217
Jean-Christophe PLAGNIOL-VILLARDae644c12009-04-04 12:46:31 +0200218$(obj)image.o: $(SRCTREE)/common/image.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500219 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100220
Peter Tyserb0d4d722009-03-13 18:54:49 -0500221$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500222 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000223
Peter Tyser2f8d3962009-03-13 18:54:51 -0500224$(obj)os_support.o: $(SRCTREE)/tools/os_support.c
225 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
226
Peter Tyserb0d4d722009-03-13 18:54:49 -0500227# Some of the tool objects need to be accessed from outside the tools directory
228$(obj)%.o: $(SRCTREE)/common/%.c
229 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
230
231$(obj)%.o: $(SRCTREE)/lib_generic/%.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500232 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkeedcd072004-09-08 22:03:11 +0000233
Peter Tyserb0d4d722009-03-13 18:54:49 -0500234$(LIBFDT_OBJS):
Peter Tyser21d28e92009-03-13 18:54:33 -0500235 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100236
wdenkefee1702002-07-20 20:14:13 +0000237subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000238ifeq ($(TOOLSUBDIRS),)
Peter Tyser21d28e92009-03-13 18:54:33 -0500239 @:
wdenke0ac62d2003-08-17 18:55:18 +0000240else
Peter Tyser21d28e92009-03-13 18:54:33 -0500241 @for dir in $(TOOLSUBDIRS) ; do \
242 $(MAKE) \
243 HOSTOS=$(HOSTOS) \
244 HOSTARCH=$(HOSTARCH) \
Mike Frysinger9aef7382009-07-19 15:17:03 -0400245 HOSTCFLAGS="$(HOSTCFLAGS)" \
Peter Tyser21d28e92009-03-13 18:54:33 -0500246 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
247 -C $$dir || exit 1 ; \
248 done
wdenke0ac62d2003-08-17 18:55:18 +0000249endif
250
Marian Balakowiczf9328632006-09-01 19:49:50 +0200251$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
Peter Tyser21d28e92009-03-13 18:54:33 -0500252 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000253
254#########################################################################
255
Marian Balakowiczf9328632006-09-01 19:49:50 +0200256# defines $(obj).depend target
257include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000258
Marian Balakowiczf9328632006-09-01 19:49:50 +0200259sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000260
261#########################################################################