+RADIUSD_MINOR_VERSION=`cat VERSION | sed 's/^[[^\.]]*\.//' | sed 's/\..*$//'`
+RADIUSD_INCRM_VERSION=`cat VERSION | sed 's/^.*\..*\.//' | sed 's/[[\.-]].*$//'`
+
+RADIUSD_VERSION=`echo | awk -v major="$RADIUSD_MAJOR_VERSION" \
+-v minor="$RADIUSD_MINOR_VERSION" \
+-v incrm="$RADIUSD_INCRM_VERSION" \
+'{ printf "%02i%02i%02i", major, minor, incrm }'`
+
+dnl # Still useful for custom builds
+RADIUSD_VERSION_STRING=`cat VERSION`
+
+dnl #
+dnl # Add definitions to Make.inc as it's used by various build targets
+dnl #
+AC_SUBST([RADIUSD_VERSION_STRING])
+
+dnl #
+dnl # Add definitions to autoconf.h, so that the headers that we install
+dnl # contain the version number of the server.
+dnl #
+AC_DEFINE_UNQUOTED([RADIUSD_VERSION], [${RADIUSD_VERSION}], [Version integer in format <ma><ma><mi><mi><in><in>])
+AC_DEFINE_UNQUOTED([RADIUSD_VERSION_STRING], ["${RADIUSD_VERSION_STRING}"], [Raw version string from VERSION file])
+
+dnl #############################################################
+dnl #
+dnl # Override some of the default autoconf variables such as
+dnl # CFLAGS if were building in developer mode
+dnl #
+dnl #############################################################
+
+dnl #
+dnl # Enable developer features like debugging symbols.
+dnl # These checks must be done before expanding the AC_PROG_CC
+dnl # and AC_PROG_CXX macros.
+dnl #
+AC_ARG_ENABLE(developer,
+[ --enable-developer enables features of interest to developers.],
+[ case "$enableval" in
+ no)
+ developer=no
+ ;;
+ *)
+ developer=yes
+ esac ]
+)
+
+if test -d $srcdir/.git; then
+ if test "x$developer" != "xno"; then
+ dnl turn on the developer flag when taken from a git checkout (not a release)
+ developer="yes"
+ fi
+fi
+
+dnl #
+dnl # Autoconf sets -O2 and -g by default, but this is a PITA for debugging
+dnl # so we remove the defaults if were building in developer mode, and set
+dnl # -g3 so nice things like macro values are included. Other arguments are
+dnl # added later when we know what compiler were using.
+dnl #
+if test "x$developer" = "xyes"; then
+ : ${CFLAGS=-g3}
+ : ${MAKEFLAGS=-j8}
+fi
+
+AC_SUBST(MAKEFLAGS)