Starting with the Beta 4 distribution, we are using a new configuration system, which was built using the Free Software Foundation's autoconf program.  This system will hopefully make Kerberos V5 much simpler to build and reduce the amount of effort required in porting Kerberos V5 to a new platform.

Build Requirements
==================

In order to build Kerberos V5, you will need approximately 60-70 megabytes of disk space.  The exact amount will vary depending on the platform and whether the distribution is compiled with debugging symbol tables or not.

If you wish to keep a separate build tree, which contains the compiled *.o file and executables, separate from your source tree, you will need a make program which supports VPATH, or you will need to use a tool such as lndir to produce a symbolic link tree for your build tree.

Unpacking the Sources
=====================

The first step in each of these build procedures is to unpack the source distribution.  The Kerberos V5 distribution comes in two compressed tar files.  The first file, which is generally named krb5.src.tar.gz, contains the sources for all of Kerberos except for the crypto library, which is found in the file krb5.crypto.tar.gz.

Both files should be unpacked in the same directory, such as /u1/krb5.  (In the rest of this document, we will assume that you have chosen to unpack the Kerberos V5 source distribution in this directory.)

Doing the Build
===============

You have a number of different options in how to build Kerberos.  If you only need to build Kerberos for one platform, using a single directory tree which contains both the source files and the object files is the simplest.  However, if you need to maintain Kerberos for a large number of platforms, you will probably want to use separate build trees for each platform. We recommend that you look at see OS Incompatibilities for notes that we have on particular operating systems.

Building Within a Single Tree
-----------------------------

If you don't want separate build trees for each architecture, then use the following abbreviated procedure.

 1. cd /u1/krb5/src

 2. ./configure

 3. make

That's it!

Building with Separate Build Directories
----------------------------------------

