summaryrefslogtreecommitdiff
path: root/n/avr/rs232/Makefile.avr
diff options
context:
space:
mode:
authorschodet2004-07-06 21:09:13 +0000
committerschodet2004-07-06 21:09:13 +0000
commit0c19b9edaa65f71f79a651302379fde883b76602 (patch)
tree79b4367ecf80e2ccbfb0f064ec5895d9043f0a5d /n/avr/rs232/Makefile.avr
parent6a37da0027ac312365eff5f63596bf35db6c5fa5 (diff)
Ajout du support des modules.
Diffstat (limited to 'n/avr/rs232/Makefile.avr')
-rw-r--r--n/avr/rs232/Makefile.avr99
1 files changed, 99 insertions, 0 deletions
diff --git a/n/avr/rs232/Makefile.avr b/n/avr/rs232/Makefile.avr
new file mode 100644
index 0000000..1bcf944
--- /dev/null
+++ b/n/avr/rs232/Makefile.avr
@@ -0,0 +1,99 @@
+# Flags. {{{1
+
+CC = avr-gcc
+
+CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
+CPPFLAGS = $(DEFS)
+LDFLAGS =
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+
+# Main rules. {{{1
+
+CSOURCES = $(filter %.c, $(SOURCES))
+SSOURCES = $(filter %.s, $(SOURCES))
+OBJECTS = $(CSOURCES:%.c=%.o) $(SSOURCES:%.s=%.o)
+ELFS = $(PROGS:%=%.elf)
+
+all: elf lst hex
+
+.PHONY: all clean elf lst doc text hex srec bin eeprom ehex esrec ebin
+
+elf: $(PROGS:%=%.elf)
+lst: $(PROGS:%=%.lst)
+
+$(PROGS:%=%.elf): $(OBJECTS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+%.lst: %.elf
+ $(OBJDUMP) -h -S $< > $@
+
+clean:
+ rm -f *.o $(PROGS:%=%.elf) *.lst *.map *.bak *~ $(DOC) *.exd
+ rm -f $(EXTRA_CLEAN_FILES) $(TEXTS) $(EEPROMS)
+
+# Rules for building the doc. {{{1
+
+doc: $(DOC)
+
+%.html: %.txt %.exd
+ aft $<
+
+%.exd: $(EXTRACTDOC)
+ test -n "$^" && extractdoc $^ > $@ || true
+
+# Rules for modules. {{{1
+
+MODULESFILES = $(MODULES:%=modules/%/Module)
+
+Makefile: $(MODULESFILES)
+
+MODULESOURCES = $(addprefix $(module)/,$(shell cat modules/$(module)/Module))
+MODULESSOURCES := $(if $(MODULES),\
+ $(foreach module,$(MODULES),$(MODULESOURCES)))
+
+$(MODULESFILES):
+ mkdir -p modules
+ cd modules && cvs co $(@:modules/%/Module=%)
+ test -f $@
+
+# Rules for building the .text rom images. {{{1
+
+TEXTS = $(PROGS:%=%.hex) $(PROGS:%=%.bin) $(PROGS:%=%.srec)
+
+text: hex bin srec
+
+hex: $(PROGS:%=%.hex)
+bin: $(PROGS:%=%.bin)
+srec: $(PROGS:%=%.srec)
+
+%.hex: %.elf
+ $(OBJCOPY) -j .text -j .data -O ihex $< $@
+
+%.srec: %.elf
+ $(OBJCOPY) -j .text -j .data -O srec $< $@
+
+%.bin: %.elf
+ $(OBJCOPY) -j .text -j .data -O binary $< $@
+
+# Rules for building the .eeprom rom images. {{{1
+
+EEPROMS = $(PROGS:%=%_eeprom.hex) $(PROGS:%=%_eeprom.bin) \
+ $(PROGS:%=%_eeprom.srec)
+
+eeprom: ehex ebin esrec
+
+ehex: $(PROGS:%=%_eeprom.hex)
+ebin: $(PROGS:%=%_eeprom.bin)
+esrec: $(PROGS:%=%_eeprom.srec)
+
+%_eeprom.hex: %.elf
+ $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
+
+%_eeprom.srec: %.elf
+ $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
+
+%_eeprom.bin: %.elf
+ $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
+