Merged revisions 317 and 318 from trunk to the branches
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 3.5.0)
3 AC_CONFIG_SRCDIR(src/collectd.c)
4 AC_CONFIG_HEADERS(src/config.h)
5 AM_INIT_AUTOMAKE(dist-bzip2)
6 AC_LANG(C)
7
8 AC_PREFIX_DEFAULT("/opt/collectd")
9
10 #
11 # Checks for programs.
12 #
13 AC_PROG_CC
14 AC_PROG_CPP
15 AC_PROG_INSTALL
16 AC_PROG_LN_S
17 AC_PROG_MAKE_SET
18
19 dnl configure libtool
20 AC_DISABLE_STATIC
21 AC_LIBLTDL_CONVENIENCE
22 AC_SUBST(LTDLINCL)
23 AC_SUBST(LIBLTDL)
24 AC_LIBTOOL_DLOPEN
25 AC_PROG_LIBTOOL
26 #AC_PROG_RANLIB
27 AC_CONFIG_SUBDIRS(libltdl)
28
29 #
30 # Checks for header files.
31 #
32 AC_HEADER_SYS_WAIT
33 AC_HEADER_DIRENT
34 AC_CHECK_HEADERS(fcntl.h)
35 AC_CHECK_HEADERS(signal.h)
36 AC_CHECK_HEADERS(sys/socket.h)
37 AC_CHECK_HEADERS(sys/select.h)
38 AC_CHECK_HEADERS(netdb.h)
39 AC_CHECK_HEADERS(sys/resource.h)
40 AC_CHECK_HEADERS(errno.h)
41 AC_CHECK_HEADERS(syslog.h)
42
43 # For cpu modules
44 AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.h)
45
46 # For load module
47 AC_CHECK_HEADERS(sys/loadavg.h)
48
49 # For ping module
50 AC_CHECK_HEADERS(arpa/inet.h)
51 AC_CHECK_HEADERS(netinet/in.h)
52
53 # For users module
54 AC_CHECK_HEADERS(utmp.h)
55 AC_CHECK_HEADERS(utmpx.h)
56
57 # For quota module
58 AC_CHECK_HEADERS(grp.h pwd.h sys/ucred.h)
59 AC_CHECK_HEADERS(ctype.h)
60 AC_CHECK_HEADERS(limits.h)
61 AC_CHECK_HEADERS(sys/quota.h)
62 AC_CHECK_HEADERS(xfs/xqm.h)
63
64 # For mount interface
65 AC_CHECK_HEADERS(fs_info.h)
66 AC_CHECK_HEADERS(fshelp.h)
67 AC_CHECK_HEADERS(paths.h)
68 AC_CHECK_HEADERS(mntent.h)
69 AC_CHECK_HEADERS(mnttab.h)
70 AC_CHECK_HEADERS(sys/fstyp.h)
71 AC_CHECK_HEADERS(sys/fs_types.h)
72 AC_CHECK_HEADERS(sys/mntent.h)
73 AC_CHECK_HEADERS(sys/mnttab.h)
74 AC_CHECK_HEADERS(sys/mount.h)
75 AC_CHECK_HEADERS(sys/statfs.h)
76 AC_CHECK_HEADERS(sys/vfs.h)
77 AC_CHECK_HEADERS(sys/vfstab.h)
78
79 # For debugging interface (variable number of arguments)
80 AC_CHECK_HEADERS(stdarg.h)
81
82 dnl Checking for libraries
83 AC_CHECK_LIB(m, ext)
84
85 #
86 # Checks for typedefs, structures, and compiler characteristics.
87 #
88 AC_C_CONST
89 AC_TYPE_PID_T
90 AC_TYPE_SIZE_T
91 AC_HEADER_TIME
92
93 #
94 # Checks for library functions.
95 #
96 AC_PROG_GCC_TRADITIONAL
97 AC_CHECK_FUNCS(gettimeofday select strdup strtol)
98 AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket))
99 AC_CHECK_FUNCS(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
100 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
101 AC_CHECK_FUNCS(strncasecmp strcasecmp)
102 AC_CHECK_FUNCS(openlog syslog closelog)
103
104 # For cpu module
105 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
106
107 # For load module
108 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
109
110 # For users module
111 AC_CHECK_FUNCS(getutent getutxent)
112
113 # For quota module
114 AC_CHECK_FUNCS(quotactl)
115 AC_CHECK_FUNCS(getgrgid getpwuid)
116
117 # For mount interface
118 AC_CHECK_FUNCS(getfsent getvfsent listmntent)
119 AC_FUNC_GETMNTENT
120 if test "x$ac_cv_func_getmntent" = 'xyes'; then
121         saveCFLAGS="$CFLAGS"
122         CFLAGS="-Wall -Werror $CFLAGS"
123         AC_CACHE_CHECK([whether getmntent takes one argument],
124                 [fu_cv_getmntent1],
125                 AC_COMPILE_IFELSE(
126                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
127 #include "$srcdir/src/utils_mount.h"]],
128                                 [[(void)getmntent((FILE *)NULL);]]
129                         ),
130                         [fu_cv_getmntent1=yes],
131                         [fu_cv_getmntent1=no]
132                 )
133         )
134         if test "x$fu_cv_getmntent1" = 'xno'; then
135                 AC_CACHE_CHECK([whether getmntent takes two arguments],
136                         [fu_cv_getmntent2],
137                         AC_COMPILE_IFELSE(
138                                 AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
139 #include "$srcdir/src/utils_mount.h"]],
140                                         [[(void)getmntent((FILE *)NULL,
141                                                 (struct mnttab *)NULL);]]
142                                 ),
143                                 [fu_cv_getmntent2=yes],
144                                 [fu_cv_getmntent2=no]
145                         )
146                 )
147         fi
148         CFLAGS="$saveCFLAGS"
149 fi
150 if test "x$fu_cv_getmntent1" = 'xyes'; then
151         AC_DEFINE(HAVE_GETMNTENT1,
152                 1,
153                 [Define if there is a function named getmntent
154                         for reading the list of mounted filesystems, and
155                         that function takes a single argument. (4.3BSD,
156                         SunOS, HP-UX, Dynix, Irix, Linux)]
157                 )
158 fi
159 if test "x$fu_cv_getmntent2" = 'xyes'; then
160         AC_DEFINE(HAVE_GETMNTENT2,
161                 1,
162                 [Define if there is a function named getmntent
163                         for reading the list of mounted filesystems, and
164                         that function takes two arguments. (SVR4)]
165                 )
166 fi
167
168 AC_MSG_CHECKING([for kernel type ($host_os)])
169 case $host_os in
170         *linux*)
171         AC_DEFINE([KERNEL_LINUX], [], [True if program is to be compiled for a Linux kernel])
172         ac_system="Linux"
173         ;;
174         *solaris*)
175         AC_DEFINE([KERNEL_SOLARIS], [], [True if program is to be compiled for a Solaris kernel])
176         ac_system="Solaris"
177         ;;
178         *)
179         ac_system="unknown"
180 esac
181 AC_MSG_RESULT([$ac_system])
182
183 dnl Checks for libraries.
184 AC_CHECK_LIB(socket, socket)
185 AC_CHECK_LIB(resolv, res_search)
186
187 m4_divert_once([HELP_WITH], [
188 collectd additional packages:])
189
190 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
191 AC_ARG_WITH(rrdtool, AS_HELP_STRING([--with-rrdtool=PFX], [Path to rrdtool.]),
192 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
193         then
194                 LDFLAGS="$LDFLAGS -L$withval/lib"
195                 CPPFLAGS="$CPPFLAGS -I$withval/include"
196                 with_rrdtool="yes"
197         fi
198 ], [with_rrdtool="yes"])
199 if test "x$with_rrdtool" = "xyes"
200 then
201         AC_CHECK_LIB(rrd, rrd_update,, [with_rrdtool="no"], [-lm])
202 fi
203 if test "x$with_rrdtool" = "xyes"
204 then
205         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no"])
206 fi
207 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
208
209 AC_ARG_WITH(pth, AS_HELP_STRING([--with-pth=PFX], [Path to pth (experimental).]),
210 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
211         then
212                 LDFLAGS="$LDFLAGS -L$withval/lib"
213                 CPPFLAGS="$CPPFLAGS -I$withval/include"
214                 with_pth="yes"
215         fi
216 ], [with_pth="no"])
217 if test "x$with_pth" = "xyes"
218 then
219         AC_CHECK_LIB(pth, pth_init,, [with_pth="no"], [])
220 fi
221 if test "x$with_pth" = "xyes"
222 then
223         AC_CHECK_HEADERS(pth.h,, [with_pth="no"])
224 fi
225 if test "x$with_pth" = "xyes"
226 then
227         collect_pth=1
228 else
229         collect_pth=0
230 fi
231 AC_DEFINE_UNQUOTED(COLLECT_PTH, [$collect_pth],
232         [Wether or not to use pth (portable threads) library])
233 AM_CONDITIONAL(BUILD_WITH_PTH, test "x$with_pth" = "xyes")
234
235 if test "$ac_system" = "Solaris"
236 then
237         with_kstat="yes"
238         AC_CHECK_LIB(kstat, kstat_open,, [with_kstat="no (not found)"])
239         AC_CHECK_LIB(devinfo, di_init)
240         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
241 else
242         with_kstat="no (Solaris only)"
243 fi
244
245 AC_ARG_WITH(libstatgrab, AS_HELP_STRING([--with-libstatgrab@<:@=PFX@:>@], [Path to libstatgrab.]),
246 [
247         # given..
248         if test "x$withval" != "xno"
249         then
250                 if test "x$withval" != "xyes"
251                 then
252                         LDFLAGS="$LDFLAGS -L$withval/lib"
253                         CPPFLAGS="$CPPFLAGS -I$withval/include"
254                         with_libstatgrab="yes"
255                 fi
256         fi
257 ],
258 [
259         # not given..
260         if test "x$ac_system" != "xunknown"
261         then
262                 with_libstatgrab="no"
263         else
264                 with_libstatgrab="yes"
265         fi
266 ])
267 if test "x$with_libstatgrab" = "xyes"
268 then
269         AC_CHECK_LIB(devstat, getdevs)
270         AC_CHECK_LIB(kvm, kvm_getargv)
271         AC_CHECK_LIB(statgrab, sg_init,, [with_libstatgrab="no (not found)"])
272         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (not found)"])
273 fi
274
275 AC_ARG_WITH(lm-sensors, AS_HELP_STRING([--with-lm-sensors@<:@=PFX@:>@], [Path to lm_sensors.]),
276 [
277         # given..
278         if test "x$withval" != "xno"
279         then
280                 if test "x$withval" != "xyes"
281                 then
282                         LDFLAGS="$LDFLAGS -L$withval/lib"
283                         CPPFLAGS="$CPPFLAGS -I$withval/include"
284                         with_lm_sensors="yes"
285                 fi
286         fi
287 ],
288 [
289         # not given..
290         if test "x$ac_system" = "xLinux"
291         then
292                 with_lm_sensors="yes"
293         else
294                 with_lm_sensors="no"
295         fi
296 ])
297 if test "x$with_lm_sensors" = "xyes"
298 then
299         AC_CHECK_LIB(sensors, sensors_init,
300         [
301                 with_lm_sensors="yes"
302                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
303         ],
304         [with_lm_sensors="no (not found)"])
305         AC_CHECK_HEADERS(sensors/sensors.h,
306         [
307                 with_lm_sensors="yes"
308                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
309         ],
310         [with_lm_sensors="no (not found)"])
311 fi
312
313
314
315 #
316 # Check for enabled/disabled features
317 #
318
319 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
320 # ------------------------------------------------------------
321 dnl
322 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
323 dnl
324 AC_DEFUN(
325         [AC_COLLECTD],
326         [
327         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
328         m4_if(
329                 [$2],
330                 [enable],
331                 [dnl
332                 m4_define([EnDis],[disabled])dnl
333                 m4_define([YesNo],[no])dnl
334                 ],dnl
335                 [m4_if(
336                         [$2],
337                         [disable],
338                         [dnl
339                         m4_define([EnDis],[enabled])dnl
340                         m4_define([YesNo],[yes])dnl
341                         ],
342                         [dnl
343                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
344                         ]dnl
345                 )]dnl
346         )dnl
347         m4_if([$3], [feature], [],
348                 [m4_if(
349                         [$3], [module], [],
350                         [dnl
351                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
352                         ]dnl
353                 )]dnl
354         )dnl
355         AC_ARG_ENABLE(
356                 [$1],
357                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
358                 [],
359                 enable_$1='[YesNo]'dnl
360         )# AC_ARG_ENABLE
361 if test "x$enable_$1" = 'xno'
362 then
363         collectd_$1=0
364 else
365         if test "x$enable_$1" = 'xyes'
366         then
367                 collectd_$1=1
368         else
369                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
370                 collectd_$1=1
371                 enable_$1='yes'
372         fi
373 fi
374         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
375         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
376         ]dnl
377 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
378
379
380
381 m4_divert_once([HELP_ENABLE], [
382 collectd features:])
383 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
384 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
385
386 m4_divert_once([HELP_ENABLE], [
387 collectd modules:])
388 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
389 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
390 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
391 AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
392 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
393 AC_COLLECTD([load],      [disable], [module], [system load statistics])
394 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
395 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
396 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
397 AC_COLLECTD([processes], [disable], [module], [processes statistics])
398 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
399 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
400 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
401 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
402 AC_COLLECTD([traffic],   [disable], [module], [system traffic statistics])
403 AC_COLLECTD([users],     [disable], [module], [user count statistics])
404
405 AC_OUTPUT(Makefile src/libping/Makefile src/Makefile)
406
407 cat <<EOF;
408
409 Configuration:
410   Libraries:
411     librrd  . . . . . . $with_rrdtool
412     libpth  . . . . . . $with_pth (experimental)
413     lm_sensors  . . . . $with_lm_sensors
414     libstatgrab . . . . $with_libstatgrab
415     libkstat  . . . . . $with_kstat
416
417   Features:
418     debug . . . . . . . $enable_debug
419     daemon mode . . . . $enable_daemon
420
421   Modules:
422     cpu . . . . . LKC . $enable_cpu
423     cpufreq . . . L   . $enable_cpufreq
424     disk  . . . . LK  . $enable_disk
425     quota . . . .   A . $enable_quota (experimental)
426     hddtemp . . .   A . $enable_hddtemp
427     load  . . . . LGE . $enable_load
428     memory  . . . LKG . $enable_memory
429     nfs . . . . . L   . $enable_nfs
430     ping  . . . .   A . $enable_ping
431     processes . . L   . $enable_processes
432     sensors . . . S   . $enable_sensors
433     serial  . . . L   . $enable_serial
434     swap  . . . . LKG . $enable_swap
435     tape  . . . . K   . $enable_tape
436     traffic . . . LKG . $enable_traffic
437     users . . . .   A . $enable_users
438        A ... all systems
439        L ... Linux
440        K ... libkstat (Solaris)
441        G ... libstatgrab
442        S ... libsensors
443        C ... sysctlbyname()
444        E ... getloadavg()
445 EOF