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 ELF += smc91111_eeprom 109 SREC += smc91111_eeprom.srec 110 BIN += smc91111_eeprom.bin 111 endif 112 113 # The following example is pretty 8xx specific... 114 ifeq ($(CPU),mpc8xx) 115 ELF += timer 116 SREC += timer.srec 117 BIN += timer.bin 118 endif 119 120 # The following example is 8260 specific... 121 ifeq ($(CPU),mpc8260) 122 ELF += mem_to_mem_idma2intr 123 SREC += mem_to_mem_idma2intr.srec 124 BIN += mem_to_mem_idma2intr.bin 125 endif 126 127 # Demo for 52xx IRQs 128 ifeq ($(CPU),mpc5xxx) 129 ELF += interrupt 130 SREC += interrupt.srec 131 BIN += interrupt.bin 132 endif 133 134 # Utility for resetting i82559 EEPROM 135 ifeq ($(BOARD),oxc) 136 ELF += eepro100_eeprom 137 SREC += eepro100_eeprom.srec 138 BIN += eepro100_eeprom.bin 139 endif 140 141 ifeq ($(BIG_ENDIAN),y) 142 EX_LDFLAGS += -EB 143 endif 144 145 COBJS := $(SREC:.srec=.o) 146 147 LIB = $(obj)libstubs.a 148 LIBAOBJS= 149 ifeq ($(ARCH),ppc) 150 LIBAOBJS+= $(ARCH)_longjmp.o $(ARCH)_setjmp.o 151 endif 152 ifeq ($(CPU),mpc8xx) 153 LIBAOBJS+= test_burst_lib.o 154 endif 155 LIBCOBJS= stubs.o 156 157 LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS)) 158 159 SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(if $(LIBAOBJS),$(LIBAOBJS:.o=.S)) 160 OBJS := $(addprefix $(obj),$(COBJS)) 161 ELF := $(addprefix $(obj),$(ELF)) 162 BIN := $(addprefix $(obj),$(BIN)) 163 SREC := $(addprefix $(obj),$(SREC)) 164 165 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) 166 clibdir := $(shell dirname `$(CC) $(CFLAGS) -print-file-name=libc.a`) 167 168 CPPFLAGS += -I.. 169 170 all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF) 171 172 ######################################################################### 173 $(LIB): $(obj).depend $(LIBOBJS) 174 $(AR) $(ARFLAGS) $@ $(LIBOBJS) 175 176 $(ELF): 177 $(obj)%: $(obj)%.o $(LIB) 178 $(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \ 179 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \ 180 -L$(gcclibdir) -lgcc 181 182 $(SREC): 183 $(obj)%.srec: $(obj)% 184 $(OBJCOPY) -O srec $< $@ 2>/dev/null 185 186 $(BIN): 187 $(obj)%.bin: $(obj)% 188 $(OBJCOPY) -O binary $< $@ 2>/dev/null 189 190 ######################################################################### 191 192 # defines $(obj).depend target 193 include $(SRCTREE)/rules.mk 194 195 sinclude $(obj).depend 196 197 ######################################################################### 198