xref: /openbmc/u-boot/tools/Makefile (revision a3f3897b)
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
24TOOLSUBDIRS =
25
26#
27# toolchains targeting win32 generate .exe files
28#
29ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
30SFX = .exe
31else
32SFX =
33endif
34
35#
36# Include this after HOSTOS HOSTARCH check
37# so that we can act intelligently.
38#
39include $(TOPDIR)/config.mk
40
41# Enable all the config-independent tools
42ifneq ($(HOST_TOOLS_ALL),)
43CONFIG_LCD_LOGO = y
44CONFIG_CMD_NET = y
45CONFIG_INCA_IP = y
46CONFIG_NETCONSOLE = y
47CONFIG_SHA1_CHECK_UB_IMG = y
48endif
49
50# Generated executable files
51BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
52BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
53BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
54BIN_FILES-$(CONFIG_ENV_IS_IN_DATAFLASH) += envcrc$(SFX)
55BIN_FILES-$(CONFIG_ENV_IS_IN_EEPROM) += envcrc$(SFX)
56BIN_FILES-$(CONFIG_ENV_IS_IN_FLASH) += envcrc$(SFX)
57BIN_FILES-$(CONFIG_ENV_IS_IN_ONENAND) += envcrc$(SFX)
58BIN_FILES-$(CONFIG_ENV_IS_IN_NAND) += envcrc$(SFX)
59BIN_FILES-$(CONFIG_ENV_IS_IN_NVRAM) += envcrc$(SFX)
60BIN_FILES-$(CONFIG_ENV_IS_IN_SPI_FLASH) += envcrc$(SFX)
61BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
62BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
63BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
64BIN_FILES-y += mkimage$(SFX)
65BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
66BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
67
68# Source files which exist outside the tools directory
69EXT_OBJ_FILES-y += common/env_embedded.o
70EXT_OBJ_FILES-y += common/image.o
71EXT_OBJ_FILES-y += lib_generic/crc32.o
72EXT_OBJ_FILES-y += lib_generic/md5.o
73EXT_OBJ_FILES-y += lib_generic/sha1.o
74
75# Source files located in the tools directory
76OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
77OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
78NOPED_OBJ_FILES-y += default_image.o
79OBJ_FILES-y += envcrc.o
80NOPED_OBJ_FILES-y += fit_image.o
81OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
82OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
83OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
84NOPED_OBJ_FILES-y += kwbimage.o
85NOPED_OBJ_FILES-y += mkimage.o
86OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
87NOPED_OBJ_FILES-y += os_support.o
88OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
89
90# Don't build by default
91#ifeq ($(ARCH),ppc)
92#BIN_FILES-y += mpc86x_clk$(SFX)
93#OBJ_FILES-y += mpc86x_clk.o
94#endif
95
96# Flattened device tree objects
97LIBFDT_OBJ_FILES-y += fdt.o
98LIBFDT_OBJ_FILES-y += fdt_ro.o
99LIBFDT_OBJ_FILES-y += fdt_rw.o
100LIBFDT_OBJ_FILES-y += fdt_strerror.o
101LIBFDT_OBJ_FILES-y += fdt_wip.o
102
103# Generated LCD/video logo
104LOGO_H = $(OBJTREE)/include/bmp_logo.h
105LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
106LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)
107
108ifeq ($(LOGO_BMP),)
109LOGO_BMP= logos/denx.bmp
110endif
111ifeq ($(VENDOR),atmel)
112LOGO_BMP= logos/atmel.bmp
113endif
114ifeq ($(VENDOR),ronetix)
115LOGO_BMP= logos/ronetix.bmp
116endif
117
118# now $(obj) is defined
119HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
120HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
121HOSTSRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
122BINS	:= $(addprefix $(obj),$(sort $(BIN_FILES-y)))
123LIBFDT_OBJS	:= $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
124
125HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
126NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
127
128#
129# Use native tools and options
130# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
131#
132HOSTCPPFLAGS =	-idirafter $(SRCTREE)/include \
133		-idirafter $(OBJTREE)/include2 \
134		-idirafter $(OBJTREE)/include \
135	        -I $(SRCTREE)/libfdt \
136		-I $(SRCTREE)/tools \
137		-DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
138		-D__KERNEL_STRICT_NAMES
139
140
141all:	$(obj).depend $(BINS) $(LOGO-y) subdirs
142
143$(obj)bin2header$(SFX): $(obj)bin2header.o
144	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
145	$(HOSTSTRIP) $@
146
147$(obj)bmp_logo$(SFX):	$(obj)bmp_logo.o
148	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
149	$(HOSTSTRIP) $@
150
151$(obj)envcrc$(SFX):	$(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
152	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
153
154$(obj)gen_eth_addr$(SFX):	$(obj)gen_eth_addr.o
155	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
156	$(HOSTSTRIP) $@
157
158$(obj)img2srec$(SFX):	$(obj)img2srec.o
159	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
160	$(HOSTSTRIP) $@
161
162$(obj)inca-swap-bytes$(SFX):	$(obj)inca-swap-bytes.o
163	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
164	$(HOSTSTRIP) $@
165
166$(obj)mkimage$(SFX):	$(obj)crc32.o \
167			$(obj)default_image.o \
168			$(obj)fit_image.o \
169			$(obj)image.o \
170			$(obj)kwbimage.o \
171			$(obj)md5.o \
172			$(obj)mkimage.o \
173			$(obj)os_support.o \
174			$(obj)sha1.o \
175			$(LIBFDT_OBJS)
176	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
177	$(HOSTSTRIP) $@
178
179$(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
180	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
181	$(HOSTSTRIP) $@
182
183$(obj)ncb$(SFX):	$(obj)ncb.o
184	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
185	$(HOSTSTRIP) $@
186
187$(obj)ubsha1$(SFX):	$(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
188	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
189
190# Some of the tool objects need to be accessed from outside the tools directory
191$(obj)%.o: $(SRCTREE)/common/%.c
192	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
193
194$(obj)%.o: $(SRCTREE)/lib_generic/%.c
195	$(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
196
197$(LIBFDT_OBJS):
198	$(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
199
200subdirs:
201ifeq ($(TOOLSUBDIRS),)
202	@:
203else
204	@for dir in $(TOOLSUBDIRS) ; do \
205	    $(MAKE) \
206		HOSTOS=$(HOSTOS) \
207		HOSTARCH=$(HOSTARCH) \
208		-C $$dir || exit 1 ; \
209	done
210endif
211
212$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
213	$(obj)./bmp_logo $(LOGO_BMP) >$@
214
215#########################################################################
216
217# defines $(obj).depend target
218include $(SRCTREE)/rules.mk
219
220sinclude $(obj).depend
221
222#########################################################################
223