Merge branch 'master-sync' of git://git.denx.de/u-boot-arm
[oweals/u-boot.git] / tools / Makefile
1 #
2 # (C) Copyright 2000-2006
3 # 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
24 TOOLSUBDIRS =
25
26 #
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.
33 #
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.
37 #
38
39 HOSTCFLAGS = -Wall
40 HOST_LDFLAGS =
41
42 ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
43 HOSTCFLAGS += -traditional-cpp
44 HOST_LDFLAGS += -multiply_defined suppress
45 else
46 HOSTCFLAGS += -pedantic
47 endif
48
49 ifeq ($(HOSTOS),cygwin)
50 HOSTCFLAGS += -ansi
51 endif
52
53 #
54 # toolchains targeting win32 generate .exe files
55 #
56 ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
57 SFX = .exe
58 else
59 SFX =
60 endif
61
62 #
63 # Include this after HOSTOS HOSTARCH check
64 # so that we can act intelligently.
65 #
66 include $(TOPDIR)/config.mk
67
68 # Generated executable files
69 BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
70 BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
71 BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
72 BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
73 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
74 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
75 BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
76 BIN_FILES-y += mkimage$(SFX)
77 BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
78 BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
79
80 # Source files which exist outside the tools directory
81 EXT_OBJ_FILES-y += common/env_embedded.o
82 EXT_OBJ_FILES-y += common/image.o
83 EXT_OBJ_FILES-y += lib_generic/crc32.o
84 EXT_OBJ_FILES-y += lib_generic/md5.o
85 EXT_OBJ_FILES-y += lib_generic/sha1.o
86
87 # Source files located in the tools directory
88 OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
89 OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
90 OBJ_FILES-y += default_image.o
91 OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
92 OBJ_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc.o
93 OBJ_FILES-y += fit_image.o
94 OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
95 OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
96 OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
97 OBJ_FILES-y += kwbimage.o
98 OBJ_FILES-y += mkimage.o
99 OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
100 OBJ_FILES-y += os_support.o
101 OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
102
103 # Don't build by default
104 #ifeq ($(ARCH),ppc)
105 #BIN_FILES-y += mpc86x_clk$(SFX)
106 #OBJ_FILES-y += mpc86x_clk.o
107 #endif
108
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
115
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)
120
121 ifeq ($(LOGO_BMP),)
122 LOGO_BMP= logos/denx.bmp
123 endif
124 ifeq ($(VENDOR),atmel)
125 LOGO_BMP= logos/atmel.bmp
126 endif
127 ifeq ($(VENDOR),ronetix)
128 LOGO_BMP= logos/ronetix.bmp
129 endif
130
131 # now $(obj) is defined
132 SRCS    += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
133 SRCS    += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
134 SRCS    += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
135 BINS    := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
136 LIBFDT_OBJS     := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
137
138 #
139 # Use native tools and options
140 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
141 #
142 CPPFLAGS   = -idirafter $(SRCTREE)/include \
143                 -idirafter $(OBJTREE)/include2 \
144                 -idirafter $(OBJTREE)/include \
145                 -I $(SRCTREE)/libfdt \
146                 -I $(SRCTREE)/tools \
147                 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
148                 -D__KERNEL_STRICT_NAMES
149 CFLAGS     = $(HOSTCFLAGS) $(CPPFLAGS) -O
150
151 # No -pedantic switch to avoid libfdt compilation warnings
152 FIT_CFLAGS = -Wall $(CPPFLAGS) -O
153
154 AFLAGS     = -D__ASSEMBLY__ $(CPPFLAGS)
155 CC         = $(HOSTCC)
156 STRIP      = $(HOSTSTRIP)
157 MAKEDEPEND = makedepend
158
159 all:    $(obj).depend $(BINS) $(LOGO-y) subdirs
160
161 $(obj)bin2header$(SFX): $(obj)bin2header.o
162         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
163         $(STRIP) $@
164
165 $(obj)bmp_logo$(SFX):   $(obj)bmp_logo.o
166         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
167         $(STRIP) $@
168
169 $(obj)envcrc$(SFX):     $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
170         $(CC) $(CFLAGS) -o $@ $^
171
172 $(obj)gen_eth_addr$(SFX):       $(obj)gen_eth_addr.o
173         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
174         $(STRIP) $@
175
176 $(obj)img2srec$(SFX):   $(obj)img2srec.o
177         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
178         $(STRIP) $@
179
180 $(obj)inca-swap-bytes$(SFX):    $(obj)inca-swap-bytes.o
181         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
182         $(STRIP) $@
183
184 $(obj)mkimage$(SFX):    $(obj)crc32.o \
185                         $(obj)default_image.o \
186                         $(obj)fit_image.o \
187                         $(obj)image.o \
188                         $(obj)kwbimage.o \
189                         $(obj)md5.o \
190                         $(obj)mkimage.o \
191                         $(obj)os_support.o \
192                         $(obj)sha1.o \
193                         $(LIBFDT_OBJS)
194         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
195         $(STRIP) $@
196
197 $(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
198         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
199         $(STRIP) $@
200
201 $(obj)ncb$(SFX):        $(obj)ncb.o
202         $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
203         $(STRIP) $@
204
205 $(obj)ubsha1$(SFX):     $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
206         $(CC) $(CFLAGS) -o $@ $^
207
208 # Some files complain if compiled with -pedantic, use FIT_CFLAGS
209 $(obj)default_image.o: $(SRCTREE)/tools/default_image.c
210         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
211
212 $(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c
213         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
214
215 $(obj)image.o: $(SRCTREE)/common/image.c
216         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
217
218 $(obj)kwbimage.o: $(SRCTREE)/tools/kwbimage.c
219         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
220
221 $(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
222         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
223
224 $(obj)os_support.o: $(SRCTREE)/tools/os_support.c
225         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
226
227 # Some of the tool objects need to be accessed from outside the tools directory
228 $(obj)%.o: $(SRCTREE)/common/%.c
229         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
230
231 $(obj)%.o: $(SRCTREE)/lib_generic/%.c
232         $(CC) -g $(CFLAGS) -c -o $@ $<
233
234 $(LIBFDT_OBJS):
235         $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
236
237 subdirs:
238 ifeq ($(TOOLSUBDIRS),)
239         @:
240 else
241         @for dir in $(TOOLSUBDIRS) ; do \
242             $(MAKE) \
243                 HOSTOS=$(HOSTOS) \
244                 HOSTARCH=$(HOSTARCH) \
245                 HOSTCFLAGS="$(HOSTCFLAGS)" \
246                 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
247                 -C $$dir || exit 1 ; \
248         done
249 endif
250
251 $(LOGO_H):      $(obj)bmp_logo $(LOGO_BMP)
252         $(obj)./bmp_logo $(LOGO_BMP) >$@
253
254 #########################################################################
255
256 # defines $(obj).depend target
257 include $(SRCTREE)/rules.mk
258
259 sinclude $(obj).depend
260
261 #########################################################################