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