Skip to content

Commit

Permalink
configure: improve MySQL detection, unset USE_MYSQL with failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Jan 8, 2024
1 parent 26850de commit d4fb802
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 9 deletions.
77 changes: 72 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -12106,20 +12106,87 @@ 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'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

fi

fi # $USE_MYSQL


Expand Down
13 changes: 9 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d4fb802

Please sign in to comment.