2 # (C) Copyright 2000-2006
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 # See file CREDITS for list of people who contributed to this
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.
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.
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,
24 BIN_FILES = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) ubsha1$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
26 OBJ_LINKS = env_embedded.o crc32.o md5.o sha1.o image.o
27 OBJ_FILES = img2srec.o mkimage.o envcrc.o ubsha1.o gen_eth_addr.o bmp_logo.o
30 BIN_FILES += inca-swap-bytes$(SFX)
31 OBJ_FILES += inca-swap-bytes.o
34 # Don't build by default
36 #BIN_FILES += mpc86x_clk$(SFX)
37 #OBJ_FILES += mpc86x_clk.o
40 LIBFDT_OBJ_FILES = $(obj)fdt.o $(obj)fdt_ro.o $(obj)fdt_rw.o $(obj)fdt_strerror.o $(obj)fdt_wip.o
42 LOGO_H = $(OBJTREE)/include/bmp_logo.h
45 LOGO_BMP= logos/denx.bmp
47 ifeq ($(VENDOR),atmel)
48 LOGO_BMP= logos/atmel.bmp
52 #-------------------------------------------------------------------------
54 HOSTARCH := $(shell uname -m | \
60 -e s/Power\ Macintosh/ppc/ \
63 HOSTOS := $(shell uname -s | tr A-Z a-z | \
64 sed -e 's/\(cygwin\).*/cygwin/')
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.
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.
80 ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
81 HOST_CFLAGS = -traditional-cpp -Wall
82 HOST_LDFLAGS =-multiply_defined suppress
86 ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
87 HOST_CFLAGS = -Wall -pedantic
95 HOST_CFLAGS = -Wall -pedantic
102 # Cygwin needs .exe files :-(
104 ifeq ($(HOSTOS),cygwin)
112 # Include this after HOSTOS HOSTARCH check
113 # so that we can act intelligently.
115 include $(TOPDIR)/config.mk
117 # now $(obj) is defined
118 SRCS := $(addprefix $(obj),$(OBJ_LINKS:.o=.c)) $(OBJ_FILES:.o=.c)
119 BINS := $(addprefix $(obj),$(BIN_FILES))
122 # Use native tools and options
124 CPPFLAGS = -idirafter $(SRCTREE)/include \
125 -idirafter $(OBJTREE)/include2 \
126 -idirafter $(OBJTREE)/include \
127 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
128 CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
130 # No -pedantic switch to avoid libfdt compilation warnings
131 FIT_CFLAGS = -Wall $(CPPFLAGS) -O
133 AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
136 MAKEDEPEND = makedepend
138 all: $(obj).depend $(BINS) $(LOGO_H) subdirs
140 $(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
141 $(CC) $(CFLAGS) -o $@ $^
143 $(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
144 $(CC) $(CFLAGS) -o $@ $^
146 $(obj)img2srec$(SFX): $(obj)img2srec.o
147 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
150 $(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o $(obj)sha1.o $(LIBFDT_OBJ_FILES)
151 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
154 $(obj)ncb$(SFX): $(obj)ncb.o
155 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
158 $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
159 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
162 $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
163 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
166 $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
170 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
171 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
174 $(obj)bin2header$(SFX): $(obj)bin2header.o
175 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
178 $(obj)envcrc.o: $(src)envcrc.c
179 $(CC) -g $(CFLAGS) -c -o $@ $<
181 $(obj)ubsha1.o: $(src)ubsha1.c
182 $(CC) -g $(CFLAGS) -c -o $@ $<
184 $(obj)crc32.o: $(obj)crc32.c
185 $(CC) -g $(CFLAGS) -c -o $@ $<
187 $(obj)md5.o: $(obj)md5.c
188 $(CC) -g $(CFLAGS) -c -o $@ $<
190 $(obj)sha1.o: $(obj)sha1.c
191 $(CC) -g $(CFLAGS) -c -o $@ $<
193 $(obj)image.o: $(obj)image.c
194 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
196 $(obj)mkimage.o: $(src)mkimage.c
197 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
199 $(obj)ncb.o: $(src)ncb.c
200 $(CC) -g $(CFLAGS) -c -o $@ $<
202 $(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
203 $(CC) -g $(CFLAGS) -c -o $@ $<
205 $(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
206 $(CC) -g $(CFLAGS) -c -o $@ $<
208 $(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
209 $(CC) -g $(CFLAGS) -c -o $@ $<
211 $(obj)fdt.o: $(obj)fdt.c
212 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
214 $(obj)fdt_ro.o: $(obj)fdt_ro.c
215 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
217 $(obj)fdt_rw.o: $(obj)fdt_rw.c
218 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
220 $(obj)fdt_strerror.o: $(obj)fdt_strerror.c
221 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
223 $(obj)fdt_wip.o: $(obj)fdt_wip.c
224 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
227 ifeq ($(TOOLSUBDIRS),)
230 @for dir in $(TOOLSUBDIRS) ; do \
233 HOSTARCH=$(HOSTARCH) \
234 HOST_CFLAGS="$(HOST_CFLAGS)" \
235 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
236 -C $$dir || exit 1 ; \
240 $(obj)env_embedded.c:
241 @rm -f $(obj)env_embedded.c
242 ln -s $(src)../common/env_embedded.c $(obj)env_embedded.c
244 $(obj)env_embedded.o: $(obj)env_embedded.c
245 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
249 ln -s $(src)../include/zlib.h $@
251 $(obj)crc32.c: $(obj)zlib.h
253 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
257 ln -s $(src)../lib_generic/md5.c $(obj)md5.c
261 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
265 ln -s $(src)../common/image.c $(obj)image.c
266 if [ ! -f $(obj)mkimage.h ] ; then \
267 ln -s $(src)../tools/mkimage.h $(obj)mkimage.h; \
269 if [ ! -f $(obj)fdt_host.h ] ; then \
270 ln -s $(src)../tools/fdt_host.h $(obj)fdt_host.h; \
273 $(obj)fdt.c: $(obj)libfdt_internal.h
275 ln -s $(src)../libfdt/fdt.c $(obj)fdt.c
277 $(obj)fdt_ro.c: $(obj)libfdt_internal.h
278 @rm -f $(obj)fdt_ro.c
279 ln -s $(src)../libfdt/fdt_ro.c $(obj)fdt_ro.c
281 $(obj)fdt_rw.c: $(obj)libfdt_internal.h
282 @rm -f $(obj)fdt_rw.c
283 ln -s $(src)../libfdt/fdt_rw.c $(obj)fdt_rw.c
285 $(obj)fdt_strerror.c: $(obj)libfdt_internal.h
286 @rm -f $(obj)fdt_strerror.c
287 ln -s $(src)../libfdt/fdt_strerror.c $(obj)fdt_strerror.c
289 $(obj)fdt_wip.c: $(obj)libfdt_internal.h
290 @rm -f $(obj)fdt_wip.c
291 ln -s $(src)../libfdt/fdt_wip.c $(obj)fdt_wip.c
293 $(obj)libfdt_internal.h:
294 @rm -f $(obj)libfdt_internal.h
295 ln -s $(src)../libfdt/libfdt_internal.h $(obj)libfdt_internal.h
297 $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
298 $(obj)./bmp_logo $(LOGO_BMP) >$@
300 #########################################################################
302 # defines $(obj).depend target
303 include $(SRCTREE)/rules.mk
305 sinclude $(obj).depend
307 #########################################################################