From 1ff4e9008b70ccf521179ad1a2438bdc93554fd4 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 20 Jun 2009 17:24:43 +0000 Subject: Refactor how libraries are checked for connect() function, and check for connect() as it is done for other functions. --- ares/acinclude.m4 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'ares/acinclude.m4') diff --git a/ares/acinclude.m4 b/ares/acinclude.m4 index 6594b6fb6..4c5e8c736 100644 --- a/ares/acinclude.m4 +++ b/ares/acinclude.m4 @@ -1670,6 +1670,47 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [ ]) +dnl CARES_CHECK_LIBS_CONNECT +dnl ------------------------------------------------- +dnl Verify if network connect function is already available +dnl using current libraries or if another one is required. + +AC_DEFUN([CARES_CHECK_LIBS_CONNECT], [ + AC_MSG_CHECKING([for connect in libraries]) + tst_connect_save_LIBS="$LIBS" + tst_connect_need_LIBS="unknown" + for tst_lib in '' '-lsocket' ; do + if test "$tst_connect_need_LIBS" = "unknown"; then + LIBS="$tst_lib $tst_connect_save_LIBS" + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + ]],[[ + if(0 != connect(0, 0, 0)) + return 1; + ]]) + ],[ + tst_connect_need_LIBS="$tst_lib" + ]) + fi + done + LIBS="$tst_connect_save_LIBS" + # + case X-"$tst_connect_need_LIBS" in + X-unknown) + AC_MSG_RESULT([cannot find connect]) + AC_MSG_ERROR([cannot find connect function in libraries.]) + ;; + X-) + AC_MSG_RESULT([yes]) + ;; + *) + AC_MSG_RESULT([$tst_connect_need_LIBS]) + LIBS="$tst_connect_need_LIBS $tst_connect_save_LIBS" + ;; + esac +]) + + dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE]) dnl ------------------------------------------------- dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor -- cgit v1.2.3