blob: 14da78dc2d5b1fdf59cc89d229276f91ef45e3c8 [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
76BIN_FILES-y += img2srec$(SFX)
77BIN_FILES-y += mkimage$(SFX)
78BIN_FILES-y += envcrc$(SFX)
79BIN_FILES-y += ubsha1$(SFX)
80BIN_FILES-y += gen_eth_addr$(SFX)
81BIN_FILES-y += bmp_logo$(SFX)
82
83# Source files which are symlinked from elsewhere in U-Boot
84OBJ_LINKS-y += env_embedded.o
85OBJ_LINKS-y += crc32.o md5.o
86OBJ_LINKS-y += sha1.o
87OBJ_LINKS-y += image.o
88
89# Source files located in the tools directory
90OBJ_FILES-y += img2srec.o
91OBJ_FILES-y += mkimage.o
92OBJ_FILES-y += envcrc.o
93OBJ_FILES-y += ubsha1.o
94OBJ_FILES-y += gen_eth_addr.o
95OBJ_FILES-y += bmp_logo.o
96
97ifeq ($(ARCH),mips)
98BIN_FILES-y += inca-swap-bytes$(SFX)
99OBJ_FILES-y += inca-swap-bytes.o
100endif
101
102# Don't build by default
103#ifeq ($(ARCH),ppc)
104#BIN_FILES-y += mpc86x_clk$(SFX)
105#OBJ_FILES-y += mpc86x_clk.o
106#endif
107
108# Flattened device tree objects
109LIBFDT_OBJ_FILES-y += fdt.o
110LIBFDT_OBJ_FILES-y += fdt_ro.o
111LIBFDT_OBJ_FILES-y += fdt_rw.o
112LIBFDT_OBJ_FILES-y += fdt_strerror.o
113LIBFDT_OBJ_FILES-y += fdt_wip.o
114
115LOGO_H = $(OBJTREE)/include/bmp_logo.h
116
117ifeq ($(LOGO_BMP),)
118LOGO_BMP= logos/denx.bmp
119endif
120ifeq ($(VENDOR),atmel)
121LOGO_BMP= logos/atmel.bmp
122endif
123
Marian Balakowiczf9328632006-09-01 19:49:50 +0200124# now $(obj) is defined
Peter Tyseree3584a2009-03-13 18:54:34 -0500125SRCS := $(addprefix $(obj),$(OBJ_LINKS-y:.o=.c)) $(OBJ_FILES-y:.o=.c)
126BINS := $(addprefix $(obj),$(BIN_FILES-y))
127LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
Marian Balakowiczf9328632006-09-01 19:49:50 +0200128
wdenkefee1702002-07-20 20:14:13 +0000129#
130# Use native tools and options
131#
Marian Balakowiczf9328632006-09-01 19:49:50 +0200132CPPFLAGS = -idirafter $(SRCTREE)/include \
133 -idirafter $(OBJTREE)/include2 \
134 -idirafter $(OBJTREE)/include \
135 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000136CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100137
138# No -pedantic switch to avoid libfdt compilation warnings
139FIT_CFLAGS = -Wall $(CPPFLAGS) -O
140
wdenkefee1702002-07-20 20:14:13 +0000141AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
142CC = $(HOSTCC)
143STRIP = $(HOSTSTRIP)
144MAKEDEPEND = makedepend
145
Marian Balakowiczf9328632006-09-01 19:49:50 +0200146all: $(obj).depend $(BINS) $(LOGO_H) subdirs
wdenkefee1702002-07-20 20:14:13 +0000147
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200148$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500149 $(CC) $(CFLAGS) -o $@ $^
Heiko Schocher566a4942007-06-22 19:11:54 +0200150
151$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500152 $(CC) $(CFLAGS) -o $@ $^
wdenkefee1702002-07-20 20:14:13 +0000153
Marian Balakowiczf9328632006-09-01 19:49:50 +0200154$(obj)img2srec$(SFX): $(obj)img2srec.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500155 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
156 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000157
Peter Tyser21d28e92009-03-13 18:54:33 -0500158$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
Peter Tyseree3584a2009-03-13 18:54:34 -0500159 $(obj)sha1.o $(LIBFDT_OBJS)
Peter Tyser21d28e92009-03-13 18:54:33 -0500160 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
161 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000162
Marian Balakowiczf9328632006-09-01 19:49:50 +0200163$(obj)ncb$(SFX): $(obj)ncb.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500164 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
165 $(STRIP) $@
wdenkeedcd072004-09-08 22:03:11 +0000166
Marian Balakowiczf9328632006-09-01 19:49:50 +0200167$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500168 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
169 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000170
Marian Balakowiczf9328632006-09-01 19:49:50 +0200171$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500172 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
173 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000174
Marian Balakowiczf9328632006-09-01 19:49:50 +0200175$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500176 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
177 $(STRIP) $@
wdenk3e386912003-04-05 00:53:31 +0000178
Marian Balakowiczf9328632006-09-01 19:49:50 +0200179$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500180 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
181 $(STRIP) $@
wdenkef1464c2003-10-08 22:14:02 +0000182
Harald Welte0a823aa2008-07-09 22:30:30 +0800183$(obj)bin2header$(SFX): $(obj)bin2header.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500184 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
185 $(STRIP) $@
Harald Welte0a823aa2008-07-09 22:30:30 +0800186
Marian Balakowiczf9328632006-09-01 19:49:50 +0200187$(obj)envcrc.o: $(src)envcrc.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500188 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000189
Heiko Schocher566a4942007-06-22 19:11:54 +0200190$(obj)ubsha1.o: $(src)ubsha1.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500191 $(CC) -g $(CFLAGS) -c -o $@ $<
Heiko Schocher566a4942007-06-22 19:11:54 +0200192
Marian Balakowiczf9328632006-09-01 19:49:50 +0200193$(obj)crc32.o: $(obj)crc32.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500194 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000195
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100196$(obj)md5.o: $(obj)md5.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500197 $(CC) -g $(CFLAGS) -c -o $@ $<
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100198
Heiko Schocher566a4942007-06-22 19:11:54 +0200199$(obj)sha1.o: $(obj)sha1.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500200 $(CC) -g $(CFLAGS) -c -o $@ $<
Heiko Schocher566a4942007-06-22 19:11:54 +0200201
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100202$(obj)image.o: $(obj)image.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500203 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100204
Marian Balakowiczf9328632006-09-01 19:49:50 +0200205$(obj)mkimage.o: $(src)mkimage.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500206 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000207
Marian Balakowiczf9328632006-09-01 19:49:50 +0200208$(obj)ncb.o: $(src)ncb.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500209 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkeedcd072004-09-08 22:03:11 +0000210
Marian Balakowiczf9328632006-09-01 19:49:50 +0200211$(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500212 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000213
Marian Balakowiczf9328632006-09-01 19:49:50 +0200214$(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500215 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenk3e386912003-04-05 00:53:31 +0000216
Marian Balakowiczf9328632006-09-01 19:49:50 +0200217$(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500218 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkef1464c2003-10-08 22:14:02 +0000219
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100220$(obj)fdt.o: $(obj)fdt.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500221 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100222
223$(obj)fdt_ro.o: $(obj)fdt_ro.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500224 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100225
226$(obj)fdt_rw.o: $(obj)fdt_rw.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500227 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100228
229$(obj)fdt_strerror.o: $(obj)fdt_strerror.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500230 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100231
232$(obj)fdt_wip.o: $(obj)fdt_wip.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500233 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100234
wdenkefee1702002-07-20 20:14:13 +0000235subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000236ifeq ($(TOOLSUBDIRS),)
Peter Tyser21d28e92009-03-13 18:54:33 -0500237 @:
wdenke0ac62d2003-08-17 18:55:18 +0000238else
Peter Tyser21d28e92009-03-13 18:54:33 -0500239 @for dir in $(TOOLSUBDIRS) ; do \
240 $(MAKE) \
241 HOSTOS=$(HOSTOS) \
242 HOSTARCH=$(HOSTARCH) \
243 HOST_CFLAGS="$(HOST_CFLAGS)" \
244 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
245 -C $$dir || exit 1 ; \
246 done
wdenke0ac62d2003-08-17 18:55:18 +0000247endif
248
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200249$(obj)env_embedded.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500250 @rm -f $(obj)env_embedded.c
251 ln -s $(src)../common/env_embedded.c $(obj)env_embedded.c
wdenkefee1702002-07-20 20:14:13 +0000252
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200253$(obj)env_embedded.o: $(obj)env_embedded.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500254 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000255
Mike Frysinger89cdab72008-03-31 11:02:01 -0400256$(obj)zlib.h:
Peter Tyser21d28e92009-03-13 18:54:33 -0500257 @rm -f $@
258 ln -s $(src)../include/zlib.h $@
Mike Frysinger89cdab72008-03-31 11:02:01 -0400259
260$(obj)crc32.c: $(obj)zlib.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500261 @rm -f $(obj)crc32.c
262 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
wdenkefee1702002-07-20 20:14:13 +0000263
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100264$(obj)md5.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500265 @rm -f $(obj)md5.c
266 ln -s $(src)../lib_generic/md5.c $(obj)md5.c
Bartlomiej Sieka766529f2008-03-14 16:22:34 +0100267
Heiko Schocher566a4942007-06-22 19:11:54 +0200268$(obj)sha1.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500269 @rm -f $(obj)sha1.c
270 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
Heiko Schocher566a4942007-06-22 19:11:54 +0200271
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100272$(obj)image.c:
Peter Tyser21d28e92009-03-13 18:54:33 -0500273 @rm -f $(obj)image.c
274 ln -s $(src)../common/image.c $(obj)image.c
275 if [ ! -f $(obj)mkimage.h ] ; then \
276 ln -s $(src)../tools/mkimage.h $(obj)mkimage.h; \
277 fi
278 if [ ! -f $(obj)fdt_host.h ] ; then \
279 ln -s $(src)../tools/fdt_host.h $(obj)fdt_host.h; \
280 fi
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100281
Anatolij Gustschinb9670dd2008-03-26 21:05:43 +0100282$(obj)fdt.c: $(obj)libfdt_internal.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500283 @rm -f $(obj)fdt.c
284 ln -s $(src)../libfdt/fdt.c $(obj)fdt.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100285
Anatolij Gustschinb9670dd2008-03-26 21:05:43 +0100286$(obj)fdt_ro.c: $(obj)libfdt_internal.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500287 @rm -f $(obj)fdt_ro.c
288 ln -s $(src)../libfdt/fdt_ro.c $(obj)fdt_ro.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100289
Anatolij Gustschinb9670dd2008-03-26 21:05:43 +0100290$(obj)fdt_rw.c: $(obj)libfdt_internal.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500291 @rm -f $(obj)fdt_rw.c
292 ln -s $(src)../libfdt/fdt_rw.c $(obj)fdt_rw.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100293
Anatolij Gustschinb9670dd2008-03-26 21:05:43 +0100294$(obj)fdt_strerror.c: $(obj)libfdt_internal.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500295 @rm -f $(obj)fdt_strerror.c
296 ln -s $(src)../libfdt/fdt_strerror.c $(obj)fdt_strerror.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100297
Anatolij Gustschinb9670dd2008-03-26 21:05:43 +0100298$(obj)fdt_wip.c: $(obj)libfdt_internal.h
Peter Tyser21d28e92009-03-13 18:54:33 -0500299 @rm -f $(obj)fdt_wip.c
300 ln -s $(src)../libfdt/fdt_wip.c $(obj)fdt_wip.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100301
302$(obj)libfdt_internal.h:
Peter Tyser21d28e92009-03-13 18:54:33 -0500303 @rm -f $(obj)libfdt_internal.h
304 ln -s $(src)../libfdt/libfdt_internal.h $(obj)libfdt_internal.h
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100305
Marian Balakowiczf9328632006-09-01 19:49:50 +0200306$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
Peter Tyser21d28e92009-03-13 18:54:33 -0500307 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000308
309#########################################################################
310
Marian Balakowiczf9328632006-09-01 19:49:50 +0200311# defines $(obj).depend target
312include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000313
Marian Balakowiczf9328632006-09-01 19:49:50 +0200314sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000315
316#########################################################################