-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (31 loc) · 871 Bytes
/
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
SRCDIR = src
LIBDIR = lib
OBJDIR = bin
export BOARD_TAG=mega
export BOARD_SUB=atmega2560
CC ?= clang
CFLAGS += -MMD -MP -std=c11 -Wall -Wextra -O3 -pedantic -I./lib/ -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE
LDLIBS += -lpthread
SRC = $(wildcard $(SRCDIR)/*.c)
OBJ = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
.PHONY: all clean arduino
all: controller arduino
controller: bin/main.o bin/controller.o bin/serial.o bin/command.o
$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
$(OBJDIR)/%.o: CFLAGS += -MF $(@:.o=.d)
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(OBJDIR):
mkdir $@
-include $(wildcard $(OBJDIR)/*.d)
debug: CFLAGS += -g3 -O -DDEBUG
debug: all
arduino:
$(MAKE) -C arduino
clean-controller:
$(RM) -r $(OBJDIR)
$(RM) controller
clean: clean-controller
$(RM) -r $(OBJDIR)
$(RM) controller
-$(MAKE) -C arduino clean