forked from greenplum-db/plcontainer-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
200 lines (162 loc) · 6.76 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#------------------------------------------------------------------------------
#
# Copyright (c) 2016-Present Pivotal Software, Inc
#
#------------------------------------------------------------------------------
MODULE_big = plcontainer
# for extension
EXTENSION = plcontainer
# Directories
SRCDIR = ./src
MGMTDIR = ./management
RCLIENTDIR = src/rclient/bin
# the DATA is including files for extension use
DATA = $(MGMTDIR)/sql/plcontainer--1.0.0.sql $(MGMTDIR)/sql/plcontainer--unpackaged--1.0.0.sql plcontainer.control
ifeq ($(PLC_PG),yes)
$(shell cd $(MGMTDIR)/sql/ && ln -sf plcontainer_pg--1.0.0.sql plcontainer_install.sql.in )
$(shell cd $(MGMTDIR)/sql/ && cp -f plcontainer_pg--1.0.0.sql plcontainer--1.0.0.sql )
else
$(shell cd $(MGMTDIR)/sql/ && ln -sf plcontainer_gp--1.0.0.sql plcontainer_install.sql.in )
$(shell cd $(MGMTDIR)/sql/ && cp -f plcontainer_gp--1.0.0.sql plcontainer--1.0.0.sql )
endif
# DATA_built will built sql from .in file
DATA_built = $(MGMTDIR)/sql/plcontainer_install.sql $(MGMTDIR)/sql/plcontainer_uninstall.sql
# Files to build
# TODO: clean docker out from plcontainer
FILES = src/function_cache.c src/plcontainer.c \
src/containers.c src/message_fns.c src/plc_configuration.c src/plc_docker_api.c \
src/plc_typeio.c \
src/common/comm_connectivity.c src/common/comm_messages.c src/common/comm_dummy_plc.c
OBJS = $(foreach FILE,$(FILES),$(subst .c,.o,$(FILE)))
CXX_FILES=src/proto/client.cc src/proto/proto_utils.cc src/proto/plcontainer.pb.cc src/proto/plcontainer.grpc.pb.cc src/docker/docker_client.cc src/docker/plc_docker.cc
OBJS += $(foreach FILE,$(CXX_FILES),$(subst .cc,.o,$(FILE)))
PROTO_PREFIX=plcontainer
PROTO_FILE=$(PROTO_PREFIX).proto
PROTO_CXX_FILES=src/proto/$(PROTO_PREFIX).pb.cc src/proto/$(PROTO_PREFIX).grpc.pb.cc
PROTOC=protoc
GRPC_CPP_PLUGIN=grpc_cpp_plugin
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
PGXS := $(shell pg_config --pgxs)
include $(PGXS)
ifeq ($(PLC_PG),yes)
override CFLAGS += -DPLC_PG
# override CFLAGS += -DPLC_PG -Wno-sign-compare
endif
# FIXME: We might need a configure script to handle below checks later.
# See https://github.com/greenplum-db/plcontainer/issues/322
# Plcontainer version
PLCONTAINER_VERSION = $(shell git describe)
ifeq ($(PLCONTAINER_VERSION),)
$(error can not determine the plcontainer version)
else
ver = \#define PLCONTAINER_VERSION \"$(PLCONTAINER_VERSION)\"
$(shell if [ ! -f src/common/config.h ] || [ "$(ver)" != "`cat src/common/config.h`" ]; then echo "$(ver)" > src/common/config.h; fi)
endif
PLCONTAINERDIR = $(DESTDIR)$(datadir)/plcontainer
INCLUDE_DIR = $(SRCDIR)/include
override CFLAGS += -Wextra -Wall -Wno-sign-compare -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/proto
override CFLAGS += $(shell xml2-config --cflags)
CXXFLAGS += $(subst -fexcess-precision=standard,,$(subst -Wmissing-prototypes,,$(subst -std=gnu99,,$(CFLAGS)))) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/proto
override SHLIB_LINK += $(shell pkg-config --libs json-c)
override SHLIB_LINK += $(shell xml2-config --libs)
override SHLIB_LINK += $(shell curl-config --libs)
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
SYSTEM ?= $(HOST_SYSTEM)
CXX = g++
#CPPFLAGS += `pkg-config --cflags protobuf grpc`
CXXFLAGS += -std=c++11
override SHLIB_LINK += -lstdc++
ifeq ($(SYSTEM),Darwin)
#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`
override SHLIB_LINK += -L/usr/local/lib -lprotobuf -lgrpc++\
-lgrpc++_reflection\
-ldl
else
#LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++`
override SHLIB_LINK += -L/usr/local/lib -lprotobuf -lgrpc++\
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\
-ldl
endif
ifeq ($(ENABLE_COVERAGE),yes)
override CFLAGS += -coverage
override SHLIB_LINK += -lgcov --coverage
endif
all: proto coordinator all-lib
@echo "Build PL/Container Done."
install: all install-coordinator installdirs install-lib install-extra install-clients
clean: clean-clients clean-coverage clean-proto clean-coordinator
distclean: distclean-config
.PHONY: coordinator
coordinator:
$(MAKE) -C $(SRCDIR)/
clean-coordinator:
$(MAKE) -C $(SRCDIR)/ clean
.PHONY: install-coordinator
install-coordinator:
$(MAKE) -C $(SRCDIR)/ install
installdirs: installdirs-lib
$(MKDIR_P) '$(DESTDIR)$(bindir)'
$(MKDIR_P) '$(PLCONTAINERDIR)'
uninstall: uninstall-lib
rm -f '$(DESTDIR)$(bindir)/plcontainer'
rm -rf '$(PLCONTAINERDIR)'
.PHONY: proto
proto:
@echo "Generating protobuf and grpc files."
$(PROTOC) -I src --grpc_out=src/proto --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $(PROTO_FILE)
$(PROTOC) -I src --cpp_out=src/proto $(PROTO_FILE)
mv src/proto/$(PROTO_PREFIX).pb.h src/include/proto/
mv src/proto/$(PROTO_PREFIX).grpc.pb.h src/include/proto/
@echo "Finish protobuf and grpc."
.PHONY: clean-proto
clean-proto:
rm -f src/include/proto/$(PROTO_PREFIX).pb.h
rm -f src/include/proto/$(PROTO_PREFIX).grpc.pb.h
rm -f src/proto/$(PROTO_PREFIX).pb.cc
rm -f src/proto/$(PROTO_PREFIX).grpc.pb.cc
.PHONY: install-extra
install-extra: installdirs
$(INSTALL_PROGRAM) '$(MGMTDIR)/bin/plcontainer' '$(DESTDIR)$(bindir)/plcontainer'
$(INSTALL_DATA) '$(MGMTDIR)/config/plcontainer_configuration.xml' '$(PLCONTAINERDIR)/'
$(INSTALL_DATA) '$(MGMTDIR)/sql/plcontainer_install.sql.in' '$(PLCONTAINERDIR)/plcontainer_install.sql'
$(INSTALL_DATA) '$(MGMTDIR)/sql/plcontainer_uninstall.sql.in' '$(PLCONTAINERDIR)/plcontainer_uninstall.sql'
.PHONY: install-clients
install-clients:
$(MKDIR_P) '$(DESTDIR)$(bindir)/plcontainer_clients'
cp $(RCLIENTDIR)/* $(DESTDIR)$(bindir)/plcontainer_clients/
.PHONY: installcheck
installcheck:
$(MAKE) -C tests tests
.PHONY: build-clients
build-clients:
$(MAKE) -C $(SRCDIR)/rclient all
.PHONY: clean-clients
clean-clients:
$(MAKE) -C $(SRCDIR)/rclient clean
.PHONY: docker-dep
docker-dep:
@if [ ! -d $(INCLUDE_DIR)/rapidjson ];\
then \
echo "rapidjson does not exist, fetching"; \
git clone --branch v1.1.0 --depth 1 https://github.com/Tencent/rapidjson.git; \
mv rapidjson/include/rapidjson $(INCLUDE_DIR)/rapidjson; \
rm -rf rapidjson; \
fi
.PHONY: test-docker
test-docker: docker-dep
$(CXX) $(CXXFLAGS) -c src/docker/docker_client.cc -o docker_client.o -g -O0 $(CXXFLAGS)
$(CXX) $(CXXFLAGS) -c tests/docker_client/docker_client_test.cc -o docker_client_test.o -g -O0 $(CXXFLAGS)
$(CXX) $(CXXFLAGS) -o tests/docker_client/test docker_client.o docker_client_test.o -g -O0 $(CXXFLAGS) -lcurl
rm docker_client.o docker_client_test.o
.PHONY: clean-coverage
clean-coverage:
rm -f `find . -name '*.gcda' -print`
rm -f `find . -name '*.gcno' -print`
rm -rf coverage.info coverage_result
.PHONY: distclean-config
distclean-config:
rm -f src/common/config.h
.PHONY: coverage-report
coverage-report:
lcov -c -o coverage.info -d .
genhtml coverage.info -o coverage_result