blob: 9fe5b1a0f9baec9f8bd592c0c0300238e5a90a96 [file] [log] [blame]
wdenkefee1702002-07-20 20:14:13 +00001#
Marian Balakowiczf9328632006-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#
Peter Tysere50abf62009-03-13 18:54:50 -050038
39HOST_CFLAGS = -Wall
40HOST_LDFLAGS =
41
wdenkefee1702002-07-20 20:14:13 +000042ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
Peter Tysere50abf62009-03-13 18:54:50 -050043HOST_CFLAGS += -traditional-cpp
44HOST_LDFLAGS += -multiply_defined suppress
wdenkefee1702002-07-20 20:14:13 +000045else
Peter Tysere50abf62009-03-13 18:54:50 -050046HOST_CFLAGS += -pedantic
wdenkefee1702002-07-20 20:14:13 +000047endif
48
49#
50# Cygwin needs .exe files :-(
51#
52ifeq ($(HOSTOS),cygwin)
53SFX = .exe
raptorbrino@aim.com883e3922007-12-13 21:23:28 -050054HOST_CFLAGS += -ansi
wdenkefee1702002-07-20 20:14:13 +000055else
56SFX =
57endif
58
wdenkefee1702002-07-20 20:14:13 +000059#
60# Include this after HOSTOS HOSTARCH check
61# so that we can act intelligently.
62#
63include $(TOPDIR)/config.mk
64
Peter Tyseree3584a2009-03-13 18:54:34 -050065# Generated executable files
Peter Tysereeba8612009-03-13 18:54:36 -050066BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
Peter Tyseree3584a2009-03-13 18:54:34 -050067BIN_FILES-y += mkimage$(SFX)
Peter Tyser4d93a0a2009-03-13 18:54:39 -050068BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
Peter Tyser7cd5cbc2009-03-13 18:54:37 -050069BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
Peter Tyser123c48a2009-03-13 18:54:40 -050070BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
Peter Tyser335ffe72009-03-13 18:54:35 -050071BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
72BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
Peter Tysercd26a312009-03-13 18:54:38 -050073BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
Peter Tyser1cd300d2009-03-13 18:54:41 -050074BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
Peter Tyseree3584a2009-03-13 18:54:34 -050075
Peter Tyserfb8b33c2009-03-13 18:54:47 -050076# Source files which exist outside the tools directory
77EXT_OBJ_FILES-y += common/env_embedded.o
78EXT_OBJ_FILES-y += lib_generic/crc32.o
79EXT_OBJ_FILES-y += lib_generic/md5.o
80EXT_OBJ_FILES-y += lib_generic/sha1.o
81EXT_OBJ_FILES-y += common/image.o
Peter Tyseree3584a2009-03-13 18:54:34 -050082
83# Source files located in the tools directory
Peter Tysereeba8612009-03-13 18:54:36 -050084OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
Peter Tyseree3584a2009-03-13 18:54:34 -050085OBJ_FILES-y += mkimage.o
Peter Tyser4d93a0a2009-03-13 18:54:39 -050086OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
Peter Tyser7cd5cbc2009-03-13 18:54:37 -050087OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
Peter Tyser123c48a2009-03-13 18:54:40 -050088OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
Peter Tyser335ffe72009-03-13 18:54:35 -050089OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
90OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
Peter Tysercd26a312009-03-13 18:54:38 -050091OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
Peter Tyser1cd300d2009-03-13 18:54:41 -050092OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
Peter Tyseree3584a2009-03-13 18:54:34 -050093
94# Don't build by default
95#ifeq ($(ARCH),ppc)
96#BIN_FILES-y += mpc86x_clk$(SFX)
97#OBJ_FILES-y += mpc86x_clk.o
98#endif
99
100# Flattened device tree objects
101LIBFDT_OBJ_FILES-y += fdt.o
102LIBFDT_OBJ_FILES-y += fdt_ro.o
103LIBFDT_OBJ_FILES-y += fdt_rw.o
104LIBFDT_OBJ_FILES-y += fdt_strerror.o
105LIBFDT_OBJ_FILES-y += fdt_wip.o
106
Peter Tyser335ffe72009-03-13 18:54:35 -0500107# Generated LCD/video logo
Peter Tyseree3584a2009-03-13 18:54:34 -0500108LOGO_H = $(OBJTREE)/include/bmp_logo.h
Peter Tyser335ffe72009-03-13 18:54:35 -0500109LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
110LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
Peter Tyseree3584a2009-03-13 18:54:34 -0500111
112ifeq ($(LOGO_BMP),)
113LOGO_BMP= logos/denx.bmp
114endif
115ifeq ($(VENDOR),atmel)
116LOGO_BMP= logos/atmel.bmp
117endif
118
Marian Balakowiczf9328632006-09-01 19:49:50 +0200119# now $(obj) is defined
Peter Tyserfb8b33c2009-03-13 18:54:47 -0500120SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
Peter Tyserb0d4d722009-03-13 18:54:49 -0500121SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
Peter Tysereed07332009-03-13 18:54:46 -0500122SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
Peter Tyseree3584a2009-03-13 18:54:34 -0500123BINS := $(addprefix $(obj),$(BIN_FILES-y))
124LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
Marian Balakowiczf9328632006-09-01 19:49:50 +0200125
wdenkefee1702002-07-20 20:14:13 +0000126#
127# Use native tools and options
128#
Marian Balakowiczf9328632006-09-01 19:49:50 +0200129CPPFLAGS = -idirafter $(SRCTREE)/include \
130 -idirafter $(OBJTREE)/include2 \
131 -idirafter $(OBJTREE)/include \
Peter Tyser45d6bdf2009-03-13 18:54:44 -0500132 -I $(SRCTREE)/libfdt \
Peter Tyser40b8d902009-03-13 18:54:42 -0500133 -I $(SRCTREE)/tools \
Marian Balakowiczf9328632006-09-01 19:49:50 +0200134 -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000135CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100136
137# No -pedantic switch to avoid libfdt compilation warnings
138FIT_CFLAGS = -Wall $(CPPFLAGS) -O
139
wdenkefee1702002-07-20 20:14:13 +0000140AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
141CC = $(HOSTCC)
142STRIP = $(HOSTSTRIP)
143MAKEDEPEND = makedepend
144
Peter Tyser335ffe72009-03-13 18:54:35 -0500145all: $(obj).depend $(BINS) $(LOGO-y) subdirs
wdenkefee1702002-07-20 20:14:13 +0000146
Jean-Christophe PLAGNIOL-VILLARD0cf4fd32008-09-10 22:48:01 +0200147$(obj)envcrc$(SFX): $(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500148 $(CC) $(CFLAGS) -o $@ $^
Heiko Schocher566a4942007-06-22 19:11:54 +0200149
150$(obj)ubsha1$(SFX): $(obj)ubsha1.o $(obj)sha1.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500151 $(CC) $(CFLAGS) -o $@ $^
wdenkefee1702002-07-20 20:14:13 +0000152
Marian Balakowiczf9328632006-09-01 19:49:50 +0200153$(obj)img2srec$(SFX): $(obj)img2srec.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500154 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
155 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000156
Peter Tyser21d28e92009-03-13 18:54:33 -0500157$(obj)mkimage$(SFX): $(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
Peter Tyseree3584a2009-03-13 18:54:34 -0500158 $(obj)sha1.o $(LIBFDT_OBJS)
Peter Tyser21d28e92009-03-13 18:54:33 -0500159 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
160 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000161
Marian Balakowiczf9328632006-09-01 19:49:50 +0200162$(obj)ncb$(SFX): $(obj)ncb.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500163 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
164 $(STRIP) $@
wdenkeedcd072004-09-08 22:03:11 +0000165
Marian Balakowiczf9328632006-09-01 19:49:50 +0200166$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500167 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000169
Marian Balakowiczf9328632006-09-01 19:49:50 +0200170$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500171 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
172 $(STRIP) $@
wdenkefee1702002-07-20 20:14:13 +0000173
Marian Balakowiczf9328632006-09-01 19:49:50 +0200174$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500175 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
176 $(STRIP) $@
wdenk3e386912003-04-05 00:53:31 +0000177
Marian Balakowiczf9328632006-09-01 19:49:50 +0200178$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500179 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
180 $(STRIP) $@
wdenkef1464c2003-10-08 22:14:02 +0000181
Harald Welte0a823aa2008-07-09 22:30:30 +0800182$(obj)bin2header$(SFX): $(obj)bin2header.o
Peter Tyser21d28e92009-03-13 18:54:33 -0500183 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
184 $(STRIP) $@
Harald Welte0a823aa2008-07-09 22:30:30 +0800185
Peter Tyserb0d4d722009-03-13 18:54:49 -0500186# image.c and mkimage.c require FIT_CFLAGS instead of standard CFLAGS
187$(obj)image.o: $(SRCTREE)/tools/image.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500188 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Marian Balakowiczb97a2a02008-01-08 18:14:09 +0100189
Peter Tyserb0d4d722009-03-13 18:54:49 -0500190$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500191 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
wdenkefee1702002-07-20 20:14:13 +0000192
Peter Tyserb0d4d722009-03-13 18:54:49 -0500193# 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 $@ $<
196
197$(obj)%.o: $(SRCTREE)/lib_generic/%.c
Peter Tyser21d28e92009-03-13 18:54:33 -0500198 $(CC) -g $(CFLAGS) -c -o $@ $<
wdenkeedcd072004-09-08 22:03:11 +0000199
Peter Tyserb0d4d722009-03-13 18:54:49 -0500200$(LIBFDT_OBJS):
Peter Tyser21d28e92009-03-13 18:54:33 -0500201 $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
Bartlomiej Sieka8cf30802008-02-29 16:00:24 +0100202
wdenkefee1702002-07-20 20:14:13 +0000203subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000204ifeq ($(TOOLSUBDIRS),)
Peter Tyser21d28e92009-03-13 18:54:33 -0500205 @:
wdenke0ac62d2003-08-17 18:55:18 +0000206else
Peter Tyser21d28e92009-03-13 18:54:33 -0500207 @for dir in $(TOOLSUBDIRS) ; do \
208 $(MAKE) \
209 HOSTOS=$(HOSTOS) \
210 HOSTARCH=$(HOSTARCH) \
211 HOST_CFLAGS="$(HOST_CFLAGS)" \
212 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
213 -C $$dir || exit 1 ; \
214 done
wdenke0ac62d2003-08-17 18:55:18 +0000215endif
216
Marian Balakowiczf9328632006-09-01 19:49:50 +0200217$(LOGO_H): $(obj)bmp_logo $(LOGO_BMP)
Peter Tyser21d28e92009-03-13 18:54:33 -0500218 $(obj)./bmp_logo $(LOGO_BMP) >$@
wdenkefee1702002-07-20 20:14:13 +0000219
220#########################################################################
221
Marian Balakowiczf9328632006-09-01 19:49:50 +0200222# defines $(obj).depend target
223include $(SRCTREE)/rules.mk
wdenkefee1702002-07-20 20:14:13 +0000224
Marian Balakowiczf9328632006-09-01 19:49:50 +0200225sinclude $(obj).depend
wdenkefee1702002-07-20 20:14:13 +0000226
227#########################################################################