forked from r-dbi/RMySQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.in
More file actions
228 lines (210 loc) · 8.04 KB
/
configure.in
File metadata and controls
228 lines (210 loc) · 8.04 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
dnl
dnl RMySQL
dnl
dnl $Id$
dnl
dnl Generate a "configure" script that will install the RMySQL package.
dnl
dnl NOTE: The resulting configure script implements the following logic:
dnl
dnl 1. If PKG_CPPFLAGS and PKG_LIBS are defined, use them (as suggested in
dnl Section 1.2.1 in the "Writing R Extensions, 1.3.0). Ditto for
dnl MYSQL_DIR, MYSQL_INC, MYSQL_LIB.
dnl
dnl 2. We check for mysql.h and -lmysqlclient in system directories, and if
dnl found, we use these (provide the user does not explicitly request
dnl another version, see below). Notice that the MySQL source distribution
dnl installs by default to /usr/local/lib/mysql and /usr/local/include/mysql
dnl
dnl 3. Alternatively, if the user specifies explicitly a particular MySQL
dnl installation we use that version. This can be requested through
dnl --with-mysql-dir=DIR
dnl --with-mysql-inc=<include-DIR>
dnl or --with-mysql-lib=<library-DIR>
dnl
dnl (these are equivent to setting and exporting MYSQL_{DIR,INC,LIB})
dnl In the first case, DIR is assumed to include the lib and include
dnl subdirectories; individual locations of these two may be
dnl specified independently through <include-inc> and <library-dir>,
dnl respectively. If we found these, we exit.
dnl
dnl 4. We check for the GNU implementation of getopt_long and set the
dnl C preprocessor macro HAVE_GETOPT_LONG accordingly. On windows
dnl (including MinGW) should be false.
dnl
dnl Global variables: The following variables may be set and exported
dnl prior to running configure:
dnl PKG_CPPFLAGS, PKG_LIBS, MYSQL_DIR, MYSQL_INC, MYSQL_LIB
dnl
AC_INIT(src/RS-MySQL.c)
AC_PROG_CPP
# Some people have reported not having libz (which we clearly is needed
# in the INSTALL file). Oh well.
#
AC_CHECK_LIB(z, compress,
HAVE_COMPRESS="yes",
HAVE_COMPRESS="no")
# Do we have access to GNU's getopt_long (problem on some systems, e.g.,
# FreeBDS, Mac OS/X, Windows/MinGW)
#
AC_CHECK_LIB(c, getopt_long,
HAVE_GETOPT_LONG="yes",
HAVE_GETOPT_LONG="no")
# can we find MySQL in the system directories? (users may still want/need
# to use another version/installation)
#
AC_CHECK_LIB(mysqlclient, mysql_init,
HAVE_MYSQL_LIB="yes",
HAVE_MYSQL_LIB="")
AC_CHECK_HEADERS(mysql.h,
HAVE_MYSQL_INC="yes",
HAVE_MYSQL_INC="")
#
# the user may still want a particular MySQL installation/version (possibly
# overriding system directories). Note that we don't clobber the shell
# variables MYSQL_DIR, MSYQL_INC, MYSQL_LIB, that may be inherited from the
# global shell environement.
#
AC_ARG_WITH(mysql-dir,
[--with-mysql-dir=MYSQL_DIR specifies an existing MySQL base dir],
MYSQL_DIR="${with_mysql_dir}")
AC_ARG_WITH(mysql-inc,
[--with-mysql-inc=MYSQL_INC specifies an existing MySQL include dir],
MYSQL_INC="${with_mysql_inc}")
AC_ARG_WITH(mysql-lib,
[--with-mysql-lib=MYSQL_LIB specifies an existing MySQL lib dir],
MYSQL_LIB="${with_mysql_lib}")
# handle the uniformative cases of --with-mysql w.o. argument
# and the case of -with-no-mysql
test "${MYSQL_DIR}" = "yes" -o "${MYSQL_DIR}" = "no" && MYSQL_DIR=""
test "${MYSQL_LIB}" = "yes" -o "${MYSQL_LIB}" = "no" && MYSQL_LIB=""
test "${MYSQL_INC}" = "yes" -o "${MYSQL_INC}" = "no" && MYSQL_INC=""
if test -n "${MYSQL_DIR}" ; then
test ! -d "${MYSQL_DIR}" && AC_MSG_ERROR([dir ${MYSQL_DIR} does not exist])
test -z "${MYSQL_INC}" -a -d "${MYSQL_DIR}/include/mysql" && \
MYSQL_INC="${MYSQL_DIR}/include/mysql"
test -z "${MYSQL_LIB}" -a -d "${MYSQL_DIR}/lib/mysql" && \
MYSQL_LIB="${MYSQL_DIR}/lib/mysql"
fi
#
# We now determine whether we found the lib and header files (we still
# need to check PKG_*, in case the user only defined one them)
#
if test -z "${PKG_LIBS}" ; then
if test -n "${MYSQL_LIB}" ; then
# use the one specified in --with-mysql-*
PKG_LIBS="-L${MYSQL_LIB} -lmysqlclient"
else
# use the one in the system dirs (if there's one)
test -n "${HAVE_MYSQL_LIB}" && PKG_LIBS="-lmysqlclient"
fi
fi
if test -z "${PKG_CPPFLAGS}" ; then
if test -n "${MYSQL_INC}" ; then
# use the one specified in --with-mysql-inc=DIR
PKG_CPPFLAGS="-I${MYSQL_INC}"
FOUND_INC="yes"
else
if test -n "${HAVE_MYSQL_INC}" ; then
# use the one in the system dirs
PKG_CPPFLAGS=""
FOUND_INC="yes"
else
PKG_CPPFLAGS=""
FOUND_INC="no"
fi
fi
fi
if test "${HAVE_GETOPT_LONG}" = "no" ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -DHAVE_GETOPT_LONG=0 "
fi
# if above fails, do a more exhaustive search into potential mysql
# subdirectories of the system directories.
if test -z "${HAVE_MYSQL_LIB}" -a -z "${PKG_LIBS}" ; then
for dir in /usr/local/lib64 /usr/lib64 \
/usr/local/lib /usr/lib /usr/local/mysql/lib /opt/lib /lib
do # need to release mysqlcient from cache
unset ac_cv_lib_mysqlclient_mysql_init
candidate="${dir}/mysql"
AC_CHECK_LIB(mysqlclient, mysql_init,
HAVE_MYSQL_LIB="${candidate}",
HAVE_MYSQL_LIB="",
[-L${candidate}])
if test -n "${HAVE_MYSQL_LIB}" ; then
echo " mysqlclient found in -L${HAVE_MYSQL_LIB}"
PKG_LIBS="-L${HAVE_MYSQL_LIB} -lmysqlclient"
break
fi
done
fi
# ditto for the header files
if test -z "${HAVE_MYSQL_INC}" -a -z "${PKG_CPPFLAGS}" ; then
for dir in /usr/local/include /usr/include /usr/local/mysql/include \
/opt/include /include
do
candidate="${dir}/mysql"
AC_CHECK_HEADER(${candidate}/mysql.h,
HAVE_MYSQL_INC="${candidate}",
HAVE_MYSQL_INC="")
if test -n "${HAVE_MYSQL_INC}" ; then
PKG_CPPFLAGS="-I${HAVE_MYSQL_INC}"
FOUND_INC="yes"
break
fi
done
fi
# don't go any further if don't have libz
if test "${HAVE_COMPRESS}" = "no" ; then
echo ""
echo "Configuration error:"
echo ' Could not locate the library "libz" required by MySQL.'
echo ""
echo "INSTRUCTIONS:"
echo ""
echo ' The "libz" library is required by the MySQL client library'
echo " in order to compress/uncompress connections between clients"
echo " and the MySQL engine."
echo ""
echo ' Make sure you have "libz" installed properly and/or included'
echo ' in your $LD_LIBRARY_PATH. Perhaps it is not in any of the'
echo " standard directories (e.g., /usr/lib/, /usr/local/lib)?"
echo ""
echo "Aborting the installation of RMySQL."
echo ""
exit 1
fi
# If we stil haven't set PKG_*, error
if test "${FOUND_INC}" = "no" -o -z "${PKG_LIBS}" ; then
echo ""
echo "Configuration error:"
echo " could not find the MySQL installation include and/or library"
echo " directories. Manually specify the location of the MySQL"
echo " libraries and the header files and re-run R CMD INSTALL."
echo ""
echo "INSTRUCTIONS:"
echo ""
echo "1. Define and export the 2 shell variables PKG_CPPFLAGS and"
echo " PKG_LIBS to include the directory for header files (*.h)"
echo " and libraries, for example (using Bourne shell syntax):"
echo ""
echo ' export PKG_CPPFLAGS="-I<MySQL-include-dir>"'
echo ' export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"'
echo ""
echo " Re-run the R INSTALL command:"
echo ""
echo " R CMD INSTALL RMySQL_<version>.tar.gz"
echo ""
echo "2. Alternatively, you may pass the configure arguments"
echo " --with-mysql-dir=<base-dir> (distribution directory)"
echo " or"
echo " --with-mysql-inc=<base-inc> (where MySQL header files reside)"
echo " --with-mysql-lib=<base-lib> (where MySQL libraries reside)"
echo " in the call to R INSTALL --configure-args='...' "
echo ""
echo " R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz"
echo ""
exit 1
fi
AC_SUBST(PKG_CPPFLAGS)
AC_SUBST(PKG_LIBS)
AC_OUTPUT(src/Makevars)