source: umon/apps/demo/Makefile @ 24d5973

Last change on this file since 24d5973 was 24d5973, checked in by Amar Takhar <amar@…>, on 04/16/15 at 19:29:24

Rename makefile -> Makefile.

  • Property mode set to 100644
File size: 6.1 KB
Line 
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#
32ARCH            = ARM
33MONCOMPTR       = 12345
34APPRAMBASE      = 12345
35TARGET_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#
42APPNAME         = app
43NM                      = $(TOOL_PREFIX)-nm
44AR                      = $(TOOL_PREFIX)-ar
45LD                      = $(TOOL_PREFIX)-ld
46ASM                     = $(TOOL_PREFIX)-as
47CC                      = $(TOOL_PREFIX)-gcc
48COMMON          = ../common
49STRIP           = $(TOOL_PREFIX)-strip
50OBJCOPY         = $(TOOL_PREFIX)-objcopy
51OBJDUMP         = $(TOOL_PREFIX)-objdump
52LIBGCC          = `$(CC) --print-libgcc-file-name`
53LIBDIR          = $(LIBGCC:/libgcc.a=)
54LIBPATH         =
55COMMON_CFLAGS   = -I $(COMMON) -fno-builtin -Wall
56
57ifeq ($(ARCH),MIPS)
58TOOL_PREFIX     := mips-elf
59CFLAGS          := $(COMMON_CFLAGS) -G 0 -march=r4600 -mips3 -mno-abicalls \
60                          -fno-pic -c -g -O2 -EB -I .
61CRT0            := crt0_mips.o
62CPU                     := -D CPU_IS_MIPS=1
63endif
64
65ifeq ($(ARCH),PPC)
66TOOL_PREFIX     := ppc-elf
67CFLAGS          := $(COMMON_CFLAGS) -mno-sdata -msoft-float \
68                           -c -O -g -I.
69CRT0            := crt0_ppc.o
70CPU                     := -D CPU_IS_PPC=1
71LIBGCC          = `$(CC) --print-file-name=nof/libgcc.a`
72endif
73
74ifeq ($(ARCH),ARM)
75TOOL_PREFIX     := arm-elf
76CFLAGS          := $(COMMON_CFLAGS) -mcpu=arm1136j-s -fno-omit-frame-pointer \
77                           -c -O -g -I.
78CRT0            := crt0_arm.o
79CPU                     := -D CPU_IS_ARM=1
80endif
81
82ifeq ($(ARCH),BLACKFIN)
83TOOL_PREFIX     := bfin-elf
84CFLAGS          := $(COMMON_CFLAGS) -mcsync-anomaly -c -O -g -I.
85CRT0            := crt0_bfin.o
86CPU                     := -D CPU_IS_BFIN=1
87endif
88
89ifeq ($(ARCH),MICROBLAZE)
90TOOL_PREFIX     := C:/EDK/gnu/microblaze/nt/bin/mb
91LIBPATH         := -L C:/xilinx/els_stuff/projects/avnet_spartan3_devkit/microblaze_0/lib
92CFLAGS          := $(COMMON_CFLAGS) -mno-xl-soft-mul -c -O -g -I.
93CRT0            := crt0_mb.o
94CPU                     := -D CPU_IS_MICROBLAZE=1
95endif
96
97ifeq ($(ARCH),COLDFIRE)
98TOOL_PREFIX     := m68k-elf
99CFLAGS          := $(COMMON_CFLAGS) -msoft-float -m5200 -g -c -I.
100CRT0            := crt0_cf.o
101CPU                     := -D CPU_IS_68K=1
102#LIBGCC         = `$(CC) -m5200 --print-libgcc-file-name`
103LIBGCC          = /usr/lib/gcc-lib/m68k-elf/3.2/m5200/libgcc.a -L /usr/m68k-elf/lib/m5200
104endif
105
106OBJS=$(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#
126varcheck:
127ifndef ARCH
128        @echo Must specify ARCH=XXX on command line.
129        @exit 1
130endif   
131ifndef TOOL_PREFIX
132        @echo Invalid ARCH specification. Use PPC, ARM, MIPS, BLACKFIN or COLDFIRE.
133        @exit 1
134endif   
135ifeq ($(TOOL_PREFIX),-)
136        @echo Invalid ARCH specification. Use PPC, ARM, MIPS, BLACKFIN or COLDFIRE.
137        @exit 1
138endif   
139ifndef MONCOMPTR
140        @echo Must specify MONCOMPTR=XXX on command line.
141        @exit 1
142endif   
143ifndef APPRAMBASE
144        @echo Must specify APPRAMBASE=XXX on command line.
145        @exit 1
146endif   
147
148targetipcheck:
149ifndef TARGET_IP
150        @echo Must specify TARGET_IP=IPADDRESS on command line.
151        @exit 1
152endif   
153
154
155#####
156#
157# Objects:
158#
159crt0_68k.o: $(COMMON)/crt0_68k.S
160        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_68k.S
161
162crt0_arm.o: $(COMMON)/crt0_arm.S
163        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_arm.S
164
165crt0_bfin.o: $(COMMON)/crt0_bfin.S
166        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_bfin.S
167
168crt0_mips.o: $(COMMON)/crt0_mips.S
169        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_mips.S
170
171crt0_mb.o: $(COMMON)/crt0_mb.S
172        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_mb.S
173
174crt0_ppc.o: $(COMMON)/crt0_ppc.S
175        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_ppc.S
176
177crt0_sh2.o: $(COMMON)/crt0_sh2.S
178        $(CC) $(CFLAGS) -o $@ $(COMMON)/crt0_sh2.S
179
180main.o: main.c
181        $(CC) $(CFLAGS) -D MONCOMPTR=$(MONCOMPTR) -o $@ main.c
182
183monlib.o: $(COMMON)/monlib.c
184        $(CC) $(CFLAGS) -o $@ $(COMMON)/monlib.c
185
186strace.o: strace.c
187        $(CC) $(CFLAGS) $(CPU) -o $@ strace.c
188
189#####
190#
191# clean:
192# Remove all files created by this make.
193#
194clean:
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#
203sym: 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#
216dld: 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#
226zdld: 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
Note: See TracBrowser for help on using the repository browser.