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, 25 insertions, 19 deletions
diff --git a/n/avr/make/Makefile.gen b/n/avr/make/Makefile.gen
index e403923..5193e43 100644
--- a/n/avr/make/Makefile.gen
+++ b/n/avr/make/Makefile.gen
@@ -2,46 +2,50 @@
# Flags
-INCLUDES = -I$(BASE) -I$(BASE)/common
-CFLAGS = -g -Wall -W -Wundef -Wno-unused-parameter $(OPTIMIZE)
-ASFLAGS = -Wa,--gstabs
-CPPFLAGS = $(DEFS) $(INCLUDES) -MMD \
- $(if $(CONFIGFILE),$(CONFIGFILE:%=-include %))
-LDFLAGS =
-LDLIBS = $(LIBS)
+INCLUDES := -I$(BASE) -I$(BASE)/common
+CFLAGS := -g -Wall -W -Wundef -Wno-unused-parameter $(OPTIMIZE)
+ASFLAGS := -Wa,--gstabs
+CPPFLAGS := $(DEFS) $(INCLUDES) -MMD \
+ $(if $(CONFIGFILE),$(CONFIGFILE:%=-include %))
+LDFLAGS :=
+LDLIBS := $(LIBS)
+
+# Usefull macros.
+## Return $(A) only if defined, else return B.
+## $(call defval A,B)
+defval = $(if $(filter undefined,$(origin $(1))),$(2),$($(1)))
# Main rules.
-all: avr host
+all: avr simu host
.PHONY: all clean doc
# General rules.
-ALL_PROGS = $(PROGS) $(AVR_PROGS) $(HOST_PROGS)
-SOURCES = $(foreach prog,$(ALL_PROGS),$($(prog)_SOURCES))
+ALL_PROGS := $(PROGS) $(AVR_PROGS) $(HOST_PROGS) $(SIMU_PROGS)
+ALL_SOURCES = $(foreach prog,$(ALL_PROGS),$($(prog)_SOURCES))
# Modules.
MODULES += host
-ifneq (,$(MODULES))
-include $(MODULES:%=$(BASE)/modules/%/Makefile.module)
-endif
+ALL_MODULES := $(sort $(MODULES) \
+ $(foreach prog,$(ALL_PROGS),$($(prog)_MODULES)))
-none_SOURCES =
+include $(ALL_MODULES:%=$(BASE)/modules/%/Makefile.module)
define MODULES_template
$(1)_SOURCES += $(foreach module,\
- $(if $($(1)_MODULES),$($(1)_MODULES),$(MODULES)),\
+ $(call defval,$(1)_MODULES,$(MODULES)),\
$($(subst /,_,$(module))_SOURCES)\
)
endef
$(foreach prog,$(ALL_PROGS),$(eval $(call MODULES_template,$(prog))))
-vpath %.c $(MODULES:%=$(BASE)/modules/%)
-vpath %.S $(MODULES:%=$(BASE)/modules/%)
+vpath %.c $(ALL_MODULES:%=$(BASE)/modules/%)
+vpath %.S $(ALL_MODULES:%=$(BASE)/modules/%)
# Compilation test rules.
@@ -51,7 +55,8 @@ test.sub::
endef
define TEST_template
-$$(foreach mcu,$$(if $$($(1:%.h=%)_MCU),$$($(1:%.h=%)_MCU),$$(TEST_MCU)),\
+$$(foreach mcu,\
+ $$(if $$($(1:%.h=%)_TEST_MCU),$$($(1:%.h=%)_TEST_MCU),$$(TEST_MCU)),\
$$(eval $$(call TEST_MCU_template,$(1),$$(mcu))))
test.sub::
$$(MAKE) CONFIGFILE=$(1) clean host
@@ -63,7 +68,7 @@ test: test.sub clean
# Include other Makefiles.
-ifneq (,$(filter-out %.c %.avr.S,$(SOURCES)))
+ifneq (,$(filter-out %.c %.avr.S,$(ALL_SOURCES)))
$(error Sources should be .c or .avr.S files)
endif
@@ -72,6 +77,7 @@ include $(BASE)/make/Makefile.avr
include $(BASE)/make/Makefile.host
else
avr:
+simu:
host:
clean.avr:
clean.host: