+#
+# Detecting the linux distro for specific things like initscripts.
+#
+AC_ARG_WITH(distro, AC_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, or slackware]))
+if test "z$with_distro" = "z"; then
+ AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
+ AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
+ AC_CHECK_FILE(/etc/fedora-release,with_distro="redhat")
+ AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
+ AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
+ AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
+fi
+with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
+
+if test "z$with_distro" = "z"; then
+ echo "Linux distribution autodetection failed, you must specify the distribution to target using --with-distro=DISTRO"
+ exit 1
+else
+case $with_distro in
+ debian|gentoo|suse)
+ ;;
+ *)
+ echo "Your distribution (${with_distro}) is not yet supported, init scripts and dbus configuration will not be installed! (patches welcome)"
+ ;;
+esac
+
+fi
+AM_CONDITIONAL(TARGET_REDHAT, test x"$with_distro" = xredhat)
+AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
+AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
+AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
+AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
+
+#
+# Defining Avahi User and Group.
+#
+AC_ARG_WITH(avahi_user,[ --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
+fi
+AC_SUBST(AVAHI_USER)
+AC_DEFINE_UNQUOTED(AVAHI_USER,"$AVAHI_USER", [User for running the Avahi daemon])
+
+AC_ARG_WITH(avahi_group,[ --with-avahi-group=<grp> Group for Avahi (avahi)])
+if test -z "$with_avahi_group" ; then
+ AVAHI_GROUP=avahi
+else
+ AVAHI_GROUP=$with_avahi_group
+fi
+AC_SUBST(AVAHI_GROUP)
+AC_DEFINE_UNQUOTED(AVAHI_GROUP,"$AVAHI_GROUP", [Group for Avahi])
+
+#
+# Avahi runtime dir
+#
+avahi_runtime_dir="${localstatedir}/run"
+avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket"
+AC_SUBST(avahi_runtime_dir)
+AC_SUBST(avahi_socket)
+
+#
+# Python stuff
+#
+AC_SUBST(PYGTK_REQ, 2.6.0)
+
+AM_PATH_PYTHON(2.4)
+AM_PYTHON_CHECK_VERSION("$PYTHON", 2.4, [HAVE_PYTHON=yes], [HAVE_PYTHON=no])
+AM_CONDITIONAL(HAVE_PYTHON, [test "x$HAVE_PYTHON" = xyes ])
+
+# check for pygtk
+PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= $PYGTK_REQ)
+PYGTK_DIR="`$PKG_CONFIG --variable=pyexecdir pygtk-2.0`"
+AC_SUBST(PYGTK_DIR)
+AC_MSG_NOTICE(Using pygtk installed in $PYGTK_DIR)
+PYGTK_VERSION="`$PKG_CONFIG --modversion pygtk-2.0`"
+if test "x$PYGTK_VERSION" = "x2.5.2"
+then
+ AC_MSG_ERROR([PyGTK 2.5.2 contains known bugs, please install other version])
+fi
+export PYTHONPATH=$PYGTK_DIR:$PYTHONPATH
+
+# check for gtk.glade
+AC_MSG_CHECKING(for gtk.glade)
+prog="
+import sys
+try:
+ import gtk.glade
+except RuntimeError:
+ sys.exit(0)
+except ImportError:
+ sys.exit(1)
+sys.exit(0)
+"
+
+if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
+then
+ AC_MSG_RESULT(found)
+else
+ AC_MSG_RESULT(not found)
+ AC_MSG_ERROR([You need to have python libglade bindings installed])
+fi
+
+dnl ==========================================================================
+AC_CONFIG_FILES([
+Makefile
+avahi-core.pc
+avahi-common/Makefile
+avahi-core/Makefile
+avahi-daemon/Makefile
+avahi-daemon/avahi-dbus.conf
+avahi-discover/Makefile
+avahi-client/Makefile
+initscript/Makefile
+initscript/Debian/Makefile
+initscript/Gentoo/Makefile
+initscript/SUSE/Makefile
+avahi-dnsconfd/Makefile
+avahi-utils/Makefile
+avahi-utils/avahi/Makefile
+avahi-utils/avahi-dump-all
+avahi-utils/avahi-publish-service
+avahi-utils/avahi-publish-address
+avahi-utils/avahi-discover
+examples/Makefile
+common/Makefile
+])