summaryrefslogtreecommitdiff
path: root/n
diff options
context:
space:
mode:
Diffstat (limited to 'n')
-rw-r--r--n/es/src/Makefile19
-rw-r--r--n/es/src/Makefile.avr114
2 files changed, 133 insertions, 0 deletions
diff --git a/n/es/src/Makefile b/n/es/src/Makefile
new file mode 100644
index 0000000..b09dd9e
--- /dev/null
+++ b/n/es/src/Makefile
@@ -0,0 +1,19 @@
+PROGS = Carte_capteur
+Carte_capteur_OBJECTS = main.o rs232.o Tourelle.o adc.o
+DOC =
+EXTRACTDOC =
+MODULES = n/avr/rs232 n/avr/carte_capteur n/avr/utils n/avr/adc
+CONFIGFILE = avrconfig.h
+# atmega8, atmega8535, atmega128...
+MCU_TARGET = atmega8535
+# -O2 : speed
+# -Os : size
+OPTIMIZE = -O2
+
+DEFS =
+LDLIBS =
+
+include Makefile.avr
+
+Carte_capteur.elf: $(Carte_capteur_OBJECTS)
+
diff --git a/n/es/src/Makefile.avr b/n/es/src/Makefile.avr
new file mode 100644
index 0000000..c010642
--- /dev/null
+++ b/n/es/src/Makefile.avr
@@ -0,0 +1,114 @@
+# Flags. {{{1
+
+CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
+CPPFLAGS = $(DEFS) -MMD $(INCLUDES) \
+ $(if $(CONFIGFILE), $(CONFIGFILE:%=-include %))
+INCLUDES = -Imodules
+LDFLAGS = $(CFLAGS)
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+
+# Main rules. {{{1
+
+all: elf lst hex
+
+.PHONY: all clean elf lst doc text hex srec bin eeprom ehex esrec ebin
+
+# Rules for modules. {{{1
+
+VPATH = $(MODULES:%=modules/%)
+
+modules_checkout: modules_co
+
+modules_co: $(MODULES:%=modules_co.%)
+
+$(MODULES:%=modules_co.%):
+ mkdir -p modules
+ cd modules && cvs co $(@:modules_co.%=%)
+
+modules_update: modules_up
+
+modules_up: $(MODULES:%=modules_up.%)
+
+$(MODULES:%=modules_up.%):
+ cd modules/$(@:modules_up.%=%) && cvs up
+
+# General rules. {{{1
+
+ELFS = $(PROGS:%=%.elf)
+OBJECTS = $(filter %.o,$(foreach prog,$(PROGS),$($(prog)_OBJECTS)))
+
+elf: $(ELFS)
+lst: $(PROGS:%=%.lst)
+
+# Great piece of rules which only works in make 3.80+.
+# define PROG_template
+# $(1).elf: $$($(1)_OBJECTS)
+# endef
+#
+# $(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))
+
+$(ELFS):
+ $(LINK.o) $^ $(LDLIBS) -o $@
+
+%.lst: %.elf
+ $(OBJDUMP) -h -S $< > $@
+
+# Dependency checking.
+-include $(OBJECTS:%.o=%.d)
+
+clean:
+ rm -f *.o *.d $(ELFS) *.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 $< $@
+