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,
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.
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.
38 ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
39 HOST_CFLAGS = -traditional-cpp -Wall
40 HOST_LDFLAGS =-multiply_defined suppress
44 ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
45 HOST_CFLAGS = -Wall -pedantic
53 HOST_CFLAGS = -Wall -pedantic
60 # Cygwin needs .exe files :-(
62 ifeq ($(HOSTOS),cygwin)
70 # Include this after HOSTOS HOSTARCH check
71 # so that we can act intelligently.
73 include $(TOPDIR)/config.mk
75 # Generated executable files
76 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
77 BIN_FILES-y += mkimage$(SFX)
78 BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
79 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
80 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
81 BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
82 BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
83 BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
84 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
86 # Source files which are symlinked from elsewhere in U-Boot
87 OBJ_LINKS-y += env_embedded.o
88 OBJ_LINKS-y += crc32.o md5.o
90 OBJ_LINKS-y += image.o
92 # Source files located in the tools directory
93 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
94 OBJ_FILES-y += mkimage.o
95 OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
96 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
97 OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
98 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
99 OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
100 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
101 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
103 # Don't build by default
105 #BIN_FILES-y += mpc86x_clk$(SFX)
106 #OBJ_FILES-y += mpc86x_clk.o
109 # Flattened device tree objects
110 LIBFDT_OBJ_FILES-y += fdt.o
111 LIBFDT_OBJ_FILES-y += fdt_ro.o
112 LIBFDT_OBJ_FILES-y += fdt_rw.o
113 LIBFDT_OBJ_FILES-y += fdt_strerror.o
114 LIBFDT_OBJ_FILES-y += fdt_wip.o
116 # Generated LCD/video logo
117 LOGO_H = $(OBJTREE)/include/bmp_logo.h
118 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
119 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
122 LOGO_BMP= logos/denx.bmp
124 ifeq ($(VENDOR),atmel)
125 LOGO_BMP= logos/atmel.bmp
128 # now $(obj) is defined
129 SRCS := $(addprefix $(obj),$(OBJ_LINKS-y:.o=.c)) $(OBJ_FILES-y:.o=.c)
130 BINS := $(addprefix $(obj),$(BIN_FILES-y))
131 LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
134 # Use native tools and options
136 CPPFLAGS = -idirafter $(SRCTREE)/include \
137 -idirafter $(OBJTREE)/include2 \
138 -idirafter $(OBJTREE)/include \
139 -I $(SRCTREE)/tools \
140 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
141 CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
143 # No -pedantic switch to avoid libfdt compilation warnings
144 FIT_CFLAGS = -Wall $(CPPFLAGS) -O
146 AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
149 MAKEDEPEND = makedepend
151 all: $(obj).depend $(BINS) $(LOGO-y) subdirs
153 $(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
154 $(CC) $(CFLAGS) -o $@ $^
156 $(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
157 $(CC) $(CFLAGS) -o $@ $^
159 $(obj)img2srec$(SFX): $(obj)img2srec.o
160 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
163 $(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
164 $(obj)sha1.o $(LIBFDT_OBJS)
165 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168 $(obj)ncb$(SFX): $(obj)ncb.o
169 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
172 $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
173 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
176 $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
177 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
180 $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
181 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
184 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
185 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
188 $(obj)bin2header$(SFX): $(obj)bin2header.o
189 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
192 $(obj)envcrc.o: $(src)envcrc.c
193 $(CC) -g $(CFLAGS) -c -o $@ $<
195 $(obj)ubsha1.o: $(src)ubsha1.c
196 $(CC) -g $(CFLAGS) -c -o $@ $<
198 $(obj)crc32.o: $(obj)crc32.c
199 $(CC) -g $(CFLAGS) -c -o $@ $<
201 $(obj)md5.o: $(obj)md5.c
202 $(CC) -g $(CFLAGS) -c -o $@ $<
204 $(obj)sha1.o: $(obj)sha1.c
205 $(CC) -g $(CFLAGS) -c -o $@ $<
207 $(obj)image.o: $(obj)image.c
208 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
210 $(obj)mkimage.o: $(src)mkimage.c
211 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
213 $(obj)ncb.o: $(src)ncb.c
214 $(CC) -g $(CFLAGS) -c -o $@ $<
216 $(obj)gen_eth_addr.o: $(src)gen_eth_addr.c
217 $(CC) -g $(CFLAGS) -c -o $@ $<
219 $(obj)inca-swap-bytes.o: $(src)inca-swap-bytes.c
220 $(CC) -g $(CFLAGS) -c -o $@ $<
222 $(obj)mpc86x_clk.o: $(src)mpc86x_clk.c
223 $(CC) -g $(CFLAGS) -c -o $@ $<
225 $(obj)fdt.o: $(obj)fdt.c
226 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
228 $(obj)fdt_ro.o: $(obj)fdt_ro.c
229 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
231 $(obj)fdt_rw.o: $(obj)fdt_rw.c
232 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
234 $(obj)fdt_strerror.o: $(obj)fdt_strerror.c
235 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
237 $(obj)fdt_wip.o: $(obj)fdt_wip.c
238 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
241 ifeq ($(TOOLSUBDIRS),)
244 @for dir in $(TOOLSUBDIRS) ; do \
247 HOSTARCH=$(HOSTARCH) \
248 HOST_CFLAGS="$(HOST_CFLAGS)" \
249 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
250 -C $$dir || exit 1 ; \
254 $(obj)env_embedded.c:
255 @rm -f $(obj)env_embedded.c
256 ln -s $(src)../common/env_embedded.c $(obj)env_embedded.c
258 $(obj)env_embedded.o: $(obj)env_embedded.c
259 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
261 $(obj)crc32.c: $(SRCTREE)/include/u-boot/zlib.h
263 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
267 ln -s $(src)../lib_generic/md5.c $(obj)md5.c
271 ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
275 ln -s $(src)../common/image.c $(obj)image.c
277 $(obj)fdt.c: $(obj)libfdt_internal.h
279 ln -s $(src)../libfdt/fdt.c $(obj)fdt.c
281 $(obj)fdt_ro.c: $(obj)libfdt_internal.h
282 @rm -f $(obj)fdt_ro.c
283 ln -s $(src)../libfdt/fdt_ro.c $(obj)fdt_ro.c
285 $(obj)fdt_rw.c: $(obj)libfdt_internal.h
286 @rm -f $(obj)fdt_rw.c
287 ln -s $(src)../libfdt/fdt_rw.c $(obj)fdt_rw.c
289 $(obj)fdt_strerror.c: $(obj)libfdt_internal.h
290 @rm -f $(obj)fdt_strerror.c
291 ln -s $(src)../libfdt/fdt_strerror.c $(obj)fdt_strerror.c
293 $(obj)fdt_wip.c: $(obj)libfdt_internal.h
294 @rm -f $(obj)fdt_wip.c
295 ln -s $(src)../libfdt/fdt_wip.c $(obj)fdt_wip.c
297 $(obj)libfdt_internal.h:
298 @rm -f $(obj)libfdt_internal.h
299 ln -s $(src)../libfdt/libfdt_internal.h $(obj)libfdt_internal.h
301 $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
302 $(obj)./bmp_logo $(LOGO_BMP) >$@
304 #########################################################################
306 # defines $(obj).depend target
307 include $(SRCTREE)/rules.mk
309 sinclude $(obj).depend
311 #########################################################################