1 This is configure.info, produced by makeinfo version 4.2 from
2 ../../src/etc/configure.texi.
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: Top, Next: Introduction, Up: (dir)
30 GNU configure and build system
31 ******************************
33 The GNU configure and build system.
37 * Introduction:: Introduction.
38 * Getting Started:: Getting Started.
40 * Configuration Names:: Configuration Names.
41 * Cross Compilation Tools:: Cross Compilation Tools.
42 * Canadian Cross:: Canadian Cross.
43 * Cygnus Configure:: Cygnus Configure.
44 * Multilibs:: Multilibs.
45 * FAQ:: Frequently Asked Questions.
49 File: configure.info, Node: Introduction, Next: Getting Started, Prev: Top, Up: Top
54 This document describes the GNU configure and build systems. It
55 describes how autoconf, automake, libtool, and make fit together. It
56 also includes a discussion of the older Cygnus configure system.
58 This document does not describe in detail how to use each of the
59 tools; see the respective manuals for that. Instead, it describes
60 which files the developer must write, which files are machine generated
61 and how they are generated, and where certain common problems should be
64 This document draws on several sources, including the autoconf
65 manual by David MacKenzie (*note autoconf overview: (autoconf)Top.),
66 the automake manual by David MacKenzie and Tom Tromey (*note automake
67 overview: (automake)Top.), the libtool manual by Gordon Matzigkeit
68 (*note libtool overview: (libtool)Top.), and the Cygnus configure
69 manual by K. Richard Pixley.
76 * Building:: Building.
79 File: configure.info, Node: Goals, Next: Tools, Up: Introduction
84 The GNU configure and build system has two main goals.
86 The first is to simplify the development of portable programs. The
87 system permits the developer to concentrate on writing the program,
88 simplifying many details of portability across Unix and even Windows
89 systems, and permitting the developer to describe how to build the
90 program using simple rules rather than complex Makefiles.
92 The second is to simplify the building of programs distributed as
93 source code. All programs are built using a simple, standardized, two
94 step process. The program builder need not install any special tools in
95 order to build the program.
98 File: configure.info, Node: Tools, Next: History, Prev: Goals, Up: Introduction
103 The GNU configure and build system is comprised of several different
104 tools. Program developers must build and install all of these tools.
106 People who just want to build programs from distributed sources
107 normally do not need any special tools beyond a Unix shell, a make
108 program, and a C compiler.
111 provides a general portability framework, based on testing the
112 features of the host system at build time.
115 a system for describing how to build a program, permitting the
116 developer to write a simplified `Makefile'.
119 a standardized approach to building shared libraries.
122 provides a framework for translation of text messages into other
123 languages; not really discussed in this document.
126 autoconf requires the GNU version of m4; the standard Unix m4 does
130 automake requires perl.
133 File: configure.info, Node: History, Next: Building, Prev: Tools, Up: Introduction
138 This is a very brief and probably inaccurate history.
140 As the number of Unix variants increased during the 1980s, it became
141 harder to write programs which could run on all variants. While it was
142 often possible to use `#ifdef' to identify particular systems,
143 developers frequently did not have access to every system, and the
144 characteristics of some systems changed from version to version.
146 By 1992, at least three different approaches had been developed:
147 * The Metaconfig program, by Larry Wall, Harlan Stenn, and Raphael
150 * The Cygnus configure script, by K. Richard Pixley, and the gcc
151 configure script, by Richard Stallman. These use essentially the
152 same approach, and the developers communicated regularly.
154 * The autoconf program, by David MacKenzie.
156 The Metaconfig program is still used for Perl and a few other
157 programs. It is part of the Dist package. I do not know if it is
160 In 1994, David MacKenzie and others modified autoconf to incorporate
161 all the features of Cygnus configure. Since then, there has been a
162 slow but steady conversion of GNU programs from Cygnus configure to
163 autoconf. gcc has been converted, eliminating the gcc configure script.
165 GNU autoconf was regularly maintained until late 1996. As of this
166 writing in June, 1998, it has no public maintainer.
168 Most programs are built using the make program, which requires the
169 developer to write Makefiles describing how to build the programs.
170 Since most programs are built in pretty much the same way, this led to a
173 The X Window system is built using the imake tool, which uses a
174 database of rules to eliminate the duplication. However, building a
175 tool which was developed using imake requires that the builder have
176 imake installed, violating one of the goals of the GNU system.
178 The new BSD make provides a standard library of Makefile fragments,
179 which permits developers to write very simple Makefiles. However, this
180 requires that the builder install the new BSD make program.
182 In 1994, David MacKenzie wrote the first version of automake, which
183 permitted writing a simple build description which was converted into a
184 Makefile which could be used by the standard make program. In 1995, Tom
185 Tromey completely rewrote automake in Perl, and he continues to enhance
188 Various free packages built libraries, and by around 1995 several
189 included support to build shared libraries on various platforms.
190 However, there was no consistent approach. In early 1996, Gordon
191 Matzigkeit began working on libtool, which provided a standardized
192 approach to building shared libraries. This was integrated into
193 automake from the start.
195 The development of automake and libtool was driven by the GNITS
196 project, a group of GNU maintainers who designed standardized tools to
197 help meet the GNU coding standards.
200 File: configure.info, Node: Building, Prev: History, Up: Introduction
205 Most readers of this document should already know how to build a
206 tool by running `configure' and `make'. This section may serve as a
207 quick introduction or reminder.
209 Building a tool is normally as simple as running `configure'
210 followed by `make'. You should normally run `configure' from an empty
211 directory, using some path to refer to the `configure' script in the
212 source directory. The directory in which you run `configure' is called
213 the "object directory".
215 In order to use a object directory which is different from the source
216 directory, you must be using the GNU version of `make', which has the
217 required `VPATH' support. Despite this restriction, using a different
218 object directory is highly recommended:
219 * It keeps the files generated during the build from cluttering up
222 * It permits you to remove the built files by simply removing the
223 entire build directory.
225 * It permits you to build from the same sources with several sets of
226 configure options simultaneously.
228 If you don't have GNU `make', you will have to run `configure' in
229 the source directory. All GNU packages should support this; in
230 particular, GNU packages should not assume the presence of GNU `make'.
232 After running `configure', you can build the tools by running `make'.
234 To install the tools, run `make install'. Installing the tools will
235 copy the programs and any required support files to the "installation
236 directory". The location of the installation directory is controlled
237 by `configure' options, as described below.
239 In the Cygnus tree at present, the info files are built and
240 installed as a separate step. To build them, run `make info'. To
241 install them, run `make install-info'.
243 All `configure' scripts support a wide variety of options. The most
244 interesting ones are `--with' and `--enable' options which are
245 generally specific to particular tools. You can usually use the
246 `--help' option to get a list of interesting options for a particular
249 The only generic options you are likely to use are the `--prefix'
250 and `--exec-prefix' options. These options are used to specify the
251 installation directory.
253 The directory named by the `--prefix' option will hold machine
254 independent files such as info files.
256 The directory named by the `--exec-prefix' option, which is normally
257 a subdirectory of the `--prefix' directory, will hold machine dependent
258 files such as executables.
260 The default for `--prefix' is `/usr/local'. The default for
261 `--exec-prefix' is the value used for `--prefix'.
263 The convention used in Cygnus releases is to use a `--prefix' option
264 of `/usr/cygnus/RELEASE', where RELEASE is the name of the release, and
265 to use a `--exec-prefix' option of `/usr/cygnus/RELEASE/H-HOST', where
266 HOST is the configuration name of the host system (*note Configuration
269 Do not use either the source or the object directory as the
270 installation directory. That will just lead to confusion.
273 File: configure.info, Node: Getting Started, Next: Files, Prev: Introduction, Up: Top
278 To start using the GNU configure and build system with your software
279 package, you must write three files, and you must run some tools to
280 manually generate additional files.
284 * Write configure.in:: Write configure.in.
285 * Write Makefile.am:: Write Makefile.am.
286 * Write acconfig.h:: Write acconfig.h.
287 * Generate files:: Generate files.
288 * Getting Started Example:: Example.
291 File: configure.info, Node: Write configure.in, Next: Write Makefile.am, Up: Getting Started
296 You must first write the file `configure.in'. This is an autoconf
297 input file, and the autoconf manual describes in detail what this file
300 You will write tests in your `configure.in' file to check for
301 conditions that may change from one system to another, such as the
302 presence of particular header files or functions.
304 For example, not all systems support the `gettimeofday' function.
305 If you want to use the `gettimeofday' function when it is available,
306 and to use some other function when it is not, you would check for this
307 by putting `AC_CHECK_FUNCS(gettimeofday)' in `configure.in'.
309 When the configure script is run at build time, this will arrange to
310 define the preprocessor macro `HAVE_GETTIMEOFDAY' to the value 1 if the
311 `gettimeofday' function is available, and to not define the macro at
312 all if the function is not available. Your code can then use `#ifdef'
313 to test whether it is safe to call `gettimeofday'.
315 If you have an existing body of code, the `autoscan' program may
316 help identify potential portability problems, and hence configure tests
317 that you will want to use. *Note Invoking autoscan: (autoconf)Invoking
320 Another handy tool for an existing body of code is `ifnames'. This
321 will show you all the preprocessor conditionals that the code already
322 uses. *Note Invoking ifnames: (autoconf)Invoking ifnames.
324 Besides the portability tests which are specific to your particular
325 package, every `configure.in' file should contain the following macros.
328 This macro takes a single argument, which is the name of a file in
329 your package. For example, `AC_INIT(foo.c)'.
332 This macro is optional. It may be used to indicate the version of
333 `autoconf' that you are using. This will prevent users from
334 running an earlier version of `autoconf' and perhaps getting an
335 invalid `configure' script. For example, `AC_PREREQ(2.12)'.
338 This macro takes two arguments: the name of the package, and a
339 version number. For example, `AM_INIT_AUTOMAKE(foo, 1.0)'. (This
340 macro is not needed if you are not using automake).
343 This macro names the header file which will hold the preprocessor
344 macro definitions at run time. Normally this should be
345 `config.h'. Your sources would then use `#include "config.h"' to
348 This macro may optionally name the input file for that header
349 file; by default, this is `config.h.in', but that file name works
350 poorly on DOS filesystems. Therefore, it is often better to name
351 it explicitly as `config.in'.
353 This is what you should normally put in `configure.in':
354 AM_CONFIG_HEADER(config.h:config.in)
356 (If you are not using automake, use `AC_CONFIG_HEADER' rather than
360 This macro always appears in Cygnus configure scripts. Other
361 programs may or may not use it.
363 If this macro is used, the `--enable-maintainer-mode' option is
364 required to enable automatic rebuilding of generated files used by
365 the configure system. This of course requires that developers be
366 aware of, and use, that option.
368 If this macro is not used, then the generated files will always be
369 rebuilt automatically. This will cause problems if the wrong
370 versions of autoconf, automake, or others are in the builder's
373 (If you are not using automake, you do not need to use this macro).
376 Either this macro or `AM_EXEEXT' always appears in Cygnus configure
377 files. Other programs may or may not use one of them.
379 This macro looks for the executable suffix used on the host
380 system. On Unix systems, this is the empty string. On Windows
381 systems, this is `.exe'. This macro directs automake to use the
382 executable suffix as appropriate when creating programs. This
383 macro does not take any arguments.
385 The `AC_EXEEXT' form is new, and is part of a Cygnus patch to
386 autoconf to support compiling with Visual C++. Older programs use
389 (Programs which do not use automake use neither `AC_EXEEXT' nor
393 If you are writing C code, you will normally want to use this
394 macro. It locates the C compiler to use. It does not take any
397 However, if this `configure.in' file is for a library which is to
398 be compiled by a cross compiler which may not fully work, then you
399 will not want to use `AC_PROG_CC'. Instead, you will want to use a
400 variant which does not call the macro `AC_PROG_CC_WORKS'. Examples
401 can be found in various `configure.in' files for libraries that are
402 compiled with cross compilers, such as libiberty or libgloss.
403 This is essentially a bug in autoconf, and there will probably be
404 a better workaround at some point.
407 If you are writing C++ code, you will want to use this macro. It
408 locates the C++ compiler to use. It does not take any arguments.
409 The same cross compiler comments apply as for `AC_PROG_CC'.
412 If you want to build libraries, and you want to permit them to be
413 shared, or you want to link against libraries which were built
414 using libtool, then you will need this macro. This macro is
415 required in order to use libtool.
417 By default, this will cause all libraries to be built as shared
418 libraries. To prevent this-to change the default-use
419 `AM_DISABLE_SHARED' before `AM_PROG_LIBTOOL'. The configure
420 options `--enable-shared' and `--disable-shared' may be used to
421 override the default at build time.
423 `AC_DEFINE(_GNU_SOURCE)'
424 GNU packages should normally include this line before any other
425 feature tests. This defines the macro `_GNU_SOURCE' when
426 compiling, which directs the libc header files to provide the
427 standard GNU system interfaces including all GNU extensions. If
428 this macro is not defined, certain GNU extensions may not be
432 This macro takes a list of file names which the configure process
433 should produce. This is normally a list of one or more `Makefile'
434 files in different directories. If your package lives entirely in
435 a single directory, you would use simply `AC_OUTPUT(Makefile)'.
436 If you also have, for example, a `lib' subdirectory, you would use
437 `AC_OUTPUT(Makefile lib/Makefile)'.
439 If you want to use locally defined macros in your `configure.in'
440 file, then you will need to write a `acinclude.m4' file which defines
441 them (if not using automake, this file is called `aclocal.m4').
442 Alternatively, you can put separate macros in an `m4' subdirectory, and
443 put `ACLOCAL_AMFLAGS = -I m4' in your `Makefile.am' file so that the
444 `aclocal' program will be able to find them.
446 The different macro prefixes indicate which tool defines the macro.
447 Macros which start with `AC_' are part of autoconf. Macros which start
448 with `AM_' are provided by automake or libtool.
451 File: configure.info, Node: Write Makefile.am, Next: Write acconfig.h, Prev: Write configure.in, Up: Getting Started
456 You must write the file `Makefile.am'. This is an automake input
457 file, and the automake manual describes in detail what this file should
460 The automake commands in `Makefile.am' mostly look like variable
461 assignments in a `Makefile'. automake recognizes special variable
462 names, and automatically add make rules to the output as needed.
464 There will be one `Makefile.am' file for each directory in your
465 package. For each directory with subdirectories, the `Makefile.am'
466 file should contain the line
467 SUBDIRS = DIR DIR ...
469 where each DIR is the name of a subdirectory.
471 For each `Makefile.am', there should be a corresponding `Makefile'
472 in the `AC_OUTPUT' macro in `configure.in'.
474 Every `Makefile.am' written at Cygnus should contain the line
475 AUTOMAKE_OPTIONS = cygnus
477 This puts automake into Cygnus mode. See the automake manual for
480 You may to include the version number of `automake' that you are
481 using on the `AUTOMAKE_OPTIONS' line. For example,
482 AUTOMAKE_OPTIONS = cygnus 1.3
484 This will prevent users from running an earlier version of `automake'
485 and perhaps getting an invalid `Makefile.in'.
487 If your package builds a program, then in the directory where that
488 program is built you will normally want a line like
489 bin_PROGRAMS = PROGRAM
491 where PROGRAM is the name of the program. You will then want a line
493 PROGRAM_SOURCES = FILE FILE ...
495 where each FILE is the name of a source file to link into the program
498 If your package builds a library, and you do not want the library to
499 ever be built as a shared library, then in the directory where that
500 library is built you will normally want a line like
501 lib_LIBRARIES = libNAME.a
503 where `libNAME.a' is the name of the library. You will then want a
505 libNAME_a_SOURCES = FILE FILE ...
507 where each FILE is the name of a source file to add to the library.
509 If your package builds a library, and you want to permit building the
510 library as a shared library, then in the directory where that library is
511 built you will normally want a line like
512 lib_LTLIBRARIES = libNAME.la
513 The use of `LTLIBRARIES', and the `.la' extension, indicate a
514 library to be built using libtool. As usual, you will then want a line
516 libNAME_la_SOURCES = FILE FILE ...
518 The strings `bin' and `lib' that appear above in `bin_PROGRAMS' and
519 `lib_LIBRARIES' are not arbitrary. They refer to particular
520 directories, which may be set by the `--bindir' and `--libdir' options
521 to `configure'. If those options are not used, the default values are
522 based on the `--prefix' or `--exec-prefix' options to `configure'. It
523 is possible to use other names if the program or library should be
524 installed in some other directory.
526 The `Makefile.am' file may also contain almost anything that may
527 appear in a normal `Makefile'. automake also supports many other
528 special variables, as well as conditionals.
530 See the automake manual for more information.
533 File: configure.info, Node: Write acconfig.h, Next: Generate files, Prev: Write Makefile.am, Up: Getting Started
538 If you are generating a portability header file, (i.e., you are using
539 `AM_CONFIG_HEADER' in `configure.in'), then you will have to write a
540 `acconfig.h' file. It will have to contain the following lines.
542 /* Name of package. */
545 /* Version of package. */
548 This requirement is really a bug in the system, and the requirement
549 may be eliminated at some later date.
551 The `acconfig.h' file will also similar comment and `#undef' lines
552 for any unusual macros in the `configure.in' file, including any macro
553 which appears in a `AC_DEFINE' macro.
555 In particular, if you are writing a GNU package and therefore include
556 `AC_DEFINE(_GNU_SOURCE)' in `configure.in' as suggested above, you will
557 need lines like this in `acconfig.h':
558 /* Enable GNU extensions. */
561 Normally the `autoheader' program will inform you of any such
562 requirements by printing an error message when it is run. However, if
563 you do anything particular odd in your `configure.in' file, you will
564 have to make sure that the right entries appear in `acconfig.h', since
565 otherwise the results of the tests may not be available in the
566 `config.h' file which your code will use.
568 (Thee `PACKAGE' and `VERSION' lines are not required if you are not
569 using automake, and in that case you may not need a `acconfig.h' file
573 File: configure.info, Node: Generate files, Next: Getting Started Example, Prev: Write acconfig.h, Up: Getting Started
578 Once you have written `configure.in', `Makefile.am', `acconfig.h',
579 and possibly `acinclude.m4', you must use autoconf and automake
580 programs to produce the first versions of the generated files. This is
581 done by executing the following sequence of commands.
588 The `aclocal' and `automake' commands are part of the automake
589 package, and the `autoconf' and `autoheader' commands are part of the
592 If you are using a `m4' subdirectory for your macros, you will need
593 to use the `-I m4' option when you run `aclocal'.
595 If you are not using the Cygnus tree, use the `-a' option when
596 running `automake' command in order to copy the required support files
597 into your source directory.
599 If you are using libtool, you must build and install the libtool
600 package with the same `--prefix' and `--exec-prefix' options as you
601 used with the autoconf and automake packages. You must do this before
602 running any of the above commands. If you are not using the Cygnus
603 tree, you will need to run the `libtoolize' program to copy the libtool
604 support files into your directory.
606 Once you have managed to run these commands without getting any
607 errors, you should create a new empty directory, and run the `configure'
608 script which will have been created by `autoconf' with the
609 `--enable-maintainer-mode' option. This will give you a set of
610 Makefiles which will include rules to automatically rebuild all the
613 After doing that, whenever you have changed some of the input files
614 and want to regenerated the other files, go to your object directory
615 and run `make'. Doing this is more reliable than trying to rebuild the
616 files manually, because there are complex order dependencies and it is
617 easy to forget something.
620 File: configure.info, Node: Getting Started Example, Prev: Generate files, Up: Getting Started
625 Let's consider a trivial example.
627 Suppose we want to write a simple version of `touch'. Our program,
628 which we will call `poke', will take a single file name argument, and
629 use the `utime' system call to set the modification and access times of
630 the file to the current time. We want this program to be highly
633 We'll first see what this looks like without using autoconf and
634 automake, and then see what it looks like with them.
638 * Getting Started Example 1:: First Try.
639 * Getting Started Example 2:: Second Try.
640 * Getting Started Example 3:: Third Try.
641 * Generate Files in Example:: Generate Files.
644 File: configure.info, Node: Getting Started Example 1, Next: Getting Started Example 2, Up: Getting Started Example
649 Here is our first try at `poke.c'. Note that we've written it
650 without ANSI/ISO C prototypes, since we want it to be highly portable.
654 #include <sys/types.h>
664 fprintf (stderr, "Usage: poke file\n");
668 if (utime (argv[1], NULL) < 0)
677 We also write a simple `Makefile'.
685 $(CC) -o poke $(CFLAGS) $(LDFLAGS) poke.o
689 Unfortunately, there are a few problems.
691 On older Unix systems derived from BSD 4.3, the `utime' system call
692 does not accept a second argument of `NULL'. On those systems, we need
693 to pass a pointer to `struct utimbuf' structure. Unfortunately, even
694 older systems don't define that structure; on those systems, we need to
695 pass an array of two `long' values.
697 The header file `stdlib.h' was invented by ANSI C, and older systems
698 don't have a copy. We included it above to get a declaration of `exit'.
700 We can find some of these portability problems by running
701 `autoscan', which will create a `configure.scan' file which we can use
702 as a prototype for our `configure.in' file. I won't show the output,
703 but it will notice the potential problems with `utime' and `stdlib.h'.
705 In our `Makefile', we don't provide any way to install the program.
706 This doesn't matter much for such a simple example, but a real program
707 will need an `install' target. For that matter, we will also want a
711 File: configure.info, Node: Getting Started Example 2, Next: Getting Started Example 3, Prev: Getting Started Example 1, Up: Getting Started Example
716 Here is our second try at this program.
718 We modify `poke.c' to use preprocessor macros to control what
719 features are available. (I've cheated a bit by using the same macro
720 names which autoconf will use).
728 #include <sys/types.h>
734 #ifndef HAVE_UTIME_NULL
738 #ifndef HAVE_STRUCT_UTIMBUF
754 now.actime = now.modtime = time (NULL);
755 return utime (file, &now);
758 #define utime(f, p) utime_now (f)
760 #endif /* HAVE_UTIME_NULL */
769 fprintf (stderr, "Usage: poke file\n");
773 if (utime (argv[1], NULL) < 0)
782 Here is the associated `Makefile'. We've added support for the
783 preprocessor flags we use. We've also added `install' and `clean'
786 # Set this to your installation directory.
787 bindir = /usr/local/bin
789 # Uncomment this if you have the standard ANSI/ISO C header files.
790 # STDC_HDRS = -DSTDC_HEADERS
792 # Uncomment this if you have utime.h.
793 # UTIME_H = -DHAVE_UTIME_H
795 # Uncomment this if utime (FILE, NULL) works on your system.
796 # UTIME_NULL = -DHAVE_UTIME_NULL
798 # Uncomment this if struct utimbuf is defined in utime.h.
799 # UTIMBUF = -DHAVE_STRUCT_UTIMBUF
804 ALL_CFLAGS = $(STDC_HDRS) $(UTIME_H) $(UTIME_NULL) $(UTIMBUF) $(CFLAGS)
809 $(CC) -o poke $(ALL_CFLAGS) $(LDFLAGS) poke.o
812 $(CC) -c $(ALL_CFLAGS) poke.c
815 cp poke $(bindir)/poke
820 Some problems with this approach should be clear.
822 Users who want to compile poke will have to know how `utime' works
823 on their systems, so that they can uncomment the `Makefile' correctly.
825 The installation is done using `cp', but many systems have an
826 `install' program which may be used, and which supports optional
827 features such as stripping debugging information out of the installed
830 The use of `Makefile' variables like `CC', `CFLAGS' and `LDFLAGS'
831 follows the requirements of the GNU standards. This is convenient for
832 all packages, since it reduces surprises for users. However, it is
833 easy to get the details wrong, and wind up with a slightly nonstandard
837 File: configure.info, Node: Getting Started Example 3, Next: Generate Files in Example, Prev: Getting Started Example 2, Up: Getting Started Example
842 For our third try at this program, we will write a `configure.in'
843 script to discover the configuration features on the host system, rather
844 than requiring the user to edit the `Makefile'. We will also write a
845 `Makefile.am' rather than a `Makefile'.
847 The only change to `poke.c' is to add a line at the start of the
851 The new `configure.in' file is as follows.
854 AM_INIT_AUTOMAKE(poke, 1.0)
855 AM_CONFIG_HEADER(config.h:config.in)
858 AC_CHECK_HEADERS(utime.h)
859 AC_EGREP_HEADER(utimbuf, utime.h, AC_DEFINE(HAVE_STRUCT_UTIMBUF))
863 The first four macros in this file, and the last one, were described
864 above; see *Note Write configure.in::. If we omit these macros, then
865 when we run `automake' we will get a reminder that we need them.
867 The other macros are standard autoconf macros.
870 Check for standard C headers.
873 Check whether a particular header file exists.
876 Check for a particular string in a particular header file, in this
877 case checking for `utimbuf' in `utime.h'.
880 Check whether `utime' accepts a NULL second argument to set the
881 file change time to the current time.
883 See the autoconf manual for a more complete description.
885 The new `Makefile.am' file is as follows. Note how simple this is
886 compared to our earlier `Makefile'.
890 poke_SOURCES = poke.c
892 This means that we should build a single program name `poke'. It
893 should be installed in the binary directory, which we called `bindir'
894 earlier. The program `poke' is built from the source file `poke.c'.
896 We must also write a `acconfig.h' file. Besides `PACKAGE' and
897 `VERSION', which must be mentioned for all packages which use automake,
898 we must include `HAVE_STRUCT_UTIMBUF', since we mentioned it in an
901 /* Name of package. */
904 /* Version of package. */
907 /* Whether utime.h defines struct utimbuf. */
908 #undef HAVE_STRUCT_UTIMBUF
911 File: configure.info, Node: Generate Files in Example, Prev: Getting Started Example 3, Up: Getting Started Example
916 We must now generate the other files, using the following commands.
923 When we run `autoheader', it will remind us of any macros we forgot
924 to add to `acconfig.h'.
926 When we run `automake', it will want to add some files to our
927 distribution. It will add them automatically if we use the
928 `--add-missing' option.
930 By default, `automake' will run in GNU mode, which means that it
931 will want us to create certain additional files; as of this writing, it
932 will want `NEWS', `README', `AUTHORS', and `ChangeLog', all of which
933 are files which should appear in a standard GNU distribution. We can
934 either add those files, or run `automake' with the `--foreign' option.
936 Running these tools will generate the following files, all of which
937 are described in the next chapter.
950 File: configure.info, Node: Files, Next: Configuration Names, Prev: Getting Started, Up: Top
955 As was seen in the previous chapter, the GNU configure and build
956 system uses a number of different files. The developer must write a
957 few files. The others are generated by various tools.
959 The system is rather flexible, and can be used in many different
960 ways. In describing the files that it uses, I will describe the common
961 case, and mention some other cases that may arise.
965 * Developer Files:: Developer Files.
966 * Build Files:: Build Files.
967 * Support Files:: Support Files.
970 File: configure.info, Node: Developer Files, Next: Build Files, Up: Files
975 This section describes the files written or generated by the
976 developer of a package.
980 * Developer Files Picture:: Developer Files Picture.
981 * Written Developer Files:: Written Developer Files.
982 * Generated Developer Files:: Generated Developer Files.
985 File: configure.info, Node: Developer Files Picture, Next: Written Developer Files, Up: Developer Files
987 Developer Files Picture
988 -----------------------
990 Here is a picture of the files which are written by the developer,
991 the generated files which would be included with a complete source
992 distribution, and the tools which create those files. The file names
993 are plain text and the tool names are enclosed by `*' characters (e.g.,
994 `autoheader' is the name of a tool, not the name of a file).
996 acconfig.h configure.in Makefile.am
998 | --------------+---------------------- |
1000 v v | acinclude.m4 | |
1001 *autoheader* | | v v
1002 | | v --->*automake*
1003 v |--->*aclocal* | |
1015 File: configure.info, Node: Written Developer Files, Next: Generated Developer Files, Prev: Developer Files Picture, Up: Developer Files
1017 Written Developer Files
1018 -----------------------
1020 The following files would be written by the developer.
1023 This is the configuration script. This script contains
1024 invocations of autoconf macros. It may also contain ordinary
1025 shell script code. This file will contain feature tests for
1026 portability issues. The last thing in the file will normally be
1027 an `AC_OUTPUT' macro listing which files to create when the
1028 builder runs the configure script. This file is always required
1029 when using the GNU configure system. *Note Write configure.in::.
1032 This is the automake input file. It describes how the code should
1033 be built. It consists of definitions of automake variables. It
1034 may also contain ordinary Makefile targets. This file is only
1035 needed when using automake (newer tools normally use automake, but
1036 there are still older tools which have not been converted, in
1037 which the developer writes `Makefile.in' directly). *Note Write
1041 When the configure script creates a portability header file, by
1042 using `AM_CONFIG_HEADER' (or, if not using automake,
1043 `AC_CONFIG_HEADER'), this file is used to describe macros which are
1044 not recognized by the `autoheader' command. This is normally a
1045 fairly uninteresting file, consisting of a collection of `#undef'
1046 lines with comments. Normally any call to `AC_DEFINE' in
1047 `configure.in' will require a line in this file. *Note Write
1051 This file is not always required. It defines local autoconf
1052 macros. These macros may then be used in `configure.in'. If you
1053 don't need any local autoconf macros, then you don't need this
1054 file at all. In fact, in general, you never need local autoconf
1055 macros, since you can put everything in `configure.in', but
1056 sometimes a local macro is convenient.
1058 Newer tools may omit `acinclude.m4', and instead use a
1059 subdirectory, typically named `m4', and define `ACLOCAL_AMFLAGS =
1060 -I m4' in `Makefile.am' to force `aclocal' to look there for macro
1061 definitions. The macro definitions are then placed in separate
1062 files in that directory.
1064 The `acinclude.m4' file is only used when using automake; in older
1065 tools, the developer writes `aclocal.m4' directly, if it is needed.
1068 File: configure.info, Node: Generated Developer Files, Prev: Written Developer Files, Up: Developer Files
1070 Generated Developer Files
1071 -------------------------
1073 The following files would be generated by the developer.
1075 When using automake, these files are normally not generated manually
1076 after the first time. Instead, the generated `Makefile' contains rules
1077 to automatically rebuild the files as required. When
1078 `AM_MAINTAINER_MODE' is used in `configure.in' (the normal case in
1079 Cygnus code), the automatic rebuilding rules will only be defined if
1080 you configure using the `--enable-maintainer-mode' option.
1082 When using automatic rebuilding, it is important to ensure that all
1083 the various tools have been built and installed on your `PATH'. Using
1084 automatic rebuilding is highly recommended, so much so that I'm not
1085 going to explain what you have to do if you don't use it.
1088 This is the configure script which will be run when building the
1089 package. This is generated by `autoconf' from `configure.in' and
1090 `aclocal.m4'. This is a shell script.
1093 This is the file which the configure script will turn into the
1094 `Makefile' at build time. This file is generated by `automake'
1095 from `Makefile.am'. If you aren't using automake, you must write
1096 this file yourself. This file is pretty much a normal `Makefile',
1097 with some configure substitutions for certain variables.
1100 This file is created by the `aclocal' program, based on the
1101 contents of `configure.in' and `acinclude.m4' (or, as noted in the
1102 description of `acinclude.m4' above, on the contents of an `m4'
1103 subdirectory). This file contains definitions of autoconf macros
1104 which `autoconf' will use when generating the file `configure'.
1105 These autoconf macros may be defined by you in `acinclude.m4' or
1106 they may be defined by other packages such as automake, libtool or
1107 gettext. If you aren't using automake, you will normally write
1108 this file yourself; in that case, if `configure.in' uses only
1109 standard autoconf macros, this file will not be needed at all.
1112 This file is created by `autoheader' based on `acconfig.h' and
1113 `configure.in'. At build time, the configure script will define
1114 some of the macros in it to create `config.h', which may then be
1115 included by your program. This permits your C code to use
1116 preprocessor conditionals to change its behaviour based on the
1117 characteristics of the host system. This file may also be called
1121 This rather uninteresting file, which I omitted from the picture,
1122 is generated by `automake'. It always contains the string
1123 `timestamp'. It is used as a timestamp file indicating whether
1124 `config.in' is up to date. Using a timestamp file means that
1125 `config.in' can be marked as up to date without actually changing
1126 its modification time. This is useful since `config.in' depends
1127 upon `configure.in', but it is easy to change `configure.in' in a
1128 way which does not affect `config.in'.
1131 File: configure.info, Node: Build Files, Next: Support Files, Prev: Developer Files, Up: Files
1136 This section describes the files which are created at configure and
1137 build time. These are the files which somebody who builds the package
1140 Of course, the developer will also build the package. The
1141 distinction between developer files and build files is not that the
1142 developer does not see the build files, but that somebody who only
1143 builds the package does not have to worry about the developer files.
1147 * Build Files Picture:: Build Files Picture.
1148 * Build Files Description:: Build Files Description.
1151 File: configure.info, Node: Build Files Picture, Next: Build Files Description, Up: Build Files
1156 Here is a picture of the files which will be created at build time.
1157 `config.status' is both a created file and a shell script which is run
1158 to create other files, and the picture attempts to show that.
1160 config.in *configure* Makefile.in
1165 *config.status*<======+==========>*config.status*
1171 File: configure.info, Node: Build Files Description, Prev: Build Files Picture, Up: Build Files
1173 Build Files Description
1174 -----------------------
1176 This is a description of the files which are created at build time.
1179 The first step in building a package is to run the `configure'
1180 script. The `configure' script will create the file
1181 `config.status', which is itself a shell script. When you first
1182 run `configure', it will automatically run `config.status'. An
1183 `Makefile' derived from an automake generated `Makefile.in' will
1184 contain rules to automatically run `config.status' again when
1185 necessary to recreate certain files if their inputs change.
1188 This is the file which make will read to build the program. The
1189 `config.status' script will transform `Makefile.in' into
1193 This file defines C preprocessor macros which C code can use to
1194 adjust its behaviour on different systems. The `config.status'
1195 script will transform `config.in' into `config.h'.
1198 This file did not fit neatly into the picture, and I omitted it.
1199 It is used by the `configure' script to cache results between
1200 runs. This can be an important speedup. If you modify
1201 `configure.in' in such a way that the results of old tests should
1202 change (perhaps you have added a new library to `LDFLAGS'), then
1203 you will have to remove `config.cache' to force the tests to be
1206 The autoconf manual explains how to set up a site specific cache
1207 file. This can speed up running `configure' scripts on your
1211 This file, which I omitted from the picture, is similar to
1212 `stamp-h.in'. It is used as a timestamp file indicating whether
1213 `config.h' is up to date. This is useful since `config.h' depends
1214 upon `config.status', but it is easy for `config.status' to change
1215 in a way which does not affect `config.h'.
1218 File: configure.info, Node: Support Files, Prev: Build Files, Up: Files
1223 The GNU configure and build system requires several support files to
1224 be included with your distribution. You do not normally need to concern
1225 yourself with these. If you are using the Cygnus tree, most are already
1226 present. Otherwise, they will be installed with your source by
1227 `automake' (with the `--add-missing' option) and `libtoolize'.
1229 You don't have to put the support files in the top level directory.
1230 You can put them in a subdirectory, and use the `AC_CONFIG_AUX_DIR'
1231 macro in `configure.in' to tell `automake' and the `configure' script
1234 In this section, I describe the support files, so that you can know
1235 what they are and why they are there.
1238 Added by automake if you are using gettext. This is a
1239 documentation file about the gettext project.
1242 Used by an automake generated `Makefile' if you put `ansi2knr' in
1243 `AUTOMAKE_OPTIONS' in `Makefile.am'. This permits compiling ANSI
1244 C code with a K&R C compiler.
1247 The man page which goes with `ansi2knr.c'.
1250 A shell script which determines the configuration name for the
1251 system on which it is run.
1254 A shell script which canonicalizes a configuration name entered by
1258 Used to compile Emacs LISP files.
1261 A shell script which installs a program. This is used if the
1262 configure script can not find an install binary.
1265 Used by libtool. This is a shell script which configures libtool
1266 for the particular system on which it is used.
1269 Used by libtool. This is the actual libtool script which is used,
1270 after it is configured by `ltconfig' to build a library.
1273 A shell script used by an automake generated `Makefile' to pretty
1274 print the modification time of a file. This is used to maintain
1275 version numbers for texinfo files.
1278 A shell script used if some tool is missing entirely. This is
1279 used by an automake generated `Makefile' to avoid certain sorts of
1283 A shell script which creates a directory, including all parent
1284 directories. This is used by an automake generated `Makefile'
1285 during installation.
1288 Required if you have any texinfo files. This is used when
1289 converting Texinfo files into DVI using `texi2dvi' and TeX.
1292 A shell script used by an automake generated `Makefile' to run
1293 programs like `bison', `yacc', `flex', and `lex'. These programs
1294 default to producing output files with a fixed name, and the
1295 `ylwrap' script runs them in a subdirectory to avoid file name
1296 conflicts when using a parallel make program.
1299 File: configure.info, Node: Configuration Names, Next: Cross Compilation Tools, Prev: Files, Up: Top
1304 The GNU configure system names all systems using a "configuration
1305 name". All such names used to be triplets (they may now contain four
1306 parts in certain cases), and the term "configuration triplet" is still
1311 * Configuration Name Definition:: Configuration Name Definition.
1312 * Using Configuration Names:: Using Configuration Names.
1315 File: configure.info, Node: Configuration Name Definition, Next: Using Configuration Names, Up: Configuration Names
1317 Configuration Name Definition
1318 =============================
1320 This is a string of the form CPU-MANUFACTURER-OPERATING_SYSTEM. In
1321 some cases, this is extended to a four part form:
1322 CPU-MANUFACTURER-KERNEL-OPERATING_SYSTEM.
1324 When using a configuration name in a configure option, it is normally
1325 not necessary to specify an entire name. In particular, the
1326 MANUFACTURER field is often omitted, leading to strings such as
1327 `i386-linux' or `sparc-sunos'. The shell script `config.sub' will
1328 translate these shortened strings into the canonical form. autoconf
1329 will arrange for `config.sub' to be run automatically when it is needed.
1331 The fields of a configuration name are as follows:
1334 The type of processor. This is typically something like `i386' or
1335 `sparc'. More specific variants are used as well, such as
1336 `mipsel' to indicate a little endian MIPS processor.
1339 A somewhat freeform field which indicates the manufacturer of the
1340 system. This is often simply `unknown'. Other common strings are
1341 `pc' for an IBM PC compatible system, or the name of a workstation
1342 vendor, such as `sun'.
1345 The name of the operating system which is run on the system. This
1346 will be something like `solaris2.5' or `irix6.3'. There is no
1347 particular restriction on the version number, and strings like
1348 `aix4.1.4.0' are seen. For an embedded system, which has no
1349 operating system, this field normally indicates the type of object
1350 file format, such as `elf' or `coff'.
1353 This is used mainly for GNU/Linux. A typical GNU/Linux
1354 configuration name is `i586-pc-linux-gnulibc1'. In this case the
1355 kernel, `linux', is separated from the operating system,
1358 The shell script `config.guess' will normally print the correct
1359 configuration name for the system on which it is run. It does by
1360 running `uname' and by examining other characteristics of the system.
1362 Because `config.guess' can normally determine the configuration name
1363 for a machine, it is normally only necessary to specify a configuration
1364 name when building a cross-compiler or when building using a
1368 File: configure.info, Node: Using Configuration Names, Prev: Configuration Name Definition, Up: Configuration Names
1370 Using Configuration Names
1371 =========================
1373 A configure script will sometimes have to make a decision based on a
1374 configuration name. You will need to do this if you have to compile
1375 code differently based on something which can not be tested using a
1376 standard autoconf feature test.
1378 It is normally better to test for particular features, rather than to
1379 test for a particular system. This is because as Unix evolves,
1380 different systems copy features from one another. Even if you need to
1381 determine whether the feature is supported based on a configuration
1382 name, you should define a macro which describes the feature, rather than
1383 defining a macro which describes the particular system you are on.
1385 Testing for a particular system is normally done using a case
1386 statement in `configure.in'. The case statement might look something
1387 like the following, assuming that `host' is a shell variable holding a
1388 canonical configuration name (which will be the case if `configure.in'
1389 uses the `AC_CANONICAL_HOST' or `AC_CANONICAL_SYSTEM' macro).
1392 i[3-7]86-*-linux-gnu*) do something ;;
1393 sparc*-sun-solaris2.[56789]*) do something ;;
1394 sparc*-sun-solaris*) do something ;;
1395 mips*-*-elf*) do something ;;
1398 It is particularly important to use `*' after the operating system
1399 field, in order to match the version number which will be generated by
1402 In most cases you must be careful to match a range of processor
1403 types. For most processor families, a trailing `*' suffices, as in
1404 `mips*' above. For the i386 family, something along the lines of
1405 `i[3-7]86' suffices at present. For the m68k family, you will need
1406 something like `m68*'. Of course, if you do not need to match on the
1407 processor, it is simpler to just replace the entire field by a `*', as
1411 File: configure.info, Node: Cross Compilation Tools, Next: Canadian Cross, Prev: Configuration Names, Up: Top
1413 Cross Compilation Tools
1414 ***********************
1416 The GNU configure and build system can be used to build "cross
1417 compilation" tools. A cross compilation tool is a tool which runs on
1418 one system and produces code which runs on another system.
1422 * Cross Compilation Concepts:: Cross Compilation Concepts.
1423 * Host and Target:: Host and Target.
1424 * Using the Host Type:: Using the Host Type.
1425 * Specifying the Target:: Specifying the Target.
1426 * Using the Target Type:: Using the Target Type.
1427 * Cross Tools in the Cygnus Tree:: Cross Tools in the Cygnus Tree
1430 File: configure.info, Node: Cross Compilation Concepts, Next: Host and Target, Up: Cross Compilation Tools
1432 Cross Compilation Concepts
1433 ==========================
1435 A compiler which produces programs which run on a different system
1436 is a cross compilation compiler, or simply a "cross compiler".
1437 Similarly, we speak of cross assemblers, cross linkers, etc.
1439 In the normal case, a compiler produces code which runs on the same
1440 system as the one on which the compiler runs. When it is necessary to
1441 distinguish this case from the cross compilation case, such a compiler
1442 is called a "native compiler". Similarly, we speak of native
1445 Although the debugger is not strictly speaking a compilation tool,
1446 it is nevertheless meaningful to speak of a cross debugger: a debugger
1447 which is used to debug code which runs on another system. Everything
1448 that is said below about configuring cross compilation tools applies to
1449 the debugger as well.
1452 File: configure.info, Node: Host and Target, Next: Using the Host Type, Prev: Cross Compilation Concepts, Up: Cross Compilation Tools
1457 When building cross compilation tools, there are two different
1458 systems involved: the system on which the tools will run, and the
1459 system for which the tools generate code.
1461 The system on which the tools will run is called the "host" system.
1463 The system for which the tools generate code is called the "target"
1466 For example, suppose you have a compiler which runs on a GNU/Linux
1467 system and generates ELF programs for a MIPS embedded system. In this
1468 case the GNU/Linux system is the host, and the MIPS ELF system is the
1469 target. Such a compiler could be called a GNU/Linux cross MIPS ELF
1470 compiler, or, equivalently, a `i386-linux-gnu' cross `mips-elf'
1473 Naturally, most programs are not cross compilation tools. For those
1474 programs, it does not make sense to speak of a target. It only makes
1475 sense to speak of a target for tools like `gcc' or the `binutils' which
1476 actually produce running code. For example, it does not make sense to
1477 speak of the target of a tool like `bison' or `make'.
1479 Most cross compilation tools can also serve as native tools. For a
1480 native compilation tool, it is still meaningful to speak of a target.
1481 For a native tool, the target is the same as the host. For example, for
1482 a GNU/Linux native compiler, the host is GNU/Linux, and the target is
1486 File: configure.info, Node: Using the Host Type, Next: Specifying the Target, Prev: Host and Target, Up: Cross Compilation Tools
1491 In almost all cases the host system is the system on which you run
1492 the `configure' script, and on which you build the tools (for the case
1493 when they differ, *note Canadian Cross::).
1495 If your configure script needs to know the configuration name of the
1496 host system, and the package is not a cross compilation tool and
1497 therefore does not have a target, put `AC_CANONICAL_HOST' in
1498 `configure.in'. This macro will arrange to define a few shell
1499 variables when the `configure' script is run.
1502 The canonical configuration name of the host. This will normally
1503 be determined by running the `config.guess' shell script, although
1504 the user is permitted to override this by using an explicit
1508 In the unusual case that the user used an explicit `--host' option,
1509 this will be the argument to `--host'. In the normal case, this
1510 will be the same as the `host' variable.
1515 The first three parts of the canonical configuration name.
1517 The shell variables may be used by putting shell code in
1518 `configure.in'. For an example, see *Note Using Configuration Names::.
1521 File: configure.info, Node: Specifying the Target, Next: Using the Target Type, Prev: Using the Host Type, Up: Cross Compilation Tools
1523 Specifying the Target
1524 =====================
1526 By default, the `configure' script will assume that the target is
1527 the same as the host. This is the more common case; for example, it
1528 leads to a native compiler rather than a cross compiler.
1530 If you want to build a cross compilation tool, you must specify the
1531 target explicitly by using the `--target' option when you run
1532 `configure'. The argument to `--target' is the configuration name of
1533 the system for which you wish to generate code. *Note Configuration
1536 For example, to build tools which generate code for a MIPS ELF
1537 embedded system, you would use `--target mips-elf'.
1540 File: configure.info, Node: Using the Target Type, Next: Cross Tools in the Cygnus Tree, Prev: Specifying the Target, Up: Cross Compilation Tools
1542 Using the Target Type
1543 =====================
1545 When writing `configure.in' for a cross compilation tool, you will
1546 need to use information about the target. To do this, put
1547 `AC_CANONICAL_SYSTEM' in `configure.in'.
1549 `AC_CANONICAL_SYSTEM' will look for a `--target' option and
1550 canonicalize it using the `config.sub' shell script. It will also run
1551 `AC_CANONICAL_HOST' (*note Using the Host Type::).
1553 The target type will be recorded in the following shell variables.
1554 Note that the host versions of these variables will also be defined by
1555 `AC_CANONICAL_HOST'.
1558 The canonical configuration name of the target.
1561 The argument to the `--target' option. If the user did not specify
1562 a `--target' option, this will be the same as `host_alias'.
1567 The first three parts of the canonical target configuration name.
1569 Note that if `host' and `target' are the same string, you can assume
1570 a native configuration. If they are different, you can assume a cross
1573 It is arguably possible for `host' and `target' to represent the
1574 same system, but for the strings to not be identical. For example, if
1575 `config.guess' returns `sparc-sun-sunos4.1.4', and somebody configures
1576 with `--target sparc-sun-sunos4.1', then the slight differences between
1577 the two versions of SunOS may be unimportant for your tool. However,
1578 in the general case it can be quite difficult to determine whether the
1579 differences between two configuration names are significant or not.
1580 Therefore, by convention, if the user specifies a `--target' option
1581 without specifying a `--host' option, it is assumed that the user wants
1582 to configure a cross compilation tool.
1584 The variables `target' and `target_alias' should be handled
1587 In general, whenever the user may actually see a string,
1588 `target_alias' should be used. This includes anything which may appear
1589 in the file system, such as a directory name or part of a tool name.
1590 It also includes any tool output, unless it is clearly labelled as the
1591 canonical target configuration name. This permits the user to use the
1592 `--target' option to specify how the tool will appear to the outside
1595 On the other hand, when checking for characteristics of the target
1596 system, `target' should be used. This is because a wide variety of
1597 `--target' options may map into the same canonical configuration name.
1598 You should not attempt to duplicate the canonicalization done by
1599 `config.sub' in your own code.
1601 By convention, cross tools are installed with a prefix of the
1602 argument used with the `--target' option, also known as `target_alias'
1603 (*note Using the Target Type::). If the user does not use the
1604 `--target' option, and thus is building a native tool, no prefix is
1607 For example, if gcc is configured with `--target mips-elf', then the
1608 installed binary will be named `mips-elf-gcc'. If gcc is configured
1609 without a `--target' option, then the installed binary will be named
1612 The autoconf macro `AC_ARG_PROGRAM' will handle this for you. If
1613 you are using automake, no more need be done; the programs will
1614 automatically be installed with the correct prefixes. Otherwise, see
1615 the autoconf documentation for `AC_ARG_PROGRAM'.
1618 File: configure.info, Node: Cross Tools in the Cygnus Tree, Prev: Using the Target Type, Up: Cross Compilation Tools
1620 Cross Tools in the Cygnus Tree
1621 ==============================
1623 The Cygnus tree is used for various packages including gdb, the GNU
1624 binutils, and egcs. It is also, of course, used for Cygnus releases.
1626 In the Cygnus tree, the top level `configure' script uses the old
1627 Cygnus configure system, not autoconf. The top level `Makefile.in' is
1628 written to build packages based on what is in the source tree, and
1629 supports building a large number of tools in a single
1630 `configure'/`make' step.
1632 The Cygnus tree may be configured with a `--target' option. The
1633 `--target' option applies recursively to every subdirectory, and
1634 permits building an entire set of cross tools at once.
1638 * Host and Target Libraries:: Host and Target Libraries.
1639 * Target Library Configure Scripts:: Target Library Configure Scripts.
1640 * Make Targets in Cygnus Tree:: Make Targets in Cygnus Tree.
1641 * Target libiberty:: Target libiberty
1644 File: configure.info, Node: Host and Target Libraries, Next: Target Library Configure Scripts, Up: Cross Tools in the Cygnus Tree
1646 Host and Target Libraries
1647 -------------------------
1649 The Cygnus tree distinguishes host libraries from target libraries.
1651 Host libraries are built with the compiler used to build the programs
1652 which run on the host, which is called the host compiler. This includes
1653 libraries such as `bfd' and `tcl'. These libraries are built with the
1654 host compiler, and are linked into programs like the binutils or gcc
1655 which run on the host.
1657 Target libraries are built with the target compiler. If gcc is
1658 present in the source tree, then the target compiler is the gcc that is
1659 built using the host compiler. Target libraries are libraries such as
1660 `newlib' and `libstdc++'. These libraries are not linked into the host
1661 programs, but are instead made available for use with programs built
1662 with the target compiler.
1664 For the rest of this section, assume that gcc is present in the
1665 source tree, so that it will be used to build the target libraries.
1667 There is a complication here. The configure process needs to know
1668 which compiler you are going to use to build a tool; otherwise, the
1669 feature tests will not work correctly. The Cygnus tree handles this by
1670 not configuring the target libraries until the target compiler is
1671 built. In order to permit everything to build using a single
1672 `configure'/`make', the configuration of the target libraries is
1673 actually triggered during the make step.
1675 When the target libraries are configured, the `--target' option is
1676 not used. Instead, the `--host' option is used with the argument of
1677 the `--target' option for the overall configuration. If no `--target'
1678 option was used for the overall configuration, the `--host' option will
1679 be passed with the output of the `config.guess' shell script. Any
1680 `--build' option is passed down unchanged.
1682 This translation of configuration options is done because since the
1683 target libraries are compiled with the target compiler, they are being
1684 built in order to run on the target of the overall configuration. By
1685 the definition of host, this means that their host system is the same as
1686 the target system of the overall configuration.
1688 The same process is used for both a native configuration and a cross
1689 configuration. Even when using a native configuration, the target
1690 libraries will be configured and built using the newly built compiler.
1691 This is particularly important for the C++ libraries, since there is no
1692 reason to assume that the C++ compiler used to build the host tools (if
1693 there even is one) uses the same ABI as the g++ compiler which will be
1694 used to build the target libraries.
1696 There is one difference between a native configuration and a cross
1697 configuration. In a native configuration, the target libraries are
1698 normally configured and built as siblings of the host tools. In a cross
1699 configuration, the target libraries are normally built in a subdirectory
1700 whose name is the argument to `--target'. This is mainly for
1703 To summarize, running `configure' in the Cygnus tree configures all
1704 the host libraries and tools, but does not configure any of the target
1705 libraries. Running `make' then does the following steps:
1707 * Build the host libraries.
1709 * Build the host programs, including gcc. Note that we call gcc
1710 both a host program (since it runs on the host) and a target
1711 compiler (since it generates code for the target).
1713 * Using the newly built target compiler, configure the target
1716 * Build the target libraries.
1718 The steps need not be done in precisely this order, since they are
1719 actually controlled by `Makefile' targets.
1722 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
1724 Target Library Configure Scripts
1725 --------------------------------
1727 There are a few things you must know in order to write a configure
1728 script for a target library. This is just a quick sketch, and beginners
1729 shouldn't worry if they don't follow everything here.
1731 The target libraries are configured and built using a newly built
1732 target compiler. There may not be any startup files or libraries for
1733 this target compiler. In fact, those files will probably be built as
1734 part of some target library, which naturally means that they will not
1735 exist when your target library is configured.
1737 This means that the configure script for a target library may not use
1738 any test which requires doing a link. This unfortunately includes many
1739 useful autoconf macros, such as `AC_CHECK_FUNCS'. autoconf macros
1740 which do a compile but not a link, such as `AC_CHECK_HEADERS', may be
1743 This is a severe restriction, but normally not a fatal one, as target
1744 libraries can often assume the presence of other target libraries, and
1745 thus know which functions will be available.
1747 As of this writing, the autoconf macro `AC_PROG_CC' does a link to
1748 make sure that the compiler works. This may fail in a target library,
1749 so target libraries must use a different set of macros to locate the
1750 compiler. See the `configure.in' file in a directory like `libiberty'
1751 or `libgloss' for an example.
1753 As noted in the previous section, target libraries are sometimes
1754 built in directories which are siblings to the host tools, and are
1755 sometimes built in a subdirectory. The `--with-target-subdir' configure
1756 option will be passed when the library is configured. Its value will be
1757 an empty string if the target library is a sibling. Its value will be
1758 the name of the subdirectory if the target library is in a subdirectory.
1760 If the overall build is not a native build (i.e., the overall
1761 configure used the `--target' option), then the library will be
1762 configured with the `--with-cross-host' option. The value of this
1763 option will be the host system of the overall build. Recall that the
1764 host system of the library will be the target of the overall build. If
1765 the overall build is a native build, the `--with-cross-host' option
1768 A library which can be built both standalone and as a target library
1769 may want to install itself into different directories depending upon the
1770 case. When built standalone, or when built native, the library should
1771 be installed in `$(libdir)'. When built as a target library which is
1772 not native, the library should be installed in `$(tooldir)/lib'. The
1773 `--with-cross-host' option may be used to distinguish these cases.
1775 This same test of `--with-cross-host' may be used to see whether it
1776 is OK to use link tests in the configure script. If the
1777 `--with-cross-host' option is not used, then the library is being built
1778 either standalone or native, and a link should work.
1781 File: configure.info, Node: Make Targets in Cygnus Tree, Next: Target libiberty, Prev: Target Library Configure Scripts, Up: Cross Tools in the Cygnus Tree
1783 Make Targets in Cygnus Tree
1784 ---------------------------
1786 The top level `Makefile' in the Cygnus tree defines targets for
1787 every known subdirectory.
1789 For every subdirectory DIR which holds a host library or program,
1790 the `Makefile' target `all-DIR' will build that library or program.
1792 There are dependencies among host tools. For example, building gcc
1793 requires first building gas, because the gcc build process invokes the
1794 target assembler. These dependencies are reflected in the top level
1797 For every subdirectory DIR which holds a target library, the
1798 `Makefile' target `configure-target-DIR' will configure that library.
1799 The `Makefile' target `all-target-DIR' will build that library.
1801 Every `configure-target-DIR' target depends upon `all-gcc', since
1802 gcc, the target compiler, is required to configure the tool. Every
1803 `all-target-DIR' target depends upon the corresponding
1804 `configure-target-DIR' target.
1806 There are several other targets which may be of interest for each
1807 directory: `install-DIR', `clean-DIR', and `check-DIR'. There are also
1808 corresponding `target' versions of these for the target libraries ,
1809 such as `install-target-DIR'.
1812 File: configure.info, Node: Target libiberty, Prev: Make Targets in Cygnus Tree, Up: Cross Tools in the Cygnus Tree
1817 The `libiberty' subdirectory is currently a special case, in that it
1818 is the only directory which is built both using the host compiler and
1819 using the target compiler.
1821 This is because the files in `libiberty' are used when building the
1822 host tools, and they are also incorporated into the `libstdc++' target
1823 library as support code.
1825 This duality does not pose any particular difficulties. It means
1826 that there are targets for both `all-libiberty' and
1827 `all-target-libiberty'.
1829 In a native configuration, when target libraries are not built in a
1830 subdirectory, the same objects are normally used as both the host build
1831 and the target build. This is normally OK, since libiberty contains
1832 only C code, and in a native configuration the results of the host
1833 compiler and the target compiler are normally interoperable.
1835 Irix 6 is again an exception here, since the SGI native compiler
1836 defaults to using the `O32' ABI, and gcc defaults to using the `N32'
1837 ABI. On Irix 6, the target libraries are built in a subdirectory even
1838 for a native configuration, avoiding this problem.
1840 There are currently no other libraries built for both the host and
1841 the target, but there is no conceptual problem with adding more.
1844 File: configure.info, Node: Canadian Cross, Next: Cygnus Configure, Prev: Cross Compilation Tools, Up: Top
1849 It is possible to use the GNU configure and build system to build a
1850 program which will run on a system which is different from the system on
1851 which the tools are built. In other words, it is possible to build
1852 programs using a cross compiler.
1854 This is referred to as a "Canadian Cross".
1858 * Canadian Cross Example:: Canadian Cross Example.
1859 * Canadian Cross Concepts:: Canadian Cross Concepts.
1860 * Build Cross Host Tools:: Build Cross Host Tools.
1861 * Build and Host Options:: Build and Host Options.
1862 * CCross not in Cygnus Tree:: Canadian Cross not in Cygnus Tree.
1863 * CCross in Cygnus Tree:: Canadian Cross in Cygnus Tree.
1864 * Supporting Canadian Cross:: Supporting Canadian Cross.
1867 File: configure.info, Node: Canadian Cross Example, Next: Canadian Cross Concepts, Up: Canadian Cross
1869 Canadian Cross Example
1870 ======================
1872 Here is an example of a Canadian Cross.
1874 While running on a GNU/Linux, you can build a program which will run
1875 on a Solaris system. You would use a GNU/Linux cross Solaris compiler
1876 to build the program.
1878 Of course, you could not run the resulting program on your GNU/Linux
1879 system. You would have to copy it over to a Solaris system before you
1882 Of course, you could also simply build the programs on the Solaris
1883 system in the first place. However, perhaps the Solaris system is not
1884 available for some reason; perhaps you actually don't have one, but you
1885 want to build the tools for somebody else to use. Or perhaps your
1886 GNU/Linux system is much faster than your Solaris system.
1888 A Canadian Cross build is most frequently used when building
1889 programs to run on a non-Unix system, such as DOS or Windows. It may
1890 be simpler to configure and build on a Unix system than to support the
1891 configuration machinery on a non-Unix system.
1894 File: configure.info, Node: Canadian Cross Concepts, Next: Build Cross Host Tools, Prev: Canadian Cross Example, Up: Canadian Cross
1896 Canadian Cross Concepts
1897 =======================
1899 When building a Canadian Cross, there are at least two different
1900 systems involved: the system on which the tools are being built, and
1901 the system on which the tools will run.
1903 The system on which the tools are being built is called the "build"
1906 The system on which the tools will run is called the host system.
1908 For example, if you are building a Solaris program on a GNU/Linux
1909 system, as in the previous section, the build system would be GNU/Linux,
1910 and the host system would be Solaris.
1912 It is, of course, possible to build a cross compiler using a Canadian
1913 Cross (i.e., build a cross compiler using a cross compiler). In this
1914 case, the system for which the resulting cross compiler generates code
1915 is called the target system. (For a more complete discussion of host
1916 and target systems, *note Host and Target::).
1918 An example of building a cross compiler using a Canadian Cross would
1919 be building a Windows cross MIPS ELF compiler on a GNU/Linux system. In
1920 this case the build system would be GNU/Linux, the host system would be
1921 Windows, and the target system would be MIPS ELF.
1923 The name Canadian Cross comes from the case when the build, host, and
1924 target systems are all different. At the time that these issues were
1925 all being hashed out, Canada had three national political parties.
1928 File: configure.info, Node: Build Cross Host Tools, Next: Build and Host Options, Prev: Canadian Cross Concepts, Up: Canadian Cross
1930 Build Cross Host Tools
1931 ======================
1933 In order to configure a program for a Canadian Cross build, you must
1934 first build and install the set of cross tools you will use to build the
1937 These tools will be build cross host tools. That is, they will run
1938 on the build system, and will produce code that runs on the host system.
1940 It is easy to confuse the meaning of build and host here. Always
1941 remember that the build system is where you are doing the build, and the
1942 host system is where the resulting program will run. Therefore, you
1943 need a build cross host compiler.
1945 In general, you must have a complete cross environment in order to do
1946 the build. This normally means a cross compiler, cross assembler, and
1947 so forth, as well as libraries and include files for the host system.
1950 File: configure.info, Node: Build and Host Options, Next: CCross not in Cygnus Tree, Prev: Build Cross Host Tools, Up: Canadian Cross
1952 Build and Host Options
1953 ======================
1955 When you run `configure', you must use both the `--build' and
1958 The `--build' option is used to specify the configuration name of
1959 the build system. This can normally be the result of running the
1960 `config.guess' shell script, and it is reasonable to use
1961 `--build=`config.guess`'.
1963 The `--host' option is used to specify the configuration name of the
1966 As we explained earlier, `config.guess' is used to set the default
1967 value for the `--host' option (*note Using the Host Type::). We can
1968 now see that since `config.guess' returns the type of system on which
1969 it is run, it really identifies the build system. Since the host
1970 system is normally the same as the build system (i.e., people do not
1971 normally build using a cross compiler), it is reasonable to use the
1972 result of `config.guess' as the default for the host system when the
1973 `--host' option is not used.
1975 It might seem that if the `--host' option were used without the
1976 `--build' option that the configure script could run `config.guess' to
1977 determine the build system, and presume a Canadian Cross if the result
1978 of `config.guess' differed from the `--host' option. However, for
1979 historical reasons, some configure scripts are routinely run using an
1980 explicit `--host' option, rather than using the default from
1981 `config.guess'. As noted earlier, it is difficult or impossible to
1982 reliably compare configuration names (*note Using the Target Type::).
1983 Therefore, by convention, if the `--host' option is used, but the
1984 `--build' option is not used, then the build system defaults to the
1988 File: configure.info, Node: CCross not in Cygnus Tree, Next: CCross in Cygnus Tree, Prev: Build and Host Options, Up: Canadian Cross
1990 Canadian Cross not in Cygnus Tree.
1991 ==================================
1993 If you are not using the Cygnus tree, you must explicitly specify the
1994 cross tools which you want to use to build the program. This is done by
1995 setting environment variables before running the `configure' script.
1997 You must normally set at least the environment variables `CC', `AR',
1998 and `RANLIB' to the cross tools which you want to use to build.
2000 For some programs, you must set additional cross tools as well, such
2001 as `AS', `LD', or `NM'.
2003 You would set these environment variables to the build cross tools
2004 which you are going to use.
2006 For example, if you are building a Solaris program on a GNU/Linux
2007 system, and your GNU/Linux cross Solaris compiler were named
2008 `solaris-gcc', then you would set the environment variable `CC' to
2012 File: configure.info, Node: CCross in Cygnus Tree, Next: Supporting Canadian Cross, Prev: CCross not in Cygnus Tree, Up: Canadian Cross
2014 Canadian Cross in Cygnus Tree
2015 =============================
2017 This section describes configuring and building a Canadian Cross when
2018 using the Cygnus tree.
2022 * Standard Cygnus CCross:: Building a Normal Program.
2023 * Cross Cygnus CCross:: Building a Cross Program.
2026 File: configure.info, Node: Standard Cygnus CCross, Next: Cross Cygnus CCross, Up: CCross in Cygnus Tree
2028 Building a Normal Program
2029 -------------------------
2031 When configuring a Canadian Cross in the Cygnus tree, all the
2032 appropriate environment variables are automatically set to `HOST-TOOL',
2033 where HOST is the value used for the `--host' option, and TOOL is the
2034 name of the tool (e.g., `gcc', `as', etc.). These tools must be on
2037 Adding a prefix of HOST will give the usual name for the build cross
2038 host tools. To see this, consider that when these cross tools were
2039 built, they were configured to run on the build system and to produce
2040 code for the host system. That is, they were configured with a
2041 `--target' option that is the same as the system which we are now
2042 calling the host. Recall that the default name for installed cross
2043 tools uses the target system as a prefix (*note Using the Target
2044 Type::). Since that is the system which we are now calling the host,
2045 HOST is the right prefix to use.
2047 For example, if you configure with `--build=i386-linux-gnu' and
2048 `--host=solaris', then the Cygnus tree will automatically default to
2049 using the compiler `solaris-gcc'. You must have previously built and
2050 installed this compiler, probably by doing a build with no `--host'
2051 option and with a `--target' option of `solaris'.
2054 File: configure.info, Node: Cross Cygnus CCross, Prev: Standard Cygnus CCross, Up: CCross in Cygnus Tree
2056 Building a Cross Program
2057 ------------------------
2059 There are additional considerations if you want to build a cross
2060 compiler, rather than a native compiler, in the Cygnus tree using a
2063 When you build a cross compiler using the Cygnus tree, then the
2064 target libraries will normally be built with the newly built target
2065 compiler (*note Host and Target Libraries::). However, this will not
2066 work when building with a Canadian Cross. This is because the newly
2067 built target compiler will be a program which runs on the host system,
2068 and therefore will not be able to run on the build system.
2070 Therefore, when building a cross compiler with the Cygnus tree, you
2071 must first install a set of build cross target tools. These tools will
2072 be used when building the target libraries.
2074 Note that this is not a requirement of a Canadian Cross in general.
2075 For example, it would be possible to build just the host cross target
2076 tools on the build system, to copy the tools to the host system, and to
2077 build the target libraries on the host system. The requirement for
2078 build cross target tools is imposed by the Cygnus tree, which expects
2079 to be able to build both host programs and target libraries in a single
2080 `configure'/`make' step. Because it builds these in a single step, it
2081 expects to be able to build the target libraries on the build system,
2082 which means that it must use a build cross target toolchain.
2084 For example, suppose you want to build a Windows cross MIPS ELF
2085 compiler on a GNU/Linux system. You must have previously installed
2086 both a GNU/Linux cross Windows compiler and a GNU/Linux cross MIPS ELF
2089 In order to build the Windows (configuration name `i386-cygwin32')
2090 cross MIPS ELF (configure name `mips-elf') compiler, you might execute
2091 the following commands (long command lines are broken across lines with
2092 a trailing backslash as a continuation character).
2094 mkdir linux-x-cygwin32
2096 SRCDIR/configure --target i386-cygwin32 --prefix=INSTALLDIR \
2097 --exec-prefix=INSTALLDIR/H-i386-linux
2101 mkdir linux-x-mips-elf
2103 SRCDIR/configure --target mips-elf --prefix=INSTALLDIR \
2104 --exec-prefix=INSTALLDIR/H-i386-linux
2108 mkdir cygwin32-x-mips-elf
2109 cd cygwin32-x-mips-elf
2110 SRCDIR/configure --build=i386-linux-gnu --host=i386-cygwin32 \
2111 --target=mips-elf --prefix=WININSTALLDIR \
2112 --exec-prefix=WININSTALLDIR/H-i386-cygwin32
2116 You would then copy the contents of WININSTALLDIR over to the
2117 Windows machine, and run the resulting programs.
2120 File: configure.info, Node: Supporting Canadian Cross, Prev: CCross in Cygnus Tree, Up: Canadian Cross
2122 Supporting Canadian Cross
2123 =========================
2125 If you want to make it possible to build a program you are developing
2126 using a Canadian Cross, you must take some care when writing your
2127 configure and make rules. Simple cases will normally work correctly.
2128 However, it is not hard to write configure and make tests which will
2129 fail in a Canadian Cross.
2133 * CCross in Configure:: Supporting Canadian Cross in Configure Scripts.
2134 * CCross in Make:: Supporting Canadian Cross in Makefiles.
2137 File: configure.info, Node: CCross in Configure, Next: CCross in Make, Up: Supporting Canadian Cross
2139 Supporting Canadian Cross in Configure Scripts
2140 ----------------------------------------------
2142 In a `configure.in' file, after calling `AC_PROG_CC', you can find
2143 out whether this is a Canadian Cross configure by examining the shell
2144 variable `cross_compiling'. In a Canadian Cross, which means that the
2145 compiler is a cross compiler, `cross_compiling' will be `yes'. In a
2146 normal configuration, `cross_compiling' will be `no'.
2148 You ordinarily do not need to know the type of the build system in a
2149 configure script. However, if you do need that information, you can get
2150 it by using the macro `AC_CANONICAL_SYSTEM', the same macro that is
2151 used to determine the target system. This macro will set the variables
2152 `build', `build_alias', `build_cpu', `build_vendor', and `build_os',
2153 which correspond to the similar `target' and `host' variables, except
2154 that they describe the build system.
2156 When writing tests in `configure.in', you must remember that you
2157 want to test the host environment, not the build environment.
2159 Macros like `AC_CHECK_FUNCS' which use the compiler will test the
2160 host environment. That is because the tests will be done by running the
2161 compiler, which is actually a build cross host compiler. If the
2162 compiler can find the function, that means that the function is present
2163 in the host environment.
2165 Tests like `test -f /dev/ptyp0', on the other hand, will test the
2166 build environment. Remember that the configure script is running on the
2167 build system, not the host system. If your configure scripts examines
2168 files, those files will be on the build system. Whatever you determine
2169 based on those files may or may not be the case on the host system.
2171 Most autoconf macros will work correctly for a Canadian Cross. The
2172 main exception is `AC_TRY_RUN'. This macro tries to compile and run a
2173 test program. This will fail in a Canadian Cross, because the program
2174 will be compiled for the host system, which means that it will not run
2175 on the build system.
2177 The `AC_TRY_RUN' macro provides an optional argument to tell the
2178 configure script what to do in a Canadian Cross. If that argument is
2179 not present, you will get a warning when you run `autoconf':
2180 warning: AC_TRY_RUN called without default to allow cross compiling
2182 This tells you that the resulting `configure' script will not work with
2185 In some cases while it may better to perform a test at configure
2186 time, it is also possible to perform the test at run time. In such a
2187 case you can use the cross compiling argument to `AC_TRY_RUN' to tell
2188 your program that the test could not be performed at configure time.
2190 There are a few other autoconf macros which will not work correctly
2191 with a Canadian Cross: a partial list is `AC_FUNC_GETPGRP',
2192 `AC_FUNC_SETPGRP', `AC_FUNC_SETVBUF_REVERSED', and
2193 `AC_SYS_RESTARTABLE_SYSCALLS'. The `AC_CHECK_SIZEOF' macro is
2194 generally not very useful with a Canadian Cross; it permits an optional
2195 argument indicating the default size, but there is no way to know what
2196 the correct default should be.
2199 File: configure.info, Node: CCross in Make, Prev: CCross in Configure, Up: Supporting Canadian Cross
2201 Supporting Canadian Cross in Makefiles.
2202 ---------------------------------------
2204 The main Canadian Cross issue in a `Makefile' arises when you want
2205 to use a subsidiary program to generate code or data which you will then
2206 include in your real program.
2208 If you compile this subsidiary program using `$(CC)' in the usual
2209 way, you will not be able to run it. This is because `$(CC)' will
2210 build a program for the host system, but the program is being built on
2213 You must instead use a compiler for the build system, rather than the
2214 host system. In the Cygnus tree, this make variable `$(CC_FOR_BUILD)'
2215 will hold a compiler for the build system.
2217 Note that you should not include `config.h' in a file you are
2218 compiling with `$(CC_FOR_BUILD)'. The `configure' script will build
2219 `config.h' with information for the host system. However, you are
2220 compiling the file using a compiler for the build system (a native
2221 compiler). Subsidiary programs are normally simple filters which do no
2222 user interaction, and it is normally possible to write them in a highly
2223 portable fashion so that the absence of `config.h' is not crucial.
2225 The gcc `Makefile.in' shows a complex situation in which certain
2226 files, such as `rtl.c', must be compiled into both subsidiary programs
2227 run on the build system and into the final program. This approach may
2228 be of interest for advanced build system hackers. Note that the build
2229 system compiler is rather confusingly called `HOST_CC'.
2232 File: configure.info, Node: Cygnus Configure, Next: Multilibs, Prev: Canadian Cross, Up: Top
2237 The Cygnus configure script predates autoconf. All of its
2238 interesting features have been incorporated into autoconf. No new
2239 programs should be written to use the Cygnus configure script.
2241 However, the Cygnus configure script is still used in a few places:
2242 at the top of the Cygnus tree and in a few target libraries in the
2243 Cygnus tree. Until those uses have been replaced with autoconf, some
2244 brief notes are appropriate here. This is not complete documentation,
2245 but it should be possible to use this as a guide while examining the
2250 * Cygnus Configure Basics:: Cygnus Configure Basics.
2251 * Cygnus Configure in C++ Libraries:: Cygnus Configure in C++ Libraries.
2254 File: configure.info, Node: Cygnus Configure Basics, Next: Cygnus Configure in C++ Libraries, Up: Cygnus Configure
2256 Cygnus Configure Basics
2257 =======================
2259 Cygnus configure does not use any generated files; there is no
2260 program corresponding to `autoconf'. Instead, there is a single shell
2261 script named `configure' which may be found at the top of the Cygnus
2262 tree. This shell script was written by hand; it was not generated by
2263 autoconf, and it is incorrect, and indeed harmful, to run `autoconf' in
2264 the top level of a Cygnus tree.
2266 Cygnus configure works in a particular directory by examining the
2267 file `configure.in' in that directory. That file is broken into four
2268 separate shell scripts.
2270 The first is the contents of `configure.in' up to a line that starts
2271 with `# per-host:'. This is the common part.
2273 The second is the rest of `configure.in' up to a line that starts
2274 with `# per-target:'. This is the per host part.
2276 The third is the rest of `configure.in' up to a line that starts
2277 with `# post-target:'. This is the per target part.
2279 The fourth is the remainder of `configure.in'. This is the post
2282 If any of these comment lines are missing, the corresponding shell
2285 Cygnus configure will first execute the common part. This must set
2286 the shell variable `srctrigger' to the name of a source file, to
2287 confirm that Cygnus configure is looking at the right directory. This
2288 may set the shell variables `package_makefile_frag' and
2289 `package_makefile_rules_frag'.
2291 Cygnus configure will next set the `build' and `host' shell
2292 variables, and execute the per host part. This may set the shell
2293 variable `host_makefile_frag'.
2295 Cygnus configure will next set the `target' variable, and execute
2296 the per target part. This may set the shell variable
2297 `target_makefile_frag'.
2299 Any of these scripts may set the `subdirs' shell variable. This
2300 variable is a list of subdirectories where a `Makefile.in' file may be
2301 found. Cygnus configure will automatically look for a `Makefile.in'
2302 file in the current directory. The `subdirs' shell variable is not
2303 normally used, and I believe that the only directory which uses it at
2304 present is `newlib'.
2306 For each `Makefile.in', Cygnus configure will automatically create a
2307 `Makefile' by adding definitions for `make' variables such as `host'
2308 and `target', and automatically editing the values of `make' variables
2309 such as `prefix' if they are present.
2311 Also, if any of the `makefile_frag' shell variables are set, Cygnus
2312 configure will interpret them as file names relative to either the
2313 working directory or the source directory, and will read the contents of
2314 the file into the generated `Makefile'. The file contents will be read
2315 in after the first line in `Makefile.in' which starts with `####'.
2317 These `Makefile' fragments are used to customize behaviour for a
2318 particular host or target. They serve to select particular files to
2319 compile, and to define particular preprocessor macros by providing
2320 values for `make' variables which are then used during compilation.
2321 Cygnus configure, unlike autoconf, normally does not do feature tests,
2322 and normally requires support to be added manually for each new host.
2324 The `Makefile' fragment support is similar to the autoconf
2325 `AC_SUBST_FILE' macro.
2327 After creating each `Makefile', the post target script will be run
2328 (i.e., it may be run several times). This script may further customize
2329 the `Makefile'. When it is run, the shell variable `Makefile' will
2330 hold the name of the `Makefile', including the appropriate directory
2333 Like an autoconf generated `configure' script, Cygnus configure will
2334 create a file named `config.status' which, when run, will automatically
2335 recreate the configuration. The `config.status' file will simply
2336 execute the Cygnus configure script again with the appropriate
2339 Any of the parts of `configure.in' may set the shell variables
2340 `files' and `links'. Cygnus configure will set up symlinks from the
2341 names in `links' to the files named in `files'. This is similar to the
2342 autoconf `AC_LINK_FILES' macro.
2344 Finally, any of the parts of `configure.in' may set the shell
2345 variable `configdirs' to a set of subdirectories. If it is set, Cygnus
2346 configure will recursively run the configure process in each
2347 subdirectory. If the subdirectory uses Cygnus configure, it will
2348 contain a `configure.in' file but no `configure' file, in which case
2349 Cygnus configure will invoke itself recursively. If the subdirectory
2350 has a `configure' file, Cygnus configure assumes that it is an autoconf
2351 generated `configure' script, and simply invokes it directly.
2354 File: configure.info, Node: Cygnus Configure in C++ Libraries, Prev: Cygnus Configure Basics, Up: Cygnus Configure
2356 Cygnus Configure in C++ Libraries
2357 =================================
2359 The C++ library configure system, written by Per Bothner, deserves
2360 special mention. It uses Cygnus configure, but it does feature testing
2361 like that done by autoconf generated `configure' scripts. This
2362 approach is used in the libraries `libio', `libstdc++', and `libg++'.
2364 Most of the `Makefile' information is written out by the shell
2365 script `libio/config.shared'. Each `configure.in' file sets certain
2366 shell variables, and then invokes `config.shared' to create two package
2367 `Makefile' fragments. These fragments are then incorporated into the
2368 resulting `Makefile' by the Cygnus configure script.
2370 The file `_G_config.h' is created in the `libio' object directory by
2371 running the shell script `libio/gen-params'. This shell script uses
2372 feature tests to define macros and typedefs in `_G_config.h'.
2375 File: configure.info, Node: Multilibs, Next: FAQ, Prev: Cygnus Configure, Up: Top
2380 For some targets gcc may have different processor requirements
2381 depending upon command line options. An obvious example is the
2382 `-msoft-float' option supported on several processors. This option
2383 means that the floating point registers are not available, which means
2384 that floating point operations must be done by calling an emulation
2385 subroutine rather than by using machine instructions.
2387 For such options, gcc is often configured to compile target libraries
2388 twice: once with `-msoft-float' and once without. When gcc compiles
2389 target libraries more than once, the resulting libraries are called
2392 Multilibs are not really part of the GNU configure and build system,
2393 but we discuss them here since they require support in the `configure'
2394 scripts and `Makefile's used for target libraries.
2398 * Multilibs in gcc:: Multilibs in gcc.
2399 * Multilibs in Target Libraries:: Multilibs in Target Libraries.
2402 File: configure.info, Node: Multilibs in gcc, Next: Multilibs in Target Libraries, Up: Multilibs
2407 In gcc, multilibs are defined by setting the variable
2408 `MULTILIB_OPTIONS' in the target `Makefile' fragment. Several other
2409 `MULTILIB' variables may also be defined there. *Note The Target
2410 Makefile Fragment: (gcc)Target Fragment.
2412 If you have built gcc, you can see what multilibs it uses by running
2413 it with the `-print-multi-lib' option. The output `.;' means that no
2414 multilibs are used. In general, the output is a sequence of lines, one
2415 per multilib. The first part of each line, up to the `;', is the name
2416 of the multilib directory. The second part is a list of compiler
2417 options separated by `@' characters.
2419 Multilibs are built in a tree of directories. The top of the tree,
2420 represented by `.' in the list of multilib directories, is the default
2421 library to use when no special compiler options are used. The
2422 subdirectories of the tree hold versions of the library to use when
2423 particular compiler options are used.
2426 File: configure.info, Node: Multilibs in Target Libraries, Prev: Multilibs in gcc, Up: Multilibs
2428 Multilibs in Target Libraries
2429 =============================
2431 The target libraries in the Cygnus tree are automatically built with
2432 multilibs. That means that each library is built multiple times.
2434 This default is set in the top level `configure.in' file, by adding
2435 `--enable-multilib' to the list of arguments passed to configure when
2436 it is run for the target libraries (*note Host and Target Libraries::).
2438 Each target library uses the shell script `config-ml.in', written by
2439 Doug Evans, to prepare to build target libraries. This shell script is
2440 invoked after the `Makefile' has been created by the `configure'
2441 script. If multilibs are not enabled, it does nothing, otherwise it
2442 modifies the `Makefile' to support multilibs.
2444 The `config-ml.in' script makes one copy of the `Makefile' for each
2445 multilib in the appropriate subdirectory. When configuring in the
2446 source directory (which is not recommended), it will build a symlink
2447 tree of the sources in each subdirectory.
2449 The `config-ml.in' script sets several variables in the various
2450 `Makefile's. The `Makefile.in' must have definitions for these
2451 variables already; `config-ml.in' simply changes the existing values.
2452 The `Makefile' should use default values for these variables which will
2453 do the right thing in the subdirectories.
2456 `config-ml.in' will set this to a sequence of `../' strings, where
2457 the number of strings is the number of multilib levels in the
2458 source tree. The default value should be the empty string.
2461 `config-ml.in' will set this to a sequence of `../' strings, where
2462 the number of strings is number of multilib levels in the object
2463 directory. The default value should be the empty string. This
2464 will differ from `MULTISRCTOP' when configuring in the source tree
2465 (which is not recommended).
2468 In the top level `Makefile' only, `config-ml.in' will set this to
2469 the list of multilib subdirectories. The default value should be
2473 `config-ml.in' will set this to the installed subdirectory name to
2474 use for this subdirectory, with a leading `/'. The default value
2475 shold be the empty string.
2479 In the top level `Makefile' only, `config-ml.in' will set these
2480 variables to commands to use when doing a recursive make. These
2481 variables should both default to the string `true', so that by
2482 default nothing happens.
2484 All references to the parent of the source directory should use the
2485 variable `MULTISRCTOP'. Instead of writing `$(srcdir)/..', you must
2486 write `$(srcdir)/$(MULTISRCTOP)..'.
2488 Similarly, references to the parent of the object directory should
2489 use the variable `MULTIBUILDTOP'.
2491 In the installation target, the libraries should be installed in the
2492 subdirectory `MULTISUBDIR'. Instead of installing
2493 `$(libdir)/libfoo.a', install `$(libdir)$(MULTISUBDIR)/libfoo.a'.
2495 The `config-ml.in' script also modifies the top level `Makefile' to
2496 add `multi-do' and `multi-clean' targets which are used when building
2499 The default target of the `Makefile' should include the following
2501 @$(MULTIDO) $(FLAGS_TO_PASS) DO=all multi-do
2503 This assumes that `$(FLAGS_TO_PASS)' is defined as a set of variables
2504 to pass to a recursive invocation of `make'. This will build all the
2505 multilibs. Note that the default value of `MULTIDO' is `true', so by
2506 default this command will do nothing. It will only do something in the
2507 top level `Makefile' if multilibs were enabled.
2509 The `install' target of the `Makefile' should include the following
2511 @$(MULTIDO) $(FLAGS_TO_PASS) DO=install multi-do
2513 In general, any operation, other than clean, which should be
2514 performed on all the multilibs should use a `$(MULTIDO)' line, setting
2515 the variable `DO' to the target of each recursive call to `make'.
2517 The `clean' targets (`clean', `mostlyclean', etc.) should use
2518 `$(MULTICLEAN)'. For example, the `clean' target should do this:
2519 @$(MULTICLEAN) DO=clean multi-clean
2522 File: configure.info, Node: FAQ, Next: Index, Prev: Multilibs, Up: Top
2524 Frequently Asked Questions
2525 **************************
2527 Which do I run first, `autoconf' or `automake'?
2528 Except when you first add autoconf or automake support to a
2529 package, you shouldn't run either by hand. Instead, configure
2530 with the `--enable-maintainer-mode' option, and let `make' take
2533 `autoconf' says something about undefined macros.
2534 This means that you have macros in your `configure.in' which are
2535 not defined by `autoconf'. You may be using an old version of
2536 `autoconf'; try building and installing a newer one. Make sure the
2537 newly installled `autoconf' is first on your `PATH'. Also, see
2540 My `configure' script has stuff like `CY_GNU_GETTEXT' in it.
2541 This means that you have macros in your `configure.in' which should
2542 be defined in your `aclocal.m4' file, but aren't. This usually
2543 means that `aclocal' was not able to appropriate definitions of the
2544 macros. Make sure that you have installed all the packages you
2545 need. In particular, make sure that you have installed libtool
2546 (this is where `AM_PROG_LIBTOOL' is defined) and gettext (this is
2547 where `CY_GNU_GETTEXT' is defined, at least in the Cygnus version
2550 My `Makefile' has `@' characters in it.
2551 This may mean that you tried to use an autoconf substitution in
2552 your `Makefile.in' without adding the appropriate `AC_SUBST' call
2553 to your `configure' script. Or it may just mean that you need to
2554 rebuild `Makefile' in your build directory. To rebuild `Makefile'
2555 from `Makefile.in', run the shell script `config.status' with no
2556 arguments. If you need to force `configure' to run again, first
2557 run `config.status --recheck'. These runs are normally done
2558 automatically by `Makefile' targets, but if your `Makefile' has
2559 gotten messed up you'll need to help them along.
2561 Why do I have to run both `config.status --recheck' and `config.status'?
2562 Normally, you don't; they will be run automatically by `Makefile'
2563 targets. If you do need to run them, use `config.status --recheck'
2564 to run the `configure' script again with the same arguments as the
2565 first time you ran it. Use `config.status' (with no arguments) to
2566 regenerate all files (`Makefile', `config.h', etc.) based on the
2567 results of the configure script. The two cases are separate
2568 because it isn't always necessary to regenerate all the files
2569 after running `config.status --recheck'. The `Makefile' targets
2570 generated by automake will use the environment variables
2571 `CONFIG_FILES' and `CONFIG_HEADERS' to only regenerate files as
2574 What is the Cygnus tree?
2575 The Cygnus tree is used for various packages including gdb, the GNU
2576 binutils, and egcs. It is also, of course, used for Cygnus
2577 releases. It is the build system which was developed at Cygnus,
2578 using the Cygnus configure script. It permits building many
2579 different packages with a single configure and make. The
2580 configure scripts in the tree are being converted to autoconf, but
2581 the general build structure remains intact.
2583 Why do I have to keep rebuilding and reinstalling the tools?
2584 I know, it's a pain. Unfortunately, there are bugs in the tools
2585 themselves which need to be fixed, and each time that happens
2586 everybody who uses the tools need to reinstall new versions of
2587 them. I don't know if there is going to be a clever fix until the
2590 Why not just have a Cygnus tree `make' target to update the tools?
2591 The tools unfortunately need to be installed before they can be
2592 used. That means that they must be built using an appropriate
2593 prefix, and it seems unwise to assume that every configuration
2594 uses an appropriate prefix. It might be possible to make them
2595 work in place, or it might be possible to install them in some
2596 subdirectory; so far these approaches have not been implemented.
2599 File: configure.info, Node: Index, Prev: FAQ, Up: Top
2606 * --build option: Build and Host Options.
2607 * --host option: Build and Host Options.
2608 * --target option: Specifying the Target.
2609 * _GNU_SOURCE: Write configure.in.
2610 * AC_CANONICAL_HOST: Using the Host Type.
2611 * AC_CANONICAL_SYSTEM: Using the Target Type.
2612 * AC_CONFIG_HEADER: Write configure.in.
2613 * AC_EXEEXT: Write configure.in.
2614 * AC_INIT: Write configure.in.
2615 * AC_OUTPUT: Write configure.in.
2616 * AC_PREREQ: Write configure.in.
2617 * AC_PROG_CC: Write configure.in.
2618 * AC_PROG_CXX: Write configure.in.
2619 * acconfig.h: Written Developer Files.
2620 * acconfig.h, writing: Write acconfig.h.
2621 * acinclude.m4: Written Developer Files.
2622 * aclocal.m4: Generated Developer Files.
2623 * AM_CONFIG_HEADER: Write configure.in.
2624 * AM_DISABLE_SHARED: Write configure.in.
2625 * AM_EXEEXT: Write configure.in.
2626 * AM_INIT_AUTOMAKE: Write configure.in.
2627 * AM_MAINTAINER_MODE: Write configure.in.
2628 * AM_PROG_LIBTOOL: Write configure.in.
2629 * AM_PROG_LIBTOOL in configure: FAQ.
2630 * build option: Build and Host Options.
2631 * building with a cross compiler: Canadian Cross.
2632 * canadian cross: Canadian Cross.
2633 * canadian cross in configure: CCross in Configure.
2634 * canadian cross in cygnus tree: CCross in Cygnus Tree.
2635 * canadian cross in makefile: CCross in Make.
2636 * canadian cross, configuring: Build and Host Options.
2637 * canonical system names: Configuration Names.
2638 * config.cache: Build Files Description.
2639 * config.h: Build Files Description.
2640 * config.h.in: Generated Developer Files.
2641 * config.in: Generated Developer Files.
2642 * config.status: Build Files Description.
2643 * config.status --recheck: FAQ.
2644 * configuration names: Configuration Names.
2645 * configuration triplets: Configuration Names.
2646 * configure: Generated Developer Files.
2647 * configure build system: Build and Host Options.
2648 * configure host: Build and Host Options.
2649 * configure target: Specifying the Target.
2650 * configure.in: Written Developer Files.
2651 * configure.in, writing: Write configure.in.
2652 * configuring a canadian cross: Build and Host Options.
2653 * cross compiler: Cross Compilation Concepts.
2654 * cross compiler, building with: Canadian Cross.
2655 * cross tools: Cross Compilation Tools.
2656 * CY_GNU_GETTEXT in configure: FAQ.
2657 * cygnus configure: Cygnus Configure.
2660 * host names: Configuration Names.
2661 * host option: Build and Host Options.
2662 * host system: Host and Target.
2663 * host triplets: Configuration Names.
2664 * HOST_CC: CCross in Make.
2665 * libg++ configure: Cygnus Configure in C++ Libraries.
2666 * libio configure: Cygnus Configure in C++ Libraries.
2667 * libstdc++ configure: Cygnus Configure in C++ Libraries.
2668 * Makefile: Build Files Description.
2669 * Makefile, garbage characters: FAQ.
2670 * Makefile.am: Written Developer Files.
2671 * Makefile.am, writing: Write Makefile.am.
2672 * Makefile.in: Generated Developer Files.
2673 * multilibs: Multilibs.
2674 * stamp-h: Build Files Description.
2675 * stamp-h.in: Generated Developer Files.
2676 * system names: Configuration Names.
2677 * system types: Configuration Names.
2678 * target option: Specifying the Target.
2679 * target system: Host and Target.
2680 * triplets: Configuration Names.
2681 * undefined macros: FAQ.