-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
116 lines (88 loc) · 3.19 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
110
111
112
113
114
115
116
RPATH = /usr/local/gpstall/lib/
LFLAGS = -Wl,-rpath=$(RPATH)
UNAME := $(shell if [ -f "/etc/redhat-release" ]; then echo "CentOS"; else echo "Ubuntu"; fi)
ifeq ($(UNAME), CentOS)
OSVERSION := $(shell cat /etc/redhat-release | cut -d "." -f 1 | awk '{print $$NF}')
endif
ifeq ($(UNAME), Ubuntu)
$(shell mkdir -p $(CURDIR)/lib/ubuntu)
SO_PATH = $(CURDIR)/lib/ubuntu
else ifeq ($(OSVERSION), 5)
$(shell mkdir -p $(CURDIR)/lib/5.4)
SO_PATH = $(CURDIR)/lib/5.4
else
$(shell mkdir -p $(CURDIR)/lib/6.2)
SO_PATH = $(CURDIR)/lib/6.2
endif
CXX = g++
ifeq ($(__REL), 1)
#CXXFLAGS = -Wall -W -DDEBUG -g -O0 -D__XDEBUG__ -fPIC -Wno-unused-function -std=c++11
CXXFLAGS = -O2 -g -pipe -fPIC -W -DNDEBUG -Wwrite-strings -Wpointer-arith -Wreorder -Wswitch -Wsign-promo -Wredundant-decls -Wformat -Wall -Wno-unused-parameter -D_GNU_SOURCE -D__STDC_FORMAT_MACROS -std=c++11 -gdwarf-2 -Wno-redundant-decls
else
CXXFLAGS = -O0 -g -gstabs+ -pg -pipe -fPIC -W -D__XDEBUG__ -DDEBUG -Wwrite-strings -Wpointer-arith -Wreorder -Wswitch -Wsign-promo -Wredundant-decls -Wformat -Wall -Wno-unused-parameter -D_GNU_SOURCE -D__STDC_FORMAT_MACROS -std=c++11 -Wno-redundant-decls
endif
SRC_PATH = ./src/
THIRD_PATH = ./third
SCRIPT_PATH = ./script
OUTPUT = ./output
TOOLS_PATH = ./tools
SRC = $(wildcard $(SRC_PATH)/*.cc)
TOOLS_SRC = $(wildcard $(TOOLS_PATH)/*.cc)
OBJS = $(patsubst %.cc,%.o,$(SRC))
TOOLS_OBJS = $(patsubst %.cc,%.o,$(TOOLS_SRC))
BIN = gpstall
TOOLS_BIN = stall_status
INCLUDE_PATH = -I./include/ \
-I./src/ \
-I$(THIRD_PATH)/glog/src/ \
-I$(THIRD_PATH)/slash/output/include/ \
-I$(THIRD_PATH)/pink/output/ \
-I$(THIRD_PATH)/pink/output/include
LIB_PATH = -L./ \
-L$(THIRD_PATH)/slash/output/lib/ \
-L$(THIRD_PATH)/pink/output/lib/ \
-L$(THIRD_PATH)/glog/.libs/
LIBS = -lpthread \
-lglog \
-lslash \
-lprotobuf \
-lpink
GLOG = $(THIRD_PATH)/glog/.libs/libglog.so.0
PINK = $(THIRD_PATH)/pink/output/lib/libpink.a
SLASH = $(THIRD_PATH)/slash/output/lib/libslash.a
.PHONY: all clean
all: $(BIN) $(TOOLS_BIN)
rm -rf $(OUTPUT)
mkdir $(OUTPUT)
mkdir $(OUTPUT)/bin
cp -r ./conf $(OUTPUT)
mkdir $(OUTPUT)/lib
cp -r $(SO_PATH)/* $(OUTPUT)/lib
mv $(BIN) $(OUTPUT)/bin/
mv $(TOOLS_BIN) $(OUTPUT)/bin/
cp $(SCRIPT_PATH)/load.sh $(OUTPUT)/bin/
cp $(SCRIPT_PATH)/gpload.yaml.ori $(OUTPUT)/bin/
cp $(SCRIPT_PATH)/gpload.py $(OUTPUT)/bin/
@echo "Success, go, go, go..."
$(BIN): $(GLOG) $(PINK) $(SLASH) $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(INCLUDE_PATH) $(LIB_PATH) $(LFLAGS) $(LIBS)
$(OBJS): %.o : %.cc
$(CXX) $(CXXFLAGS) $(INCLUDE_PATH) -c $< -o $@
$(TOOLS_BIN): $(PINK) $(SLASH) $(TOOLS_OBJS)
$(CXX) $(CXXFLAGS) -o $@ $(TOOLS_OBJS) $(INCLUDE_PATH) $(LIB_PATH) $(LFLAGS) $(LIBS)
$(TOOLS_OBJS): %.o : %.cc
$(CXX) $(CXXFLAGS) $(INCLUDE_PATH) -c $< -o $@
$(SLASH):
make -C $(THIRD_PATH)/slash/
$(PINK):
make -C $(THIRD_PATH)/pink/
$(GLOG):
#if [ -d $(THIRD_PATH)/glog/.libs ]; then
if [ ! -f $(GLOG) ]; then \
cd $(THIRD_PATH)/glog; \
autoreconf -ivf; ./configure; make; echo '*' > $(CURDIR)/third/glog/.gitignore; cp $(CURDIR)/third/glog/.libs/libglog.so.0 $(SO_PATH); \
fi;
clean:
rm -rf $(SRC_PATH)/*.o
rm -rf $(OUTPUT)
rm -rf $(TOOLS_PATH)/*.o