Fixes for the load module (did not work correctly under Solaris)
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(src/collectd.c)
3 AM_INIT_AUTOMAKE(collectd, 3.4.0)
4 AM_CONFIG_HEADER(src/config.h src/libping/config.h)
5 AC_LANG(C)
6
7 AC_PREFIX_DEFAULT("/opt/collectd")
8
9 #
10 # Checks for programs.
11 #
12 AC_PROG_CC
13 AC_PROG_CPP
14 AC_PROG_INSTALL
15 AC_PROG_LN_S
16 AC_PROG_MAKE_SET
17
18 dnl configure libtool
19 AC_DISABLE_STATIC
20 AC_LIBTOOL_DLOPEN
21 AC_PROG_LIBTOOL
22 #AC_PROG_RANLIB
23
24 #
25 # Checks for header files.
26 #
27 AC_HEADER_STDC
28 AC_HEADER_SYS_WAIT
29 AC_CHECK_HEADERS(fcntl.h unistd.h)
30 AC_CHECK_HEADERS(signal.h)
31 AC_CHECK_HEADERS(sys/socket.h)
32 AC_CHECK_HEADERS(sys/select.h)
33 AC_CHECK_HEADERS(netdb.h)
34 AC_CHECK_HEADERS(sys/time.h sys/times.h)
35 AC_CHECK_HEADERS(sys/types.h)
36 AC_CHECK_HEADERS(sys/resource.h)
37 AC_CHECK_HEADERS(errno.h)
38 AC_CHECK_HEADERS(syslog.h)
39 AC_CHECK_HEADERS(dlfcn.h)
40
41 # For load module
42 AC_CHECK_HEADERS(sys/loadavg.h)
43
44 # For ping module
45 AC_CHECK_HEADERS(arpa/inet.h)
46 AC_CHECK_HEADERS(netinet/in.h)
47 AC_CHECK_HEADERS(netdb.h)
48
49 # For users module
50 AC_CHECK_HEADERS(utmp.h)
51 AC_CHECK_HEADERS(utmpx.h)
52
53 dnl Checking for libraries
54 AC_CHECK_LIB(m, ext)
55
56 #
57 # Checks for typedefs, structures, and compiler characteristics.
58 #
59 AC_C_CONST
60 AC_TYPE_PID_T
61 AC_TYPE_SIZE_T
62 AC_HEADER_TIME
63
64 #
65 # Checks for library functions.
66 #
67 AC_PROG_GCC_TRADITIONAL
68 AC_CHECK_FUNCS(gettimeofday select socket strdup strstr strtol)
69 AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
70 AC_CHECK_FUNCS(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
71 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
72 AC_CHECK_FUNCS(strncasecmp strcasecmp strncmp)
73
74 # For load module
75 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
76
77 # For users module
78 AC_CHECK_FUNCS(getutent getutxent)
79
80 AC_MSG_CHECKING([for kernel type ($host_os)])
81 case $host_os in
82         *linux*)
83         AC_DEFINE([KERNEL_LINUX], [], [True if program is to be compiled for a Linux kernel])
84         ac_system="Linux"
85         ;;
86         *solaris*)
87         AC_DEFINE([KERNEL_SOLARIS], [], [True if program is to be compiled for a Solaris kernel])
88         ac_system="Solaris"
89         ;;
90         *)
91         ac_system="unknown"
92 esac
93 AC_MSG_RESULT([$ac_system])
94
95 dnl Checks for libraries.
96 AC_CHECK_LIB(socket, socket)
97 AC_CHECK_LIB(resolv, res_search)
98 AC_CHECK_LIB(dl, dlopen)
99
100 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
101 AC_ARG_WITH(rrdtool, AC_HELP_STRING([--with-rrdtool=PFX], [Path to rrdtool.]),
102 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
103         then
104                 LDFLAGS="$LDFLAGS -L$withval/lib"
105                 CPPFLAGS="$CPPFLAGS -I$withval/include"
106                 with_rrdtool="yes"
107         fi
108 ], [with_rrdtool="yes"])
109 if test "x$with_rrdtool" = "xyes"
110 then
111         AC_CHECK_LIB(rrd, rrd_update,, [with_rrdtool="no"], [-lm])
112 fi
113 if test "x$with_rrdtool" = "xyes"
114 then
115         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no"])
116 fi
117 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
118
119 if test "$ac_system" = "Solaris"
120 then
121         with_kstat="yes"
122         AC_CHECK_LIB(kstat, kstat_open,, [with_kstat="no (not found)"])
123         AC_CHECK_LIB(devinfo, di_init)
124         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
125 else
126         with_kstat="no (Solaris only)"
127 fi
128
129 AC_ARG_WITH(libstatgrab, AC_HELP_STRING([--with-libstatgrab@<:@=PFX@:>@], [Path to libstatgrab.]),
130 [
131         # given..
132         if test "x$withval" != "xno"
133         then
134                 if test "x$withval" != "xyes"
135                 then
136                         LDFLAGS="$LDFLAGS -L$withval/lib"
137                         CPPFLAGS="$CPPFLAGS -I$withval/include"
138                         with_libstatgrab="yes"
139                 fi
140         fi
141 ],
142 [
143         # not given..
144         if test "x$ac_system" != "xunknown"
145         then
146                 with_libstatgrab="no"
147         else
148                 with_libstatgrab="yes"
149         fi
150 ])
151 if test "x$with_libstatgrab" = "xyes"
152 then
153         AC_CHECK_LIB(statgrab, sg_init,, [with_libstatgrab="no (not found)"])
154         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (not found)"])
155 fi
156
157 AC_ARG_WITH(lm-sensors, AC_HELP_STRING([--with-lm-sensors@<:@=PFX@:>@], [Path to lm_sensors.]),
158 [
159         # given..
160         if test "x$withval" != "xno"
161         then
162                 if test "x$withval" != "xyes"
163                 then
164                         LDFLAGS="$LDFLAGS -L$withval/lib"
165                         CPPFLAGS="$CPPFLAGS -I$withval/include"
166                         with_lm_sensors="yes"
167                 fi
168         fi
169 ],
170 [
171         # not given..
172         if test "x$ac_system" = "xLinux"
173         then
174                 with_lm_sensors="yes"
175         else
176                 with_lm_sensors="no"
177         fi
178 ])
179 if test "x$with_lm_sensors" = "xyes"
180 then
181         AC_CHECK_LIB(sensors, sensors_init,
182         [
183                 with_lm_sensors="yes"
184                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
185         ],
186         [with_lm_sensors="no (not found)"])
187         AC_CHECK_HEADERS(sensors/sensors.h,
188         [
189                 with_lm_sensors="yes"
190                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
191         ],
192         [with_lm_sensors="no (not found)"])
193 fi
194
195
196
197 #
198 # Check for enabled/disabled features
199 #
200 AC_ARG_ENABLE(cpu, AC_HELP_STRING([--disable-cpu], [Disable CPU usage statistics]),, [enable_cpu="yes"])
201 if test "x$enable_cpu" != "xno"
202 then
203         if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
204         then
205                 enable_cpu="yes"
206         else
207                 enable_cpu="no"
208         fi
209 fi
210 if test "x$enable_cpu" = "xno"
211 then
212         AC_DEFINE(COLLECT_CPU, 0, [Wether or not to collect CPU usage statistics])
213 fi
214 AM_CONDITIONAL(BUILD_MODULE_CPU, test "x$enable_cpu" = "xyes")
215
216 AC_ARG_ENABLE(cpufreq, AC_HELP_STRING([--disable-cpufreq], [Disable system cpu frequency statistics]),, [enable_cpufreq="yes"])
217 if test "x$enable_cpufreq" != "xno"
218 then
219         if test "x$ac_system" = "xLinux"
220         then
221                 enable_cpufreq="yes"
222         else
223                 enable_cpufreq="no"
224         fi
225 fi
226 if test "x$enable_cpufreq" = "xno"
227 then
228         AC_DEFINE(COLLECT_CPUFREQ, 0, [Wether or not to collect cpu frequency statistics])
229 fi
230 AM_CONDITIONAL(BUILD_MODULE_CPUFREQ, test "x$enable_cpufreq" = "xyes")
231
232 AC_ARG_ENABLE(disk, AC_HELP_STRING([--disable-disk], [Disable disk/partition statistics]),, [enable_disk="yes"])
233 if test "x$enable_disk" != "xno"
234 then
235         if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes"
236         then
237                 enable_disk="yes"
238         else
239                 enable_disk="no"
240         fi
241 fi
242 if test "x$enable_disk" = "xno"
243 then
244         AC_DEFINE(COLLECT_DISK, 0, [Wether or not to collect diskstats])
245 fi
246 AM_CONDITIONAL(BUILD_MODULE_DISK, test "x$enable_disk" = "xyes")
247
248 AC_ARG_ENABLE(hddtemp, AC_HELP_STRING([--disable-hddtemp], [Disable hdd temperature statistics]),, [enable_hddtemp="yes"])
249 if test "x$enable_hddtemp" = "xno"
250 then
251         AC_DEFINE(COLLECT_HDDTEMP, 0, [Wether or not to collect hdd temperature statistics])
252 fi
253 AM_CONDITIONAL(BUILD_MODULE_HDDTEMP, test "x$enable_hddtemp" = "xyes")
254
255 AC_ARG_ENABLE(load, AC_HELP_STRING([--disable-load], [Disable system load statistics]),, [enable_load="yes"])
256 if test "x$enable_load" != "xno"
257 then
258         if test "x$have_getloadavg" = "xyes" -o "x$ac_system" = "xLinux" -o "x$with_libstatgrab" = "xyes"
259         then
260                 enable_load="yes"
261         else
262                 enable_load="no"
263         fi
264 fi
265 if test "x$enable_load" = "xno"
266 then
267         AC_DEFINE(COLLECT_LOAD, 0, [Wether or not to collect system load statistics])
268 fi
269 AM_CONDITIONAL(BUILD_MODULE_LOAD, test "x$enable_load" = "xyes")
270
271 AC_ARG_ENABLE(memory, AC_HELP_STRING([--disable-memory], [Disable memory statistics]),, [enable_memory="yes"])
272 if test "x$enable_memory" != "xno"
273 then
274         if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
275         then
276                 enable_memory="yes"
277         else
278                 enable_memory="no"
279         fi
280 fi
281 if test "x$enable_memory" = "xno"
282 then
283         AC_DEFINE(COLLECT_MEMORY, 0, [Wether or not to collect memory statistics])
284 fi
285 AM_CONDITIONAL(BUILD_MODULE_MEMORY, test "x$enable_memory" = "xyes")
286
287 AC_ARG_ENABLE(nfs, AC_HELP_STRING([--disable-nfs], [Disable nfs statistics]),, [enable_nfs="yes"])
288 if test "x$enable_nfs" != "xno"
289 then
290         if test "x$ac_system" = "xLinux"
291         then
292                 enable_nfs="yes"
293         else
294                 enable_nfs="no"
295         fi
296 fi
297 if test "x$enable_nfs" = "xno"
298 then
299         AC_DEFINE(COLLECT_NFS, 0, [Wether or not to collect nfs statistics])
300 fi
301 AM_CONDITIONAL(BUILD_MODULE_NFS, test "x$enable_nfs" = "xyes")
302
303 AC_ARG_ENABLE(ping, AC_HELP_STRING([--disable-ping], [Disable ping statistics]),, [enable_ping="yes"])
304 if test "x$enable_ping" != "xno"
305 then
306         enable_ping="yes"
307 fi
308 if test "x$enable_ping" = "xno"
309 then
310         AC_DEFINE(COLLECT_PING, 0, [Wether or not to collect ping statistics])
311 fi
312 AM_CONDITIONAL(BUILD_MODULE_PING, test "x$enable_ping" = "xyes")
313
314 AC_ARG_ENABLE(processes, AC_HELP_STRING([--disable-processes], [Disable processes statistics]),, [enable_processes="yes"])
315 if test "x$enable_processes" != "xno"
316 then
317         if test "x$ac_system" = "xLinux" 
318         then
319                 enable_processes="yes"
320         else
321                 enable_processes="no"
322         fi
323 fi
324 if test "x$enable_processes" = "xno"
325 then
326         AC_DEFINE(COLLECT_PROCESSES, 0, [Wether or not to collect processes statistics])
327 fi
328 AM_CONDITIONAL(BUILD_MODULE_PROCESSES, test "x$enable_processes" = "xyes")
329
330 AC_ARG_ENABLE(sensors, AC_HELP_STRING([--disable-sensors], [Disable lm_sensors statistics]),, [enable_sensors=$with_lm_sensors])
331 if test "x$enable_sensors" != "xno"
332 then
333         if test "x$with_lm_sensors" = "xyes"
334         then
335                 enable_sensors="yes"
336         else
337                 enable_sensors="no"
338         fi
339 fi
340 if test "x$enable_sensors" = "xno"
341 then
342         AC_DEFINE(COLLECT_SENSORS, 0, [Wether or not to collect lm_sensors statistics])
343 fi
344 AM_CONDITIONAL(BUILD_MODULE_SENSORS, test "x$enable_sensors" = "xyes")
345
346 AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [Disable serial statistics]),, [enable_serial="yes"])
347 if test "x$enable_serial" != "xno"
348 then
349         if test "x$ac_system" = "xLinux"
350         then
351                 enable_serial="yes"
352         else
353                 enable_serial="no"
354         fi
355 fi
356 if test "x$enable_serial" = "xno"
357 then
358         AC_DEFINE(COLLECT_SERIAL, 0, [Wether or not to collect serial statistics])
359 fi
360 AM_CONDITIONAL(BUILD_MODULE_SERIAL, test "x$enable_serial" = "xyes")
361
362 AC_ARG_ENABLE(swap, AC_HELP_STRING([--disable-swap], [Disable swap statistics]),, [enable_swap="yes"])
363 if test "x$enable_swap" != "xno"
364 then
365         if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
366         then
367                 enable_swap="yes"
368         else
369                 enable_swap="no"
370         fi
371 fi
372 if test "x$enable_swap" = "xno"
373 then
374         AC_DEFINE(COLLECT_SWAP, 0, [Wether or not to collect swap statistics])
375 fi
376 AM_CONDITIONAL(BUILD_MODULE_SWAP, test "x$enable_swap" = "xyes")
377
378 AC_ARG_ENABLE(tape, AC_HELP_STRING([--disable-tape], [Disable tape statistics]),, [enable_tape="yes"])
379 if test "x$enable_tape" != "xno"
380 then
381         if test "x$with_kstat" = "xyes"
382         then
383                 enable_tape="yes"
384         else
385                 enable_tape="no"
386         fi
387 fi
388 if test "x$enable_tape" = "xno"
389 then
390         AC_DEFINE(COLLECT_TAPE, 0, [Wether or not to collect tape statistics])
391 fi
392 AM_CONDITIONAL(BUILD_MODULE_TAPE, test "x$enable_tape" = "xyes")
393
394 AC_ARG_ENABLE(traffic, AC_HELP_STRING([--disable-traffic], [Disable system traffic statistics]),, [enable_traffic="yes"])
395 if test "x$enable_traffic" != "xno"
396 then
397         if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
398         then
399                 enable_traffic="yes"
400         else
401                 enable_traffic="no"
402         fi
403 fi
404 if test "x$enable_traffic" = "xno"
405 then
406         AC_DEFINE(COLLECT_TRAFFIC, 0, [Wether or not to collect network traffic statistics])
407 fi
408 AM_CONDITIONAL(BUILD_MODULE_TRAFFIC, test "x$enable_traffic" = "xyes")
409
410 AC_ARG_ENABLE(users, AC_HELP_STRING([--disable-users], [Disable user count statistics]),, [enable_users="yes"])
411 if test "x$enable_users" != "xno"
412 then
413        if test "x$ac_system" = "xLinux" -o "x$ac_system" = "xSolaris"
414        then
415                enable_users="yes"
416        else
417                enable_users="no"
418        fi
419 fi
420 if test "x$enable_users" = "xno"
421 then
422        AC_DEFINE(COLLECT_USERS, 0, [Wether or not to collect user count statistics])
423 fi
424 AM_CONDITIONAL(BUILD_MODULE_USERS, test "x$enable_users" = "xyes")
425
426 AC_OUTPUT(Makefile src/libping/Makefile src/Makefile)
427
428 cat <<EOF;
429
430 Configuration:
431   Libraries:
432     librrd  . . . . . . $with_rrdtool
433     lm_sensors  . . . . $with_lm_sensors
434     libstatgrab . . . . $with_libstatgrab
435     libkstat  . . . . . $with_kstat
436
437   Features:
438     cpu . . . . . . . . $enable_cpu
439     cpufreq . . . . . . $enable_cpufreq
440     disk  . . . . . . . $enable_disk
441     hddtemp . . . . . . $enable_hddtemp
442     load  . . . . . . . $enable_load
443     memory  . . . . . . $enable_memory
444     nfs . . . . . . . . $enable_nfs
445     ping  . . . . . . . $enable_ping
446     processes . . . . . $enable_processes
447     sensors . . . . . . $enable_sensors
448     serial  . . . . . . $enable_serial
449     swap  . . . . . . . $enable_swap
450     tape  . . . . . . . $enable_tape
451     traffic . . . . . . $enable_traffic
452     users . . . . . . . $enable_users
453
454 EOF