(no commit message)
[psensor.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.64])
5 AC_INIT([psensor], [0.6.1.7],[wpitchoune@gmail.com],[psensor],[http://wpitchoune.net/psensor])
6
7 AM_INIT_AUTOMAKE([-Wall -Werror gnu])
8
9 AC_CONFIG_SRCDIR([src/compat.h])
10 AC_CONFIG_HEADERS([config.h])
11
12 # Checks for programs.
13 AC_PROG_CC
14 AM_PROG_CC_C_O
15
16 # Checks lib build
17 AC_PROG_RANLIB
18
19 # Checks for header files.
20 AC_PATH_X
21 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h getopt.h])
22
23 # Checks for typedefs, structures, and compiler characteristics.
24 AC_TYPE_SIZE_T
25 AC_TYPE_SSIZE_T
26
27 # Checks for library functions.
28 AC_FUNC_MALLOC
29 AC_FUNC_REALLOC
30 AC_CHECK_FUNCS([gettimeofday memmove socket strdup strtol])
31
32 AM_GNU_GETTEXT_VERSION([0.16])
33 AM_GNU_GETTEXT([external])
34
35 ############### common 
36
37 # Checks sensors, required by psensor and psensor-server
38 AC_CHECK_LIB(sensors, sensors_init)
39 AC_CHECK_HEADERS([sensors/sensors.h sensors/errors.h])
40 SENSORS_LIBS=-lsensors
41 AC_SUBST(SENSORS_LIBS)
42
43 ############### psensor 
44
45 ### Required
46
47 PKG_CHECK_MODULES(X11, x11)
48 AC_SUBST(X11_CFLAGS)
49 AC_SUBST(X11_LIBS)
50
51 PKG_CHECK_MODULES(XEXT, xext)
52 AC_SUBST(XEXT_CFLAGS)
53 AC_SUBST(XEXT_LIBS)
54
55 # Checks GTK 
56 PKG_CHECK_MODULES(GTK, gtk+-2.0 )
57 AC_SUBST(GTK_CFLAGS)
58 AC_SUBST(GTK_LIBS)
59
60 # Check GCONF
61 PKG_CHECK_MODULES(GCONF, gconf-2.0)
62 AC_SUBST(GCONF_CFLAGS)
63 AC_SUBST(GCONF_LIBS)
64
65 ### Optional
66
67 # Check libnotify
68 LIBNOTIFY_LIBS=
69 PKG_CHECK_MODULES(LIBNOTIFY, 
70   libnotify, 
71   [AC_DEFINE([HAVE_LIBNOTIFY],[1],[Use desktop notification])], 
72   [AC_MSG_WARN("Desktop notification disabled")])
73 AM_CONDITIONAL(LIBNOTIFY, test -n "$LIBNOTIFY_LIBS")
74 AC_SUBST(LIBNOTIFY_CFLAGS)
75 AC_SUBST(LIBNOTIFY_LIBS)
76
77 # Checks AppIndicator 
78 APPINDICATOR_LIBS=
79 PKG_CHECK_MODULES(APPINDICATOR, 
80   appindicator-0.1, 
81   [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator])], 
82   [AC_MSG_WARN("AppIndicator disabled")])
83 AM_CONDITIONAL(APPINDICATOR, test -n "$APPINDICATOR_LIBS")
84 AC_SUBST(APPINDICATOR_CFLAGS)
85 AC_SUBST(APPINDICATOR_LIBS)
86
87 # Check CURL, needed for remote monitoring
88 CURL_LIBS=
89 PKG_CHECK_MODULES(CURL, 
90   libcurl, 
91   [AC_DEFINE([HAVE_CURL],[1],[Use CURL])], 
92   [AC_MSG_WARN("Remote monitoring disabled, curl missing")])
93 AM_CONDITIONAL(CURL, test -n "$CURL_LIBS")
94 AC_SUBST(CURL_CFLAGS)
95 AC_SUBST(CURL_LIBS)
96
97 # Check JSON, needed for remote monitoring
98 JSON_LIBS=
99 PKG_CHECK_MODULES(JSON, 
100   json, 
101   [AC_DEFINE([HAVE_JSON],[1],[Use JSON])], 
102   [AC_MSG_WARN("Remote monitoring disabled, json missing")])
103 AM_CONDITIONAL(JSON, test -n "$JSON_LIBS")
104 AC_SUBST(JSON_CFLAGS)
105 AC_SUBST(JSON_LIBS)
106
107 # Enables remote monitoring if JSON and CURL is present
108 if test -n "$JSON_LIBS"; then
109    if test -n "$CURL_LIBS"; then
110    AC_DEFINE([HAVE_REMOTE_SUPPORT],[1],[Remote monitoring enabled])
111    fi
112 fi
113
114 # Checks NVIDIA
115 # following code from sensors-applet
116 # sensors-applet.sourceforge.net/
117 AC_CHECK_HEADERS(NVCtrl/NVCtrl.h NVCtrl/NVCtrlLib.h, 
118                  [ HAVE_NVIDIA=true ], [], 
119                  [ 
120                   #include <X11/Xlib.h>
121                  ])
122 if test -n "$X11_LIBS}"; then
123 LIBS="${LIBS} -lX11 -lXext"
124
125 if test "${HAVE_NVIDIA}" = "true"; then
126   AC_CHECK_LIB(XNVCtrl,XNVCTRLQueryExtension, 
127                  [NVIDIA_LIBS="-lXNVCtrl -lX11 -lXext" 
128                   AC_DEFINE(HAVE_NVIDIA,1,[NVidia support enabled])
129                  ])                     
130 fi
131 fi
132 AM_CONDITIONAL(NVIDIA, test -n "$NVIDIA_LIBS")
133 AC_SUBST(NVIDIA_CFLAGS)
134 AC_SUBST(NVIDIA_LIBS)
135
136 ############### psensor-server
137
138 # Checks Lua 5.1 (required)
139 LUA_LIBS=
140 PKG_CHECK_MODULES(LUA, 
141   lua, 
142   [AC_DEFINE([HAVE_LUA],[1],[Use Lua])], 
143   [AC_MSG_WARN(Lua not present, checks Lua5.1)])
144
145 # Ubuntu pkg module is lua5.1 not lua
146 if test "$LUA_LIBS" == ""; then
147    PKG_CHECK_MODULES(LUA, 
148      lua5.1, 
149      [AC_DEFINE([HAVE_LUA],[1],[Use Lua5.1])], 
150      [AC_MSG_WARN(Lua5.1 not present, psensor-server will NOT be built")])
151 fi
152 AM_CONDITIONAL(LUA, test -n "$LUA_LIBS")
153 AC_SUBST(LUA_CFLAGS)
154 AC_SUBST(LUA_LIBS)
155
156 # libmicrohttpd, mandatory for psensor-server
157 LIBMICROHTTPD_LIBS=
158 PKG_CHECK_MODULES(LIBMICROHTTPD, 
159   libmicrohttpd, 
160   [AC_DEFINE([HAVE_LIBMICROHTTPD],[1],[Use libmicrohttpd])], 
161   [AC_MSG_WARN("libmicrohttpd not present, psensor-server will NOT be built")])
162 AM_CONDITIONAL(LIBMICROHTTPD, test -n "$LIBMICROHTTPD_LIBS")
163 AC_SUBST(LIBMICROHTTPD_CFLAGS)
164 AC_SUBST(LIBMICROHTTPD_LIBS)
165
166 # GTop, optional
167
168 AC_ARG_WITH(gtop,
169 [  --with-gtop[=yes|no]   use gtop],[
170         with_gtop=$withval],[
171         with_gtop="yes"
172 ])
173
174 GTOP_LIBS=
175 if test "$with_gtop" = "yes"; then
176 PKG_CHECK_MODULES(GTOP, 
177   libgtop-2.0, 
178   [AC_DEFINE([HAVE_GTOP],[1],[Use GTOP])], 
179   [AC_MSG_WARN("gtop not present, CPU/Memory information will NOT be available")])
180 fi
181 AM_CONDITIONAL(GTOP, test -n "$GTOP_LIBS")
182 AC_SUBST(GTOP_CFLAGS)
183 AC_SUBST(GTOP_LIBS)
184
185 AC_CONFIG_FILES([
186  Makefile
187  src/Makefile
188  src/plib/Makefile
189  src/lib/Makefile
190  src/libpsensor_json/Makefile
191  src/server/Makefile
192  pixmaps/scalable/Makefile
193  pixmaps/48x48/Makefile
194  www/Makefile
195  po/Makefile.in
196  tests/Makefile
197 ])
198
199 AC_CHECK_PROGS([HELP2MAN], [help2man])
200
201 AC_OUTPUT