xref: /openbmc/u-boot/tools/Makefile (revision f69766e4)
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
24BIN_FILES	= img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) ubsha1$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
25
26OBJ_LINKS	= environment.o crc32.o md5.o sha1.o image.o
27OBJ_FILES	= img2srec.o mkimage.o envcrc.o ubsha1.o gen_eth_addr.o bmp_logo.o
28
29ifeq ($(ARCH),mips)
30BIN_FILES	+= inca-swap-bytes$(SFX)
31OBJ_FILES	+= inca-swap-bytes.o
32endif
33
34# Don't build by default
35#ifeq ($(ARCH),ppc)
36#BIN_FILES		+= mpc86x_clk$(SFX)
37#OBJ_FILES	+= mpc86x_clk.o
38#endif
39
40LIBFDT_OBJ_FILES	= fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o
41
42LOGO_H	= $(OBJTREE)/include/bmp_logo.h
43
44ifeq ($(LOGO_BMP),)
45LOGO_BMP= logos/denx.bmp
46endif
47
48#-------------------------------------------------------------------------
49
50HOSTARCH := $(shell uname -m | \
51	sed -e s/i.86/i386/ \
52	    -e s/sun4u/sparc64/ \
53	    -e s/arm.*/arm/ \
54	    -e s/sa110/arm/ \
55	    -e s/powerpc/ppc/ \
56	    -e s/Power\ Macintosh/ppc/ \
57	    -e s/macppc/ppc/)
58
59HOSTOS := $(shell uname -s | tr A-Z a-z | \
60	sed -e 's/\(cygwin\).*/cygwin/')
61
62TOOLSUBDIRS =
63
64#
65# Mac OS X / Darwin's C preprocessor is Apple specific.  It
66# generates numerous errors and warnings.  We want to bypass it
67# and use GNU C's cpp.  To do this we pass the -traditional-cpp
68# option to the compiler.  Note that the -traditional-cpp flag
69# DOES NOT have the same semantics as GNU C's flag, all it does
70# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
71#
72# Apple's linker is similar, thanks to the new 2 stage linking
73# multiple symbol definitions are treated as errors, hence the
74# -multiply_defined suppress option to turn off this error.
75#
76ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
77HOST_CFLAGS = -traditional-cpp -Wall
78HOST_LDFLAGS =-multiply_defined suppress
79HOST_ENVIRO_CFLAGS =
80
81else
82ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
83HOST_CFLAGS = -Wall -pedantic
84HOST_LDFLAGS =
85HOST_ENVIRO_CFLAGS =
86
87#
88# Everyone else
89#
90else
91HOST_CFLAGS = -Wall -pedantic
92HOST_LDFLAGS =
93HOST_ENVIRO_CFLAGS =
94endif
95endif
96
97#
98# Cygwin needs .exe files :-(
99#
100ifeq ($(HOSTOS),cygwin)
101SFX = .exe
102HOST_CFLAGS += -ansi
103else
104SFX =
105endif
106
107#
108# Include this after HOSTOS HOSTARCH check
109# so that we can act intelligently.
110#
111include $(TOPDIR)/config.mk
112
113# now $(obj) is defined
114SRCS	:= $(addprefix $(obj),$(OBJ_LINKS:.o=.c)) $(OBJ_FILES:.o=.c)
115BINS	:= $(addprefix $(obj),$(BIN_FILES))
116
117#
118# Use native tools and options
119#
120CPPFLAGS   = -idirafter $(SRCTREE)/include \
121		-idirafter $(OBJTREE)/include2 \
122		-idirafter $(OBJTREE)/include \
123		-DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
124CFLAGS     = $(HOST_CFLAGS) $(CPPFLAGS) -O
125
126# No -pedantic switch to avoid libfdt compilation warnings
127FIT_CFLAGS = -Wall $(CPPFLAGS) -O
128
129AFLAGS	   = -D__ASSEMBLY__ $(CPPFLAGS)
130CC	   = $(HOSTCC)
131STRIP	   = $(HOSTSTRIP)
132MAKEDEPEND = makedepend
133
134all:	$(obj).depend $(BINS) $(LOGO_H) subdirs
135
136$(obj)envcrc$(SFX):	$(obj)envcrc.o $(obj)crc32.o $(obj)environment.o $(obj)sha1.o
137		$(CC) $(CFLAGS) -o $@ $^
138
139$(obj)ubsha1$(SFX):	$(obj)ubsha1.o $(obj)sha1.o
140		$(CC) $(CFLAGS) -o $@ $^
141
142$(obj)img2srec$(SFX):	$(obj)img2srec.o
143		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
144		$(STRIP) $@
145
146$(obj)mkimage$(SFX):	$(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o $(obj)sha1.o $(LIBFDT_OBJ_FILES)
147		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
148		$(STRIP) $@
149
150$(obj)ncb$(SFX):	$(obj)ncb.o
151		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
152		$(STRIP) $@
153
154$(obj)gen_eth_addr$(SFX):	$(obj)gen_eth_addr.o
155		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
156		$(STRIP) $@
157
158$(obj)bmp_logo$(SFX):	$(obj)bmp_logo.o
159		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
160		$(STRIP) $@
161
162$(obj)inca-swap-bytes$(SFX):	$(obj)inca-swap-bytes.o
163		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
164		$(STRIP) $@
165
166$(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
167		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
168		$(STRIP) $@
169
170$(obj)envcrc.o:	$(src)envcrc.c
171		$(CC) -g $(CFLAGS) -c -o $@ $<
172
173$(obj)ubsha1.o:	$(src)ubsha1.c
174		$(CC) -g $(CFLAGS) -c -o $@ $<
175
176$(obj)crc32.o:	$(obj)crc32.c
177		$(CC) -g $(CFLAGS) -c -o $@ $<
178
179$(obj)md5.o:	$(obj)md5.c
180		$(CC) -g $(CFLAGS) -c -o $@ $<
181
182$(obj)sha1.o:	$(obj)sha1.c
183		$(CC) -g $(CFLAGS) -c -o $@ $<
184
185$(obj)image.o:	$(obj)image.c
186		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
187
188$(obj)mkimage.o:	$(src)mkimage.c
189		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
190
191$(obj)ncb.o:		$(src)ncb.c
192		$(CC) -g $(CFLAGS) -c -o $@ $<
193
194$(obj)gen_eth_addr.o:	$(src)gen_eth_addr.c
195		$(CC) -g $(CFLAGS) -c -o $@ $<
196
197$(obj)inca-swap-bytes.o:	$(src)inca-swap-bytes.c
198		$(CC) -g $(CFLAGS) -c -o $@ $<
199
200$(obj)mpc86x_clk.o:	$(src)mpc86x_clk.c
201		$(CC) -g $(CFLAGS) -c -o $@ $<
202
203$(obj)fdt.o:	$(obj)fdt.c
204		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
205
206$(obj)fdt_ro.o:	$(obj)fdt_ro.c
207		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
208
209$(obj)fdt_rw.o:	$(obj)fdt_rw.c
210		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
211
212$(obj)fdt_strerror.o:	$(obj)fdt_strerror.c
213		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
214
215$(obj)fdt_wip.o:	$(obj)fdt_wip.c
216		$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
217
218subdirs:
219ifeq ($(TOOLSUBDIRS),)
220		@:
221else
222		@for dir in $(TOOLSUBDIRS) ; do \
223		    $(MAKE) \
224			HOSTOS=$(HOSTOS) \
225			HOSTARCH=$(HOSTARCH) \
226			HOST_CFLAGS="$(HOST_CFLAGS)" \
227		   	HOST_LDFLAGS="$(HOST_LDFLAGS)" \
228			-C $$dir || exit 1 ; \
229		done
230endif
231
232$(obj)environment.c:
233		@rm -f $(obj)environment.c
234		ln -s $(src)../common/environment.c $(obj)environment.c
235
236$(obj)environment.o:	$(obj)environment.c
237		$(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<
238
239$(obj)crc32.c:
240		@rm -f $(obj)crc32.c
241		ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
242
243$(obj)md5.c:
244		@rm -f $(obj)md5.c
245		ln -s $(src)../lib_generic/md5.c $(obj)md5.c
246
247$(obj)sha1.c:
248		@rm -f $(obj)sha1.c
249		ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c
250
251$(obj)image.c:
252		@rm -f $(obj)image.c
253		ln -s $(src)../common/image.c $(obj)image.c
254
255$(obj)fdt.c:	libfdt_internal.h
256		@rm -f $(obj)fdt.c
257		ln -s $(src)../libfdt/fdt.c $(obj)fdt.c
258
259$(obj)fdt_ro.c:	libfdt_internal.h
260		@rm -f $(obj)fdt_ro.c
261		ln -s $(src)../libfdt/fdt_ro.c $(obj)fdt_ro.c
262
263$(obj)fdt_rw.c:	libfdt_internal.h
264		@rm -f $(obj)fdt_rw.c
265		ln -s $(src)../libfdt/fdt_rw.c $(obj)fdt_rw.c
266
267$(obj)fdt_strerror.c:	libfdt_internal.h
268		@rm -f $(obj)fdt_strerror.c
269		ln -s $(src)../libfdt/fdt_strerror.c $(obj)fdt_strerror.c
270
271$(obj)fdt_wip.c:	libfdt_internal.h
272		@rm -f $(obj)fdt_wip.c
273		ln -s $(src)../libfdt/fdt_wip.c $(obj)fdt_wip.c
274
275$(obj)libfdt_internal.h:
276		@rm -f $(obj)libfdt_internal.h
277		ln -s $(src)../libfdt/libfdt_internal.h $(obj)libfdt_internal.h
278
279$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
280		$(obj)./bmp_logo $(LOGO_BMP) >$@
281
282#########################################################################
283
284# defines $(obj).depend target
285include $(SRCTREE)/rules.mk
286
287sinclude $(obj).depend
288
289#########################################################################
290