Merge branch 'mimc200'
[oweals/u-boot.git] / examples / Makefile
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
24 ifeq ($(ARCH),ppc)
25 LOAD_ADDR = 0x40000
26 endif
27
28 ifeq ($(ARCH),i386)
29 LOAD_ADDR = 0x40000
30 endif
31
32 ifeq ($(ARCH),arm)
33 ifeq ($(BOARD),omap2420h4)
34 LOAD_ADDR = 0x80300000
35 else
36 ifeq ($(CPU),omap3)
37 LOAD_ADDR = 0x80300000
38 else
39 LOAD_ADDR = 0xc100000
40 endif
41 endif
42 endif
43
44 ifeq ($(ARCH),mips)
45 LOAD_ADDR = 0x80200000 -T mips.lds
46 endif
47
48 ifeq ($(ARCH),nios)
49 LOAD_ADDR = 0x00800000 -L $(gcclibdir)/m32 -T nios.lds
50 endif
51
52 ifeq ($(ARCH),nios2)
53 LOAD_ADDR = 0x02000000 -L $(gcclibdir) -T nios2.lds
54 endif
55
56 ifeq ($(ARCH),m68k)
57 LOAD_ADDR = 0x20000  -L $(clibdir)
58 endif
59
60 ifeq ($(ARCH),microblaze)
61 LOAD_ADDR = 0x80F00000
62 endif
63
64 ifeq ($(ARCH),blackfin)
65 LOAD_ADDR = 0x1000
66 endif
67
68 ifeq ($(ARCH),avr32)
69 LOAD_ADDR = 0x00000000
70 endif
71
72 ifeq ($(ARCH),sh)
73 LOAD_ADDR = 0x8C000000
74 ifeq ($(CPU),sh2)
75 BIG_ENDIAN=y
76 endif
77 endif
78
79 ifeq ($(ARCH),sparc)
80 LOAD_ADDR = 0x00000000 -L $(gcclibdir) -T sparc.lds
81 endif
82
83 include $(TOPDIR)/config.mk
84
85 ELF     = hello_world
86 SREC    = hello_world.srec
87 BIN     = hello_world.bin
88
89 ifeq ($(CPU),mpc8xx)
90 ELF     += test_burst
91 SREC    += test_burst.srec
92 BIN     += test_burst.bin
93 endif
94
95 ifeq ($(ARCH),i386)
96 ELF     += 82559_eeprom
97 SREC    += 82559_eeprom.srec
98 BIN     += 82559_eeprom.bin
99 endif
100
101 ifeq ($(ARCH),ppc)
102 ELF     += sched
103 SREC    += sched.srec
104 BIN     += sched.bin
105 endif
106
107 ifeq ($(ARCH),blackfin)
108 BFIN_BIN = smc91111_eeprom smc911x_eeprom
109 ELF     += $(BFIN_BIN)
110 SREC    += $(addsuffix .srec,$(BFIN_BIN))
111 BIN     += $(addsuffix .bin,$(BFIN_BIN))
112 endif
113
114 # The following example is pretty 8xx specific...
115 ifeq ($(CPU),mpc8xx)
116 ELF     += timer
117 SREC    += timer.srec
118 BIN     += timer.bin
119 endif
120
121 # The following example is 8260 specific...
122 ifeq ($(CPU),mpc8260)
123 ELF     += mem_to_mem_idma2intr
124 SREC    += mem_to_mem_idma2intr.srec
125 BIN     += mem_to_mem_idma2intr.bin
126 endif
127
128 # Demo for 52xx IRQs
129 ifeq ($(CPU),mpc5xxx)
130 ELF     += interrupt
131 SREC    += interrupt.srec
132 BIN     += interrupt.bin
133 endif
134
135 # Utility for resetting i82559 EEPROM
136 ifeq ($(BOARD),oxc)
137 ELF     += eepro100_eeprom
138 SREC    += eepro100_eeprom.srec
139 BIN     += eepro100_eeprom.bin
140 endif
141
142 ifeq ($(BIG_ENDIAN),y)
143 EX_LDFLAGS += -EB
144 endif
145
146 COBJS   := $(SREC:.srec=.o)
147
148 LIB     = $(obj)libstubs.a
149 LIBAOBJS=
150 ifeq ($(ARCH),ppc)
151 LIBAOBJS+= $(ARCH)_longjmp.o $(ARCH)_setjmp.o
152 endif
153 ifeq ($(CPU),mpc8xx)
154 LIBAOBJS+= test_burst_lib.o
155 endif
156 LIBCOBJS= stubs.o
157
158 LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
159
160 SRCS    := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(if $(LIBAOBJS),$(LIBAOBJS:.o=.S))
161 OBJS    := $(addprefix $(obj),$(COBJS))
162 ELF     := $(addprefix $(obj),$(ELF))
163 BIN     := $(addprefix $(obj),$(BIN))
164 SREC    := $(addprefix $(obj),$(SREC))
165
166 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
167 clibdir := $(shell dirname `$(CC) $(CFLAGS) -print-file-name=libc.a`)
168
169 CPPFLAGS += -I..
170
171 all:    $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
172
173 #########################################################################
174 $(LIB): $(obj).depend $(LIBOBJS)
175                 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
176
177 $(ELF):
178 $(obj)%:        $(obj)%.o $(LIB)
179                 $(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
180                         -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
181                         -L$(gcclibdir) -lgcc
182
183 $(SREC):
184 $(obj)%.srec:   $(obj)%
185                 $(OBJCOPY) -O srec $< $@ 2>/dev/null
186
187 $(BIN):
188 $(obj)%.bin:    $(obj)%
189                 $(OBJCOPY) -O binary $< $@ 2>/dev/null
190
191 #########################################################################
192
193 # defines $(obj).depend target
194 include $(SRCTREE)/rules.mk
195
196 sinclude $(obj).depend
197
198 #########################################################################