summaryrefslogtreecommitdiff
path: root/tools/Makefile
blob: b1680adc0c9623ec07b3bea27e4ecb7deb791784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#
# (C) Copyright 2000-2006
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#

TOOLSUBDIRS =

#
# Mac OS X / Darwin's C preprocessor is Apple specific.  It
# generates numerous errors and warnings.  We want to bypass it
# and use GNU C's cpp.  To do this we pass the -traditional-cpp
# option to the compiler.  Note that the -traditional-cpp flag
# DOES NOT have the same semantics as GNU C's flag, all it does
# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
#
# Apple's linker is similar, thanks to the new 2 stage linking
# multiple symbol definitions are treated as errors, hence the
# -multiply_defined suppress option to turn off this error.
#
ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
HOST_CFLAGS = -traditional-cpp -Wall
HOST_LDFLAGS =-multiply_defined suppress
HOST_ENVIRO_CFLAGS =

else
ifeq ($(HOSTOS)-$(HOSTARCH),netbsd-ppc)
HOST_CFLAGS = -Wall -pedantic
HOST_LDFLAGS =
HOST_ENVIRO_CFLAGS =

#
# Everyone else
#
else
HOST_CFLAGS = -Wall -pedantic
HOST_LDFLAGS =
HOST_ENVIRO_CFLAGS =
endif
endif

#
# Cygwin needs .exe files :-(
#
ifeq ($(HOSTOS),cygwin)
SFX = .exe
HOST_CFLAGS += -ansi
else
SFX =
endif

#
# Include this after HOSTOS HOSTARCH check
# so that we can act intelligently.
#
include $(TOPDIR)/config.mk

# Generated executable files
BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
BIN_FILES-y += mkimage$(SFX)
BIN_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc$(SFX)
BIN_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1$(SFX)
BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
BIN_FILES-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
BIN_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo$(SFX)
BIN_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes$(SFX)
BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)

# Source files which are symlinked from elsewhere in U-Boot
OBJ_LINKS-y += env_embedded.o
OBJ_LINKS-y += crc32.o md5.o
OBJ_LINKS-y += sha1.o
OBJ_LINKS-y += image.o

# Source files located in the tools directory
OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
OBJ_FILES-y += mkimage.o
OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o

# Don't build by default
#ifeq ($(ARCH),ppc)
#BIN_FILES-y += mpc86x_clk$(SFX)
#OBJ_FILES-y += mpc86x_clk.o
#endif

# Flattened device tree objects
LIBFDT_OBJ_FILES-y += fdt.o
LIBFDT_OBJ_FILES-y += fdt_ro.o
LIBFDT_OBJ_FILES-y += fdt_rw.o
LIBFDT_OBJ_FILES-y += fdt_strerror.o
LIBFDT_OBJ_FILES-y += fdt_wip.o

# Generated LCD/video logo
LOGO_H = $(OBJTREE)/include/bmp_logo.h
LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H)
LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H)

ifeq ($(LOGO_BMP),)
LOGO_BMP= logos/denx.bmp
endif
ifeq ($(VENDOR),atmel)
LOGO_BMP= logos/atmel.bmp
endif

# now $(obj) is defined
SRCS	:= $(addprefix $(obj),$(OBJ_LINKS-y:.o=.c)) $(OBJ_FILES-y:.o=.c)
SRCS	+= $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
BINS	:= $(addprefix $(obj),$(BIN_FILES-y))
LIBFDT_OBJS	:= $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))

#
# Use native tools and options
#
CPPFLAGS   = -idirafter $(SRCTREE)/include \
		-idirafter $(OBJTREE)/include2 \
		-idirafter $(OBJTREE)/include \
	        -I $(SRCTREE)/libfdt \
		-I $(SRCTREE)/tools \
		-DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC
CFLAGS     = $(HOST_CFLAGS) $(CPPFLAGS) -O

# No -pedantic switch to avoid libfdt compilation warnings
FIT_CFLAGS = -Wall $(CPPFLAGS) -O

