[sane-devel] [PATCH v2 03/14] bldchn, use our new macro SANE_CHECK_NETDB_FUNC

Ruediger Meier sweet_f_a at gmx.de
Mon Jan 23 23:05:48 UTC 2012


From: Ruediger Meier <ruediger.meier at ga-group.nl>

Now we will find getaddrinfo and getnameinfo on win32 systems.
Note it should be even safe to use that macro for all systems instead of
trying AC_CHECK_FUNCS first. For now I don't want to do such risky things
things and leave it as is.
---
 configure                |  169 ++++++++++++++++++++++++++++++++++++++++++++++
 configure.in             |    8 ++
 include/sane/config.h.in |    3 +
 3 files changed, 180 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 4c9dfcd..5da8db8 100755
--- a/configure
+++ b/configure
@@ -9508,6 +9508,175 @@ fi
 
 
 
+if test "$ac_cv_func_getaddrinfo" != "yes" \
+  || test "$ac_cv_func_getnameinfo" != "yes"; then
+
+
+  sane_netdb_includes="$ac_includes_default
+  #ifdef HAVE_SYS_SOCKET_H
+  # include <sys/socket.h>
+  #endif
+  #ifdef HAVE_NETDB_H
+  # include <netdb.h>
+  #endif
+  #ifdef HAVE_WINSOCK2_H
+  # include <winsock2.h>
+  #endif
+  #ifdef HAVE_WS2TCPIP_H
+  # include <ws2tcpip.h>
+  #endif"
+
+  ac_cv_func_getaddrinfo="no"
+  need_winver_xp="no"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for win32 getaddrinfo" >&5
+$as_echo_n "checking for win32 getaddrinfo... " >&6; }
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$sane_netdb_includes
+int
+main ()
+{
+int testme(){ getaddrinfo; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    ac_cv_func_getaddrinfo="yes"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+    if test "$ac_cv_func_getaddrinfo" != "yes"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for win32 getaddrinfo if WINVER is 0x0501" >&5
+$as_echo_n "checking for win32 getaddrinfo if WINVER is 0x0501... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define WINVER 0x0501
+      $sane_netdb_includes
+int
+main ()
+{
+int testme(){ getaddrinfo; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      ac_cv_func_getaddrinfo="yes"
+      need_winver_xp="yes"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  fi
+
+  if test "$ac_cv_func_getaddrinfo" = "yes"; then
+
+$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h
+
+
+    if test "$need_winver_xp" = "yes"; then
+
+$as_echo "#define NEED_WINVER_XP 1" >>confdefs.h
+
+    fi
+  fi
+
+  unset sane_netdb_includes
+
+
+  sane_netdb_includes="$ac_includes_default
+  #ifdef HAVE_SYS_SOCKET_H
+  # include <sys/socket.h>
+  #endif
+  #ifdef HAVE_NETDB_H
+  # include <netdb.h>
+  #endif
+  #ifdef HAVE_WINSOCK2_H
+  # include <winsock2.h>
+  #endif
+  #ifdef HAVE_WS2TCPIP_H
+  # include <ws2tcpip.h>
+  #endif"
+
+  ac_cv_func_getnameinfo="no"
+  need_winver_xp="no"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for win32 getnameinfo" >&5
+$as_echo_n "checking for win32 getnameinfo... " >&6; }
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$sane_netdb_includes
+int
+main ()
+{
+int testme(){ getnameinfo; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    ac_cv_func_getnameinfo="yes"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+    if test "$ac_cv_func_getnameinfo" != "yes"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for win32 getnameinfo if WINVER is 0x0501" >&5
+$as_echo_n "checking for win32 getnameinfo if WINVER is 0x0501... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define WINVER 0x0501
+      $sane_netdb_includes
+int
+main ()
+{
+int testme(){ getnameinfo; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      ac_cv_func_getnameinfo="yes"
+      need_winver_xp="yes"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  fi
+
+  if test "$ac_cv_func_getnameinfo" = "yes"; then
+
+$as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h
+
+
+    if test "$need_winver_xp" = "yes"; then
+
+$as_echo "#define NEED_WINVER_XP 1" >>confdefs.h
+
+    fi
+  fi
+
+  unset sane_netdb_includes
+
+fi
+
 
 
 
diff --git a/configure.in b/configure.in
index 6eb3355..060b8b6 100644
--- a/configure.in
+++ b/configure.in
@@ -308,6 +308,14 @@ AC_CHECK_FUNCS(atexit ioperm i386_set_ioperm \
 AC_REPLACE_FUNCS(getenv isfdtype sigprocmask snprintf \
     strcasestr strdup strndup strsep usleep sleep syslog vsyslog)
 
+dnl Some systems need better ckecks for get*info
+if test "$ac_cv_func_getaddrinfo" != "yes" \
+  || test "$ac_cv_func_getnameinfo" != "yes"; then
+
+  SANE_CHECK_NETDB_FUNC(getaddrinfo)
+  SANE_CHECK_NETDB_FUNC(getnameinfo)
+fi
+
 SANE_PROTOTYPES
 
 if test "$ac_cv_header_os2_h" = "yes" ; then
diff --git a/include/sane/config.h.in b/include/sane/config.h.in
index afeb667..3d0cd1a 100644
--- a/include/sane/config.h.in
+++ b/include/sane/config.h.in
@@ -454,6 +454,9 @@
    */
 #undef LT_OBJDIR
 
+/* Define to 1 if some win32 functions needs WINVER set. */
+#undef NEED_WINVER_XP
+
 /* Define to 1 if your C compiler doesn't accept -c and -o together. */
 #undef NO_MINUS_C_MINUS_O
 
-- 
1.7.6.1




More information about the sane-devel mailing list