-
Notifications
You must be signed in to change notification settings - Fork 107
/
configure
executable file
·89 lines (79 loc) · 3.12 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
#!/bin/sh
# Anticonf (tm) script by Jeroen Ooms, Jim Hester (2017)
# This script will query 'pkg-config' for the required cflags and ldflags.
# If pkg-config is unavailable or does not find the library, try setting
# INCLUDE_DIR and LIB_DIR manually via e.g:
# R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'
# Library settings
PKG_CONFIG_NAME="odbc"
PKG_DEB_NAME="unixodbc-dev"
PKG_RPM_NAME="unixODBC-devel"
PKG_CSW_NAME="unixodbc_dev"
PKG_PACMAN_NAME="unixodbc"
PKG_BREW_NAME="unixodbc"
PKG_TEST_HEADER="<sql.h>"
PKG_LIBS="${PKG_LIBS:--lodbc}"
# 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"
else
# Use odbc_config, iodbc-config if available
if [ "`command -v odbc_config`" ]; then
echo "Found odbc_config cflags and libs!"
PKGCONFIG_CFLAGS=`odbc_config --cflags`
PKGCONFIG_LIBS=`odbc_config --libs`
elif [ "`command -v iodbc-config`" ]; then
echo "Found iodbc-config cflags and libs!"
PKGCONFIG_CFLAGS=`iodbc-config --cflags`
PKGCONFIG_LIBS=`iodbc-config --libs`
elif [ "`command -v pkg-config`" ]; then
PKGCONFIG_CFLAGS=`pkg-config --cflags $PKG_CONFIG_NAME 2>/dev/null`
echo "Found pkg-config cflags and libs!"
PKGCONFIG_LIBS=`pkg-config --libs $PKG_CONFIG_NAME 2>/dev/null`
fi
if [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
PKG_CFLAGS=${PKGCONFIG_CFLAGS}
PKG_LIBS=${PKGCONFIG_LIBS}
elif [ "`uname`" = 'Darwin' ]; then
if [ "`command -v brew`" ]; then
BREWDIR=`brew --prefix`
PKG_CFLAGS="-I$BREWDIR/opt/$PKG_BREW_NAME/include"
PKG_LIBS="-L$BREWDIR/lib $PKG_LIBS"
else
curl -sfL "https://autobrew.github.io/scripts/unixodbc" > autobrew
. ./autobrew
fi
fi
fi
# Find compiler
if "${R_HOME}"/bin/R CMD config CXX11 > /dev/null; then
CXX11="`"${R_HOME}"/bin/R CMD config CXX11` -E"
else
CXX11="`"${R_HOME}"/bin/R CMD config CXX1X` -E"
fi
CXXFLAGS=`"${R_HOME}"/bin/R CMD config CXXFLAGS`
CPPFLAGS=`"${R_HOME}"/bin/R CMD config CPPFLAGS`
# For debugging
echo "PKG_CFLAGS=$PKG_CFLAGS"
echo "PKG_LIBS=$PKG_LIBS"
# Test for odbc
echo "#include $PKG_TEST_HEADER" | ${CXX11} ${PKG_CFLAGS} ${CPPFLAGS} ${CXXFLAGS} -xc++ - > /dev/null
if [ $? -ne 0 ]; then
echo "------------------------- ANTICONF ERROR ---------------------------"
echo "Configuration failed because $PKG_CONFIG_NAME was not found. Try installing:"
echo " * deb: $PKG_DEB_NAME (Debian, Ubuntu, etc)"
echo " * rpm: $PKG_RPM_NAME (Fedora, CentOS, RHEL)"
echo " * csw: $PKG_CSW_NAME (Solaris)"
echo " * pacman: $PKG_PACMAN_NAME (Archlinux, Manjaro, etc)"
echo " * brew: $PKG_BREW_NAME (Mac OSX)"
echo "To use a custom $PKG_CONFIG_NAME set INCLUDE_DIR and LIB_DIR and PKG_LIBS manually via:"
echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=... PKG_LIBS=...'"
echo "--------------------------------------------------------------------"
exit 1;
fi
# Write to Makevars
sed -e "s|@PKG_CFLAGS@|$PKG_CFLAGS|" -e "s|@PKG_LIBS@|$PKG_LIBS|" src/Makevars.in > src/Makevars
# Success
exit 0