From 3c12e8a6b1b22d5f02e2cfe9982f9b0cd5da5d7c Mon Sep 17 00:00:00 2001 From: niki Date: Sat, 17 Dec 2005 02:38:31 +0000 Subject: [PATCH] added conditions and implemented AC_COLLECTD() macro. only disk module, debug and daemon feature are using it for now. --- configure.in | 194 +++++++++++++++++++++++++++--------------------- src/Makefile.am | 8 +- 2 files changed, 116 insertions(+), 86 deletions(-) diff --git a/configure.in b/configure.in index f1fcbe53..b68e94b3 100644 --- a/configure.in +++ b/configure.in @@ -118,7 +118,7 @@ AC_CHECK_FUNCS(getgrgid getpwuid) # For mount interface AC_CHECK_FUNCS(getfsent getvfsent listmntent) AC_FUNC_GETMNTENT -if test "x$ac_cv_func_getmntent" = 'xyes'; then +if test "x$ac_cv_func_getmntent" = "xyes"; then saveCFLAGS="$CFLAGS" CFLAGS="-Wall -Werror $CFLAGS" AC_CACHE_CHECK([whether getmntent takes one argument], @@ -132,7 +132,7 @@ if test "x$ac_cv_func_getmntent" = 'xyes'; then [fu_cv_getmntent1=no] ) ) - if test "x$fu_cv_getmntent1" = 'xno'; then + if test "x$fu_cv_getmntent1" = "xno"; then AC_CACHE_CHECK([whether getmntent takes two arguments], [fu_cv_getmntent2], AC_COMPILE_IFELSE( @@ -148,7 +148,7 @@ if test "x$ac_cv_func_getmntent" = 'xyes'; then fi CFLAGS="$saveCFLAGS" fi -if test "x$fu_cv_getmntent1" = 'xyes'; then +if test "x$fu_cv_getmntent1" = "xyes"; then AC_DEFINE(HAVE_GETMNTENT1, 1, [Define if there is a function named getmntent @@ -157,7 +157,7 @@ if test "x$fu_cv_getmntent1" = 'xyes'; then SunOS, HP-UX, Dynix, Irix, Linux)] ) fi -if test "x$fu_cv_getmntent2" = 'xyes'; then +if test "x$fu_cv_getmntent2" = "xyes"; then AC_DEFINE(HAVE_GETMNTENT2, 1, [Define if there is a function named getmntent @@ -189,7 +189,7 @@ m4_divert_once([HELP_WITH], [ collectd additional packages:]) # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given]) -AC_ARG_WITH(rrdtool, AC_HELP_STRING([--with-rrdtool=PFX], [Path to rrdtool.]), +AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])], [ if test "x$withval" != "xno" && test "x$withval" != "xyes" then LDFLAGS="$LDFLAGS -L$withval/lib" @@ -199,11 +199,11 @@ AC_ARG_WITH(rrdtool, AC_HELP_STRING([--with-rrdtool=PFX], [Path to rrdtool.]), ], [with_rrdtool="yes"]) if test "x$with_rrdtool" = "xyes" then - AC_CHECK_LIB(rrd, rrd_update,, [with_rrdtool="no"], [-lm]) + AC_CHECK_LIB(rrd, rrd_update,, [with_rrdtool="no (librrd not found)"], [-lm]) fi if test "x$with_rrdtool" = "xyes" then - AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no"]) + AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"]) fi if test "x$with_rrdtool" = "xyes" then @@ -215,7 +215,7 @@ AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool], [Wether or not to use rrdtool library]) AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes") -#AC_ARG_WITH(pth, AC_HELP_STRING([--with-pth=PFX], [Path to pth (experimental).]), +#AC_ARG_WITH(pth, [AS_HELP_STRING([--with-pth=@<:@=PREFIX@:>@], [Path to pth (experimental).]), #[ if test "x$withval" != "xno" && test "x$withval" != "xyes" # then # LDFLAGS="$LDFLAGS -L$withval/lib" @@ -225,11 +225,11 @@ AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes") #], [with_pth="no"]) #if test "x$with_pth" = "xyes" #then -# AC_CHECK_LIB(pth, pth_init,, [with_pth="no"], []) +# AC_CHECK_LIB(pth, pth_init,, [with_pth="no (libpth not found)"], []) #fi #if test "x$with_pth" = "xyes" #then -# AC_CHECK_HEADERS(pth.h,, [with_pth="no"]) +# AC_CHECK_HEADERS(pth.h,, [with_pth="no (pth.h not found)"]) #fi #if test "x$with_pth" = "xyes" #then @@ -244,11 +244,17 @@ AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes") if test "$ac_system" = "Solaris" then with_kstat="yes" +else + with_kstat="no (Solaris only)" +fi +if test "x$with_kstat" = "xyes" +then AC_CHECK_LIB(kstat, kstat_open,, [with_kstat="no (libkstat not found)"]) +fi +if test "x$with_kstat" = "xyes" +then AC_CHECK_LIB(devinfo, di_init) AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"]) -else - with_kstat="no (Solaris only)" fi if test "x$with_kstat" = "xyes" then @@ -260,7 +266,7 @@ AC_DEFINE_UNQUOTED(COLLECT_KSTAT, [$collect_kstat], [Wether or not to use kstat library (Solaris)]) AM_CONDITIONAL(BUILD_WITH_KSTAT, test "x$with_kstat" = "xyes") -AC_ARG_WITH(libstatgrab, AC_HELP_STRING([--with-libstatgrab@<:@=PFX@:>@], [Path to libstatgrab.]), +AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])], [ if test "x$withval" != "xno" && test "x$withval" != "xyes" then @@ -282,6 +288,9 @@ then AC_CHECK_LIB(devstat, getdevs) AC_CHECK_LIB(kvm, kvm_getargv) AC_CHECK_LIB(statgrab, sg_init,, [with_libstatgrab="no (libstatgrab not found)"]) +fi +if test "x$with_libstatgrab" = "xyes" +then AC_CHECK_HEADERS(statgrab.h,, [with_libstatgrab="no (statgrab.h not found)"]) fi if test "x$with_libstatgrab" = "xyes" @@ -294,7 +303,7 @@ AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab], [Wether or not to use statgrab library]) AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes") -AC_ARG_WITH(lm-sensors, AC_HELP_STRING([--with-lm-sensors@<:@=PFX@:>@], [Path to lm_sensors.]), +AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])], [ if test "x$withval" != "xno" && test "x$withval" != "xyes" then @@ -318,6 +327,9 @@ then AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).]) ], [with_lm_sensors="no (libsensors not found)"]) +fi +if test "x$with_lm_sensors" = "xyes" +then AC_CHECK_HEADERS(sensors/sensors.h, [ AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the header file.]) @@ -339,47 +351,95 @@ AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes") # # Check for enabled/disabled features # -m4_divert_once([HELP_ENABLE], [ -collectd features:]) -AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], - [Enable debugging (disabled by default)]), - [], [enable_debug="no"]) -if test "x$enable_debug" = "xno" -then - collect_debug=0 -else - if test "x$enable_debug" = "xyes" - then - collect_debug=1 - else - AC_MSG_NOTICE([Please specify either --enable-debug or --disable-debug; Enabling debugging.]) - collect_debug=1 - enable_debug="yes" - fi -fi -AC_DEFINE_UNQUOTED(COLLECT_DEBUG, [$collect_debug], - [Wether or not to enable debugging]) -AM_CONDITIONAL(BUILD_DEBUG, test "x$enable_debug" = "xyes") -AC_ARG_ENABLE(daemon, AC_HELP_STRING([--disable-daemon], - [Disable daemon mode (enabled by default)]), - [], [enable_daemon="yes"]) -if test "x$enable_daemon" = "xno" -then - collect_daemon=0 +# AC_COLLECTD(name, enable/disable, info-text, feature/module) +# ------------------------------------------------------------ +dnl +m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))]) +dnl +AC_DEFUN( + [AC_COLLECTD], + [ + m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl + m4_if( + [$2], + [enable], + [dnl + m4_define([EnDis],[disabled])dnl + m4_define([YesNo],[no])dnl + ],dnl + [m4_if( + [$2], + [disable], + [dnl + m4_define([EnDis],[enabled])dnl + m4_define([YesNo],[yes])dnl + ], + [dnl + AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl + ]dnl + )]dnl + )dnl + m4_if([$3], [feature], [], + [m4_if( + [$3], [module], [], + [dnl + AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl + ]dnl + )]dnl + )dnl + AC_ARG_ENABLE( + [$1], + AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]), + [], + enable_$1='[YesNo]'dnl + )# AC_ARG_ENABLE +if test "x$enable_$1" = "xno" +then + collectd_$1=0 else - if test "x$enable_daemon" = "xyes" + if test "x$enable_$1" = "xyes" then - collect_daemon=1 + collectd_$1=1 else - AC_MSG_NOTICE([Please specify either --enable-daemon or --disable-daemon; Enabling daemon mode.]) - collect_daemon=1 - enable_daemon="yes" + AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.]) + collectd_$1=1 + enable_$1='yes' fi fi -AC_DEFINE_UNQUOTED(COLLECT_DAEMON, [$collect_daemon], - [Wether or not to enable daemon mode]) -AM_CONDITIONAL(BUILD_DAEMON, test "x$enable_daemon" = "xyes") + AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4]) + AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl + ]dnl +)# AC_COLLECTD(name, enable/disable, info-text, feature/module) + + + +#m4_divert_once([HELP_ENABLE], [ +#collectd modules:]) +#AC_COLLECTD([cpu], [disable], [module], [cpu usage statistics]) +#AC_COLLECTD([cpufreq], [disable], [module], [system cpu frequency statistics]) +#AC_COLLECTD([disk], [disable], [module], [disk/partition statistics]) +#AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)]) +#AC_COLLECTD([hddtemp], [disable], [module], [hdd temperature statistics]) +#AC_COLLECTD([load], [disable], [module], [system load statistics]) +#AC_COLLECTD([memory], [disable], [module], [memory statistics]) +#AC_COLLECTD([nfs], [disable], [module], [nfs statistics]) +#AC_COLLECTD([ping], [disable], [module], [ping statistics]) +#AC_COLLECTD([processes], [disable], [module], [processes statistics]) +#AC_COLLECTD([sensors], [disable], [module], [lm_sensors statistics]) +#AC_COLLECTD([serial], [disable], [module], [serial statistics]) +#AC_COLLECTD([swap], [disable], [module], [swap statistics]) +#AC_COLLECTD([tape], [disable], [module], [tape statistics]) +#AC_COLLECTD([traffic], [disable], [module], [system traffic statistics]) +#AC_COLLECTD([users], [disable], [module], [user count statistics]) + + + +m4_divert_once([HELP_ENABLE], [ +collectd features:]) + +AC_COLLECTD([debug], [enable], [feature], [debugging]) +AC_COLLECTD([daemon], [disable], [feature], [daemon mode]) m4_divert_once([HELP_ENABLE], [ collectd modules:]) @@ -513,25 +573,7 @@ then fi AM_CONDITIONAL(BUILD_MODULE_PROCESSES, test "x$enable_processes" = "xyes") -#AC_ARG_ENABLE(quota, AC_HELP_STRING([--enable-quota], -# [Enable quota statistics (experimental, disabled by default)]), -# [], [enable_quota="no"]) -#if test "x$enable_quota" = "xno" -#then -# collect_quota=0 -#else -# if test "x$enable_quota" = "xyes" -# then -# collect_quota=1 -# else -# AC_MSG_NOTICE([Please specify either --enable-quota or --disable-quota; Enabling quota statistics.]) -# collect_quota=1 -# enable_quota="yes" -# fi -#fi -#AC_DEFINE_UNQUOTED(COLLECT_QUOTA, [$collect_quota], -# [Wether or not to collect quota statistics]) -#AM_CONDITIONAL(BUILD_MODULE_QUOTA, test "x$enable_quota" = "xyes") +#AC_COLLECTD([quota], [enable], [module], [quota statistics (experimental)]) AC_ARG_ENABLE(sensors, AC_HELP_STRING([--disable-sensors], [Disable lm_sensors statistics]),, [enable_sensors=$with_lm_sensors]) if test "x$enable_sensors" != "xno" @@ -613,21 +655,7 @@ then fi AM_CONDITIONAL(BUILD_MODULE_TRAFFIC, test "x$enable_traffic" = "xyes") -AC_ARG_ENABLE(users, AC_HELP_STRING([--disable-users], [Disable user count statistics]),, [enable_users="yes"]) -if test "x$enable_users" != "xno" -then - if test "x$have_getutent" = "xyes" - then - enable_users="yes" - else - enable_users="no" - fi -fi -if test "x$enable_users" = "xno" -then - AC_DEFINE(COLLECT_USERS, 0, [Wether or not to collect user count statistics]) -fi -AM_CONDITIONAL(BUILD_MODULE_USERS, test "x$enable_users" = "xyes") +AC_COLLECTD([users], [disable], [module], [user count statistics]) AC_OUTPUT(Makefile src/libping/Makefile src/Makefile) diff --git a/src/Makefile.am b/src/Makefile.am index 6b94389c..6b85c035 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,15 +14,17 @@ collectd_SOURCES = collectd.c collectd.h \ collectd_CPPFLAGS = $(LTDLINCL) collectd_CPPFLAGS += -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"' collectd_CPPFLAGS += -DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"' +if BUILD_FEATURE_DAEMON collectd_CPPFLAGS += -DPIDFILE='"${localstatedir}/run/${PACKAGE_NAME}.pid"' +endif collectd_CPPFLAGS += -DPLUGINDIR='"${pkglibdir}"' +if BUILD_FEATURE_DEBUG +collectd_CPPFLAGS += -DLOGFILE='"${localstatedir}/log/${PACKAGE_NAME}/collectd.log"' +endif collectd_LDFLAGS = -export-dynamic collectd_CFLAGS = -Werror collectd_LDADD = $(LIBLTDL) "-dlopen" self collectd_DEPENDENCIES = $(LIBLTDL) -if BUILD_WITH_RRDTOOL -collectd_LDADD += -lrrd -endif pkglib_LTLIBRARIES = -- 2.30.2