From d4fb80203b66954248c5fab548d6687ca8bd8fa9 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Mon, 8 Jan 2024 10:55:41 +0100 Subject: [PATCH] configure: improve MySQL detection, unset USE_MYSQL with failure --- configure | 77 ++++++++++++++++++++++++++++++++++++++++++++++++---- configure.ac | 13 ++++++--- 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 8f3a589cf9e..45fe1eacd41 100755 --- a/configure +++ b/configure @@ -12106,12 +12106,80 @@ if test "x$ac_cv_func_mysql_server_init" = xyes then : else $as_nop - MYSQLDLIB=""; - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libmysqld not found" >&5 -printf "%s\n" "$as_me: WARNING: libmysqld not found" >&2;} + if test "$cross_compiling" = yes +then : + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else $as_nop + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that +# executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: program exited with status $ac_status" >&5 + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval - LIBS=$ac_save_libs +} # ac_fn_cxx_try_run +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include mysql.h + int main(void) { + mysql_server_init(0, NULL, NULL); + return 0; + } + +_ACEOF +if ac_fn_cxx_try_run "$LINENO" +then : + +else $as_nop + USE_MYSQL=; MYSQLDLIB=""; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: mysql_server_init not found" >&5 +printf "%s\n" "$as_me: WARNING: mysql_server_init not found" >&2;} +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + + LIBS=${ac_save_libs} ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -12119,7 +12187,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi - fi # $USE_MYSQL diff --git a/configure.ac b/configure.ac index 2f1bfc69218..2548b49f116 100644 --- a/configure.ac +++ b/configure.ac @@ -1286,12 +1286,17 @@ if test -n "$USE_MYSQL"; then MYSQLDLIB=`"$MYSQLD_CONFIG" --libmysqld-libs` LIBS="$MYSQLDLIB $LIBS" - AC_CHECK_FUNC(mysql_server_init,,[MYSQLDLIB=""; - AC_MSG_WARN([libmysqld not found])] ) - LIBS=$ac_save_libs + AC_CHECK_FUNC(mysql_server_init,, + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include mysql.h + int main(void) { + mysql_server_init(0, NULL, NULL); + return 0; + } + ]])],,[USE_MYSQL=; MYSQLDLIB=""; AC_MSG_WARN([mysql_server_init not found])])) + LIBS=${ac_save_libs} AC_LANG_POP([C++]) fi - fi # $USE_MYSQL AC_SUBST(USE_MYSQL)