xref: /openbmc/u-boot/tools/Makefile (revision 8bde7f77)
1#
2# (C) Copyright 2000, 2001
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
24BINS	= img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
25
26OBJS	= environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
27
28ifeq ($(ARCH),mips)
29BINS   += inca-swap-bytes$(SFX)
30OBJS   += inca-swap-bytes.o
31endif
32
33LOGO_H	= $(TOPDIR)/include/bmp_logo.h
34
35ifeq ($(LOGO_BMP),)
36LOGO_BMP= logos/denx.bmp
37endif
38
39#-------------------------------------------------------------------------
40
41HOSTARCH := $(shell uname -m | \
42	sed -e s/i.86/i386/ \
43	    -e s/sun4u/sparc64/ \
44	    -e s/arm.*/arm/ \
45	    -e s/sa110/arm/ \
46	    -e s/powerpc/ppc/ \
47	    -e s/Power\ Macintosh/ppc/ \
48	    -e s/macppc/ppc/)
49
50HOSTOS := $(shell uname -s | tr A-Z a-z | \
51	sed -e 's/\(cygwin\).*/cygwin/')
52
53TOOLSUBDIRS =
54
55#
56# Mac OS X / Darwin's C preprocessor is Apple specific.  It
57# generates numerous errors and warnings.  We want to bypass it
58# and use GNU C's cpp.  To do this we pass the -traditional-cpp
59# option to the compiler.  Note that the -traditional-cpp flag
60# DOES NOT have the same semantics as GNU C's flag, all it does
61# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
62#
63# Apple's linker is similar, thanks to the new 2 stage linking
64# multiple symbol definitions are treated as errors, hence the
65# -multiply_defined suppress option to turn off this error.
66#
67ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
68TOOLSUBDIRS+= gdb
69HOST_CFLAGS = -traditional-cpp -Wall
70HOST_LDFLAGS =-multiply_defined suppress
71HOST_ENVIRO_CFLAGS = -traditional-cpp
72
73else
74#
75# The gdb tools won't build natively on NetBSD since bfd.h (and ansidecl.h)
76# are not installed -- just skip them, they are not really essential.
77#
78ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
79HOST_CFLAGS = -Wall -pedantic
80HOST_LDFLAGS =
81HOST_ENVIRO_CFLAGS =
82
83#
84# Everyone else
85#
86else
87TOOLSUBDIRS+= gdb
88HOST_CFLAGS = -Wall -pedantic
89HOST_LDFLAGS =
90HOST_ENVIRO_CFLAGS =
91endif
92endif
93
94#
95# Cygwin needs .exe files :-(
96#
97ifeq ($(HOSTOS),cygwin)
98SFX = .exe
99else
100SFX =
101endif
102
103
104#
105# Include this after HOSTOS HOSTARCH check
106# so that we can act intelligently.
107#
108include $(TOPDIR)/config.mk
109
110#
111# Use native tools and options
112#
113CPPFLAGS   = -I../include -I.. -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
114CFLAGS     = $(HOST_CFLAGS) $(CPPFLAGS) -O
115AFLAGS	   = -D__ASSEMBLY__ $(CPPFLAGS)
116CC	   = $(HOSTCC)
117STRIP	   = $(HOSTSTRIP)
118MAKEDEPEND = makedepend
119
120all:	.depend $(BINS) $(LOGO_H) subdirs
121
122envcrc$(SFX):	envcrc.o crc32.o environment.o
123		$(CC) $(CFLAGS) -o $@ $^
124
125img2srec$(SFX):	img2srec.o
126		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
127		$(STRIP) $@
128
129mkimage$(SFX):	mkimage.o crc32.o
130		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
131		$(STRIP) $@
132
133gen_eth_addr$(SFX):	gen_eth_addr.o
134		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
135		$(STRIP) $@
136
137bmp_logo$(SFX):	bmp_logo.o
138		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
139		$(STRIP) $@
140
141inca-swap-bytes$(SFX):	inca-swap-bytes.o
142		$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
143		$(STRIP) $@
144
145envcrc.o:	envcrc.c
146		$(CC) -g $(CFLAGS) -c $<
147
148crc32.o:	crc32.c
149		$(CC) -g $(CFLAGS) -c $<
150
151mkimage.o:	mkimage.c
152		$(CC) -g $(CFLAGS) -c $<
153
154gen_eth_addr.o:	gen_eth_addr.c
155		$(CC) -g $(CFLAGS) -c $<
156
157inca-swap-bytes.o:	inca-swap-bytes.c
158		$(CC) -g $(CFLAGS) -c $<
159
160subdirs:
161		@for dir in $(TOOLSUBDIRS) ; do \
162		    $(MAKE) \
163			HOSTOS=$(HOSTOS) \
164			HOSTARCH=$(HOSTARCH) \
165			HOST_CFLAGS="$(HOST_CFLAGS)" \
166		   	HOST_LDFLAGS="$(HOST_LDFLAGS)" \
167			-C $$dir || exit 1 ; \
168		done
169environment.c:
170		ln -s ../common/environment.c environment.c
171
172environment.o: environment.c
173		$(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $<
174
175crc32.c:
176		ln -s ../lib_generic/crc32.c crc32.c
177
178$(LOGO_H):	bmp_logo $(LOGO_BMP)
179		./bmp_logo $(LOGO_BMP) >$@
180
181#########################################################################
182
183.depend:	Makefile $(OBJS:.o=.c)
184		$(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@
185
186sinclude .depend
187
188#########################################################################
189