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
49 ifeq ($(HOSTOS),cygwin)
54 # toolchains targeting win32 generate .exe files
56 ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
63 # Include this after HOSTOS HOSTARCH check
64 # so that we can act intelligently.
66 include $(TOPDIR)/config.mk
68 # Generated executable files
69 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
70 BIN_FILES-y += mkimage$(SFX)
71 BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
72 BIN_FILES-$(CONFIG_ENV_IS_IN_EEPROM) += envcrc$(SFX)
73 BIN_FILES-$(CONFIG_ENV_IS_IN_FLASH) += envcrc$(SFX)
74 BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
75 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
76 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
77 BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
78 BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
79 BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
80 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
82 # Source files which exist outside the tools directory
83 EXT_OBJ_FILES-y += common/env_embedded.o
84 EXT_OBJ_FILES-y += lib_generic/crc32.o
85 EXT_OBJ_FILES-y += lib_generic/md5.o
86 EXT_OBJ_FILES-y += lib_generic/sha1.o
87 EXT_OBJ_FILES-y += common/image.o
89 # Source files located in the tools directory
90 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
91 OBJ_FILES-y += mkimage.o
92 OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
93 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
94 OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
95 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
96 OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
97 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
98 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
99 OBJ_FILES-y += os_support.o
101 # Don't build by default
103 #BIN_FILES-y += mpc86x_clk$(SFX)
104 #OBJ_FILES-y += mpc86x_clk.o
107 # Flattened device tree objects
108 LIBFDT_OBJ_FILES-y += fdt.o
109 LIBFDT_OBJ_FILES-y += fdt_ro.o
110 LIBFDT_OBJ_FILES-y += fdt_rw.o
111 LIBFDT_OBJ_FILES-y += fdt_strerror.o
112 LIBFDT_OBJ_FILES-y += fdt_wip.o
114 # Generated LCD/video logo
115 LOGO_H = $(OBJTREE)/include/bmp_logo.h
116 LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
117 LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
120 LOGO_BMP= logos/denx.bmp
122 ifeq ($(VENDOR),atmel)
123 LOGO_BMP= logos/atmel.bmp
126 # now $(obj) is defined
127 SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
128 SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
129 SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
130 BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
131 LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
134 # Use native tools and options
135 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
137 CPPFLAGS = -idirafter $(SRCTREE)/include \
138 -idirafter $(OBJTREE)/include2 \
139 -idirafter $(OBJTREE)/include \
140 -I $(SRCTREE)/libfdt \
141 -I $(SRCTREE)/tools \
142 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
143 -D__KERNEL_STRICT_NAMES
144 CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
146 # No -pedantic switch to avoid libfdt compilation warnings
147 FIT_CFLAGS = -Wall $(CPPFLAGS) -O
149 AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
152 MAKEDEPEND = makedepend
154 all: $(obj).depend $(BINS) $(LOGO-y) subdirs
156 $(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
157 $(CC) $(CFLAGS) -o $@ $^
159 $(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o $(obj)os_support.o
160 $(CC) $(CFLAGS) -o $@ $^
162 $(obj)img2srec$(SFX): $(obj)img2srec.o
163 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
166 $(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
167 $(obj)sha1.o $(LIBFDT_OBJS) $(obj)os_support.o
168 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
171 $(obj)ncb$(SFX): $(obj)ncb.o
172 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
175 $(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
176 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
179 $(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
180 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
183 $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
184 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
187 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
188 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
191 $(obj)bin2header$(SFX): $(obj)bin2header.o
192 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
195 # Some files complain if compiled with -pedantic, use FIT_CFLAGS
196 $(obj)image.o: $(SRCTREE)/common/image.c
197 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
199 $(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
200 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
202 $(obj)os_support.o: $(SRCTREE)/tools/os_support.c
203 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
205 # Some of the tool objects need to be accessed from outside the tools directory
206 $(obj)%.o: $(SRCTREE)/common/%.c
207 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
209 $(obj)%.o: $(SRCTREE)/lib_generic/%.c
210 $(CC) -g $(CFLAGS) -c -o $@ $<
213 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
216 ifeq ($(TOOLSUBDIRS),)
219 @for dir in $(TOOLSUBDIRS) ; do \
222 HOSTARCH=$(HOSTARCH) \
223 HOST_CFLAGS="$(HOST_CFLAGS)" \
224 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
225 -C $$dir || exit 1 ; \
229 $(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
230 $(obj)./bmp_logo $(LOGO_BMP) >$@
232 #########################################################################
234 # defines $(obj).depend target
235 include $(SRCTREE)/rules.mk
237 sinclude $(obj).depend
239 #########################################################################