-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (50 loc) · 1.77 KB
/
Makefile
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
59
60
61
62
63
64
65
66
67
68
69
# Path to project root (for top-level, so the project is in ./; first-level, ../; etc.)
ROOT = .
-include $(ROOT)/Config.mk
-include $(ROOT)/common.mk
.PHONY: all clean upload test run_test _force_look
all: $(BINDIRS) $(OUT)
# Remove all intermediate object files (remove the binary directory)
clean:
-rm -f $(OUT)
-rm -rf $(BINDIR)
-rm -rf $(BINDIR_TEST)
# Uploads program to device
upload: all
$(UPLOAD)
test: $(BINDIRS) $(OUT_TEST) run_test
run_test: $(OUT_TEST)
$(foreach test, $(OUT_TEST), @$(test))
_force_look:
@true
$(BINDIRS):
-@mkdir -p $(BINDIRS)
# Compile program
$(OUT): $(ASMOBJ) $(COBJ) $(CPPOBJ)
@echo LN $(BINDIR)/*.o $(LIBRARIES) to $@
@$(CC) $(LDFLAGS) $(BINDIR)/*.o $(LIBRARIES) -o $@
@$(MCUPREFIX)size $(SIZEFLAGS) $(OUT)
$(MCUPREPARE)
$(OUT_TEST): $(BINDIR_TEST)/%$(EXESUFFIX): $(BINDIR_TEST)/%.$(OEXT) $(BINDIR_TEST)/%.$(OEXT_TEST) $(LIBOBJ_TEST)
@echo LN $^ to $@
@$(CC_TEST) $(LDFLAGS_TEST) $^ -o $@
# Assembly source file management
$(ASMOBJ): $(BINDIR)/%.$(OEXT): $(SRCDIR)/%.$(ASMEXT) $(HEADERS)
@echo AS $<
@$(AS) $(AFLAGS) -o $@ $<
# Object management
$(COBJ): $(BINDIR)/%.$(OEXT): $(SRCDIR)/%.$(CEXT) $(HEADERS)
@echo CC $(INCLUDE) $<
@$(CC) $(INCLUDE) $(CFLAGS) -o $@ $<
$(CPPOBJ): $(BINDIR)/%.$(OEXT): $(SRCDIR)/%.$(CPPEXT) $(HEADERS)
@echo CPC $(INCLUDE) $<
@$(CPPCC) $(INCLUDE) $(CPPFLAGS) -o $@ $<
$(COBJ_TEST): $(BINDIR_TEST)/%.$(OEXT): $(SRCDIR)/%.$(CEXT) $(HEADERS)
@echo CC $(INCLUDE_TEST) $<
@$(CC_TEST) $(INCLUDE_TEST) $(CFLAGS_TEST) -o $@ $<
$(TESTOBJ): $(BINDIR_TEST)/%.$(OEXT_TEST): $(SRCDIR_TEST)/%.$(CEXT_TEST) $(HEADERS)
@echo CC $(INCLUDE_TEST) $<
@$(CC_TEST) $(INCLUDE_TEST) $(CFLAGS_TEST) -o $@ $<
$(LIBOBJ_TEST): $(LIBSRC_TEST) $(HEADERS)
@echo CC $(INCLUDE_TEST) $<
@$(CC_TEST) $(INCLUDE_TEST) $(CFLAGS_TEST) -o $@ $<