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.gen58
1 files changed, 58 insertions, 0 deletions
diff --git a/n/avr/make/Makefile.gen b/n/avr/make/Makefile.gen
new file mode 100644
index 0000000..d6fdcca
--- /dev/null
+++ b/n/avr/make/Makefile.gen
@@ -0,0 +1,58 @@
+# Makefile.gen - General Makefile.
+
+# Flags {{{1
+
+INCLUDES = -Imodules
+OPTIMIZE =
+CFLAGS = -g -Wall $(OPTIMIZE)
+DEFS =
+CPPFLAGS = $(DEFS) $(INCLUDES) -MMD \
+ $(if $(CONFIGFILE),$(CONFIGFILE:%=-include %))
+LDFLAGS =
+
+# Main rules. {{{1
+
+all: avr host
+
+.PHONY: all clean doc
+
+# General rules. {{{1
+
+SOURCES = $(foreach prog,$(PROGS),$($(prog)_SOURCES))
+
+ifneq (,$(filter-out %.c,$(SOURCES)))
+$(error Sources should be c files)
+endif
+
+# Modules. {{{1
+
+include $(MODULES:%=$(BASE)/modules/%/Makefile.module)
+
+define MODULES_template
+$(1)_SOURCES += $(foreach module,$(MODULES),$($(module)_SOURCES))
+endef
+
+$(foreach prog,$(PROGS),$(eval $(call MODULES_template,$(prog))))
+
+vpath %.c $(MODULES:%=$(BASE)/modules/%)
+
+# Include other Makefiles. {{{1
+
+include $(BASE)/make/Makefile.avr
+include $(BASE)/make/Makefile.host
+
+# Rules for building the doc. {{{1
+
+doc: $(DOC)
+
+%.html: %.txt %.exd
+ aft $<
+
+%.exd: $(EXTRACTDOC)
+ test -n "$^" && extractdoc $^ > $@ || true
+
+# Cleanning. {{{1
+
+clean: clean.avr clean.host
+ rm -f *.bak *~ $(DOC) *.exd $(EXTRA_CLEAN_FILES)
+