forked from GerritRiesch94/libdoip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (48 loc) · 2.26 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
CXX = g++
CPPFLAGS = -g -Wall -Wextra -std=c++11
LDFLAGS = -shared
TESTFLAGS = -g -L/usr/lib -lgtest -lgtest_main -lpthread
SRCPATH = src
INCPATH = include
BUILDPATH = build
TESTPATH = test
COMMONTARGET = libdoipcommon
SERVERTARGET = libdoipserver
CLIENTTARGET = libdoipclient
# List of all source files, separated by whitespace
COMMONSOURCE = $(wildcard $(COMMONTARGET)/$(SRCPATH)/*.cpp)
SERVERSOURCE = $(wildcard $(SERVERTARGET)/$(SRCPATH)/*.cpp)
CLIENTSOURCE = $(wildcard $(CLIENTTARGET)/$(SRCPATH)/*.cpp)
TESTSOURCE = TestRunner.cpp
TESTSOURCE += $(wildcard $(COMMONTARGET)/test/*.cpp)
TESTSOURCE += $(wildcard $(SERVERTARGET)/test/*.cpp)
TESTSOURCE += $(wildcard $(CLIENTTARGET)/test/*.cpp)
COMMONOBJS = $(patsubst $(COMMONTARGET)/$(SRCPATH)/%.cpp, $(BUILDPATH)/%.o, $(COMMONSOURCE))
SERVEROBJS = $(patsubst $(SERVERTARGET)/$(SRCPATH)/%.cpp, $(BUILDPATH)/%.o, $(SERVERSOURCE))
CLIENTOBJS = $(patsubst $(CLIENTTARGET)/$(SRCPATH)/%.cpp, $(BUILDPATH)/%.o, $(CLIENTSOURCE))
.PHONY: all clean
all: env $(BUILDPATH)/$(COMMONTARGET).so $(BUILDPATH)/$(SERVERTARGET).so $(BUILDPATH)/$(CLIENTTARGET).so test
env:
mkdir -p $(BUILDPATH)
clean:
rm -rf $(BUILDPATH)/*.*
$(BUILDPATH)/%.o: $(COMMONTARGET)/$(SRCPATH)/%.cpp
$(CXX) $(CPPFLAGS) -I $(COMMONTARGET)/$(INCPATH) -fPIC -c $< -o $@
$(BUILDPATH)/%.o: $(SERVERTARGET)/$(SRCPATH)/%.cpp
$(CXX) $(CPPFLAGS) -I $(SERVERTARGET)/$(INCPATH) -I $(COMMONTARGET)/$(INCPATH) -fPIC -c $< -o $@
$(BUILDPATH)/%.o: $(CLIENTTARGET)/$(SRCPATH)/%.cpp
$(CXX) $(CPPFLAGS) -I $(CLIENTTARGET)/$(INCPATH) -I $(COMMONTARGET)/$(INCPATH) -fPIC -c $< -o $@
$(BUILDPATH)/$(COMMONTARGET).so: $(COMMONOBJS)
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@
$(BUILDPATH)/$(SERVERTARGET).so: $(SERVEROBJS)
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@
$(BUILDPATH)/$(CLIENTTARGET).so: $(CLIENTOBJS)
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@
test:
$(CXX) $(CPPFLAGS) -I $(COMMONTARGET)/$(INCPATH) -I $(SERVERTARGET)/$(INCPATH) -I $(CLIENTTARGET)/$(INCPATH) $(COMMONSOURCE) $(SERVERSOURCE) $(CLIENTSOURCE) -o runTest $(TESTSOURCE) $(TESTFLAGS)
install:
install -d /usr/lib/libdoip
install -d /usr/lib/libdoip/include
install build/*.so /usr/lib/libdoip
install libdoipcommon/include/*.h /usr/lib/libdoip/include
install libdoipserver/include/*.h /usr/lib/libdoip/include