4ad44cf0b5fae16f5303b5a19dffb7e589637cf6
[fw/openocd] / testing / examples / SAM7X256Test / makefile
1 #
2 #       !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!    
3 #
4 ##############################################################################################
5
6 # On command line:
7 #
8 # make all = Create project
9 #
10 # make clean = Clean project files.
11 #
12 # To rebuild project do "make clean" and "make all".
13 #
14
15 ##############################################################################################
16 # Start of default section
17 #
18
19 TRGT = arm-elf-
20 CC   = $(TRGT)gcc
21 CP   = $(TRGT)objcopy
22 AS   = $(TRGT)gcc -x assembler-with-cpp
23 BIN  = $(CP) -O ihex 
24
25 MCU  = arm7tdmi
26
27 # List all default C defines here, like -D_DEBUG=1
28 DDEFS = 
29
30 # List all default ASM defines here, like -D_DEBUG=1
31 DADEFS = 
32
33 # List all default directories to look for include files here
34 DINCDIR = 
35
36 # List the default directory to look for the libraries here
37 DLIBDIR =
38
39 # List all default libraries here
40 DLIBS = 
41
42 #
43 # End of default section
44 ##############################################################################################
45
46 ##############################################################################################
47 # Start of user section
48 #
49
50 # Define project name here
51 PROJECT = test
52
53 # Define linker script file here
54 LDSCRIPT_RAM = ./prj/sam7x256_ram.ld
55 LDSCRIPT_ROM = ./prj/sam7x256_rom.ld
56
57 # List all user C define here, like -D_DEBUG=1
58 UDEFS = 
59
60 # Define ASM defines here
61 UADEFS = 
62
63 # List C source files here
64 SRC  = ./src/main.c
65
66 # List ASM source files here
67 ASRC = ./src/crt.s
68
69 # List all user directories here
70 UINCDIR = ./inc
71
72 # List the user directory to look for the libraries here
73 ULIBDIR =
74
75 # List all user libraries here
76 ULIBS = 
77
78 # Define optimisation level here
79 OPT = -O0
80
81 #
82 # End of user defines
83 ##############################################################################################
84
85
86 INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
87 LIBDIR  = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
88 DEFS    = $(DDEFS) $(UDEFS)
89 ADEFS   = $(DADEFS) $(UADEFS)
90 OBJS    = $(ASRC:.s=.o) $(SRC:.c=.o)
91 LIBS    = $(DLIBS) $(ULIBS)
92 MCFLAGS = -mcpu=$(MCU)
93
94 ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
95 CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb-interwork -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
96 LDFLAGS_RAM = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT_RAM) -Wl,-Map=$(PROJECT)_ram.map,--cref,--no-warn-mismatch $(LIBDIR)
97 LDFLAGS_ROM = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT_ROM) -Wl,-Map=$(PROJECT)_rom.map,--cref,--no-warn-mismatch $(LIBDIR)
98
99 # Generate dependency information
100 CPFLAGS += -MD -MP -MF .dep/$(@F).d
101
102 #
103 # makefile rules
104 #
105
106 all: RAM ROM
107
108 RAM: $(OBJS) $(PROJECT)_ram.elf $(PROJECT)_ram.hex
109
110 ROM: $(OBJS) $(PROJECT)_rom.elf $(PROJECT)_rom.hex
111
112 %o : %c
113         $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
114
115 %o : %s
116         $(AS) -c $(ASFLAGS) $< -o $@
117
118 %ram.elf: $(OBJS)
119         $(CC) $(OBJS) $(LDFLAGS_RAM) $(LIBS) -o $@
120
121 %rom.elf: $(OBJS)
122         $(CC) $(OBJS) $(LDFLAGS_ROM) $(LIBS) -o $@
123
124 %hex: %elf
125         $(BIN) $< $@
126
127 clean:
128         -rm -f $(OBJS)
129         -rm -f $(PROJECT)_ram.elf
130         -rm -f $(PROJECT)_ram.map
131         -rm -f $(PROJECT)_ram.hex
132         -rm -f $(PROJECT)_rom.elf
133         -rm -f $(PROJECT)_rom.map
134         -rm -f $(PROJECT)_rom.hex
135         -rm -f $(SRC:.c=.c.bak)
136         -rm -f $(SRC:.c=.lst)
137         -rm -f $(ASRC:.s=.s.bak)
138         -rm -f $(ASRC:.s=.lst)
139         -rm -fR .dep
140
141
142 # Include the dependency files, should be the last of the makefile
143 #
144 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
145
146 # *** EOF ***