blob: 9e9ee15fb87dc4f94ec1e24fa4d83c8b3ba5e1a1 [file] [log] [blame]
wdenkefee1702002-07-20 20:14:13 +00001#
Marian Balakowiczd62379d2006-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
Heiko Schocher633e03a2007-06-22 19:11:54 +020024BIN_FILES = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) ubsha1$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
wdenkefee1702002-07-20 20:14:13 +000025
Jean-Christophe PLAGNIOL-VILLARD4436c1e2008-09-10 22:48:01 +020026OBJ_LINKS = env_embedded.o crc32.o md5.o sha1.o image.o
Heiko Schocher633e03a2007-06-22 19:11:54 +020027OBJ_FILES = img2srec.o mkimage.o envcrc.o ubsha1.o gen_eth_addr.o bmp_logo.o
wdenkefee1702002-07-20 20:14:13 +000028
wdenkb02744a2003-04-05 00:53:31 +000029ifeq ($(ARCH),mips)
Marian Balakowiczd62379d2006-09-01 19:49:50 +020030BIN_FILES += inca-swap-bytes$(SFX)
31OBJ_FILES += inca-swap-bytes.o
wdenkb02744a2003-04-05 00:53:31 +000032endif
33
wdenk1ee550e2003-10-08 22:14:02 +000034# Don't build by default
35#ifeq ($(ARCH),ppc)
Marian Balakowiczd62379d2006-09-01 19:49:50 +020036#BIN_FILES += mpc86x_clk$(SFX)
37#OBJ_FILES += mpc86x_clk.o
wdenk1ee550e2003-10-08 22:14:02 +000038#endif
39
Anatolij Gustschin72977922008-03-26 21:05:43 +010040LIBFDT_OBJ_FILES = $(obj)fdt.o $(obj)fdt_ro.o $(obj)fdt_rw.o $(obj)fdt_strerror.o $(obj)fdt_wip.o
Bartlomiej Sieka61250862008-02-29 16:00:24 +010041
Marian Balakowiczd62379d2006-09-01 19:49:50 +020042LOGO_H = $(OBJTREE)/include/bmp_logo.h
wdenkefee1702002-07-20 20:14:13 +000043
44ifeq ($(LOGO_BMP),)
45LOGO_BMP= logos/denx.bmp
46endif
Stelian Pope6632d92008-05-08 14:52:33 +020047ifeq ($(VENDOR),atmel)
48LOGO_BMP= logos/atmel.bmp
49endif
50
wdenkefee1702002-07-20 20:14:13 +000051
52#-------------------------------------------------------------------------
53
54HOSTARCH := $(shell uname -m | \
55 sed -e s/i.86/i386/ \
56 -e s/sun4u/sparc64/ \
57 -e s/arm.*/arm/ \
58 -e s/sa110/arm/ \
59 -e s/powerpc/ppc/ \
60 -e s/Power\ Macintosh/ppc/ \
61 -e s/macppc/ppc/)
62
63HOSTOS := $(shell uname -s | tr A-Z a-z | \
64 sed -e 's/\(cygwin\).*/cygwin/')
65
66TOOLSUBDIRS =
67
68#
69# Mac OS X / Darwin's C preprocessor is Apple specific. It
70# generates numerous errors and warnings. We want to bypass it
71# and use GNU C's cpp. To do this we pass the -traditional-cpp
72# option to the compiler. Note that the -traditional-cpp flag
73# DOES NOT have the same semantics as GNU C's flag, all it does
74# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
75#
76# Apple's linker is similar, thanks to the new 2 stage linking
77# multiple symbol definitions are treated as errors, hence the
78# -multiply_defined suppress option to turn off this error.
79#
80ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
wdenkefee1702002-07-20 20:14:13 +000081HOST_CFLAGS = -traditional-cpp -Wall
82HOST_LDFLAGS =-multiply_defined suppress
Aubrey.Lifecb2a02007-05-14 11:47:35 +080083HOST_ENVIRO_CFLAGS =
wdenkefee1702002-07-20 20:14:13 +000084
85else
wdenkefee1702002-07-20 20:14:13 +000086ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
87HOST_CFLAGS = -Wall -pedantic
88HOST_LDFLAGS =
89HOST_ENVIRO_CFLAGS =
90
91#
92# Everyone else
93#
94else
wdenkefee1702002-07-20 20:14:13 +000095HOST_CFLAGS = -Wall -pedantic
96HOST_LDFLAGS =
97HOST_ENVIRO_CFLAGS =
98endif
99endif
100
101#
102# Cygwin needs .exe files :-(
103#
104ifeq ($(HOSTOS),cygwin)
105SFX = .exe
raptorbrino@aim.com59f12752007-12-13 21:23:28 -0500106HOST_CFLAGS += -ansi
wdenkefee1702002-07-20 20:14:13 +0000107else
108SFX =
109endif
110
wdenkefee1702002-07-20 20:14:13 +0000111#
112# Include this after HOSTOS HOSTARCH check
113# so that we can act intelligently.
114#
115include $(TOPDIR)/config.mk
116
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200117# now $(obj) is defined
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200118SRCS := $(addprefix $(obj),$(OBJ_LINKS:.o=.c)) $(OBJ_FILES:.o=.c)
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200119BINS := $(addprefix $(obj),$(BIN_FILES))
120
wdenkefee1702002-07-20 20:14:13 +0000121#
122# Use native tools and options
123#
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200124CPPFLAGS = -idirafter $(SRCTREE)/include \
125 -idirafter $(OBJTREE)/include2 \
126 -idirafter $(OBJTREE)/include \
127 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000128CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100129
130# No -pedantic switch to avoid libfdt compilation warnings
131FIT_CFLAGS = -Wall $(CPPFLAGS) -O
132
wdenkefee1702002-07-20 20:14:13 +0000133AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
134CC = $(HOSTCC)
135STRIP = $(HOSTSTRIP)
136MAKEDEPEND = makedepend
137
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200138all: $(obj).depend $(BINS) $(LOGO_H) subdirs
wdenkefee1702002-07-20 20:14:13 +0000139
Jean-Christophe PLAGNIOL-VILLARD4436c1e2008-09-10 22:48:01 +0200140$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
wdenkefee1702002-07-20 20:14:13 +0000141 $(CC) $(CFLAGS) -o $@ $^
142
Heiko Schocher633e03a2007-06-22 19:11:54 +0200143$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
144 $(CC) $(CFLAGS) -o $@ $^
145
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200146$(obj)img2srec$(SFX): $(obj)img2srec.o
wdenkefee1702002-07-20 20:14:13 +0000147 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
148 $(STRIP) $@
149
Bartlomiej Sieka2e6f2852008-03-14 16:22:34 +0100150$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o $(obj)sha1.o $(LIBFDT_OBJ_FILES)
wdenkefee1702002-07-20 20:14:13 +0000151 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
152 $(STRIP) $@
153
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200154$(obj)ncb$(SFX): $(obj)ncb.o
wdenka0ebde52004-09-08 22:03:11 +0000155 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
156 $(STRIP) $@
157
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200158$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
wdenkefee1702002-07-20 20:14:13 +0000159 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
160 $(STRIP) $@
161
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200162$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
wdenkefee1702002-07-20 20:14:13 +0000163 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
164 $(STRIP) $@
165
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200166$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
wdenkb02744a2003-04-05 00:53:31 +0000167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168 $(STRIP) $@
169
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200170$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
wdenk1ee550e2003-10-08 22:14:02 +0000171 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
172 $(STRIP) $@
173
Harald Welte5708dbf2008-07-09 22:30:30 +0800174$(obj)bin2header$(SFX): $(obj)bin2header.o
175 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
176 $(STRIP) $@
177
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200178$(obj)envcrc.o: $(src)envcrc.c
179 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000180
Heiko Schocher633e03a2007-06-22 19:11:54 +0200181$(obj)ubsha1.o: $(src)ubsha1.c
182 $(CC) -g $(CFLAGS) -c -o $@ $<
183
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200184$(obj)crc32.o: $(obj)crc32.c
185 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000186
Bartlomiej Sieka2e6f2852008-03-14 16:22:34 +0100187$(obj)md5.o: $(obj)md5.c
188 $(CC) -g $(CFLAGS) -c -o $@ $<
189
Heiko Schocher633e03a2007-06-22 19:11:54 +0200190$(obj)sha1.o: $(obj)sha1.c
191 $(CC) -g $(CFLAGS) -c -o $@ $<
192
Marian Balakowicz41d71ed2008-01-08 18:14:09 +0100193$(obj)image.o: $(obj)image.c
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100194 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowicz41d71ed2008-01-08 18:14:09 +0100195
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200196$(obj)mkimage.o: $(src)mkimage.c
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100197 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000198
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200199$(obj)ncb.o: $(src)ncb.c
200 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenka0ebde52004-09-08 22:03:11 +0000201
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200202$(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
203 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000204
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200205$(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
206 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkb02744a2003-04-05 00:53:31 +0000207
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200208$(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
209 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenk1ee550e2003-10-08 22:14:02 +0000210
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100211$(obj)fdt.o: $(obj)fdt.c
212 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
213
214$(obj)fdt_ro.o: $(obj)fdt_ro.c
215 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
216
217$(obj)fdt_rw.o: $(obj)fdt_rw.c
218 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
219
220$(obj)fdt_strerror.o: $(obj)fdt_strerror.c
221 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
222
223$(obj)fdt_wip.o: $(obj)fdt_wip.c
224 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
225
wdenkefee1702002-07-20 20:14:13 +0000226subdirs:
wdenk5d841732003-08-17 18:55:18 +0000227ifeq ($(TOOLSUBDIRS),)
228 @:
229else
wdenkefee1702002-07-20 20:14:13 +0000230 @for dir in $(TOOLSUBDIRS) ; do \
231 $(MAKE) \
232 HOSTOS=$(HOSTOS) \
233 HOSTARCH=$(HOSTARCH) \
234 HOST_CFLAGS="$(HOST_CFLAGS)" \
Wolfgang Denka1be4762008-05-20 16:00:29 +0200235 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
wdenkefee1702002-07-20 20:14:13 +0000236 -C $$dir || exit 1 ; \
237 done
wdenk5d841732003-08-17 18:55:18 +0000238endif
239
Jean-Christophe PLAGNIOL-VILLARD4436c1e2008-09-10 22:48:01 +0200240$(obj)env_embedded.c:
241 @rm -f $(obj)env_embedded.c
242 ln -s $(src)../common/env_embedded.c $(obj)env_embedded.c
wdenkefee1702002-07-20 20:14:13 +0000243
Jean-Christophe PLAGNIOL-VILLARD4436c1e2008-09-10 22:48:01 +0200244$(obj)env_embedded.o: $(obj)env_embedded.c
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200245 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000246
Mike Frysingera2c67e92008-03-31 11:02:01 -0400247$(obj)zlib.h:
248 @rm -f $@
249 ln -s $(src)../include/zlib.h $@
250
251$(obj)crc32.c: $(obj)zlib.h
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200252 @rm -f $(obj)crc32.c
253 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
wdenkefee1702002-07-20 20:14:13 +0000254
Bartlomiej Sieka2e6f2852008-03-14 16:22:34 +0100255$(obj)md5.c:
256 @rm -f $(obj)md5.c
257 ln -s $(src)../lib_generic/md5.c $(obj)md5.c
258
Heiko Schocher633e03a2007-06-22 19:11:54 +0200259$(obj)sha1.c:
260 @rm -f $(obj)sha1.c
261 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
262
Marian Balakowicz41d71ed2008-01-08 18:14:09 +0100263$(obj)image.c:
264 @rm -f $(obj)image.c
265 ln -s $(src)../common/image.c $(obj)image.c
Anatolij Gustschin72977922008-03-26 21:05:43 +0100266 if [ ! -f $(obj)mkimage.h ] ; then \
267 ln -s $(src)../tools/mkimage.h $(obj)mkimage.h; \
268 fi
269 if [ ! -f $(obj)fdt_host.h ] ; then \
270 ln -s $(src)../tools/fdt_host.h $(obj)fdt_host.h; \
271 fi
Marian Balakowicz41d71ed2008-01-08 18:14:09 +0100272
Anatolij Gustschin72977922008-03-26 21:05:43 +0100273$(obj)fdt.c: $(obj)libfdt_internal.h
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100274 @rm -f $(obj)fdt.c
275 ln -s $(src)../libfdt/fdt.c $(obj)fdt.c
276
Anatolij Gustschin72977922008-03-26 21:05:43 +0100277$(obj)fdt_ro.c: $(obj)libfdt_internal.h
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100278 @rm -f $(obj)fdt_ro.c
279 ln -s $(src)../libfdt/fdt_ro.c $(obj)fdt_ro.c
280
Anatolij Gustschin72977922008-03-26 21:05:43 +0100281$(obj)fdt_rw.c: $(obj)libfdt_internal.h
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100282 @rm -f $(obj)fdt_rw.c
283 ln -s $(src)../libfdt/fdt_rw.c $(obj)fdt_rw.c
284
Anatolij Gustschin72977922008-03-26 21:05:43 +0100285$(obj)fdt_strerror.c: $(obj)libfdt_internal.h
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100286 @rm -f $(obj)fdt_strerror.c
287 ln -s $(src)../libfdt/fdt_strerror.c $(obj)fdt_strerror.c
288
Anatolij Gustschin72977922008-03-26 21:05:43 +0100289$(obj)fdt_wip.c: $(obj)libfdt_internal.h
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100290 @rm -f $(obj)fdt_wip.c
291 ln -s $(src)../libfdt/fdt_wip.c $(obj)fdt_wip.c
292
293$(obj)libfdt_internal.h:
294 @rm -f $(obj)libfdt_internal.h
295 ln -s $(src)../libfdt/libfdt_internal.h $(obj)libfdt_internal.h
296
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200297$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
298 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000299
300#########################################################################
301
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200302# defines $(obj).depend target
303include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000304
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200305sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000306
307#########################################################################