Make the auto-generated config.h not conflict with other config.h.
The Autotools generated config.h (in our case autoconf.h) is not supposed to leak into users of your headers files, its meant to be private to the project being generated. But this presents some problem.
The primary problem is that our headers include autoconf.h if HAVE_CONFIG_H is set. This creates a conflict if a user of our library is also an autotools driven tool. This conflict was recently seen in libprelude, as it leaked HAVE_CONFIG_H/config.h into its public implementation, making it harder to use with any autotools application.
The correct fix is to keep any details/configuration options in config.h out of the public implementation, while this might seem easy in a new project, it can be very hard to cleanup an older code base.
The other approach is to rename the config.h to something like suricata-config.h then change the header HAVE_CONFIG_H to HAVE_SURICATA_CONFIG_H, or even drop this conditional completely as you can't build Suricata without it anyways (in a practicable way anyways). This can be taken one step further and prefixing all defines set in this header with something specific to Suricata, (eg. SC_HAVE_LUA instead of HAVE_LUA). The main problem here is its not supported by autoheader/autoreconf, but otherwise well supported by autotools, it just means maintaining the template ourselves, which is probably idea for a public exposed interface.
An example of a program that would have issues using Suricata as a library is Apache as its an autoconf managed application.
An example of a library that uses autoconf but is autoconf clean in its public interface is Jansson (https://github.com/akheron/jansson). It uses an autoheader generated internally, but a manually managed template for its public interface (https://github.com/akheron/jansson/blob/master/src/jansson_config.h.in).
We have some details in autoconf.h that can remain private to Suricata (CAPTURE_OFFLOAD_MANAGER), but we have others that affect the size of data structures that may be needed by a public/library user, for example HAVE_NFLOG will change the size of the Packet data structure.
Some more discussion on this matter here: https://stackoverflow.com/questions/19586211/correct-installation-of-config-h-for-shared-library-using-autotools
Updated by Jason Ish over 1 year ago
- Related to Task #2693: tracking: libsuricata added
Updated by Victor Julien 7 months ago
- Target version changed from 7.0.0-beta1 to 8.0.0-beta1