1 | ########################################################################## |
---|
2 | # |
---|
3 | # Basic, target/architecture independent makefile for building an |
---|
4 | # application that runs on its own stack. |
---|
5 | # |
---|
6 | # NOTE: |
---|
7 | # This is a template, and may need modification for different sites. |
---|
8 | # |
---|
9 | # The application code in main.c provides a target-independent example |
---|
10 | # of hooking up an application to a target running MicroMonitor. |
---|
11 | # Also, there is a self-induced exception branch (see strace_demo.c) |
---|
12 | # that can be invoked to force the application to take an exception. |
---|
13 | # The purpose of this is to allow the user to then use the monitor's |
---|
14 | # 'strace' command to see the function nesting that occurred prior to |
---|
15 | # the exception. This requires that the symbol table also be on-board. |
---|
16 | # To walk through this example, establish the site-dependent information |
---|
17 | # specified below, then execute "make" to build the image, and then |
---|
18 | # "make dld sym" to install it (and a symbol table) on the target. |
---|
19 | # |
---|
20 | # Site dependent information: |
---|
21 | # Adjust these values based on your system configuration. |
---|
22 | # ARCH: |
---|
23 | # Set ARCH to one of the accepted CPU architectures (i.e. MIPS |
---|
24 | # PPC, ARM, BLACKFIN, COLDFIRE, MICROBLAZE). |
---|
25 | # MONCOMPTR: |
---|
26 | # Set MONCOMPTR to the output of 'echo $MONCOMPTR' on your target. |
---|
27 | # APPRAMBASE: |
---|
28 | # Set APPRAMBASE to the output of 'echo $APPRAMBASE' on your target. |
---|
29 | # TARGET_IP: |
---|
30 | # Set TARGET_IP to the IP address of your target. |
---|
31 | # |
---|
32 | ARCH = ARM |
---|
33 | MONCOMPTR = 12345 |
---|
34 | APPRAMBASE = 12345 |
---|
35 | TARGET_IP = |
---|
36 | |
---|
37 | ########################################################################## |
---|
38 | # |
---|
39 | # There should be no need to change anything below this point if |
---|
40 | # building for the csb350, csb472, csb337 or csb360... |
---|
41 | # |
---|
42 | APPNAME = app |
---|
43 | NM = $(TOOL_PREFIX)-nm |
---|
44 | AR = $(TOOL_PREFIX)-ar |
---|
45 | LD = $(TOOL_PREFIX)-ld |
---|
46 | ASM = $(TOOL_PREFIX)-as |
---|
47 | CC = $(TOOL_PREFIX)-gcc |
---|
48 | COMMON = ../common |
---|
49 | STRIP = $(TOOL_PREFIX)-strip |
---|
50 | OBJCOPY = $(TOOL_PREFIX)-objcopy |
---|
51 | OBJDUMP = $(TOOL_PREFIX)-objdump |
---|
52 | LIBGCC = `$(CC) --print-libgcc-file-name` |
---|
53 | LIBDIR = $(LIBGCC:/libgcc.a=) |
---|
54 | LIBPATH = |
---|
55 | COMMON_CFLAGS = -I $(COMMON) -fno-builtin -Wall |
---|
56 | |
---|
57 | ifeq ($(ARCH),MIPS) |
---|
58 | TOOL_PREFIX := mips-elf |
---|
59 | CFLAGS := $(COMMON_CFLAGS) -G 0 -march=r4600 -mips3 -mno-abicalls \ |
---|
60 | -fno-pic -c -g -O2 -EB -I . |
---|
61 | CRT0 := crt0_mips.o |
---|
62 | CPU := -D CPU_IS_MIPS=1 |
---|
63 | endif |
---|
64 | |
---|
65 | ifeq ($(ARCH),PPC) |
---|
66 | TOOL_PREFIX := ppc-elf |
---|
67 | CFLAGS := $(COMMON_CFLAGS) -mno-sdata -msoft-float \ |
---|
68 | -c -O -g -I. |
---|
69 | CRT0 := crt0_ppc.o |
---|
70 | CPU := -D CPU_IS_PPC=1 |
---|
71 | LIBGCC = `$(CC) --print-file-name=nof/libgcc.a` |
---|
72 | endif |
---|
73 | |
---|
74 | ifeq ($(ARCH),ARM) |
---|
75 | TOOL_PREFIX := arm-elf |
---|
76 | CFLAGS := $(COMMON_CFLAGS) -mcpu=arm1136j-s -fno-omit-frame-pointer \ |
---|
77 | -c -O -g -I. |
---|
78 | CRT0 := crt0_arm.o |
---|
79 | CPU := -D CPU_IS_ARM=1 |
---|
80 | endif |
---|
81 | |
---|
82 | ifeq ($(ARCH),BLACKFIN) |
---|
83 | TOOL_PREFIX := bfin-elf |
---|
84 | CFLAGS := $(COMMON_CFLAGS) -mcsync-anomaly -c -O -g -I. |
---|
85 | CRT0 := crt0_bfin.o |
---|
86 | CPU := -D CPU_IS_BFIN=1 |
---|
87 | endif |
---|
88 | |
---|
89 | ifeq ($(ARCH),MICROBLAZE) |
---|
90 | TOOL_PREFIX := C:/EDK/gnu/microblaze/nt/bin/mb |
---|
91 | LIBPATH := -L C:/xilinx/els_stuff/projects/avnet_spartan3_devkit/microblaze_0/lib |
---|
92 | CFLAGS := $(COMMON_CFLAGS) -mno-xl-soft-mul -c -O -g -I. |
---|
93 | CRT0 := crt0_mb.o |
---|
94 | CPU := -D CPU_IS_MICROBLAZE=1 |
---|
95 | endif |
---|
96 | |
---|
97 | ifeq ($(ARCH),COLDFIRE) |
---|
98 | TOOL_PREFIX := m68k-elf |
---|
99 | CFLAGS := $(COMMON_CFLAGS) -msoft-float -m5200 -g -c -I. |
---|
100 | CRT0 := crt0_cf.o |
---|
101 | CPU := -D CPU_IS_68K=1 |
---|
102 | #LIBGCC = `$(CC) -m5200 --print-libgcc-file-name` |
---|
103 | LIBGCC = /usr/lib/gcc-lib/m68k-elf/3.2/m5200/libgcc.a -L /usr/m68k-elf/lib/m5200 |
---|
104 | endif |
---|
105 | |
---|
106 | OBJS=$(CRT0) main.o strace.o monlib.o |
---|
107 | |
---|
108 | ##### |
---|
109 | # |
---|
110 | # $(APPNAME): |
---|
111 | # Top level target builds the application. |
---|
112 | # |
---|
113 | $(APPNAME): varcheck $(OBJS) makefile |
---|
114 | echo tools: $(TOOL_PREFIX) |
---|
115 | $(LD) -e start -o $(APPNAME) -Ttext $(APPRAMBASE) $(OBJS) $(LIBPATH) -lc $(LIBGCC) |
---|
116 | $(NM) --numeric-sort $(APPNAME) >$(APPNAME).sym |
---|
117 | $(OBJDUMP) --source --disassemble $(APPNAME) > $(APPNAME).dis |
---|
118 | $(STRIP) $(APPNAME) |
---|
119 | |
---|
120 | ##### |
---|
121 | # |
---|
122 | # Variable checks: |
---|
123 | # Verify that the necessary variables have been set on the make |
---|
124 | # command line. |
---|
125 | # |
---|
126 | varcheck: |
---|
127 | ifndef ARCH |
---|
128 | @echo Must specify ARCH=XXX on command line. |
---|
129 | @exit 1 |
---|
130 | endif |
---|
131 | ifndef TOOL_PREFIX |
---|
132 | @echo Invalid ARCH specification. Use PPC, ARM, MIPS, BLACKFIN or COLDFIRE. |
---|
133 | @exit 1 |
---|
134 | endif |
---|
135 | ifeq ($(TOOL_PREFIX),-) |
---|
136 | @echo Invalid ARCH specification. Use PPC, ARM, MIPS, BLACKFIN or COLDFIRE. |
---|
137 | @exit 1 |
---|
138 | endif |
---|
139 | ifndef MONCOMPTR |
---|
140 | @echo Must specify MONCOMPTR=XXX on command line. |
---|
141 | @exit 1 |
---|
142 | endif |
---|
143 | ifndef APPRAMBASE |
---|
144 | @echo Must specify APPRAMBASE=XXX on command line. |
---|
145 | @exit 1 |
---|
146 | endif |
---|
147 | |
---|
148 | targetipcheck: |
---|
149 | ifndef TARGET_IP |
---|
150 | @echo Must specify TARGET_IP=IPADDRESS on command line. |
---|
151 | @exit 1 |
---|
152 | endif |
---|
153 | |
---|
154 | |
---|
155 | ##### |
---|
156 | # |
---|
157 | # Objects: |
---|
158 | # |
---|
159 | crt0_68k.o: $(COMMON)/crt0_68k.S |
---|
160 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_68k.S |
---|
161 | |
---|
162 | crt0_arm.o: $(COMMON)/crt0_arm.S |
---|
163 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_arm.S |
---|
164 | |
---|
165 | crt0_bfin.o: $(COMMON)/crt0_bfin.S |
---|
166 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_bfin.S |
---|
167 | |
---|
168 | crt0_mips.o: $(COMMON)/crt0_mips.S |
---|
169 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_mips.S |
---|
170 | |
---|
171 | crt0_mb.o: $(COMMON)/crt0_mb.S |
---|
172 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_mb.S |
---|
173 | |
---|
174 | crt0_ppc.o: $(COMMON)/crt0_ppc.S |
---|
175 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_ppc.S |
---|
176 | |
---|
177 | crt0_sh2.o: $(COMMON)/crt0_sh2.S |
---|
178 | $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_sh2.S |
---|
179 | |
---|
180 | main.o: main.c |
---|
181 | $(CC) $(CFLAGS) -D MONCOMPTR=$(MONCOMPTR) -o $@ main.c |
---|
182 | |
---|
183 | monlib.o: $(COMMON)/monlib.c |
---|
184 | $(CC) $(CFLAGS) -o $@ $(COMMON)/monlib.c |
---|
185 | |
---|
186 | strace.o: strace.c |
---|
187 | $(CC) $(CFLAGS) $(CPU) -o $@ strace.c |
---|
188 | |
---|
189 | ##### |
---|
190 | # |
---|
191 | # clean: |
---|
192 | # Remove all files created by this make. |
---|
193 | # |
---|
194 | clean: |
---|
195 | rm -f *.o $(APPNAME) $(APPNAME).ezip $(APPNAME).sym $(APPNAME).dis symtbl |
---|
196 | |
---|
197 | ##### |
---|
198 | # |
---|
199 | # sym: |
---|
200 | # Create and download the symbol table file that can be used by uMon |
---|
201 | # with this application... |
---|
202 | # |
---|
203 | sym: targetipcheck |
---|
204 | @if ! test -f $(APPNAME).sym; then echo Must build $(APPNAME) first; exit 1; fi |
---|
205 | monsym -p0x $(APPNAME).sym >symtbl |
---|
206 | ttftp $(TARGET_IP) put symtbl |
---|
207 | |
---|
208 | |
---|
209 | |
---|
210 | ##### |
---|
211 | # |
---|
212 | # dld: |
---|
213 | # Use the ttftp tool (supplied with MicroMonitor) to download the |
---|
214 | # application to the target. |
---|
215 | # |
---|
216 | dld: targetipcheck |
---|
217 | @if ! test -f $(APPNAME); then echo Must build $(APPNAME) first; exit 1; fi |
---|
218 | ttftp $(TARGET_IP) put $(APPNAME) $(APPNAME),E |
---|
219 | |
---|
220 | ##### |
---|
221 | # |
---|
222 | # zdld: |
---|
223 | # Compress the elf file using the 'elf' tool (supplied with MicroMonitor) |
---|
224 | # The output of this is "$(APPNAME).ezip", then download that compressed file. |
---|
225 | # |
---|
226 | zdld: targetipcheck |
---|
227 | @if ! test -f $(APPNAME); then echo Must build $(APPNAME) first; exit 1; fi |
---|
228 | elf -z6 $(APPNAME) |
---|
229 | ttftp $(TARGET_IP) put $(APPNAME).ezip $(APPNAME),Ec |
---|