summaryrefslogtreecommitdiff
path: root/n/avr/make/Makefile.gen
blob: c68ce730cf23c6223e621dc4acc2b3ba1d32677c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Makefile.gen - General Makefile.

# Flags {{{1

INCLUDES = -I$(BASE)
OPTIMIZE = 
CFLAGS = -g -Wall -W -Wundef -Werror $(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)