On 3/6/20 10:38 PM, Michael Orlitzky wrote:
When building with MySQL support, the configure script guesses that
the path to the MySQL headers is /usr/include/mysql. That is usually
correct, but when people install MySQL to a nonstandard location such
as /home/mjo/usr, it falls over. Fortunately, MySQL usually provides
an executable called "mysql_config" that can output the location of
its headers.
In such a "local" installation, if I prepend /home/mjo/usr/bin to my
PATH, then running "mysql_config" will execute the mysql_config from
/home/mjo/usr/bin and will therefore output -I/home/mjo/usr/include as
the preprocessor flag that glpk needs. That's the right thing to do,
and it works just as well for a system install under /usr or
/usr/local.
This commit attempts to find the headers using mysql_config first,
and falls back to the location /usr/include/mysql.
Gentoo-bug: https://bugs.gentoo.org/597620
---
configure.ac | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 96c4cc5..d20a6ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,7 +145,10 @@ if test "$enable_mysql" = "yes"; then
AC_MSG_ERROR([--enable-mysql requires --enable-dl])
fi
AC_MSG_RESULT([yes])
- CPPFLAGS="-I/usr/include/mysql $CPPFLAGS"
+ # Guess at the include directory if mysql_config isn't in our PATH.
+ MYSQL_INCLUDE=$(mysql_config --include 2>/dev/null)
+ test -z "${MYSQL_INCLUDE}" && MYSQL_INCLUDE="-I/usr/include/mysql"
+ CPPFLAGS="${MYSQL_INCLUDE} $CPPFLAGS"
Thanks for your suggestion.
Should we only use 'mysql_config --include' or the more comprehensive
'mysql_config --cflags'?
In the scenario that you describe wouldn't the library also be installed
in a user path. So would we have to consider 'mysql_config --libs'?
Of cause you already can pass CPPFLAGS and LDFLAGS to ./configure to
specify your special directories.
On my computer I get:
$ mysql_config --include
-I/usr/include/mysql
$ mysql_config --cflags
-I/usr/include/mysql -g -g -fabi-version=2 -fno-omit-frame-pointer
-fno-strict-aliasing
$ mysql_config --libs
-L/usr/lib/arm-linux-gnueabihf -lmysqlclient -lpthread -lz -lm -ldl
Best regards
Heinrich
AC_DEFINE_UNQUOTED([MYSQL_DLNAME], ["$LIBMYSQL"], [N/A])
else
AC_MSG_RESULT([no])