(no commit message)
[openafs-wiki.git] / AFSLore / HowToBuildOpenAFSFromSource.mdwn
index 5414fb5..88a8ea1 100644 (file)
-This is a guide on how to build [[OpenAFS]] from source code. Note that [[OpenAFS]] pre-built binaries are available on the [[OpenAFS]] site and are available as prebuilt packages for many platforms. These instructions may be useful for you if you need to build [[OpenAFS]] from source.
+This page describes how to build OpenAFS binaries from source code.
+The information is specific to unix-like systems. See the
+README-WINDOWS file in the root of the OpenAFS source code tree for
+instructions and software needed to build OpenAFS on Microsoft Windows.
 
-### <a name="Platform Requirements"></a> Platform Requirements
+Unless otherwise noted, the information on this page is for version 1.6.x
+(available as pre-release 3 at the time of this writing).
 
-(this is where we list requirements like krb)
+## The Short Version
 
-### <a name="Development Tools Requirements"></a> Development Tools Requirements
+For the impatient, this section describes how to get a code tree and
+build it, assuming you have a development environment already setup.
 
-(list the required tools needed to build openafs)
+The following shows how to download source code tarballs and build the
+OpenAFS binaries:
 
-### <a name="Getting the Source Code"></a> Getting the Source Code
+    $ wget http://openafs.org/dl/openafs/<version>/openafs-<version>-src.tar.bz2
+    $ wget http://openafs.org/dl/openafs/<version>/openafs-<version>-doc.tar.bz2
+    $ tar xjf openafs-<version>-src.tar.bz2 
+    $ tar xjf openafs-<version>-doc.tar.bz2 
+    $ cd openafs-<version>
+    $ ./configure
+    $ make
 
-(show how to get the code from the openafs cvs repo. list most important branches)
+See <http://openafs.org/dl/openafs> for available versions.
 
-### <a name="Building the Binaries"></a> Building the Binaries
+The following shows how to do a git checkout and build the OpenAFS binaries,
 
