+ DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wlarger-than-4000 -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter"
+
+ # Test whether rtnetlink.h can be included when compiled with -std=c99
+ # some distributions (e.g. archlinux) have broken headers that dont
+ # define __u64 with -std=c99
+ AC_MSG_CHECKING([checking whether rtnetlink.h can be included with -std=c99])
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="-std=c99"
+ AC_TRY_COMPILE([#include <linux/rtnetlink.h>], [],
+ use_stdc99=yes, use_stdc99=no)
+
+ if test x"$use_stdc99" = xyes; then
+ DESIRED_FLAGS="-std=c99 $DESIRED_FLAGS"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+
+ CFLAGS="$OLDCFLAGS"
+
+ for flag in $DESIRED_FLAGS ; do
+ AC_MSG_CHECKING([whether $CC accepts $flag])
+ if test_gcc_flag $flag ; then
+ CFLAGS="$CFLAGS $flag"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ done
+fi
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+AC_HEADER_SYS_WAIT
+
+# Checks for library functions.
+AC_FUNC_MEMCMP
+AC_FUNC_SELECT_ARGTYPES
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([gethostname memchr memmove memset mkdir select socket strchr strcspn strdup strerror strrchr strspn strstr uname setresuid setreuid strcasecmp gettimeofday putenv strncasecmp])
+
+AC_FUNC_CHOWN
+AC_FUNC_STAT
+AC_TYPE_MODE_T
+AC_TYPE_PID_T
+
+# Check for pkg-config manually first, as if its not installed the
+# PKG_PROG_PKG_CONFIG macro won't be defined.
+AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
+
+if test x"$have_pkg_config" == xno; then
+ AC_MSG_ERROR(pkg-config is required to install this program)
+fi
+
+PKG_PROG_PKG_CONFIG
+
+#
+# Check for GLIB 2.0
+#
+AC_ARG_ENABLE(glib,
+ AS_HELP_STRING([--disable-glib],[Disable use of GLib]),
+ [case "${enableval}" in
+ yes) HAVE_GLIB=yes ;;
+ no) HAVE_GLIB=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-glib) ;;
+ esac],
+ [HAVE_GLIB=yes])
+
+if test "x$HAVE_GLIB" = "xyes" ; then
+ PKG_CHECK_MODULES(GLIB20, [ glib-2.0 >= 2.4.0 ])
+ AC_SUBST(GLIB20_CFLAGS)
+ AC_SUBST(GLIB20_LIBS)
+fi
+AM_CONDITIONAL(HAVE_GLIB, test "x$HAVE_GLIB" = "xyes")
+
+#
+# Check for GTK+
+#
+AC_ARG_ENABLE(gtk,
+ AS_HELP_STRING([--disable-gtk],[Disable use of GTK+]),
+ [case "${enableval}" in
+ yes) HAVE_GTK=yes ;;
+ no) HAVE_GTK=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-gtk) ;;
+ esac],
+ [HAVE_GTK=yes])
+
+if test "x$HAVE_GTK" = "xyes" ; then
+ # Check for GTK 2.0
+ PKG_CHECK_MODULES(GTK20, [ gtk+-2.0 >= 2.4.0 ])
+ AC_SUBST(GTK20_CFLAGS)
+ AC_SUBST(GTK20_LIBS)
+
+ # Check for GLADE 2.0
+ PKG_CHECK_MODULES(GLADE20, [ libglade-2.0 >= 2.4.0 ])
+ AC_SUBST(GLADE20_CFLAGS)
+ AC_SUBST(GLADE20_LIBS)
+
+ interfacesdir="${datadir}/${PACKAGE}/interfaces/"
+ AC_SUBST(interfacesdir)
+fi
+AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
+
+#
+# D-BUS
+#
+AC_ARG_ENABLE(dbus,
+ AS_HELP_STRING([--disable-dbus],[Disable use of D-BUS]),
+ [case "${enableval}" in
+ yes) HAVE_DBUS=yes ;;
+ no) HAVE_DBUS=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-dbus) ;;
+ esac],
+ [HAVE_DBUS=yes])
+
+AC_ARG_WITH(dbus-sys, AS_HELP_STRING([--with-dbus-sys=<dir>], [where D-BUS system.d directory is]))
+AC_ARG_WITH(dbus-system-socket, AS_HELP_STRING([--with-dbus-system-address=<address>], [where the dbus system socket is, you probably want to put unix:path= at the start]))
+
+if test "x$HAVE_DBUS" = "xyes" ; then
+ AC_DEFINE(HAVE_DBUS, 1, [Whether we have D-BUS or not])
+
+ PKG_CHECK_MODULES(DBUS, [ dbus-1 >= 0.30 ])
+ DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_API_SUBJECT_TO_CHANGE"
+ AC_SUBST(DBUS_CFLAGS)
+ AC_SUBST(DBUS_LIBS)
+
+ if ! test -z "$with_dbus_sys" ; then
+ DBUS_SYS_DIR="$with_dbus_sys"
+ else
+ DBUS_SYS_DIR="${sysconfdir}/dbus-1/system.d"
+ fi
+ AC_SUBST(DBUS_SYS_DIR)
+
+ if ! test -z "$with_dbus_system_address" ; then
+ DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="$with_dbus_system_address"
+ else
+ # Note this default path is hardcoded in D-BUS and should
+ # not use $localstatedir
+ DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=/var/run/dbus/system_bus_socket"
+ fi
+ AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
+
+fi
+AM_CONDITIONAL(HAVE_DBUS, test "x$HAVE_DBUS" = "xyes")
+
+#
+# Expat
+#
+AC_ARG_ENABLE(expat,
+ AS_HELP_STRING([--disable-expat],[Disable use of Expat]),
+ [case "${enableval}" in
+ yes) HAVE_EXPAT=yes ;;
+ no) HAVE_EXPAT=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-expat) ;;
+ esac],
+ [HAVE_EXPAT=yes])
+
+if test "x$HAVE_EXPAT" = "xyes" ; then
+ AC_CHECK_LIB(expat, XML_ParserCreate, [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ], have_expat=false)
+
+ if ! $have_expat ; then
+ AC_MSG_ERROR([*** libexpat not found ***])
+ fi
+fi
+AM_CONDITIONAL(HAVE_EXPAT, test "x$HAVE_EXPAT" = "xyes")
+
+#
+# libdaemon
+#
+AC_ARG_ENABLE(libdaemon,
+ AS_HELP_STRING([--disable-libdaemon],[Disable use of libdaemon]),
+ [case "${enableval}" in
+ yes) HAVE_LIBDAEMON=yes ;;
+ no) HAVE_LIBDAEMON=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-libdaemon) ;;
+ esac],
+ [HAVE_LIBDAEMON=yes])
+
+if test "x$HAVE_LIBDAEMON" = "xyes" ; then
+ PKG_CHECK_MODULES(LIBDAEMON, [ libdaemon >= 0.5 ])
+ AC_SUBST(LIBDAEMON_CFLAGS)
+ AC_SUBST(LIBDAEMON_LIBS)
+fi
+AM_CONDITIONAL(HAVE_LIBDAEMON, test "x$HAVE_LIBDAEMON" = "xyes")
+
+#
+# Python stuff
+#
+AC_ARG_ENABLE(python,
+ AS_HELP_STRING([--disable-python], [Disable scripts that depends on python]),
+ [case "${enableval}" in
+ yes) HAVE_PYTHON=yes ;;
+ no) HAVE_PYTHON=no ;;
+ *) AC_MSG_ERROR([bad value ${enableval} for --enable-python]) ;;
+ esac],[HAVE_PYTHON=yes])
+
+if test "x$HAVE_PYTHON" = "xyes" ; then
+ AM_PATH_PYTHON([2.4])
+ AM_CHECK_PYMOD(gtk,,,[AC_MSG_ERROR(Could not find Python module pygtk)])
+ AM_CHECK_PYMOD(dbus,,,[AC_MSG_ERROR(Could not find Python module dbus)])
+fi
+AM_CONDITIONAL(HAVE_PYTHON, [test "x$HAVE_PYTHON" = "xyes" ])
+
+#
+# Defining Avahi User and Group.
+#
+AC_ARG_WITH(avahi_user, AS_HELP_STRING([--with-avahi-user=<user>],[User for running the Avahi daemon (avahi)]))
+if test -z "$with_avahi_user" ; then
+ AVAHI_USER=avahi
+else
+ AVAHI_USER=$with_avahi_user