From: Trond Norbye Date: Thu, 29 Jul 2010 00:09:42 +0000 (+0200) Subject: Fixed autoconf macros for cross compile X-Git-Tag: 0.44~7^2~5 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3aba02a06e7adfd7dfd0621ac55da31331d75b77;p=m6w6%2Flibmemcached Fixed autoconf macros for cross compile --- diff --git a/configure.ac b/configure.ac index d3a4a349..4beb8a0a 100644 --- a/configure.ac +++ b/configure.ac @@ -140,25 +140,7 @@ AM_CONDITIONAL(BUILD_POLL, test "x$ac_cv_header_poll_h" = "xno") AM_CONDITIONAL(BUILD_WIN32_WRAPPERS, test "x$ac_cv_header_winsock2_h" = "xyes") AS_IF(test "x$ac_cv_header_winsock2_h" = "xyes", AM_LDFLAGS="$AM_LDFLAGS -lws2_32") - -# -# Some platforms define EWOULDBLOCK == EAGAIN, causing our switch for error -# codes to be illegal (POSIX.1-2001 allows both return codes from recv, so -# we need to test both if they differ...) -# -AC_MSG_CHECKING([if EWOULDBLOCK == EAGAIN]) -AC_RUN_IFELSE( - [AC_LANG_PROGRAM([ -#include - ], [dnl - return EAGAIN == EWOULDBLOCK ? 0 : 1; - ]) - ],[ - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([no]) - AC_DEFINE([USE_EAGAIN], [1], [Define to true if you need to test for eagain]) - ]) +DETECT_EAGAIN AC_CONFIG_FILES([ Makefile diff --git a/m4/byteorder.m4 b/m4/byteorder.m4 index 4692bbd2..5a99af7a 100644 --- a/m4/byteorder.m4 +++ b/m4/byteorder.m4 @@ -1,25 +1,19 @@ AC_DEFUN([DETECT_BYTEORDER], [ AC_REQUIRE([AC_C_BIGENDIAN]) - AC_CACHE_CHECK([for htonll],[av_cv_have_htonll],[ - - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[ + AC_CACHE_CHECK([for htonll], [ac_cv_have_htonll], + [AC_TRY_COMPILE([ #include #include #include - ]],[[ - return htonll(0); - ]]) - ], [ - ac_cv_have_htonll=yes - ],[ - ac_cv_have_htonll=no - ])]) - + ], [ +return htonll(0); + ], + [ ac_cv_have_htonll=yes ], + [ ac_cv_have_htonll=no ]) + ]) AS_IF([test "x$ac_cv_have_htonll" = "xyes"],[ - AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])]) + AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])]) AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$ac_cv_have_htonll" = "xno"]) ]) - diff --git a/m4/eagain.m4 b/m4/eagain.m4 new file mode 100644 index 00000000..3ba8c23f --- /dev/null +++ b/m4/eagain.m4 @@ -0,0 +1,28 @@ +# +# Some platforms define EWOULDBLOCK == EAGAIN, causing our switch for error +# codes to be illegal (POSIX.1-2001 allows both return codes from recv, so +# we need to test both if they differ...) +# +AC_DEFUN([DETECT_EAGAIN], +[ + AC_CACHE_CHECK([if EWOULDBLOCK == EAGAIN],[av_cv_eagain_ewouldblock], + [AC_TRY_COMPILE([ +#include + ], [ +int error = EAGAIN; +switch (error) +{ + case EAGAIN: + case EWOULDBLOCK: + error = 1; + break; + default: + error = 0; +} + ], + [ av_cv_eagain_ewouldblock=no ], + [ av_cv_eagain_ewouldblock=yes ]) + ]) + AS_IF([test "x$ac_cv_eagain_ewouldblock" = "xyes"],[ + AC_DEFINE([USE_EAGAIN], [1], [Define to true if you need to test for eagain])]) +]) diff --git a/m4/protocol_binary.m4 b/m4/protocol_binary.m4 index ba7acaf5..5c00b556 100644 --- a/m4/protocol_binary.m4 +++ b/m4/protocol_binary.m4 @@ -1,22 +1,34 @@ dnl --------------------------------------------------------------------------- dnl Macro: PROTOCOL_BINARY_TEST dnl --------------------------------------------------------------------------- + AC_DEFUN([PROTOCOL_BINARY_TEST], - [AC_LANG_PUSH([C]) - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -I${srcdir}" - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[ +[ + AC_CACHE_CHECK([for supported struct padding], [ac_cv_supported_struct_padding], [ + AC_LANG_PUSH([C]) + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I${srcdir}" + AC_TRY_COMPILE([ #include #include "libmemcached/memcached/protocol_binary.h" - ]],[[ + ], [ protocol_binary_request_set request; - if (sizeof(request) != sizeof(request.bytes)) { - return 1; + int a = 1; + switch (a) { + case sizeof(request): + case sizeof(request.bytes): + break; + default: + a = 2; } - ]])],, AC_MSG_ERROR([Unsupported struct padding done by compiler.])) + ], + [ ac_cv_supported_struct_padding=no ], + [ ac_cv_supported_struct_padding=yes ]) CFLAGS="$save_CFLAGS" AC_LANG_POP + ]) + AS_IF([test "x$ac_cv_supported_struct_padding" = "xno"],[ + AC_MSG_ERROR([Unsupported struct padding done by compiler.])]) ]) dnl --------------------------------------------------------------------------- diff --git a/m4/setsockopt.m4 b/m4/setsockopt.m4 index e37fe2ae..58c61c0a 100644 --- a/m4/setsockopt.m4 +++ b/m4/setsockopt.m4 @@ -2,6 +2,7 @@ dnl --------------------------------------------------------------------------- dnl Macro: SETSOCKOPT_SANITY dnl --------------------------------------------------------------------------- AC_DEFUN([SETSOCKOPT_SANITY],[ + AC_CACHE_CHECK([for working SO_SNDTIMEO], [ac_cv_have_so_sndtimeo], AC_LANG_PUSH([C]) AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ @@ -25,8 +26,17 @@ AC_DEFUN([SETSOCKOPT_SANITY],[ } return 0; ]])], - [AC_DEFINE(HAVE_SNDTIMEO, 1, [Define to 1 if you have a working SO_SNDTIMEO])]) + [ac_cv_have_so_sndtimeo=yes], + [ac_cv_have_so_sndtimeo=no], + [ac_cv_have_so_sndtimeo=yes]) + AS_IF([test "x$ac_cv_have_so_sndtimeo" = "xyes"], [ + AC_DEFINE(HAVE_SNDTIMEO, 1, [Define to 1 if you have a working SO_SNDTIMEO])]) + AC_LANG_POP + ) + + AC_CACHE_CHECK([for working SO_RCVTIMEO], [ac_cv_have_so_rcvtimeo], + AC_LANG_PUSH([C]) AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ #include @@ -34,7 +44,7 @@ AC_DEFUN([SETSOCKOPT_SANITY],[ #include #include #include - ]],[[ + ]],[[ int sock = socket(AF_INET, SOCK_STREAM, 0); struct timeval waittime; @@ -48,9 +58,15 @@ AC_DEFUN([SETSOCKOPT_SANITY],[ } } return 0; - ]])], [AC_DEFINE(HAVE_RCVTIMEO, 1, [Define to 1 if you have a working SO_RCVTIMEO])]) + ]])], + [ac_cv_have_so_rcvtimeo=yes], + [ac_cv_have_so_rcvtimeo=no], + [ac_cv_have_so_rcvtimeo=yes]) - AC_LANG_POP + AS_IF([test "x$ac_cv_have_so_rcvtimeo" = "xyes"], [ + AC_DEFINE(HAVE_RCVTIMEO, 1, [Define to 1 if you have a working SO_RCVTIMEO])]) + AC_LANG_POP + ) ]) dnl --------------------------------------------------------------------------- dnl End Macro: SETSOCKOPT_SANITY