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