summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorAlon Bar-Lev <alon.barlev@gmail.com>2015-11-15 18:40:17 +0200
committerAlon Bar-Lev <alon.barlev@gmail.com>2015-11-15 23:43:24 +0200
commit6372ed837298a34f6d16e0cde929822879863195 (patch)
tree6a79d087fd0888d2ac07d74f56d51cec256f8570 /configure.ac
parent471ddd68074c546156a01216fe2b99a3a7e64a04 (diff)
build: migrate to autotools
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac163
1 files changed, 163 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000000..fbfbec6e70
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,163 @@
+#
+# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
+#
+AC_PREREQ(2.60)
+
+define([VERSION_MAJOR], [1])
+define([VERSION_MINOR], [0])
+define([VERSION_FIX], [0])
+define([VERSION_NUMBER], VERSION_MAJOR[.]VERSION_MINOR[.]VERSION_FIX)
+define([VERSION_SUFFIX], [_master])
+
+AC_INIT([netdata], VERSION_NUMBER[]VERSION_SUFFIX)
+PACKAGE_RPM_VERSION="VERSION_NUMBER"
+PACKAGE_RPM_RELEASE="0.0.$(echo VERSION_SUFFIX | sed 's/^_//')"
+AC_SUBST([PACKAGE_RPM_VERSION])
+AC_SUBST([PACKAGE_RPM_RELEASE])
+
+AC_CONFIG_AUX_DIR([.])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SRCDIR([src/main.c])
+AM_INIT_AUTOMAKE
+AC_CANONICAL_HOST
+AC_PROG_CC
+AC_PROG_INSTALL
+PKG_PROG_PKG_CONFIG
+AC_USE_SYSTEM_EXTENSIONS
+
+AC_ARG_ENABLE(
+ [daemon],
+ [AS_HELP_STRING([--disable-daemon], [disable daemon])],
+ ,
+ [enable_daemon="yes"]
+)
+AC_ARG_ENABLE(
+ [plugin-plugin-nfacct],
+ [AS_HELP_STRING([--enable-plugin-plugin-nfacct], [enable nfacct plugin, requires root])],
+ ,
+ [enable_plugin_plugin_nfacct="no"]
+)
+AC_ARG_ENABLE(
+ [pedantic],
+ [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings])],
+ ,
+ [enable_pedantic="no"]
+)
+AC_ARG_WITH(
+ [webdir],
+ [AS_HELP_STRING([--with-webdir], [location of webdir @<:@PKGDATADIR/web@:>@])],
+ [webdir="${withval}"],
+ [webdir="\$(pkgdatadir)/web"]
+)
+AC_ARG_WITH(
+ [zlib],
+ [AS_HELP_STRING([--with-zlib], [build with zlib])],
+ ,
+ [with_zlib="yes"]
+)
+AC_ARG_WITH(
+ [math],
+ [AS_HELP_STRING([--with-math], [build with math])],
+ ,
+ [with_math="yes"]
+)
+AC_ARG_WITH(
+ [user],
+ [AS_HELP_STRING([--with-user], [use this user to drop privilege])],
+ ,
+ [with_user="nobody"]
+)
+
+ACX_PTHREAD(, [AC_MSG_ERROR([Cannot initialize pthread environment])])
+LIBS="${PTHREAD_LIBS} ${LIBS}"
+CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}"
+CC="${PTHREAD_CC}"
+
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_C_INLINE
+
+PKG_CHECK_MODULES(
+ [NFACCT],
+ [libnetfilter_acct],
+)
+PKG_CHECK_MODULES(
+ [LIBMNL],
+ [libmnl],
+)
+PKG_CHECK_MODULES(
+ [ZLIB],
+ [zlib],
+)
+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 "${enable_daemon}" = "yes" && AC_DEFINE([NETDATA_DAEMON], [1], [daemon settings])
+if test "${enable_plugin_plugin_nfacct}" = "yes"; then
+ test -z "${NFACCT_LIBS}" && AC_MSG_ERROR([netfilter_acct required but not found])
+ test -z "${LIBMNL_LIBS}" && AC_MSG_ERROR([libmnl required but not found])
+ AC_DEFINE([INTERNAL_PLUGIN_NFACCT], [1], [nfacct plugin settings])
+ OPTIONAL_NFACCT_CLFAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
+ OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
+fi
+if test "${with_zlib}" = "yes"; then
+ test -z "${ZLIB_LIBS}" && AC_MSG_ERROR([zlib required but not found])
+ AC_DEFINE([NETDATA_WITH_ZLIB], [1], [zlib settings])
+ OPTIONAL_ZLIB_CLFAGS="${ZLIB_CFLAGS}"
+ OPTIONAL_ZLIB_LIBS="${ZLIB_LIBS}"
+fi
+if test "${with_math}" = "yes"; then
+ test -z "${MATH_LIBS}" && AC_MSG_ERROR([math required but not found])
+ AC_DEFINE([STORAGE_WITH_MATH], [1], [math settings])
+ OPTIONAL_MATH_CFLAGS="${MATH_CFLAGS}"
+ OPTIONAL_MATH_LIBS="${MATH_LIBS}"
+fi
+
+if test "${GCC}" = "yes"; then
+ AC_DEFINE_UNQUOTED([likely(x)], [__builtin_expect(!!(x), 1)], [gcc branch optimization])
+ AC_DEFINE_UNQUOTED([unlikely(x)], [__builtin_expect(!!(x), 0)], [gcc branch optimization])
+else
+ AC_DEFINE_UNQUOTED([likely(x)], [(x)], [gcc branch optimization])
+ AC_DEFINE_UNQUOTED([unlikely(x)], [(x)], [gcc branch optimization])
+fi
+
+if test "${enable_pedantic}" = "yes"; then
+ enable_strict="yes"
+ CFLAGS="${CFLAGS} -pedantic -Wall -Wextra -Wno-long-long"
+fi
+
+AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
+
+AC_SUBST([cachedir], ["\$(localstatedir)/cache/netdata"])
+AC_SUBST([chartsdir], ["\$(libexecdir)/netdata/charts.d"])
+AC_SUBST([configdir], ["\$(sysconfdir)/netdata"])
+AC_SUBST([logdir], ["\$(localstatedir)/log/netdata"])
+AC_SUBST([pluginsdir], ["\$(libexecdir)/netdata/plugins.d"])
+AC_SUBST([webdir])
+
+AC_SUBST([OPTIONAL_MATH_CLFAGS])
+AC_SUBST([OPTIONAL_MATH_LIBS])
+AC_SUBST([OPTIONAL_NFACCT_CLFAGS])
+AC_SUBST([OPTIONAL_NFACCT_LIBS])
+AC_SUBST([OPTIONAL_ZLIB_CLFAGS])
+AC_SUBST([OPTIONAL_ZLIB_LIBS])
+
+AC_CONFIG_FILES([
+ Makefile
+ charts.d/Makefile
+ conf.d/Makefile
+ netdata.spec
+ plugins.d/Makefile
+ src/Makefile
+ web/Makefile
+])
+AC_OUTPUT