blob: 5c764bba9f2c7108e00bcfc6fab08469e066fadf [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
Peter Tyser01d5f1d2009-03-13 18:54:50 -050039HOST_CFLAGS = -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)
43HOST_CFLAGS += -traditional-cpp
44HOST_LDFLAGS += -multiply_defined suppress
wdenkefee1702002-07-20 20:14:13 +000045else
Peter Tyser01d5f1d2009-03-13 18:54:50 -050046HOST_CFLAGS += -pedantic
wdenkefee1702002-07-20 20:14:13 +000047endif
48
Peter Tyserb06976d2009-03-13 18:54:51 -050049ifeq ($(HOSTOS),cygwin)
50HOST_CFLAGS += -ansi
51endif
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
Peter Tyserf3494492009-03-13 18:54:36 -050069BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
Peter Tyser5b3c54d2009-03-13 18:54:34 -050070BIN_FILES-y += mkimage$(SFX)
Peter Tyser82b88f82009-03-13 18:54:39 -050071BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
Mike Frysingerecb7a932009-06-14 21:35:16 -040072BIN_FILES-$(CONFIG_ENV_IS_IN_DATAFLASH) += envcrc$(SFX)
Wolfgang Denk11ddc172009-04-05 00:18:44 +020073BIN_FILES-$(CONFIG_ENV_IS_IN_EEPROM) += envcrc$(SFX)
Wolfgang Denkcec9c2f2009-04-04 16:10:40 +020074BIN_FILES-$(CONFIG_ENV_IS_IN_FLASH) += envcrc$(SFX)
Mike Frysingerecb7a932009-06-14 21:35:16 -040075BIN_FILES-$(CONFIG_ENV_IS_IN_ONENAND) += envcrc$(SFX)
76BIN_FILES-$(CONFIG_ENV_IS_IN_NAND) += envcrc$(SFX)
Wolfgang Denk11ddc172009-04-05 00:18:44 +020077BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
Mike Frysingerecb7a932009-06-14 21:35:16 -040078BIN_FILES-$(CONFIG_ENV_IS_IN_SPI_FLASH) += envcrc$(SFX)
Peter Tyser77b45b82009-03-13 18:54:37 -050079BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
Peter Tyser39168772009-03-13 18:54:40 -050080BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
Peter Tyserce7626d2009-03-13 18:54:35 -050081BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
82BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
Peter Tyser7e897672009-03-13 18:54:38 -050083BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
Peter Tyser0fa9ce32009-03-13 18:54:41 -050084BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(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
88EXT_OBJ_FILES-y += lib_generic/crc32.o
89EXT_OBJ_FILES-y += lib_generic/md5.o
90EXT_OBJ_FILES-y += lib_generic/sha1.o
91EXT_OBJ_FILES-y += common/image.o
Peter Tyser5b3c54d2009-03-13 18:54:34 -050092
93# Source files located in the tools directory
Peter Tyserf3494492009-03-13 18:54:36 -050094OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
Peter Tyser5b3c54d2009-03-13 18:54:34 -050095OBJ_FILES-y += mkimage.o
Peter Tyser82b88f82009-03-13 18:54:39 -050096OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
Peter Tyser77b45b82009-03-13 18:54:37 -050097OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
Peter Tyser39168772009-03-13 18:54:40 -050098OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
Peter Tyserce7626d2009-03-13 18:54:35 -050099OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
100OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
Peter Tyser7e897672009-03-13 18:54:38 -0500101OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
Peter Tyser0fa9ce32009-03-13 18:54:41 -0500102OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
Peter Tyserb06976d2009-03-13 18:54:51 -0500103OBJ_FILES-y += os_support.o
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500104
105# Don't build by default
106#ifeq ($(ARCH),ppc)
107#BIN_FILES-y += mpc86x_clk$(SFX)
108#OBJ_FILES-y += mpc86x_clk.o
109#endif
110
111# Flattened device tree objects
112LIBFDT_OBJ_FILES-y += fdt.o
113LIBFDT_OBJ_FILES-y += fdt_ro.o
114LIBFDT_OBJ_FILES-y += fdt_rw.o
115LIBFDT_OBJ_FILES-y += fdt_strerror.o
116LIBFDT_OBJ_FILES-y += fdt_wip.o
117
Peter Tyserce7626d2009-03-13 18:54:35 -0500118# Generated LCD/video logo
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500119LOGO_H = $(OBJTREE)/include/bmp_logo.h
Peter Tyserce7626d2009-03-13 18:54:35 -0500120LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
121LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500122
123ifeq ($(LOGO_BMP),)
124LOGO_BMP= logos/denx.bmp
125endif
126ifeq ($(VENDOR),atmel)
127LOGO_BMP= logos/atmel.bmp
128endif
Ilko Iliev8b954a92009-04-16 21:30:48 +0200129ifeq ($(VENDOR),ronetix)
130LOGO_BMP= logos/ronetix.bmp
131endif
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500132
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200133# now $(obj) is defined
Peter Tyserbd5605b2009-03-13 18:54:47 -0500134SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
Peter Tyser2ba26342009-03-13 18:54:49 -0500135SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
Peter Tyser08f15572009-03-13 18:54:46 -0500136SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
Wolfgang Denkcec9c2f2009-04-04 16:10:40 +0200137BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
Peter Tyser5b3c54d2009-03-13 18:54:34 -0500138LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200139
wdenkefee1702002-07-20 20:14:13 +0000140#
141# Use native tools and options
Peter Tyserb06976d2009-03-13 18:54:51 -0500142# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
wdenkefee1702002-07-20 20:14:13 +0000143#
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200144CPPFLAGS = -idirafter $(SRCTREE)/include \
145 -idirafter $(OBJTREE)/include2 \
146 -idirafter $(OBJTREE)/include \
Peter Tyser988f02c2009-03-13 18:54:44 -0500147 -I $(SRCTREE)/libfdt \
Peter Tyserd4de1b22009-03-13 18:54:42 -0500148 -I $(SRCTREE)/tools \
Peter Tyserb06976d2009-03-13 18:54:51 -0500149 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
150 -D__KERNEL_STRICT_NAMES
wdenkefee1702002-07-20 20:14:13 +0000151CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100152
153# No -pedantic switch to avoid libfdt compilation warnings
154FIT_CFLAGS = -Wall $(CPPFLAGS) -O
155
wdenkefee1702002-07-20 20:14:13 +0000156AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
157CC = $(HOSTCC)
158STRIP = $(HOSTSTRIP)
159MAKEDEPEND = makedepend
160
Peter Tyserce7626d2009-03-13 18:54:35 -0500161all: $(obj).depend $(BINS) $(LOGO-y) subdirs
wdenkefee1702002-07-20 20:14:13 +0000162
Jean-Christophe PLAGNIOL-VILLARD4436c1e2008-09-10 22:48:01 +0200163$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500164 $(CC) $(CFLAGS) -o $@ $^
wdenkefee1702002-07-20 20:14:13 +0000165
Peter Tyserb06976d2009-03-13 18:54:51 -0500166$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o $(obj)os_support.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500167 $(CC) $(CFLAGS) -o $@ $^
Heiko Schocher633e03a2007-06-22 19:11:54 +0200168
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200169$(obj)img2srec$(SFX): $(obj)img2srec.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500170 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
171 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000172
Peter Tyser2f84bc12009-03-13 18:54:33 -0500173$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
Peter Tyserb06976d2009-03-13 18:54:51 -0500174 $(obj)sha1.o $(LIBFDT_OBJS) $(obj)os_support.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500175 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
176 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000177
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200178$(obj)ncb$(SFX): $(obj)ncb.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500179 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
180 $(STRIP) $@
wdenka0ebde52004-09-08 22:03:11 +0000181
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200182$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500183 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
184 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000185
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200186$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500187 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
188 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000189
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200190$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500191 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
192 $(STRIP) $@
wdenkb02744a2003-04-05 00:53:31 +0000193
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200194$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500195 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
196 $(STRIP) $@
wdenk1ee550e2003-10-08 22:14:02 +0000197
Harald Welte5708dbf2008-07-09 22:30:30 +0800198$(obj)bin2header$(SFX): $(obj)bin2header.o
Peter Tyser2f84bc12009-03-13 18:54:33 -0500199 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
200 $(STRIP) $@
Harald Welte5708dbf2008-07-09 22:30:30 +0800201
Peter Tyserb06976d2009-03-13 18:54:51 -0500202# Some files complain if compiled with -pedantic, use FIT_CFLAGS
Jean-Christophe PLAGNIOL-VILLARD8625a5c2009-04-04 12:46:31 +0200203$(obj)image.o: $(SRCTREE)/common/image.c
Peter Tyser2f84bc12009-03-13 18:54:33 -0500204 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowicz41d71ed2008-01-08 18:14:09 +0100205
Peter Tyser2ba26342009-03-13 18:54:49 -0500206$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
Peter Tyser2f84bc12009-03-13 18:54:33 -0500207 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000208
Peter Tyserb06976d2009-03-13 18:54:51 -0500209$(obj)os_support.o: $(SRCTREE)/tools/os_support.c
210 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
211
Peter Tyser2ba26342009-03-13 18:54:49 -0500212# Some of the tool objects need to be accessed from outside the tools directory
213$(obj)%.o: $(SRCTREE)/common/%.c
Peter Tyser2f84bc12009-03-13 18:54:33 -0500214 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100215
Peter Tyser2ba26342009-03-13 18:54:49 -0500216$(obj)%.o: $(SRCTREE)/lib_generic/%.c
217 $(CC) -g $(CFLAGS) -c -o $@ $<
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100218
Peter Tyser2ba26342009-03-13 18:54:49 -0500219$(LIBFDT_OBJS):
Peter Tyser2f84bc12009-03-13 18:54:33 -0500220 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka61250862008-02-29 16:00:24 +0100221
wdenkefee1702002-07-20 20:14:13 +0000222subdirs:
wdenk5d841732003-08-17 18:55:18 +0000223ifeq ($(TOOLSUBDIRS),)
Peter Tyser2f84bc12009-03-13 18:54:33 -0500224 @:
wdenk5d841732003-08-17 18:55:18 +0000225else
Peter Tyser2f84bc12009-03-13 18:54:33 -0500226 @for dir in $(TOOLSUBDIRS) ; do \
227 $(MAKE) \
228 HOSTOS=$(HOSTOS) \
229 HOSTARCH=$(HOSTARCH) \
230 HOST_CFLAGS="$(HOST_CFLAGS)" \
231 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
232 -C $$dir || exit 1 ; \
233 done
wdenk5d841732003-08-17 18:55:18 +0000234endif
235
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200236$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
Peter Tyser2f84bc12009-03-13 18:54:33 -0500237 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000238
239#########################################################################
240
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200241# defines $(obj).depend target
242include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000243
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200244sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000245
246#########################################################################