#Make file with link time initialization of the stack pointer, MCUCR and watchdog control register. #In order to tell the linker how much SRAM You have use the attached local linker script file. #Modify length of data segment: 'data (rw!x) : ORIGIN = 0x800060, LENGTH = ...' <- 512; 32672 #Modified by Molnar Zoltan, original by Volker Oth. #Special thanks for their help to Jason Kyle address@hidden and Ludovic COURTES
#Good luck using it. ###### define some variables based on the AVR base path in $(AVR) ####### CC=avr-gcc AS=avr-gcc -x assembler-with-cpp RM=rm -f RN=mv BIN=avr-objcopy INCDIR=. LIBDIR=$(AVR)/avr/lib SHELL=$(AVR)/bin/sh.exe ###### output format can be srec, ihex (avrobj is always created) ####### FORMAT=ihex ########################## default mcu type ############################# #put the name of the target mcu here (at90s8515, at90s8535, attiny22, atmega603 etc.) MCU=at90s8515 ####################### default compiler flags ########################## CPFLAGS=-g -Os -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst) ####################### default assembler flags ######################### ASFLAGS=-Wa,-gstabs ########################## default linker flags ######################### LDFLAGS=-Wl,-Map=$(TRG).map,--cref,-Tavr85xx.x #put the name of the target file here (without extension) TRG=test2 #put your C sourcefiles here SRC= $(TRG).c #put additional assembler source file here ASRC= #additional libraries and object files to link LIB= #additional includes to compile INC= ########### you should not need to change the following line ############# #define all project specific object files OBJ = $(ASRC:.s=.o) $(SRC:.c=.o) CPFLAGS += -mmcu=$(MCU) ASFLAGS += -mmcu=$(MCU) LDFLAGS += -mmcu=$(MCU) LDFLAGS += -Xlinker --defsym -Xlinker __init_wdtcr__=0x00 LDFLAGS += -Xlinker --defsym -Xlinker __init_mcucr__=0x80 LDFLAGS += -Xlinker --defsym -Xlinker __stack=0x7FFF #this defines the aims of the make process all: $(TRG).obj $(TRG).elf $(TRG).rom #$(TRG).eep #compile: instructions to create assembler and/or object files from C source %o : %c $(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@ %s : %c $(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@ #assemble: instructions to create object file from assembler files %o : %s $(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@ #link: instructions to create elf output file from object files %elf: $(OBJ) $(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@ #create avrobj file from elf output file %obj: %elf $(BIN) -O avrobj -R .eeprom $< $@ #create bin (ihex, srec) file from elf output file %rom: %elf $(BIN) -O $(FORMAT) -R .eeprom $< $@ %eep: %elf $(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ ###### dependecies, add any dependencies you need here ################### $(TRG).o: $(TRG).c #make instruction to delete created files clean: $(RM) $(OBJ) $(RM) $(SRC:.c=.s) $(RM) $(SRC:.c=.lst) $(RM) $(TRG).map $(RM) $(TRG).elf $(RM) $(TRG).obj $(RM) $(TRG).eep $(RM) $(TRG).rom $(RM) *.bak $(RM) *.log