[gtetrinet] Rework configure checks.



commit 3fbe9dca51c95d534f6f57da79c89d238d0e9674
Author: Jordi Mallach <jordi sindominio net>
Date:   Mon May 2 12:17:05 2011 +0200

    Rework configure checks.
    
    Quote arguments and fix summary information when IPv6 or detaching is not enabled.
    Change config.h USE_IPV6 variable to ENABLE_IPV6 and update code accordingly.

 configure.ac |   43 ++++++++++++++++++++++++++++---------------
 src/client.c |    8 ++++----
 2 files changed, 32 insertions(+), 19 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index baa9d6b..a63511f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,7 +43,7 @@ AM_GCONF_SOURCE_2
 # Check for pkg-config
 PKG_PROG_PKG_CONFIG([0.22])
 
-dnl Add debug flags if building from git.
+# Add debug flags if building from git.
 if test -d $srcdir/.git; then
 	CFLAGS="-Wall -W -g3 -ggdb -O0"
 	AC_SUBST(CFLAGS)
@@ -63,7 +63,7 @@ PKG_CHECK_MODULES(GTETRINET,[
 AC_SUBST(GTETRINET_CFLAGS)
 AC_SUBST(GTETRINET_LIBS)
 
-dnl Check for libesd
+# Check for libesd
 if pkg-config --exists esound ; then
 	have_esound=yes
 else 
@@ -71,10 +71,10 @@ else
 fi
 
 if test "x$have_esound" = "xyes"; then
-AC_DEFINE(HAVE_ESD, 1, [Define this to enable EsounD support.])
-PKG_CHECK_MODULES(ESOUND, esound >= $LIBESD_OPTIONAL)
-AC_SUBST(ESOUND_CFLAGS)
-AC_SUBST(ESOUND_LIBS)
+	AC_DEFINE([HAVE_ESD],[1],[Define this to enable EsounD support.])
+	PKG_CHECK_MODULES([ESOUND],[esound >= $LIBESD_OPTIONAL])
+	AC_SUBST(ESOUND_CFLAGS)
+	AC_SUBST(ESOUND_LIBS)
 fi
 
 AM_CONDITIONAL(HAVE_ESOUND, test "x$have_esound" = "xyes")
@@ -95,18 +95,30 @@ if test $ac_cv_func_setenv = no; then
   AC_DEFINE(HAVE_SETENV, 1, [Define this if setenv() is available.])
  fi
 
-dnl configure options
+# configure options
+# Check for page detaching support
 AC_ARG_ENABLE(detach,
-[  --enable-detach         Enable page detaching (default=no)],
-  [if test "x$enable_detach" = "xyes"; then
-    AC_DEFINE(ENABLE_DETACH, 1, [Define this to enable page detaching.])
-  fi])
+	AS_HELP_STRING([--enable-detach],[Enable page detaching support (default=no)]),
+	enable_detach="yes")
+AC_MSG_CHECKING([if page detaching support should be built])
+if test "x$enable_detach" = "xyes"; then
+	AC_DEFINE([ENABLE_DETACH],[1],[Define this to enable page detaching.])
+else
+	enable_detach="no"
+fi
+AC_MSG_RESULT($enable_detach)
 
+# Check for IPv6
 AC_ARG_ENABLE(ipv6,
-[  --enable-ipv6           Enable IPv6 support (default=no)],
-  [if test "x$enable_ipv6" = "xyes"; then
-   AC_DEFINE(USE_IPV6, 1, [Define this to enable IPv6 support.])
-  fi])
+	AS_HELP_STRING([--enable-ipv6],[Enable IPv6 support (default=no)]),
+        enable_ipv6="yes")
+AC_MSG_CHECKING([if IPv6 support should be built])
+if test "x$enable_ipv6" = "xyes"; then
+	AC_DEFINE([ENABLE_IPV6],[1],[Define this to enable IPv6 support.])
+else
+	enable_ipv6="no"
+fi
+AC_MSG_RESULT($enable_ipv6)
 
 # Generate files
 AC_CONFIG_FILES([
@@ -123,6 +135,7 @@ icons/Makefile
 AC_OUTPUT
 
 # Print configuration information
+echo
 echo "   Configuration result"
 echo "   ------------- ------"
 echo
diff --git a/src/client.c b/src/client.c
index 7124bd0..6fe53af 100644
--- a/src/client.c
+++ b/src/client.c
@@ -291,7 +291,7 @@ void client_process (void)
 
 gpointer client_resolv_hostname (void)
 {
-#ifdef USE_IPV6
+#ifdef ENABLE_IPV6
     char hbuf[NI_MAXHOST];
     struct addrinfo hints, *res, *res0;
     struct sockaddr_in6 sa;
@@ -303,7 +303,7 @@ gpointer client_resolv_hostname (void)
 
     /* set up the connection */
 
-#ifdef USE_IPV6
+#ifdef ENABLE_IPV6
     snprintf(service, 9, "%d", spectating?SPECPORT:PORT);
     memset(&hints, 0, sizeof(hints));
     hints.ai_family = AF_UNSPEC;
@@ -498,7 +498,7 @@ int client_readmsg (gchar **str)
 
 void server_ip (unsigned char buf[4])
 {
-#ifdef USE_IPV6
+#ifdef ENABLE_IPV6
     struct sockaddr_in6 sin;
     struct sockaddr_in *sin4;
 #else
@@ -507,7 +507,7 @@ void server_ip (unsigned char buf[4])
     int len = sizeof(sin);
 
     getpeername (sock, (struct sockaddr *)&sin, &len);
-#ifdef USE_IPV6
+#ifdef ENABLE_IPV6
     if (sin.sin6_family == AF_INET6) {
 	memcpy (buf, ((char *) &sin.sin6_addr) + 12, 4);
     } else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]