-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (32 loc) · 866 Bytes
/
Makefile
File metadata and controls
40 lines (32 loc) · 866 Bytes
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
# 设置编译器
CC = gcc
# 设置包含路径
CFLAGS += -I common \
-I mqttclient/include \
-I coreMqtt \
-I platform/linux \
-I platform/linux/valloc
# 设置编译选项
CFLAGS += -Wall -Wno-unused-parameter -Wformat=2
# 搜索所有C源文件
SRCS = $(wildcard ./test/*.c)
SRCS += $(wildcard ./common/*.c)
SRCS += $(wildcard ./platform/linux/*.c)
SRCS += $(wildcard ./platform/linux/valloc/*.c)
SRCS += $(wildcard ./mqttclient/*.c)
SRCS += $(wildcard ./coreMqtt/*.c)
# 定义目标文件和输出文件
OBJS = $(patsubst %.c,%.o,$(SRCS))
TARGET = app.o
# 默认目标
all: $(TARGET)
# 链接所有对象文件生成最终二进制文件
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@ -lm -lpthread
# 编译规则
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# 清理生成的文件
.PHONY: clean
clean:
rm -f $(OBJS) $(TARGET)