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