]> git.ipfire.org Git - thirdparty/glibc.git/blame - manual/install.texi
Do not claim that GCC predefines __POSIX__.
[thirdparty/glibc.git] / manual / install.texi
CommitLineData
3c20b9b6
UD
1@c This is for making the `INSTALL' file for the distribution.
2@c Makeinfo ignores it when processing the file from the include.
3@setfilename INSTALL
4
5@node Installation, Maintenance, Library Summary, Top
7a68c94a 6@c %MENU% How to install the GNU C library
3c20b9b6
UD
7@appendix Installing the GNU C Library
8
a4d62195 9Before you do anything else, you should read the file @file{FAQ} located
3c20b9b6
UD
10at the top level of the source tree. This file answers common questions
11and describes problems you may experience with compilation and
12installation. It is updated more frequently than this manual.
13
1792d4db 14Features can be added to GNU Libc via @dfn{add-on} bundles. These are
a4d62195 15separate tar files, which you unpack into the top level of the source
1792d4db 16tree. Then you give @code{configure} the @samp{--enable-add-ons} option
b3af1a24 17to activate them, and they will be compiled into the library.
00c1176b
UD
18
19You will need recent versions of several GNU tools: definitely GCC and
fe959e1e 20GNU Make, and possibly others. @xref{Tools for Compilation}, below.
00c1176b
UD
21
22@menu
23* Configuring and compiling:: How to compile and test GNU libc.
a4d62195
UD
24* Running make install:: How to install it once you've got it
25 compiled.
00c1176b 26* Tools for Compilation:: You'll need these first.
90d1d40b 27* Linux:: Specific advice for GNU/Linux systems.
00c1176b
UD
28* Reporting Bugs:: So they'll get fixed.
29@end menu
30
31@node Configuring and compiling
32@appendixsec Configuring and compiling GNU Libc
1792d4db
UD
33@cindex configuring
34@cindex compiling
00c1176b 35
3858bf28
RM
36GNU libc cannot be compiled in the source directory. You must build
37it in a separate build directory. For example, if you have unpacked
38the glibc sources in @file{/src/gnu/glibc-2.4}, create a directory
e8b1163e 39@file{/src/gnu/glibc-build} to put the object files in. This allows
3858bf28
RM
40removing the whole build directory in case an error occurs, which is
41the safest way to get a fresh start and should always be done.
00c1176b 42
a4d62195 43From your object directory, run the shell script @file{configure} located
00c1176b
UD
44at the top level of the source tree. In the scenario above, you'd type
45
46@smallexample
3858bf28 47$ ../glibc-2.4/configure @var{args@dots{}}
00c1176b
UD
48@end smallexample
49
3858bf28
RM
50Please note that even though you're building in a separate build
51directory, the compilation needs to modify a few files in the source
f76d7052
UD
52directory, especially some files in the manual subdirectory.
53
00c1176b 54@noindent
3858bf28
RM
55@code{configure} takes many options, but the only one that is usually
56mandatory is @samp{--prefix}. This option tells @code{configure}
57where you want glibc installed. This defaults to @file{/usr/local},
58but the normal setting to install as the standard system library is
59@samp{--prefix=/usr} for GNU/Linux systems and @samp{--prefix=} (an
60empty prefix) for GNU/Hurd systems.
00c1176b
UD
61
62It may also be useful to set the @var{CC} and @var{CFLAGS} variables in
63the environment when running @code{configure}. @var{CC} selects the C
64compiler that will be used, and @var{CFLAGS} sets optimization options
65for the compiler.
66
a4d62195
UD
67The following list describes all of the available options for
68 @code{configure}:
3c20b9b6
UD
69
70@table @samp
00c1176b
UD
71@item --prefix=@var{directory}
72Install machine-independent data files in subdirectories of
73@file{@var{directory}}. The default is to install in @file{/usr/local}.
74
75@item --exec-prefix=@var{directory}
76Install the library and other machine-dependent files in subdirectories
77of @file{@var{directory}}. The default is to the @samp{--prefix}
04b9968b 78directory if that option is specified, or @file{/usr/local} otherwise.
00c1176b
UD
79
80@item --with-headers=@var{directory}
81Look for kernel header files in @var{directory}, not
82@file{/usr/include}. Glibc needs information from the kernel's private
a4d62195 83header files. Glibc will normally look in @file{/usr/include} for them,
04b9968b 84but if you specify this option, it will look in @var{DIRECTORY} instead.
00c1176b
UD
85
86This option is primarily of use on a system where the headers in
87@file{/usr/include} come from an older version of glibc. Conflicts can
88occasionally happen in this case. Note that Linux libc5 qualifies as an
89older version of glibc. You can also use this option if you want to
90compile glibc with a newer set of kernel headers than the ones found in
91@file{/usr/include}.
92
93@item --enable-add-ons[=@var{list}]
3858bf28
RM
94Specify add-on packages to include in the build. If this option is
95specified with no list, it enables all the add-on packages it finds in
96the main source directory; this is the default behavior. You may
97specify an explicit list of add-ons to use in @var{list}, separated by
98spaces or commas (if you use spaces, remember to quote them from the
99shell). Each add-on in @var{list} can be an absolute directory name
100or can be a directory name relative to the main source directory, or
101relative to the build directory (that is, the current working directory).
102For example, @samp{--enable-add-ons=nptl,../glibc-libidn-2.4}.
00c1176b 103
d2830ba4 104@item --enable-kernel=@var{version}
90d1d40b 105This option is currently only useful on GNU/Linux systems. The
d2830ba4
UD
106@var{version} parameter should have the form X.Y.Z and describes the
107smallest version of the Linux kernel the generated library is expected
108to support. The higher the @var{version} number is, the less
109compatibility code is added, and the faster the code gets.
110
3c20b9b6
UD
111@item --with-binutils=@var{directory}
112Use the binutils (assembler and linker) in @file{@var{directory}}, not
a4d62195 113the ones the C compiler would default to. You can use this option if
3c20b9b6 114the default binutils on your system cannot deal with all the constructs
a4d62195
UD
115in the GNU C library. In that case, @code{configure} will detect the
116problem and suppress these constructs, so that the library will still be
117usable, but functionality may be lost---for example, you can't build a
118shared libc with old binutils.
3c20b9b6 119
3c20b9b6 120@item --without-fp
3c20b9b6
UD
121Use this option if your computer lacks hardware floating-point support
122and your operating system does not emulate an FPU.
123
b5ca0fb0
UD
124@c disable static doesn't work currently
125@c @item --disable-static
a4d62195
UD
126@c Don't build static libraries. Static libraries aren't that useful
127 these
b5ca0fb0 128@c days, but we recommend you build them in case you need them.
3c20b9b6 129
00c1176b 130@item --disable-shared
a4d62195
UD
131Don't build shared libraries even if it is possible. Not all systems
132support shared libraries; you need ELF support and (currently) the GNU
133linker.
3c20b9b6 134
00c1176b
UD
135@item --disable-profile
136Don't build libraries with profiling information. You may want to use
137this option if you don't plan to do profiling.
f12944ec 138
00c1176b
UD
139@item --disable-versioning
140Don't compile the shared libraries with symbol version information.
04b9968b 141Doing this will make the resulting library incompatible with old
00c1176b
UD
142binaries, so it's not recommended.
143
144@item --enable-static-nss
145Compile static versions of the NSS (Name Service Switch) libraries.
146This is not recommended because it defeats the purpose of NSS; a program
147linked statically with the NSS libraries cannot be dynamically
148reconfigured to use a different name database.
149
8d4b5a8a 150@item --without-tls
a4d62195 151By default the C library is built with support for thread-local storage
8d4b5a8a
UD
152if the used tools support it. By using @samp{--without-tls} this can be
153prevented though there generally is no reason since it creates
154compatibility problems.
155
00c1176b
UD
156@item --build=@var{build-system}
157@itemx --host=@var{host-system}
04b9968b 158These options are for cross-compiling. If you specify both options and
00c1176b
UD
159@var{build-system} is different from @var{host-system}, @code{configure}
160will prepare to cross-compile glibc from @var{build-system} to be used
161on @var{host-system}. You'll probably need the @samp{--with-headers}
162option too, and you may have to override @var{configure}'s selection of
163the compiler and/or binutils.
164
a4d62195
UD
165If you only specify @samp{--host}, @code{configure} will prepare for a
166native compile but use what you specify instead of guessing what your
167system is. This is most useful to change the CPU submodel. For example,
168if @code{configure} guesses your machine as @code{i586-pc-linux-gnu} but
169you want to compile a library for 386es, give
170@samp{--host=i386-pc-linux-gnu} or just @samp{--host=i386-linux} and add
171the appropriate compiler flags (@samp{-mcpu=i386} will do the trick) to
172@var{CFLAGS}.
1792d4db 173
a4d62195 174If you specify just @samp{--build}, @code{configure} will get confused.
3c20b9b6
UD
175@end table
176
00c1176b
UD
177To build the library and related programs, type @code{make}. This will
178produce a lot of output, some of which may look like errors from
179@code{make} but isn't. Look for error messages from @code{make}
a4d62195 180containing @samp{***}. Those indicate that something is seriously wrong.
00c1176b 181
3858bf28
RM
182The compilation process can take a long time, depending on the
183configuration and the speed of your machine. Some complex modules may
184take a very long time to compile, as much as several minutes on slower
185machines. Do not panic if the compiler appears to hang.
3c20b9b6 186
8eadd4f3
UD
187If you want to run a parallel make, simply pass the @samp{-j} option
188with an appropriate numeric parameter to @code{make}. You need a recent
189GNU @code{make} version, though.
f12944ec 190
04b9968b
UD
191To build and run test programs which exercise some of the library
192facilities, type @code{make check}. If it does not complete
193successfully, do not use the built library, and report a bug after
194verifying that the problem is not already known. @xref{Reporting Bugs},
195for instructions on reporting bugs. Note that some of the tests assume
196they are not being run by @code{root}. We recommend you compile and
197test glibc as an unprivileged user.
3c20b9b6 198
8eadd4f3 199Before reporting bugs make sure there is no problem with your system.
a4d62195 200The tests (and later installation) use some pre-existing files of the
8eadd4f3
UD
201system such as @file{/etc/passwd}, @file{/etc/nsswitch.conf} and others.
202These files must all contain correct and sensible content.
203
3c20b9b6
UD
204To format the @cite{GNU C Library Reference Manual} for printing, type
205@w{@code{make dvi}}. You need a working @TeX{} installation to do this.
1792d4db
UD
206The distribution already includes the on-line formatted version of the
207manual, as Info files. You can regenerate those with @w{@code{make
208info}}, but it shouldn't be necessary.
209
2e8048e5
UD
210The library has a number of special-purpose configuration parameters
211which you can find in @file{Makeconfig}. These can be overwritten with
212the file @file{configparms}. To change them, create a
213@file{configparms} in your build directory and add values as appropriate
214for your system. The file is included and parsed by @code{make} and has
215to follow the conventions for makefiles.
216
217It is easy to configure the GNU C library for cross-compilation by
218setting a few variables in @file{configparms}. Set @code{CC} to the
219cross-compiler for the target you configured the library for; it is
220important to use this same @code{CC} value when running
221@code{configure}, like this: @samp{CC=@var{target}-gcc configure
a4d62195
UD
222@var{target}}. Set @code{BUILD_CC} to the compiler to use for programs
223run on the build system as part of compiling the library. You may need to
e9433893
UD
224set @code{AR} to cross-compiling versions of @code{ar}
225if the native tools are not configured to work with
a4d62195 226object files for the target you configured for.
2e8048e5
UD
227
228
085320f5 229@node Running make install
1792d4db
UD
230@appendixsec Installing the C Library
231@cindex installing
3c20b9b6
UD
232
233To install the library and its header files, and the Info files of the
920e11e9 234manual, type @code{env LANGUAGE=C LC_ALL=C make install}. This will
a4d62195 235build things, if necessary, before installing them; however, you should
920e11e9
UD
236still compile everything first. If you are installing glibc as your
237primary C library, we recommend that you shut the system down to
238single-user mode first, and reboot afterward. This minimizes the risk
239of breaking things when the library changes out from underneath.
1792d4db 240
c559a3ca 241If you're upgrading from Linux libc5 or some other C library, you need to
a4d62195
UD
242replace the @file{/usr/include} with a fresh directory before installing
243it. The new @file{/usr/include} should contain the Linux headers, but
244nothing else.
c559a3ca
UD
245
246You must first build the library (@samp{make}), optionally check it
247(@samp{make check}), switch the include directories and then install
248(@samp{make install}). The steps must be done in this order. Not moving
249the directory before install will result in an unusable mixture of header
250files from both libraries, but configuring, building, and checking the
251library requires the ability to compile and run programs against the old
62075f0f 252library.
c559a3ca 253
1792d4db 254If you are upgrading from a previous installation of glibc 2.0 or 2.1,
62075f0f
UD
255@samp{make install} will do the entire job. You do not need to remove
256the old includes -- if you want to do so anyway you must then follow the
c559a3ca
UD
257order given above.
258
259You may also need to reconfigure GCC to work with the new library. The
260easiest way to do that is to figure out the compiler switches to make it
261work again (@samp{-Wl,--dynamic-linker=/lib/ld-linux.so.2} should work on
90d1d40b 262GNU/Linux systems) and use them to recompile gcc. You can also edit the specs
c559a3ca 263file (@file{/usr/lib/gcc-lib/@var{TARGET}/@var{VERSION}/specs}), but that
62075f0f 264is a bit of a black art.
1792d4db
UD
265
266You can install glibc somewhere other than where you configured it to go
267by setting the @code{install_root} variable on the command line for
268@samp{make install}. The value of this variable is prepended to all the
269paths for installation. This is useful when setting up a chroot
bef24895
UD
270environment or preparing a binary distribution. The directory should be
271specified with an absolute file name.
1792d4db 272
a0edd63e 273Glibc 2.2 includes a daemon called @code{nscd}, which you
1792d4db
UD
274may or may not want to run. @code{nscd} caches name service lookups; it
275can dramatically improve performance with NIS+, and may help with DNS as
a0edd63e 276well.
1792d4db
UD
277
278One auxiliary program, @file{/usr/libexec/pt_chown}, is installed setuid
279@code{root}. This program is invoked by the @code{grantpt} function; it
280sets the permissions on a pseudoterminal so it can be used by the
281calling process. This means programs like @code{xterm} and
282@code{screen} do not have to be setuid to get a pty. (There may be
440d13e2
UD
283other reasons why they need privileges.) If you are using a 2.1 or
284newer Linux kernel with the @code{devptsfs} or @code{devfs} filesystems
285providing pty slaves, you don't need this program; otherwise you do.
286The source for @file{pt_chown} is in @file{login/programs/pt_chown.c}.
3c20b9b6 287
d01d6319
UD
288After installation you might want to configure the timezone and locale
289installation of your system. The GNU C library comes with a locale
290database which gets configured with @code{localedef}. For example, to
291set up a German locale with name @code{de_DE}, simply issue the command
8fc1e2ca
UD
292@samp{localedef -i de_DE -f ISO-8859-1 de_DE}. To configure all locales
293that are supported by glibc, you can issue from your build directory the
d01d6319
UD
294command @samp{make localedata/install-locales}.
295
a4d62195
UD
296To configure the locally used timezone, set the @code{TZ} environment
297variable. The script @code{tzselect} helps you to select the right value.
298As an example, for Germany, @code{tzselect} would tell you to use
299@samp{TZ='Europe/Berlin'}. For a system wide installation (the given
300paths are for an installation with @samp{--prefix=/usr}), link the
d01d6319
UD
301timezone file which is in @file{/usr/share/zoneinfo} to the file
302@file{/etc/localtime}. For Germany, you might execute @samp{ln -s
303/usr/share/zoneinfo/Europe/Berlin /etc/localtime}.
304
00c1176b
UD
305@node Tools for Compilation
306@appendixsec Recommended Tools for Compilation
3c20b9b6
UD
307@cindex installation tools
308@cindex tools, for installing library
309
310We recommend installing the following GNU tools before attempting to
311build the GNU C library:
312
313@itemize @bullet
314@item
2bbc70d5 315GNU @code{make} 3.79 or newer
3c20b9b6
UD
316
317You need the latest version of GNU @code{make}. Modifying the GNU C
a4d62195
UD
318Library to work with other @code{make} programs would be so difficult that
319we recommend you port GNU @code{make} instead. @strong{Really.} We
320recommend GNU @code{make} version 3.79. All earlier versions have severe
321bugs or lack features.
3c20b9b6
UD
322
323@item
4d3f34be 324GCC 3.4 or newer, GCC 4.1 recommended
3c20b9b6 325
5306d361
UD
326For the 2.4 release or later, GCC 3.4 or higher is required; as of this
327writing, GCC 4.4 is the compiler we advise to use for current versions.
4d3f34be
RM
328On certain machines including @code{powerpc64}, compilers prior to GCC
3294.0 have bugs that prevent them compiling the C library code in the
3302.4 release. On other machines, GCC 4.1 is required to build the C
331library with support for the correct @code{long double} type format;
5306d361
UD
332these include @code{powerpc} (32 bit), @code{s390} and @code{s390x}. For
333other architectures special compiler-provided headers are needed
334(like @file{cpuid.h} on x86) which only come with later compiler versions.
91ea72b7
UD
335
336You can use whatever compiler you like to compile programs that use GNU
337libc, but be aware that both GCC 2.7 and 2.8 have bugs in their
b8f558b7 338floating-point support that may be triggered by the math library.
3c20b9b6 339
90d1d40b 340Check the FAQ for any special compiler issues on particular platforms.
5713a71e 341
3c20b9b6 342@item
98be6f68 343GNU @code{binutils} 2.15 or later
00c1176b 344
2231b60e 345You must use GNU @code{binutils} (as and ld) to build the GNU C library.
0c02c85f 346No other assembler or linker has the necessary functionality at the
2231b60e 347moment.
3c20b9b6
UD
348
349@item
407dc7a0 350GNU @code{texinfo} 3.12f
3c20b9b6
UD
351
352To correctly translate and install the Texinfo documentation you need
353this version of the @code{texinfo} package. Earlier versions do not
354understand all the tags used in the document, and the installation
1792d4db 355mechanism for the info files is not present or works differently.
3c20b9b6
UD
356
357@item
8522a053 358GNU @code{awk} 3.0, or higher
00c1176b 359
8522a053
UD
360@code{Awk} is used in several places to generate files.
361@code{gawk} 3.0 is known to work.
00c1176b
UD
362
363@item
364Perl 5
365
366Perl is not required, but it is used if present to test the
367installation. We may decide to use it elsewhere in the future.
3c20b9b6 368
d66732e0
UD
369@item
370GNU @code{sed} 3.02 or newer
371
a4d62195
UD
372@code{Sed} is used in several places to generate files. Most scripts work
373with any version of @code{sed}. The known exception is the script
d66732e0 374@code{po2test.sed} in the @code{intl} subdirectory which is used to
a4d62195
UD
375generate @code{msgs.h} for the test suite. This script works correctly
376only with GNU @code{sed} 3.02. If you like to run the test suite, you
b8668434 377should definitely upgrade @code{sed}.
d66732e0 378
3c20b9b6
UD
379@end itemize
380
381@noindent
382If you change any of the @file{configure.in} files you will also need
383
384@itemize @bullet
385@item
d4198074 386GNU @code{autoconf} 2.53 or higher
3c20b9b6
UD
387@end itemize
388
389@noindent
390and if you change any of the message translation files you will need
391
392@itemize @bullet
393@item
c26b4f64 394GNU @code{gettext} 0.10.36 or later
3c20b9b6
UD
395@end itemize
396
397@noindent
398You may also need these packages if you upgrade your source tree using
399patches, although we try to avoid this.
400
1792d4db 401@node Linux
90d1d40b 402@appendixsec Specific advice for GNU/Linux systems
1792d4db
UD
403@cindex upgrading from libc5
404@cindex kernel header files
405
90d1d40b 406If you are installing GNU libc on a GNU/Linux system, you need to have the
9c3bb910
AJ
407header files from a 2.2 or newer kernel around for reference. For some
408architectures, like ia64, sh and hppa, you need at least headers from
409kernel 2.3.99 (sh and hppa) or 2.4.0 (ia64). You do not need to use
410that kernel, just have its headers where glibc can access at them. The
411easiest way to do this is to unpack it in a directory such as
412@file{/usr/src/linux-2.2.1}. In that directory, run @samp{make config}
413and accept all the defaults. Then run @samp{make
b8f558b7
UD
414include/linux/version.h}. Finally, configure glibc with the option
415@samp{--with-headers=/usr/src/linux-2.2.1/include}. Use the most recent
416kernel you can get your hands on.
417
418An alternate tactic is to unpack the 2.2 kernel and run @samp{make
a8d87c92
UD
419config} as above; then, rename or delete @file{/usr/include}, create a
420new @file{/usr/include}, and make symbolic links of
421@file{/usr/include/linux} and @file{/usr/include/asm} into the kernel
422sources. You can then configure glibc with no special options. This
423tactic is recommended if you are upgrading from libc5, since you need to
424get rid of the old header files anyway.
425
426After installing GNU libc, you may need to remove or rename
427@file{/usr/include/linux} and @file{/usr/include/asm}, and replace them
428with copies of @file{include/linux} and
429@file{include/asm-$@var{ARCHITECTURE}} taken from the Linux source
430package which supplied kernel headers for building the library.
431@var{ARCHITECTURE} will be the machine architecture for which the
432library was built, such as @samp{i386} or @samp{alpha}. You do not need
433to do this if you did not specify an alternate kernel header source
434using @samp{--with-headers}. The intent here is that these directories
435should be copies of, @strong{not} symlinks to, the kernel headers used to
436build the library.
1792d4db
UD
437
438Note that @file{/usr/include/net} and @file{/usr/include/scsi} should
439@strong{not} be symlinks into the kernel sources. GNU libc provides its
440own versions of these files.
441
90d1d40b 442GNU/Linux expects some components of the libc installation to be in
1792d4db
UD
443@file{/lib} and some in @file{/usr/lib}. This is handled automatically
444if you configure glibc with @samp{--prefix=/usr}. If you set some other
445prefix or allow it to default to @file{/usr/local}, then all the
446components are installed there.
447
448If you are upgrading from libc5, you need to recompile every shared
449library on your system against the new library for the sake of new code,
450but keep the old libraries around for old binaries to use. This is
451complicated and difficult. Consult the Glibc2 HOWTO at
452@url{http://www.imaxx.net/~thrytis/glibc} for details.
453
454You cannot use @code{nscd} with 2.0 kernels, due to bugs in the
455kernel-side thread support. @code{nscd} happens to hit these bugs
456particularly hard, but you might have problems with any threaded
457program.
3c20b9b6
UD
458
459@node Reporting Bugs
460@appendixsec Reporting Bugs
461@cindex reporting bugs
462@cindex bugs, reporting
463
464There are probably bugs in the GNU C library. There are certainly
465errors and omissions in this manual. If you report them, they will get
466fixed. If you don't, no one will ever know about them and they will
467remain unfixed for all eternity, if not longer.
468
04b9968b
UD
469It is a good idea to verify that the problem has not already been
470reported. Bugs are documented in two places: The file @file{BUGS}
612fdf25
AS
471describes a number of well known bugs and the bug tracking system has a
472WWW interface at
d40eb37a 473@url{http://sources.redhat.com/bugzilla/}. The WWW
a4d62195
UD
474interface gives you access to open and closed reports. A closed report
475normally includes a patch or a hint on solving the problem.
612fdf25 476
a4d62195 477To report a bug, first you must find it. With any luck, this will be the
3c20b9b6
UD
478hard part. Once you've found a bug, make sure it's really a bug. A
479good way to do this is to see if the GNU C library behaves the same way
480some other C library does. If so, probably you are wrong and the
481libraries are right (but not necessarily). If not, one of the libraries
1792d4db
UD
482is probably wrong. It might not be the GNU library. Many historical
483Unix C libraries permit things that we don't, such as closing a file
484twice.
485
486If you think you have found some way in which the GNU C library does not
487conform to the ISO and POSIX standards (@pxref{Standards and
488Portability}), that is definitely a bug. Report it!
3c20b9b6
UD
489
490Once you're sure you've found a bug, try to narrow it down to the
491smallest test case that reproduces the problem. In the case of a C
492library, you really only need to narrow it down to one library
493function call, if possible. This should not be too difficult.
494
495The final step when you have a simple test case is to report the bug.
d40eb37a 496Do this using the WWW interface to the bug database.
3c20b9b6
UD
497
498If you are not sure how a function should behave, and this manual
499doesn't tell you, that's a bug in the manual. Report that too! If the
500function's behavior disagrees with the manual, then either the library
501or the manual has a bug, so report the disagreement. If you find any
d40eb37a
UD
502errors or omissions in this manual, please report them to the
503bug database. If you refer to specific
04b9968b
UD
504sections of the manual, please include the section names for easier
505identification.