configure.ac: avoid AC_TRY_RUN

Those tests are compile-time and link-time checks, and running the
resulting programs is not needed or even helpful.  This fixes the
Windows cross-build, which previously failed because SO_BINDTODEVICE
was assumed to be available.
libnfs-4.0.0-vitalif
Max Kellermann 2017-02-10 23:34:22 +01:00
parent f51769792a
commit 3ef8675c6f
1 changed files with 7 additions and 25 deletions

View File

@ -44,24 +44,17 @@ if test x$ENABLE_EXAMPLES = xyes; then
AC_MSG_CHECKING(whether libpopt is available) AC_MSG_CHECKING(whether libpopt is available)
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="$LIBS -lpopt" LIBS="$LIBS -lpopt"
AC_TRY_RUN([ AC_TRY_LINK([#include <popt.h>], [
/* /*
* Just see if we can compile/link with popt * Just see if we can compile/link with popt
*/ */
#include <popt.h> int _argc;
char **_argv;
int main(int argc, const char *argv[])
{
struct poptOption popt_options[] = { struct poptOption popt_options[] = {
POPT_TABLEEND POPT_TABLEEND
}; };
poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST); poptGetContext(_argv[0], _argc, _argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
], ac_cv_have_popt=yes, ac_cv_have_popt=no)
return 0;
}
], ac_cv_have_popt=yes, ac_cv_have_popt=no,
[echo $ac_n "compile with POPT. Assuming OK... $ac_c"
ac_cv_have_popt=yes])
LIBS="$ac_save_LIBS" LIBS="$ac_save_LIBS"
if test "$ac_cv_have_popt" = yes ; then if test "$ac_cv_have_popt" = yes ; then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
@ -76,20 +69,9 @@ fi
AC_SUBST(MAYBE_EXAMPLES) AC_SUBST(MAYBE_EXAMPLES)
AC_MSG_CHECKING(whether SO_BINDTODEVICE is available) AC_MSG_CHECKING(whether SO_BINDTODEVICE is available)
AC_TRY_RUN([ AC_TRY_COMPILE([#include <net/if.h>], [
/*
* Just see if we can compile with SO_BINDTODEVICE
*/
#include <net/if.h>
int main(int argc, const char *argv[])
{
int i = SO_BINDTODEVICE; int i = SO_BINDTODEVICE;
return 0; ], ac_cv_have_so_bindtodevice=yes, ac_cv_have_so_bindtodevice=no)
}
], ac_cv_have_so_bindtodevice=yes, ac_cv_have_so_bindtodevice=no,
[echo $ac_n "compile with SO_BINDTODEVICE. Assuming OK... $ac_c"
ac_cv_have_so_bindtodevice=yes])
if test "$ac_cv_have_so_bindtodevice" = yes ; then if test "$ac_cv_have_so_bindtodevice" = yes ; then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SO_BINDTODEVICE, 1, [Whether our sockets support SO_BINDTODEVICE]) AC_DEFINE(HAVE_SO_BINDTODEVICE, 1, [Whether our sockets support SO_BINDTODEVICE])