forked from r-dbi/RMariaDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·105 lines (95 loc) · 3.93 KB
/
configure
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
# 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="libmariadb-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 [ -n "$RMARIADB_FORCE_MARIADBCONFIG" ]; then
echo "Using mariadb_config (forced)"
PKGCONFIG_CFLAGS=`mariadb_config --cflags`
PKGCONFIG_LIBS=`mariadb_config --libs`
elif [ -n "$RMARIADB_FORCE_MYSQLCONFIG" ]; then
echo "Using mysql_config (forced)"
PKGCONFIG_CFLAGS=`mysql_config --cflags`
PKGCONFIG_LIBS=`mysql_config --libs`
elif [ `command -v mysql_config` ]; then
echo "Using mysql_config"
if [ `command -v mariadb_config` ]; then
echo "RMariaDB 1.2.0 will default to use mariadb_config."
echo "Set the RMARIADB_FORCE_MYSQLCONFIG environment variable to a nonempty value to force mysql_config."
fi
PKGCONFIG_CFLAGS=`mysql_config --cflags`
PKGCONFIG_LIBS=`mysql_config --libs`
elif [ `command -v mariadb_config` ]; then
echo "Using mariadb_config"
PKGCONFIG_CFLAGS=`mariadb_config --cflags`
PKGCONFIG_LIBS=`mariadb_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 [ `uname` = "Darwin" ]; then
PKG_LIBS="-L/usr/local/opt/openssl/lib $PKG_LIBS"
fi
elif [ `uname` = "Darwin" ]; then
test ! "$CI" && brew --version 2>/dev/null
if [ $? -eq 0 ]; then
BREWDIR=`brew --prefix`
else
curl -sfL "https://autobrew.github.io/scripts/$PKG_BREW_NAME" > autobrew
. ./autobrew
fi
fi
if [ "$R_PLOGR_ENABLE" ]; then
PKG_PLOGR=-DPLOGR_ENABLE
fi
# For debugging
echo "Using PKG_CFLAGS=$PKG_CFLAGS"
echo "Using PKG_LIBS=$PKG_LIBS"
echo "Using PKG_PLOGR=$PKG_PLOGR"
# 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`
# 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
echo "# Generated from Makevars.in, do not edit by hand" > src/Makevars.new
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@plogr@|$PKG_PLOGR|" src/Makevars.in >> src/Makevars.new
if [ ! -f src/Makevars ] || (which diff > /dev/null && ! diff -q src/Makevars src/Makevars.new); then
cp -f src/Makevars.new src/Makevars
fi
rm -f src/Makevars.new
# Success
exit 0