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