Build system

From collectd Wiki
Jump to: navigation, search

This page described collectd's build system, which is based on autoconf and automake.

Starting with Version 4.1 the dependency checking is done in the configure script with version 4.1. The plugins are automatically enabled or disabled, depending on whether their dependencies are met (or not) and the --enable-plugin argument can be used to force the plugin to be enabled or disabled.


The first step to include your plugin in the build process is to add it to the configure script. To do so, edit the file. You'll need to add a line with the AC_PLUGIN macro that will add:

  • the --enable-plugin argument to the configure script,
  • the BUILD_PLUGIN_PLUGIN conditional to the Makefile, and
  • the HAVE_PLUGIN_PLUGIN define to config.h.

The macro needs to be called like this:

AC_PLUGIN([name], $with_dependency, [description])

The second argument is the value of a variable which decides whether the plugin should be built or not. If your plugin does not have any dependencies outside of C99 / POSIX, you can simply pass "yes" here. Otherwise, determining if a dependency is present is, of course, the tricky part. The variable $with_dependency should be set to "yes" if the dependency is met and anything else otherwise. The first argument is simply the name of the plugin, the third is only a description for

./configure --help

It's probably a good idea to just search for the macro and copy one of the existing lines. If you plan on sending your patch to the mailing list, please note that the plugins are sorted alphabetically.


The AC_PLUGIN macro (see above) sets a conditional to be used in src/, the input files for automake. There are multiple's, one in each directory. If you want to add your own plugin to src/, the on in that directory is the one you need to edit. The conditionals are named BUILD_PLUGIN_PLUGIN. Conditionals are similar to #ifdef preprocessor statements in C: They surround the block that defines the plugin so that it's only build if the conditional is true. A typical block looks like this:

foobar_la_SOURCES = foobar.c
foobar_la_LDFLAGS = -module -avoid-version
collectd_LDADD += "-dlopen"
collectd_DEPENDENCIES +=

Again, your best bet is to copy an existing block and adapt it to your needs.

Generating configure and

After you have made your changes you need to generate the configure-script and some's. This can be done by simply typing make if you already have a configure script (the generated Makefile will check if it needs to re-generate the auto{conf,make} stuff) or by running the script from the Git repository. After that you should be ready to go.

Personal tools