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.
42 ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
43 HOST_CFLAGS += -traditional-cpp
44 HOST_LDFLAGS += -multiply_defined suppress
46 HOST_CFLAGS += -pedantic
50 # Cygwin needs .exe files :-(
52 ifeq ($(HOSTOS),cygwin)
60 # Include this after HOSTOS HOSTARCH check
61 # so that we can act intelligently.
63 include $(TOPDIR)/config.mk
65 # Generated executable files
66 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
67 BIN_FILES-y += mkimage$(SFX)
68 BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
69 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
70 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
71 BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
72 BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
73 BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
74 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
76 # Source files which exist outside the tools directory
77 EXT_OBJ_FILES-y += common/env_embedded.o
78 EXT_OBJ_FILES-y += lib_generic/crc32.o
79 EXT_OBJ_FILES-y += lib_generic/md5.o
80 EXT_OBJ_FILES-y += lib_generic/sha1.o
81 EXT_OBJ_FILES-y += common/image.o
83 # Source files located in the tools directory
84 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
85 OBJ_FILES-y += mkimage.o
86 OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
87 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
88 OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
89 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
90 OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
91 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
92 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
94 # Don't build by default
96 #BIN_FILES-y += mpc86x_clk$(SFX)
97 #OBJ_FILES-y += mpc86x_clk.o
100 # Flattened device tree objects
101 LIBFDT_OBJ_FILES-y += fdt.o
102 LIBFDT_OBJ_FILES-y += fdt_ro.o
103 LIBFDT_OBJ_FILES-y += fdt_rw.o
104 LIBFDT_OBJ_FILES-y += fdt_strerror.o
105 LIBFDT_OBJ_FILES-y += fdt_wip.o
107 # Generated LCD/video logo
108 LOGO_H = $(OBJTREE)/include/bmp_logo.h
109 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
110 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
113 LOGO_BMP= logos/denx.bmp
115 ifeq ($(VENDOR),atmel)
116 LOGO_BMP= logos/atmel.bmp
119 # now $(obj) is defined
120 SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
121 SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
122 SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
123 BINS := $(addprefix $(obj),$(BIN_FILES-y))
124 LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
127 # Use native tools and options
129 CPPFLAGS = -idirafter $(SRCTREE)/include \
130 -idirafter $(OBJTREE)/include2 \
131 -idirafter $(OBJTREE)/include \
132 -I $(SRCTREE)/libfdt \
133 -I $(SRCTREE)/tools \
134 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
135 CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
137 # No -pedantic switch to avoid libfdt compilation warnings
138 FIT_CFLAGS = -Wall $(CPPFLAGS) -O
140 AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
143 MAKEDEPEND = makedepend
145 all: $(obj).depend $(BINS) $(LOGO-y) subdirs
147 $(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
148 $(CC) $(CFLAGS) -o $@ $^
150 $(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
151 $(CC) $(CFLAGS) -o $@ $^
153 $(obj)img2srec$(SFX): $(obj)img2srec.o
154 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
157 $(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
158 $(obj)sha1.o $(LIBFDT_OBJS)
159 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
162 $(obj)ncb$(SFX): $(obj)ncb.o
163 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
166 $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
170 $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
171 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
174 $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
175 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
178 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
179 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
182 $(obj)bin2header$(SFX): $(obj)bin2header.o
183 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
186 # image.c and mkimage.c require FIT_CFLAGS instead of standard CFLAGS
187 $(obj)image.o: $(SRCTREE)/tools/image.c
188 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
190 $(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
191 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
193 # Some of the tool objects need to be accessed from outside the tools directory
194 $(obj)%.o: $(SRCTREE)/common/%.c
195 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
197 $(obj)%.o: $(SRCTREE)/lib_generic/%.c
198 $(CC) -g $(CFLAGS) -c -o $@ $<
201 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
204 ifeq ($(TOOLSUBDIRS),)
207 @for dir in $(TOOLSUBDIRS) ; do \
210 HOSTARCH=$(HOSTARCH) \
211 HOST_CFLAGS="$(HOST_CFLAGS)" \
212 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
213 -C $$dir || exit 1 ; \
217 $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
218 $(obj)./bmp_logo $(LOGO_BMP) >$@
220 #########################################################################
222 # defines $(obj).depend target
223 include $(SRCTREE)/rules.mk
225 sinclude $(obj).depend
227 #########################################################################