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
24LOAD_ADDR = 0x1000000
25
26include $(TOPDIR)/config.mk
27
28PROG		= $(obj)multiplier
29IMAGE		= $(obj)multiplier.image
30
31COBJS		= update.o utils.o string.o ctype.o dummy.o
32COBJS_LINKS	= stubs.o
33AOBJS		= ppcstring.o
34AOBJS_LINKS	=
35
36OBJS	:= $(addprefix $(obj),$(COBJS) $(COBJS_LINKS) $(AOBJS) $(AOBJS_LINKS))
37SRCS	:= $(COBJS:.o=.c) $(AOBJS:.o=.S) $(addprefix $(obj), $(COBJS_LINKS:.o:.c) $(AOBJS_LINKS:.o:.S))
38
39CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/board/ACube/Sam460ex
40CFLAGS   += -I$(TOPDIR)/board/ACube/Sam460ex
41AFLAGS   += -I$(TOPDIR)/board/ACube/Sam460ex
42
43DEPS = $(OBJTREE)/u-boot.bin $(OBJTREE)/tools/mkimage
44ifneq ($(DEPS),$(wildcard $(DEPS)))
45$(error "updater: Missing required objects, please run regular build first")
46endif
47
48all:	$(obj).depend $(PROG) $(IMAGE)
49
50#########################################################################
51
52$(obj)%.srec:	%.o $(LIB)
53	$(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $< $(LIB)
54	$(OBJCOPY) -O srec $(<:.o=) $@
55
56$(obj)%.o: %.c
57	$(CC) $(CFLAGS) -c -o $@ $<
58
59$(obj)%.o: %.S
60	$(CC) $(AFLAGS) -c -o $@ $<
61
62$(obj)memio.o: $(obj)memio.S
63	$(CC) $(AFLAGS) -c -o $@ $<
64
65$(obj)memio.S:
66	rm -f $(obj)memio.c
67	ln -s $(SRCTREE)/board/ACube/Sam460ex/memio.S $(obj)memio.S
68
69$(obj)stubs.o: $(obj)stubs.c
70	$(CC) $(CFLAGS) -c -o $@ $<
71
72$(obj)stubs.c:
73	rm -f $(obj)stubs.c
74	ln -s $(SRCTREE)/examples/stubs.c $(obj)stubs.c
75
76#########################################################################
77
78$(obj)multiplier: $(OBJS)
79	$(LD) -g -Ttext $(LOAD_ADDR) -o $(obj)multiplier -e _main $(OBJS)
80	$(OBJCOPY) -O binary $(obj)multiplier $(obj)multiplier.bin
81
82$(obj)multiplier.image: $(obj)multiplier $(OBJTREE)/u-boot.bin
83	cat >/tmp/tempimage $(obj)multiplier.bin junk $(OBJTREE)/u-boot.bin
84	$(OBJTREE)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
85	-e `$(NM) $(obj)multiplier | grep _main | cut --bytes=1-8` \
86	-n "Multiplier" -d /tmp/tempimage $(obj)multiplier.image
87	rm /tmp/tempimage
88	cp $(obj)multiplier.image /boot/multiplier
89
90#########################################################################
91
92# defines $(obj).depend target
93include $(SRCTREE)/rules.mk
94
95sinclude $(obj).depend
96
97#########################################################################
98