libfossil  AmalgamationBuild

The Amalgamation Build

See also: building

This library supports the creation of a so-called "amalgamation build", a practice adopted from the sqlite project which compounds the sources and headers into a form which can easily be dropped into client-side projects.

To create the amalgamation you need a working build environment (GNU Make and friends):

[stephan@host:~/libfossil/src]$ make amal
Generating dependencies...
Creating ../libfossil.h...
Creating ../libfossil.c...
Trying GCC C89...
Trying GCC C99...
Trying tcc...
Man, that was FAST!
Trying clang...

It will try to compile it with various compilers if they are found in the search path.

The output is these three files:

  • libfossil-config.h holds a basic set of configuration options. This file can/should be tweaked for the target platform. The default options set there are, by design, conservative. That said, the conservative options "should" work just fine for all modern platforms.
  • libfossil.h contains header files. It #includes libfossil-config.h.
  • libfossil.c contains all of the sources. It #includes libfossil.h.

The C++ build also has an amalgamation build which requires this amalgamation. To build it, run make amal from the cpp directory.

To use the amalgamation, simply:

  • Make sure you have zlib and sqlite3 libraries and headers installed. They are preinstalled on any modern Unix system, though a newer sqlite3 might be required (which version is unknown - development typically happens against the sqlite3 trunk). Optionally, you can link in a self-compiled sqlite3.o.
  • #include "libfossil.h"
  • Compile libfossil.c
  • Link your app with libfossil.o, zlib, and sqlite3. On Unix: -lz -lsqlite3 -ldl -lpthread.
    libdl and libpthread is required by sqlite3 in some configurations.

Regarding the sqlite3 dependency: currently this library tries to work with whatever sqlite3 version is installed, but if it at some point requires features of relatively new versions then clients may need to use the sqlite3 amalgamation when building this code. The main makefile will use those two files (sqlite3.c and sqlite3.h) automatically if they are found in the src/ dir the build tree, but it does not include them in the Amalgamation build.