AFLAGS	   = -D__ASSEMBLY__ $(CPPFLAGS)
CC	   = $(HOSTCC)
STRIP	   = $(HOSTSTRIP)
MAKEDEPEND = makedepend

all:	$(obj).depend $(BINS) $(LOGO-y) subdirs

$(obj)envcrc$(SFX):	$(obj)envcrc.o $(obj)crc32.o $(obj)env_embedded.o $(obj)sha1.o
	$(CC) $(CFLAGS) -o $@ $^

$(obj)ubsha1$(SFX):	$(obj)ubsha1.o $(obj)sha1.o
	$(CC) $(CFLAGS) -o $@ $^

$(obj)img2srec$(SFX):	$(obj)img2srec.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)mkimage$(SFX):	$(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
			$(obj)sha1.o $(LIBFDT_OBJS)
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)ncb$(SFX):	$(obj)ncb.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)gen_eth_addr$(SFX):	$(obj)gen_eth_addr.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)bmp_logo$(SFX):	$(obj)bmp_logo.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)inca-swap-bytes$(SFX):	$(obj)inca-swap-bytes.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)mpc86x_clk$(SFX):	$(obj)mpc86x_clk.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)bin2header$(SFX): $(obj)bin2header.o
	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
	$(STRIP) $@

$(obj)envcrc.o:	$(src)envcrc.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)ubsha1.o:	$(src)ubsha1.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)crc32.o:	$(obj)crc32.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)md5.o:	$(obj)md5.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)sha1.o:	$(obj)sha1.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)image.o:	$(obj)image.c
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

$(obj)mkimage.o:	$(src)mkimage.c
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

$(obj)ncb.o:		$(src)ncb.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)gen_eth_addr.o:	$(src)gen_eth_addr.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)inca-swap-bytes.o:	$(src)inca-swap-bytes.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)mpc86x_clk.o:	$(src)mpc86x_clk.c
	$(CC) -g $(CFLAGS) -c -o $@ $<

$(obj)fdt.o:
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

$(obj)fdt_ro.o:
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

$(obj)fdt_rw.o:
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

$(obj)fdt_strerror.o:
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

$(obj)fdt_wip.o:
	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<

subdirs:
ifeq ($(TOOLSUBDIRS),)
	@:
else
	@for dir in $(TOOLSUBDIRS) ; do \
	    $(MAKE) \
		HOSTOS=$(HOSTOS) \
		HOSTARCH=$(HOSTARCH) \
		HOST_CFLAGS="$(HOST_CFLAGS)" \
		HOST_LDFLAGS="$(HOST_LDFLAGS)" \
		-C $$dir || exit 1 ; \
	done
endif

$(obj)env_embedded.c:
	@rm -f $(obj)env_embedded.c
	ln -s $(src)../common/env_embedded.c $(obj)env_embedded.c

$(obj)env_embedded.o:	$(obj)env_embedded.c
	$(CC) -g $(HOST_ENVIRO_CFLAGS) $(CPPFLAGS) -c -o $@ $<

$(obj)crc32.c: $(SRCTREE)/include/u-boot/zlib.h
	@rm -f $(obj)crc32.c
	ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c

$(obj)md5.c:
	@rm -f $(obj)md5.c
	ln -s $(src)../lib_generic/md5.c $(obj)md5.c

$(obj)sha1.c:
	@rm -f $(obj)sha1.c
	ln -s $(src)../lib_generic/sha1.c $(obj)sha1.c

$(obj)image.c:
	@rm -f $(obj)image.c
	ln -s $(src)../common/image.c $(obj)image.c

$(LOGO_H):	$(obj)bmp_logo $(LOGO_BMP)
	$(obj)./bmp_logo $(LOGO_BMP) >$@

#########################################################################

# defines $(obj).depend target
include $(SRCTREE)/rules.mk

sinclude $(obj).depend

#########################################################################