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