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