autoconf-deal-with-res-search-as-macro-20030428
authorDerrick Brashear <shadow@dementia.org>
Tue, 29 Apr 2003 00:05:57 +0000 (00:05 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 29 Apr 2003 00:05:57 +0000 (00:05 +0000)
on some platforms, res_search is a macro for __res_search, find it anyway

acinclude.m4
src/cf/ressearch.m4 [new file with mode: 0644]

index 248751c..4a0515c 100644 (file)
@@ -619,17 +619,30 @@ else
         done    
   fi    
 
-  AC_CHECK_FUNCS(res_search)
+  openafs_save_libs="$LIBS"
+  AC_MSG_CHECKING([for res_search])
+  AC_FUNC_RES_SEARCH
+
   if test "$ac_cv_func_res_search" = no; then
-        for lib in dns nsl resolv; do
-          if test "$HAVE_RES_SEARCH" != 1; then
-            AC_CHECK_LIB(${lib}, res_search, LIBS="$LIBS -l$lib";HAVE_RES_SEARCH=1;AC_DEFINE(HAVE_RES_SEARCH, 1, [define if you have res_search]))
-          fi
-        done    
-       if test "$HAVE_RES_SEARCH" = 1; then
-         LIB_res_search="-l$lib"       
-       fi
-  fi    
+      for lib in dns nsl resolv; do
+        if test "$ac_cv_func_res_search" != yes; then
+         LIBS="-l$lib $LIBS"
+          AC_FUNC_RES_SEARCH
+          LIBS="$openafs_save_libs"
+        fi
+      done    
+      if test "$ac_cv_func_res_search" = yes; then
+        LIB_res_search="-l$lib"       
+       AC_DEFINE(HAVE_RES_SEARCH, 1, [])
+        AC_MSG_RESULT([yes, in lib$lib])
+      else
+        AC_MSG_RESULT(no)
+      fi
+  else
+    AC_DEFINE(HAVE_RES_SEARCH, 1, [])
+    AC_MSG_RESULT(yes)
+  fi
+  
 fi
 
 PTHREAD_LIBS=error
diff --git a/src/cf/ressearch.m4 b/src/cf/ressearch.m4
new file mode 100644 (file)
index 0000000..2094a4f
--- /dev/null
@@ -0,0 +1,21 @@
+AC_DEFUN(AC_FUNC_RES_SEARCH, [
+  ac_cv_func_res_search=no
+  AC_TRY_LINK([
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>],
+  [
+const char host[11]="openafs.org";
+u_char ans[1024];
+int r;
+res_init();
+/* Capture result in r but return 0, since a working nameserver is
+ * not a requirement for compilation.
+ */
+r =  res_search( host, C_IN, T_MX, (u_char *)&ans, sizeof(ans));
+return 0;
+res_close();
+  ],
+  ac_cv_func_res_search=yes)
+])
\ No newline at end of file