blob: b1680adc0c9623ec07b3bea27e4ecb7deb791784 [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#
38ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
wdenkefee1702002-07-20 20:14:13 +000039HOST_CFLAGS = -traditional-cpp -Wall
40HOST_LDFLAGS =-multiply_defined suppress
Aubrey.Li5dfaa502007-05-14 11:47:35 +080041HOST_ENVIRO_CFLAGS =
wdenkefee1702002-07-20 20:14:13 +000042
43else
wdenkefee1702002-07-20 20:14:13 +000044ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
45HOST_CFLAGS = -Wall -pedantic
46HOST_LDFLAGS =
47HOST_ENVIRO_CFLAGS =
48
49#
50# Everyone else
51#
52else
wdenkefee1702002-07-20 20:14:13 +000053HOST_CFLAGS = -Wall -pedantic
54HOST_LDFLAGS =
55HOST_ENVIRO_CFLAGS =
56endif
57endif
58
59#
60# Cygwin needs .exe files :-(
61#
62ifeq ($(HOSTOS),cygwin)
63SFX = .exe
raptorbrino@aim.com883e3922007-12-13 21:23:28 -050064HOST_CFLAGS += -ansi
wdenkefee1702002-07-20 20:14:13 +000065else
66SFX =
67endif
68
wdenkefee1702002-07-20 20:14:13 +000069#
70# Include this after HOSTOS HOSTARCH check
71# so that we can act intelligently.
72#
73include $(TOPDIR)/config.mk
74
Peter Tyseree3584a2009-03-13 18:54:34 -050075# Generated executable files
Peter Tysereeba8612009-03-13 18:54:36 -050076BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
Peter Tyseree3584a2009-03-13 18:54:34 -050077BIN_FILES-y += mkimage$(SFX)
Peter Tyser4d93a0a2009-03-13 18:54:39 -050078BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
Peter Tyser7cd5cbc2009-03-13 18:54:37 -050079BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
Peter Tyser123c48a2009-03-13 18:54:40 -050080BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
Peter Tyser335ffe72009-03-13 18:54:35 -050081BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
82BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
Peter Tysercd26a312009-03-13 18:54:38 -050083BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
Peter Tyser1cd300d2009-03-13 18:54:41 -050084BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
Peter Tyseree3584a2009-03-13 18:54:34 -050085
86# Source files which are symlinked from elsewhere in U-Boot
87OBJ_LINKS-y += env_embedded.o
88OBJ_LINKS-y += crc32.o md5.o
89OBJ_LINKS-y += sha1.o
90OBJ_LINKS-y += image.o
91
92# Source files located in the tools directory
Peter Tysereeba8612009-03-13 18:54:36 -050093OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
Peter Tyseree3584a2009-03-13 18:54:34 -050094OBJ_FILES-y += mkimage.o
Peter Tyser4d93a0a2009-03-13 18:54:39 -050095OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
Peter Tyser7cd5cbc2009-03-13 18:54:37 -050096OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
Peter Tyser123c48a2009-03-13 18:54:40 -050097OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
Peter Tyser335ffe72009-03-13 18:54:35 -050098OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
99OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
Peter Tysercd26a312009-03-13 18:54:38 -0500100OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
Peter Tyser1cd300d2009-03-13 18:54:41 -0500101OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
Peter Tyseree3584a2009-03-13 18:54:34 -0500102
103# Don't build by default
104#ifeq ($(ARCH),ppc)
105#BIN_FILES-y += mpc86x_clk$(SFX)
106#OBJ_FILES-y += mpc86x_clk.o
107#endif
108
109# Flattened device tree objects
110LIBFDT_OBJ_FILES-y += fdt.o
111LIBFDT_OBJ_FILES-y += fdt_ro.o
112LIBFDT_OBJ_FILES-y += fdt_rw.o
113LIBFDT_OBJ_FILES-y += fdt_strerror.o
114LIBFDT_OBJ_FILES-y += fdt_wip.o
115
Peter Tyser335ffe72009-03-13 18:54:35 -0500116# Generated LCD/video logo
Peter Tyseree3584a2009-03-13 18:54:34 -0500117LOGO_H = $(OBJTREE)/include/bmp_logo.h
Peter Tyser335ffe72009-03-13 18:54:35 -0500118LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
119LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
Peter Tyseree3584a2009-03-13 18:54:34 -0500120
121ifeq ($(LOGO_BMP),)
122LOGO_BMP= logos/denx.bmp
123endif
124ifeq ($(VENDOR),atmel)
125LOGO_BMP= logos/atmel.bmp
126endif
127
Marian Balakowiczf9328632006-09-01 19:49:50 +0200128# now $(obj) is defined
Peter Tyseree3584a2009-03-13 18:54:34 -0500129SRCS := $(addprefix $(obj),$(OBJ_LINKS-y:.o=.c)) $(OBJ_FILES-y:.o=.c)
Peter Tysereed07332009-03-13 18:54:46 -0500130SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
Peter Tyseree3584a2009-03-13 18:54:34 -0500131BINS := $(addprefix $(obj),$(BIN_FILES-y))
132LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
Marian Balakowiczf9328632006-09-01 19:49:50 +0200133
wdenkefee1702002-07-20 20:14:13 +0000134#
135# Use native tools and options
136#
Marian Balakowiczf9328632006-09-01 19:49:50 +0200137CPPFLAGS = -idirafter $(SRCTREE)/include \
138 -idirafter $(OBJTREE)/include2 \
139 -idirafter $(OBJTREE)/include \
Peter Tyser45d6bdf2009-03-13 18:54:44 -0500140 -I $(SRCTREE)/libfdt \
Peter Tyser40b8d902009-03-13 18:54:42 -0500141 -I $(SRCTREE)/tools \
Marian Balakowiczf9328632006-09-01 19:49:50 +0200142 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000143CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100144
145# No -pedantic switch to avoid libfdt compilation warnings
146FIT_CFLAGS = -Wall $(CPPFLAGS) -O
147
wdenkefee1702002-07-20 20:14:13 +0000148AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
149CC = $(HOSTCC)
150STRIP = $(HOSTSTRIP)
151MAKEDEPEND = makedepend
152
Peter Tyser335ffe72009-03-13 18:54:35 -0500153all: $(obj).depend $(BINS) $(LOGO-y) subdirs
wdenkefee1702002-07-20 20:14:13 +0000154
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200155$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500156 $(CC) $(CFLAGS) -o $@ $^
Heiko Schocher566a4942007-06-22 19:11:54 +0200157
158$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500159 $(CC) $(CFLAGS) -o $@ $^
wdenkefee1702002-07-20 20:14:13 +0000160
Marian Balakowiczf9328632006-09-01 19:49:50 +0200161$(obj)img2srec$(SFX): $(obj)img2srec.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500162 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
163 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000164
Peter Tyser21d28e92009-03-13 18:54:33 -0500165$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
Peter Tyseree3584a2009-03-13 18:54:34 -0500166 $(obj)sha1.o $(LIBFDT_OBJS)
Peter Tyser21d28e92009-03-13 18:54:33 -0500167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000169
Marian Balakowiczf9328632006-09-01 19:49:50 +0200170$(obj)ncb$(SFX): $(obj)ncb.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500171 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
172 $(STRIP) $@
wdenkeedcd072004-09-08 22:03:11 +0000173
Marian Balakowiczf9328632006-09-01 19:49:50 +0200174$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500175 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
176 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000177
Marian Balakowiczf9328632006-09-01 19:49:50 +0200178$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500179 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
180 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000181
Marian Balakowiczf9328632006-09-01 19:49:50 +0200182$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500183 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
184 $(STRIP) $@
wdenk3e386912003-04-05 00:53:31 +0000185
Marian Balakowiczf9328632006-09-01 19:49:50 +0200186$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500187 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
188 $(STRIP) $@
wdenkef1464c2003-10-08 22:14:02 +0000189
Harald Welte0a823aa2008-07-09 22:30:30 +0800190$(obj)bin2header$(SFX): $(obj)bin2header.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500191 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
192 $(STRIP) $@
Harald Welte0a823aa2008-07-09 22:30:30 +0800193
Marian Balakowiczf9328632006-09-01 19:49:50 +0200194$(obj)envcrc.o: $(src)envcrc.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500195 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000196
Heiko Schocher566a4942007-06-22 19:11:54 +0200197$(obj)ubsha1.o: $(src)ubsha1.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500198 $(CC) -g $(CFLAGS) -c -o $@ $<
Heiko Schocher566a4942007-06-22 19:11:54 +0200199
Marian Balakowiczf9328632006-09-01 19:49:50 +0200200$(obj)crc32.o: $(obj)crc32.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500201 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000202
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100203$(obj)md5.o: $(obj)md5.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500204 $(CC) -g $(CFLAGS) -c -o $@ $<
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100205
Heiko Schocher566a4942007-06-22 19:11:54 +0200206$(obj)sha1.o: $(obj)sha1.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500207 $(CC) -g $(CFLAGS) -c -o $@ $<
Heiko Schocher566a4942007-06-22 19:11:54 +0200208
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100209$(obj)image.o: $(obj)image.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500210 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100211
Marian Balakowiczf9328632006-09-01 19:49:50 +0200212$(obj)mkimage.o: $(src)mkimage.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500213 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000214
Marian Balakowiczf9328632006-09-01 19:49:50 +0200215$(obj)ncb.o: $(src)ncb.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500216 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkeedcd072004-09-08 22:03:11 +0000217
Marian Balakowiczf9328632006-09-01 19:49:50 +0200218$(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500219 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000220
Marian Balakowiczf9328632006-09-01 19:49:50 +0200221$(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500222 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenk3e386912003-04-05 00:53:31 +0000223
Marian Balakowiczf9328632006-09-01 19:49:50 +0200224$(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500225 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkef1464c2003-10-08 22:14:02 +0000226
Peter Tysereed07332009-03-13 18:54:46 -0500227$(obj)fdt.o:
Peter Tyser21d28e92009-03-13 18:54:33 -0500228 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100229
Peter Tysereed07332009-03-13 18:54:46 -0500230$(obj)fdt_ro.o:
Peter Tyser21d28e92009-03-13 18:54:33 -0500231 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100232
Peter Tysereed07332009-03-13 18:54:46 -0500233$(obj)fdt_rw.o:
Peter Tyser21d28e92009-03-13 18:54:33 -0500234 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100235
Peter Tysereed07332009-03-13 18:54:46 -0500236$(obj)fdt_strerror.o:
Peter Tyser21d28e92009-03-13 18:54:33 -0500237 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100238
Peter Tysereed07332009-03-13 18:54:46 -0500239$(obj)fdt_wip.o:
Peter Tyser21d28e92009-03-13 18:54:33 -0500240 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100241
wdenkefee1702002-07-20 20:14:13 +0000242subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000243ifeq ($(TOOLSUBDIRS),)
Peter Tyser21d28e92009-03-13 18:54:33 -0500244 @:
wdenke0ac62d2003-08-17 18:55:18 +0000245else
Peter Tyser21d28e92009-03-13 18:54:33 -0500246 @for dir in $(TOOLSUBDIRS) ; do \
247 $(MAKE) \
248 HOSTOS=$(HOSTOS) \
249 HOSTARCH=$(HOSTARCH) \
250 HOST_CFLAGS="$(HOST_CFLAGS)" \
251 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
252 -C $$dir || exit 1 ; \
253 done
wdenke0ac62d2003-08-17 18:55:18 +0000254endif
255
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200256$(obj)env_embedded.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500257 @rm -f $(obj)env_embedded.c
258 ln -s $(src)../common/env_embedded.c $(obj)env_embedded.c
wdenkefee1702002-07-20 20:14:13 +0000259
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200260$(obj)env_embedded.o: $(obj)env_embedded.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500261 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000262
Peter Tyserfba0e3a2009-03-13 18:54:43 -0500263$(obj)crc32.c: $(SRCTREE)/include/u-boot/zlib.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500264 @rm -f $(obj)crc32.c
265 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
wdenkefee1702002-07-20 20:14:13 +0000266
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100267$(obj)md5.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500268 @rm -f $(obj)md5.c
269 ln -s $(src)../lib_generic/md5.c $(obj)md5.c
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100270
Heiko Schocher566a4942007-06-22 19:11:54 +0200271$(obj)sha1.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500272 @rm -f $(obj)sha1.c
273 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
Heiko Schocher566a4942007-06-22 19:11:54 +0200274
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100275$(obj)image.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500276 @rm -f $(obj)image.c
277 ln -s $(src)../common/image.c $(obj)image.c
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100278
Marian Balakowiczf9328632006-09-01 19:49:50 +0200279$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
Peter Tyser21d28e92009-03-13 18:54:33 -0500280 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000281
282#########################################################################
283
Marian Balakowiczf9328632006-09-01 19:49:50 +0200284# defines $(obj).depend target
285include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000286
Marian Balakowiczf9328632006-09-01 19:49:50 +0200287sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000288
289#########################################################################