]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-autoconf-deal-with-res-search-as-macro-20030428
authorDerrick Brashear <shadow@dementia.org>
Thu, 15 May 2003 16:51:27 +0000 (16:51 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 15 May 2003 16:51:27 +0000 (16:51 +0000)
on some platforms, res_search is a macro for __res_search, find it anyway

(cherry picked from commit f5df7b1d97572b6a0cd5f8a3a7b0f752ae111905)

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

index 1eb61d0a067a237f765f73a790dae475b102c809..41d69d75ae7fb2c2bc42f775d1eb86f9f2e6a7b4 100644 (file)
@@ -519,17 +519,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