1 This is configure.info, produced by makeinfo version 4.0 from
4 INFO-DIR-SECTION GNU admin
6 * configure: (configure). The GNU configure and build system
9 This file documents the GNU configure and build system.
11 Copyright (C) 1998 Cygnus Solutions.
13 Permission is granted to make and distribute verbatim copies of this
14 manual provided the copyright notice and this permission notice are
15 preserved on all copies.
17 Permission is granted to copy and distribute modified versions of
18 this manual under the conditions for verbatim copying, provided that
19 the entire resulting derived work is distributed under the terms of a
20 permission notice identical to this one.
22 Permission is granted to copy and distribute translations of this
23 manual into another language, under the above conditions for modified
24 versions, except that this permission notice may be stated in a
25 translation approved by the Foundation.
28 File: configure.info, Node: Configuration Name Definition, Next: Using Configuration Names, Up: Configuration Names
30 Configuration Name Definition
31 =============================
33 This is a string of the form CPU-MANUFACTURER-OPERATING_SYSTEM. In
34 some cases, this is extended to a four part form:
35 CPU-MANUFACTURER-KERNEL-OPERATING_SYSTEM.
37 When using a configuration name in a configure option, it is normally
38 not necessary to specify an entire name. In particular, the
39 MANUFACTURER field is often omitted, leading to strings such as
40 `i386-linux' or `sparc-sunos'. The shell script `config.sub' will
41 translate these shortened strings into the canonical form. autoconf
42 will arrange for `config.sub' to be run automatically when it is needed.
44 The fields of a configuration name are as follows:
47 The type of processor. This is typically something like `i386' or
48 `sparc'. More specific variants are used as well, such as
49 `mipsel' to indicate a little endian MIPS processor.
52 A somewhat freeform field which indicates the manufacturer of the
53 system. This is often simply `unknown'. Other common strings are
54 `pc' for an IBM PC compatible system, or the name of a workstation
55 vendor, such as `sun'.
58 The name of the operating system which is run on the system. This
59 will be something like `solaris2.5' or `irix6.3'. There is no
60 particular restriction on the version number, and strings like
61 `aix4.1.4.0' are seen. For an embedded system, which has no
62 operating system, this field normally indicates the type of object
63 file format, such as `elf' or `coff'.
66 This is used mainly for GNU/Linux. A typical GNU/Linux
67 configuration name is `i586-pc-linux-gnulibc1'. In this case the
68 kernel, `linux', is separated from the operating system,
71 The shell script `config.guess' will normally print the correct
72 configuration name for the system on which it is run. It does by
73 running `uname' and by examining other characteristics of the system.
75 Because `config.guess' can normally determine the configuration name
76 for a machine, it is normally only necessary to specify a configuration
77 name when building a cross-compiler or when building using a
81 File: configure.info, Node: Using Configuration Names, Prev: Configuration Name Definition, Up: Configuration Names
83 Using Configuration Names
84 =========================
86 A configure script will sometimes have to make a decision based on a
87 configuration name. You will need to do this if you have to compile
88 code differently based on something which can not be tested using a
89 standard autoconf feature test.
91 It is normally better to test for particular features, rather than to
92 test for a particular system. This is because as Unix evolves,
93 different systems copy features from one another. Even if you need to
94 determine whether the feature is supported based on a configuration
95 name, you should define a macro which describes the feature, rather than
96 defining a macro which describes the particular system you are on.
98 Testing for a particular system is normally done using a case
99 statement in `configure.in'. The case statement might look something
100 like the following, assuming that `host' is a shell variable holding a
101 canonical configuration name (which will be the case if `configure.in'
102 uses the `AC_CANONICAL_HOST' or `AC_CANONICAL_SYSTEM' macro).
105 i[3456]86-*-linux-gnu*) do something ;;
106 sparc*-sun-solaris2.[56789]*) do something ;;
107 sparc*-sun-solaris*) do something ;;
108 mips*-*-elf*) do something ;;
111 It is particularly important to use `*' after the operating system
112 field, in order to match the version number which will be generated by
115 In most cases you must be careful to match a range of processor
116 types. For most processor families, a trailing `*' suffices, as in
117 `mips*' above. For the i386 family, something along the lines of
118 `i[3456]86' suffices at present. For the m68k family, you will need
119 something like `m68*'. Of course, if you do not need to match on the
120 processor, it is simpler to just replace the entire field by a `*', as
124 File: configure.info, Node: Cross Compilation Tools, Next: Canadian Cross, Prev: Configuration Names, Up: Top
126 Cross Compilation Tools
127 ***********************
129 The GNU configure and build system can be used to build "cross
130 compilation" tools. A cross compilation tool is a tool which runs on
131 one system and produces code which runs on another system.
135 * Cross Compilation Concepts:: Cross Compilation Concepts.
136 * Host and Target:: Host and Target.
137 * Using the Host Type:: Using the Host Type.
138 * Specifying the Target:: Specifying the Target.
139 * Using the Target Type:: Using the Target Type.
140 * Cross Tools in the Cygnus Tree:: Cross Tools in the Cygnus Tree
143 File: configure.info, Node: Cross Compilation Concepts, Next: Host and Target, Up: Cross Compilation Tools
145 Cross Compilation Concepts
146 ==========================
148 A compiler which produces programs which run on a different system
149 is a cross compilation compiler, or simply a "cross compiler".
150 Similarly, we speak of cross assemblers, cross linkers, etc.
152 In the normal case, a compiler produces code which runs on the same
153 system as the one on which the compiler runs. When it is necessary to
154 distinguish this case from the cross compilation case, such a compiler
155 is called a "native compiler". Similarly, we speak of native
158 Although the debugger is not strictly speaking a compilation tool,
159 it is nevertheless meaningful to speak of a cross debugger: a debugger
160 which is used to debug code which runs on another system. Everything
161 that is said below about configuring cross compilation tools applies to
162 the debugger as well.
165 File: configure.info, Node: Host and Target, Next: Using the Host Type, Prev: Cross Compilation Concepts, Up: Cross Compilation Tools
170 When building cross compilation tools, there are two different
171 systems involved: the system on which the tools will run, and the
172 system for which the tools generate code.
174 The system on which the tools will run is called the "host" system.
176 The system for which the tools generate code is called the "target"
179 For example, suppose you have a compiler which runs on a GNU/Linux
180 system and generates ELF programs for a MIPS embedded system. In this
181 case the GNU/Linux system is the host, and the MIPS ELF system is the
182 target. Such a compiler could be called a GNU/Linux cross MIPS ELF
183 compiler, or, equivalently, a `i386-linux-gnu' cross `mips-elf'
186 Naturally, most programs are not cross compilation tools. For those
187 programs, it does not make sense to speak of a target. It only makes
188 sense to speak of a target for tools like `gcc' or the `binutils' which
189 actually produce running code. For example, it does not make sense to
190 speak of the target of a tool like `bison' or `make'.
192 Most cross compilation tools can also serve as native tools. For a
193 native compilation tool, it is still meaningful to speak of a target.
194 For a native tool, the target is the same as the host. For example, for
195 a GNU/Linux native compiler, the host is GNU/Linux, and the target is
199 File: configure.info, Node: Using the Host Type, Next: Specifying the Target, Prev: Host and Target, Up: Cross Compilation Tools
204 In almost all cases the host system is the system on which you run
205 the `configure' script, and on which you build the tools (for the case
206 when they differ, *note Canadian Cross::).
208 If your configure script needs to know the configuration name of the
209 host system, and the package is not a cross compilation tool and
210 therefore does not have a target, put `AC_CANONICAL_HOST' in
211 `configure.in'. This macro will arrange to define a few shell
212 variables when the `configure' script is run.
215 The canonical configuration name of the host. This will normally
216 be determined by running the `config.guess' shell script, although
217 the user is permitted to override this by using an explicit
221 In the unusual case that the user used an explicit `--host' option,
222 this will be the argument to `--host'. In the normal case, this
223 will be the same as the `host' variable.
228 The first three parts of the canonical configuration name.
230 The shell variables may be used by putting shell code in
231 `configure.in'. For an example, see *Note Using Configuration Names::.
234 File: configure.info, Node: Specifying the Target, Next: Using the Target Type, Prev: Using the Host Type, Up: Cross Compilation Tools
236 Specifying the Target
237 =====================
239 By default, the `configure' script will assume that the target is
240 the same as the host. This is the more common case; for example, it
241 leads to a native compiler rather than a cross compiler.
243 If you want to build a cross compilation tool, you must specify the
244 target explicitly by using the `--target' option when you run
245 `configure'. The argument to `--target' is the configuration name of
246 the system for which you wish to generate code. *Note Configuration
249 For example, to build tools which generate code for a MIPS ELF
250 embedded system, you would use `--target mips-elf'.
253 File: configure.info, Node: Using the Target Type, Next: Cross Tools in the Cygnus Tree, Prev: Specifying the Target, Up: Cross Compilation Tools
255 Using the Target Type
256 =====================
258 When writing `configure.in' for a cross compilation tool, you will
259 need to use information about the target. To do this, put
260 `AC_CANONICAL_SYSTEM' in `configure.in'.
262 `AC_CANONICAL_SYSTEM' will look for a `--target' option and
263 canonicalize it using the `config.sub' shell script. It will also run
264 `AC_CANONICAL_HOST' (*note Using the Host Type::).
266 The target type will be recorded in the following shell variables.
267 Note that the host versions of these variables will also be defined by
271 The canonical configuration name of the target.
274 The argument to the `--target' option. If the user did not specify
275 a `--target' option, this will be the same as `host_alias'.
280 The first three parts of the canonical target configuration name.
282 Note that if `host' and `target' are the same string, you can assume
283 a native configuration. If they are different, you can assume a cross
286 It is arguably possible for `host' and `target' to represent the
287 same system, but for the strings to not be identical. For example, if
288 `config.guess' returns `sparc-sun-sunos4.1.4', and somebody configures
289 with `--target sparc-sun-sunos4.1', then the slight differences between
290 the two versions of SunOS may be unimportant for your tool. However,
291 in the general case it can be quite difficult to determine whether the
292 differences between two configuration names are significant or not.
293 Therefore, by convention, if the user specifies a `--target' option
294 without specifying a `--host' option, it is assumed that the user wants
295 to configure a cross compilation tool.
297 The variables `target' and `target_alias' should be handled
300 In general, whenever the user may actually see a string,
301 `target_alias' should be used. This includes anything which may appear
302 in the file system, such as a directory name or part of a tool name.
303 It also includes any tool output, unless it is clearly labelled as the
304 canonical target configuration name. This permits the user to use the
305 `--target' option to specify how the tool will appear to the outside
308 On the other hand, when checking for characteristics of the target
309 system, `target' should be used. This is because a wide variety of
310 `--target' options may map into the same canonical configuration name.
311 You should not attempt to duplicate the canonicalization done by
312 `config.sub' in your own code.
314 By convention, cross tools are installed with a prefix of the
315 argument used with the `--target' option, also known as `target_alias'
316 (*note Using the Target Type::). If the user does not use the
317 `--target' option, and thus is building a native tool, no prefix is
320 For example, if gcc is configured with `--target mips-elf', then the
321 installed binary will be named `mips-elf-gcc'. If gcc is configured
322 without a `--target' option, then the installed binary will be named
325 The autoconf macro `AC_ARG_PROGRAM' will handle this for you. If
326 you are using automake, no more need be done; the programs will
327 automatically be installed with the correct prefixes. Otherwise, see
328 the autoconf documentation for `AC_ARG_PROGRAM'.
331 File: configure.info, Node: Cross Tools in the Cygnus Tree, Prev: Using the Target Type, Up: Cross Compilation Tools
333 Cross Tools in the Cygnus Tree
334 ==============================
336 The Cygnus tree is used for various packages including gdb, the GNU
337 binutils, and egcs. It is also, of course, used for Cygnus releases.
339 In the Cygnus tree, the top level `configure' script uses the old
340 Cygnus configure system, not autoconf. The top level `Makefile.in' is
341 written to build packages based on what is in the source tree, and
342 supports building a large number of tools in a single
343 `configure'/`make' step.
345 The Cygnus tree may be configured with a `--target' option. The
346 `--target' option applies recursively to every subdirectory, and
347 permits building an entire set of cross tools at once.
351 * Host and Target Libraries:: Host and Target Libraries.
352 * Target Library Configure Scripts:: Target Library Configure Scripts.
353 * Make Targets in Cygnus Tree:: Make Targets in Cygnus Tree.
354 * Target libiberty:: Target libiberty
357 File: configure.info, Node: Host and Target Libraries, Next: Target Library Configure Scripts, Up: Cross Tools in the Cygnus Tree
359 Host and Target Libraries
360 -------------------------
362 The Cygnus tree distinguishes host libraries from target libraries.
364 Host libraries are built with the compiler used to build the programs
365 which run on the host, which is called the host compiler. This includes
366 libraries such as `bfd' and `tcl'. These libraries are built with the
367 host compiler, and are linked into programs like the binutils or gcc
368 which run on the host.
370 Target libraries are built with the target compiler. If gcc is
371 present in the source tree, then the target compiler is the gcc that is
372 built using the host compiler. Target libraries are libraries such as
373 `newlib' and `libstdc++'. These libraries are not linked into the host
374 programs, but are instead made available for use with programs built
375 with the target compiler.
377 For the rest of this section, assume that gcc is present in the
378 source tree, so that it will be used to build the target libraries.
380 There is a complication here. The configure process needs to know
381 which compiler you are going to use to build a tool; otherwise, the
382 feature tests will not work correctly. The Cygnus tree handles this by
383 not configuring the target libraries until the target compiler is
384 built. In order to permit everything to build using a single
385 `configure'/`make', the configuration of the target libraries is
386 actually triggered during the make step.
388 When the target libraries are configured, the `--target' option is
389 not used. Instead, the `--host' option is used with the argument of
390 the `--target' option for the overall configuration. If no `--target'
391 option was used for the overall configuration, the `--host' option will
392 be passed with the output of the `config.guess' shell script. Any
393 `--build' option is passed down unchanged.
395 This translation of configuration options is done because since the
396 target libraries are compiled with the target compiler, they are being
397 built in order to run on the target of the overall configuration. By
398 the definition of host, this means that their host system is the same as
399 the target system of the overall configuration.
401 The same process is used for both a native configuration and a cross
402 configuration. Even when using a native configuration, the target
403 libraries will be configured and built using the newly built compiler.
404 This is particularly important for the C++ libraries, since there is no
405 reason to assume that the C++ compiler used to build the host tools (if
406 there even is one) uses the same ABI as the g++ compiler which will be
407 used to build the target libraries.
409 There is one difference between a native configuration and a cross
410 configuration. In a native configuration, the target libraries are
411 normally configured and built as siblings of the host tools. In a cross
412 configuration, the target libraries are normally built in a subdirectory
413 whose name is the argument to `--target'. This is mainly for
416 To summarize, running `configure' in the Cygnus tree configures all
417 the host libraries and tools, but does not configure any of the target
418 libraries. Running `make' then does the following steps:
420 * Build the host libraries.
422 * Build the host programs, including gcc. Note that we call gcc
423 both a host program (since it runs on the host) and a target
424 compiler (since it generates code for the target).
426 * Using the newly built target compiler, configure the target
429 * Build the target libraries.
431 The steps need not be done in precisely this order, since they are
432 actually controlled by `Makefile' targets.
435 File: configure.info, Node: Target Library Configure Scripts, Next: Make Targets in Cygnus Tree, Prev: Host and Target Libraries, Up: Cross Tools in the Cygnus Tree
437 Target Library Configure Scripts
438 --------------------------------
440 There are a few things you must know in order to write a configure
441 script for a target library. This is just a quick sketch, and beginners
442 shouldn't worry if they don't follow everything here.
444 The target libraries are configured and built using a newly built
445 target compiler. There may not be any startup files or libraries for
446 this target compiler. In fact, those files will probably be built as
447 part of some target library, which naturally means that they will not
448 exist when your target library is configured.
450 This means that the configure script for a target library may not use
451 any test which requires doing a link. This unfortunately includes many
452 useful autoconf macros, such as `AC_CHECK_FUNCS'. autoconf macros
453 which do a compile but not a link, such as `AC_CHECK_HEADERS', may be
456 This is a severe restriction, but normally not a fatal one, as target
457 libraries can often assume the presence of other target libraries, and
458 thus know which functions will be available.
460 As of this writing, the autoconf macro `AC_PROG_CC' does a link to
461 make sure that the compiler works. This may fail in a target library,
462 so target libraries must use a different set of macros to locate the
463 compiler. See the `configure.in' file in a directory like `libiberty'
464 or `libgloss' for an example.
466 As noted in the previous section, target libraries are sometimes
467 built in directories which are siblings to the host tools, and are
468 sometimes built in a subdirectory. The `--with-target-subdir' configure
469 option will be passed when the library is configured. Its value will be
470 an empty string if the target library is a sibling. Its value will be
471 the name of the subdirectory if the target library is in a subdirectory.
473 If the overall build is not a native build (i.e., the overall
474 configure used the `--target' option), then the library will be
475 configured with the `--with-cross-host' option. The value of this
476 option will be the host system of the overall build. Recall that the
477 host system of the library will be the target of the overall build. If
478 the overall build is a native build, the `--with-cross-host' option
481 A library which can be built both standalone and as a target library
482 may want to install itself into different directories depending upon the
483 case. When built standalone, or when built native, the library should
484 be installed in `$(libdir)'. When built as a target library which is
485 not native, the library should be installed in `$(tooldir)/lib'. The
486 `--with-cross-host' option may be used to distinguish these cases.
488 This same test of `--with-cross-host' may be used to see whether it
489 is OK to use link tests in the configure script. If the
490 `--with-cross-host' option is not used, then the library is being built
491 either standalone or native, and a link should work.
494 File: configure.info, Node: Make Targets in Cygnus Tree, Next: Target libiberty, Prev: Target Library Configure Scripts, Up: Cross Tools in the Cygnus Tree
496 Make Targets in Cygnus Tree
497 ---------------------------
499 The top level `Makefile' in the Cygnus tree defines targets for
500 every known subdirectory.
502 For every subdirectory DIR which holds a host library or program,
503 the `Makefile' target `all-DIR' will build that library or program.
505 There are dependencies among host tools. For example, building gcc
506 requires first building gas, because the gcc build process invokes the
507 target assembler. These dependencies are reflected in the top level
510 For every subdirectory DIR which holds a target library, the
511 `Makefile' target `configure-target-DIR' will configure that library.
512 The `Makefile' target `all-target-DIR' will build that library.
514 Every `configure-target-DIR' target depends upon `all-gcc', since
515 gcc, the target compiler, is required to configure the tool. Every
516 `all-target-DIR' target depends upon the corresponding
517 `configure-target-DIR' target.
519 There are several other targets which may be of interest for each
520 directory: `install-DIR', `clean-DIR', and `check-DIR'. There are also
521 corresponding `target' versions of these for the target libraries ,
522 such as `install-target-DIR'.
525 File: configure.info, Node: Target libiberty, Prev: Make Targets in Cygnus Tree, Up: Cross Tools in the Cygnus Tree
530 The `libiberty' subdirectory is currently a special case, in that it
531 is the only directory which is built both using the host compiler and
532 using the target compiler.
534 This is because the files in `libiberty' are used when building the
535 host tools, and they are also incorporated into the `libstdc++' target
536 library as support code.
538 This duality does not pose any particular difficulties. It means
539 that there are targets for both `all-libiberty' and
540 `all-target-libiberty'.
542 In a native configuration, when target libraries are not built in a
543 subdirectory, the same objects are normally used as both the host build
544 and the target build. This is normally OK, since libiberty contains
545 only C code, and in a native configuration the results of the host
546 compiler and the target compiler are normally interoperable.
548 Irix 6 is again an exception here, since the SGI native compiler
549 defaults to using the `O32' ABI, and gcc defaults to using the `N32'
550 ABI. On Irix 6, the target libraries are built in a subdirectory even
551 for a native configuration, avoiding this problem.
553 There are currently no other libraries built for both the host and
554 the target, but there is no conceptual problem with adding more.
557 File: configure.info, Node: Canadian Cross, Next: Cygnus Configure, Prev: Cross Compilation Tools, Up: Top
562 It is possible to use the GNU configure and build system to build a
563 program which will run on a system which is different from the system on
564 which the tools are built. In other words, it is possible to build
565 programs using a cross compiler.
567 This is referred to as a "Canadian Cross".
571 * Canadian Cross Example:: Canadian Cross Example.
572 * Canadian Cross Concepts:: Canadian Cross Concepts.
573 * Build Cross Host Tools:: Build Cross Host Tools.
574 * Build and Host Options:: Build and Host Options.
575 * CCross not in Cygnus Tree:: Canadian Cross not in Cygnus Tree.
576 * CCross in Cygnus Tree:: Canadian Cross in Cygnus Tree.
577 * Supporting Canadian Cross:: Supporting Canadian Cross.
580 File: configure.info, Node: Canadian Cross Example, Next: Canadian Cross Concepts, Up: Canadian Cross
582 Canadian Cross Example
583 ======================
585 Here is an example of a Canadian Cross.
587 While running on a GNU/Linux, you can build a program which will run
588 on a Solaris system. You would use a GNU/Linux cross Solaris compiler
589 to build the program.
591 Of course, you could not run the resulting program on your GNU/Linux
592 system. You would have to copy it over to a Solaris system before you
595 Of course, you could also simply build the programs on the Solaris
596 system in the first place. However, perhaps the Solaris system is not
597 available for some reason; perhaps you actually don't have one, but you
598 want to build the tools for somebody else to use. Or perhaps your
599 GNU/Linux system is much faster than your Solaris system.
601 A Canadian Cross build is most frequently used when building
602 programs to run on a non-Unix system, such as DOS or Windows. It may
603 be simpler to configure and build on a Unix system than to support the
604 configuration machinery on a non-Unix system.
607 File: configure.info, Node: Canadian Cross Concepts, Next: Build Cross Host Tools, Prev: Canadian Cross Example, Up: Canadian Cross
609 Canadian Cross Concepts
610 =======================
612 When building a Canadian Cross, there are at least two different
613 systems involved: the system on which the tools are being built, and
614 the system on which the tools will run.
616 The system on which the tools are being built is called the "build"
619 The system on which the tools will run is called the host system.
621 For example, if you are building a Solaris program on a GNU/Linux
622 system, as in the previous section, the build system would be GNU/Linux,
623 and the host system would be Solaris.
625 It is, of course, possible to build a cross compiler using a Canadian
626 Cross (i.e., build a cross compiler using a cross compiler). In this
627 case, the system for which the resulting cross compiler generates code
628 is called the target system. (For a more complete discussion of host
629 and target systems, *note Host and Target::).
631 An example of building a cross compiler using a Canadian Cross would
632 be building a Windows cross MIPS ELF compiler on a GNU/Linux system. In
633 this case the build system would be GNU/Linux, the host system would be
634 Windows, and the target system would be MIPS ELF.
636 The name Canadian Cross comes from the case when the build, host, and
637 target systems are all different. At the time that these issues were
638 all being hashed out, Canada had three national political parties.
641 File: configure.info, Node: Build Cross Host Tools, Next: Build and Host Options, Prev: Canadian Cross Concepts, Up: Canadian Cross
643 Build Cross Host Tools
644 ======================
646 In order to configure a program for a Canadian Cross build, you must
647 first build and install the set of cross tools you will use to build the
650 These tools will be build cross host tools. That is, they will run
651 on the build system, and will produce code that runs on the host system.
653 It is easy to confuse the meaning of build and host here. Always
654 remember that the build system is where you are doing the build, and the
655 host system is where the resulting program will run. Therefore, you
656 need a build cross host compiler.
658 In general, you must have a complete cross environment in order to do
659 the build. This normally means a cross compiler, cross assembler, and
660 so forth, as well as libraries and include files for the host system.
663 File: configure.info, Node: Build and Host Options, Next: CCross not in Cygnus Tree, Prev: Build Cross Host Tools, Up: Canadian Cross
665 Build and Host Options
666 ======================
668 When you run `configure', you must use both the `--build' and
671 The `--build' option is used to specify the configuration name of
672 the build system. This can normally be the result of running the
673 `config.guess' shell script, and it is reasonable to use
674 `--build=`config.guess`'.
676 The `--host' option is used to specify the configuration name of the
679 As we explained earlier, `config.guess' is used to set the default
680 value for the `--host' option (*note Using the Host Type::). We can
681 now see that since `config.guess' returns the type of system on which
682 it is run, it really identifies the build system. Since the host
683 system is normally the same as the build system (i.e., people do not
684 normally build using a cross compiler), it is reasonable to use the
685 result of `config.guess' as the default for the host system when the
686 `--host' option is not used.
688 It might seem that if the `--host' option were used without the
689 `--build' option that the configure script could run `config.guess' to
690 determine the build system, and presume a Canadian Cross if the result
691 of `config.guess' differed from the `--host' option. However, for
692 historical reasons, some configure scripts are routinely run using an
693 explicit `--host' option, rather than using the default from
694 `config.guess'. As noted earlier, it is difficult or impossible to
695 reliably compare configuration names (*note Using the Target Type::).
696 Therefore, by convention, if the `--host' option is used, but the
697 `--build' option is not used, then the build system defaults to the
701 File: configure.info, Node: CCross not in Cygnus Tree, Next: CCross in Cygnus Tree, Prev: Build and Host Options, Up: Canadian Cross
703 Canadian Cross not in Cygnus Tree.
704 ==================================
706 If you are not using the Cygnus tree, you must explicitly specify the
707 cross tools which you want to use to build the program. This is done by
708 setting environment variables before running the `configure' script.
710 You must normally set at least the environment variables `CC', `AR',
711 and `RANLIB' to the cross tools which you want to use to build.
713 For some programs, you must set additional cross tools as well, such
714 as `AS', `LD', or `NM'.
716 You would set these environment variables to the build cross tools
717 which you are going to use.
719 For example, if you are building a Solaris program on a GNU/Linux
720 system, and your GNU/Linux cross Solaris compiler were named
721 `solaris-gcc', then you would set the environment variable `CC' to
725 File: configure.info, Node: CCross in Cygnus Tree, Next: Supporting Canadian Cross, Prev: CCross not in Cygnus Tree, Up: Canadian Cross
727 Canadian Cross in Cygnus Tree
728 =============================
730 This section describes configuring and building a Canadian Cross when
731 using the Cygnus tree.
735 * Standard Cygnus CCross:: Building a Normal Program.
736 * Cross Cygnus CCross:: Building a Cross Program.
739 File: configure.info, Node: Standard Cygnus CCross, Next: Cross Cygnus CCross, Up: CCross in Cygnus Tree
741 Building a Normal Program
742 -------------------------
744 When configuring a Canadian Cross in the Cygnus tree, all the
745 appropriate environment variables are automatically set to `HOST-TOOL',
746 where HOST is the value used for the `--host' option, and TOOL is the
747 name of the tool (e.g., `gcc', `as', etc.). These tools must be on
750 Adding a prefix of HOST will give the usual name for the build cross
751 host tools. To see this, consider that when these cross tools were
752 built, they were configured to run on the build system and to produce
753 code for the host system. That is, they were configured with a
754 `--target' option that is the same as the system which we are now
755 calling the host. Recall that the default name for installed cross
756 tools uses the target system as a prefix (*note Using the Target
757 Type::). Since that is the system which we are now calling the host,
758 HOST is the right prefix to use.
760 For example, if you configure with `--build=i386-linux-gnu' and
761 `--host=solaris', then the Cygnus tree will automatically default to
762 using the compiler `solaris-gcc'. You must have previously built and
763 installed this compiler, probably by doing a build with no `--host'
764 option and with a `--target' option of `solaris'.
767 File: configure.info, Node: Cross Cygnus CCross, Prev: Standard Cygnus CCross, Up: CCross in Cygnus Tree
769 Building a Cross Program
770 ------------------------
772 There are additional considerations if you want to build a cross
773 compiler, rather than a native compiler, in the Cygnus tree using a
776 When you build a cross compiler using the Cygnus tree, then the
777 target libraries will normally be built with the newly built target
778 compiler (*note Host and Target Libraries::). However, this will not
779 work when building with a Canadian Cross. This is because the newly
780 built target compiler will be a program which runs on the host system,
781 and therefore will not be able to run on the build system.
783 Therefore, when building a cross compiler with the Cygnus tree, you
784 must first install a set of build cross target tools. These tools will
785 be used when building the target libraries.
787 Note that this is not a requirement of a Canadian Cross in general.
788 For example, it would be possible to build just the host cross target
789 tools on the build system, to copy the tools to the host system, and to
790 build the target libraries on the host system. The requirement for
791 build cross target tools is imposed by the Cygnus tree, which expects
792 to be able to build both host programs and target libraries in a single
793 `configure'/`make' step. Because it builds these in a single step, it
794 expects to be able to build the target libraries on the build system,
795 which means that it must use a build cross target toolchain.
797 For example, suppose you want to build a Windows cross MIPS ELF
798 compiler on a GNU/Linux system. You must have previously installed
799 both a GNU/Linux cross Windows compiler and a GNU/Linux cross MIPS ELF
802 In order to build the Windows (configuration name `i386-cygwin32')
803 cross MIPS ELF (configure name `mips-elf') compiler, you might execute
804 the following commands (long command lines are broken across lines with
805 a trailing backslash as a continuation character).
807 mkdir linux-x-cygwin32
809 SRCDIR/configure --target i386-cygwin32 --prefix=INSTALLDIR \
810 --exec-prefix=INSTALLDIR/H-i386-linux
814 mkdir linux-x-mips-elf
816 SRCDIR/configure --target mips-elf --prefix=INSTALLDIR \
817 --exec-prefix=INSTALLDIR/H-i386-linux
821 mkdir cygwin32-x-mips-elf
822 cd cygwin32-x-mips-elf
823 SRCDIR/configure --build=i386-linux-gnu --host=i386-cygwin32 \
824 --target=mips-elf --prefix=WININSTALLDIR \
825 --exec-prefix=WININSTALLDIR/H-i386-cygwin32
829 You would then copy the contents of WININSTALLDIR over to the
830 Windows machine, and run the resulting programs.
833 File: configure.info, Node: Supporting Canadian Cross, Prev: CCross in Cygnus Tree, Up: Canadian Cross
835 Supporting Canadian Cross
836 =========================
838 If you want to make it possible to build a program you are developing
839 using a Canadian Cross, you must take some care when writing your
840 configure and make rules. Simple cases will normally work correctly.
841 However, it is not hard to write configure and make tests which will
842 fail in a Canadian Cross.
846 * CCross in Configure:: Supporting Canadian Cross in Configure Scripts.
847 * CCross in Make:: Supporting Canadian Cross in Makefiles.
850 File: configure.info, Node: CCross in Configure, Next: CCross in Make, Up: Supporting Canadian Cross
852 Supporting Canadian Cross in Configure Scripts
853 ----------------------------------------------
855 In a `configure.in' file, after calling `AC_PROG_CC', you can find
856 out whether this is a Canadian Cross configure by examining the shell
857 variable `cross_compiling'. In a Canadian Cross, which means that the
858 compiler is a cross compiler, `cross_compiling' will be `yes'. In a
859 normal configuration, `cross_compiling' will be `no'.
861 You ordinarily do not need to know the type of the build system in a
862 configure script. However, if you do need that information, you can get
863 it by using the macro `AC_CANONICAL_SYSTEM', the same macro that is
864 used to determine the target system. This macro will set the variables
865 `build', `build_alias', `build_cpu', `build_vendor', and `build_os',
866 which correspond to the similar `target' and `host' variables, except
867 that they describe the build system.
869 When writing tests in `configure.in', you must remember that you
870 want to test the host environment, not the build environment.
872 Macros like `AC_CHECK_FUNCS' which use the compiler will test the
873 host environment. That is because the tests will be done by running the
874 compiler, which is actually a build cross host compiler. If the
875 compiler can find the function, that means that the function is present
876 in the host environment.
878 Tests like `test -f /dev/ptyp0', on the other hand, will test the
879 build environment. Remember that the configure script is running on the
880 build system, not the host system. If your configure scripts examines
881 files, those files will be on the build system. Whatever you determine
882 based on those files may or may not be the case on the host system.
884 Most autoconf macros will work correctly for a Canadian Cross. The
885 main exception is `AC_TRY_RUN'. This macro tries to compile and run a
886 test program. This will fail in a Canadian Cross, because the program
887 will be compiled for the host system, which means that it will not run
890 The `AC_TRY_RUN' macro provides an optional argument to tell the
891 configure script what to do in a Canadian Cross. If that argument is
892 not present, you will get a warning when you run `autoconf':
893 warning: AC_TRY_RUN called without default to allow cross compiling
895 This tells you that the resulting `configure' script will not work with
898 In some cases while it may better to perform a test at configure
899 time, it is also possible to perform the test at run time. In such a
900 case you can use the cross compiling argument to `AC_TRY_RUN' to tell
901 your program that the test could not be performed at configure time.
903 There are a few other autoconf macros which will not work correctly
904 with a Canadian Cross: a partial list is `AC_FUNC_GETPGRP',
905 `AC_FUNC_SETPGRP', `AC_FUNC_SETVBUF_REVERSED', and
906 `AC_SYS_RESTARTABLE_SYSCALLS'. The `AC_CHECK_SIZEOF' macro is
907 generally not very useful with a Canadian Cross; it permits an optional
908 argument indicating the default size, but there is no way to know what
909 the correct default should be.
912 File: configure.info, Node: CCross in Make, Prev: CCross in Configure, Up: Supporting Canadian Cross
914 Supporting Canadian Cross in Makefiles.
915 ---------------------------------------
917 The main Canadian Cross issue in a `Makefile' arises when you want
918 to use a subsidiary program to generate code or data which you will then
919 include in your real program.
921 If you compile this subsidiary program using `$(CC)' in the usual
922 way, you will not be able to run it. This is because `$(CC)' will
923 build a program for the host system, but the program is being built on
926 You must instead use a compiler for the build system, rather than the
927 host system. In the Cygnus tree, this make variable `$(CC_FOR_BUILD)'
928 will hold a compiler for the build system.
930 Note that you should not include `config.h' in a file you are
931 compiling with `$(CC_FOR_BUILD)'. The `configure' script will build
932 `config.h' with information for the host system. However, you are
933 compiling the file using a compiler for the build system (a native
934 compiler). Subsidiary programs are normally simple filters which do no
935 user interaction, and it is normally possible to write them in a highly
936 portable fashion so that the absence of `config.h' is not crucial.
938 The gcc `Makefile.in' shows a complex situation in which certain
939 files, such as `rtl.c', must be compiled into both subsidiary programs
940 run on the build system and into the final program. This approach may
941 be of interest for advanced build system hackers. Note that the build
942 system compiler is rather confusingly called `HOST_CC'.
945 File: configure.info, Node: Cygnus Configure, Next: Multilibs, Prev: Canadian Cross, Up: Top
950 The Cygnus configure script predates autoconf. All of its
951 interesting features have been incorporated into autoconf. No new
952 programs should be written to use the Cygnus configure script.
954 However, the Cygnus configure script is still used in a few places:
955 at the top of the Cygnus tree and in a few target libraries in the
956 Cygnus tree. Until those uses have been replaced with autoconf, some
957 brief notes are appropriate here. This is not complete documentation,
958 but it should be possible to use this as a guide while examining the
963 * Cygnus Configure Basics:: Cygnus Configure Basics.
964 * Cygnus Configure in C++ Libraries:: Cygnus Configure in C++ Libraries.
967 File: configure.info, Node: Cygnus Configure Basics, Next: Cygnus Configure in C++ Libraries, Up: Cygnus Configure
969 Cygnus Configure Basics
970 =======================
972 Cygnus configure does not use any generated files; there is no
973 program corresponding to `autoconf'. Instead, there is a single shell
974 script named `configure' which may be found at the top of the Cygnus
975 tree. This shell script was written by hand; it was not generated by
976 autoconf, and it is incorrect, and indeed harmful, to run `autoconf' in
977 the top level of a Cygnus tree.
979 Cygnus configure works in a particular directory by examining the
980 file `configure.in' in that directory. That file is broken into four
981 separate shell scripts.
983 The first is the contents of `configure.in' up to a line that starts
984 with `# per-host:'. This is the common part.
986 The second is the rest of `configure.in' up to a line that starts
987 with `# per-target:'. This is the per host part.
989 The third is the rest of `configure.in' up to a line that starts
990 with `# post-target:'. This is the per target part.
992 The fourth is the remainder of `configure.in'. This is the post
995 If any of these comment lines are missing, the corresponding shell
998 Cygnus configure will first execute the common part. This must set
999 the shell variable `srctrigger' to the name of a source file, to
1000 confirm that Cygnus configure is looking at the right directory. This
1001 may set the shell variables `package_makefile_frag' and
1002 `package_makefile_rules_frag'.
1004 Cygnus configure will next set the `build' and `host' shell
1005 variables, and execute the per host part. This may set the shell
1006 variable `host_makefile_frag'.
1008 Cygnus configure will next set the `target' variable, and execute
1009 the per target part. This may set the shell variable
1010 `target_makefile_frag'.
1012 Any of these scripts may set the `subdirs' shell variable. This
1013 variable is a list of subdirectories where a `Makefile.in' file may be
1014 found. Cygnus configure will automatically look for a `Makefile.in'
1015 file in the current directory. The `subdirs' shell variable is not
1016 normally used, and I believe that the only directory which uses it at
1017 present is `newlib'.
1019 For each `Makefile.in', Cygnus configure will automatically create a
1020 `Makefile' by adding definitions for `make' variables such as `host'
1021 and `target', and automatically editing the values of `make' variables
1022 such as `prefix' if they are present.
1024 Also, if any of the `makefile_frag' shell variables are set, Cygnus
1025 configure will interpret them as file names relative to either the
1026 working directory or the source directory, and will read the contents of
1027 the file into the generated `Makefile'. The file contents will be read
1028 in after the first line in `Makefile.in' which starts with `####'.
1030 These `Makefile' fragments are used to customize behaviour for a
1031 particular host or target. They serve to select particular files to
1032 compile, and to define particular preprocessor macros by providing
1033 values for `make' variables which are then used during compilation.
1034 Cygnus configure, unlike autoconf, normally does not do feature tests,
1035 and normally requires support to be added manually for each new host.
1037 The `Makefile' fragment support is similar to the autoconf
1038 `AC_SUBST_FILE' macro.
1040 After creating each `Makefile', the post target script will be run
1041 (i.e., it may be run several times). This script may further customize
1042 the `Makefile'. When it is run, the shell variable `Makefile' will
1043 hold the name of the `Makefile', including the appropriate directory
1046 Like an autoconf generated `configure' script, Cygnus configure will
1047 create a file named `config.status' which, when run, will automatically
1048 recreate the configuration. The `config.status' file will simply
1049 execute the Cygnus configure script again with the appropriate
1052 Any of the parts of `configure.in' may set the shell variables
1053 `files' and `links'. Cygnus configure will set up symlinks from the
1054 names in `links' to the files named in `files'. This is similar to the
1055 autoconf `AC_LINK_FILES' macro.
1057 Finally, any of the parts of `configure.in' may set the shell
1058 variable `configdirs' to a set of subdirectories. If it is set, Cygnus
1059 configure will recursively run the configure process in each
1060 subdirectory. If the subdirectory uses Cygnus configure, it will
1061 contain a `configure.in' file but no `configure' file, in which case
1062 Cygnus configure will invoke itself recursively. If the subdirectory
1063 has a `configure' file, Cygnus configure assumes that it is an autoconf
1064 generated `configure' script, and simply invokes it directly.
1067 File: configure.info, Node: Cygnus Configure in C++ Libraries, Prev: Cygnus Configure Basics, Up: Cygnus Configure
1069 Cygnus Configure in C++ Libraries
1070 =================================
1072 The C++ library configure system, written by Per Bothner, deserves
1073 special mention. It uses Cygnus configure, but it does feature testing
1074 like that done by autoconf generated `configure' scripts. This
1075 approach is used in the libraries `libio', `libstdc++', and `libg++'.
1077 Most of the `Makefile' information is written out by the shell
1078 script `libio/config.shared'. Each `configure.in' file sets certain
1079 shell variables, and then invokes `config.shared' to create two package
1080 `Makefile' fragments. These fragments are then incorporated into the
1081 resulting `Makefile' by the Cygnus configure script.
1083 The file `_G_config.h' is created in the `libio' object directory by
1084 running the shell script `libio/gen-params'. This shell script uses
1085 feature tests to define macros and typedefs in `_G_config.h'.
1088 File: configure.info, Node: Multilibs, Next: FAQ, Prev: Cygnus Configure, Up: Top
1093 For some targets gcc may have different processor requirements
1094 depending upon command line options. An obvious example is the
1095 `-msoft-float' option supported on several processors. This option
1096 means that the floating point registers are not available, which means
1097 that floating point operations must be done by calling an emulation
1098 subroutine rather than by using machine instructions.
1100 For such options, gcc is often configured to compile target libraries
1101 twice: once with `-msoft-float' and once without. When gcc compiles
1102 target libraries more than once, the resulting libraries are called
1105 Multilibs are not really part of the GNU configure and build system,
1106 but we discuss them here since they require support in the `configure'
1107 scripts and `Makefile's used for target libraries.
1111 * Multilibs in gcc:: Multilibs in gcc.
1112 * Multilibs in Target Libraries:: Multilibs in Target Libraries.
1115 File: configure.info, Node: Multilibs in gcc, Next: Multilibs in Target Libraries, Up: Multilibs
1120 In gcc, multilibs are defined by setting the variable
1121 `MULTILIB_OPTIONS' in the target `Makefile' fragment. Several other
1122 `MULTILIB' variables may also be defined there. *Note The Target
1123 Makefile Fragment: (gcc)Target Fragment.
1125 If you have built gcc, you can see what multilibs it uses by running
1126 it with the `-print-multi-lib' option. The output `.;' means that no
1127 multilibs are used. In general, the output is a sequence of lines, one
1128 per multilib. The first part of each line, up to the `;', is the name
1129 of the multilib directory. The second part is a list of compiler
1130 options separated by `@' characters.
1132 Multilibs are built in a tree of directories. The top of the tree,
1133 represented by `.' in the list of multilib directories, is the default
1134 library to use when no special compiler options are used. The
1135 subdirectories of the tree hold versions of the library to use when
1136 particular compiler options are used.