Added R methods and their c counterparts for connection and database management
This commit is contained in:
81
configure
vendored
Executable file
81
configure
vendored
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
# Anticonf script by Jeroen Ooms (2020)
|
||||
# The script will try 'mariadb_config' and 'mysql_config' to find required
|
||||
# cflags and ldflags. Make sure this executable is in PATH when installing
|
||||
# the package. Alternatively, you can set INCLUDE_DIR and LIB_DIR manually:
|
||||
# R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'
|
||||
|
||||
# Library settings
|
||||
PKG_DEB_NAME="libmariadbclient-dev | libmariadb-client-lgpl-dev"
|
||||
PKG_RPM_NAME="mariadb-connector-c-devel | mariadb-devel | mysql-devel"
|
||||
PKG_CSW_NAME="mysql56_dev"
|
||||
PKG_BREW_NAME="mariadb-connector-c"
|
||||
PKG_TEST_HEADER="<mysql.h>"
|
||||
PKG_LIBS="-lmysqlclient"
|
||||
|
||||
# Use mysql_config (on Solaris /opt/csw/bin must be in PATH)
|
||||
if [ $(command -v mariadb_config) ]; then
|
||||
PKGCONFIG_CFLAGS=$(mariadb_config --cflags)
|
||||
PKGCONFIG_LIBS=$(mariadb_config --libs)
|
||||
elif [ $(command -v mysql_config) ]; then
|
||||
PKGCONFIG_CFLAGS=$(mysql_config --cflags)
|
||||
PKGCONFIG_LIBS=$(mysql_config --libs)
|
||||
fi
|
||||
|
||||
# Note that cflags may be empty in case of success
|
||||
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
|
||||
echo "Found INCLUDE_DIR and/or LIB_DIR!"
|
||||
PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
|
||||
PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
|
||||
elif [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
|
||||
echo "Found mysql_config cflags and libs!"
|
||||
PKG_CFLAGS=${PKGCONFIG_CFLAGS}
|
||||
PKG_LIBS=${PKGCONFIG_LIBS}
|
||||
# Workaround for homebrew linkin bug
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
PKG_LIBS="-L/usr/local/opt/openssl/lib $PKG_LIBS"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if [ $(command -v brew) ]; then
|
||||
BREWDIR=$(brew --prefix)
|
||||
else
|
||||
curl -sfL "https://jeroen.github.io/autobrew/$PKG_BREW_NAME" > autobrew
|
||||
source autobrew
|
||||
fi
|
||||
fi
|
||||
|
||||
# Find compiler
|
||||
CC=$(${R_HOME}/bin/R CMD config CC)
|
||||
CFLAGS=$(${R_HOME}/bin/R CMD config CFLAGS)
|
||||
CPPFLAGS=$(${R_HOME}/bin/R CMD config CPPFLAGS)
|
||||
|
||||
# For debugging
|
||||
echo "Using PKG_CFLAGS=$PKG_CFLAGS"
|
||||
echo "Using PKG_LIBS=$PKG_LIBS"
|
||||
|
||||
# Test configuration
|
||||
echo "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2> configure.log
|
||||
|
||||
# Customize the error
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "-----------------------------[ ANTICONF ]-----------------------------"
|
||||
echo "Configure could not find suitable mysql/mariadb client library. Try installing:"
|
||||
echo " * deb: $PKG_DEB_NAME (Debian, Ubuntu)"
|
||||
echo " * rpm: $PKG_RPM_NAME (Fedora, CentOS, RHEL)"
|
||||
echo " * csw: $PKG_CSW_NAME (Solaris)"
|
||||
echo " * brew: $PKG_BREW_NAME (OSX)"
|
||||
echo "If you already have a mysql client library installed, verify that either"
|
||||
echo "mariadb_config or mysql_config is on your PATH. If these are unavailable"
|
||||
echo "you can also set INCLUDE_DIR and LIB_DIR manually via:"
|
||||
echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'"
|
||||
echo "--------------------------[ ERROR MESSAGE ]----------------------------"
|
||||
cat configure.log
|
||||
echo "-----------------------------------------------------------------------"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Write to Makevars
|
||||
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars
|
||||
|
||||
# Success
|
||||
exit 0
|
||||
Reference in New Issue
Block a user