Build system

From collectd Wiki
Revision as of 06:34, 29 April 2011 by 57.90.36.29 (talk) (autoconf)

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.

Wow! That's a really neat awnesr!

automake

The AC_PLUGIN macro (see above) sets a conditional to be used in src/Makefile.am, the input files for automake. There are multiple Makefile.am'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:

if BUILD_PLUGIN_FOOBAR
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

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

Generating 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 generated 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.