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