forked from Beckhoff/ADS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (65 loc) · 2.12 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
$(warning ATTENTION make is deprecated and superseeded by meson)
OS_NAME ?= $(shell uname)
VPATH = AdsLib
LIB_NAME = AdsLib-$(OS_NAME).a
OBJ_DIR = obj
CXX :=$(CROSS_COMPILE)$(CXX)
CXXFLAGS += -std=c++11
CXXFLAGS += -pedantic
CXXFLAGS += -Wall
CXXFLAGS += -Wextra
CXXFLAGS += -D_GNU_SOURCE
CXXFLAGS += $(ci_cxx_flags)
CPPFLAGS += -I AdsLib/
CPPFLAGS += -I tools/
Tc$(LIB_NAME): CPPFLAGS += -DUSE_TWINCAT_ROUTER
Tc$(LIB_NAME): CPPFLAGS += -I/usr/local/include
SRC_FILES += AdsDef.cpp
SRC_FILES += AdsDevice.cpp
SRC_FILES += AdsFile.cpp
SRC_FILES += Log.cpp
SRC_FILES += Sockets.cpp
SRC_FILES += Frame.cpp
OBJ_FILES = $(SRC_FILES:%.cpp=$(OBJ_DIR)/%.o)
# simple router implementation required for systems without TwinCAT
ROUTER_FILES += standalone/AdsLib.cpp
ROUTER_FILES += standalone/AmsConnection.cpp
ROUTER_FILES += standalone/AmsNetId.cpp
ROUTER_FILES += standalone/AmsPort.cpp
ROUTER_FILES += standalone/AmsRouter.cpp
ROUTER_FILES += standalone/NotificationDispatcher.cpp
ROUTER_OBJ = $(ROUTER_FILES:%.cpp=$(OBJ_DIR)/%.o)
# some extensions to use AdsLib objects with TwinCAT router
TWINCAT_FILES += TwinCAT/AdsLib.cpp
TWINCAT_OBJ = $(TWINCAT_FILES:%.cpp=$(OBJ_DIR)/%.o)
LDFLAGS += -lpthread
LDFLAGS_Darwin += -lc++
LDFLAGS_win32 += -lws2_32
LDFLAGS += $(LDFLAGS_$(OS_NAME))
all: $(LIB_NAME)
$(OBJ_DIR):
mkdir -p $@/standalone
mkdir -p $@/TwinCAT
$(OBJ_DIR)/%.o: %.cpp | $(OBJ_DIR)
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(LIB_NAME): $(OBJ_FILES) $(ROUTER_OBJ)
$(AR) rvs $@ $^
Tc$(LIB_NAME): $(OBJ_FILES) $(TWINCAT_OBJ)
$(AR) rvs $@ $^
AdsLibTest.bin: AdsLibTest/main.cpp $(LIB_NAME)
$(CXX) $^ $(LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@
AdsLibOOITest.bin: AdsLibOOITest/main.cpp $(LIB_NAME)
$(CXX) $^ $(LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@
test: AdsLibTest.bin
./$<
testOOI: AdsLibOOITest.bin
./$<
clean:
rm -rf *.a *.o *.bin AdsLib*Test/*.o $(OBJ_DIR)
uncrustify:
find AdsLib* example -name *.h -or -name *.cpp | uncrustify --no-backup -c tools/uncrustify.cfg -F -
prepare-hooks:
rm -f .git/hooks/pre-commit
ln -Fv tools/pre-commit.uncrustify .git/hooks/pre-commit
chmod a+x .git/hooks/pre-commit
.PHONY: clean uncrustify prepare-hooks