# # !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!! # ############################################################################################## # # On command line: # # make all = Create project # # make clean = Clean project files. # # To rebuild project do "make clean" and "make all". # ############################################################################################## # Start of default section # HEX2V = /opt/cad/bim/c/hex2v/hex2v_soc TRGT = arm-none-eabi- CC = $(TRGT)gcc CP = $(TRGT)objcopy AS = $(TRGT)gcc -x assembler-with-cpp BIN = $(CP) -O ihex MCU = cortex-m0 # List all default C defines here, like -D_DEBUG=1 DDEFS = # List all default ASM defines here, like -D_DEBUG=1 DADEFS = # List all default directories to look for include files here DINCDIR = # List the default directory to look for the libraries here DLIBDIR = # List all default libraries here DLIBS = # # End of default section ############################################################################################## ############################################################################################## # Start of user section # # # Define project name and Ram/Flash mode here PROJECT = test RUN_FROM_FLASH = 1 # # Define linker script file here # LDSCRIPT = soc.ld FULL_PRJ = code # List all user C define here, like -D_DEBUG=1 UDEFS = # Define ASM defines here UADEFS = # List C source files here SRC = ./code/crt.c \ ./code/vectors_designstart.c \ ./code/main.c # List ASM source files here ASRC = # List all user directories here UINCDIR = ./inc # List the user directory to look for the libraries here ULIBDIR = # List all user libraries here ULIBS = # Define optimisation level here OPT = -O0 # # End of user defines ############################################################################################## INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) ifeq ($(RUN_FROM_FLASH), 0) DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=0 else DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=1 endif ADEFS = $(DADEFS) $(UADEFS) OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) LIBS = $(DLIBS) $(ULIBS) MCFLAGS = -mcpu=$(MCU) ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(<:.s=.lst) $(ADEFS) CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS) LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch $(LIBDIR) # Generate dependency information CPFLAGS += -MD -MP -MF .dep/$(@F).d # # makefile rules # all: $(OBJS) $(FULL_PRJ).elf $(FULL_PRJ).lst $(FULL_PRJ).ihex $(FULL_PRJ).hex code.elf $(FULL_PRJ).vmem %.o : %.c $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ %.o : %.s $(AS) -c $(ASFLAGS) $< -o $@ %.elf: $(OBJS) $(LDSCRIPT) $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ %.ihex: %.elf $(BIN) $< $@ %.lst: %.elf $(TRGT)objdump -d $< > $@ # convert the Intel format hex file to a 4 byte per line format for $readmemh %.hex: %.ihex $(HEX2V) $< 4 > $@ # convert the Intel format hex file to a verilog style memory assignment # note that the .hex file is always updated when a new .vmem file is created %.vmem: %.ihex %.hex $(HEX2V) $< 4 memory > $@ clean: -rm -f $(OBJS) -rm -f $(FULL_PRJ).elf -rm -f $(FULL_PRJ).map -rm -f $(FULL_PRJ).ihex -rm -f $(FULL_PRJ).hex -rm -f $(SRC:.c=.c.bak) -rm -f $(SRC:.c=.lst) -rm -f $(ASRC:.s=.s.bak) -rm -f $(ASRC:.s=.lst) -rm -fR .dep # # Include the dependency files, should be the last of the makefile # -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) # *** EOF ***