-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.mongocxx
73 lines (59 loc) · 3.38 KB
/
Makefile.mongocxx
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
# -*- Makefile -*-
# ======================================================================
all: mongo-client-lib
include Makefile.config
ifneq (1,$(shell if [ "$$(cmake --version 2>/dev/null | grep version | cut -d ' ' -f 3 | cut -d '.' -f 1)" -lt 3 ]; then echo 0; else echo 1; fi))
$(error cmake 3.2 or later required)
endif
ifeq ($(PLATFORM),darwin)
SHARED_LIB_SUFFIX = dylib
PKG_CONFIG_PATH = /usr/local/opt/openssl/lib/pkgconfig
else
SHARED_LIB_SUFFIX = so
endif
MONGO_PREFIX = $(AD_ROOT)
MONGOC_DRIVER_LIB = $(MONGO_PREFIX)/lib/libmongoc-1.0.$(SHARED_LIB_SUFFIX)
MONGOCXX_DRIVER_LIB = $(MONGO_PREFIX)/lib/libmongocxx._noabi.$(SHARED_LIB_SUFFIX)
# cannot use 1.10+, it does not support mongodb2 used by acmacs-web
MONGOC_DRIVER_VERSION = 1.9.5
MONGOC_DRIVER_DIR = $(BUILD)/mongo-c-driver-$(MONGOC_DRIVER_VERSION)
MONGOCXX_DRIVER_BRANCH = releases/v3.2
MONGOCXX_DRIVER_DIR = $(BUILD)/mongo-cxx-driver
mongo-client-lib: $(MONGOCXX_DRIVER_LIB)
$(call symbolic_link_wildcard,$(MONGO_PREFIX)/include/*cxx,$(AD_INCLUDE))
$(call symbolic_link_wildcard,$(MONGO_PREFIX)/lib/lib*,$(AD_LIB))
$(MONGOC_DRIVER_LIB): $(MONGOC_DRIVER_DIR)/VERSION_CURRENT
echo Configuring mongo-c-driver-$(MONGOC_DRIVER_VERSION) for building $(MONGOC_DRIVER_LIB)
cd $(MONGOC_DRIVER_DIR) && env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) ./configure --disable-automatic-init-and-cleanup --with-libbson=bundled --with-snappy=no --prefix="$(MONGO_PREFIX)"
echo Building mongo-c-driver-$(MONGOC_DRIVER_VERSION)
$(MAKE) -C $(MONGOC_DRIVER_DIR) install
echo mongo-c-driver-$(MONGOC_DRIVER_VERSION) installed
$(MONGOC_DRIVER_DIR)/VERSION_CURRENT:
if [ ! -d $(MONGOC_DRIVER_DIR) ]; then \
echo Downloading mongo-c-driver-$(MONGOC_DRIVER_VERSION); \
mkdir -p $$(dirname $(MONGOC_DRIVER_DIR)) || exit 1; \
cd $$(dirname $(MONGOC_DRIVER_DIR)) || exit 1; \
/usr/bin/curl -L -s https://github.com/mongodb/mongo-c-driver/releases/download/$(MONGOC_DRIVER_VERSION)/mongo-c-driver-$(MONGOC_DRIVER_VERSION).tar.gz | tar xzf - || exit 1; \
fi
$(MONGOCXX_DRIVER_LIB): $(MONGOCXX_DRIVER_DIR)/CMakeLists.txt $(MONGOC_DRIVER_LIB)
export PKG_CONFIG_PATH=$(MONGO_PREFIX)/lib/pkgconfig:"$$PKG_CONFIG_PATH" && \
mkdir -p $(MONGOCXX_DRIVER_DIR)/build && \
cd $(MONGOCXX_DRIVER_DIR)/build && \
cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX="$(MONGO_PREFIX)" -DCMAKE_PREFIX_PATH="$(MONGO_PREFIX)" .. && \
$(MAKE) install && \
if [ "$$(uname)" = "Darwin" ]; then \
cd "$(MONGO_PREFIX)/lib" || exit 1; \
for library in libbsoncxx._noabi.dylib libmongocxx._noabi.dylib; do \
/usr/bin/install_name_tool -id "$(MONGO_PREFIX)/lib/$$library" "$$library" || exit 1; \
done; \
/usr/bin/install_name_tool -change "@rpath/libbsoncxx._noabi.dylib" "$(MONGO_PREFIX)/lib/libbsoncxx._noabi.dylib" "libmongocxx._noabi.dylib" || exit 1; \
fi && \
mkdir -p $(AD_BUILD)/include && \
if [ ! -d $(AD_BUILD)/include/bsoncxx ]; then ln -sv $(MONGO_PREFIX)/include/bsoncxx $(AD_BUILD)/include/bsoncxx; fi && \
if [ ! -d $(AD_BUILD)/include/mongocxx ]; then ln -sv $(MONGO_PREFIX)/include/mongocxx $(AD_BUILD)/include/mongocxx; fi
$(MONGOCXX_DRIVER_DIR)/CMakeLists.txt:
$(call git_clone_or_pull,$(MONGOCXX_DRIVER_DIR),https://github.com/mongodb,$(MONGOCXX_DRIVER_BRANCH))
# ======================================================================
### Local Variables:
### eval: (if (fboundp 'eu-rename-buffer) (eu-rename-buffer))
### End: