summaryrefslogtreecommitdiff
path: root/n
diff options
context:
space:
mode:
Diffstat (limited to 'n')
-rw-r--r--n/avr/howto/Makefile77
-rw-r--r--n/avr/howto/Makefile.avr103
-rw-r--r--n/avr/howto/howto-avr.txt9
-rw-r--r--n/avr/rs232/Makefile.avr38
-rw-r--r--n/avr/utils/Makefile77
-rw-r--r--n/avr/utils/Makefile.avr103
6 files changed, 240 insertions, 167 deletions
diff --git a/n/avr/howto/Makefile b/n/avr/howto/Makefile
index b4478ff..2ac6571 100644
--- a/n/avr/howto/Makefile
+++ b/n/avr/howto/Makefile
@@ -1,7 +1,8 @@
-PRG = example
-OBJECTS = example.o
+PROGS = example
+SOURCES = example.c
DOC = howto-avr.html
EXTRACTDOC =
+MODULES =
# atmega8, atmega8535, atmega128...
MCU_TARGET = atmega8
# -O2 : speed
@@ -11,74 +12,4 @@ OPTIMIZE = -O2
DEFS =
LIBS =
-# You should not have to change anything below here.
-
-CC = avr-gcc
-
-CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
-CPPFLAGS = $(DEFS)
-LDFLAGS = -Wl,-Map,$(PRG).map
-
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-
-all: elf lst hex
-
-elf: $(PRG).elf
-lst: $(PRG).lst
-
-$(PRG).elf: $(OBJECTS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-%.lst: %.elf
- $(OBJDUMP) -h -S $< > $@
-
-clean:
- rm -f *.o $(PRG).elf *.bak $(DOC) *.exd
- rm -f *.lst *.map $(EXTRA_CLEAN_FILES)
- rm -f $(PRG).hex $(PRG).bin $(PRG).srec $(PRG)_eeprom.hex $(PRG)_eeprom.bin $(PRG)_eeprom.srec
-
-# Rules for building the doc.
-
-doc: $(DOC)
-
-%.html: %.txt %.exd
- aft $<
-
-%.exd: $(EXTRACTDOC)
- test -n "$^" && extractdoc $^ > $@ || true
-
-# Rules for building the .text rom images.
-
-text: hex bin srec
-
-hex: $(PRG).hex
-bin: $(PRG).bin
-srec: $(PRG).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.
-
-eeprom: ehex ebin esrec
-
-ehex: $(PRG)_eeprom.hex
-ebin: $(PRG)_eeprom.bin
-esrec: $(PRG)_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 $< $@
-
+include Makefile.avr
diff --git a/n/avr/howto/Makefile.avr b/n/avr/howto/Makefile.avr
new file mode 100644
index 0000000..b3ceb39
--- /dev/null
+++ b/n/avr/howto/Makefile.avr
@@ -0,0 +1,103 @@
+# 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
+
+# Rules for modules. {{{1
+
+MODULESFILES = $(MODULES:%=modules/%/Module)
+
+Makefile: $(MODULESFILES)
+
+MODULESOURCES = $(addprefix modules/$(module)/,\
+ $(shell cat modules/$(module)/Module))
+MODULESSOURCES := $(if $(MODULES),\
+ $(foreach module,$(MODULES),$(MODULESOURCES)))
+SOURCES += $(MODULESSOURCES)
+
+$(MODULESFILES):
+ mkdir -p modules
+ cd modules && cvs co $(@:modules/%/Module=%)
+ test -f $@
+
+# General rules. {{{1
+
+elf: $(PROGS:%=%.elf)
+lst: $(PROGS:%=%.lst)
+
+$(PROGS:%=%.elf): $(OBJECTS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+%.lst: %.elf
+ $(OBJDUMP) -h -S $< > $@
+
+clean:
+ rm -f *.o $(OBJECTS) $(PROGS:%=%.elf) *.lst *.map *.bak *~
+ rm -f $(DOC) *.exd $(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 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 $< $@
+
diff --git a/n/avr/howto/howto-avr.txt b/n/avr/howto/howto-avr.txt
index 7e5e626..baa21cf 100644
--- a/n/avr/howto/howto-avr.txt
+++ b/n/avr/howto/howto-avr.txt
@@ -30,12 +30,13 @@ Sur les Windows, on peut faire fonctionner gcc avec AVR Studio.
Pour la programmation, il y a avrdude, programmation de l'AVR avec 3 fils.
-Le fichier Makefile livré avec cet howto peut être utilisé pour compiler les
-projets.
+Les fichiers |Makefile| et |Makefile.avr| livrés avec cet howto peuvent être
+utilisés pour compiler les projets.
* Modules Efrei Robotique
Chaque module est déposé dans son répertoire séparé. Pour les utiliser dans un
projet, il suffit de créer un |avrconfig.h| qui va bien et de compiler les
-sources du module avec son projet. Pour bien, il faudrait automatiser tout ça
-histoire de ne pas retrouver 5 fois le même code dans le CVS.
+sources du module avec son projet. Pour cela, il suffit de mettre le nom du
+module dans le |Makefile|. Le module est cherché automatiquement sur le cvs,
+puis ajouté à l'édition des liens.
diff --git a/n/avr/rs232/Makefile.avr b/n/avr/rs232/Makefile.avr
index 1bcf944..b3ceb39 100644
--- a/n/avr/rs232/Makefile.avr
+++ b/n/avr/rs232/Makefile.avr
@@ -20,6 +20,25 @@ all: elf lst hex
.PHONY: all clean elf lst doc text hex srec bin eeprom ehex esrec ebin
+# Rules for modules. {{{1
+
+MODULESFILES = $(MODULES:%=modules/%/Module)
+
+Makefile: $(MODULESFILES)
+
+MODULESOURCES = $(addprefix modules/$(module)/,\
+ $(shell cat modules/$(module)/Module))
+MODULESSOURCES := $(if $(MODULES),\
+ $(foreach module,$(MODULES),$(MODULESOURCES)))
+SOURCES += $(MODULESSOURCES)
+
+$(MODULESFILES):
+ mkdir -p modules
+ cd modules && cvs co $(@:modules/%/Module=%)
+ test -f $@
+
+# General rules. {{{1
+
elf: $(PROGS:%=%.elf)
lst: $(PROGS:%=%.lst)
@@ -30,8 +49,8 @@ $(PROGS:%=%.elf): $(OBJECTS)
$(OBJDUMP) -h -S $< > $@
clean:
- rm -f *.o $(PROGS:%=%.elf) *.lst *.map *.bak *~ $(DOC) *.exd
- rm -f $(EXTRA_CLEAN_FILES) $(TEXTS) $(EEPROMS)
+ rm -f *.o $(OBJECTS) $(PROGS:%=%.elf) *.lst *.map *.bak *~
+ rm -f $(DOC) *.exd $(EXTRA_CLEAN_FILES) $(TEXTS) $(EEPROMS)
# Rules for building the doc. {{{1
@@ -43,21 +62,6 @@ doc: $(DOC)
%.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)
diff --git a/n/avr/utils/Makefile b/n/avr/utils/Makefile
index 89e18f4..2be5002 100644
--- a/n/avr/utils/Makefile
+++ b/n/avr/utils/Makefile
@@ -1,7 +1,8 @@
-PRG = test_utils
-OBJECTS = test_utils.o
+PROGS = test_utils
+SOURCES = test_utils.c
DOC = utils.html
EXTRACTDOC = utils.h avrconfig.h
+MODULES =
# atmega8, atmega8535, atmega128...
MCU_TARGET = atmega8
# -O2 : speed
@@ -11,74 +12,4 @@ OPTIMIZE = -O2
DEFS =
LIBS =
-# You should not have to change anything below here.
-
-CC = avr-gcc
-
-CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
-CPPFLAGS = $(DEFS)
-LDFLAGS = -Wl,-Map,$(PRG).map
-
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-
-all: elf lst hex
-
-elf: $(PRG).elf
-lst: $(PRG).lst
-
-$(PRG).elf: $(OBJECTS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-%.lst: %.elf
- $(OBJDUMP) -h -S $< > $@
-
-clean:
- rm -f *.o $(PRG).elf *.bak $(DOC) *.exd
- rm -f *.lst *.map $(EXTRA_CLEAN_FILES)
- rm -f $(PRG).hex $(PRG).bin $(PRG).srec $(PRG)_eeprom.hex $(PRG)_eeprom.bin $(PRG)_eeprom.srec
-
-# Rules for building the doc.
-
-doc: $(DOC)
-
-%.html: %.txt %.exd
- aft $<
-
-%.exd: $(EXTRACTDOC)
- test -n "$^" && extractdoc $^ > $@ || true
-
-# Rules for building the .text rom images.
-
-text: hex bin srec
-
-hex: $(PRG).hex
-bin: $(PRG).bin
-srec: $(PRG).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.
-
-eeprom: ehex ebin esrec
-
-ehex: $(PRG)_eeprom.hex
-ebin: $(PRG)_eeprom.bin
-esrec: $(PRG)_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 $< $@
-
+include Makefile.avr
diff --git a/n/avr/utils/Makefile.avr b/n/avr/utils/Makefile.avr
new file mode 100644
index 0000000..b3ceb39
--- /dev/null
+++ b/n/avr/utils/Makefile.avr
@@ -0,0 +1,103 @@
+# 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
+
+# Rules for modules. {{{1
+
+MODULESFILES = $(MODULES:%=modules/%/Module)
+
+Makefile: $(MODULESFILES)
+
+MODULESOURCES = $(addprefix modules/$(module)/,\
+ $(shell cat modules/$(module)/Module))
+MODULESSOURCES := $(if $(MODULES),\
+ $(foreach module,$(MODULES),$(MODULESOURCES)))
+SOURCES += $(MODULESSOURCES)
+
+$(MODULESFILES):
+ mkdir -p modules
+ cd modules && cvs co $(@:modules/%/Module=%)
+ test -f $@
+
+# General rules. {{{1
+
+elf: $(PROGS:%=%.elf)
+lst: $(PROGS:%=%.lst)
+
+$(PROGS:%=%.elf): $(OBJECTS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+%.lst: %.elf
+ $(OBJDUMP) -h -S $< > $@
+
+clean:
+ rm -f *.o $(OBJECTS) $(PROGS:%=%.elf) *.lst *.map *.bak *~
+ rm -f $(DOC) *.exd $(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 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 $< $@
+