(no commit message)
[ptask.git] / configure.ac
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..3ad1f39
--- /dev/null
@@ -0,0 +1,253 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.64])
+AC_INIT([psensor], [0.0.x],[jeanfi@gmail.com],[psensor],[http://wpitchoune.net/gtask])
+
+AM_INIT_AUTOMAKE([-Wall -Werror gnu])
+
+AC_CONFIG_SRCDIR([src/main.c])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+# Checks lib build
+AC_PROG_RANLIB
+
+# Checks for header files.
+AC_PATH_X
+AC_CHECK_HEADERS([stdbool.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([gettimeofday memmove socket strdup strtol])
+
+AM_GNU_GETTEXT_VERSION([0.16])
+AM_GNU_GETTEXT([external])
+
+# Gconf
+AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
+
+if test x"$GCONFTOOL" = xno; then
+  AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
+fi
+
+AM_GCONF_SOURCE_2
+
+############### common 
+
+# Checks pthread
+AC_CHECK_LIB(pthread, pthread_create)
+PTHREAD_LIBS=-pthread
+AC_SUBST(PTHREAD_LIBS)
+
+# Checks sensors, required by psensor and psensor-server
+AC_CHECK_LIB(sensors, sensors_init)
+AC_CHECK_HEADERS([sensors/sensors.h sensors/errors.h])
+SENSORS_LIBS=-lsensors
+AC_SUBST(SENSORS_LIBS)
+
+############### psensor 
+
+### Required
+
+PKG_CHECK_MODULES(X11, x11)
+AC_SUBST(X11_CFLAGS)
+AC_SUBST(X11_LIBS)
+
+PKG_CHECK_MODULES(XEXT, xext)
+AC_SUBST(XEXT_CFLAGS)
+AC_SUBST(XEXT_LIBS)
+
+# Checks GTK+ 3.0
+PKG_CHECK_MODULES(GTK, gtk+-3.0)               
+# ensure that only allowed headers are included
+GTK_CFLAGS+=" -DGTK_DISABLE_SINGLE_INCLUDES "
+# ensure that no gtk deprecated symbols are used
+GTK_CFLAGS+=" -DGDK_DISABLE_DEPRECATED "
+GTK_CFLAGS+=" -DGTK_DISABLE_DEPRECATED "
+# ensure use of accessors
+GTK_CFLAGS+=" -DGSEAL_ENABLE "
+AC_SUBST(GTK_CFLAGS)
+AC_SUBST(GTK_LIBS)
+
+# Check GCONF
+PKG_CHECK_MODULES(GCONF, gconf-2.0)
+AC_SUBST(GCONF_CFLAGS)
+AC_SUBST(GCONF_LIBS)
+
+### Optional
+
+# check libatasmart
+PKG_CHECK_MODULES(ATASMART, libatasmart,
+                 [AC_DEFINE([HAVE_ATASMART],[1],[Use libatasmart])],
+                         [AC_MSG_WARN("Library atasmart not present")])
+
+AM_CONDITIONAL(ATASMART, test -n "$ATASMART_LIBS")
+AC_SUBST(ATASMART_CFLAGS)
+AC_SUBST(ATASMART_LIBS)
+
+# Check libnotify
+LIBNOTIFY_LIBS=
+PKG_CHECK_MODULES(LIBNOTIFY, 
+  libnotify, 
+  [AC_DEFINE([HAVE_LIBNOTIFY],[1],[Use desktop notification])], 
+  [AC_MSG_WARN("Desktop notification disabled")])
+AM_CONDITIONAL(LIBNOTIFY, test -n "$LIBNOTIFY_LIBS")
+AC_SUBST(LIBNOTIFY_CFLAGS)
+AC_SUBST(LIBNOTIFY_LIBS)
+
+# Checks AppIndicator 
+APPINDICATOR_LIBS=
+
+PKG_CHECK_MODULES(APPINDICATOR, appindicator3-0.1,
+     [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator3-0.1])],
+     [AC_MSG_WARN(AppIndicator 3-0.1 not present")])
+
+if test "$APPINDICATOR_LIBS" == ""; then
+   PKG_CHECK_MODULES(APPINDICATOR, 
+     appindicator-0.1 <= 0.2.9 , 
+     [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator 0.2.9])
+      AC_DEFINE([HAVE_APPINDICATOR_029],[1],[Use AppIndicator 0.2.9])
+     ],
+     [AC_MSG_WARN(AppIndicator 0.2.9 not present")])
+fi
+
+if test "$APPINDICATOR_LIBS" == ""; then
+   PKG_CHECK_MODULES(APPINDICATOR, 
+     appindicator-0.1 > 0.2.9, 
+     [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator > 0.2.9])], 
+     [AC_MSG_WARN("AppIndicator > 0.2.9 not present")])
+fi
+AM_CONDITIONAL(APPINDICATOR, test -n "$APPINDICATOR_LIBS")
+AC_SUBST(APPINDICATOR_CFLAGS)
+AC_SUBST(APPINDICATOR_LIBS)
+
+# Check CURL, needed for remote monitoring
+CURL_LIBS=
+PKG_CHECK_MODULES(CURL, 
+  libcurl, 
+  [AC_DEFINE([HAVE_CURL],[1],[Use CURL])], 
+  [AC_MSG_WARN("Remote monitoring disabled, curl missing")])
+AM_CONDITIONAL(CURL, test -n "$CURL_LIBS")
+AC_SUBST(CURL_CFLAGS)
+AC_SUBST(CURL_LIBS)
+
+# Check JSON, needed for remote monitoring
+JSON_LIBS=
+PKG_CHECK_MODULES(JSON, 
+  json, 
+  [AC_DEFINE([HAVE_JSON],[1],[Use JSON])], 
+  [AC_MSG_WARN("Remote monitoring disabled, json missing")])
+AM_CONDITIONAL(JSON, test -n "$JSON_LIBS")
+AC_SUBST(JSON_CFLAGS)
+AC_SUBST(JSON_LIBS)
+
+# Enables remote monitoring if JSON and CURL is present
+if test -n "$JSON_LIBS"; then
+   if test -n "$CURL_LIBS"; then
+   AC_DEFINE([HAVE_REMOTE_SUPPORT],[1],[Remote monitoring enabled])
+   fi
+fi
+
+# Checks NVIDIA
+# following code from sensors-applet
+# sensors-applet.sourceforge.net/
+AC_CHECK_HEADERS(NVCtrl/NVCtrl.h NVCtrl/NVCtrlLib.h, 
+                [ HAVE_NVIDIA=true ], [], 
+                 [ 
+                 #include <X11/Xlib.h>
+                 ])
+if test -n "${X11_LIBS}"; then
+LIBS="${LIBS} -lX11 -lXext"
+
+if test "${HAVE_NVIDIA}" = "true"; then
+  AC_CHECK_LIB(XNVCtrl,XNVCTRLQueryExtension, 
+                 [NVIDIA_LIBS="-lXNVCtrl -lX11 -lXext" 
+                  AC_DEFINE(HAVE_NVIDIA,1,[NVidia support enabled])
+                ])                     
+fi
+fi
+AM_CONDITIONAL(NVIDIA, test -n "$NVIDIA_LIBS")
+AC_SUBST(NVIDIA_CFLAGS)
+AC_SUBST(NVIDIA_LIBS)
+
+# Checks Unity
+PKG_CHECK_MODULES(UNITY, 
+                 unity >= 3.4.2,
+                 [AC_DEFINE([HAVE_UNITY],[1],[Use Unity])], 
+                 [AC_MSG_WARN(Unity not present)])
+AC_SUBST(UNITY_CFLAGS)
+AC_SUBST(UNITY_LIBS)
+AM_CONDITIONAL(UNITY, test -n "$UNITY_LIBS")
+
+# libatiadl
+AC_ARG_WITH(libatiadl,
+[  --with-libatiadl[=DIR]   use libatiadlxx in DIR],[
+                  ATIADL_DIR=${withval}
+                  CPPFLAGS="${CPPFLAGS} -I${ATIADL_DIR}/include"
+                  LIBS="$LIBS -L/usr/lib/fglrx -L/usr/lib64/fglrx -L/usr/lib/catalyst -L/usr/lib64/catalyst"
+                 ]
+)
+
+AC_CHECK_HEADERS(adl_defines.h,
+       AC_CHECK_LIB(atiadlxx,ADL_Main_Control_Refresh,
+               [
+                       AC_DEFINE(HAVE_LIBATIADL,1,[libatiadl is available])
+                       LIBATIADL_CFLAGS="-I${ATIADL_DIR}/include"
+                       LIBATIADL_LIBS="-L/usr/lib/fglrx -L/usr/lib64/fglrx -L/usr/lib/catalyst -L/usr/lib64/catalyst -latiadlxx -ldl"
+               ]))
+
+AM_CONDITIONAL(LIBATIADL, test -n "$LIBATIADL_LIBS")
+AC_SUBST(LIBATIADL_CFLAGS)
+AC_SUBST(LIBATIADL_LIBS)
+
+############### psensor-server
+
+# libmicrohttpd, mandatory for psensor-server
+LIBMICROHTTPD_LIBS=
+PKG_CHECK_MODULES(LIBMICROHTTPD, 
+  libmicrohttpd, 
+  [AC_DEFINE([HAVE_LIBMICROHTTPD],[1],[Use libmicrohttpd])], 
+  [AC_MSG_WARN("libmicrohttpd not present, psensor-server will NOT be built")])
+AM_CONDITIONAL(LIBMICROHTTPD, test -n "$LIBMICROHTTPD_LIBS")
+AC_SUBST(LIBMICROHTTPD_CFLAGS)
+AC_SUBST(LIBMICROHTTPD_LIBS)
+
+# GTop, optional
+
+AC_ARG_WITH(gtop,
+[  --with-gtop[=yes|no]   use gtop],[
+       with_gtop=$withval],[
+       with_gtop="yes"
+])
+
+GTOP_LIBS=
+if test "$with_gtop" = "yes"; then
+PKG_CHECK_MODULES(GTOP, 
+  libgtop-2.0, 
+  [AC_DEFINE([HAVE_GTOP],[1],[Use GTOP])], 
+  [AC_MSG_WARN("gtop not present, CPU/Memory information will NOT be available")])
+fi
+AM_CONDITIONAL(GTOP, test -n "$GTOP_LIBS")
+AC_SUBST(GTOP_CFLAGS)
+AC_SUBST(GTOP_LIBS)
+
+AC_CONFIG_FILES([
+ Makefile
+ po/Makefile.in
+ src/Makefile
+])
+
+AC_CHECK_PROGS([HELP2MAN], [help2man])
+
+AC_CHECK_PROG(HAVE_CPPCHECK, cppcheck, yes)
+AM_CONDITIONAL(CPPCHECK, test -n "$HAVE_CPPCHECK")
+
+AC_OUTPUT