blob: b04e3f3044156b1a958be1922d8e20bc4132030f [file] [log] [blame]
wdenkefee1702002-07-20 20:14:13 +00001#
Marian Balakowiczd62379d2006-09-01 19:49:50 +02002# (C) Copyright 2000-2006
wdenkefee1702002-07-20 20:14:13 +00003# 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
wdenkefee1702002-07-20 20:14:13 +000024TOOLSUBDIRS =
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#
wdenkefee1702002-07-20 20:14:13 +000038
Mike Frysinger00d5bfd2009-07-19 15:17:03 -040039HOSTCFLAGS = -Wall
wdenkefee1702002-07-20 20:14:13 +000040HOST_LDFLAGS =
wdenkefee1702002-07-20 20:14:13 +000041
Peter Tyser01d5f1d2009-03-13 18:54:50 -050042ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
Mike Frysinger00d5bfd2009-07-19 15:17:03 -040043HOSTCFLAGS += -traditional-cpp
Peter Tyser01d5f1d2009-03-13 18:54:50 -050044HOST_LDFLAGS += -multiply_defined suppress
wdenkefee1702002-07-20 20:14:13 +000045else
Mike Frysinger00d5bfd2009-07-19 15:17:03 -040046HOSTCFLAGS += -pedantic
wdenkefee1702002-07-20 20:14:13 +000047endif
48
Peter Tyserb06976d2009-03-13 18:54:51 -050049ifeq ($(HOSTOS),cygwin)
Mike Frysinger00d5bfd2009-07-19 15:17:03 -040050HOSTCFLAGS += -ansi
Peter Tyserb06976d2009-03-13 18:54:51 -050051endif
52
wdenkefee1702002-07-20 20:14:13 +000053#
Peter Tyserb06976d2009-03-13 18:54:51 -050054# toolchains targeting win32 generate .exe files
wdenkefee1702002-07-20 20:14:13 +000055#
Peter Tyserb06976d2009-03-13 18:54:51 -050056ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
wdenkefee1702002-07-20 20:14:13 +000057SFX = .exe
58else
59SFX =
60endif
61
wdenkefee1702002-07-20 20:14:13 +000062#
63# Include this after HOSTOS HOSTARCH check
64# so that we can act intelligently.
65#
66include $(TOPDIR)/config.mk
67
Peter Tyser5b3c54d2009-03-13 18:54:34 -050068# Generated executable files
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053069BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
70BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
Peter Tyser82b88f82009-03-13 18:54:39 -050071BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
Wolfgang Denk51420fb2009-10-27 00:03:32 +010072BIN_FILES-$(CONFIG_ENV_IS_IN_DATAFLASH) += envcrc$(SFX)
73BIN_FILES-$(CONFIG_ENV_IS_IN_EEPROM) += envcrc$(SFX)
74BIN_FILES-$(CONFIG_ENV_IS_IN_FLASH) += envcrc$(SFX)
75BIN_FILES-$(CONFIG_ENV_IS_IN_ONENAND) += envcrc$(SFX)
76BIN_FILES-$(CONFIG_ENV_IS_IN_NAND) += envcrc$(SFX)
77BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
78BIN_FILES-$(CONFIG_ENV_IS_IN_SPI_FLASH) += envcrc$(SFX)
Peter Tyser39168772009-03-13 18:54:40 -050079BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053080BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
Peter Tyser7e897672009-03-13 18:54:38 -050081BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053082BIN_FILES-y += mkimage$(SFX)
Peter Tyser0fa9ce32009-03-13 18:54:41 -050083BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053084BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
Peter Tyser5b3c54d2009-03-13 18:54:34 -050085
Peter Tyserbd5605b2009-03-13 18:54:47 -050086# Source files which exist outside the tools directory
87EXT_OBJ_FILES-y += common/env_embedded.o
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053088EXT_OBJ_FILES-y += common/image.o
Peter Tyserbd5605b2009-03-13 18:54:47 -050089EXT_OBJ_FILES-y += lib_generic/crc32.o
90EXT_OBJ_FILES-y += lib_generic/md5.o
91EXT_OBJ_FILES-y += lib_generic/sha1.o
Peter Tyser5b3c54d2009-03-13 18:54:34 -050092
93# Source files located in the tools directory
Peter Tyserce7626d2009-03-13 18:54:35 -050094OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
95OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
Prafulla Wadaskar58bb3c62009-09-07 14:59:06 +053096OBJ_FILES-y += default_image.o
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053097OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
Prafulla Wadaskar58bb3c62009-09-07 14:59:06 +053098OBJ_FILES-y += fit_image.o
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +053099OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
100OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
Peter Tyser7e897672009-03-13 18:54:38 -0500101OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
Prafulla Wadaskar07329412009-09-07 15:05:02 +0530102OBJ_FILES-y += kwbimage.o
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530103OBJ_FILES-y += mkimage.o
Peter Tyser0fa9ce32009-03-13 18:54:41 -0500104OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
Peter Tyserb06976d2009-03-13 18:54:51 -0500105OBJ_FILES-y += os_support.o
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530106OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500107
108# Don't build by default
109#ifeq ($(ARCH),ppc)
110#BIN_FILES-y += mpc86x_clk$(SFX)
111#OBJ_FILES-y += mpc86x_clk.o
112#endif
113
114# Flattened device tree objects
115LIBFDT_OBJ_FILES-y += fdt.o
116LIBFDT_OBJ_FILES-y += fdt_ro.o
117LIBFDT_OBJ_FILES-y += fdt_rw.o
118LIBFDT_OBJ_FILES-y += fdt_strerror.o
119LIBFDT_OBJ_FILES-y += fdt_wip.o
120
Peter Tyserce7626d2009-03-13 18:54:35 -0500121# Generated LCD/video logo
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500122LOGO_H = $(OBJTREE)/include/bmp_logo.h
Peter Tyserce7626d2009-03-13 18:54:35 -0500123LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
124LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500125
126ifeq ($(LOGO_BMP),)
127LOGO_BMP= logos/denx.bmp
128endif
129ifeq ($(VENDOR),atmel)
130LOGO_BMP= logos/atmel.bmp
131endif
Ilko Iliev8b954a92009-04-16 21:30:48 +0200132ifeq ($(VENDOR),ronetix)
133LOGO_BMP= logos/ronetix.bmp
134endif
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500135
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200136# now $(obj) is defined
Peter Tyserbd5605b2009-03-13 18:54:47 -0500137SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
Peter Tyser2ba26342009-03-13 18:54:49 -0500138SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
Peter Tyser08f15572009-03-13 18:54:46 -0500139SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
Wolfgang Denkcec9c2f2009-04-04 16:10:40 +0200140BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500141LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200142
wdenkefee1702002-07-20 20:14:13 +0000143#
144# Use native tools and options
Peter Tyserb06976d2009-03-13 18:54:51 -0500145# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
wdenkefee1702002-07-20 20:14:13 +0000146#
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200147CPPFLAGS = -idirafter $(SRCTREE)/include \
148 -idirafter $(OBJTREE)/include2 \
149 -idirafter $(OBJTREE)/include \
Peter Tyser988f02c2009-03-13 18:54:44 -0500150 -I $(SRCTREE)/libfdt \
Peter Tyserd4de1b22009-03-13 18:54:42 -0500151 -I $(SRCTREE)/tools \
Peter Tyserb06976d2009-03-13 18:54:51 -0500152 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
153 -D__KERNEL_STRICT_NAMES
Mike Frysinger00d5bfd2009-07-19 15:17:03 -0400154CFLAGS = $(HOSTCFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100155
156# No -pedantic switch to avoid libfdt compilation warnings
157FIT_CFLAGS = -Wall $(CPPFLAGS) -O
158
wdenkefee1702002-07-20 20:14:13 +0000159AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
160CC = $(HOSTCC)
161STRIP = $(HOSTSTRIP)
162MAKEDEPEND = makedepend
163
Peter Tyserce7626d2009-03-13 18:54:35 -0500164all: $(obj).depend $(BINS) $(LOGO-y) subdirs
wdenkefee1702002-07-20 20:14:13 +0000165
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530166$(obj)bin2header$(SFX): $(obj)bin2header.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000169
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530170$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500171 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
172 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000173
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530174$(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
175 $(CC) $(CFLAGS) -o $@ $^
wdenka0ebde52004-09-08 22:03:11 +0000176
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200177$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500178 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
179 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000180
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530181$(obj)img2srec$(SFX): $(obj)img2srec.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500182 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
183 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000184
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200185$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500186 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
187 $(STRIP) $@
wdenkb02744a2003-04-05 00:53:31 +0000188
Prafulla Wadaskarfabf3cf2009-08-19 17:36:46 +0530189$(obj)mkimage$(SFX): $(obj)crc32.o \
190 $(obj)default_image.o \
191 $(obj)fit_image.o \
192 $(obj)image.o \
Prafulla Wadaskar07329412009-09-07 15:05:02 +0530193 $(obj)kwbimage.o \
Prafulla Wadaskarfabf3cf2009-08-19 17:36:46 +0530194 $(obj)md5.o \
195 $(obj)mkimage.o \
196 $(obj)os_support.o \
197 $(obj)sha1.o \
198 $(LIBFDT_OBJS)
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530199 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
200 $(STRIP) $@
201
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200202$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500203 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
204 $(STRIP) $@
wdenk1ee550e2003-10-08 22:14:02 +0000205
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530206$(obj)ncb$(SFX): $(obj)ncb.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500207 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
208 $(STRIP) $@
Harald Welte5708dbf2008-07-09 22:30:30 +0800209
Prafulla Wadaskarc4e270f2009-08-10 20:44:06 +0530210$(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
211 $(CC) $(CFLAGS) -o $@ $^
212
Peter Tyserb06976d2009-03-13 18:54:51 -0500213# Some files complain if compiled with -pedantic, use FIT_CFLAGS
Prafulla Wadaskarfabf3cf2009-08-19 17:36:46 +0530214$(obj)default_image.o: $(SRCTREE)/tools/default_image.c
215 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
216
217$(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c
218 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
219
Jean-Christophe PLAGNIOL-VILLARD8625a5c2009-04-04 12:46:31 +0200220$(obj)image.o: $(SRCTREE)/common/image.c
Peter Tyser2f84bc12009-03-13 18:54:33 -0500221 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowicz41d71ed2008-01-08 18:14:09 +0100222
Prafulla Wadaskar07329412009-09-07 15:05:02 +0530223$(obj)kwbimage.o: $(SRCTREE)/tools/kwbimage.c
224 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
225
Peter Tyser2ba26342009-03-13 18:54:49 -0500226$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
Peter Tyser2f84bc12009-03-13 18:54:33 -0500227 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000228
Peter Tyserb06976d2009-03-13 18:54:51 -0500229$(obj)os_support.o: $(SRCTREE)/tools/os_support.c
230 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
231
Peter Tyser2ba26342009-03-13 18:54:49 -0500232# Some of the tool objects need to be accessed from outside the tools directory
233$(obj)%.o: $(SRCTREE)/common/%.c
Peter Tyser2f84bc12009-03-13 18:54:33 -0500234 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100235
Peter Tyser2ba26342009-03-13 18:54:49 -0500236$(obj)%.o: $(SRCTREE)/lib_generic/%.c
237 $(CC) -g $(CFLAGS) -c -o $@ $<
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100238
Peter Tyser2ba26342009-03-13 18:54:49 -0500239$(LIBFDT_OBJS):
Peter Tyser2f84bc12009-03-13 18:54:33 -0500240 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100241
wdenkefee1702002-07-20 20:14:13 +0000242subdirs:
wdenk5d841732003-08-17 18:55:18 +0000243ifeq ($(TOOLSUBDIRS),)
Peter Tyser2f84bc12009-03-13 18:54:33 -0500244 @:
wdenk5d841732003-08-17 18:55:18 +0000245else
Peter Tyser2f84bc12009-03-13 18:54:33 -0500246 @for dir in $(TOOLSUBDIRS) ; do \
247 $(MAKE) \
248 HOSTOS=$(HOSTOS) \
249 HOSTARCH=$(HOSTARCH) \
Mike Frysinger00d5bfd2009-07-19 15:17:03 -0400250 HOSTCFLAGS="$(HOSTCFLAGS)" \
Peter Tyser2f84bc12009-03-13 18:54:33 -0500251 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
252 -C $$dir || exit 1 ; \
253 done
wdenk5d841732003-08-17 18:55:18 +0000254endif
255
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200256$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
Peter Tyser2f84bc12009-03-13 18:54:33 -0500257 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000258
259#########################################################################
260
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200261# defines $(obj).depend target
262include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000263
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200264sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000265
266#########################################################################