blob: aa4af1823b7810715e0afc1aae0eb6dee75a61ed [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
Heiko Schocher566a4942007-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
Marian Balakowiczb97a2a02008-01-08 18:14:09 +010026OBJ_LINKS = environment.o crc32.o sha1.o image.o
Heiko Schocher566a4942007-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
wdenk3e386912003-04-05 00:53:31 +000029ifeq ($(ARCH),mips)
Marian Balakowiczf9328632006-09-01 19:49:50 +020030BIN_FILES += inca-swap-bytes$(SFX)
31OBJ_FILES += inca-swap-bytes.o
wdenk3e386912003-04-05 00:53:31 +000032endif
33
wdenkef1464c2003-10-08 22:14:02 +000034# Don't build by default
35#ifeq ($(ARCH),ppc)
Marian Balakowiczf9328632006-09-01 19:49:50 +020036#BIN_FILES += mpc86x_clk$(SFX)
37#OBJ_FILES += mpc86x_clk.o
wdenkef1464c2003-10-08 22:14:02 +000038#endif
39
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +010040LIBFDT_OBJ_FILES = fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o
41
Marian Balakowiczf9328632006-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
47
48#-------------------------------------------------------------------------
49
50HOSTARCH := $(shell uname -m | \
51 sed -e s/i.86/i386/ \
52 -e s/sun4u/sparc64/ \
53 -e s/arm.*/arm/ \
54 -e s/sa110/arm/ \
55 -e s/powerpc/ppc/ \
56 -e s/Power\ Macintosh/ppc/ \
57 -e s/macppc/ppc/)
58
59HOSTOS := $(shell uname -s | tr A-Z a-z | \
60 sed -e 's/\(cygwin\).*/cygwin/')
61
62TOOLSUBDIRS =
63
64#
65# Mac OS X / Darwin's C preprocessor is Apple specific. It
66# generates numerous errors and warnings. We want to bypass it
67# and use GNU C's cpp. To do this we pass the -traditional-cpp
68# option to the compiler. Note that the -traditional-cpp flag
69# DOES NOT have the same semantics as GNU C's flag, all it does
70# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
71#
72# Apple's linker is similar, thanks to the new 2 stage linking
73# multiple symbol definitions are treated as errors, hence the
74# -multiply_defined suppress option to turn off this error.
75#
76ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
wdenkefee1702002-07-20 20:14:13 +000077HOST_CFLAGS = -traditional-cpp -Wall
78HOST_LDFLAGS =-multiply_defined suppress
Aubrey.Li5dfaa502007-05-14 11:47:35 +080079HOST_ENVIRO_CFLAGS =
wdenkefee1702002-07-20 20:14:13 +000080
81else
wdenkefee1702002-07-20 20:14:13 +000082ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
83HOST_CFLAGS = -Wall -pedantic
84HOST_LDFLAGS =
85HOST_ENVIRO_CFLAGS =
86
87#
88# Everyone else
89#
90else
wdenkefee1702002-07-20 20:14:13 +000091HOST_CFLAGS = -Wall -pedantic
92HOST_LDFLAGS =
93HOST_ENVIRO_CFLAGS =
94endif
95endif
96
97#
98# Cygwin needs .exe files :-(
99#
100ifeq ($(HOSTOS),cygwin)
101SFX = .exe
raptorbrino@aim.com883e3922007-12-13 21:23:28 -0500102HOST_CFLAGS += -ansi
wdenkefee1702002-07-20 20:14:13 +0000103else
104SFX =
105endif
106
wdenkefee1702002-07-20 20:14:13 +0000107#
108# Include this after HOSTOS HOSTARCH check
109# so that we can act intelligently.
110#
111include $(TOPDIR)/config.mk
112
Marian Balakowiczf9328632006-09-01 19:49:50 +0200113# now $(obj) is defined
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200114SRCS := $(addprefix $(obj),$(OBJ_LINKS:.o=.c)) $(OBJ_FILES:.o=.c)
Marian Balakowiczf9328632006-09-01 19:49:50 +0200115BINS := $(addprefix $(obj),$(BIN_FILES))
116
wdenkefee1702002-07-20 20:14:13 +0000117#
118# Use native tools and options
119#
Marian Balakowiczf9328632006-09-01 19:49:50 +0200120CPPFLAGS = -idirafter $(SRCTREE)/include \
121 -idirafter $(OBJTREE)/include2 \
122 -idirafter $(OBJTREE)/include \
123 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000124CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100125
126# No -pedantic switch to avoid libfdt compilation warnings
127FIT_CFLAGS = -Wall $(CPPFLAGS) -O
128
wdenkefee1702002-07-20 20:14:13 +0000129AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
130CC = $(HOSTCC)
131STRIP = $(HOSTSTRIP)
132MAKEDEPEND = makedepend
133
Marian Balakowiczf9328632006-09-01 19:49:50 +0200134all: $(obj).depend $(BINS) $(LOGO_H) subdirs
wdenkefee1702002-07-20 20:14:13 +0000135
Heiko Schocher566a4942007-06-22 19:11:54 +0200136$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)environment.o $(obj)sha1.o
137 $(CC) $(CFLAGS) -o $@ $^
138
139$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
wdenkefee1702002-07-20 20:14:13 +0000140 $(CC) $(CFLAGS) -o $@ $^
141
Marian Balakowiczf9328632006-09-01 19:49:50 +0200142$(obj)img2srec$(SFX): $(obj)img2srec.o
wdenkefee1702002-07-20 20:14:13 +0000143 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
144 $(STRIP) $@
145
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100146$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)sha1.o $(LIBFDT_OBJ_FILES)
wdenkefee1702002-07-20 20:14:13 +0000147 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
148 $(STRIP) $@
149
Marian Balakowiczf9328632006-09-01 19:49:50 +0200150$(obj)ncb$(SFX): $(obj)ncb.o
wdenkeedcd072004-09-08 22:03:11 +0000151 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
152 $(STRIP) $@
153
Marian Balakowiczf9328632006-09-01 19:49:50 +0200154$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
wdenkefee1702002-07-20 20:14:13 +0000155 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
156 $(STRIP) $@
157
Marian Balakowiczf9328632006-09-01 19:49:50 +0200158$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
wdenkefee1702002-07-20 20:14:13 +0000159 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
160 $(STRIP) $@
161
Marian Balakowiczf9328632006-09-01 19:49:50 +0200162$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
wdenk3e386912003-04-05 00:53:31 +0000163 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
164 $(STRIP) $@
165
Marian Balakowiczf9328632006-09-01 19:49:50 +0200166$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
wdenkef1464c2003-10-08 22:14:02 +0000167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168 $(STRIP) $@
169
Marian Balakowiczf9328632006-09-01 19:49:50 +0200170$(obj)envcrc.o: $(src)envcrc.c
171 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000172
Heiko Schocher566a4942007-06-22 19:11:54 +0200173$(obj)ubsha1.o: $(src)ubsha1.c
174 $(CC) -g $(CFLAGS) -c -o $@ $<
175
Marian Balakowiczf9328632006-09-01 19:49:50 +0200176$(obj)crc32.o: $(obj)crc32.c
177 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000178
Heiko Schocher566a4942007-06-22 19:11:54 +0200179$(obj)sha1.o: $(obj)sha1.c
180 $(CC) -g $(CFLAGS) -c -o $@ $<
181
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100182$(obj)image.o: $(obj)image.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100183 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100184
Marian Balakowiczf9328632006-09-01 19:49:50 +0200185$(obj)mkimage.o: $(src)mkimage.c
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100186 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000187
Marian Balakowiczf9328632006-09-01 19:49:50 +0200188$(obj)ncb.o: $(src)ncb.c
189 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkeedcd072004-09-08 22:03:11 +0000190
Marian Balakowiczf9328632006-09-01 19:49:50 +0200191$(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
192 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000193
Marian Balakowiczf9328632006-09-01 19:49:50 +0200194$(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
195 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenk3e386912003-04-05 00:53:31 +0000196
Marian Balakowiczf9328632006-09-01 19:49:50 +0200197$(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
198 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkef1464c2003-10-08 22:14:02 +0000199
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100200$(obj)fdt.o: $(obj)fdt.c
201 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
202
203$(obj)fdt_ro.o: $(obj)fdt_ro.c
204 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
205
206$(obj)fdt_rw.o: $(obj)fdt_rw.c
207 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
208
209$(obj)fdt_strerror.o: $(obj)fdt_strerror.c
210 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
211
212$(obj)fdt_wip.o: $(obj)fdt_wip.c
213 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
214
wdenkefee1702002-07-20 20:14:13 +0000215subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000216ifeq ($(TOOLSUBDIRS),)
217 @:
218else
wdenkefee1702002-07-20 20:14:13 +0000219 @for dir in $(TOOLSUBDIRS) ; do \
220 $(MAKE) \
221 HOSTOS=$(HOSTOS) \
222 HOSTARCH=$(HOSTARCH) \
223 HOST_CFLAGS="$(HOST_CFLAGS)" \
224 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
225 -C $$dir || exit 1 ; \
226 done
wdenke0ac62d2003-08-17 18:55:18 +0000227endif
228
Marian Balakowiczf9328632006-09-01 19:49:50 +0200229$(obj)environment.c:
230 @rm -f $(obj)environment.c
231 ln -s $(src)../common/environment.c $(obj)environment.c
wdenkefee1702002-07-20 20:14:13 +0000232
Marian Balakowiczf9328632006-09-01 19:49:50 +0200233$(obj)environment.o: $(obj)environment.c
234 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000235
Marian Balakowiczf9328632006-09-01 19:49:50 +0200236$(obj)crc32.c:
237 @rm -f $(obj)crc32.c
238 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
wdenkefee1702002-07-20 20:14:13 +0000239
Heiko Schocher566a4942007-06-22 19:11:54 +0200240$(obj)sha1.c:
241 @rm -f $(obj)sha1.c
242 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
243
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100244$(obj)image.c:
245 @rm -f $(obj)image.c
246 ln -s $(src)../common/image.c $(obj)image.c
247
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100248$(obj)fdt.c: libfdt_internal.h
249 @rm -f $(obj)fdt.c
250 ln -s $(src)../libfdt/fdt.c $(obj)fdt.c
251
252$(obj)fdt_ro.c: libfdt_internal.h
253 @rm -f $(obj)fdt_ro.c
254 ln -s $(src)../libfdt/fdt_ro.c $(obj)fdt_ro.c
255
256$(obj)fdt_rw.c: libfdt_internal.h
257 @rm -f $(obj)fdt_rw.c
258 ln -s $(src)../libfdt/fdt_rw.c $(obj)fdt_rw.c
259
260$(obj)fdt_strerror.c: libfdt_internal.h
261 @rm -f $(obj)fdt_strerror.c
262 ln -s $(src)../libfdt/fdt_strerror.c $(obj)fdt_strerror.c
263
264$(obj)fdt_wip.c: libfdt_internal.h
265 @rm -f $(obj)fdt_wip.c
266 ln -s $(src)../libfdt/fdt_wip.c $(obj)fdt_wip.c
267
268$(obj)libfdt_internal.h:
269 @rm -f $(obj)libfdt_internal.h
270 ln -s $(src)../libfdt/libfdt_internal.h $(obj)libfdt_internal.h
271
Marian Balakowiczf9328632006-09-01 19:49:50 +0200272$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
273 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000274
275#########################################################################
276
Marian Balakowiczf9328632006-09-01 19:49:50 +0200277# defines $(obj).depend target
278include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000279
Marian Balakowiczf9328632006-09-01 19:49:50 +0200280sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000281
282#########################################################################