Login
building
Login

Building libfossil

See also: AmalgamationBuild

libfossil's canonical build system is currently aimed at platforms hosting GNU Make 3.81 or newer (most relatively recent platforms have 3.81, though some name it 'gmake' instead of 'make').

Prerequisites: libfossil requires that zlib, both the library and headers, be installed at the system level (where they normally are).

The first step is to configure the build tree, which generates some configuration and makefiles:

$ ./configure

Pass it the --help option for the list of options, but none are normally needed. If you'd like to install it it, pass --prefix=$HOME, or similar, to define the root of the installation. Files installed by make install will go under $PREFIX/bin, $PREFIX/lib, etc.

To change the compiler, pass CC=compiler-name to the configuration script. It is currently known to build cleanly with gcc and clang on x64, i386, and ARM Linux. Note that the makefiles tweak the compiler flags for those particular compilers, and may need similar tweaks for other compilers (see config.make.in). When using clang it might be useful to pass CC='clang -fno-color-diagnostics' to disable color output. Normally clang detects that automatically, but it mis-detects when compiling from xemacs and the color codes break xemacs' understanding of the output.

To build it:

$ make # or gmake

That will compile the library and a few sample/test/demo applications. Be careful with them - some modify the repository (but never without being told to).

Running Tests

The majority of the library's functionality is either covered by unit tests or tested indirectly via unit tests. The remaining functionality (which cannot be easily tested without modifying the repo) is tested via various apps.

The most fundamental of the sanity tests is the aptly-named f-sanity, which can be used like this:

$ cd f-apps
$ make # or gmake
$ ./f-sanity

If that runs to completion, without triggering an exception, the basic sanity test looks good. To be sure, though, it also should be run through valgrind:

$ valgrind --leak-check=full -v --show-reachable=yes --track-origins=yes ./f-sanity

If both of those run to completion without triggering an exception, leak, or memory usage violation, "the world is round." Note that if an assertion is triggered, valgrind will report many leaks as a side-effect, so first make sure it runs assertion-free without valgrind.

System vs. Local sqlite3

libfossil often uses bleeding-edge features of sqlite3, so it includes its own copy of sqlite3 amalgamation. Building against a system-wide libsqlite3 may or may not work properly, depending on how new it it.