update gerrit list
[openafs-wiki.git] / devel / HowToBuildOpenAFSFromSource.mdwn
1 This page describes how to build OpenAFS binaries from source code.
2 The information is specific to unix-like systems. See the
3 README-WINDOWS file in the root of the OpenAFS source code tree for
4 instructions and software needed to build OpenAFS on Microsoft Windows.
5
6 Unless otherwise noted, the information on this page is for building
7 the OpenAFS master branch or the OpenAFS stable releases (currently
8 the 1.6.x series).
9
10 [[!toc levels=3]]
11
12 # The Short Version #
13
14 For the impatient, this section describes how to get a code tree and
15 build it, assuming you have a development environment already setup.
16
17 The following shows how to download source code tarballs and build the
18 OpenAFS binaries:
19
20     $ wget http://openafs.org/dl/openafs/<version>/openafs-<version>-src.tar.bz2
21     $ wget http://openafs.org/dl/openafs/<version>/openafs-<version>-doc.tar.bz2
22     $ tar xjf openafs-<version>-src.tar.bz2
23     $ tar xjf openafs-<version>-doc.tar.bz2
24     $ cd openafs-<version>
25     $ ./configure
26     $ make
27
28 See [openafs downloads](http://openafs.org/dl/openafs) for available versions.
29
30 The following shows how to do a git checkout and build the OpenAFS binaries,
31
32     $ git clone git://git.openafs.org/openafs.git
33     $ cd openafs
34     $ git checkout <branch-or-tag>
35     $ ./regen.sh
36     $ ./configure
37     $ make
38
39 You will usually want to specify configure options. For example, to enable the
40 traditional Transarc/IBM AFS installation paths, run configure with the
41 --enable-transarc-paths option. (Read on for more information about configure
42 options.)
43
44     $ ./configure --enable-transarc-paths --enable-checking --enable-debug
45     $ make
46     $ make dest
47
48 This will build the binaries and place them in the &lt;platform&gt;/dest
49 directories, that is, the Transarc-style binary distribution directory layout.
50
51 See [[how to build OpenAFS RPM packages|HowToBuildOpenAFSRpmPackages]] for
52 instructions on how to build RPM packages.
53
54 See [[how to build OpenAFS Debian packages|HowToBuildOpenAFSDebianPackages]]
55 for instructions on how to build packages for Debian.
56
57 # Building OpenAFS #
58
59 Building and packaging OpenAFS is not difficult on current unix-like
60 systems. A small number of fairly common libraries and tools are required. The
61 kernel headers and a compiler capable of building a kernel module is needed to
62 build the OpenAFS kernel module (used by the cache manager and for
63 inode-backend fileservers.) The gnu autoconf and automake tools are used to
64 configure the build system, so should be familiar to most people accustomed to
65 building binaries on unix-like systems.
66
67 Begin by verifying you have the prerequisite tools and libraries installed on your
68 build host. These are listed in the next section. You will need to obtain the
69 OpenAFS source code, either by downloading a release tar file, or by checking
70 out a version from the git repository.
71
72 See the README file for details on building OpenAFS and platform specific
73 notes. See src/SOURCE-MAP for a brief description of each source code component.
74
75 A script called regen.sh is used to build the configure script and to
76 generate the man page documentation from perl pod formatted files.
77
78 The configure sets up the build system for your platform. Configure will
79 attempt to detect your platform type and capabilities. Configure will generate
80 the makefiles using automake. You may need to specify configure options to
81 enable certain compile-time features. Run ./configure --help to see a
82 complete list of the available configure options.
83
84 After a successful run of configure, run make in the top level directory to
85 build all the client and server OpenAFS binaries. The server binaries, user and
86 admin tools, and the cache manager can be installed manually if you are not
87 using your systems package manager, for example if you are installing OpenAFS
88 on solaris, or if the target system is being used for testing and development.
89 The installation paths depend on the configure options specified.
90
91 The process for building rpm packages is actually a bit different than what was
92 just described above.  Packaging scripts in the source tree are used to build
93 rpms from a source code tree tar file. You'll need to create two tar files, one
94 of the source and one of the documentation. A script is run to build a source
95 rpm, which can be used to build the various rpm packages.  Details are given
96 on the page [[How to build OpenAFS RPM packages|HowToBuildOpenAFSRpmPackages]].
97
98 ## Prerequisites ##
99
100 The following tools are needed to build OpenAFS from source from a tar file:
101
102 - make
103 - compiler
104 - assembler
105 - linker
106 - ranlib
107 - lex/yacc
108 - install
109 - perl 5.6 or better (only to build the documention)
110
111 In addition to the above, the following tools are needed to build OpenAFS
112 from a git checkout:
113
114 - git
115 - autoconf 2.60 or better
116 - automake
117 - libtool
118
119 The compiler used must be capable of building kernel modules for the target
120 platform.
121
122 > Note for RHEL users: RedHat Enterprise Linux 5.5 and less shipped with a
123 > version of autoconf too old to generate the OpenAFS configure script.
124 > Fortunately, the recently released RHEL 6.0 shipped with a more up to date
125 > version of autoconf which mets the minimum version needed to generate the
126 > configure script.
127
128 The following tools are needed to build OpenAFS RPMS:
129
130 - perl 5.6 or better
131 - rpmbuild
132
133 The following development libraries are needed:
134
135 - libc
136 - kerberos 5
137 - perl
138 - ncurses (optional, needed to build scout/afsmonitor)
139 - pam (optional)
140 - libfuse (optional)
141 - kernel headers
142
143 The ncurses libraries are needed to build the ncurses based admin tools
144 scout and afsmonitor. The kerberos 5 libraries are needed to build kerberos 5
145 support, which is *strongly* recommended.
146
147 ### Linux Debian Packages ###
148
149 On recent versions of Debian, use the apt-get build-dep command to install the needed
150 build dependencies,
151
152     $ sudo apt-get build-dep openafs
153     $ sudo apt-get install linux-headers-$(uname -r)
154
155 On a Debian 6, the required packages can be install with the following commands apt-get commands,
156
157     $ sudo apt-get install git autoconf automake libtool make gcc flex bison \
158       libc6-dev libkrb5-dev libperl-dev libncurses5-dev libfuse-dev \
159       linux-headers-$(uname -r)
160
161 ### Linux RPM Packages ###
162
163 On a RedHat-based linux distributions, all of the required packages can be
164 installed with the following yum commands,
165
166      $ sudo yum install git-core gcc autoconf automake libtool make flex bison
167      $ sudo yum install glibc-devel krb5-devel perl-devel ncurses-devel pam-devel kernel-devel-$(uname -r)
168      $ sudo yum install perl-devel perl-ExtUtils-Embed perl-Test-Simple
169
170 The following additional packages are needed to [[build RPM packages|HowToBuildOpenAfsRpmPackages]].
171
172      $ sudo yum install wget rpm-build redhat-rpm-config
173
174 ### Solaris Packages ###
175
176 [Oracle Solaris Studio][1] can be used to build OpenAFS binaries on the
177 solaris platform. Solaris Studio is freely available for the solaris and linux
178 platforms with a no-cost Oracle Technology Network (OTN) account.  For recent
179 versions of Solaris, use the `pkg' command to install Solaris Studio.  Follow the
180 package installer instructions on the Solaris Studio download page for
181 your platform type and version. This requires you to create and download a key
182 and certificate using your OTN account.
183
184 [1]: http://www.oracle.com/technetwork/server-storage/solarisstudio
185
186 All the tools and libs needed to build OpenAFS are available with the `pkg`
187 command on Solaris 11.  Earlier versions of Solaris require third party tools
188 and libs.
189
190 #### Solaris 10 and earlier ####
191
192 The [OpenCSW][2] project provides software packages for solaris 10 and earlier
193 which can be easily installed to build OpenAFS.  Follow the [OpenCSW getting started][3]
194 instructions to setup the `pkgutil` package manager tool.
195
196 [2]: http://www.opencsw.org
197 [3]: http://www.opencsw.org/manual/for-administrators/getting-started.html
198
199 Update your path to include `/opt/csw/bin`.
200
201 With `pkgutil` installed, install the necessary packages;
202
203      $ sudo pkgutil -y --install git
204      $ sudo pkgutil -y --install gmake flex bison gsed automake autoconf libtool
205      $ sudo pkgutil -y --install libkrb5_dev libncurses_dev
206
207 Note: Is a perl devel lib needed on solaris?
208
209 #### Solaris 11 ####
210
211 Install [SolarisStudio][1] using the `pkg' command. You will need an SSL
212 certificate and key, which can be created using your OTN account. See the instructions
213 on the Solaris Studio download page.
214
215 (Alternately, install Solaris Studio from the tar file installer, and then find
216 and install any missing dependencies.)
217
218 Use the `pkg` tool to install the other necessary packages:
219
220       $ sudo pkg install git
221       $ sudo pkg install text/locale
222       $ sudo pkg install gnu-coreutils gnu-binutils gnu-sed
223       $ sudo pkg install make flex bison
224       $ sudo pkg install automake autoconf libtool
225       $ sudo pkg install onbld
226
227 If you have dependency issues with automake, try automake-110
228
229 If you have installed Solaris Studio via the tar file, you may need to install
230 the `system/header' package manually:
231
232       $ sudo pkg install system/header
233
234
235 ## Getting the Source Code ##
236
237 See [[GitDevelopers]] for details on how to use git to fetch OpenAFS source
238 code and to submit source code changes to the OpenAFS project. This is the
239 preferred method to retrieve the source code.  Briefly, first create a local
240 clone of the git repository and then checkout a local branch of the version you
241 need to build.  For example,
242
243     $ git clone git://git.openafs.org/openafs.git
244     $ cd openafs
245     $ git checkout openafs-stable-<major>-<minor>-<patchlevel>
246
247 Compressed tar files of the source tree are made available for each stable and
248 development release. The most recent release is located at
249 <http://openafs.org/release/latest.html>.  Archives for releases are located at
250 /afs/openafs.org/software/openafs/ and <http://dl.openafs.org/dl>. For example,
251 to download and uncompress version 1.4.14,
252
253     $ wget http://dl.openafs.org/dl/1.4.14/openafs-1.4.14-src.tar.bz2
254     $ wget http://dl.openafs.org/dl/1.4.14/openafs-1.4.14-doc.tar.bz2
255     $ tar xjf openafs-1.4.14-src.tar.bz2
256     $ tar xjf openafs-1.4.14-doc.tar.bz2
257     $ cd openafs-1.4.14
258
259 The -src archive contains the source code and the -doc archive contains the
260 documentation in xml and pod format. Having a separate archive for
261 documentation allows people working on documentation to download just the pod
262 and xml portions of the project.
263
264 ### Regen
265
266 After a git checkout, run the regen.sh shell script to generate a
267 configure script (and a configure-libafs script) and to generate
268 the man pages. The regen.sh script runs the autoconf tools to
269 generate the configure scripts and runs perl to generate the
270 man pages.
271
272     ./regen.sh
273
274 You can skip the generation of the man pages by specifying the '-q'
275 option to regen.sh.
276
277     ./regen.sh -q
278
279 Always run regen.sh again (and then configure) if you change any of the OpenAFS
280 m4 autoconf macros, such as configure.ac or any of the macros under src/cf.
281
282 ## Configure
283
284 The OpenAFS configure script has many options available. Take some time to read
285 the README file and the output of configure --help before running configure the
286 first time. The most common options are introduced below.
287
288 ### AFS sysname
289
290 AFS uses an identifier called a *sysname* to distinguish platforms. configure
291 will automatically detect the sysname of the build system and by default
292 assumes the target system matches. If you are building for a target system
293 which is different than the build system, or if for some reason the sysname
294 detection fails, you will need to manually specify the sysname with the
295 --with-afs-sysname option.  See the README file for a complete list of sysnames.
296
297 The 'sysname' is also used as the name of the destination sub-directory for the
298 binaries created during the build. This sub-directory is automatically created
299 during the build.
300
301 ### Installation Directory Path Modes
302
303 There are two modes for directory path handling: *Transarc mode* and *default
304 mode*. The mode is selected with the --enable-transarc-paths option.
305
306 Traditionally, AFS server binaries and configuration files are located in the
307 directory /usr/afs and client binaries and configuration files are located in
308 the directory /usr/vice/etc. This convention is known as *Transarc path mode*
309 because it was the convention adopted by Transarc/IBM in the commercial
310 predecessor of OpenAFS.  Use the --enable-transarc-paths configure option to
311 build binaries compatible with the Transarc installation convention.
312
313 When configure is run without the --enable-transarc-paths option, the build
314 system is configured to be in the *default mode*. This mode builds OpenAFS with
315 installation paths more commonly used in open-source projects, for example
316 /usr/local.  The standard configure --prefix option(s) can be used to specify
317 non-default directories.  See the README for details on the type of installation
318 directories and the configure options to set the paths.
319
320 Installation paths are set at build time. Do not mix binaries for the two modes
321 on the same system.
322
323 ### Linux Kernel Headers
324
325 When building on linux, configure will attempt to detect the path to the linux
326 kernel headers.  If this path is not found on the build system, you must
327 specify the path with the --with-linux-kernel-headers option. For example,
328
329     --with-linux-kernel-headers=/usr/src/linux
330
331 ### Kerberos 5 configuration
332
333 The 1.6.0 configure scripts should automatically find the kerberos 5
334 libraries and headers.
335
336 If you need to build 1.4.x, or if the krb5-config file is in a non-standard
337 location, use the --with-krb5-conf option to specify the path to the krb5-config
338 utility (part of the kerberos 5 development package).
339
340     --with-krb5-conf=/usr/bin/krb5-config
341
342
343 ### Debugging Options ###
344
345 To enable a debugging build, specify the --enable-debug option on the
346 ./configure command line.  This builds with debugging compiler options and
347 disables stripping of binaries.
348
349     --enable-debug                enable compilation of the user space code
350                                      with debugging information
351     --enable-debug-kernel         enable compilation of the kernel module
352                                      with debugging information
353     --enable-checking             Enable compiler warnings when building
354                                     with gcc and treat compiler warnings
355                                     as errors
356
357 ### Feature Options ###
358
359 There are many configure options for OpenAFS. See the ./configure --help
360 for a complete list and README for more details.  Common options are:
361
362     --enable-bos-restricted-mode  enable bosserver restricted mode
363                                      which disables certain bosserver functionality
364     --enable-bos-new-config       enable bosserver pickup of BosConfig.new on restarts
365     --enable-namei-fileserver     force compilation of namei fileserver
366                                     in preference to inode fileserver
367                                     on systems were inode is the default
368     --enable-supergroups          enable support for nested pts groups
369                                    WARNING: Once you make use of this option
370                                    by nesting one group inside another,
371                                    the resulting PTS database cannot be correctly
372                                    and safely used by a ptserver built
373                                    without this option.
374
375 ### Configure changes in 1.6.0 ###
376
377 If you have been building the 1.5.0 freatures branch, note the following configure
378 options have been removed in 1.6.0. Each feature is now always on, except as noted:
379
380 * --disable-afsdb
381 * --disable-largefile-fileserver
382 * --enable-bos-restricted
383 * --enable-fast-restart (off, but the code is still there)
384 * --disable-full-vos-listvol
385 * --enable-disconnected
386 * --enable-icmp-pmtu-discovery
387 * --enable-demand-attach-fs (see below)
388
389 In 1.5.x, the demand attach fileserver feature was enabld by the a configure
390 switch. Starting in 1.6.0, both DAFS and legacy binaries are built. The
391 DAFS binaries are prefixed with 'da', expect for the new salvageserver, since
392 salvageserver is new with DAFS.
393
394
395 ## Make
396
397 After a successful configure, run make to build OpenAFS. The
398 default target will build all.
399
400     $ make
401
402
403 ## Install ##
404
405 You can install the OpenAFS binaries outside a package system
406 by copying the binaries. If you built OpenAFS in the default
407 mode (that is, without --enable-transarc-paths), run the install
408 target as root to install the binaries.
409
410     $ sudo make install
411
412 If configure was run with --enable-transarc-paths, then run make to build a
413 binary distribution directory, and then manually copy the files as the root
414 user. To install the server and client binaries,
415
416     $ make dest
417     $ cd <sysname>/dest
418     $ sudo mkdir /usr/afs
419     $ sudo mkdir /usr/vice
420     $ sudo mkdir /usr/vice/etc
421     $ sudo cp -p -r root.server/usr/afs/* /usr/afs
422     $ sudo cp -p -r root.client/usr/vice/etc/* /usr/vice/etc
423
424 See the Quick Start Guide for complete instructions to setup
425 the OpenAFS cache manager and servers.
426
427 The 'make dest' command places workstation binaries in the sub-directories of
428 &lt;sysname&gt;/dest: bin, etc, man, lib, include. Optionally, copy these to you
429 local filesystem or install them in an appropriate path in AFS. To install
430 these file into your local filesystem:
431
432     $ sudo mkdir /usr/afsws
433     $ sudo cp -p -r bin /usr/afsws
434     $ sudo cp -p -r etc /usr/afsws
435     $ sudo cp -p -r man /usr/afsws
436     $ sudo cp -p -r lib /usr/afsws
437     $ sudo cp -p -r include /usr/afsws
438
439 See [Storing AFS Binaries in AFS](http://docs.openafs.org/QuickStartUnix/ch02s29.html) for instructions on
440 how to store the workstation binaries in AFS.
441
442 ## Post build ##
443
444 Some make targets of interest
445
446 - make clean - remove build artifacts
447 - make distclean - remove build and configure artifacts
448 - make tests - make the (old) afs test suite
449
450 ## Out of Tree Builds ##
451
452 You may want to avoid cluttering your source tree with build artifacts, or
453 perhaps your source is in /afs and you want to write build artifacts on a
454 local, fast temporary file system.  No configure hacking is needed to do
455 perform an out of tree build. An out of tree build is done by changing
456 directory and then specifying the path to the configure script.  When building
457 from a git checkout and not a source tarball, first build a configure script
458 with `regen.sh` as usual in the source directory. This requires read-write
459 access to the source directory.
460
461 To do the out of tree build, change the current working directory to your local
462 build directory and run `configure` and `make`.  For example:
463
464     $ mkdir /tmp/mybuild
465     $ cd /tmp/mybuild
466     $ /afs/example.com/myfiles/openafs/configure $options
467     $ make