-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
88 lines (66 loc) · 1.94 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 编译器
CROSS_COMPILE :=
# 编译器在编译时的参数设置
CFLAGS := -Wall -Wno-unused-function -Werror -O2 -g
# 添加头文件路径
CFLAGS += -I$(PWD) -I./onvif -I./client -I./soap -I./com
# 链接器的链接参数设置 比如库文件
LDFLAGS := -lpthread
EXTRA_CFLAGS := -DSOAP_DEBUG
# 添加项目中所有用到的源文件,如.c文件,子文件夹(格式/*.c)
# 添加到库中的源文件
lib-y :=
# 添加到可执行程序中的源文件
obj-y :=
# com
obj-y += com/log.c
# client personal src
obj-y += client/onvif_cli_discovery.cpp
# onvif src
obj-y += onvif/soapC.cpp
obj-y += onvif/soapwsddProxy.cpp
# obj-y += onvif/soapwsddService.cpp
# soap src
# obj-y += soap/chrono_duration.cpp
# obj-y += soap/duration.c
obj-y += soap/stdsoap2.cpp
# obj-y += soap/wsdlC.cpp
obj-y += soap/dom.cpp
# demo
obj-y += demo/main.cpp
# build目录
BUILD_PATH = build
# 可执行程序名称
TARGET ?= test
# 库名称
LIB ?=
#展开为.o文件 增加build目录信息
TARGET := $(BUILD_PATH)/$(TARGET)
lib-y := $(wildcard $(lib-y))
lib-y := $(patsubst %.c, $(BUILD_PATH)/%.c.o, $(lib-y))
lib-y := $(patsubst %.cpp, $(BUILD_PATH)/%.cpp.o, $(lib-y))
obj-y := $(wildcard $(obj-y))
obj-y := $(patsubst %.c, $(BUILD_PATH)/%.c.o, $(obj-y))
obj-y := $(patsubst %.cpp, $(BUILD_PATH)/%.cpp.o, $(obj-y))
dep_files := $(patsubst %.o,%.d, $(lib-y) $(obj-y))
#规则
.PHONY: clean all lib target
all : target
lib : $(lib-y)
ifneq ($(lib-y),)
@$(CROSS_COMPILE)ar crs $(BUILD_PATH)/lib$(LIB).a $(lib-y)
@echo $(LIB) generate succeed!
endif
$(BUILD_PATH)/%.c.o : %.c
@mkdir -p $(dir $@)
$(CROSS_COMPILE)gcc $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< -MMD -MP
$(BUILD_PATH)/%.cpp.o : %.cpp
@mkdir -p $(dir $@)
$(CROSS_COMPILE)c++ $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< -MMD -MP
target : $(obj-y)
ifneq ($(obj-y),)
$(CROSS_COMPILE)g++ -o $(TARGET) $(obj-y) $(LDFLAGS)
endif
clean:
rm -rf $(BUILD_PATH)
-include $(dep_files) #必须放到后面,暂不清楚原因