blob: d3dcc7d86e05551b39e1aa4319f2bbc34578acee [file] [log] [blame]
wdenkefee1702002-07-20 20:14:13 +00001#
dzu8f713fd2003-08-07 14:20:31 +00002# (C) Copyright 2000-2003
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
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
wdenk3e386912003-04-05 00:53:31 +000028ifeq ($(ARCH),mips)
29BINS += inca-swap-bytes$(SFX)
30OBJS += inca-swap-bytes.o
31endif
32
wdenkef1464c2003-10-08 22:14:02 +000033# Don't build by default
34#ifeq ($(ARCH),ppc)
35#BINS += mpc86x_clk$(SFX)
36#OBJS += mpc86x_clk.o
37#endif
38
wdenkefee1702002-07-20 20:14:13 +000039LOGO_H = $(TOPDIR)/include/bmp_logo.h
40
41ifeq ($(LOGO_BMP),)
42LOGO_BMP= logos/denx.bmp
43endif
44
45#-------------------------------------------------------------------------
46
47HOSTARCH := $(shell uname -m | \
48 sed -e s/i.86/i386/ \
49 -e s/sun4u/sparc64/ \
50 -e s/arm.*/arm/ \
51 -e s/sa110/arm/ \
52 -e s/powerpc/ppc/ \
53 -e s/Power\ Macintosh/ppc/ \
54 -e s/macppc/ppc/)
55
56HOSTOS := $(shell uname -s | tr A-Z a-z | \
57 sed -e 's/\(cygwin\).*/cygwin/')
58
59TOOLSUBDIRS =
60
61#
62# Mac OS X / Darwin's C preprocessor is Apple specific. It
63# generates numerous errors and warnings. We want to bypass it
64# and use GNU C's cpp. To do this we pass the -traditional-cpp
65# option to the compiler. Note that the -traditional-cpp flag
66# DOES NOT have the same semantics as GNU C's flag, all it does
67# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
68#
69# Apple's linker is similar, thanks to the new 2 stage linking
70# multiple symbol definitions are treated as errors, hence the
71# -multiply_defined suppress option to turn off this error.
72#
73ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
wdenkefee1702002-07-20 20:14:13 +000074HOST_CFLAGS = -traditional-cpp -Wall
75HOST_LDFLAGS =-multiply_defined suppress
76HOST_ENVIRO_CFLAGS = -traditional-cpp
77
78else
wdenkefee1702002-07-20 20:14:13 +000079ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
80HOST_CFLAGS = -Wall -pedantic
81HOST_LDFLAGS =
82HOST_ENVIRO_CFLAGS =
83
84#
85# Everyone else
86#
87else
wdenkefee1702002-07-20 20:14:13 +000088HOST_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
wdenkefee1702002-07-20 20:14:13 +0000103#
104# Include this after HOSTOS HOSTARCH check
105# so that we can act intelligently.
106#
107include $(TOPDIR)/config.mk
108
109#
110# Use native tools and options
111#
wdenke1a3f6b2004-09-28 21:39:45 +0000112CPPFLAGS = -idirafter ../include -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
wdenkefee1702002-07-20 20:14:13 +0000113CFLAGS = $(HOST_CFLAGS) $(CPPFLAGS) -O
114AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
115CC = $(HOSTCC)
116STRIP = $(HOSTSTRIP)
117MAKEDEPEND = makedepend
118
119all: .depend $(BINS) $(LOGO_H) subdirs
120
121envcrc$(SFX): envcrc.o crc32.o environment.o
122 $(CC) $(CFLAGS) -o $@ $^
123
124img2srec$(SFX): img2srec.o
125 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
126 $(STRIP) $@
127
128mkimage$(SFX): mkimage.o crc32.o
129 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
130 $(STRIP) $@
131
wdenkeedcd072004-09-08 22:03:11 +0000132ncb$(SFX): ncb.o
133 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
134 $(STRIP) $@
135
wdenkefee1702002-07-20 20:14:13 +0000136gen_eth_addr$(SFX): gen_eth_addr.o
137 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
138 $(STRIP) $@
139
140bmp_logo$(SFX): bmp_logo.o
141 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
142 $(STRIP) $@
143
wdenk3e386912003-04-05 00:53:31 +0000144inca-swap-bytes$(SFX): inca-swap-bytes.o
145 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
146 $(STRIP) $@
147
wdenkef1464c2003-10-08 22:14:02 +0000148mpc86x_clk$(SFX): mpc86x_clk.o
149 $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
150 $(STRIP) $@
151
wdenkefee1702002-07-20 20:14:13 +0000152envcrc.o: envcrc.c
153 $(CC) -g $(CFLAGS) -c $<
154
155crc32.o: crc32.c
156 $(CC) -g $(CFLAGS) -c $<
157
158mkimage.o: mkimage.c
159 $(CC) -g $(CFLAGS) -c $<
160
wdenkeedcd072004-09-08 22:03:11 +0000161ncb.o: ncb.c
162 $(CC) -g $(CFLAGS) -c $<
163
wdenkefee1702002-07-20 20:14:13 +0000164gen_eth_addr.o: gen_eth_addr.c
165 $(CC) -g $(CFLAGS) -c $<
166
wdenk3e386912003-04-05 00:53:31 +0000167inca-swap-bytes.o: inca-swap-bytes.c
168 $(CC) -g $(CFLAGS) -c $<
169
wdenkef1464c2003-10-08 22:14:02 +0000170mpc86x_clk.o: mpc86x_clk.c
171 $(CC) -g $(CFLAGS) -c $<
172
wdenkefee1702002-07-20 20:14:13 +0000173subdirs:
wdenke0ac62d2003-08-17 18:55:18 +0000174ifeq ($(TOOLSUBDIRS),)
175 @:
176else
wdenkefee1702002-07-20 20:14:13 +0000177 @for dir in $(TOOLSUBDIRS) ; do \
178 $(MAKE) \
179 HOSTOS=$(HOSTOS) \
180 HOSTARCH=$(HOSTARCH) \
181 HOST_CFLAGS="$(HOST_CFLAGS)" \
182 HOST_LDFLAGS="$(HOST_LDFLAGS)" \
183 -C $$dir || exit 1 ; \
184 done
wdenke0ac62d2003-08-17 18:55:18 +0000185endif
186
wdenkefee1702002-07-20 20:14:13 +0000187environment.c:
wdenka8c7c702003-12-06 19:49:23 +0000188 @rm -f environment.c
wdenkefee1702002-07-20 20:14:13 +0000189 ln -s ../common/environment.c environment.c
190
191environment.o: environment.c
192 $(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c $<
193
194crc32.c:
wdenka8c7c702003-12-06 19:49:23 +0000195 @rm -f crc32.c
wdenkefee1702002-07-20 20:14:13 +0000196 ln -s ../lib_generic/crc32.c crc32.c
197
198$(LOGO_H): bmp_logo $(LOGO_BMP)
199 ./bmp_logo $(LOGO_BMP) >$@
200
201#########################################################################
202
203.depend: Makefile $(OBJS:.o=.c)
204 $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) $(OBJS:.o=.c) > $@
205
206sinclude .depend
207
208#########################################################################