gtk3 is optional
[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.2.13],[jeanfi@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 GTK_LIBS=
57 PKG_CHECK_MODULES(GTK, gtk+-3.0,,[AC_MSG_WARN("GTK+ 3 not present")])
58 AC_SUBST(GTK_CFLAGS)
59 AC_SUBST(GTK_LIBS)
60
61 if test "$GTK_LIBS" == ""; then
62    PKG_CHECK_MODULES(GTK, gtk+-2.0 )
63    AC_SUBST(GTK_CFLAGS)
64    AC_SUBST(GTK_LIBS)
65 fi
66
67 # Check GCONF
68 PKG_CHECK_MODULES(GCONF, gconf-2.0)
69 AC_SUBST(GCONF_CFLAGS)
70 AC_SUBST(GCONF_LIBS)
71
72 ### Optional
73
74 # Check libnotify
75 LIBNOTIFY_LIBS=
76 PKG_CHECK_MODULES(LIBNOTIFY, 
77   libnotify, 
78   [AC_DEFINE([HAVE_LIBNOTIFY],[1],[Use desktop notification])], 
79   [AC_MSG_WARN("Desktop notification disabled")])
80 AM_CONDITIONAL(LIBNOTIFY, test -n "$LIBNOTIFY_LIBS")
81 AC_SUBST(LIBNOTIFY_CFLAGS)
82 AC_SUBST(LIBNOTIFY_LIBS)
83
84 # Checks AppIndicator 
85 APPINDICATOR_LIBS=
86
87 PKG_CHECK_MODULES(APPINDICATOR, appindicator3-0.1,
88      [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator3-0.1])],
89      [AC_MSG_WARN(AppIndicator 3-0.1 not present")])
90
91 if test "$APPINDICATOR_LIBS" == ""; then
92    PKG_CHECK_MODULES(APPINDICATOR, 
93      appindicator-0.1 <= 0.2.9 , 
94      [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator 0.2.9])
95       AC_DEFINE([HAVE_APPINDICATOR_029],[1],[Use AppIndicator 0.2.9])
96      ],
97      [AC_MSG_WARN(AppIndicator 0.2.9 not present")])
98 fi
99
100 if test "$APPINDICATOR_LIBS" == ""; then
101    PKG_CHECK_MODULES(APPINDICATOR, 
102      appindicator-0.1 > 0.2.9, 
103      [AC_DEFINE([HAVE_APPINDICATOR],[1],[Use AppIndicator > 0.2.9])], 
104      [AC_MSG_WARN("AppIndicator > 0.2.9 not present")])
105 fi
106 AM_CONDITIONAL(APPINDICATOR, test -n "$APPINDICATOR_LIBS")
107 AC_SUBST(APPINDICATOR_CFLAGS)
108 AC_SUBST(APPINDICATOR_LIBS)
109
110 # Check CURL, needed for remote monitoring
111 CURL_LIBS=
112 PKG_CHECK_MODULES(CURL, 
113   libcurl, 
114   [AC_DEFINE([HAVE_CURL],[1],[Use CURL])], 
115   [AC_MSG_WARN("Remote monitoring disabled, curl missing")])
116 AM_CONDITIONAL(CURL, test -n "$CURL_LIBS")
117 AC_SUBST(CURL_CFLAGS)
118 AC_SUBST(CURL_LIBS)
119
120 # Check JSON, needed for remote monitoring
121 JSON_LIBS=
122 PKG_CHECK_MODULES(JSON, 
123   json, 
124   [AC_DEFINE([HAVE_JSON],[1],[Use JSON])], 
125   [AC_MSG_WARN("Remote monitoring disabled, json missing")])
126 AM_CONDITIONAL(JSON, test -n "$JSON_LIBS")
127 AC_SUBST(JSON_CFLAGS)
128 AC_SUBST(JSON_LIBS)
129
130 # Enables remote monitoring if JSON and CURL is present
131 if test -n "$JSON_LIBS"; then
132    if test -n "$CURL_LIBS"; then
133    AC_DEFINE([HAVE_REMOTE_SUPPORT],[1],[Remote monitoring enabled])
134    fi
135 fi
136
137 # Checks NVIDIA
138 # following code from sensors-applet
139 # sensors-applet.sourceforge.net/
140 AC_CHECK_HEADERS(NVCtrl/NVCtrl.h NVCtrl/NVCtrlLib.h, 
141                  [ HAVE_NVIDIA=true ], [], 
142                  [ 
143                   #include <X11/Xlib.h>
144                  ])
145 if test -n "${X11_LIBS}"; then
146 LIBS="${LIBS} -lX11 -lXext"
147
148 if test "${HAVE_NVIDIA}" = "true"; then
149   AC_CHECK_LIB(XNVCtrl,XNVCTRLQueryExtension, 
150                  [NVIDIA_LIBS="-lXNVCtrl -lX11 -lXext" 
151                   AC_DEFINE(HAVE_NVIDIA,1,[NVidia support enabled])
152                  ])                     
153 fi
154 fi
155 AM_CONDITIONAL(NVIDIA, test -n "$NVIDIA_LIBS")
156 AC_SUBST(NVIDIA_CFLAGS)
157 AC_SUBST(NVIDIA_LIBS)
158
159 # Checks Unity
160 PKG_CHECK_MODULES(UNITY, 
161                   unity >= 3.4.2,
162                   [AC_DEFINE([HAVE_UNITY],[1],[Use Unity])], 
163                   [AC_MSG_WARN(Unity not present)])
164 AC_SUBST(UNITY_CFLAGS)
165 AC_SUBST(UNITY_LIBS)
166 AM_CONDITIONAL(UNITY, test -n "$UNITY_LIBS")
167
168 # libatiadl
169 AC_ARG_WITH(libatiadl,
170 [  --with-libatiadl[=DIR]   use libatiadlxx in DIR],[
171                    ATIADL_DIR=${withval}
172                    CPPFLAGS="${CPPFLAGS} -I${ATIADL_DIR}/include"
173                    LIBS="$LIBS -L/usr/lib/fglrx"
174                   ]
175 )
176
177 AC_CHECK_HEADERS(adl_defines.h,
178         AC_CHECK_LIB(atiadlxx,ADL_Main_Control_Refresh,
179                 [
180                         AC_DEFINE(HAVE_LIBATIADL,1,[libatiadl is available])
181                         LIBATIADL_CFLAGS="-I${ATIADL_DIR}/include"
182                         LIBATIADL_LIBS="-L/usr/lib/fglrx -latiadlxx"
183                 ]))
184
185 AM_CONDITIONAL(LIBATIADL, test -n "$LIBATIADL_LIBS")
186 AC_SUBST(LIBATIADL_CFLAGS)
187 AC_SUBST(LIBATIADL_LIBS)
188
189 ############### psensor-server
190
191 # libmicrohttpd, mandatory for psensor-server
192 LIBMICROHTTPD_LIBS=
193 PKG_CHECK_MODULES(LIBMICROHTTPD, 
194   libmicrohttpd, 
195   [AC_DEFINE([HAVE_LIBMICROHTTPD],[1],[Use libmicrohttpd])], 
196   [AC_MSG_WARN("libmicrohttpd not present, psensor-server will NOT be built")])
197 AM_CONDITIONAL(LIBMICROHTTPD, test -n "$LIBMICROHTTPD_LIBS")
198 AC_SUBST(LIBMICROHTTPD_CFLAGS)
199 AC_SUBST(LIBMICROHTTPD_LIBS)
200
201 # GTop, optional
202
203 AC_ARG_WITH(gtop,
204 [  --with-gtop[=yes|no]   use gtop],[
205         with_gtop=$withval],[
206         with_gtop="yes"
207 ])
208
209 GTOP_LIBS=
210 if test "$with_gtop" = "yes"; then
211 PKG_CHECK_MODULES(GTOP, 
212   libgtop-2.0, 
213   [AC_DEFINE([HAVE_GTOP],[1],[Use GTOP])], 
214   [AC_MSG_WARN("gtop not present, CPU/Memory information will NOT be available")])
215 fi
216 AM_CONDITIONAL(GTOP, test -n "$GTOP_LIBS")
217 AC_SUBST(GTOP_CFLAGS)
218 AC_SUBST(GTOP_LIBS)
219
220 AC_CONFIG_FILES([
221  Makefile
222  src/Makefile
223  src/glade/Makefile
224  src/plib/Makefile
225  src/lib/Makefile
226  src/unity/Makefile
227  src/libpsensor_json/Makefile
228  src/server/Makefile
229  icons/hicolor/scalable/Makefile
230  icons/hicolor/14x14/Makefile
231  icons/hicolor/16x16/Makefile
232  icons/hicolor/22x22/Makefile
233  icons/hicolor/24x24/Makefile
234  icons/hicolor/32x32/Makefile
235  icons/hicolor/48x48/Makefile
236  icons/hicolor/64x64/Makefile
237  icons/ubuntu-mono-dark/status/22/Makefile
238  icons/ubuntu-mono-light/status/22/Makefile
239  icons/ubuntu-mono-dark/apps/22/Makefile
240  www/Makefile
241  po/Makefile.in
242  tests/Makefile
243 ])
244
245 AC_CHECK_PROGS([HELP2MAN], [help2man])
246
247 AC_OUTPUT