collectd's build system
It has been asked how to include a new plugin in the build system. I have to admit that I'm not too firm with autoconf/automake myself, so this is more a "it works for me" than a "this is how it works" description.
In the past, the --enable-plugin argument was used to
enable/disable the building of plugins, with the default being "enabled" for
all plugins. This was necessary because the "server" needed the plugins to
decode received data, even if it couldn't collect data on its own. Since this is
no longer true, plugins such as apple_sensors only need to
be build when they can actually collect the values. Thus, the dependency checking has
been moved into the configure script with version 4.1. The plugins are
automatically enabled or disabled, depending on wether their dependencies are met (or
not) and the --enable-plugin argument can be used to
force the plugin to be enabled or disabled.
autoconf
There is a macro that will add
- the
--enable-pluginargument to the configure script, - the
BUILD_PLUGIN_PLUGINconditional to theMakefile, and - the
HAVE_PLUGIN_PLUGINdefine toconfig.h.
The macro needs to be called like this:
The second argument is the value of a variable which decides wether the plugin should
be built or not. This is, of course, the tricky part. The first argument is simply the
name of the plugin, the third is only a description for ./configure
--help.
automake
The AC_PLUGIN (see above) sets a conditional to be used in the
Makefile.am, named BUILD_PLUGIN_PLUGIN. This
conditional surrounds the block that defines the plugin so that it's only build if the
conditional is true. A typical block looks like this:
pkglib_LTLIBRARIES += foobar.la
foobar_la_SOURCES = foobar.c
foobar_la_LDFLAGS = -module -avoid-version
collectd_LDADD += "-dlopen" foobar.la
collectd_DEPENDENCIES += foobar.la
endif
Generate configure and Makefile.in
After you have made your changes you need to
generate the configure-script and
some Makefile.in's. This can be
done by simply typing make if you
already have a configure script
(the genereated Makefile will
check if it needs to re-generate the
auto{conf,make} stuff) or by
running the build.sh script from
the Git
repository. After that you should be
ready to go.
