## Berkeley DB: Building for UNIX platforms

Building Berkeley DB on a UNIX platform
Berkeley DB's configuration options
Changing compilers, libraries or compiler and loader options
Installing Berkeley DB

### Building Berkeley DB on a UNIX platform:

To perform the default build of Berkeley DB, first change to the build_unix directory, and then enter the following two commands:

    	../dist/configure
    	make

This will build the Berkeley DB library. To install the Berkeley DB library, enter:

    	make install

See below for specific information on what files are installed and in what directories, and how to configure installation on a per-system basis.

If you want to rebuild DB, enter:

    	make clean
    	make

If you change your mind about how Berkeley DB is configured, you must start from scratch by entering:

    	make distclean
    	../dist/configure
    	make

To build multiple UNIX versions of Berkeley DB in the same source tree, create a new directory at the same level as build_unix, and then configure and build.

    	mkdir build_bsdos3.0
    	cd build_bsdos3.0
    	../dist/configure
    	make

Java support cannot be built using the configuration options. To configure and build the Java API, see the file db/java/README for more information.

If you have trouble with any of these commands, please send email to the addresses found in the Sleepycat Software contact information. In that email, please provide a complete copy of the commands that you entered and their output.

### Berkeley DB's configuration options:

There are many options that you can enter to the configuration program, only a few of which are Berkeley DB specific. To see a complete list of the options, enter ../dist/configure --help.

The Berkeley DB specific options are as follows:

--enable-cxx:

If you want to include C++ interfaces in the library, enter --enable-cxx as an argument to configure.

--enable-debug:

If you want to build Berkeley DB with -g as a compiler flag and with DEBUG #defined during compilation, enter --enable-debug as an argument to configure. This will create Berkeley DB with debugging symbols, as well as load various routines that can be called from a debugger to display pages, cursor queues and so forth. This flag should probably not be defined when configuring to build production binaries, although there shouldn't be any significant performance degradation.

--enable-diagnostic:

If you want to build Berkeley DB with debugging run-time sanity checks and with DIAGNOSTIC #defined during compilation, enter --enable-diagnostic as an argument to configure. This will cause a number of special checks to be performed when Berkeley DB is running. This flag should NOT be defined when configuring to build production binaries, as you will lose a significant amount of performance.

--enable-compat185:

If you want to compile or load Berkeley DB 1.85 applications against the DB 2.0 library, enter --enable-compat185 as an argument to configure. This will include Berkeley DB 1.85 API compatibility code in the library.

--enable-dump185:

If you need to convert Berkeley DB 1.85 (or earlier) databases to Berkeley DB 2.0 databases, enter --enable-dump185 as an argument to configure. This will build the dump_185 utility. This utility will dump Berkeley DB 1.85 and 1.86 databases in a format readable by the db_load utility. For more information, see db_dump and db_load.

The system libraries with which you are loading the dump_185 utility MUST already contain the Berkeley DB 1.85 library routines for this to work, as the Berkeley DB distribution does not include them. If you are using a non-standard library for the Berkeley DB 1.85 library routines, you will have to change the Makefile that the configuration step creates to load the dump_185 utility with that library.

--enable-test:

If you want to build the Tcl test suite, enter --enable-test as an argument to configure. The Tcl test suite will only build if the Tcl libraries and include files are already available on the system!

--disable-bigfile:

Some systems, notably versions of AIX, HP/UX and Solaris, require special compile-time options in order to create files larger than 2^32 bytes. These options are automatically enabled when Berkeley DB is compiled. For this reason, binaries built on current versions of these systems may not run on earlier versions of the system, as the library and system calls necessary for large files are not available. To disable building with these compile-time options, enter --disable-bigfile as an argument to configure.

### Changing compilers, libraries or compiler and loader options:

You can specify a compiler and/or compile and load time flags by using environment variables during configuration. For example, if you want to use a specific compiler, specify the CC environment variable before running configure:

env CC=gcc ../dist/configure

Using anything other than the native compiler will almost certainly mean that you'll want to check the compile and load line flags, too.

To specify debugging and optimization options for the C compiler, use the CFLAGS environment variable:

env CFLAGS=-O2 ../dist/configure

To specify header file search directories and other miscellaneous options for the C preprocessor and compiler, use the CPPFLAGS environment variable:

env CPPFLAGS=-I/usr/contrib/include ../dist/configure

To specify debugging and optimization options for the C++ compiler, use the CXXFLAGS environment variable:

env CXXFLAGS=-Woverloaded-virtual ../dist/configure

To specify miscellaneous options for the linker, use the LDFLAGS environment variable:

env LDFLAGS="-N32" ../dist/configure

If the Tcl or any other include files or libraries are in non-standard places on your system, you will need to specify the directory path where they can be found.

If you want to specify additional libraries and library directories, set the LIBS environment variable before running configure. For example:

env LIBS="-L/a/b -L/e/f -lposix" ../dist/configure

would specify two additional directories to search for libraries, /a/b and /e/f, and one additional library to load, "posix".

Make sure that you prepend -L to any library directory names and that you prepend -I to any include file directory names! Also, make sure that you quote the arguments as shown above, i.e. with single or double quotes around the values you're specifying for LIBS, if they contain blank or tab characters.

The env command is available on most systems, and simply sets one or more environment variables before running a command. If the env command is not available to you, you can set the environment variables in your shell before running configure. For example, in sh or ksh, you could do:

LIBS="-L/a/b -L/e/f -ldb" ../dist/configure

and in csh or tcsh, you could do:

setenv LIBS "-L/a/b -L/e/f -ldb" ../dist/configure

See your shell's manual page for further information.

### Installing Berkeley DB:

Berkeley DB installs the following files into the following locations, with the following default values:

Variables | Default value
--- | ---
prefix | /usr/local
bindir | $(prefix)/BerkeleyDB/bin
includedir | $(prefix)/BerkeleyDB/include
libdir | $(prefix)/BerkeleyDB/lib
mandir | $(prefix)/BerkeleyDB/docs
File(s) | Default location
db.h, db_cxx.h, db_185.h | $(includedir)
libdb.a | $(libdir)
utilities | $(bindir)
documentation | $(mandir)

To move the entire installation tree to somewhere besides /usr/local, change the value of prefix. To move the binaries to a different place, change the value of bindir. The values of includedir, libdir and mandir may be similarly changed. These values can be changed as part of configuration:

../dist/configure --prefix=/usr/contrib

or when doing the install itself:

make prefix=/usr/contrib install

Note, the installation process will attempt to create any directories that do not already exist on the system.