URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [insight/] [etc/] [configure.info-1] - Rev 1765
Compare with Previous | Blame | View Log
This is configure.info, produced by makeinfo version 4.0 from./configure.texi.INFO-DIR-SECTION GNU adminSTART-INFO-DIR-ENTRY* configure: (configure). The GNU configure and build systemEND-INFO-DIR-ENTRYThis file documents the GNU configure and build system.Copyright (C) 1998 Cygnus Solutions.Permission is granted to make and distribute verbatim copies of thismanual provided the copyright notice and this permission notice arepreserved on all copies.Permission is granted to copy and distribute modified versions ofthis manual under the conditions for verbatim copying, provided thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of thismanual into another language, under the above conditions for modifiedversions, except that this permission notice may be stated in atranslation approved by the Foundation.File: configure.info, Node: Top, Next: Introduction, Up: (dir)GNU configure and build system******************************The GNU configure and build system.* Menu:* Introduction:: Introduction.* Getting Started:: Getting Started.* Files:: Files.* Configuration Names:: Configuration Names.* Cross Compilation Tools:: Cross Compilation Tools.* Canadian Cross:: Canadian Cross.* Cygnus Configure:: Cygnus Configure.* Multilibs:: Multilibs.* FAQ:: Frequently Asked Questions.* Index:: Index.File: configure.info, Node: Introduction, Next: Getting Started, Prev: Top, Up: TopIntroduction************This document describes the GNU configure and build systems. Itdescribes how autoconf, automake, libtool, and make fit together. Italso includes a discussion of the older Cygnus configure system.This document does not describe in detail how to use each of thetools; see the respective manuals for that. Instead, it describeswhich files the developer must write, which files are machine generatedand how they are generated, and where certain common problems should beaddressed.This document draws on several sources, including the autoconfmanual by David MacKenzie (*note autoconf overview: (autoconf)Top.),the automake manual by David MacKenzie and Tom Tromey (*note automakeoverview: (automake)Top.), the libtool manual by Gordon Matzigkeit(*note libtool overview: (libtool)Top.), and the Cygnus configuremanual by K. Richard Pixley.* Menu:* Goals:: Goals.* Tools:: The tools.* History:: History.* Building:: Building.File: configure.info, Node: Goals, Next: Tools, Up: IntroductionGoals=====The GNU configure and build system has two main goals.The first is to simplify the development of portable programs. Thesystem permits the developer to concentrate on writing the program,simplifying many details of portability across Unix and even Windowssystems, and permitting the developer to describe how to build theprogram using simple rules rather than complex Makefiles.The second is to simplify the building of programs distributed assource code. All programs are built using a simple, standardized, twostep process. The program builder need not install any special tools inorder to build the program.File: configure.info, Node: Tools, Next: History, Prev: Goals, Up: IntroductionTools=====The GNU configure and build system is comprised of several differenttools. Program developers must build and install all of these tools.People who just want to build programs from distributed sourcesnormally do not need any special tools beyond a Unix shell, a makeprogram, and a C compiler.autoconfprovides a general portability framework, based on testing thefeatures of the host system at build time.automakea system for describing how to build a program, permitting thedeveloper to write a simplified `Makefile'.libtoola standardized approach to building shared libraries.gettextprovides a framework for translation of text messages into otherlanguages; not really discussed in this document.m4autoconf requires the GNU version of m4; the standard Unix m4 doesnot suffice.perlautomake requires perl.File: configure.info, Node: History, Next: Building, Prev: Tools, Up: IntroductionHistory=======This is a very brief and probably inaccurate history.As the number of Unix variants increased during the 1980s, it becameharder to write programs which could run on all variants. While it wasoften possible to use `#ifdef' to identify particular systems,developers frequently did not have access to every system, and thecharacteristics of some systems changed from version to version.By 1992, at least three different approaches had been developed:* The Metaconfig program, by Larry Wall, Harlan Stenn, and RaphaelManfredi.* The Cygnus configure script, by K. Richard Pixley, and the gccconfigure script, by Richard Stallman. These use essentially thesame approach, and the developers communicated regularly.* The autoconf program, by David MacKenzie.The Metaconfig program is still used for Perl and a few otherprograms. It is part of the Dist package. I do not know if it isbeing developed.In 1994, David MacKenzie and others modified autoconf to incorporateall the features of Cygnus configure. Since then, there has been aslow but steady conversion of GNU programs from Cygnus configure toautoconf. gcc has been converted, eliminating the gcc configure script.GNU autoconf was regularly maintained until late 1996. As of thiswriting in June, 1998, it has no public maintainer.Most programs are built using the make program, which requires thedeveloper to write Makefiles describing how to build the programs.Since most programs are built in pretty much the same way, this led to alot of duplication.The X Window system is built using the imake tool, which uses adatabase of rules to eliminate the duplication. However, building atool which was developed using imake requires that the builder haveimake installed, violating one of the goals of the GNU system.The new BSD make provides a standard library of Makefile fragments,which permits developers to write very simple Makefiles. However, thisrequires that the builder install the new BSD make program.In 1994, David MacKenzie wrote the first version of automake, whichpermitted writing a simple build description which was converted into aMakefile which could be used by the standard make program. In 1995, TomTromey completely rewrote automake in Perl, and he continues to enhanceit.Various free packages built libraries, and by around 1995 severalincluded support to build shared libraries on various platforms.However, there was no consistent approach. In early 1996, GordonMatzigkeit began working on libtool, which provided a standardizedapproach to building shared libraries. This was integrated intoautomake from the start.The development of automake and libtool was driven by the GNITSproject, a group of GNU maintainers who designed standardized tools tohelp meet the GNU coding standards.File: configure.info, Node: Building, Prev: History, Up: IntroductionBuilding========Most readers of this document should already know how to build atool by running `configure' and `make'. This section may serve as aquick introduction or reminder.Building a tool is normally as simple as running `configure'followed by `make'. You should normally run `configure' from an emptydirectory, using some path to refer to the `configure' script in thesource directory. The directory in which you run `configure' is calledthe "object directory".In order to use a object directory which is different from the sourcedirectory, you must be using the GNU version of `make', which has therequired `VPATH' support. Despite this restriction, using a differentobject directory is highly recommended:* It keeps the files generated during the build from cluttering upyour sources.* It permits you to remove the built files by simply removing theentire build directory.* It permits you to build from the same sources with several sets ofconfigure options simultaneously.If you don't have GNU `make', you will have to run `configure' inthe source directory. All GNU packages should support this; inparticular, GNU packages should not assume the presence of GNU `make'.After running `configure', you can build the tools by running `make'.To install the tools, run `make install'. Installing the tools willcopy the programs and any required support files to the "installationdirectory". The location of the installation directory is controlledby `configure' options, as described below.In the Cygnus tree at present, the info files are built andinstalled as a separate step. To build them, run `make info'. Toinstall them, run `make install-info'.All `configure' scripts support a wide variety of options. The mostinteresting ones are `--with' and `--enable' options which aregenerally specific to particular tools. You can usually use the`--help' option to get a list of interesting options for a particularconfigure script.The only generic options you are likely to use are the `--prefix'and `--exec-prefix' options. These options are used to specify theinstallation directory.The directory named by the `--prefix' option will hold machineindependent files such as info files.The directory named by the `--exec-prefix' option, which is normallya subdirectory of the `--prefix' directory, will hold machine dependentfiles such as executables.The default for `--prefix' is `/usr/local'. The default for`--exec-prefix' is the value used for `--prefix'.The convention used in Cygnus releases is to use a `--prefix' optionof `/usr/cygnus/RELEASE', where RELEASE is the name of the release, andto use a `--exec-prefix' option of `/usr/cygnus/RELEASE/H-HOST', whereHOST is the configuration name of the host system (*note ConfigurationNames::).Do not use either the source or the object directory as theinstallation directory. That will just lead to confusion.File: configure.info, Node: Getting Started, Next: Files, Prev: Introduction, Up: TopGetting Started***************To start using the GNU configure and build system with your softwarepackage, you must write three files, and you must run some tools tomanually generate additional files.* Menu:* Write configure.in:: Write configure.in.* Write Makefile.am:: Write Makefile.am.* Write acconfig.h:: Write acconfig.h.* Generate files:: Generate files.* Getting Started Example:: Example.File: configure.info, Node: Write configure.in, Next: Write Makefile.am, Up: Getting StartedWrite configure.in==================You must first write the file `configure.in'. This is an autoconfinput file, and the autoconf manual describes in detail what this fileshould look like.You will write tests in your `configure.in' file to check forconditions that may change from one system to another, such as thepresence of particular header files or functions.For example, not all systems support the `gettimeofday' function.If you want to use the `gettimeofday' function when it is available,and to use some other function when it is not, you would check for thisby putting `AC_CHECK_FUNCS(gettimeofday)' in `configure.in'.When the configure script is run at build time, this will arrange todefine the preprocessor macro `HAVE_GETTIMEOFDAY' to the value 1 if the`gettimeofday' function is available, and to not define the macro atall if the function is not available. Your code can then use `#ifdef'to test whether it is safe to call `gettimeofday'.If you have an existing body of code, the `autoscan' program mayhelp identify potential portability problems, and hence configure teststhat you will want to use. *Note Invoking autoscan: (autoconf)Invokingautoscan.Another handy tool for an existing body of code is `ifnames'. Thiswill show you all the preprocessor conditionals that the code alreadyuses. *Note Invoking ifnames: (autoconf)Invoking ifnames.Besides the portability tests which are specific to your particularpackage, every `configure.in' file should contain the following macros.`AC_INIT'This macro takes a single argument, which is the name of a file inyour package. For example, `AC_INIT(foo.c)'.`AC_PREREQ(VERSION)'This macro is optional. It may be used to indicate the version of`autoconf' that you are using. This will prevent users fromrunning an earlier version of `autoconf' and perhaps getting aninvalid `configure' script. For example, `AC_PREREQ(2.12)'.`AM_INIT_AUTOMAKE'This macro takes two arguments: the name of the package, and aversion number. For example, `AM_INIT_AUTOMAKE(foo, 1.0)'. (Thismacro is not needed if you are not using automake).`AM_CONFIG_HEADER'This macro names the header file which will hold the preprocessormacro definitions at run time. Normally this should be`config.h'. Your sources would then use `#include "config.h"' toinclude it.This macro may optionally name the input file for that headerfile; by default, this is `config.h.in', but that file name workspoorly on DOS filesystems. Therefore, it is often better to nameit explicitly as `config.in'.This is what you should normally put in `configure.in':AM_CONFIG_HEADER(config.h:config.in)(If you are not using automake, use `AC_CONFIG_HEADER' rather than`AM_CONFIG_HEADER').`AM_MAINTAINER_MODE'This macro always appears in Cygnus configure scripts. Otherprograms may or may not use it.If this macro is used, the `--enable-maintainer-mode' option isrequired to enable automatic rebuilding of generated files used bythe configure system. This of course requires that developers beaware of, and use, that option.If this macro is not used, then the generated files will always berebuilt automatically. This will cause problems if the wrongversions of autoconf, automake, or others are in the builder's`PATH'.(If you are not using automake, you do not need to use this macro).`AC_EXEEXT'Either this macro or `AM_EXEEXT' always appears in Cygnus configurefiles. Other programs may or may not use one of them.This macro looks for the executable suffix used on the hostsystem. On Unix systems, this is the empty string. On Windowssystems, this is `.exe'. This macro directs automake to use theexecutable suffix as appropriate when creating programs. Thismacro does not take any arguments.The `AC_EXEEXT' form is new, and is part of a Cygnus patch toautoconf to support compiling with Visual C++. Older programs use`AM_EXEEXT' instead.(Programs which do not use automake use neither `AC_EXEEXT' nor`AM_EXEEXT').`AC_PROG_CC'If you are writing C code, you will normally want to use thismacro. It locates the C compiler to use. It does not take anyarguments.However, if this `configure.in' file is for a library which is tobe compiled by a cross compiler which may not fully work, then youwill not want to use `AC_PROG_CC'. Instead, you will want to use avariant which does not call the macro `AC_PROG_CC_WORKS'. Examplescan be found in various `configure.in' files for libraries that arecompiled with cross compilers, such as libiberty or libgloss.This is essentially a bug in autoconf, and there will probably bea better workaround at some point.`AC_PROG_CXX'If you are writing C++ code, you will want to use this macro. Itlocates the C++ compiler to use. It does not take any arguments.The same cross compiler comments apply as for `AC_PROG_CC'.`AM_PROG_LIBTOOL'If you want to build libraries, and you want to permit them to beshared, or you want to link against libraries which were builtusing libtool, then you will need this macro. This macro isrequired in order to use libtool.By default, this will cause all libraries to be built as sharedlibraries. To prevent this-to change the default-use`AM_DISABLE_SHARED' before `AM_PROG_LIBTOOL'. The configureoptions `--enable-shared' and `--disable-shared' may be used tooverride the default at build time.`AC_DEFINE(_GNU_SOURCE)'GNU packages should normally include this line before any otherfeature tests. This defines the macro `_GNU_SOURCE' whencompiling, which directs the libc header files to provide thestandard GNU system interfaces including all GNU extensions. Ifthis macro is not defined, certain GNU extensions may not beavailable.`AC_OUTPUT'This macro takes a list of file names which the configure processshould produce. This is normally a list of one or more `Makefile'files in different directories. If your package lives entirely ina single directory, you would use simply `AC_OUTPUT(Makefile)'.If you also have, for example, a `lib' subdirectory, you would use`AC_OUTPUT(Makefile lib/Makefile)'.If you want to use locally defined macros in your `configure.in'file, then you will need to write a `acinclude.m4' file which definesthem (if not using automake, this file is called `aclocal.m4').Alternatively, you can put separate macros in an `m4' subdirectory, andput `ACLOCAL_AMFLAGS = -I m4' in your `Makefile.am' file so that the`aclocal' program will be able to find them.The different macro prefixes indicate which tool defines the macro.Macros which start with `AC_' are part of autoconf. Macros which startwith `AM_' are provided by automake or libtool.File: configure.info, Node: Write Makefile.am, Next: Write acconfig.h, Prev: Write configure.in, Up: Getting StartedWrite Makefile.am=================You must write the file `Makefile.am'. This is an automake inputfile, and the automake manual describes in detail what this file shouldlook like.The automake commands in `Makefile.am' mostly look like variableassignments in a `Makefile'. automake recognizes special variablenames, and automatically add make rules to the output as needed.There will be one `Makefile.am' file for each directory in yourpackage. For each directory with subdirectories, the `Makefile.am'file should contain the lineSUBDIRS = DIR DIR ...where each DIR is the name of a subdirectory.For each `Makefile.am', there should be a corresponding `Makefile'in the `AC_OUTPUT' macro in `configure.in'.Every `Makefile.am' written at Cygnus should contain the lineAUTOMAKE_OPTIONS = cygnusThis puts automake into Cygnus mode. See the automake manual fordetails.You may to include the version number of `automake' that you areusing on the `AUTOMAKE_OPTIONS' line. For example,AUTOMAKE_OPTIONS = cygnus 1.3This will prevent users from running an earlier version of `automake'and perhaps getting an invalid `Makefile.in'.If your package builds a program, then in the directory where thatprogram is built you will normally want a line likebin_PROGRAMS = PROGRAMwhere PROGRAM is the name of the program. You will then want a linelikePROGRAM_SOURCES = FILE FILE ...where each FILE is the name of a source file to link into the program(e.g., `foo.c').If your package builds a library, and you do not want the library toever be built as a shared library, then in the directory where thatlibrary is built you will normally want a line likelib_LIBRARIES = libNAME.awhere `libNAME.a' is the name of the library. You will then want aline likelibNAME_a_SOURCES = FILE FILE ...where each FILE is the name of a source file to add to the library.If your package builds a library, and you want to permit building thelibrary as a shared library, then in the directory where that library isbuilt you will normally want a line likelib_LTLIBRARIES = libNAME.laThe use of `LTLIBRARIES', and the `.la' extension, indicate alibrary to be built using libtool. As usual, you will then want a linelikelibNAME_la_SOURCES = FILE FILE ...The strings `bin' and `lib' that appear above in `bin_PROGRAMS' and`lib_LIBRARIES' are not arbitrary. They refer to particulardirectories, which may be set by the `--bindir' and `--libdir' optionsto `configure'. If those options are not used, the default values arebased on the `--prefix' or `--exec-prefix' options to `configure'. Itis possible to use other names if the program or library should beinstalled in some other directory.The `Makefile.am' file may also contain almost anything that mayappear in a normal `Makefile'. automake also supports many otherspecial variables, as well as conditionals.See the automake manual for more information.File: configure.info, Node: Write acconfig.h, Next: Generate files, Prev: Write Makefile.am, Up: Getting StartedWrite acconfig.h================If you are generating a portability header file, (i.e., you are using`AM_CONFIG_HEADER' in `configure.in'), then you will have to write a`acconfig.h' file. It will have to contain the following lines./* Name of package. */#undef PACKAGE/* Version of package. */#undef VERSIONThis requirement is really a bug in the system, and the requirementmay be eliminated at some later date.The `acconfig.h' file will also similar comment and `#undef' linesfor any unusual macros in the `configure.in' file, including any macrowhich appears in a `AC_DEFINE' macro.In particular, if you are writing a GNU package and therefore include`AC_DEFINE(_GNU_SOURCE)' in `configure.in' as suggested above, you willneed lines like this in `acconfig.h':/* Enable GNU extensions. */#undef _GNU_SOURCENormally the `autoheader' program will inform you of any suchrequirements by printing an error message when it is run. However, ifyou do anything particular odd in your `configure.in' file, you willhave to make sure that the right entries appear in `acconfig.h', sinceotherwise the results of the tests may not be available in the`config.h' file which your code will use.(Thee `PACKAGE' and `VERSION' lines are not required if you are notusing automake, and in that case you may not need a `acconfig.h' fileat all).File: configure.info, Node: Generate files, Next: Getting Started Example, Prev: Write acconfig.h, Up: Getting StartedGenerate files==============Once you have written `configure.in', `Makefile.am', `acconfig.h',and possibly `acinclude.m4', you must use autoconf and automakeprograms to produce the first versions of the generated files. This isdone by executing the following sequence of commands.aclocalautoconfautoheaderautomakeThe `aclocal' and `automake' commands are part of the automakepackage, and the `autoconf' and `autoheader' commands are part of theautoconf package.If you are using a `m4' subdirectory for your macros, you will needto use the `-I m4' option when you run `aclocal'.If you are not using the Cygnus tree, use the `-a' option whenrunning `automake' command in order to copy the required support filesinto your source directory.If you are using libtool, you must build and install the libtoolpackage with the same `--prefix' and `--exec-prefix' options as youused with the autoconf and automake packages. You must do this beforerunning any of the above commands. If you are not using the Cygnustree, you will need to run the `libtoolize' program to copy the libtoolsupport files into your directory.Once you have managed to run these commands without getting anyerrors, you should create a new empty directory, and run the `configure'script which will have been created by `autoconf' with the`--enable-maintainer-mode' option. This will give you a set ofMakefiles which will include rules to automatically rebuild all thegenerated files.After doing that, whenever you have changed some of the input filesand want to regenerated the other files, go to your object directoryand run `make'. Doing this is more reliable than trying to rebuild thefiles manually, because there are complex order dependencies and it iseasy to forget something.File: configure.info, Node: Getting Started Example, Prev: Generate files, Up: Getting StartedExample=======Let's consider a trivial example.Suppose we want to write a simple version of `touch'. Our program,which we will call `poke', will take a single file name argument, anduse the `utime' system call to set the modification and access times ofthe file to the current time. We want this program to be highlyportable.We'll first see what this looks like without using autoconf andautomake, and then see what it looks like with them.* Menu:* Getting Started Example 1:: First Try.* Getting Started Example 2:: Second Try.* Getting Started Example 3:: Third Try.* Generate Files in Example:: Generate Files.File: configure.info, Node: Getting Started Example 1, Next: Getting Started Example 2, Up: Getting Started ExampleFirst Try---------Here is our first try at `poke.c'. Note that we've written itwithout ANSI/ISO C prototypes, since we want it to be highly portable.#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <utime.h>intmain (argc, argv)int argc;char **argv;{if (argc != 2){fprintf (stderr, "Usage: poke file\n");exit (1);}if (utime (argv[1], NULL) < 0){perror ("utime");exit (1);}exit (0);}We also write a simple `Makefile'.CC = gccCFLAGS = -g -O2all: pokepoke: poke.o$(CC) -o poke $(CFLAGS) $(LDFLAGS) poke.oSo far, so good.Unfortunately, there are a few problems.On older Unix systems derived from BSD 4.3, the `utime' system calldoes not accept a second argument of `NULL'. On those systems, we needto pass a pointer to `struct utimbuf' structure. Unfortunately, evenolder systems don't define that structure; on those systems, we need topass an array of two `long' values.The header file `stdlib.h' was invented by ANSI C, and older systemsdon't have a copy. We included it above to get a declaration of `exit'.We can find some of these portability problems by running`autoscan', which will create a `configure.scan' file which we can useas a prototype for our `configure.in' file. I won't show the output,but it will notice the potential problems with `utime' and `stdlib.h'.In our `Makefile', we don't provide any way to install the program.This doesn't matter much for such a simple example, but a real programwill need an `install' target. For that matter, we will also want a`clean' target.File: configure.info, Node: Getting Started Example 2, Next: Getting Started Example 3, Prev: Getting Started Example 1, Up: Getting Started ExampleSecond Try----------Here is our second try at this program.We modify `poke.c' to use preprocessor macros to control whatfeatures are available. (I've cheated a bit by using the same macronames which autoconf will use).#include <stdio.h>#ifdef STDC_HEADERS#include <stdlib.h>#endif#include <sys/types.h>#ifdef HAVE_UTIME_H#include <utime.h>#endif#ifndef HAVE_UTIME_NULL#include <time.h>#ifndef HAVE_STRUCT_UTIMBUFstruct utimbuf{long actime;long modtime;};#endifstatic intutime_now (file)char *file;{struct utimbuf now;now.actime = now.modtime = time (NULL);return utime (file, &now);}#define utime(f, p) utime_now (f)#endif /* HAVE_UTIME_NULL */intmain (argc, argv)int argc;char **argv;{if (argc != 2){fprintf (stderr, "Usage: poke file\n");exit (1);}if (utime (argv[1], NULL) < 0){perror ("utime");exit (1);}exit (0);}Here is the associated `Makefile'. We've added support for thepreprocessor flags we use. We've also added `install' and `clean'targets.# Set this to your installation directory.bindir = /usr/local/bin# Uncomment this if you have the standard ANSI/ISO C header files.# STDC_HDRS = -DSTDC_HEADERS# Uncomment this if you have utime.h.# UTIME_H = -DHAVE_UTIME_H# Uncomment this if utime (FILE, NULL) works on your system.# UTIME_NULL = -DHAVE_UTIME_NULL# Uncomment this if struct utimbuf is defined in utime.h.# UTIMBUF = -DHAVE_STRUCT_UTIMBUFCC = gccCFLAGS = -g -O2ALL_CFLAGS = $(STDC_HDRS) $(UTIME_H) $(UTIME_NULL) $(UTIMBUF) $(CFLAGS)all: pokepoke: poke.o$(CC) -o poke $(ALL_CFLAGS) $(LDFLAGS) poke.o.c.o:$(CC) -c $(ALL_CFLAGS) poke.cinstall: pokecp poke $(bindir)/pokeclean:rm poke poke.oSome problems with this approach should be clear.Users who want to compile poke will have to know how `utime' workson their systems, so that they can uncomment the `Makefile' correctly.The installation is done using `cp', but many systems have an`install' program which may be used, and which supports optionalfeatures such as stripping debugging information out of the installedbinary.The use of `Makefile' variables like `CC', `CFLAGS' and `LDFLAGS'follows the requirements of the GNU standards. This is convenient forall packages, since it reduces surprises for users. However, it iseasy to get the details wrong, and wind up with a slightly nonstandarddistribution.File: configure.info, Node: Getting Started Example 3, Next: Generate Files in Example, Prev: Getting Started Example 2, Up: Getting Started ExampleThird Try---------For our third try at this program, we will write a `configure.in'script to discover the configuration features on the host system, ratherthan requiring the user to edit the `Makefile'. We will also write a`Makefile.am' rather than a `Makefile'.The only change to `poke.c' is to add a line at the start of thefile:#include "config.h"The new `configure.in' file is as follows.AC_INIT(poke.c)AM_INIT_AUTOMAKE(poke, 1.0)AM_CONFIG_HEADER(config.h:config.in)AC_PROG_CCAC_HEADER_STDCAC_CHECK_HEADERS(utime.h)AC_EGREP_HEADER(utimbuf, utime.h, AC_DEFINE(HAVE_STRUCT_UTIMBUF))AC_FUNC_UTIME_NULLAC_OUTPUT(Makefile)The first four macros in this file, and the last one, were describedabove; see *Note Write configure.in::. If we omit these macros, thenwhen we run `automake' we will get a reminder that we need them.The other macros are standard autoconf macros.`AC_HEADER_STDC'Check for standard C headers.`AC_CHECK_HEADERS'Check whether a particular header file exists.`AC_EGREP_HEADER'Check for a particular string in a particular header file, in thiscase checking for `utimbuf' in `utime.h'.`AC_FUNC_UTIME_NULL'Check whether `utime' accepts a NULL second argument to set thefile change time to the current time.See the autoconf manual for a more complete description.The new `Makefile.am' file is as follows. Note how simple this iscompared to our earlier `Makefile'.bin_PROGRAMS = pokepoke_SOURCES = poke.cThis means that we should build a single program name `poke'. Itshould be installed in the binary directory, which we called `bindir'earlier. The program `poke' is built from the source file `poke.c'.We must also write a `acconfig.h' file. Besides `PACKAGE' and`VERSION', which must be mentioned for all packages which use automake,we must include `HAVE_STRUCT_UTIMBUF', since we mentioned it in an`AC_DEFINE'./* Name of package. */#undef PACKAGE/* Version of package. */#undef VERSION/* Whether utime.h defines struct utimbuf. */#undef HAVE_STRUCT_UTIMBUFFile: configure.info, Node: Generate Files in Example, Prev: Getting Started Example 3, Up: Getting Started ExampleGenerate Files--------------We must now generate the other files, using the following commands.aclocalautoconfautoheaderautomakeWhen we run `autoheader', it will remind us of any macros we forgotto add to `acconfig.h'.When we run `automake', it will want to add some files to ourdistribution. It will add them automatically if we use the`--add-missing' option.By default, `automake' will run in GNU mode, which means that itwill want us to create certain additional files; as of this writing, itwill want `NEWS', `README', `AUTHORS', and `ChangeLog', all of whichare files which should appear in a standard GNU distribution. We caneither add those files, or run `automake' with the `--foreign' option.Running these tools will generate the following files, all of whichare described in the next chapter.* `aclocal.m4'* `configure'* `config.in'* `Makefile.in'* `stamp-h.in'File: configure.info, Node: Files, Next: Configuration Names, Prev: Getting Started, Up: TopFiles*****As was seen in the previous chapter, the GNU configure and buildsystem uses a number of different files. The developer must write afew files. The others are generated by various tools.The system is rather flexible, and can be used in many differentways. In describing the files that it uses, I will describe the commoncase, and mention some other cases that may arise.* Menu:* Developer Files:: Developer Files.* Build Files:: Build Files.* Support Files:: Support Files.File: configure.info, Node: Developer Files, Next: Build Files, Up: FilesDeveloper Files===============This section describes the files written or generated by thedeveloper of a package.* Menu:* Developer Files Picture:: Developer Files Picture.* Written Developer Files:: Written Developer Files.* Generated Developer Files:: Generated Developer Files.File: configure.info, Node: Developer Files Picture, Next: Written Developer Files, Up: Developer FilesDeveloper Files Picture-----------------------Here is a picture of the files which are written by the developer,the generated files which would be included with a complete sourcedistribution, and the tools which create those files. The file namesare plain text and the tool names are enclosed by `*' characters (e.g.,`autoheader' is the name of a tool, not the name of a file).acconfig.h configure.in Makefile.am| | || --------------+---------------------- || | | | |v v | acinclude.m4 | |*autoheader* | | v v| | v --->*automake*v |--->*aclocal* | |config.in | | | v| v | Makefile.in| aclocal.m4---| |v v*autoconf*|vconfigureFile: configure.info, Node: Written Developer Files, Next: Generated Developer Files, Prev: Developer Files Picture, Up: Developer FilesWritten Developer Files-----------------------The following files would be written by the developer.`configure.in'This is the configuration script. This script containsinvocations of autoconf macros. It may also contain ordinaryshell script code. This file will contain feature tests forportability issues. The last thing in the file will normally bean `AC_OUTPUT' macro listing which files to create when thebuilder runs the configure script. This file is always requiredwhen using the GNU configure system. *Note Write configure.in::.`Makefile.am'This is the automake input file. It describes how the code shouldbe built. It consists of definitions of automake variables. Itmay also contain ordinary Makefile targets. This file is onlyneeded when using automake (newer tools normally use automake, butthere are still older tools which have not been converted, inwhich the developer writes `Makefile.in' directly). *Note WriteMakefile.am::.`acconfig.h'When the configure script creates a portability header file, byusing `AM_CONFIG_HEADER' (or, if not using automake,`AC_CONFIG_HEADER'), this file is used to describe macros which arenot recognized by the `autoheader' command. This is normally afairly uninteresting file, consisting of a collection of `#undef'lines with comments. Normally any call to `AC_DEFINE' in`configure.in' will require a line in this file. *Note Writeacconfig.h::.`acinclude.m4'This file is not always required. It defines local autoconfmacros. These macros may then be used in `configure.in'. If youdon't need any local autoconf macros, then you don't need thisfile at all. In fact, in general, you never need local autoconfmacros, since you can put everything in `configure.in', butsometimes a local macro is convenient.Newer tools may omit `acinclude.m4', and instead use asubdirectory, typically named `m4', and define `ACLOCAL_AMFLAGS =-I m4' in `Makefile.am' to force `aclocal' to look there for macrodefinitions. The macro definitions are then placed in separatefiles in that directory.The `acinclude.m4' file is only used when using automake; in oldertools, the developer writes `aclocal.m4' directly, if it is needed.File: configure.info, Node: Generated Developer Files, Prev: Written Developer Files, Up: Developer FilesGenerated Developer Files-------------------------The following files would be generated by the developer.When using automake, these files are normally not generated manuallyafter the first time. Instead, the generated `Makefile' contains rulesto automatically rebuild the files as required. When`AM_MAINTAINER_MODE' is used in `configure.in' (the normal case inCygnus code), the automatic rebuilding rules will only be defined ifyou configure using the `--enable-maintainer-mode' option.When using automatic rebuilding, it is important to ensure that allthe various tools have been built and installed on your `PATH'. Usingautomatic rebuilding is highly recommended, so much so that I'm notgoing to explain what you have to do if you don't use it.`configure'This is the configure script which will be run when building thepackage. This is generated by `autoconf' from `configure.in' and`aclocal.m4'. This is a shell script.`Makefile.in'This is the file which the configure script will turn into the`Makefile' at build time. This file is generated by `automake'from `Makefile.am'. If you aren't using automake, you must writethis file yourself. This file is pretty much a normal `Makefile',with some configure substitutions for certain variables.`aclocal.m4'This file is created by the `aclocal' program, based on thecontents of `configure.in' and `acinclude.m4' (or, as noted in thedescription of `acinclude.m4' above, on the contents of an `m4'subdirectory). This file contains definitions of autoconf macroswhich `autoconf' will use when generating the file `configure'.These autoconf macros may be defined by you in `acinclude.m4' orthey may be defined by other packages such as automake, libtool orgettext. If you aren't using automake, you will normally writethis file yourself; in that case, if `configure.in' uses onlystandard autoconf macros, this file will not be needed at all.`config.in'This file is created by `autoheader' based on `acconfig.h' and`configure.in'. At build time, the configure script will definesome of the macros in it to create `config.h', which may then beincluded by your program. This permits your C code to usepreprocessor conditionals to change its behaviour based on thecharacteristics of the host system. This file may also be called`config.h.in'.`stamp.h-in'This rather uninteresting file, which I omitted from the picture,is generated by `automake'. It always contains the string`timestamp'. It is used as a timestamp file indicating whether`config.in' is up to date. Using a timestamp file means that`config.in' can be marked as up to date without actually changingits modification time. This is useful since `config.in' dependsupon `configure.in', but it is easy to change `configure.in' in away which does not affect `config.in'.File: configure.info, Node: Build Files, Next: Support Files, Prev: Developer Files, Up: FilesBuild Files===========This section describes the files which are created at configure andbuild time. These are the files which somebody who builds the packagewill see.Of course, the developer will also build the package. Thedistinction between developer files and build files is not that thedeveloper does not see the build files, but that somebody who onlybuilds the package does not have to worry about the developer files.* Menu:* Build Files Picture:: Build Files Picture.* Build Files Description:: Build Files Description.File: configure.info, Node: Build Files Picture, Next: Build Files Description, Up: Build FilesBuild Files Picture-------------------Here is a picture of the files which will be created at build time.`config.status' is both a created file and a shell script which is runto create other files, and the picture attempts to show that.config.in *configure* Makefile.in| | || v || config.status || | |*config.status*<======+==========>*config.status*| |v vconfig.h MakefileFile: configure.info, Node: Build Files Description, Prev: Build Files Picture, Up: Build FilesBuild Files Description-----------------------This is a description of the files which are created at build time.`config.status'The first step in building a package is to run the `configure'script. The `configure' script will create the file`config.status', which is itself a shell script. When you firstrun `configure', it will automatically run `config.status'. An`Makefile' derived from an automake generated `Makefile.in' willcontain rules to automatically run `config.status' again whennecessary to recreate certain files if their inputs change.`Makefile'This is the file which make will read to build the program. The`config.status' script will transform `Makefile.in' into`Makefile'.`config.h'This file defines C preprocessor macros which C code can use toadjust its behaviour on different systems. The `config.status'script will transform `config.in' into `config.h'.`config.cache'This file did not fit neatly into the picture, and I omitted it.It is used by the `configure' script to cache results betweenruns. This can be an important speedup. If you modify`configure.in' in such a way that the results of old tests shouldchange (perhaps you have added a new library to `LDFLAGS'), thenyou will have to remove `config.cache' to force the tests to bererun.The autoconf manual explains how to set up a site specific cachefile. This can speed up running `configure' scripts on yoursystem.`stamp.h'This file, which I omitted from the picture, is similar to`stamp-h.in'. It is used as a timestamp file indicating whether`config.h' is up to date. This is useful since `config.h' dependsupon `config.status', but it is easy for `config.status' to changein a way which does not affect `config.h'.File: configure.info, Node: Support Files, Prev: Build Files, Up: FilesSupport Files=============The GNU configure and build system requires several support files tobe included with your distribution. You do not normally need to concernyourself with these. If you are using the Cygnus tree, most are alreadypresent. Otherwise, they will be installed with your source by`automake' (with the `--add-missing' option) and `libtoolize'.You don't have to put the support files in the top level directory.You can put them in a subdirectory, and use the `AC_CONFIG_AUX_DIR'macro in `configure.in' to tell `automake' and the `configure' scriptwhere they are.In this section, I describe the support files, so that you can knowwhat they are and why they are there.`ABOUT-NLS'Added by automake if you are using gettext. This is adocumentation file about the gettext project.`ansi2knr.c'Used by an automake generated `Makefile' if you put `ansi2knr' in`AUTOMAKE_OPTIONS' in `Makefile.am'. This permits compiling ANSIC code with a K&R C compiler.`ansi2knr.1'The man page which goes with `ansi2knr.c'.`config.guess'A shell script which determines the configuration name for thesystem on which it is run.`config.sub'A shell script which canonicalizes a configuration name entered bya user.`elisp-comp'Used to compile Emacs LISP files.`install-sh'A shell script which installs a program. This is used if theconfigure script can not find an install binary.`ltconfig'Used by libtool. This is a shell script which configures libtoolfor the particular system on which it is used.`ltmain.sh'Used by libtool. This is the actual libtool script which is used,after it is configured by `ltconfig' to build a library.`mdate-sh'A shell script used by an automake generated `Makefile' to prettyprint the modification time of a file. This is used to maintainversion numbers for texinfo files.`missing'A shell script used if some tool is missing entirely. This isused by an automake generated `Makefile' to avoid certain sorts oftimestamp problems.`mkinstalldirs'A shell script which creates a directory, including all parentdirectories. This is used by an automake generated `Makefile'during installation.`texinfo.tex'Required if you have any texinfo files. This is used whenconverting Texinfo files into DVI using `texi2dvi' and TeX.`ylwrap'A shell script used by an automake generated `Makefile' to runprograms like `bison', `yacc', `flex', and `lex'. These programsdefault to producing output files with a fixed name, and the`ylwrap' script runs them in a subdirectory to avoid file nameconflicts when using a parallel make program.File: configure.info, Node: Configuration Names, Next: Cross Compilation Tools, Prev: Files, Up: TopConfiguration Names*******************The GNU configure system names all systems using a "configurationname". All such names used to be triplets (they may now contain fourparts in certain cases), and the term "configuration triplet" is stillseen.* Menu:* Configuration Name Definition:: Configuration Name Definition.* Using Configuration Names:: Using Configuration Names.