-(show how to run regen, configure, give guidance on config parameters
+    $ git clone git://git.openafs.org/openafs.git
+    $ cd openafs
+    $ git checkout <branch-or-tag>
+    $ ./regen.sh
+    $ ./configure
+    $ make
 
-### <a name="Installing the Binaries"></a> Installing the Binaries
+You will usually want to specify configure options. For example, to enable the
+traditional Transarc/IBM AFS installation paths, run configure with the
+--enable-transarc-paths option. (Read on for more information about configure
+options.)
 
-(show how to install the binaries. explain the paths...)
+    $ ./configure --enable-transarc-paths $ make
+    $ make
+    $ make dest 
 
-### <a name="Initial testing"></a> Initial testing
+See the end of this page for instructions on how to build RPM packages.
+
+## Build OpenAFS 
+
+Building and packaging OpenAFS is not difficult on current unix-like
+systems. A small number of fairly common libraries and tools are required. The
+kernel headers and a compiler capable of building a kernel module is needed to
+build the OpenAFS kernel module (used by the cache manager and for
+inode-backend fileservers.) The gnu autoconf and automake tools are used to
+configure the build system, so should be familiar to most people accustomed to
+building binaries on unix-like systems.
+
+Begin by verifying you have the prerequisite tools and libraries installed on your
+build host. These are listed in the next section. You will need to obtain the
+OpenAFS source code, either by downloading a release tar file, or by checking
+out a version from the git repository.
+
+See the README file for details on building OpenAFS and platform specific
+notes. See src/SOURCE-MAP for a brief description of each source code component.
+
+A script called regen.sh is used to build the configure script and to
+generate the man page documentation from perl pod formatted files.
+
+The configure sets up the build system for your platform. Configure will
+attempt to detect your platform type and capabilities. Configure will generate
+the makefiles using automake. You may need to specify configure options to
+enable certain compile-time features. Run ./configure --help to see a
+complete list of the available configure options.
+
+After a successful run of configure, run make in the top level directory to
+build all the client and server OpenAFS binaries. The server binaries, user and
+admin tools, and the cache manager can be installed manually if you are not
+using your systems package manager, for example if you are installing OpenAFS
+on solaris, or if the target system is being used for testing and development.
+The installation paths depend on the configure options specified.
+
+The process for building rpm packages is actually a bit different than what was
+just described above.  Packaging scripts in the source tree are used to build
+rpms from a source code tree tar file. You'll need to create two tar files, one
+of the source and one of the documentation. A script is run to build a source
+rpm, which can be used to build the various rpm packages.  Details are given
+below in the section Building RPMs.
+
+## Prerequisites
+
+The following tools are needed to build OpenAFS from source from a tar file:
+
+- make
+- compiler
+- assembler
+- linker
+- ranlib
+- lex/yacc
+- install
+- perl 5.6 or better (only to build the documention)
+
+In addtion to the above, the following tools are needed to build OpenAFS 
+from a git checkout:
+
+- git
+- autoconf 2.60 or better
+- automake
+
+The compiler used must be capable of building kernel modules for the target
+platform.
+
+> Note for RHEL users: RedHat Enterprise Linux 5.5 and less shipped with a
+> version of autoconf too old to generate the OpenAFS configure script.
+> Fortunately, the recently released RHEL 6.0 shipped with a more up to date
+> version of autoconf which mets the minimum version needed to generate the
+> configure script.
+
+The following tools are needed to build OpenAFS RPMS:
+
+- perl 5.6 or better
+- rpmbuild
+
+The following development libraries are needed:
+
+- libc
+- kerberos 5
+- ncurses (optional, needed to build scout/afsmonitor)
+- pam (optional)
+- kernel headers
+
+The ncurses libraries are needed to build the ncurses based admin tools
+scout and afsmonitor. The kerberos 5 libraries are needed to build kerberos 5
+support, which is *strongly* recommended.
+
+### Linux Debian Packages
+
+On a Debian-based linux distribution, all of the required packages can be
+install with the following commands apt-get commands,
+
+    $ apt-get install git-core autoconf automake make gcc flex bison
+    $ apt-get install libc6-dev libkrb5-dev libncurses5-dev linux-headers-$(uname -r)
+
+### Linux RPM Packages
+
+On a RedHat-based linux distributions, all of the required packages can be
+installed with the following yum commands,
+
+     $ yum install git-core gcc autoconf automake make flex bison rpm-build
+     $ yum install glibc-devel krb5-devel ncurses-devel pam-devel kernel-devel-$(uname -r)
+
+### Solaris Packages
+
+For Solaris packages, start by installing pkg-get, if you have not already.
+
+     $ wget http://www.opencsw.org/pkg-get
+     $ pkgadd -d /path/to/pkg-get
+     $ wget --output-document=/tmp/gpg.key http://www.opencsw.org/get-it/mirrors/
+     $ gpg --import /tmp/gpg.key
+
+Check to make sure pkg-get is installed properly by doing a pkg-get compare.
+It should output a list of installed packages compared to up-to-date remote packages.
+
+With pkg-get installed, go ahead and begin installing the necessary packages
+
+     $ pkg-get install gcc flex bison automake autoconf gmake
+     $ pkg-get install krb5_kdc ncurses
+
+## Getting the Source Code
+
+See [[GitDevelopers]] for details on how to use git to fetch OpenAFS source
+code and to submit source code changes to the OpenAFS project. This is the
+preferred method to retrieve the source code.  Briefly, first create a local
+clone of the git repository and then checkout a local branch of the version you
+need to build.  For example,
+
+    $ git clone git://git.openafs.org/openafs.git
+    $ cd openafs
+    $ git checkout openafs-stable-<major>-<minor>-<patchlevel>
+
+Compressed tar files of the source tree are made available for each stable and
+development release. The most recent release is located at
+<http://openafs.org/release/latest.html>.  Archives for releases are located at
+/afs/openafs.org/software/openafs/ and <http://dl.openafs.org/dl>. For example,
+to download and uncompress version 1.4.14,
+
+    $ wget http://dl.openafs.org/dl/1.4.14/openafs-1.4.14-src.tar.bz2
+    $ wget http://dl.openafs.org/dl/1.4.14/openafs-1.4.14-doc.tar.bz2
+    $ tar xjf openafs-1.4.14-src.tar.bz2
+    $ tar xjf openafs-1.4.14-doc.tar.bz2
+    $ cd openafs-1.4.14
+
+The -src archive contains the source code and the -doc archive contains the
+documentation in xml and pod format. Having a separate archive for
+documentation allows people working on documentation to download just the pod
+and xml portions of the project.
+
+### Regen
+
+After a git checkout, run the regen.sh shell script to generate a
+configure script (and a configure-libafs script) and to generate
+the man pages. The regen.sh script runs the autoconf tools to
+generate the configure scripts and runs perl to generate the
+man pages.
+
+    ./regen.sh
+
+You can skip the generation of the man pages by specifying the '-q'
+option to regen.sh.
+
+    ./regen.sh -q
+
+Always run regen.sh again (and then configure) if you change any of the OpenAFS
+m4 autoconf macros, such as configure.ac or any of the macros under src/cf.
+
+## Configure
+
+The OpenAFS configure script has many options available. Take some time to read
+the README file and the output of configure --help before running configure the
+first time. The most common options are introduced below.
+
+### AFS sysname
+
+AFS uses an identifier called a *sysname* to distinguish platforms. configure
+will automatically detect the sysname of the build system and by default
+assumes the target system matches. If you are building for a target system
+which is different than the build system, or if for some reason the sysname
+detection fails, you will need to manually specify the sysname with the
+--with-afs-sysname option.  See the README file for a complete list of sysnames.
+
+The 'sysname' is also used as the name of the destination sub-directory for the
+binaries created during the build. This sub-directory is automatically created
+during the build.
+
+### Installation Directory Path Modes
+
+There are two modes for directory path handling: *Transarc mode* and *default
+mode*. The mode is selected with the --enable-transarc-paths option.
+
+Traditionally, AFS server binaries and configuration files are located in the
+directory /usr/afs and client binaries and configuration files are located in
+the directory /usr/vice/etc. This convention is known as *Transarc path mode*
+because it was the convention adopted by Transarc/IBM in the commercial
+predecessor of OpenAFS.  Use the --enable-transarc-paths configure option to
+build binaries compatible with the Transarc installation convention.
+
+When configure is run without the --enable-transarc-paths option, the build
+system is configured to be in the *default mode*. This mode builds OpenAFS with
+installation paths more commonly used in open-source projects, for example
+/usr/local.  The standard configure --prefix option(s) can be used to specify
+non-default directories.  See the README for details on the type of installation
+directories and the configure options to set the paths.
+
+Installation paths are set at build time. Do not mix binaries for the two modes
+on the same system.
+
+### Linux Kernel Headers
+
+When building on linux, configure will attempt to detect the path to the linux
+kernel headers.  If this path is not found on the build system, you must
+specify the path with the --with-linux-kernel-headers option. For example,
+
+    --with-linux-kernel-headers=/usr/src/linux
+
+### Kerberos 5 configuration
+
+The 1.6.0 configure scripts should automatically find the kerberos 5
+libraries and headers.
+
+If you need to build 1.4.x, or if the krb5-config file is in a non-standard
+location, use the --with-krb5-conf option to specify the path to the krb5-config
+utility (part of the kerberos 5 development package).
+
+    --with-krb5-conf=/usr/bin/krb5-config
+
+
+### Debugging Options
+
+To enable a debugging build, specify the --enable-debug option on the
+./configure command line.  This builds with debugging compiler options and
+disables stripping of binaries.
+
+    --enable-debug                enable compilation of the user space code
+                                     with debugging information
+    --enable-debug-kernel         enable compilation of the kernel module
+                                     with debugging information
+    --enable-checking             Enable compiler warnings when building
+                                    with gcc and treat compiler warnings
+                                    as errors
+
+### Feature Options
+
+There are many configure options for OpenAFS. See the ./configure --help
+for a complete list and README for more details.  Common options are:
+
+    --enable-bos-restricted-mode  enable bosserver restricted mode 
+                                     which disables certain bosserver functionality
+    --enable-bos-new-config       enable bosserver pickup of BosConfig.new on restarts
+    --enable-namei-fileserver     force compilation of namei fileserver
+                                    in preference to inode fileserver
+                                    on systems were inode is the default
+    --enable-supergroups          enable support for nested pts groups
+                                   WARNING: Once you make use of this option
+                                   by nesting one group inside another,
+                                   the resulting PTS database cannot be correctly
+                                   and safely used by a ptserver built 
+                                   without this option. 
+
+### Configure changes in 1.6.0
+
+If you have been building the 1.5.0 freatures branch, note the following configure
+options have been removed in 1.6.0. Each feature is now always on, except as noted:
+
+* --disable-afsdb
+* --disable-largefile-fileserver
+* --enable-bos-restricted
+* --enable-fast-restart (off, but the code is still there)
+* --disable-full-vos-listvol
+* --enable-disconnected
+* --enable-icmp-pmtu-discovery
+* --enable-demand-attach-fs (see below)
+
+In 1.5.x, the demand attach fileserver feature was enabld by the a configure
+switch. Starting in 1.6.0, both DAFS and legacy binaries are built. The
+DAFS binaries are prefixed with 'da', expect for the new salvageserver, since
+salvageserver is new with DAFS.
+
+
+## Make
+
+After a successful configure, run make to build OpenAFS. The
+default target will build all.
+
+    $ make
+
+
+## Install
+
+You can install the OpenAFS binaries outside a package system
+by copying the binaries. If you built OpenAFS in the default
+mode (that is without --enable-transarc-paths), run the install
+target as root to install the binaries.
+
+    $ sudo make install
+
+If configure was run with --enable-transarc-paths, then run make to build a
+binary distribution directory, and then manually copy the files as the root
+user. To install the server and client binaries,
+
+    $ make dest
+    $ cd <sysname>/dest
+    $ sudo mkdir /usr/afs
+    $ sudo mkdir /usr/vice
+    $ sudo mkdir /usr/vice/etc
+    $ sudo cp -p -r root.server/usr/afs/* /usr/afs
+    $ sudo cp -p -r root.client/usr/vice/etc/* /usr/vice/etc
+
+See the Quick Start Guide for complete instructions to setup
+the OpenAFS cache manager and servers.
+
+The 'make dest' command places workstation binaries in the sub-directories of
+<sysname>/dest: bin, etc, man, lib, include. Optionally, copy these to you
+local filesystem or install them in an appropriate path in AFS. To install
+these file into your local filesystem:
+
+    $ sudo mkdir /usr/afsws
+    $ sudo cp -p -r bin /usr/afsws
+    $ sudo cp -p -r etc /usr/afsws
+    $ sudo cp -p -r man /usr/afsws
+    $ sudo cp -p -r lib /usr/afsws
+    $ sudo cp -p -r include /usr/afsws
+
+See [Storing AFS Binaries in AFS](http://docs.openafs.org/QuickStartUnix/ch02s29.html) for instructions on
+how to store the workstation binaries in AFS.
+
+## Post build
+
+Some make targets of interest
+
+- make clean - remove build artifacts
+- make distclean - remove build and configure artifacts
+- make tests - make the (old) afs test suite
+
+
+## Building RPM packages
+A script called makesrpm.pl is provided to build a source RPM package.  You can
+use the generated source RPM to build the binaries and create the RPM packages
+for your source code tree of OpenAFS.
+
+The first step is to create a source tree of OpenAFS. Run the regen.sh script
+to build the docs and to generate the configure script. Also, use git describe
+to make a version stamp file which will be used by the packaging process. This
+example shows how to get a source tree from a remote git repo.
+
+    $ git clone git://git.openafs.org/openafs.git openafs-<version>
+    $ cd openafs-<version>
+    $ git checkout <tagname>
+    $ git describe >.version
+    $ ./regen.sh
+
+The _version_ is the dotted OpenAFS version number, such as 1.6.0,
+and the _tagname_ is the git tag for the version, such as openafs-stable-1_6_0.
+The _version_ number for pre-releases are suffixed with pre<number>. For example,
+to build 1.6.0pre5, create a directory called openafs-1.6.0pre5.
+
+Next, create a source RPM file. This requires creating a tar file for the
+source files and a tar file for the documents.  Run the makesrpm program
+to generate an OpenAFS source RPM.
+
+    $ cd .. # move out of the source tree
+    $ tar cjf openafs-<version>-src.tar.bz2 openafs-<version> --exclude .git --exclude doc
+    $ tar cjf openafs-<version>-doc.tar.bz2 openafs-<version>/doc
+    $ openafs-<version>/src/packaging/RedHat/makesrpm.pl openafs-<version>-src.tar.bz2 openafs-<version>-doc.tar.bz2
+
+At this point you should have a source RPM called openafs-<version>-1.0.src.rpm. See the makesrpm.pl for additional options.
+The source tree and tar files are no longer needed.
+
+Finally, run rpmbuild to build the build binary RPM packages. If all goes well, the final
+output will show the destination directory and an exit code of zero.
+
+    $ rpmbuild --rebuild openafs-<version>-1.0.src.rpm
+    ...
+    + cd /usr/src/redhat/BUILD
+    + rm -rf openafs-<version>
+    + exit 0
+
+Alternatively, the source RPM may be installed, which will place the sources in the
+rpm SOURCE directory and a spec file in the rpm SPEC directory. 
 
--- [[MichaelMeffie]] - 09 Oct 2007