contrib: add GPL license tag on files that miss it
[fw/openocd] / contrib / loaders / flash / at91sam7x / makefile
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 ##############################################################################################
4 # Start of default section
5 #
6
7 TRGT = arm-elf-
8 CC   = $(TRGT)gcc
9 CP   = $(TRGT)objcopy
10 AS   = $(TRGT)gcc -x assembler-with-cpp
11 HEX  = $(CP) -O ihex
12 BIN  = $(CP) -O binary
13 OBJDUMP = $(TRGT)objdump
14
15 MCU  = arm7tdmi
16
17 # List all default C defines here, like -D_DEBUG=1
18 DDEFS =
19
20 # List all default ASM defines here, like -D_DEBUG=1
21 DADEFS =
22
23 # List all default directories to look for include files here
24 DINCDIR =
25
26 # List the default directory to look for the libraries here
27 DLIBDIR =
28
29 # List all default libraries here
30 DLIBS =
31
32 #
33 # End of default section
34 ##############################################################################################
35
36 ##############################################################################################
37 # Start of user section
38 #
39
40 # Define project name here
41 PROJECT = at91sam7x_ocl
42
43 # Define linker script file here
44 LDSCRIPT= at91sam7x_ram.ld
45
46 # List all user C define here, like -D_DEBUG=1
47 UDEFS =
48
49 # Define ASM defines here
50 UADEFS =
51
52 # List C source files here
53 SRC  = main.c dcc.c samflash.c
54
55 # List ASM source files here
56 ASRC = crt.s
57
58 # List all user directories here
59 UINCDIR =
60
61 # List the user directory to look for the libraries here
62 ULIBDIR =
63
64 # List all user libraries here
65 ULIBS =
66
67 # Define optimisation level here
68 OPT = -O2
69
70 #
71 # End of user defines
72 ##############################################################################################
73
74
75 INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
76 LIBDIR  = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
77 DEFS    = $(DDEFS) $(UDEFS)
78 ADEFS   = $(DADEFS) $(UADEFS)
79 OBJS    = $(ASRC:.s=.o) $(SRC:.c=.o)
80 LIBS    = $(DLIBS) $(ULIBS)
81 MCFLAGS = -mcpu=$(MCU)
82
83 ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
84 CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb-interwork -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
85 LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)
86
87 # Generate dependency information
88 #CPFLAGS += -MD -MP -MF .dep/$(@F).d
89
90 #
91 # makefile rules
92 #
93
94 all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).lst
95
96 %o : %c
97         $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
98
99 %o : %s
100         $(AS) -c $(ASFLAGS) $< -o $@
101
102 %elf: $(OBJS)
103         $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
104
105 %hex: %elf
106         $(HEX) $< $@
107
108 %bin: %elf
109         $(BIN) $< $@
110
111 %.lst: %.elf
112         $(OBJDUMP) -h -S $< > $@
113
114 clean:
115         -rm -f $(OBJS)
116         -rm -f $(PROJECT).elf
117         -rm -f $(PROJECT).map
118         -rm -f $(PROJECT).hex
119         -rm -f $(PROJECT).bin
120         -rm -f $(PROJECT).lst
121         -rm -f $(SRC:.c=.c.bak)
122         -rm -f $(SRC:.c=.lst)
123         -rm -f $(ASRC:.s=.s.bak)
124         -rm -f $(ASRC:.s=.lst)
125         -rm -fR .dep
126
127 #
128 # Include the dependency files, should be the last of the makefile
129 #
130 #-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
131
132 # *** EOF ***