summaryrefslogtreecommitdiff
path: root/n/chenil
diff options
context:
space:
mode:
authorschodet2004-10-02 15:59:45 +0000
committerschodet2004-10-02 15:59:45 +0000
commit1f14105a0465099079c06955c43e58c664b13c13 (patch)
tree189fadbbf1fda68b6b102055d6f04c903a4456c7 /n/chenil
parentfa32b198d2275178f3181a1c8df5438115998d7f (diff)
Conversion au nouveau système de Makefile.
Diffstat (limited to 'n/chenil')
-rw-r--r--n/chenil/Makefile7
-rw-r--r--n/chenil/Makefile.avr55
2 files changed, 38 insertions, 24 deletions
diff --git a/n/chenil/Makefile b/n/chenil/Makefile
index 707ae0a..70d66e4 100644
--- a/n/chenil/Makefile
+++ b/n/chenil/Makefile
@@ -1,8 +1,9 @@
PROGS = chenil
-SOURCES = chenil.c
+chenil_OBJECTS = chenil.o
DOC =
EXTRACTDOC =
MODULES = n/avr/utils
+CONFIGFILE =
# atmega8, atmega8535, atmega128...
MCU_TARGET = atmega8
# -O2 : speed
@@ -10,6 +11,8 @@ MCU_TARGET = atmega8
OPTIMIZE = -O2
DEFS =
-LIBS =
+LDLIBS =
include Makefile.avr
+
+chenil.elf: $(chenil_OBJECTS)
diff --git a/n/chenil/Makefile.avr b/n/chenil/Makefile.avr
index d1411f4..325be3f 100644
--- a/n/chenil/Makefile.avr
+++ b/n/chenil/Makefile.avr
@@ -1,55 +1,66 @@
# Flags. {{{1
-CC = avr-gcc
-
CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
-CPPFLAGS = $(DEFS) -Imodules
+CPPFLAGS = $(DEFS) -MMD $(INCLUDES) \
+ $(if $(CONFIGFILE), $(CONFIGFILE:%=-include %))
+INCLUDES = -Imodules
LDFLAGS =
+CC = avr-gcc
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)
+VPATH = $(MODULES:%=modules/%)
-Makefile: $(MODULESFILES)
+modules_checkout: modules_co
-MODULESOURCES = $(addprefix modules/$(module)/,\
- $(shell cat modules/$(module)/Module))
-MODULESSOURCES := $(if $(MODULES),\
- $(foreach module,$(MODULES),$(MODULESOURCES)))
-SOURCES += $(MODULESSOURCES)
+modules_co: $(MODULES:%=modules_co.%)
-$(MODULESFILES):
+$(MODULES:%=modules_co.%):
mkdir -p modules
- cd modules && cvs co $(@:modules/%/Module=%)
- test -f $@
+ 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
-elf: $(PROGS:%=%.elf)
+ELFS = $(PROGS:%=%.elf)
+OBJECTS = $(filter %.o,$(foreach prog,$(PROGS),$($(prog)_OBJECTS)))
+
+elf: $(ELFS)
lst: $(PROGS:%=%.lst)
-$(PROGS:%=%.elf): $(OBJECTS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+# 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 $(OBJECTS) $(PROGS:%=%.elf) *.lst *.map *.bak *~
+ rm -f *.o *.d $(ELFS) *.lst *.map *.bak *~
rm -f $(DOC) *.exd $(EXTRA_CLEAN_FILES) $(TEXTS) $(EEPROMS)
# Rules for building the doc. {{{1