+
+# -----------------------------------------------------------------------------
+# operating system detection
+
+AC_MSG_CHECKING([operating system])
+case "$host_os" in
+freebsd*)
+ build_target=freebsd
+ ;;
+darwin*)
+ build_target=macos
+ LDFLAGS="${LDFLAGS} -framework CoreFoundation -framework IOKit"
+ ;;
+*)
+ build_target=linux
+ ;;
+esac
+
+AM_CONDITIONAL([FREEBSD], [test "${build_target}" = "freebsd"])
+AM_CONDITIONAL([MACOS], [test "${build_target}" = "macos"])
+AM_CONDITIONAL([LINUX], [test "${build_target}" = "linux"])
+AC_MSG_RESULT([${build_target}])
+
+
+# -----------------------------------------------------------------------------
+# pthreads
+
+ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
+LIBS="${PTHREAD_LIBS} ${LIBS}"
+CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
+CC="${PTHREAD_CC}"
+
+
+# -----------------------------------------------------------------------------
+# libm
+
+AC_ARG_VAR([MATH_CFLAGS], [C compiler flags for math])
+AC_ARG_VAR([MATH_LIBS], [linker flags for math])
+if test -z "${MATH_LIBS}"; then
+ AC_CHECK_LIB(
+ [m],
+ [sin],
+ [MATH_LIBS="-lm"]
+ )
+fi
+test "${with_math}" = "yes" -a -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
+
+AC_MSG_CHECKING([if libm should be used])
+if test "${with_math}" != "no" -a ! -z "${MATH_LIBS}"; then
+ with_math="yes"
+ AC_DEFINE([STORAGE_WITH_MATH], [1], [math usability])
+ OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
+ OPTIONAL_MATH_LIBS="${MATH_LIBS}"
+else
+ with_math="no"
+fi
+AC_MSG_RESULT([${with_math}])
+
+
+# -----------------------------------------------------------------------------
+# zlib
+
+PKG_CHECK_MODULES(
+ [ZLIB],
+ [zlib],
+ [have_zlib=yes],
+ [have_zlib=no]
+)
+test "${with_zlib}" = "yes" -a "${have_zlib}" != "yes" && AC_MSG_ERROR([zlib required but not found. Try installing 'zlib1g-dev' or 'zlib-devel'.])
+
+AC_MSG_CHECKING([if zlib should be used])
+if test "${with_zlib}" != "no" -a "${have_zlib}" = "yes"; then
+ with_zlib="yes"
+ AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib usability])
+ OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
+ OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
+else
+ with_zlib="no"
+fi
+AC_MSG_RESULT([${with_zlib}])
+
+
+# -----------------------------------------------------------------------------
+# libuuid
+
+PKG_CHECK_MODULES(
+ [UUID],
+ [uuid],
+ [have_uuid=yes],
+ [AC_MSG_ERROR([libuuid required but not found. Try installing 'uuid-dev' or 'libuuid-devel'.])]