Skip to content

Commit

Permalink
Allow mongo-c and json-c drivers installation at custom locations.
Browse files Browse the repository at this point in the history
autogen.sh helps in avoiding manual installation and automates the
download and installation of the appropriate drivers and libraries
including mongo-c and json-c driver. But, these drivers get
installed at the default locations e.g. /usr/lib/, and user might
not have permission to write in this directory. This results in
autogen.sh failure. Use environment variables MONGOC_INSTALL_DIR
and JSONC_INSTALL_DIR in autogen.sh to set CMAKE_INSTALL_PREFIX to
allow custom directory installation for these drivers where the user
might have permission.

Reported on GitHub through issue #152 by user pgloader.

FDW-406, Vaibhav Dalvi, reviewed by Jeevan Ladhe,
tested by Rajkumar Raghuwanshi.
  • Loading branch information
jeevanladhe committed Sep 10, 2021
1 parent 3d43081 commit 434b47a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,34 @@ different type of MongoDB drivers and supported libraries. If you want
to avoid the manual steps, there is a shell script available which will
download and install the appropriate drivers and libraries for you.

Here is how it works :
Here is how it works:

To install mongo-c and json-c libraries at custom locations, you need to
export environment variables `MONGOC_INSTALL_DIR` and `JSONC_INSTALL_DIR`
respectively. If these variables are not set then these libraries will be
installed in the default location. Please note that you need to have the
required permission to install the directory whether it is custom or default.

The `PKG_CONFIG_PATH` environment variable must be set to mongo-c-driver source
directory for successful compilation as shown below,

```sh
export PKG_CONFIG_PATH=$YOUR_MONGO_FDW_SOURCE_DIR/mongo-c-driver/src/libmongoc/src:$YOUR_MONGO_FDW_SOURCE_DIR/mongo-c-driver/src/libbson/src
```

The `LD_LIBRARY_PATH` environment variable must include the path to the mongo-c
installation directory containing the libmongoc-1.0.so and libbson-1.0.so
files. For example, assuming the installation directory is /home/mongo-c and
the libraries were created under it in lib64 sub-directory, then we can define
the `LD_LIBRARY_PATH` as:

```sh
export LD_LIBRARY_PATH=/home/mongo-c/lib64:$LD_LIBRARY_PATH
```

Note: This `LD_LIBRARY_PATH` environment variable setting must be in effect
when the `pg_ctl` utility is executed to start or restart PostgreSQL or
EDB Postgres Advanced Server.

Build with [MongoDB][1]'s legacy branch driver
* autogen.sh --with-legacy
Expand Down
6 changes: 4 additions & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

MONGOC_VERSION=1.17.3
JSONC_VERSION=0.15-20200726
MONGOC_INSTALL="${MONGOC_INSTALL_DIR}"
JSONC_INSTALL="${JSONC_INSTALL_DIR}"

if [ "$#" -ne 1 ]; then
echo "Usage: autogen.sh --[with-legacy | with-master]"
Expand Down Expand Up @@ -71,7 +73,7 @@ function checkout_json_lib
function install_json_lib
{
cd json-c &&
$CMAKE_COMMAND $JSONC_CFLAGS . &&
$CMAKE_COMMAND -DCMAKE_INSTALL_PREFIX=$JSONC_INSTALL $JSONC_CFLAGS . &&
make install &&
cd ..
}
Expand All @@ -82,7 +84,7 @@ function install_json_lib
function install_mongoc_driver
{
cd mongo-c-driver &&
$CMAKE_COMMAND -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_SSL=AUTO . &&
$CMAKE_COMMAND -DCMAKE_INSTALL_PREFIX=$MONGOC_INSTALL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_SSL=AUTO . &&
make install &&
cd ..
}
Expand Down

0 comments on commit 434b47a

Please sign in to comment.