1 # SPDX-License-Identifier: GPL-2.0-or-later
3 ##############################################################################################
4 # Start of default section
10 AS = $(TRGT)gcc -x assembler-with-cpp
13 OBJDUMP = $(TRGT)objdump
17 # List all default C defines here, like -D_DEBUG=1
20 # List all default ASM defines here, like -D_DEBUG=1
23 # List all default directories to look for include files here
26 # List the default directory to look for the libraries here
29 # List all default libraries here
33 # End of default section
34 ##############################################################################################
36 ##############################################################################################
37 # Start of user section
40 # Define project name here
41 PROJECT = at91sam7x_ocl
43 # Define linker script file here
44 LDSCRIPT= at91sam7x_ram.ld
46 # List all user C define here, like -D_DEBUG=1
49 # Define ASM defines here
52 # List C source files here
53 SRC = main.c dcc.c samflash.c
55 # List ASM source files here
58 # List all user directories here
61 # List the user directory to look for the libraries here
64 # List all user libraries here
67 # Define optimisation level here
72 ##############################################################################################
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)
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)
87 # Generate dependency information
88 #CPFLAGS += -MD -MP -MF .dep/$(@F).d
94 all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).lst
97 $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
100 $(AS) -c $(ASFLAGS) $< -o $@
103 $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
112 $(OBJDUMP) -h -S $< > $@
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)
128 # Include the dependency files, should be the last of the makefile
130 #-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)