Blame | Last modification | View Log | SVN | RSS feed
# $Id$PRG = biosASRC = $(BIOSDIR)/vectors.SCSRC = $(BIOSDIR)/bios_export.c $(BIOSDIR)/bios.c $(BIOSDIR)/flash.cBIOS_VERSION = 0x1337OPTIMIZE = -Os -mcall-prologuesLIBNAME = libbiosBIOSDIR = biosTEMPLATEDIR = templateinclude config.incinclude system.incDEFS = -DF_CPU=$(F_CPU) -DCAN_DRIVER_H=$(CAN_DRIVER_H) -DBIOS_VERSION=$(BIOS_VERSION) -I. -I$(BIOSDIR)LIBS =ifeq ($(CAN_CONTROLLER),MCP2515)CSRC += drivers/can/mcp2515/mcp2515.cCAN_DRIVER_H = \<drivers/can/mcp2515/mcp2515.h\>endifOBJ = $(ASRC:.S=.o) $(CSRC:.c=.o)## You should not have to change anything below here.#CC = avr-gcc# Override is only needed by avr-lib build system.override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU) $(DEFS)override LDFLAGS = -Wl,-Map,$(PRG).map,--defsym,__bios_start=$(BIOS_START),--defsym,__boot_start=$(BOOT_START),-Tldscripts/$(MCU).ld,--crefoverride ASFLAGS = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU) $(DEFS)# Start address for linking pass 1, will be overridden for optimizing passBIOS_START = 0x100OBJCOPY = avr-objcopyOBJDUMP = avr-objdumpSIZE = avr-sizeSZFLAGS =.PHONY: defaultdefault: hex template lst cleanintermediate@$(SIZE) $(SZFLAGS) $(PRG).elf#include $(CSRC:.c=.d).PHONY: allall: $(PRG).elf lst hex eeprom template$(PRG)_pass1.elf: $(BIOSDIR)/config.h $(OBJ)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS).PHONY: clean cleanintermediate cleantemplateclean: cleanintermediate cleantemplate-rm -f $(PRG).elf $(PRG).lst $(PRG).map *.hexcleanintermediate:-rm -f $(OBJ) $(PRG)_pass1.elf $(LIBNAME).[So] *.d $(BIOSDIR)/config.hcleantemplate:-rm -f $(TEMPLATEDIR)/bios.* $(TEMPLATEDIR)/$(LIBNAME).a.PHONY: lstlst: $(PRG).lst%.lst: %.elf$(OBJDUMP) -h -S $< > $@$(PRG).elf: $(PRG)_pass1.elf@echo Linking pass 2: Optimizing flash usage@rm -f $(PRG)_pass1.elf$(MAKE) BIOS_START=$(shell awk '/0x[0-9a-f]+.*__bios_optimal_start/ { print $$1 }' bios.map) $(PRG)_pass1.elf@cp $(PRG)_pass1.elf $(PRG).elf$(LIBNAME).S: $(PRG).elf@echo Generating $@@awk '$$1 ~ /0x[0-9a-f]+/ && /BIOS_/ { print "\t.set "$$2","$$1"\n\t.global "$$2 }' $(PRG).map > $@$(BIOSDIR)/config.h: config.inc@echo Generating $@@awk 'BEGIN { FS="="; print "#ifndef CONFIG_H_\n#define CONFIG_H_\n" } /^[^#].*=.*/ { print "#define "$$1,$$2 } END { print "#endif" }' $< > $@$(TEMPLATEDIR)/bios.inc: config.inc $(PRG).elf@echo Generating $@@echo "# This file is automatically generated. Do not edit." > $@@awk '/^[^#].*=.*/ { print $$0 }' config.inc >> $@@awk '/0x[0-9a-f]+.*__bios_ram_end/ { print "BIOS_RAM_END="$$1 }' bios.map >> $@@echo "BIOS_VERSION=$(BIOS_VERSION)" >> $@$(TEMPLATEDIR)/bios.h: drivers/can/can.h $(BIOSDIR)/bios_export.h@echo Generating $@@echo "/* This file is automatically generated. Do not edit. */\n" > $@@echo "#ifndef BIOS_H_\n#define BIOS_H_\n" >> $@@cat $^ >> $@@echo "\n#endif /*BIOS_H_*/" >> $@.PHONY: templatetemplate: $(TEMPLATEDIR)/bios.h $(TEMPLATEDIR)/bios.inc $(TEMPLATEDIR)/$(LIBNAME).a($(LIBNAME).o)%.d: %.c@set -e; rm -f $@; \$(CC) -M $(CFLAGS) $< > $@.$$$$; \sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \rm -f $@.$$$$# Rules for building the rom imageshex: $(PRG).hex%.hex: %.elf$(OBJCOPY) -j .text -j .data -j .bootloader -O ihex $< $@# Rules for uploading rom images to flashinstall: hex$(UPLOAD) $(ULFLAGS)# Rules for building the eeprom imageseeprom: ehexehex: $(PRG)_eeprom.hex%_eeprom.hex: %.elf$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@.DELETE_ON_ERROR: