INSTALLATION INSTRUCTIONS FOR OPENVAS-LIBRARIES
===============================================

Please note: The reference system used by most of the developers is Debian
GNU/Linux 'Jessie' 8. The build might fail on any other system. Also it is
necessary to install dependent development packages.


Prerequisites for openvas-libraries
-----------------------------------

See at the end of this section how to easily install these prerequisites on
some supported platforms.

General build environment:
* a C compiler (e.g. gcc)
* bison
* flex
* cmake >= 2.8
* pkg-config

Specific development libraries:
* libglib >= 2.32
* libgnutls >= 3.2.15
* libgcrypt >= 1.6
* zlib
* libpcap
* libgpgme >= 1.1.2
* uuid-dev (from e2fsprogs)
* libssh >= 0.5.0
* libhiredis >= 0.10.1
* libksba >= 1.0.7

Prerequisites for building documentation:
* doxygen
* xmltoman (optional, for building man page)
* sqlfairy (optional, for producing database diagram)

Recommended to have WMI support:
* openvas-smb >= 1.0.4

Recommended to have improved SNMP support:
* netsnmp

Recommended to have LDAP support:
* libldap >= 2.4.11
  (LDAP can be disabled with -DBUILD_WITHOUT_LDAP=1)

Recommended to have RADIUS support:
* libfreeradius-client >= 1.1.6
  (RADIUS can be enabled with -DBUILD_WITH_RADIUS=1)

Install prerequisites on Debian GNU/Linux 'Jessie' 8:
# apt-get install dpkg-dev pkg-config libssh-dev libgnutls28-dev libglib2.0-dev \
  libpcap-dev libgpgme11-dev uuid-dev bison libksba-dev libhiredis-dev \
  libsnmp-dev libgcrypt20-dev libldap2-dev


Compiling openvas-libraries
---------------------------

If you have installed required libraries to a non-standard location, remember to
set the PKG_CONFIG_PATH environment variable to the location of your pkg-config
files before configuring:

    $ export PKG_CONFIG_PATH=/your/location/lib/pkgconfig:$PKG_CONFIG_PATH

Create a build directory and change into it with

    $ mkdir build
    $ cd build

Configure the build with

    $ cmake -DCMAKE_INSTALL_PREFIX=/path/to/your/installation ..

or (if you want to use the default installation path /usr/local)

    $ cmake ..

This only needs to be done once.

Thereafter, the following commands are useful.

    $ make                # build the libraries
    $ make doc            # build the documentation
    $ make doc-full       # build more developer-oriented documentation
    $ make install        # install the build
    $ make rebuild_cache  # rebuild the cmake cache

Please note that you may have to execute "make install" as root, especially if
you have specified a prefix for which your user does not have full permissions.

To clean up the build environment, simply remove the contents of the "build"
directory you created above.


Configuration Options
---------------------

During compilation, the build process uses a set of compiler options which
enable very strict error checking and ask the compiler to abort should it detect
any errors in the code. This is to ensure a maximum of code quality and
security.

Unfortunately, some (especially newer) compiler can be more strict than others
when it comes to error checking. While this is a good thing and the OpenVAS
developers aim to address all compiler warnings, it may lead the build process
to abort on your system. Below you will find a list of the most common warnings
and what you can do about them.

* "call to function ‘xyz’ without a real prototype"

This warning shows up on recent openSUSE versions due to a compiler option only
present on these systems. To tell the build process to not abort the build
process on this warning, add -DIGNORE_UNPROTOTYPED_CALLS=1 to your configuration
command, for example:

    $ cmake -DIGNORE_UNPROTOTYPED_CALLS=1 .

Should you notice any other error messages causing your build process to abort,
do not hesitate to contact the OpenVAS developers using the mailing lists or IRC
chat. Don't forget to include the name and version of your system and
distribution in your message.


Building OpenVAS Libraries statically linked
--------------------------------------------

If you want to build a statically linked version of OpenVAS Libraries -- for
example to subsequently build a statically linked OMP command line client or
Nagios plugin from the "openvas-cli" module -- you need statically linked
versions of the prerequisite libraries as well.

This can be a problem with current versions of the GnuTLS library. In most
distributions GnuTLS is built with p11-kit support, which makes linking
statically against the GnuTLS library impossible. To work around this, you can
build the GnuTLS yourself after configuring it without support for p11-kit. This
can be done with the following parameters:

    $ ./configure --disable-shared --enable-static --without-p11-kit

Note that you will most likely want to add additional parameters to configure
the GnuTLS library based on your distributions policy and/or your personal
needs, e.g. the correct prefix so OpenVAS Libraries will find you statically
linked version. The "make install" command will then build the GnuTLS library
and install it into the path you configured.

Once you have build and installed the GnuTLS library, configure OpenVAS
Libraries with the following parameters to request statically linked versions of
the "base", "misc" and "omp" modules:

   $ cmake -DBUILD_STATIC=1 -DBUILD_SHARED=0 -DOPENVAS_OMP_ONLY=1 ..

Once again, the "make install" command will build and install the requested
modules.

For instructions on building statically linked binaries from the "openvas-cli"
module please see the INSTALL file there.


Static code analysis with the Clang Static Analyzer
---------------------------------------------------

If you want to use the Clang Static Analyzer (http://clang-analyzer.llvm.org/)
to do a static code analysis, you can do so by adding the following parameter
when configuring the build:

  -DCMAKE_C_COMPILER=/usr/share/clang/scan-build/ccc-analyzer

Note that the example above uses the default location of ccc-analyzer in Debian
GNU/Linux and may be different in other environments.

To have the analysis results aggregated into a set of HTML files, use the
following command:

    $ scan-build make

The tool will provide a hint on how to launch a web browser with the results.

It is recommended to do this analysis in a separate, empty build directory and
to empty the build directory before "scan-build" call.
