-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile
69 lines (57 loc) · 1.53 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
################################
## Program config
################################
PROJECT_NAME = serial_tool
BUILD_DIR = build
SOURCE_DIR = src
INC_DIR = inc
OUT_DIR = out
THIRD_PARTY = third_party
################################
## Source config
################################
SOURCE =
SOURCE += main.c
SOURCE += lib.c
SOURCE += modes.c
SOURCE += $(THIRD_PARTY)/TTY.c
SOURCE += $(THIRD_PARTY)/dbg.c
################################
## Flags config
################################
CFLAGS =
CFLAGS += -std=gnu99
CFLAGS += -Wall -Wpedantic -Werror
################################
## Print config
################################
LDPRINT = "Link $@"
CCPRINT = "Build $<"
################################
## Auto config
################################
OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE:.c=.o))
CFLAGS += -I $(INC_DIR)
PROJECT = $(OUT_DIR)/$(PROJECT_NAME)
################################
## Make config
################################
.DEFAULT_GOAL := all
################################
## Targets
################################
all: clean build
build: $(PROJECT)
$(PROJECT): $(OBJECTS)
@mkdir -p $(dir $@)
@echo $(LDPRINT)
@$(CC) -o $@ $(OBJECTS)
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c
@mkdir -p $(dir $@)
@echo $(CCPRINT)
@$(CC) -c $(CFLAGS) $< -o $@
clean:
@rm -rf $(BUILD_DIR)
@rm -rf $(OUT_DIR)
run:
@$(PROJECT) /dev/ttyUSB0 115200 1