forked from EnterpriseDB/mongo_fdw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen.sh
executable file
·126 lines (113 loc) · 2.59 KB
/
autogen.sh
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
#! /bin/bash
#-------------------------------------------------------------------------
#
# autogen.sh
# Foreign-data wrapper for remote MongoDB servers
#
# Portions Copyright (c) 2012-2014, PostgreSQL Global Development Group
#
# Portions Copyright (c) 2004-2014, EnterpriseDB Corporation.
#
# IDENTIFICATION
# autogen.sh
#
#-------------------------------------------------------------------------
MONGOC_VERSION=1.9.5
JSONC_VERSION=0.13.1-20180305
if [ "$#" -ne 1 ]; then
echo "Usage: autogen.sh --[with-legacy | with-master]"
exit
fi
###
# Pull the latest version of Monggo C Driver's master branch
#
function checkout_mongo_driver
{
rm -rf mongo-c-driver
wget https://github.com/mongodb/mongo-c-driver/releases/download/$MONGOC_VERSION/mongo-c-driver-$MONGOC_VERSION.tar.gz
tar -zxf mongo-c-driver-$MONGOC_VERSION.tar.gz
mv mongo-c-driver-$MONGOC_VERSION mongo-c-driver
rm -rf mongo-c-driver-$MONGOC_VERSION.tar.gz
}
###
# Pull the legacy branch from the Mongo C Driver's
#
function checkout_legacy_branch
{
rm -rf mongo-c-driver
wget https://github.com/mongodb/mongo-c-driver/archive/v0.8.tar.gz
tar -zxf v0.8.tar.gz
mv mongo-c-driver-0.8 mongo-c-driver
rm -rf v0.8.tar.gz
}
##
# Pull the json-c library
#
function checkout_json_lib
{
echo $PWD
rm -rf json-c
wget https://github.com/json-c/json-c/archive/json-c-$JSONC_VERSION.tar.gz
tar -zxf json-c-$JSONC_VERSION.tar.gz
mv json-c-json-c-$JSONC_VERSION json-c
rm -rf json-c-$JSONC_VERSION.tar.gz
echo $PWD
}
##
# Compile and instal json-c library
#
function install_json_lib
{
cd json-c
sh ./autogen.sh
./configure CFLAGS='-fPIC'
make install
cd ..
}
###
# Configure and install the Mongo C Driver and libbson
#
function install_mongoc_driver
{
cd mongo-c-driver
./configure --with-libbson=auto --enable-ssl
make install
cd ..
}
###
# Cleanup the system
#
function cleanup
{
rm -f config.h
touch config.h
}
###
# Create a config file and append #define META_DRIVER which will be
# used in case of Meta Driver (master branch) option.
#
function create_config
{
echo "#ifdef __CONFIG__" >> config.h
echo "#define META_DRIVER" >> config.h
echo "#endif" >> config.h
}
cleanup
if [ "--with-legacy" = $1 ]; then
checkout_json_lib
checkout_legacy_branch
install_json_lib
cp Makefile.legacy Makefile
echo "Done"
elif [ "--with-master" == $1 ]; then
checkout_mongo_driver
checkout_json_lib
install_mongoc_driver
install_json_lib
create_config
export PKG_CONFIG_PATH=mongo-c-driver/src/:mongo-c-driver/src/libbson/src
cp Makefile.meta Makefile
echo "Done"
else
echo "Usage: autogen.sh --[with-legacy | with-master]"
fi