Rev 469 | Blame | Last modification | View Log | SVN | RSS feed
# $Id: Makefile 550 2007-07-19 22:44:46Z andfri $PRG = biosASRC = $(BIOSDIR)/vectors.SCSRC = $(BIOSDIR)/bios_export.c $(BIOSDIR)/bios.c $(BIOSDIR)/flash.cBIOS_VERSION = 0x1338OPTIMIZE = -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-gccAWK = awk# 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)# Get old node config and build new bios "make update NODE_ID=0x01"# this is now done in two steps, first make oldconfig and then make update# this due to re-reading the configfile.PHONY: update oldconfig move updateconfigupdate: clean all updateconfig# Move config from a node-folder to avr-lib dir to be able to compile a new version of bios# this removes the lines starting with BIOS_RAM_END and BIOS_VERSION becasue they are added in make templateoldconfig:cp config.inc config.old@$(AWK) '!/^BIOS_RAM_END*/ && !/^BIOS_VERSION*/ { print }' $(PERSONALDIR)/*$(NODE_ID)*/$(BIOSDIR)/bios.inc > config.inc# - cp $(PERSONALDIR)/*$(NODE_ID)*/bios.inc config.inc# Copy template to personal dirmove:- mkdir -p $(PERSONALDIR)/$(NODE_ID)_$(HW_NAME)- cp -r $(TEMPLATEDIR)/* $(PERSONALDIR)/$(NODE_ID)_$(HW_NAME)/# Copy template to personal dir but dont copy makefile and main.c as you dont want these files replaced generallyupdateconfig:- cp -r $(TEMPLATEDIR)/$(BIOSDIR) $(TEMPLATEDIR)/config.inc $(TEMPLATEDIR)/Makefile $(PERSONALDIR)/$(NODE_ID)_*/.PHONY: clean cleanintermediate cleantemplate distcleanclean: cleanintermediate cleantemplate-rm -f $(PRG).elf $(PRG).lst $(PRG).map *.hexcleanintermediate:-rm -f $(OBJ) $(LIBNAME).[So] *.d $(BIOSDIR)/config.hcleantemplate:-rm -f $(TEMPLATEDIR)/$(BIOSDIR)/*distclean:@echo Cleaning: template$(MAKE) -C template distclean@echo Cleaning: bios$(MAKE) clean.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@mv $(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)/$(BIOSDIR)/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)/$(BIOSDIR)/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)/$(BIOSDIR)/bios.h $(TEMPLATEDIR)/$(BIOSDIR)/bios.inc $(TEMPLATEDIR)/$(BIOSDIR)/$(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)# Update bios over can, get config from old node config and build new bios "make reinstall NODE_ID=0x01"# this is now done in two steps, first make oldconfig and then make reinstall# this due to re-reading the configfilereinstall: update#next row not needed when using candude# $(OBJCOPY) -I ihex -O ihex --change-addresses=-$(shell $(AWK) '/0x[0-9a-f]+.*__bios_optimal_start/ { print $$1 }' bios.map) bios.hex bios_offset.hex$(CANUPLOAD) $(CANULFLAGS) -n $(NODE_ID) -f $(PRG).hex -r -b# 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: