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