c-strtof, c-strtod, c-strtold: Make multithread-safe.
[gnulib.git] / doc / install.texi
blob254522bd4e355f8868b52b69a70233ad327cae31
1 @c This file is included by autoconf.texi and is used to produce
2 @c the INSTALL file.
4 @ifclear autoconf
5 @unnumbered Installation Instructions
6 @end ifclear
8 @node Basic Installation
9 @section Basic Installation
11 The following shell commands:
13 @example
14 test -f configure || ./bootstrap
15 ./configure
16 make
17 make install
18 @end example
20 @noindent
21 should configure, build, and install this package.
22 The first line, which bootstraps, is intended for developers;
23 when building from distribution tarballs it does nothing and can be skipped.
25 The following
26 more-detailed instructions are generic; see the @file{README} file for
27 instructions specific to this package.
28 @ifclear autoconf
29 Some packages provide this @file{INSTALL} file but do not implement all
30 of the features documented below.  The lack of an optional feature in a
31 given package is not necessarily a bug.
32 @end ifclear
33 More recommendations for GNU packages can be found in
34 @ifset autoconf
35 @ref{Makefile Conventions, , Makefile Conventions, standards,
36 GNU Coding Standards}.
37 @end ifset
38 @ifclear autoconf
39 the GNU Coding Standards.
40 @end ifclear
42 Many packages have scripts meant for developers instead of ordinary
43 builders, as they may use developer tools that are less commonly installed,
44 or they may access the network, which has privacy implications.
45 If the @command{bootstrap} shell script exists, it attempts to build the
46 @command{configure} shell script and related files, possibly
47 using developer tools or the network.  Because the output of
48 @command{bootstrap} is system-independent, it is normally run by a
49 package developer so that its output can be put into the distribution
50 tarball and ordinary builders and users need not run @command{bootstrap}.
51 Some packages have commands like @command{./autopull.sh} and
52 @command {./autogen.sh} that you can run instead of @command{./bootstrap},
53 for more fine-grained control over bootstrapping.
55 The @command{configure} shell script attempts to guess correct values
56 for various system-dependent variables used during compilation.  It uses
57 those values to create a @file{Makefile} in each directory of the
58 package.  It may also create one or more @file{.h} files containing
59 system-dependent definitions.  Finally, it creates a shell script
60 @file{config.status} that you can run in the future to recreate the
61 current configuration, and a file @file{config.log} containing
62 output useful for debugging @command{configure}.
64 It can also use an optional file (typically called @file{config.cache}
65 and enabled with @option{--cache-file=config.cache} or simply
66 @option{-C}) that saves the results of its tests to speed up
67 reconfiguring.  Caching is disabled by default to prevent problems with
68 accidental use of stale cache files.
70 If you need to do unusual things to compile the package, please try to
71 figure out how @command{configure} could check whether to do them, and
72 mail diffs or instructions to the address given in the @file{README} so
73 they can be considered for the next release.  If you are using the
74 cache, and at some point @file{config.cache} contains results you don't
75 want to keep, you may remove or edit it.
77 The @command{autoconf} program generates @file{configure} from the file
78 @file{configure.ac}.  Normally you should edit @file{configure.ac}
79 instead of editing @file{configure} directly.
81 The simplest way to compile this package is:
83 @enumerate
84 @item
85 @command{cd} to the directory containing the package's source code.
87 @item
88 If this is a developer checkout and file @samp{configure} does not yet exist,
89 type @samp{./bootstrap} to create it.
90 You may need special developer tools and network access to bootstrap,
91 and the network access may have privacy implications.
93 @item
94 Type @samp{./configure} to configure the package for your system.
95 This might take a while.  While running, @command{configure} prints
96 messages telling which features it is checking for.
98 @item
99 Type @samp{make} to compile the package.
101 @item
102 Optionally, type @samp{make check} to run any self-tests that come with
103 the package, generally using the just-built uninstalled binaries.
105 @item
106 Type @samp{make install} to install the programs and any data files and
107 documentation.  When installing into a prefix owned by root, it is
108 recommended that the package be configured and built as a regular user,
109 and only the @samp{make install} phase executed with root privileges.
111 @item
112 Optionally, type @samp{make installcheck} to repeat any self-tests, but
113 this time using the binaries in their final installed location.  This
114 target does not install anything.  Running this target as a regular
115 user, particularly if the prior @samp{make install} required root
116 privileges, verifies that the installation completed correctly.
118 @item
119 You can remove the program binaries and object files from the source
120 code directory by typing @samp{make clean}.  To also remove the files
121 that @command{configure} created (so you can compile the package for a
122 different kind of computer), type @samp{make distclean}.  There is also
123 a @samp{make maintainer-clean} target, but that is intended mainly for
124 the package's developers.  If you use it, you may have to bootstrap again.
126 @item
127 If the package follows the GNU Coding Standards,
128 you can type @samp{make uninstall} to remove the installed files.
129 @end enumerate
131 @node Compilers and Options
132 @section Compilers and Options
134 Some systems require unusual options for compilation or linking that the
135 @command{configure} script does not know about.  Run @samp{./configure
136 --help} for details on some of the pertinent environment variables.
138 You can give @command{configure} initial values for configuration
139 parameters by setting variables in the command line or in the environment.
140 Here is an example:
142 @example
143 ./configure CC=gcc CFLAGS=-g LIBS=-lposix
144 @end example
146 @ifplaintext
147 See ``Defining Variables''
148 @end ifplaintext
149 @ifnotplaintext
150 @ref{Defining Variables}
151 @end ifnotplaintext
152 @ifset autoconf
153 and @ref{Preset Output Variables}
154 @end ifset
155 for more details.
157 @node Multiple Architectures
158 @section Compiling For Multiple Architectures
160 You can compile the package for more than one kind of computer at the
161 same time, by placing the object files for each system in their
162 own directory.  To do this, you can use GNU @command{make}.
163 @command{cd} to the directory where you want the object files and
164 executables to go and run the @command{configure} script.
165 @command{configure} automatically checks for the source code in the
166 directory that @command{configure} is in and in @file{..}.  This is
167 known as a @dfn{VPATH} build.
169 With a non-GNU @command{make},
170 it is safer to compile the package for one
171 system at a time in the source code directory.  After you have
172 installed the package for one system, use @samp{make distclean}
173 before reconfiguring for another system.
175 Some platforms, notably macOS, support ``fat'' or ``universal'' binaries,
176 where a single binary can execute on different architectures.
177 On these platforms you can configure and compile just once,
178 with options specific to that platform.
180 @node Installation Names
181 @section Installation Names
183 By default, @samp{make install} installs the package's commands under
184 @file{/usr/local/bin}, include files under @file{/usr/local/include}, etc.
185 You can specify an
186 installation prefix other than @file{/usr/local} by giving
187 @command{configure} the option @option{--prefix=@var{prefix}}, where
188 @var{prefix} must be an absolute file name.
190 You can specify separate installation prefixes for architecture-specific
191 files and architecture-independent files.  If you pass the option
192 @option{--exec-prefix=@var{prefix}} to @command{configure}, the
193 package uses @var{prefix} as the prefix for installing programs and
194 libraries.  Documentation and other data files still use the
195 regular prefix.
197 In addition, if you use an unusual directory layout you can give options
198 like @option{--bindir=@var{dir}} to specify different values for
199 particular kinds of files.  Run @samp{configure --help} for a list of
200 the directories you can set and what kinds of files go in them.  In
201 general, the default for these options is expressed in terms of
202 @samp{$@{prefix@}}, so that specifying just @option{--prefix} will
203 affect all of the other directory specifications that were not
204 explicitly provided.
206 The most portable way to affect installation locations is to pass the
207 correct locations to @command{configure}; however, many packages provide
208 one or both of the following shortcuts of passing variable assignments
209 to the @samp{make install} command line to change installation locations
210 without having to reconfigure or recompile.
212 The first method involves providing an override variable for each
213 affected directory.  For example, @samp{make install
214 prefix=/alternate/directory} will choose an alternate location for all
215 directory configuration variables that were expressed in terms of
216 @samp{$@{prefix@}}.  Any directories that were specified during
217 @command{configure}, but not in terms of @samp{$@{prefix@}}, must each be
218 overridden at install time for the entire
219 installation to be relocated.  The approach of makefile variable
220 overrides for each directory variable is required by the GNU
221 Coding Standards, and ideally causes no recompilation.  However, some
222 platforms have known limitations with the semantics of shared libraries
223 that end up requiring recompilation when using this method, particularly
224 noticeable in packages that use GNU Libtool.
226 The second method involves providing the @samp{DESTDIR} variable.  For
227 example, @samp{make install DESTDIR=/alternate/directory} will prepend
228 @samp{/alternate/directory} before all installation names.  The approach
229 of @samp{DESTDIR} overrides is not required by the GNU Coding
230 Standards, and does not work on platforms that have drive letters.  On
231 the other hand, it does better at avoiding recompilation issues, and
232 works well even when some directory options were not specified in terms
233 of @samp{$@{prefix@}} at @command{configure} time.
235 @node Optional Features
236 @section Optional Features
238 If the package supports it, you can cause programs to be installed with
239 an extra prefix or suffix on their names by giving @command{configure}
240 the option @option{--program-prefix=@var{PREFIX}} or
241 @option{--program-suffix=@var{SUFFIX}}.
243 Some packages pay attention to @option{--enable-@var{feature}}
244 and @option{--disable-@var{feature}} options
245 to @command{configure}, where @var{feature} indicates an optional part
246 of the package.  They may also pay attention to
247 @option{--with-@var{package}} and @option{--without-@var{package}} options,
248 where @var{package} is something like @samp{gnu-ld}.
249 @samp{./configure --help} should mention the
250 @option{--enable-...} and @option{--with-...}
251 options that the package recognizes.
253 Some packages offer the ability to configure how verbose the execution
254 of @command{make} will be.  For these packages, running
255 @samp{./configure --enable-silent-rules} sets the default to minimal
256 output, which can be overridden with @code{make V=1}; while running
257 @samp{./configure --disable-silent-rules} sets the default to verbose,
258 which can be overridden with @code{make V=0}.
260 @node System Types
261 @section Specifying a System Type
263 By default @command{configure} builds for the current system.
264 To create binaries that can run on a different system type,
265 specify a @option{--host=@var{type}} option along with compiler
266 variables that specify how to generate object code for @var{type}.
267 For example, to create binaries intended to run on a 64-bit ARM
268 processor:
270 @example
271 ./configure --host=aarch64-linux-gnu \
272    CC=aarch64-linux-gnu-gcc \
273    CXX=aarch64-linux-gnu-g++
274 @end example
276 @noindent
277 If done on a machine that can execute these binaries
278 (e.g., via @command{qemu-aarch64}, @env{$QEMU_LD_PREFIX}, and Linux's
279 @code{binfmt_misc} capability), the build behaves like a native build.
280 Otherwise it is a cross-build: @code{configure}
281 will make cross-compilation guesses instead of running test programs,
282 and @code{make check} will not work.
284 A system type can either be a short name like @samp{mingw64},
285 or a canonical name like @samp{x86_64-pc-linux-gnu}.
286 Canonical names have the form @var{cpu}-@var{company}-@var{system}
287 where @var{system} is either @var{os} or @var{kernel}-@var{os}.
288 To canonicalize and validate a system type,
289 you can run the command @file{config.sub},
290 which is often squirreled away in a subdirectory like @file{build-aux}.
291 For example:
293 @example
294 $ build-aux/config.sub arm64-linux
295 aarch64-unknown-linux-gnu
296 $ build-aux/config.sub riscv-lnx
297 Invalid configuration 'riscv-lnx': OS 'lnx' not recognized
298 @end example
300 @noindent
301 You can look at the @file{config.sub} file to see which types are recognized.
302 If the file is absent, this package does not need the system type.
304 If @command{configure} fails with the diagnostic ``cannot guess build type''.
305 @file{config.sub} did not recognize your system's type.
306 In this case, first fetch the newest versions of these files
307 from the @url{https://savannah.gnu.org/projects/config, GNU config package}.
308 If that fixes things, please report it to the
309 maintainers of the package containing @command{configure}.
310 Otherwise, you can try the configure option
311 @option{--build=@var{type}} where @var{type} comes close to your
312 system type; also, please report the problem to
313 @email{config-patches@@gnu.org}.
315 For more details about configuring system types, see
316 @ifset autoconf
317 @ref{Manual Configuration}.
318 @end ifset
319 @ifclear autoconf
320 the Autoconf documentation.
321 @end ifclear
323 @node Sharing Defaults
324 @section Sharing Defaults
326 If you want to set default values for @command{configure} scripts to
327 share, you can create a site shell script called @file{config.site} that
328 gives default values for variables like @code{CC}, @code{cache_file},
329 and @code{prefix}.  @command{configure} looks for
330 @file{@var{prefix}/share/config.site} if it exists, then
331 @file{@var{prefix}/etc/config.site} if it exists.  Or, you can set the
332 @code{CONFIG_SITE} environment variable to the location of the site
333 script.  A warning: not all @command{configure} scripts look for a site
334 script.
336 @node Defining Variables
337 @section Defining Variables
339 Variables not defined in a site shell script can be set in the
340 environment passed to @command{configure}.  However, some packages may
341 run configure again during the build, and the customized values of these
342 variables may be lost.  In order to avoid this problem, you should set
343 them in the @command{configure} command line, using @samp{VAR=value}.
344 For example:
346 @example
347 ./configure CC=/usr/local2/bin/gcc
348 @end example
350 @noindent
351 causes the specified @command{gcc} to be used as the C compiler (unless it is
352 overridden in the site shell script).
354 @noindent
355 Unfortunately, this technique does not work for @env{CONFIG_SHELL} due
356 to an Autoconf limitation.  Until the limitation is lifted, you can use
357 this workaround:
359 @example
360 CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
361 @end example
363 @node configure Invocation
364 @section @command{configure} Invocation
366 @command{configure} recognizes the following options to control how it
367 operates.
369 @table @option
370 @item --help
371 @itemx -h
372 Print a summary of all of the options to @command{configure}, and exit.
374 @item --help=short
375 @itemx --help=recursive
376 Print a summary of the options unique to this package's
377 @command{configure}, and exit.  The @code{short} variant lists options
378 used only in the top level, while the @code{recursive} variant lists
379 options also present in any nested packages.
381 @item --version
382 @itemx -V
383 Print the version of Autoconf used to generate the @command{configure}
384 script, and exit.
386 @item --cache-file=@var{file}
387 @cindex Cache, enabling
388 Enable the cache: use and save the results of the tests in @var{file},
389 traditionally @file{config.cache}.  @var{file} defaults to
390 @file{/dev/null} to disable caching.
392 @item --config-cache
393 @itemx -C
394 Alias for @option{--cache-file=config.cache}.
396 @item --srcdir=@var{dir}
397 Look for the package's source code in directory @var{dir}.  Usually
398 @command{configure} can determine that directory automatically.
400 @item --prefix=@var{dir}
401 Use @var{dir} as the installation prefix.
402 @ifplaintext
403 See ``Installation Names''
404 @end ifplaintext
405 @ifnotplaintext
406 @ref{Installation Names}
407 @end ifnotplaintext
408 for more details, including other options available for fine-tuning
409 the installation locations.
411 @item --host=@var{type}
412 Build binaries for system @var{type}.
413 @ifplaintext
414 See ``Specifying a System Type''.
415 @end ifplaintext
416 @ifnotplaintext
417 @xref{System Types}.
418 @end ifnotplaintext
420 @item --enable-@var{feature}
421 @itemx --disable-@var{feature}
422 Enable or disable the optional @var{feature}.
423 @ifplaintext
424 See ``Optional Features''.
425 @end ifplaintext
426 @ifnotplaintext
427 @xref{Optional Features}.
428 @end ifnotplaintext
430 @item --with-@var{package}
431 @itemx --without-@var{package}
432 Use or omit @var{package} when building.
433 @ifplaintext
434 See ``Optional Features''.
435 @end ifplaintext
436 @ifnotplaintext
437 @xref{Optional Features}.
438 @end ifnotplaintext
440 @item --quiet
441 @itemx --silent
442 @itemx -q
443 Do not print messages saying which checks are being made.  To suppress
444 all normal output, redirect it to @file{/dev/null} (any error messages
445 will still be shown).
447 @item --no-create
448 @itemx -n
449 Run the configure checks, but stop before creating any output files.
450 @end table
452 @noindent
453 @command{configure} also recognizes several environment variables,
454 and accepts some other, less widely useful, options.
455 Run @samp{configure --help} for more details.
457 @ifclear autoconf
458 @node Copyright notice
459 @section Copyright notice
461 Copyright @copyright{} 1994--1996, 1999--2002, 2004--2017, 2020--2024
462 Free Software Foundation, Inc.
464 Copying and distribution of this file, with or without modification, are
465 permitted in any medium without royalty provided the copyright notice
466 and this notice are preserved.  This file is offered as-is, without
467 warranty of any kind.
468 @end ifclear
470 @c Local Variables:
471 @c fill-column: 72
472 @c ispell-local-dictionary: "american"
473 @c indent-tabs-mode: nil
474 @c whitespace-check-buffer-indent: nil
475 @c End: