-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
109 lines (89 loc) · 3.08 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
BUILD = build
BUILD_TEST_BIN = utest
ifeq ($(LANG),) #windows
INSTALLDIR = install
LDFLAGS = -static-libgcc -static-libstdc++ -L./lib -L./
LIBS = ./lib/win/libsqlite3_win64.a ./lib/win/libssl.a ./lib/win/libcrypto.a ./lib/win/libgdi32.a -lwsock32 -lwinmm -lpacket -lwpcap -lws2_32 -lIPHLPAPI ./lib/win/libgmp.a
INCLUDE = -IC:\openssl-1.0.2e\win64\include -ID:\winlib\winpcap\Include
else #linux
$(shell if [ ! -d $(BUILD)/$(BUILD_TEST_BIN) ]; then mkdir -p $(BUILD)/$(BUILD_TEST_BIN); fi;)
INSTALLDIR = /usr/local/superoneproxy/
LDFLAGS =
OPENSSL = /usr/local/openssl
LIBEV = /usr/local/libev
LIBPCAP = /usr/local/libpcap
# -lprofiler -lunwind ./lib/libtcmalloc_minimal.a
LIBS = -pthread ./lib/libtcmalloc_minimal.a ./stats/database/libsqlite3.a ./lib/libgmp.a $(OPENSSL)/lib/libssl.a $(OPENSSL)/lib/libcrypto.a $(LIBEV)/lib/libev.a $(LIBPCAP)/lib/libpcap.a -ldl
INCLUDE = -I$(OPENSSL)/include -I$(LIBEV)/include -I$(LIBPCAP)/include
endif
CXXFLAGS = -Wall -Wformat=0 -Wno-strict-aliasing -g
APPSOURCEDIR = ./sql \
./util \
./conf \
./stats \
./stats/database/ \
./stats/database/tab \
./monitor \
./httpserver \
./iomultiplex \
./protocol \
./protocol/fake \
./protocol/sqlserver \
./protocol/postgresql \
./commercial
TESTSOURCEDIR = ./test/ ./unittest/
SOURCEDIR = $(TESTSOURCEDIR) $(APPSOURCEDIR)
VPATH = ./
VPATH += $(foreach tdir, $(SOURCEDIR), :$(tdir))
DIR = -I./.
DIR += $(foreach tdir, $(SOURCEDIR), -I$(tdir))
DIR += $(INCLUDE)
MAIN_SOURCES = main.cpp
SOURCES = $(filter-out $(MAIN_SOURCES), $(wildcard *.cpp))
SOURCES += $(foreach tdir, $(APPSOURCEDIR), $(filter-out $(MAIN_SOURCES), $(wildcard $(tdir)/*.cpp)))
CSOURCES = $(foreach tdir, $(APPSOURCEDIR), $(filter-out $(MAIN_SOURCES), $(wildcard $(tdir)/*.c)))
HEADERS = $(wildcard ./*.h)
HEADERS += $(foreach tdir, $(APPSOURCEDIR), $(wildcard $(tdir)/*.h))
ifeq ($(MAKECMDGOALS), test)
SOURCES += $(wildcard test/*.cpp) $(wildcard unittest/*.cpp)
HEADERS += $(wildcard test/*.h) $(wildcard unittest/*.h)
CXXFLAGS += -Dprivate=public -Dprojected=public -g
else
SOURCES += $(MAIN_SOURCES)
CXXFLAGS += -O2
endif
OBJS = $(patsubst %.cpp, $(BUILD)/%.o, $(notdir $(SOURCES)))
COBJS = $(patsubst %.c, $(BUILD)/%.o, $(notdir $(CSOURCES)))
ifeq ($(MAKECMDGOALS), test)
ifeq ($(LANG),)
TARGET = $(BUILD)/$(BUILD_TEST_BIN)/unittest_main.exe
else
TARGET = $(BUILD)/$(BUILD_TEST_BIN)/unittest_main
endif
else
ifeq ($(LANG),)
TARGET = $(BUILD)/oneproxy-for-sqlserver.exe
else
TARGET = $(BUILD)/oneproxy-for-sqlserver
endif
endif
.PHONY: all
all: $(TARGET)
$(OBJS): $(BUILD)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $(DIR) $< -o $@
$(COBJS): $(BUILD)/%.o: %.c
$(CXX) $(CXXFLAGS) -c $(DIR) $< -o $@
$(TARGET): $(OBJS) $(COBJS)
$(CXX) $(LDFLAGS) -o $(TARGET) $(OBJS) $(COBJS) $(LIBS)
.PHONY: test
test: $(TARGET)
install:
-@mkdir $(INSTALLDIR)
-@mkdir $(INSTALLDIR)/include/
-@mkdir $(INSTALLDIR)/include/conf/
-@echo $(HEADERS)
-@cp -rf $(HEADERS) $(INSTALLDIR)/include/
-@cp -rf conf/config.h $(INSTALLDIR)/include/conf/
-@cp -rf $(TARGET) $(INSTALLDIR)/bin/
clean:
-@rm $(BUILD)/*.o $(TARGET)