Previous: Reentrancy, Up: Using GNU lightning


2.6 Using gnu lightning in your programs

It is very easy to include gnu lightning's source code (without the documentation and examples) into your program's distribution so that people don't need to have it installed in order to use it.

Here is a step by step explanation of what to do:

  1. Run lightningize from your package's main distribution directory.
                   lightningize
         

    This will copy the source code for the gnu lightning back ends into the lightning directory of your package.

  2. If you're using Automake, you might be pleased to know that Makefile.am files will be already there.

    If you're not using Automake and aclocal, instead, you should delete the Makefile.am files (they are of no use to you) and copy the contents of the lightning.m4 file, found in aclocal's macro repository (usually /usr/share/aclocal, to your configure.in or acinclude.m4 or aclocal.m4 file.

  3. Include a call to the LIGHTNING_CONFIGURE_IF_NOT_FOUND macro in your configure.in file.

LIGHTNING_CONFIGURE_IF_NOT_FOUND will first look for a pre-installed copy of gnu lightning and, if it can be found, it will use it; otherwise, it will test if there is a back-end for the host system. If gnu lightning is already installed, or if the system is supported by lightning, it will define the HAVE_LIGHTNING symbol.

In addition, an Automake conditional named HAVE_INSTALLED_LIGHTNING will be set if gnu lightning is already installed, which can be used to set up include paths appropriately.

Finally, LIGHTNING_CONFIGURE_IF_NOT_FOUND accepts two optional parameters: respectively, an action to be taken if gnu lightning is available, and an action to be taken if it is not.