blob: cbfca6dcb437bd7928422e53c52069ecac4999b2 [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
Marian Balakowiczf9328632006-09-01 19:49:50 +020040LOGO_H = $(OBJTREE)/include/bmp_logo.h
wdenkefee1702002-07-20 20:14:13 +000041
42ifeq ($(LOGO_BMP),)
43LOGO_BMP= logos/denx.bmp
44endif
45
46#-------------------------------------------------------------------------
47
48HOSTARCH := $(shell uname -m | \
49 sed -e s/i.86/i386/ \
50 -e s/sun4u/sparc64/ \
51 -e s/arm.*/arm/ \
52 -e s/sa110/arm/ \
53 -e s/powerpc/ppc/ \
54 -e s/Power\ Macintosh/ppc/ \
55 -e s/macppc/ppc/)
56
57HOSTOS := $(shell uname -s | tr A-Z a-z | \
58 sed -e 's/\(cygwin\).*/cygwin/')
59
60TOOLSUBDIRS =
61
62#
63# Mac OS X / Darwin's C preprocessor is Apple specific. It
64# generates numerous errors and warnings. We want to bypass it
65# and use GNU C's cpp. To do this we pass the -traditional-cpp
66# option to the compiler. Note that the -traditional-cpp flag
67# DOES NOT have the same semantics as GNU C's flag, all it does
68# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
69#
70# Apple's linker is similar, thanks to the new 2 stage linking
71# multiple symbol definitions are treated as errors, hence the
72# -multiply_defined suppress option to turn off this error.
73#
74ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
wdenkefee1702002-07-20 20:14:13 +000075HOST_CFLAGS = -traditional-cpp -Wall
76HOST_LDFLAGS =-multiply_defined suppress
Aubrey.Li5dfaa502007-05-14 11:47:35 +080077HOST_ENVIRO_CFLAGS =
wdenkefee1702002-07-20 20:14:13 +000078
79else
wdenkefee1702002-07-20 20:14:13 +000080ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
81HOST_CFLAGS = -Wall -pedantic
82HOST_LDFLAGS =
83HOST_ENVIRO_CFLAGS =
84
85#
86# Everyone else
87#
88else
wdenkefee1702002-07-20 20:14:13 +000089HOST_CFLAGS = -Wall -pedantic
90HOST_LDFLAGS =
91HOST_ENVIRO_CFLAGS =
92endif
93endif
94
95#
96# Cygwin needs .exe files :-(
97#
98ifeq ($(HOSTOS),cygwin)
99SFX = .exe
raptorbrino@aim.com883e3922007-12-13 21:23:28 -0500100HOST_CFLAGS += -ansi
wdenkefee1702002-07-20 20:14:13 +0000101else
102SFX =
103endif
104
wdenkefee1702002-07-20 20:14:13 +0000105#
106# Include this after HOSTOS HOSTARCH check
107# so that we can act intelligently.
108#
109include $(TOPDIR)/config.mk
110
Marian Balakowiczf9328632006-09-01 19:49:50 +0200111# now $(obj) is defined
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200112SRCS := $(addprefix $(obj),$(OBJ_LINKS:.o=.c)) $(OBJ_FILES:.o=.c)
Marian Balakowiczf9328632006-09-01 19:49:50 +0200113BINS := $(addprefix $(obj),$(BIN_FILES))
114
wdenkefee1702002-07-20 20:14:13 +0000115#
116# Use native tools and options
117#
Marian Balakowiczf9328632006-09-01 19:49:50 +0200118CPPFLAGS = -idirafter $(SRCTREE)/include \
119 -idirafter $(OBJTREE)/include2 \
120 -idirafter $(OBJTREE)/include \
121 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000122CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
123AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
124CC = $(HOSTCC)
125STRIP = $(HOSTSTRIP)
126MAKEDEPEND = makedepend
127
Marian Balakowiczf9328632006-09-01 19:49:50 +0200128all: $(obj).depend $(BINS) $(LOGO_H) subdirs
wdenkefee1702002-07-20 20:14:13 +0000129
Heiko Schocher566a4942007-06-22 19:11:54 +0200130$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)environment.o $(obj)sha1.o
131 $(CC) $(CFLAGS) -o $@ $^
132
133$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
wdenkefee1702002-07-20 20:14:13 +0000134 $(CC) $(CFLAGS) -o $@ $^
135
Marian Balakowiczf9328632006-09-01 19:49:50 +0200136$(obj)img2srec$(SFX): $(obj)img2srec.o
wdenkefee1702002-07-20 20:14:13 +0000137 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
138 $(STRIP) $@
139
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100140$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o
wdenkefee1702002-07-20 20:14:13 +0000141 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
142 $(STRIP) $@
143
Marian Balakowiczf9328632006-09-01 19:49:50 +0200144$(obj)ncb$(SFX): $(obj)ncb.o
wdenkeedcd072004-09-08 22:03:11 +0000145 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
146 $(STRIP) $@
147
Marian Balakowiczf9328632006-09-01 19:49:50 +0200148$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
wdenkefee1702002-07-20 20:14:13 +0000149 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
150 $(STRIP) $@
151
Marian Balakowiczf9328632006-09-01 19:49:50 +0200152$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
wdenkefee1702002-07-20 20:14:13 +0000153 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
154 $(STRIP) $@
155
Marian Balakowiczf9328632006-09-01 19:49:50 +0200156$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
wdenk3e386912003-04-05 00:53:31 +0000157 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
158 $(STRIP) $@
159
Marian Balakowiczf9328632006-09-01 19:49:50 +0200160$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
wdenkef1464c2003-10-08 22:14:02 +0000161 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
162 $(STRIP) $@
163
Marian Balakowiczf9328632006-09-01 19:49:50 +0200164$(obj)envcrc.o: $(src)envcrc.c
165 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000166
Heiko Schocher566a4942007-06-22 19:11:54 +0200167$(obj)ubsha1.o: $(src)ubsha1.c
168 $(CC) -g $(CFLAGS) -c -o $@ $<
169
Marian Balakowiczf9328632006-09-01 19:49:50 +0200170$(obj)crc32.o: $(obj)crc32.c
171 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000172
Heiko Schocher566a4942007-06-22 19:11:54 +0200173$(obj)sha1.o: $(obj)sha1.c
174 $(CC) -g $(CFLAGS) -c -o $@ $<
175
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100176$(obj)image.o: $(obj)image.c
177 $(CC) -g $(CFLAGS) -c -o $@ $<
178
Marian Balakowiczf9328632006-09-01 19:49:50 +0200179$(obj)mkimage.o: $(src)mkimage.c
180 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000181
Marian Balakowiczf9328632006-09-01 19:49:50 +0200182$(obj)ncb.o: $(src)ncb.c
183 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkeedcd072004-09-08 22:03:11 +0000184
Marian Balakowiczf9328632006-09-01 19:49:50 +0200185$(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
186 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000187
Marian Balakowiczf9328632006-09-01 19:49:50 +0200188$(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
189 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenk3e386912003-04-05 00:53:31 +0000190
Marian Balakowiczf9328632006-09-01 19:49:50 +0200191$(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
192 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkef1464c2003-10-08 22:14:02 +0000193
wdenkefee1702002-07-20 20:14:13 +0000194subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000195ifeq ($(TOOLSUBDIRS),)
196 @:
197else
wdenkefee1702002-07-20 20:14:13 +0000198 @for dir in $(TOOLSUBDIRS) ; do \
199 $(MAKE) \
200 HOSTOS=$(HOSTOS) \
201 HOSTARCH=$(HOSTARCH) \
202 HOST_CFLAGS="$(HOST_CFLAGS)" \
203 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
204 -C $$dir || exit 1 ; \
205 done
wdenke0ac62d2003-08-17 18:55:18 +0000206endif
207
Marian Balakowiczf9328632006-09-01 19:49:50 +0200208$(obj)environment.c:
209 @rm -f $(obj)environment.c
210 ln -s $(src)../common/environment.c $(obj)environment.c
wdenkefee1702002-07-20 20:14:13 +0000211
Marian Balakowiczf9328632006-09-01 19:49:50 +0200212$(obj)environment.o: $(obj)environment.c
213 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000214
Marian Balakowiczf9328632006-09-01 19:49:50 +0200215$(obj)crc32.c:
216 @rm -f $(obj)crc32.c
217 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
wdenkefee1702002-07-20 20:14:13 +0000218
Heiko Schocher566a4942007-06-22 19:11:54 +0200219$(obj)sha1.c:
220 @rm -f $(obj)sha1.c
221 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
222
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100223$(obj)image.c:
224 @rm -f $(obj)image.c
225 ln -s $(src)../common/image.c $(obj)image.c
226
Marian Balakowiczf9328632006-09-01 19:49:50 +0200227$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
228 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000229
230#########################################################################
231
Marian Balakowiczf9328632006-09-01 19:49:50 +0200232# defines $(obj).depend target
233include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000234
Marian Balakowiczf9328632006-09-01 19:49:50 +0200235sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000236
237#########################################################################