File: configure

package info (click to toggle)
rmysql 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: ansic: 1,666; makefile: 5; sh: 1
file content (81 lines) | stat: -rwxr-xr-x 3,065 bytes parent folder | download | duplicates (2)
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
# 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 [ `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

# 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