+dnl Check for the compiler and static/shared library creation.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_LIBTOOL
+
+dnl Check if we run on a system that has fonts
+AC_ARG_WITH(rrd-default-font,
+[ --with-rrd-default-font=[OPTIONS] set the full path to your default font.],
+[RRD_DEFAULT_FONT=$withval],[
+ if test -d ${WINDIR:-nodir}/cour.ttf ; then
+ RRD_DEFAULT_FONT=`cd $WINDIR;pwd`/cour.ttf
+ else
+ RRD_DEFAULT_FONT='$(fontsdir)/$(fonts_DATA)'
+ fi
+])
+
+AC_SUBST(RRD_DEFAULT_FONT)
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_HEADER_DIRENT
+AC_CHECK_HEADERS(sys/stat.h sys/types.h fcntl.h time.h locale.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/time.h sys/times.h sys/param.h sys/resource.h float.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_HEADER_TIME
+AC_STRUCT_TM
+
+dnl Checks for libraries.
+AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
+
+dnl add pic flag in any case this makes sure all our code is relocatable
+eval `./libtool --config | grep pic_flag`
+CFLAGS="$CFLAGS $pic_flag"
+
+dnl Checks for library functions.
+AC_FUNC_STRFTIME
+AC_FUNC_VPRINTF
+
+AC_C_BIGENDIAN
+
+dnl for each function found we get a definition in config.h
+dnl of the form HAVE_FUNCTION
+
+AC_CHECK_FUNCS(tzset opendir readdir chdir chroot getuid setlocale strerror strerror_r snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
+
+dnl Use mmap in rrd_update instead of seek+write
+AC_ARG_ENABLE([mmap],
+[ --disable-mmap disable mmap in rrd_update, use seek+write instead],
+[],
+[enable_mmap=yes])
+
+if test "x$enable_mmap" = xyes; then
+ AC_FUNC_MMAP
+fi
+
+dnl HP-UX 11.00 does not have finite but does have isfinite as a macro so we need
+dnl actual code to check if this works
+AC_CHECK_FUNCS(fpclassify, ,
+ [AC_MSG_CHECKING(for fpclassify with <math.h>)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; fpclassify(f)]])],[AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_FPCLASSIFY)],[AC_MSG_RESULT(no)])])
+AC_CHECK_FUNCS(finite, ,
+ [AC_CHECK_FUNCS(isfinite, ,
+ [AC_MSG_CHECKING(for isfinite with <math.h>)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isfinite(f)]])],[AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_ISFINITE)],[AC_MSG_RESULT(no)])])])
+AC_CHECK_FUNCS(isinf, ,
+ [AC_MSG_CHECKING(for isinf with <math.h>)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isinf(f)]])],[AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])
+
+AC_FULL_IEEE
+
+dnl How the vertical axis label is printed
+AC_ARG_VAR(RRDGRAPH_YLEGEND_ANGLE,
+ [Vertical label angle: 90.0 (default) or 270.0])
+AC_DEFINE_UNQUOTED(RRDGRAPH_YLEGEND_ANGLE,${RRDGRAPH_YLEGEND_ANGLE:-90.0},
+ [Vertical label angle: 90.0 (default) or 270.0])
+
+
+AC_ARG_ENABLE(rrdcgi,[ --disable-rrdcgi disable building of rrdcgi],
+[],[enable_rrdcgi=yes])
+AM_CONDITIONAL(BUILD_RRDCGI,[test $enable_rrdcgi != no])
+
+if test $enable_rrdcgi != no; then
+EX_CHECK_ALL(cgi, cgiInit, cgi.h, cgilib, 0.5, http://www.infodrom.org/projects/cgilib, "")
+fi
+EX_CHECK_ALL(art_lgpl_2, art_vpath_add_point, libart_lgpl/libart.h, libart-2.0, 2.3.17, ftp://ftp.gnome.org/pub/GNOME/sources/libart_lgpl/2.3/, /usr/include/libart-2.0)
+EX_CHECK_ALL(z, zlibVersion, zlib.h, zlib, 1.2.2, http://www.gzip.org/zlib/, "")
+EX_CHECK_ALL(png, png_access_version_number, png.h, libpng, 1.2.8, http://prdownloads.sourceforge.net/libpng/, "")
+EX_CHECK_ALL(freetype, FT_Init_FreeType, ft2build.h, freetype2, 2.1.9, http://prdownloads.sourceforge.net/freetype/, /usr/include/freetype2)
+
+if test "$EX_CHECK_ALL_ERR" = "YES"; then
+ AC_MSG_ERROR([Please fix the library issues listed above and try again.])
+fi
+
+AC_LANG_PUSH(C)
+dnl solaris has some odd defines it needs in order to propperly compile ctime_r
+AC_MSG_CHECKING([if ctime_r need special care to act posixly correct])
+AC_LINK_IFELSE(
+ AC_LANG_PROGRAM(
+ [[#include <time.h>]],
+ [[ctime_r(NULL,NULL,0)]]
+ ),
+ [ CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
+ AC_LINK_IFELSE(
+ AC_LANG_PROGRAM(
+ [[#include <time.h>]],
+ [[ctime_r(NULL,NULL)]]
+ ),
+ [AC_MSG_RESULT([yes, this seems to be solaris style])],
+ [AC_MSG_ERROR([Can't figure how to compile ctime_r])]
+ )
+ ],
+ [ AC_LINK_IFELSE(
+ AC_LANG_PROGRAM(
+ [[#include <time.h>]],
+ [[ctime_r(NULL,NULL)]]
+ ),
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_ERROR([Can't figure how to compile ctime_r])]
+ )
+ ]
+)
+AC_LANG_POP(C)
+
+dnl Check for pthreads
+dnl http://autoconf-archive.cryp.to/acx_pthread.m4
+
+AC_SUBST(MULTITHREAD_CFLAGS)
+AC_SUBST(MULTITHREAD_LDFLAGS)
+
+
+AC_ARG_ENABLE(pthread,[ --disable-pthread disable multithread support],
+[],[enable_pthread=yes])
+