Rev 362 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 362 | Rev 397 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | # $Id: Makefile |
1 | # $Id: Makefile 397 2007-04-29 21:26:14Z arune $ |
| 2 | PRG = bios |
2 | PRG = bios |
| 3 | ASRC = $(BIOSDIR)/vectors.S |
3 | ASRC = $(BIOSDIR)/vectors.S |
| 4 | CSRC = $(BIOSDIR)/bios_export.c $(BIOSDIR)/bios.c $(BIOSDIR)/flash.c |
4 | CSRC = $(BIOSDIR)/bios_export.c $(BIOSDIR)/bios.c $(BIOSDIR)/flash.c |
| 5 | BIOS_VERSION = 0x1337 |
5 | BIOS_VERSION = 0x1337 |
| 6 | OPTIMIZE = -Os -mcall-prologues |
6 | OPTIMIZE = -Os -mcall-prologues |
| Line 24... | Line 24... | ||
| 24 | # |
24 | # |
| 25 | # You should not have to change anything below here. |
25 | # You should not have to change anything below here. |
| 26 | # |
26 | # |
| 27 | 27 | ||
| 28 | CC = avr-gcc |
28 | CC = avr-gcc |
| - | 29 | AWK = awk |
|
| 29 | 30 | ||
| 30 | # Override is only needed by avr-lib build system. |
31 | # Override is only needed by avr-lib build system. |
| 31 | 32 | ||
| 32 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU) $(DEFS) |
33 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU) $(DEFS) |
| 33 | override LDFLAGS = -Wl,-Map,$(PRG).map,--defsym,__bios_start=$(BIOS_START),--defsym,__boot_start=$(BOOT_START),-Tldscripts/$(MCU).ld,--cref |
34 | override LDFLAGS = -Wl,-Map,$(PRG).map,--defsym,__bios_start=$(BIOS_START),--defsym,__boot_start=$(BOOT_START),-Tldscripts/$(MCU).ld,--cref |
| Line 70... | Line 71... | ||
| 70 | $(OBJDUMP) -h -S $< > $@ |
71 | $(OBJDUMP) -h -S $< > $@ |
| 71 | 72 | ||
| 72 | $(PRG).elf: $(PRG)_pass1.elf |
73 | $(PRG).elf: $(PRG)_pass1.elf |
| 73 | @echo Linking pass 2: Optimizing flash usage |
74 | @echo Linking pass 2: Optimizing flash usage |
| 74 | @rm -f $(PRG)_pass1.elf |
75 | @rm -f $(PRG)_pass1.elf |
| 75 | @$(MAKE) BIOS_START=$(shell |
76 | @$(MAKE) BIOS_START=$(shell $(AWK) '/0x[0-9a-f]+.*__bios_optimal_start/ { print $$1 }' bios.map) $(PRG)_pass1.elf |
| 76 | @mv $(PRG)_pass1.elf $(PRG).elf |
77 | @mv $(PRG)_pass1.elf $(PRG).elf |
| 77 | 78 | ||
| 78 | $(LIBNAME).S: $(PRG).elf |
79 | $(LIBNAME).S: $(PRG).elf |
| 79 | @echo Generating $@ |
80 | @echo Generating $@ |
| 80 | @awk '$$1 ~ /0x[0-9a-f]+/ && /BIOS_/ { print "\t.set "$$2","$$1"\n\t.global "$$2 }' $(PRG).map > $@ |
81 | @awk '$$1 ~ /0x[0-9a-f]+/ && /BIOS_/ { print "\t.set "$$2","$$1"\n\t.global "$$2 }' $(PRG).map > $@ |
| 81 | 82 | ||
| 82 | $(BIOSDIR)/config.h: config.inc |
83 | $(BIOSDIR)/config.h: config.inc |
| 83 | @echo Generating $@ |
84 | @echo Generating $@ |
| 84 |
|
85 | @$(AWK) 'BEGIN { FS="="; print "#ifndef CONFIG_H_\n#define CONFIG_H_\n" } /^[^#].*=.*/ { print "#define "$$1,$$2 } END { print "#endif" }' $< > $@ |
| 85 | 86 | ||
| 86 | $(TEMPLATEDIR)/bios.inc: config.inc $(PRG).elf |
87 | $(TEMPLATEDIR)/bios.inc: config.inc $(PRG).elf |
| 87 | @echo Generating $@ |
88 | @echo Generating $@ |
| 88 | @echo "# This file is automatically generated. Do not edit." > $@ |
89 | @echo "# This file is automatically generated. Do not edit." > $@ |
| 89 |
|
90 | @$(AWK) '/^[^#].*=.*/ { print $$0 }' config.inc >> $@ |
| 90 |
|
91 | @$(AWK) '/0x[0-9a-f]+.*__bios_ram_end/ { print "BIOS_RAM_END="$$1 }' bios.map >> $@ |
| 91 | @echo "BIOS_VERSION=$(BIOS_VERSION)" >> $@ |
92 | @echo "BIOS_VERSION=$(BIOS_VERSION)" >> $@ |
| 92 | 93 | ||
| 93 | $(TEMPLATEDIR)/bios.h: drivers/can/can.h $(BIOSDIR)/bios_export.h |
94 | $(TEMPLATEDIR)/bios.h: drivers/can/can.h $(BIOSDIR)/bios_export.h |
| 94 | @echo Generating $@ |
95 | @echo Generating $@ |
| 95 | @echo "/* This file is automatically generated. Do not edit. */\n" > $@ |
96 | @echo "/* This file is automatically generated. Do not edit. */\n" > $@ |
| Line 117... | Line 118... | ||
| 117 | 118 | ||
| 118 | install: hex |
119 | install: hex |
| 119 | $(UPLOAD) $(ULFLAGS) |
120 | $(UPLOAD) $(ULFLAGS) |
| 120 | 121 | ||
| 121 | reinstall: hex |
122 | reinstall: hex |
| 122 | $(OBJCOPY) -I ihex -O ihex --change-addresses=-$(shell |
123 | $(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 |
| 123 | $(CANMANAGER) $(CANMANFLAGS) -n $(NODE_ID) -u bios_offset.hex --flashcopy 0,$(shell |
124 | $(CANMANAGER) $(CANMANFLAGS) -n $(NODE_ID) -u bios_offset.hex --flashcopy 0,$(shell $(AWK) '/0x[0-9a-f]+.*__bios_optimal_start/ { print $$1 }' bios.map),$(shell $(AWK) '/0x[0-9a-f]+.*__bios_size/ { print $$1 }' bios.map) |
| 124 | 125 | ||
| 125 | # Rules for building the eeprom images |
126 | # Rules for building the eeprom images |
| 126 | 127 | ||
| 127 | eeprom: ehex |
128 | eeprom: ehex |
| 128 | 129 | ||