If you wish to keep separate build directories for each platform, you can do so using the following procedure.  (Note, this requires that your make program support VPATH.  GNU's make will provide this functionality, for example.)  If your make program does not support this, see the next section.

For example, if you wish to create a build directory for pmax binaries you might use the following procedure:

 1. mkdir /u1/krb5/pmax

 2. cd /u1/krb5/pmax

 3. ../src/configure

 4. make

Building Using lndir
--------------------

If you wish to keep separate build directories for each platform, and you do not have access to a make program which supports VPATH, all is not lost.  You can use the lndir program to create symbolic link trees in your build directory.

For example, if you wish to create a build directory for solaris binaries you might use the following procedure:

 1. mkdir /u1/krb5/solaris

 2. cd /u1/krb5/solaris

 3. /u1/krb5/src/util/lndir `pwd`/../src

 4. ./configure

 5. make

You must give an absolute pathname to lndir because it has a bug that makes it fail for relative pathnames. Note that this version differs from the latest version as distributed and installed by the XConsortium with X11R6. Either version should be acceptable.

Testing the Build
=================

The Kerberos V5 distribution comes with built-in regression tests.  To run them, simply type the following command while in the top-level build directory (i.e., the directory where you sent typed make to start building Kerberos; see Doing the Build.):

     % make check

The DejaGnu Tests
-----------------

Some of the built-in regression tests are setup to use the DejaGnu framework for running tests. These tests tend to be more comprehensive than the normal built-in tests as they setup test servers and test client/server activities.

DejaGnu may be found wherever GNU software is archived.

Most of the tests are setup to run as a non-privledged user. There are two series of tests (rlogind and telnetd) which require the ability to rlogin as root to the local machine. Admittedly, this does require the use of a .rhosts file or some other authenticated means.  (If you are fortunate enough to have a previous version of Kerberos V5 or V4 installed, and the Kerberos rlogin is first in your path, you can setup .k5login or .klogin respectively to allow you access.)

If you cannot obtain root access to your machine, all the other tests will still run. Note however, with DejaGnu 1.2, the "untested testcases" will cause the testsuite to exit with a non-zero exit status which make will consider a failure of the testing process. Do not worry about this, as these tests are the last run when make check is executed from the top level of the build tree.

Options to Configure
====================

There are a number of options to configure which you can use to control how the Kerberos distribution is built.  The following table lists the most commonly used options to Kerberos V5's configure program.

--help

     Provides help to configure. This will list the set of commonly used options for building Kerberos.

--prefix=DIR

     By default, Kerberos will install the package's files rooted at `/usr/local' as in `/usr/local/bin', `/usr/local/sbin', etc. If you desire a different location use this option.

--exec-prefix=DIR

     This option allows one to separate the architecture independent programs from the configuration files and manual pages.

--with-cc=COMPILER

     Use COMPILER as the C compiler.

--with-ccopts=FLAGS

     Use FLAGS as the default set of C compiler flags.

     Note that if you use the native Ultrix compiler on a DECstation you are likely to lose if you pass no flags to cc; md4.c takes an estimated 3,469 billion years to compile if you provide neither the -g flag nor the -O flag to cc.

--with-cppopts=CPPOPTS

     Use CPPOPTS as the default set of C preprocessor flags.  The most common use of this option is to select certain #define's for use with the operating system's include files.

--with-linker=LINKER

     Use LINKER as the default loader if it should be different from C compiler as specified above.

--with-ldopts=LDOPTS

     This option allows one to specify optional arguments to be passed to the linker. This might be used to specify optional library paths.

--with-krb4

     This option enables Kerberos V4 backwards compatibility using the builtin Kerberos V4 library.

--with-krb4=KRB4DIR

     This option enables Kerberos V4 backwards compatibility.  The directory specified by KRB4DIR specifies where the V4 header files should be found (/KRB4DIR/include) as well as where the V4 Kerberos library should be found (/KRB4DIR/lib).

--without-krb4

     Disables Kerberos V4 backwards compatibility. This prevents Kerberos V4 clients from using the V5 services including the KDC. This would be useful if you know you will never install or need to interact with V4 clients.

--with-netlib[=libs]

     Allows for suppression of or replacement of network libraries. By default, Kerberos V5 configuration will look for -lnsl and -lsocket. If your operating system has a broken resolver library (see Solaris versions 2.0 through 2.3) or fails to pass the tests in src/tests/resolv you will need to use this option.

--enable-shared

     This option will turn on the building and use of shared library objects in the Kerberos build. This option is only supported on certain platforms.

--with-vague-errors

     If enabled, gives vague and unhelpful error messages to the client... er, attacker.  (Needed to meet silly government regulations; most other sites will want to keep this undefined.)

--with-kdc-kdb-update

     Set this option if you want to allow the KDC to modify the Kerberos database; this allows the last request information to be updated, as well as the failure count information.  Note that this doesn't work if you're using slave servers!!!  It also causes the database to be modified (and thus needing to be locked) frequently. Please note that the implementors do not regularly test this feature.

--with-kdb-db=database

     The configuration process will try to determine a working set of libraries required to implement the Kerberos database. Configure will look for interfaces that use or emulate a ndbm or dbm library. Failing that, a build in copy of the Berkeley DB code will be used. You may decide to compile a different interface than the default by specifying one of "ndbm", "dbm", or "db".

     An important note on platforms where the ndbm implementation is based on GDBM (such as the Linux Slackware distribution). GDBM has its own built in file locking which prevents simultaneous access to the database from two separate processes in which one wants to modify the database while the otherone only wants to read. (i.e. the KDC and administrative servers). In this case, you will need to specify the use of the Berkeley DB.

For example, in order to configure Kerberos on a Solaris machine using the suncc with the optimizer turned on, run the configure script with the following options:

     % ./configure --with-cc=suncc --with-ccopts=-O

osconf.h
========

There is one configuration file which you may wish to edit to control various compile-time parameters in the Kerberos distribution: include/krb5/stock/osconf.h. The list that follows is by no means complete, just some of the more interesting variables.

Please note: The former configuration file config.h no longer exists as its functionality has been merged into the auto-configuration process. See Options to Configure.

DEFAULT_PROFILE_PATH

     The pathname to the file which contains the profiles for the known realms, their KDCs, etc.

     The profile file format is no longer the same format as Kerberos V4's krb.conf file.

DEFAULT_LNAME_FILENAME

     The pathname to the database that maps authentication names to local account names.  See kdb5_anadd(8).

DEFAULT_KEYTAB_NAME

     The type and pathname to the default server keytab file (the equivalent of Kerberos V4's /etc/srvtab).

DEFAULT_KDC_ENCTYPE

     The default encryption type for the KDC.

KDCRCACHE

     The name of the replay cache used by the KDC.

RCTMPDIR

     The directory which stores replay caches.

DEFAULT_KDB_FILE

     The location of the default database

Shared Library Support
======================

Shared library support is provided for a few operating systems. There are restrictions as to which compiler to use when using shared libraries. In all cases, executables linked with the shared libraries in this build process will have built in the location of the libraries, therefore obliterating the need for special LD_LIBRARY_PATH, et al environment variables when using the programs. Except where noted, multiple versions of the libraries may be installed on the same system and continue to work.

Currently the supported platforms are: NetBSD 1.0A, AIX 3.2.5, AIX 4.1, Solaris 5.3, Alpha OSF/1 >= 2.1, HP-UX >= 9.X.

To enable shared libraries on the above platforms, run the configure script with the option --enable-shared.

One special note is that if the Kerberos V4 compatibility is compiled in, you must not specify an alternate Kerberos V4 library from the one in the tree or you will be missing references.

Theory of How Shared Libraries are Used
---------------------------------------

An explanation of how shared libraries are implemented on a given platform is too broad a topic for this manual. Instead this will touch on some of the issues that the Kerberos V5 tree uses to support version numbering and alternate install locations.

Normally when one builds a shared library and then links with it, the name of the shared library is stored in the object (i.e. libfoo.so). Most operating systems allows one to change name that is referenced and we have done so, placing the version number into the shared library (i.e. libfoo.so.0.1). At link time, one would reference libfoo.so, but when one executes the program, the shared library loader would then look for the shared library with the alternate name.  Hence multiple versions of shared libraries may be supported relatively easily.  (Under AIX for the RISC/6000, multiple versions of shared libraries are supported by combining two or more versions of the shared library into one file.  The Kerberos build procedure produces shared libraries with version numbers in the internal module names, so that the shared libraries are compatible with this scheme. Unfortunately, combining two shared libraries requires internal knowledge of the AIX shared library system beyond the scope of this document.  Practicallyspeaking, only one version of AIX shared libraries can be supported on a system, unless the multi-version library is constructed by a programmer familiar with the AIX internals.)

All operating systems (that we have seen) provide a means for programs to specify the location of shared libraries. On different operating systems, this is either specified when creating the shared library, and link time, or both. (Both are necessary sometimes as the shared libraries are dependent on other shared libraries) The build process will hardwire a path to the installed destination.

NetBSD Shared Library Support
-----------------------------

Shared library support has been tested under NetBSD 1.0A using GCC 2.4.5. Due to the vagaries of the loader in the operating system, the library load path needs to be specified in building libraries and in linking with them. Unless the library is placed in a standard location to search for libraries, this may make it difficult for developers to work with the shared libraries.

AIX Shared Library Support
--------------------------

AIX specifies shared library versions by combining multiple versions into a single file.  Because of the complexity of this process, no automatic procedure for building multi-versioned shared libraries is provided. Therefore, supporting multiple versions of the Kerberos shared libraries under AIX will require significant work on the part of a programmer famiiliar with AIX internals.

AIX allows a single library to be used both as a static library and as a shared library.  For this reason, the --enable-shared switch to configure builds only shared libraries.  On other operating systems, both shared and static libraries are built when this switch is specified.  As with all other operating systems, only non-shared static libraries are built when --enable-shared is not specified.

The AIX 3.2.5 linker dumps core trying to build a shared libkrb5.a produced with the GNU C compiler.  The native AIX compiler works fine.  In addition, the AIX 4.1 linker is able to build a shared libkrb5.a when GNU C is used.

Solaris 5.3 Shared Library Support
----------------------------------

Shared library support only works when using the Sunsoft C compiler. We are currently using version 3.0.1.

The path to the shared library must be specified at link time as well as when creating libraries.

Alpha OSF/1 Shared Library Support
----------------------------------

Shared library support has been tested with V2.1 and higher of the operating system. Shared libraries may be compiled both with GCC and the native compiler.

One of the nice features on this platform is that the paths to the shared libraries is specified in the library itself without requiring that one specify the same at link time.

We are using the -rpath option to ld to place the library load path into the executables. The one disadvantage of this is during testing where we want to make sure that we are using the build tree instead of a possibly installed library. The loader uses the contents of -rpath before LD_LIBRARY_PATH so we must specify a dummy _RLD_ROOT and complete LD_LIBRARY_PATH in our tests.

The one disadvantage with the method we are using

Operating System Incompatibilities
==================================

This section details operating system incompatibilities with Kerberos V5 which have been reported to the developers at MIT.  If you find additional incompatibilities, and/or discover work arounds to such problems, please send a report to krb5-bugs@mit.edu.  Thanks!

Ultrix 4.2/3
------------

On the DEC MIPS platform, using the native compiler, md4.c and md5.c can not be compiled with the optimizer set at level 1. That is, you must specify either --with-ccopts=-O and --with-ccopts=-g to configure.  If you don't specify either, the compile will never complete.

The optimizer isn't hung; it just takes an exponentially long time. Compiling 6 out of the 48 algorithmic steps takes 3 seconds; compiling 7 steps takes 9 seconds; compiling 8 steps takes 27 seconds, and so on. Calculations estimate it will finish in approximately 3,469 billion years....

Using GCC instead of the native compiler will also work fine, both with or without optimization.

Alpha OSF/1 V1.3
----------------

Using the native compiler, compiling with the -O compiler flag causes the asn.1 library to be compiled incorrectly.

Using GCC version 2.6.3 or later instead of the native compiler will also work fine, both with or without optimization.

Alpha OSF/1 V2.0++
------------------

There used to be a bug when using the native compiler in compiling md4.c when compiled without either the -O or -g compiler options.  We have changed the code and there is no problem under V2.1, but we do not have access to V2.0 to test and see if the problem would exist there. (We welcome feedback on this issue). There was never a problem in using GCC version 2.6.3.

In version 3.2 and beyond of the operating system, we have not seen any problems with the native compiler.

BSDI
----

BSDI versions 1.0 and 1.1 reportedly has a bad sed which causes it to go into an infinite loop during the build.  The work around is to use a sed from somewhere else, such as GNU.  (This may be true for some versions of other systems derived from BSD 4.4, such as NetBSD and FreeBSD.)

Solaris versions 2.0 through 2.3
--------------------------------

The gethostbyname() routine is broken; it does not return a fully qualified domain name, even if you are using the Domain Name Service routines.  Since Kerberos V5 uses the fully qualified domain name as the second component of a service principal (i.e, host/tsx-11.mit.edu@ATHENA.MIT.EDU), this causes problems for servers who try to figure out their own fully qualified domain name.

Workarounds:

 1. Supply your own resolver library. (such as bind-4.9.3pl1 availavle from ftp.vix.com)

 2. Upgrade to Solaris 2.4

 3. Make sure your /etc/nsswitch.conf has `files' before `dns' like:

          hosts:      files dns

     and then in /etc/hosts, make sure there is a line with your workstation's IP address and hostname, with the fully qualified domain name first.  Example:

          18.172.1.4      dcl.mit.edu dcl

     Note that making this change may cause other programs in your environment to break or behave differently.

Solaris 2.X
-----------

You must compile Kerberos V5 without the UCB compatibility libraries.  This means that /usr/ucblib must not be in the LD_LIBRARY_PATH environment variable when you compile it.  Alternatively you can use the -i option to cc, by using the specifying --with-ccopts=-i option to configure.

SGI Irix 5.X
------------

If you are building in a tree separate from the source tree, the vendors version of make does not work properly with regards to VPATH. It also has problems with standard inference rules in 5.2 (not tested yet in 5.3) so one needs to use GNU's make.

Under 5.2, there is a bug in the optional System V -lsocket library in which the routine gethostbyname() is broken. The system supplied version in -lc appears to work though so one may simply specify --with-netlib option to configure.

In 5.3, gethostbyname() is no longer present in -lsocket and is no longer an issue.

Using Autoconf
==============

(If you are not a developer, you can skip this section.)

In most of the Kerberos V5 source directories, there is a configure script which automatically determines the compilation environment and creates the proper Makefiles for a particular platform. These configure files are generated using autoconf version 2.4, which can be found in the src/util/autoconf directory in the distribution.

Normal users will not need to worry about running autoconf; the distribution comes with the configure files already prebuilt. Developers who wish to modify the configure.in files should see Overview (The Autoconf Manual).

Note that in order to run autoconf, you must have GNU m4 in your path.  Before you use the autoconf in the Kerberos V5 source tree, you may also need to run configure, and then run make in the src/util/autoconf directory in order to properly set up autoconf.

One tool which is provided for the convenience of developers can be found in src/util/reconf.  This program should be run while the current directory is the top source directory.  It will automatically rebuild any configure files which need rebuilding.  If you know that you have made a change that will require that all the configure files need to be rebuilt from scratch, specify the --force option:

     % cd /u1/krb5/src
     % ./util/reconf --force

The developmental sources are a raw source tree (before it's been packaged for public release), without the pre-built configure files. In order to build from such a source tree, you must do:

     % cd krb5/util/autoconf
     % ./configure
     % make
     % cd ../..
     % util/reconf

Then follow the instructions for building packaged source trees (above). To install the binaries into a binary tree, do:

     % cd /u1/krb5/src
     % make all
     % make install DESTDIR=somewhere-else