From 583f00e0b8efe2832f63efb478a51d3ad35e92ed Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 7 Oct 2007 22:16:03 +0200 Subject: Included SI2E avr modules. Well, this need more works... --- digital/avr/make/Makefile.avr | 121 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 digital/avr/make/Makefile.avr (limited to 'digital/avr/make/Makefile.avr') diff --git a/digital/avr/make/Makefile.avr b/digital/avr/make/Makefile.avr new file mode 100644 index 00000000..b063fe53 --- /dev/null +++ b/digital/avr/make/Makefile.avr @@ -0,0 +1,121 @@ +# Makefile.avr - AVR part Makefile. +# +# Flags. + +AVR_CFLAGS := $(CFLAGS) -mmcu=$(AVR_MCU) +AVR_ASFLAGS := $(ASFLAGS) -mmcu=$(AVR_MCU) +AVR_CPPFLAGS := $(CPPFLAGS) $(AVR_DEFS) +AVR_LDFLAGS := $(LDFLAGS) +AVR_LDLIBS := $(LDLIBS) $(AVR_LIBS) + +AVR_CC := avr-gcc +AVR_OBJCOPY := avr-objcopy +AVR_OBJDUMP := avr-objdump +AVR_COMPILE.c = $(AVR_CC) $(AVR_CFLAGS) $(AVR_CPPFLAGS) -c +ifdef L +AVR_COMPILE.c += -Wa,-adhlns=$(@:%.avr.o=%.c.avr.lst) +endif +AVR_COMPILE.S := $(AVR_CC) $(AVR_ASFLAGS) $(AVR_CPPFLAGS) -c +AVR_LINK.o := $(AVR_CC) $(AVR_CFLAGS) $(AVR_LDFLAGS) + +# Main rules. + +avr: elf lst hex + +simu: simuelf + +.PHONY: avr simu clean.avr elf simuelf lst \ + text hex srec bin eeprom ehex esrec ebin + +# General rules. + +AVR_PROGS += $(PROGS) +AVR_ELFS := $(AVR_PROGS:%=%.avr.elf) +AVR_SIMU_ELFS := $(SIMU_PROGS:%=%.avr.simu.elf) +AVR_SOURCES := $(filter-out %.host.c,$(ALL_SOURCES)) +AVR_C_SOURCES := $(filter %.c,$(AVR_SOURCES)) +AVR_S_SOURCES := $(filter %.S,$(AVR_SOURCES)) +AVR_OBJECTS := $(AVR_C_SOURCES:%.c=%.avr.o) $(AVR_S_SOURCES:%.S=%.avr.o) +AVR_SIMU_OBJECTS := $(AVR_OBJECTS:%.avr.o=%.avr.simu.o) + +elf: $(AVR_ELFS) +simuelf: $(AVR_SIMU_ELFS) +lst: $(AVR_PROGS:%=%.avr.lst) + +define AVR_PROG_template +$(1).avr.elf: $$(patsubst %.S,%.avr.o,$$(patsubst %.c,%.avr.o,\ + $$(filter-out %.host.c,$$($(1)_SOURCES)))) +$(1).avr.simu.elf: $$(patsubst %.S,%.avr.simu.o,$$(patsubst %.c,%.avr.simu.o,\ + $$(filter-out %.host.c,$$($(1)_SOURCES)))) +endef + +$(foreach prog,$(AVR_PROGS),$(eval $(call AVR_PROG_template,$(prog)))) + +$(AVR_ELFS) $(AVR_SIMU_ELFS): + $(AVR_LINK.o) $^ $(AVR_LDLIBS) -o $@ + +%.avr.lst: %.avr.elf + $(AVR_OBJDUMP) -h -S $< > $@ + +%.avr.o: %.c + $(AVR_COMPILE.c) -o $@ $< + +%.avr.simu.o: %.c + $(AVR_COMPILE.c) -DSIMU=1 -o $@ $< + +%.avr.o: %.S + $(AVR_COMPILE.S) -o $@ $< + +%.avr.simu.o: %.S + $(AVR_COMPILE.S) -DSIMU=1 -o $@ $< + +# Dependency checking. +-include $(AVR_OBJECTS:%.avr.o=%.avr.d) +-include $(AVR_SIMU_OBJECTS:%.avr.simu.o=%.avr.d) + +# Rules for building the .text rom images. + +TEXTS := $(AVR_PROGS:%=%.hex) $(AVR_PROGS:%=%.bin) $(AVR_PROGS:%=%.srec) + +text: hex + +hex: $(AVR_PROGS:%=%.hex) +bin: $(AVR_PROGS:%=%.bin) +srec: $(AVR_PROGS:%=%.srec) + +%.hex: %.avr.elf + $(AVR_OBJCOPY) -j .text -j .data -O ihex $< $@ + +%.srec: %.avr.elf + $(AVR_OBJCOPY) -j .text -j .data -O srec $< $@ + +%.bin: %.avr.elf + $(AVR_OBJCOPY) -j .text -j .data -O binary $< $@ + +# Rules for building the .eeprom rom images. + +EEPROMS := $(AVR_PROGS:%=%_eeprom.hex) $(AVR_PROGS:%=%_eeprom.bin) \ + $(AVR_PROGS:%=%_eeprom.srec) + +eeprom: ehex + +ehex: $(AVR_PROGS:%=%_eeprom.hex) +ebin: $(AVR_PROGS:%=%_eeprom.bin) +esrec: $(AVR_PROGS:%=%_eeprom.srec) + +%_eeprom.hex: %.avr.elf + $(AVR_OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ + +%_eeprom.srec: %.avr.elf + $(AVR_OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ + +%_eeprom.bin: %.avr.elf + $(AVR_OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ + +# Cleaning. + +clean.avr: + rm -f *.avr.o *.avr.d $(AVR_ELFS) \ + *.avr.simu.o *.avr.simu.d $(AVR_SIMU_ELFS) \ + *.avr.lst *.avr.map $(TEXTS) $(EEPROMS) + -- cgit v1.2.3