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