forked from greenplum-db/plcontainer-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
166 lines (138 loc) · 5.55 KB
/
Makefile
File metadata and controls
166 lines (138 loc) · 5.55 KB
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
#------------------------------------------------------------------------------
#
# Copyright (c) 2016-Present Pivotal Software, Inc
#
#------------------------------------------------------------------------------
MODULE_big = plcontainer
# for extension
EXTENSION = plcontainer
# Directories
SRCDIR = ./src
COMMONDIR = ./src/common
MGMTDIR = ./management
PYCLIENTDIR = src/pyclient/bin
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
FILES = $(shell find $(SRCDIR) -not -path "*client*" -type f -name "*.c")
OBJS = $(foreach FILE,$(FILES),$(subst .c,.o,$(FILE)))
PGXS := $(shell pg_config --pgxs)
include $(PGXS)
ifeq ($(PLC_PG),yes)
#reset CFLAGS for pg
override CFLAGS = -DPLC_PG -Wmissing-prototypes -Wpointer-arith -Wendif-labels -fno-strict-aliasing -fwrapv -g -O2 -DMAP_HUGETLB=0x40000 -fPIC
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
# Curl
CURL_CONFIG = $(shell type -p curl-config || echo no)
ifneq ($(CURL_CONFIG),no)
CURL_VERSION = $(shell $(CURL_CONFIG) --version | cut -d" " -f2)
VERSION_CHECK = $(shell expr $(CURL_VERSION) \>\= 7.40.0)
ifeq ($(VERSION_CHECK),1)
override CFLAGS += $(shell $(CURL_CONFIG) --cflags)
SHLIB_LINK = $(shell $(CURL_CONFIG) --libs)
else
$(error curl version is < 7.40, please update your libcurl installation.)
endif
else
$(error curl-config is not found, please check libcurl installation.)
endif
#libxml
LIBXML_CONFIG = $(shell which xml2-config || echo no)
ifneq ($(LIBXML_CONFIG),no)
override CFLAGS += $(shell xml2-config --cflags)
override SHLIB_LINK += $(shell xml2-config --libs)
else
$(error xml2-config is missing. Have you installed libxml? On RHEL/CENTOS you could install by runnning "yum install libxml2-devel" )
endif
#json-c
LIBJSON = $(shell pkg-config --libs json-c || echo no)
ifneq ($(LIBJSON),no)
override SHLIB_LINK += $(shell pkg-config --libs json-c)
override CFLAGS += $(shell pkg-config --cflags json-c)
else
$(error libjson-c.so is missing. Have you installed json-c? On RHEL/CENTOS you could install by running "yum install json-c-devel" )
endif
PLCONTAINERDIR = $(DESTDIR)$(datadir)/plcontainer
ifeq ($(PLC_PG),yes)
override CFLAGS += -Wextra -Wno-unused-but-set-variable
else
override CFLAGS += -Werror -Wextra -Wall
endif
ifeq ($(ENABLE_COVERAGE),yes)
override CFLAGS += -coverage
override SHLIB_LINK += -lgcov --coverage
override CLIENT_CFLAGS += -coverage -O0 -g
override CLIENT_LDFLAGS += -lgcov --coverage
else
override CLIENT_CFLAGS += -O3 -g
endif
# detected the docker API version, only for centos 6
RHEL_MAJOR_OS=$(shell cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*// | awk -F '.' '{print $$1}' )
ifeq ($(RHEL_MAJOR_OS), 6)
override CFLAGS += -DDOCKER_API_LOW
endif
all: all-lib build-clients
@echo "Build PL/Container Done."
install: all installdirs install-lib install-extra install-clients
clean: clean-clients clean-coverage
distclean: distclean-config
installdirs: installdirs-lib
$(MKDIR_P) '$(DESTDIR)$(bindir)'
$(MKDIR_P) '$(PLCONTAINERDIR)'
uninstall: uninstall-lib
rm -f '$(DESTDIR)$(bindir)/plcontainer'
rm -rf '$(PLCONTAINERDIR)'
.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' '$(PLCONTAINERDIR)/'
$(INSTALL_DATA) '$(MGMTDIR)/sql/plcontainer_uninstall.sql' '$(PLCONTAINERDIR)/'
.PHONY: install-clients
install-clients: build-clients
$(MKDIR_P) '$(DESTDIR)$(bindir)/plcontainer_clients'
cp $(PYCLIENTDIR)/* $(DESTDIR)$(bindir)/plcontainer_clients/
cp $(RCLIENTDIR)/* $(DESTDIR)$(bindir)/plcontainer_clients/
.PHONY: installcheck
installcheck:
$(MAKE) -C tests tests
.PHONY: build-clients
build-clients:
CC='$(CC)' CFLAGS='$(CLIENT_CFLAGS)' LDFLAGS='$(CLIENT_LDFLAGS)' $(MAKE) -C $(SRCDIR)/pyclient all
CC='$(CC)' CFLAGS='$(CLIENT_CFLAGS)' LDFLAGS='$(CLIENT_LDFLAGS)' $(MAKE) -C $(SRCDIR)/rclient all
.PHONY: clean-clients
clean-clients:
$(MAKE) -C $(SRCDIR)/pyclient clean
$(MAKE) -C $(SRCDIR)/rclient clean
.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