summaryrefslogtreecommitdiff
path: root/n/avr/make/Makefile.gen
diff options
context:
space:
mode:
Diffstat (limited to 'n/avr/make/Makefile.gen')
-rw-r--r--n/avr/make/Makefile.gen44
1 files changed, 35 insertions, 9 deletions
diff --git a/n/avr/make/Makefile.gen b/n/avr/make/Makefile.gen
index c68ce73..baa18d0 100644
--- a/n/avr/make/Makefile.gen
+++ b/n/avr/make/Makefile.gen
@@ -2,13 +2,12 @@
# Flags {{{1
-INCLUDES = -I$(BASE)
-OPTIMIZE =
-CFLAGS = -g -Wall -W -Wundef -Werror $(OPTIMIZE)
-DEFS =
+INCLUDES = -I$(BASE) -I$(BASE)/common
+CFLAGS = -g -Wall -W -Wundef $(OPTIMIZE)
CPPFLAGS = $(DEFS) $(INCLUDES) -MMD \
$(if $(CONFIGFILE),$(CONFIGFILE:%=-include %))
LDFLAGS =
+LDLIBS = $(LIBS)
# Main rules. {{{1
@@ -20,13 +19,11 @@ all: avr host
SOURCES = $(foreach prog,$(PROGS),$($(prog)_SOURCES))
-ifneq (,$(filter-out %.c,$(SOURCES)))
-$(error Sources should be c files)
-endif
-
# Modules. {{{1
+ifneq (,$(MODULES))
include $(MODULES:%=$(BASE)/modules/%/Makefile.module)
+endif
define MODULES_template
$(1)_SOURCES += $(foreach module,$(MODULES),$($(module)_SOURCES))
@@ -36,10 +33,39 @@ $(foreach prog,$(PROGS),$(eval $(call MODULES_template,$(prog))))
vpath %.c $(MODULES:%=$(BASE)/modules/%)
+# Compilation test rules. {{{1
+
+define TEST_MCU_template
+test.sub::
+ $$(MAKE) CONFIGFILE=$(1) AVR_MCU=$(2) clean elf
+endef
+
+define TEST_template
+$$(foreach mcu,$$(if $$($(1:%.h=%)_MCU),$$($(1:%.h=%)_MCU),$$(TEST_MCU)),\
+ $$(eval $$(call TEST_MCU_template,$(1),$$(mcu))))
+test.sub::
+ $$(MAKE) CONFIGFILE=$(1) clean host
+endef
+
+$(foreach config,$(TEST_CONFIGFILES),$(eval $(call TEST_template,$(config))))
+
+test: test.sub clean
+
# Include other Makefiles. {{{1
+ifneq (,$(filter-out %.c,$(SOURCES)))
+$(error Sources should be c files)
+endif
+
+ifneq (,$(PROGS))
include $(BASE)/make/Makefile.avr
include $(BASE)/make/Makefile.host
+else
+avr:
+host:
+clean.avr:
+clean.host:
+endif
# Rules for building the doc. {{{1
@@ -51,7 +77,7 @@ doc: $(DOC)
%.exd: $(EXTRACTDOC)
test -n "$^" && extractdoc $^ > $@ || true
-# Cleanning. {{{1
+# Cleaning. {{{1
clean: clean.avr clean.host
rm -f *.bak *~ $(DOC) *.exd $(EXTRA_CLEAN_FILES)