1 Ceci est le fichier Info autoconf.info, produit par Makeinfo version
2 4.0 à partir autoconf.texi.
4 INFO-DIR-SECTION GNU admin
6 * Autoconf: (autoconf). Create source code configuration scripts
9 INFO-DIR-SECTION Individual utilities
11 * autoscan: (autoconf)autoscan Invocation.
12 Semi-automatic `configure.ac' writing
13 * ifnames: (autoconf)ifnames Invocation.
14 Listing the conditionals in source code
15 * autoconf: (autoconf)autoconf Invocation.
16 How to create configuration scripts
17 * autoreconf: (autoconf)autoreconf Invocation.
18 Remaking multiple `configure' scripts
19 * configure: (autoconf)configure Invocation.
21 * config.status: (autoconf)config.status Invocation.
22 Recreating a configuration
25 Autoconf: Creating Automatic Configuration Scripts, by David
28 This file documents the GNU Autoconf package for creating scripts to
29 configure source code packages using templates and an `m4' macro
32 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free
33 Software Foundation, Inc.
35 Permission is granted to make and distribute verbatim copies of this
36 manual provided the copyright notice and this permission notice are
37 preserved on all copies.
39 Permission is granted to copy and distribute modified versions of
40 this manual under the conditions for verbatim copying, provided that the
41 entire resulting derived work is distributed under the terms of a
42 permission notice identical to this one.
44 Permission is granted to copy and distribute translations of this
45 manual into another language, under the above conditions for modified
46 versions, except that this permission notice may be stated in a
47 translation approved by the Foundation.
50 File: autoconf.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
52 This file documents the GNU Autoconf package for creating scripts to
53 configure source code packages using templates and the GNU M4 macro
54 package. This is edition 2.52, for Autoconf version 2.52.
58 * Introduction:: Autoconf's purpose, strengths, and weaknesses
59 * The GNU build system:: A set of tools for portable software packages
60 * Making configure Scripts:: How to organize and produce Autoconf scripts
61 * Setup:: Initialization and output
62 * Existing Tests:: Macros that check for particular features
63 * Writing Tests:: How to write new feature checks
64 * Results:: What to do with results from feature checks
65 * Programming in M4:: Layers on top of which Autoconf is written
66 * Writing Autoconf Macros:: Adding new macros to Autoconf
67 * Portable Shell:: Shell script portability pitfalls
68 * Manual Configuration:: Selecting features that can't be guessed
69 * Site Configuration:: Local defaults for `configure'
70 * Running configure scripts:: How to use the Autoconf output
71 * config.status Invocation:: Recreating a configuration
72 * Obsolete Constructs:: Kept for backward compatibility
73 * Questions:: Questions about Autoconf, with answers
74 * History:: History of Autoconf
75 * Environment Variable Index:: Index of environment variables used
76 * Output Variable Index:: Index of variables set in output files
77 * Preprocessor Symbol Index:: Index of C preprocessor symbols defined
78 * Autoconf Macro Index:: Index of Autoconf macros
79 * M4 Macro Index:: Index of M4, M4sugar, and M4sh macros
80 * Concept Index:: General index
85 * Automake:: Escaping Makefile hell
86 * Libtool:: Building libraries portably
87 * Pointers:: More info on the GNU build system
89 Making `configure' Scripts
91 * Writing configure.ac:: What to put in an Autoconf input file
92 * autoscan Invocation:: Semi-automatic `configure.ac' writing
93 * ifnames Invocation:: Listing the conditionals in source code
94 * autoconf Invocation:: How to create configuration scripts
95 * autoreconf Invocation:: Remaking multiple `configure' scripts
97 Writing `configure.ac'
99 * Shell Script Compiler:: Autoconf as solution of a problem
100 * Autoconf Language:: Programming in Autoconf
101 * configure.ac Layout:: Standard organization of configure.ac
103 Initialization and Output Files
105 * Notices:: Copyright, version numbers in `configure'
106 * Input:: Where Autoconf should find files
107 * Output:: Outputting results from the configuration
108 * Configuration Actions:: Preparing the output based on results
109 * Configuration Files:: Creating output files
110 * Makefile Substitutions:: Using output variables in `Makefile's
111 * Configuration Headers:: Creating a configuration header file
112 * Configuration Commands:: Running arbitrary instantiation commands
113 * Configuration Links:: Links depending from the configuration
114 * Subdirectories:: Configuring independent packages together
115 * Default Prefix:: Changing the default installation prefix
117 Substitutions in Makefiles
119 * Preset Output Variables:: Output variables that are always set
120 * Installation Directory Variables:: Other preset output variables
121 * Build Directories:: Supporting multiple concurrent compiles
122 * Automatic Remaking:: Makefile rules for configuring
124 Configuration Header Files
126 * Header Templates:: Input for the configuration headers
127 * autoheader Invocation:: How to create configuration templates
128 * Autoheader Macros:: How to specify CPP templates
132 * Common Behavior:: Macros' standard schemes
133 * Alternative Programs:: Selecting between alternative programs
134 * Files:: Checking for the existence of files
135 * Libraries:: Library archives that might be missing
136 * Library Functions:: C library functions that might be missing
137 * Header Files:: Header files that might be missing
138 * Declarations:: Declarations that may be missing
139 * Structures:: Structures or members that might be missing
140 * Types:: Types that might be missing
141 * Compilers and Preprocessors:: Checking for compiling programs
142 * System Services:: Operating system services
143 * UNIX Variants:: Special kludges for specific UNIX variants
147 * Standard Symbols:: Symbols defined by the macros
148 * Default Includes:: Includes used by the generic macros
152 * Particular Programs:: Special handling to find certain programs
153 * Generic Programs:: How to find other programs
157 * Function Portability:: Pitfalls with usual functions
158 * Particular Functions:: Special handling to find certain functions
159 * Generic Functions:: How to find other functions
163 * Particular Headers:: Special handling to find certain headers
164 * Generic Headers:: How to find other headers
168 * Particular Declarations:: Macros to check for certain declarations
169 * Generic Declarations:: How to find other declarations
173 * Particular Structures:: Macros to check for certain structure members
174 * Generic Structures:: How to find other structure members
178 * Particular Types:: Special handling to find certain types
179 * Generic Types:: How to find other types
181 Compilers and Preprocessors
183 * Generic Compiler Characteristics:: Language independent tests
184 * C Compiler:: Checking its characteristics
185 * C++ Compiler:: Likewise
186 * Fortran 77 Compiler:: Likewise
190 * Examining Declarations:: Detecting header files and declarations
191 * Examining Syntax:: Detecting language syntax features
192 * Examining Libraries:: Detecting functions and global variables
193 * Run Time:: Testing for run-time features
194 * Systemology:: A zoology of operating systems
195 * Multiple Cases:: Tests for several possible values
196 * Language Choice:: Selecting which language to use for testing
198 Checking Run Time Behavior
200 * Test Programs:: Running test programs
201 * Guidelines:: General rules for writing test programs
202 * Test Functions:: Avoiding pitfalls in test programs
206 * Defining Symbols:: Defining C preprocessor symbols
207 * Setting Output Variables:: Replacing variables in output files
208 * Caching Results:: Speeding up subsequent `configure' runs
209 * Printing Messages:: Notifying `configure' users
213 * Cache Variable Names:: Shell variables used in caches
214 * Cache Files:: Files `configure' uses for caching
215 * Cache Checkpointing:: Loading and saving the cache file
219 * M4 Quotation:: Protecting macros from unwanted expansion
220 * Programming in M4sugar:: Convenient pure M4 macros
224 * Active Characters:: Characters that change the behavior of m4
225 * One Macro Call:: Quotation and one macro call
226 * Quotation and Nested Macros:: Macros calling macros
227 * Quadrigraphs:: Another way to escape special characters
228 * Quotation Rule Of Thumb:: One parenthesis, one quote
230 Programming in M4sugar
232 * Redefined M4 Macros:: M4 builtins changed in M4sugar
233 * Forbidden Patterns:: Catching unexpanded macros
235 Writing Autoconf Macros
237 * Macro Definitions:: Basic format of an Autoconf macro
238 * Macro Names:: What to call your new macros
239 * Reporting Messages:: Notifying `autoconf' users
240 * Dependencies Between Macros:: What to do when macros depend on other macros
241 * Obsoleting Macros:: Warning about old ways of doing things
242 * Coding Style:: Writing Autoconf macros a` la Autoconf
244 Dependencies Between Macros
246 * Prerequisite Macros:: Ensuring required information
247 * Suggested Ordering:: Warning about possible ordering problems
249 Portable Shell Programming
251 * Shellology:: A zoology of shells
252 * Here-Documents:: Quirks and tricks
253 * File Descriptors:: FDs and redirections
254 * File System Conventions:: File- and pathnames
255 * Shell Substitutions:: Variable and command expansions
256 * Assignments:: Varying side effects of assignments
257 * Special Shell Variables:: Variables you should not change
258 * Limitations of Builtins:: Portable use of not so portable /bin/sh
259 * Limitations of Usual Tools:: Portable use of portable tools
260 * Limitations of Make:: Portable Makefiles
264 * Specifying Names:: Specifying the system type
265 * Canonicalizing:: Getting the canonical system type
266 * Using System Type:: What to do with the system type
270 * External Software:: Working with other optional software
271 * Package Options:: Selecting optional features
272 * Pretty Help Strings:: Formating help string
273 * Site Details:: Configuring site details
274 * Transforming Names:: Changing program names when installing
275 * Site Defaults:: Giving `configure' local defaults
277 Transforming Program Names When Installing
279 * Transformation Options:: `configure' options to transform names
280 * Transformation Examples:: Sample uses of transforming names
281 * Transformation Rules:: `Makefile' uses of transforming names
283 Running `configure' Scripts
285 * Basic Installation:: Instructions for typical cases
286 * Compilers and Options:: Selecting compilers and optimization
287 * Multiple Architectures:: Compiling for multiple architectures at once
288 * Installation Names:: Installing in different directories
289 * Optional Features:: Selecting optional features
290 * System Type:: Specifying the system type
291 * Sharing Defaults:: Setting site-wide defaults for `configure'
292 * Environment Variables:: Defining environment variables.
293 * configure Invocation:: Changing how `configure' runs
297 * Obsolete config.status Use:: Different calling convention
298 * acconfig.h:: Additional entries in `config.h.in'
299 * autoupdate Invocation:: Automatic update of `configure.ac'
300 * Obsolete Macros:: Backward compatibility macros
301 * Autoconf 1:: Tips for upgrading your files
302 * Autoconf 2.13:: Some fresher tips
304 Upgrading From Version 1
306 * Changed File Names:: Files you might rename
307 * Changed Makefiles:: New things to put in `Makefile.in'
308 * Changed Macros:: Macro calls you might replace
309 * Changed Results:: Changes in how to check test results
310 * Changed Macro Writing:: Better ways to write your own macros
312 Upgrading From Version 2.13
314 * Changed Quotation:: Broken code which used to work
315 * New Macros:: Interaction with foreign macros
317 Questions About Autoconf
319 * Distributing:: Distributing `configure' scripts
320 * Why GNU m4:: Why not use the standard M4?
321 * Bootstrapping:: Autoconf and GNU M4 require each other?
322 * Why Not Imake:: Why GNU uses `configure' instead of Imake
326 * Genesis:: Prehistory and naming of `configure'
327 * Exodus:: The plagues of M4 and Perl
328 * Leviticus:: The priestly code of portability arrives
329 * Numbers:: Growth and contributors
330 * Deuteronomy:: Approaching the promises of easy configuration
333 File: autoconf.info, Node: Introduction, Next: The GNU build system, Prev: Top, Up: Top
338 A physicist, an engineer, and a computer scientist were discussing the
339 nature of God. "Surely a Physicist," said the physicist, "because
340 early in the Creation, God made Light; and you know, Maxwell's
341 equations, the dual nature of electromagnetic waves, the relativistic
342 consequences..." "An Engineer!," said the engineer, "because
343 before making Light, God split the Chaos into Land and Water; it takes a
344 hell of an engineer to handle that big amount of mud, and orderly
345 separation of solids from liquids..." The computer scientist
346 shouted: "And the Chaos, where do you think it was coming from, hmm?"
350 Autoconf is a tool for producing shell scripts that automatically
351 configure software source code packages to adapt to many kinds of
352 UNIX-like systems. The configuration scripts produced by Autoconf are
353 independent of Autoconf when they are run, so their users do not need
356 The configuration scripts produced by Autoconf require no manual user
357 intervention when run; they do not normally even need an argument
358 specifying the system type. Instead, they individually test for the
359 presence of each feature that the software package they are for might
360 need. (Before each check, they print a one-line message stating what
361 they are checking for, so the user doesn't get too bored while waiting
362 for the script to finish.) As a result, they deal well with systems
363 that are hybrids or customized from the more common UNIX variants.
364 There is no need to maintain files that list the features supported by
365 each release of each variant of UNIX.
367 For each software package that Autoconf is used with, it creates a
368 configuration script from a template file that lists the system features
369 that the package needs or can use. After the shell code to recognize
370 and respond to a system feature has been written, Autoconf allows it to
371 be shared by many software packages that can use (or need) that feature.
372 If it later turns out that the shell code needs adjustment for some
373 reason, it needs to be changed in only one place; all of the
374 configuration scripts can be regenerated automatically to take advantage
377 The Metaconfig package is similar in purpose to Autoconf, but the
378 scripts it produces require manual user intervention, which is quite
379 inconvenient when configuring large source trees. Unlike Metaconfig
380 scripts, Autoconf scripts can support cross-compiling, if some care is
381 taken in writing them.
383 Autoconf does not solve all problems related to making portable
384 software packages--for a more complete solution, it should be used in
385 concert with other GNU build tools like Automake and Libtool. These
386 other tools take on jobs like the creation of a portable, recursive
387 `Makefile' with all of the standard targets, linking of shared
388 libraries, and so on. *Note The GNU build system::, for more
391 Autoconf imposes some restrictions on the names of macros used with
392 `#if' in C programs (*note Preprocessor Symbol Index::).
394 Autoconf requires GNU M4 in order to generate the scripts. It uses
395 features that some UNIX versions of M4, including GNU M4 1.3, do not
396 have. You must use version 1.4 or later of GNU M4.
398 *Note Autoconf 1::, for information about upgrading from version 1.
399 *Note History::, for the story of Autoconf's development. *Note
400 Questions::, for answers to some common questions about Autoconf.
402 See the Autoconf web page(1) for up-to-date information, details on
403 the mailing lists, pointers to a list of known bugs, etc.
405 Mail suggestions to the Autoconf mailing list <autoconf@gnu.org>.
407 Bug reports should be preferably submitted to the Autoconf Gnats
408 database(2), or sent to the Autoconf Bugs mailing list
409 <bug-autoconf@gnu.org>. If possible, first check that your bug is not
410 already solved in current development versions, and that it has not
411 been reported yet. Be sure to include all the needed information and a
412 short `configure.ac' that demonstrates the problem.
414 Autoconf's development tree is accessible via CVS; see the Autoconf
415 web page for details. There is also a CVSweb interface to the Autoconf
416 development tree(3). Patches relative to the current CVS version can
417 be sent for review to the Autoconf Patches mailing list
418 <autoconf-patches@gnu.org>.
420 Because of its mission, Autoconf includes only a set of often-used
421 macros that have already demonstrated their usefulness. Nevertheless,
422 if you wish to share your macros, or find existing ones, see the
423 Autoconf Macro Archive(4), which is kindly run by Peter Simons
424 <simons@computer.org>.
426 ---------- Footnotes ----------
428 (1) Autoconf web page,
429 <http://www.gnu.org/software/autoconf/autoconf.html>.
431 (2) Autoconf Gnats database,
432 <http://sources.redhat.com/cgi-bin/gnatsweb.pl?database=autoconf>.
434 (3) CVSweb interface to the Autoconf development tree,
435 <http://subversions.gnu.org/cgi-bin/cvsweb/autoconf/>.
437 (4) Autoconf Macro Archive,
438 <http://www.gnu.org/software/ac-archive/>.
441 File: autoconf.info, Node: The GNU build system, Next: Making configure Scripts, Prev: Introduction, Up: Top
446 Autoconf solves an important problem--reliable discovery of
447 system-specific build and runtime information--but this is only one
448 piece of the puzzle for the development of portable software. To this
449 end, the GNU project has developed a suite of integrated utilities to
450 finish the job Autoconf started: the GNU build system, whose most
451 important components are Autoconf, Automake, and Libtool. In this
452 chapter, we introduce you to those tools, point you to sources of more
453 information, and try to convince you to use the entire GNU build system
458 * Automake:: Escaping Makefile hell
459 * Libtool:: Building libraries portably
460 * Pointers:: More info on the GNU build system
463 File: autoconf.info, Node: Automake, Next: Libtool, Prev: The GNU build system, Up: The GNU build system
468 The ubiquity of `make' means that a `Makefile' is almost the only
469 viable way to distribute automatic build rules for software, but one
470 quickly runs into `make''s numerous limitations. Its lack of support
471 for automatic dependency tracking, recursive builds in subdirectories,
472 reliable timestamps (e.g. for network filesystems), and so on, mean
473 that developers must painfully (and often incorrectly) reinvent the
474 wheel for each project. Portability is non-trivial, thanks to the
475 quirks of `make' on many systems. On top of all this is the manual
476 labor required to implement the many standard targets that users have
477 come to expect (`make install', `make distclean', `make uninstall',
478 etc.). Since you are, of course, using Autoconf, you also have to
479 insert repetitive code in your `Makefile.in' to recognize `@CC@',
480 `@CFLAGS@', and other substitutions provided by `configure'. Into this
481 mess steps "Automake".
483 Automake allows you to specify your build needs in a `Makefile.am'
484 file with a vastly simpler and more powerful syntax than that of a plain
485 `Makefile', and then generates a portable `Makefile.in' for use with
486 Autoconf. For example, the `Makefile.am' to build and install a simple
487 "Hello world" program might look like:
490 hello_SOURCES = hello.c
492 The resulting `Makefile.in' (~400 lines) automatically supports all the
493 standard targets, the substitutions provided by Autoconf, automatic
494 dependency tracking, `VPATH' building, and so on. `make' will build
495 the `hello' program, and `make install' will install it in
496 `/usr/local/bin' (or whatever prefix was given to `configure', if not
499 Automake may require that additional tools be present on the
500 _developer's_ machine. For example, the `Makefile.in' that the
501 developer works with may not be portable (e.g. it might use special
502 features of your compiler to automatically generate dependency
503 information). Running `make dist', however, produces a
504 `hello-1.0.tar.gz' package (or whatever the program/version is) with a
505 `Makefile.in' that will work on any system.
507 The benefits of Automake increase for larger packages (especially
508 ones with subdirectories), but even for small programs the added
509 convenience and portability can be substantial. And that's not all...
512 File: autoconf.info, Node: Libtool, Next: Pointers, Prev: Automake, Up: The GNU build system
517 Very often, one wants to build not only programs, but libraries, so
518 that other programs can benefit from the fruits of your labor.
519 Ideally, one would like to produce _shared_ (dynamically-linked)
520 libraries, which can be used by multiple programs without duplication
521 on disk or in memory and can be updated independently of the linked
522 programs. Producing shared libraries portably, however, is the stuff of
523 nightmares--each system has its own incompatible tools, compiler flags,
524 and magic incantations. Fortunately, GNU provides a solution:
527 Libtool handles all the requirements of building shared libraries for
528 you, and at this time seems to be the _only_ way to do so with any
529 portability. It also handles many other headaches, such as: the
530 interaction of `Makefile' rules with the variable suffixes of shared
531 libraries, linking reliably to shared libraries before they are
532 installed by the superuser, and supplying a consistent versioning system
533 (so that different versions of a library can be installed or upgraded
534 without breaking binary compatibility). Although Libtool, like
535 Autoconf, can be used on its own, it is most simply utilized in
536 conjunction with Automake--there, Libtool is used automatically
537 whenever shared libraries are needed, and you need not know its syntax.
540 File: autoconf.info, Node: Pointers, Prev: Libtool, Up: The GNU build system
545 Developers who are used to the simplicity of `make' for small
546 projects on a single system might be daunted at the prospect of learning
547 to use Automake and Autoconf. As your software is distributed to more
548 and more users, however, you will otherwise quickly find yourself
549 putting lots of effort into reinventing the services that the GNU build
550 tools provide, and making the same mistakes that they once made and
551 overcame. (Besides, since you're already learning Autoconf, Automake
552 will be a piece of cake.)
554 There are a number of places that you can go to for more information
555 on the GNU build tools.
559 The home pages for Autoconf(1), Automake(2), and Libtool(3).
563 *Note Automake: (automake)Top, for more information on Automake.
567 The book `GNU Autoconf, Automake and Libtool'(4) describes the
568 complete GNU build environment. You can also find the entire book
569 on-line at "The Goat Book" home page(5).
571 - Tutorials and Examples
573 The Autoconf Developer Page(6) maintains links to a number of
574 Autoconf/Automake tutorials online, and also links to the Autoconf
578 ---------- Footnotes ----------
580 (1) Autoconf, <http://www.gnu.org/software/autoconf/>.
582 (2) Automake, <http://www.gnu.org/software/automake/>.
584 (3) Libtool, <http://www.gnu.org/software/libtool/>.
586 (4) `GNU Autoconf, Automake and Libtool', by G. V. Vaughan, B.
587 Elliston, T. Tromey, and I. L. Taylor. New Riders, 2000, ISBN
590 (5) "The Goat Book" home page, <http://sources.redhat.com/autobook/>.
592 (6) Autoconf Developer Page, <http://sources.redhat.com/autoconf/>.
594 (7) Autoconf Macro Archive,
595 <http://www.gnu.org/software/ac-archive/>.
598 File: autoconf.info, Node: Making configure Scripts, Next: Setup, Prev: The GNU build system, Up: Top
600 Making `configure' Scripts
601 **************************
603 The configuration scripts that Autoconf produces are by convention
604 called `configure'. When run, `configure' creates several files,
605 replacing configuration parameters in them with appropriate values.
606 The files that `configure' creates are:
608 - one or more `Makefile' files, one in each subdirectory of the
609 package (*note Makefile Substitutions::);
611 - optionally, a C header file, the name of which is configurable,
612 containing `#define' directives (*note Configuration Headers::);
614 - a shell script called `config.status' that, when run, will recreate
615 the files listed above (*note config.status Invocation::);
617 - an optional shell script normally called `config.cache' (created
618 when using `configure --config-cache') that saves the results of
619 running many of the tests (*note Cache Files::);
621 - a file called `config.log' containing any messages produced by
622 compilers, to help debugging if `configure' makes a mistake.
624 To create a `configure' script with Autoconf, you need to write an
625 Autoconf input file `configure.ac' (or `configure.in') and run
626 `autoconf' on it. If you write your own feature tests to supplement
627 those that come with Autoconf, you might also write files called
628 `aclocal.m4' and `acsite.m4'. If you use a C header file to contain
629 `#define' directives, you might also run `autoheader', and you will
630 distribute the generated file `config.h.in' with the package.
632 Here is a diagram showing how the files that can be used in
633 configuration are produced. Programs that are executed are suffixed by
634 `*'. Optional files are enclosed in square brackets (`[]').
635 `autoconf' and `autoheader' also read the installed Autoconf macro
636 files (by reading `autoconf.m4').
638 Files used in preparing a software package for distribution:
639 your source files --> [autoscan*] --> [configure.scan] --> configure.ac
642 | .------> autoconf* -----> configure
644 | `-----> [autoheader*] --> [config.h.in]
647 Makefile.in -------------------------------> Makefile.in
649 Files used in configuring a software package:
650 .-------------> [config.cache]
651 configure* ------------+-------------> config.log
653 [config.h.in] -. v .-> [config.h] -.
654 +--> config.status* -+ +--> make*
655 Makefile.in ---' `-> Makefile ---'
659 * Writing configure.ac:: What to put in an Autoconf input file
660 * autoscan Invocation:: Semi-automatic `configure.ac' writing
661 * ifnames Invocation:: Listing the conditionals in source code
662 * autoconf Invocation:: How to create configuration scripts
663 * autoreconf Invocation:: Remaking multiple `configure' scripts
666 File: autoconf.info, Node: Writing configure.ac, Next: autoscan Invocation, Prev: Making configure Scripts, Up: Making configure Scripts
668 Writing `configure.ac'
669 ======================
671 To produce a `configure' script for a software package, create a
672 file called `configure.ac' that contains invocations of the Autoconf
673 macros that test the system features your package needs or can use.
674 Autoconf macros already exist to check for many features; see *Note
675 Existing Tests::, for their descriptions. For most other features, you
676 can use Autoconf template macros to produce custom checks; see *Note
677 Writing Tests::, for information about them. For especially tricky or
678 specialized features, `configure.ac' might need to contain some
679 hand-crafted shell commands; see *Note Portable Shell::. The
680 `autoscan' program can give you a good start in writing `configure.ac'
681 (*note autoscan Invocation::, for more information).
683 Previous versions of Autoconf promoted the name `configure.in',
684 which is somewhat ambiguous (the tool needed to produce this file is not
685 described by its extension), and introduces a slight confusion with
686 `config.h.in' and so on (for which `.in' means "to be processed by
687 `configure'"). Using `configure.ac' is now preferred.
691 * Shell Script Compiler:: Autoconf as solution of a problem
692 * Autoconf Language:: Programming in Autoconf
693 * configure.ac Layout:: Standard organization of configure.ac
696 File: autoconf.info, Node: Shell Script Compiler, Next: Autoconf Language, Prev: Writing configure.ac, Up: Writing configure.ac
698 A Shell Script Compiler
699 -----------------------
701 Just as for any other computer language, in order to properly program
702 `configure.ac' in Autoconf you must understand _what_ problem the
703 language tries to address and _how_ it does so.
705 The problem Autoconf addresses is that the world is a mess. After
706 all, you are using Autoconf in order to have your package compile
707 easily on all sorts of different systems, some of them being extremely
708 hostile. Autoconf itself bears the price for these differences:
709 `configure' must run on all those systems, and thus `configure' must
710 limit itself to their lowest common denominator of features.
712 Naturally, you might then think of shell scripts; who needs
713 `autoconf'? A set of properly written shell functions is enough to
714 make it easy to write `configure' scripts by hand. Sigh!
715 Unfortunately, shell functions do not belong to the least common
716 denominator; therefore, where you would like to define a function and
717 use it ten times, you would instead need to copy its body ten times.
719 So, what is really needed is some kind of compiler, `autoconf', that
720 takes an Autoconf program, `configure.ac', and transforms it into a
721 portable shell script, `configure'.
723 How does `autoconf' perform this task?
725 There are two obvious possibilities: creating a brand new language or
726 extending an existing one. The former option is very attractive: all
727 sorts of optimizations could easily be implemented in the compiler and
728 many rigorous checks could be performed on the Autoconf program (e.g.
729 rejecting any non-portable construct). Alternatively, you can extend
730 an existing language, such as the `sh' (Bourne shell) language.
732 Autoconf does the latter: it is a layer on top of `sh'. It was
733 therefore most convenient to implement `autoconf' as a macro expander:
734 a program that repeatedly performs "macro expansions" on text input,
735 replacing macro calls with macro bodies and producing a pure `sh'
736 script in the end. Instead of implementing a dedicated Autoconf macro
737 expander, it is natural to use an existing general-purpose macro
738 language, such as M4, and implement the extensions as a set of M4
742 File: autoconf.info, Node: Autoconf Language, Next: configure.ac Layout, Prev: Shell Script Compiler, Up: Writing configure.ac
744 The Autoconf Language
745 ---------------------
747 The Autoconf language is very different from many other computer
748 languages because it treats actual code the same as plain text. Whereas
749 in C, for instance, data and instructions have very different syntactic
750 status, in Autoconf their status is rigorously the same. Therefore, we
751 need a means to distinguish literal strings from text to be expanded:
754 When calling macros that take arguments, there must not be any blank
755 space between the macro name and the open parenthesis. Arguments should
756 be enclosed within the M4 quote characters `[' and `]', and be
757 separated by commas. Any leading spaces in arguments are ignored,
758 unless they are quoted. You may safely leave out the quotes when the
759 argument is simple text, but _always_ quote complex arguments such as
760 other macro calls. This rule applies recursively for every macro call,
761 including macros called from other macros.
765 AC_CHECK_HEADER([stdio.h],
766 [AC_DEFINE([HAVE_STDIO_H])],
767 [AC_MSG_ERROR([Sorry, can't do anything for you])])
769 is quoted properly. You may safely simplify its quotation to:
771 AC_CHECK_HEADER(stdio.h,
772 [AC_DEFINE(HAVE_STDIO_H)],
773 [AC_MSG_ERROR([Sorry, can't do anything for you])])
775 Notice that the argument of `AC_MSG_ERROR' is still quoted; otherwise,
776 its comma would have been interpreted as an argument separator.
778 The following example is wrong and dangerous, as it is underquoted:
780 AC_CHECK_HEADER(stdio.h,
781 AC_DEFINE(HAVE_STDIO_H),
782 AC_MSG_ERROR([Sorry, can't do anything for you]))
784 In other cases, you may have to use text that also resembles a macro
785 call. You must quote that text even when it is not passed as a macro
788 echo "Hard rock was here! --[AC_DC]"
792 echo "Hard rock was here! --AC_DC"
794 When you use the same text in a macro argument, you must therefore have
795 an extra quotation level (since one is stripped away by the macro
796 substitution). In general, then, it is a good idea to _use double
797 quoting for all literal string arguments_:
799 AC_MSG_WARN([[AC_DC stinks --Iron Maiden]])
801 You are now able to understand one of the constructs of Autoconf that
802 has been continually misunderstood... The rule of thumb is that
803 _whenever you expect macro expansion, expect quote expansion_; i.e.,
804 expect one level of quotes to be lost. For instance:
806 AC_COMPILE_IFELSE([char b[10];],, [AC_MSG_ERROR([you lose])])
808 is incorrect: here, the first argument of `AC_COMPILE_IFELSE' is `char
809 b[10];' and will be expanded once, which results in `char b10;'.
810 (There was an idiom common in Autoconf's past to address this issue via
811 the M4 `changequote' primitive, but do not use it!) Let's take a
812 closer look: the author meant the first argument to be understood as a
813 literal, and therefore it must be quoted twice:
815 AC_COMPILE_IFELSE([[char b[10];]],, [AC_MSG_ERROR([you lose])])
817 Voila`, you actually produce `char b[10];' this time!
819 The careful reader will notice that, according to these guidelines,
820 the "properly" quoted `AC_CHECK_HEADER' example above is actually
821 lacking three pairs of quotes! Nevertheless, for the sake of
822 readability, double quotation of literals is used only where needed in
825 Some macros take optional arguments, which this documentation
826 represents as [ARG] (not to be confused with the quote characters).
827 You may just leave them empty, or use `[]' to make the emptiness of the
828 argument explicit, or you may simply omit the trailing commas. The
829 three lines below are equivalent:
831 AC_CHECK_HEADERS(stdio.h, [], [], [])
832 AC_CHECK_HEADERS(stdio.h,,,)
833 AC_CHECK_HEADERS(stdio.h)
835 It is best to put each macro call on its own line in `configure.ac'.
836 Most of the macros don't add extra newlines; they rely on the newline
837 after the macro call to terminate the commands. This approach makes
838 the generated `configure' script a little easier to read by not
839 inserting lots of blank lines. It is generally safe to set shell
840 variables on the same line as a macro call, because the shell allows
841 assignments without intervening newlines.
843 You can include comments in `configure.ac' files by starting them
844 with the `#'. For example, it is helpful to begin `configure.ac' files
845 with a line like this:
847 # Process this file with autoconf to produce a configure script.
850 File: autoconf.info, Node: configure.ac Layout, Prev: Autoconf Language, Up: Writing configure.ac
852 Standard `configure.ac' Layout
853 ------------------------------
855 The order in which `configure.ac' calls the Autoconf macros is not
856 important, with a few exceptions. Every `configure.ac' must contain a
857 call to `AC_INIT' before the checks, and a call to `AC_OUTPUT' at the
858 end (*note Output::). Additionally, some macros rely on other macros
859 having been called first, because they check previously set values of
860 some variables to decide what to do. These macros are noted in the
861 individual descriptions (*note Existing Tests::), and they also warn
862 you when `configure' is created if they are called out of order.
864 To encourage consistency, here is a suggested order for calling the
865 Autoconf macros. Generally speaking, the things near the end of this
866 list are those that could depend on things earlier in it. For example,
867 library functions could be affected by types and libraries.
869 Autoconf requirements
870 `AC_INIT(PACKAGE, VERSION, BUG-REPORT-ADDRESS)'
871 information on the package
874 checks for header files
876 checks for structures
877 checks for compiler characteristics
878 checks for library functions
879 checks for system services
880 `AC_CONFIG_FILES([FILE...])'
884 File: autoconf.info, Node: autoscan Invocation, Next: ifnames Invocation, Prev: Writing configure.ac, Up: Making configure Scripts
886 Using `autoscan' to Create `configure.ac'
887 =========================================
889 The `autoscan' program can help you create and/or maintain a
890 `configure.ac' file for a software package. `autoscan' examines source
891 files in the directory tree rooted at a directory given as a command
892 line argument, or the current directory if none is given. It searches
893 the source files for common portability problems and creates a file
894 `configure.scan' which is a preliminary `configure.ac' for that
895 package, and checks a possibly existing `configure.ac' for completeness.
897 When using `autoscan' to create a `configure.ac', you should
898 manually examine `configure.scan' before renaming it to `configure.ac';
899 it will probably need some adjustments. Occasionally, `autoscan'
900 outputs a macro in the wrong order relative to another macro, so that
901 `autoconf' produces a warning; you need to move such macros manually.
902 Also, if you want the package to use a configuration header file, you
903 must add a call to `AC_CONFIG_HEADERS' (*note Configuration Headers::).
904 You might also have to change or add some `#if' directives to your
905 program in order to make it work with Autoconf (*note ifnames
906 Invocation::, for information about a program that can help with that
909 When using `autoscan' to maintain a `configure.ac', simply consider
910 adding its suggestions. The file `autoscan.log' will contain detailed
911 information on why a macro is requested.
913 `autoscan' uses several data files (installed along with Autoconf)
914 to determine which macros to output when it finds particular symbols in
915 a package's source files. These data files all have the same format:
916 each line consists of a symbol, whitespace, and the Autoconf macro to
917 output if that symbol is encountered. Lines starting with `#' are
920 `autoscan' is only installed if you already have Perl installed.
921 `autoscan' accepts the following options:
925 Print a summary of the command line options and exit.
929 Print the version number of Autoconf and exit.
933 Print the names of the files it examines and the potentially
934 interesting symbols it finds in them. This output can be
939 Override the location where the installed Autoconf data files are
940 looked for. You can also set the `AC_MACRODIR' environment
941 variable to a directory; this option overrides the environment
944 This option is rarely needed and dangerous; it is only used when
945 one plays with different versions of Autoconf simultaneously.
948 File: autoconf.info, Node: ifnames Invocation, Next: autoconf Invocation, Prev: autoscan Invocation, Up: Making configure Scripts
950 Using `ifnames' to List Conditionals
951 ====================================
953 `ifnames' can help you write `configure.ac' for a software package.
954 It prints the identifiers that the package already uses in C
955 preprocessor conditionals. If a package has already been set up to have
956 some portability, `ifnames' can thus help you figure out what its
957 `configure' needs to check for. It may help fill in some gaps in a
958 `configure.ac' generated by `autoscan' (*note autoscan Invocation::).
960 `ifnames' scans all of the C source files named on the command line
961 (or the standard input, if none are given) and writes to the standard
962 output a sorted list of all the identifiers that appear in those files
963 in `#if', `#elif', `#ifdef', or `#ifndef' directives. It prints each
964 identifier on a line, followed by a space-separated list of the files
965 in which that identifier occurs.
967 `ifnames' accepts the following options:
971 Print a summary of the command line options and exit.
975 Print the version number of Autoconf and exit.
978 File: autoconf.info, Node: autoconf Invocation, Next: autoreconf Invocation, Prev: ifnames Invocation, Up: Making configure Scripts
980 Using `autoconf' to Create `configure'
981 ======================================
983 To create `configure' from `configure.ac', run the `autoconf'
984 program with no arguments. `autoconf' processes `configure.ac' with
985 the `m4' macro processor, using the Autoconf macros. If you give
986 `autoconf' an argument, it reads that file instead of `configure.ac'
987 and writes the configuration script to the standard output instead of
988 to `configure'. If you give `autoconf' the argument `-', it reads from
989 the standard input instead of `configure.ac' and writes the
990 configuration script to the standard output.
992 The Autoconf macros are defined in several files. Some of the files
993 are distributed with Autoconf; `autoconf' reads them first. Then it
994 looks for the optional file `acsite.m4' in the directory that contains
995 the distributed Autoconf macro files, and for the optional file
996 `aclocal.m4' in the current directory. Those files can contain your
997 site's or the package's own Autoconf macro definitions (*note Writing
998 Autoconf Macros::, for more information). If a macro is defined in
999 more than one of the files that `autoconf' reads, the last definition
1000 it reads overrides the earlier ones.
1002 `autoconf' accepts the following options:
1006 Print a summary of the command line options and exit.
1010 Print the version number of Autoconf and exit.
1014 Report processing steps.
1018 Don't remove the temporary files.
1020 `--autoconf-dir=DIR'
1022 Override the location where the installed Autoconf data files are
1023 looked for. You can also set the `AC_MACRODIR' environment
1024 variable to a directory; this option overrides the environment
1027 This option is rarely needed and dangerous; it is only used when
1028 one plays with different versions of Autoconf simultaneously.
1032 Look for the package file `aclocal.m4' in directory DIR instead of
1033 in the current directory.
1037 Save output (script or trace) to FILE. The file `-' stands for
1038 the standard output.
1040 `--warnings=CATEGORY'
1042 Report the warnings related to CATEGORY (which can actually be a
1043 comma separated list). *Note Reporting Messages::, macro
1044 `AC_DIAGNOSE', for a comprehensive list of categories. Special
1048 report all the warnings
1054 treats warnings as errors
1057 disable warnings falling into CATEGORY
1059 Warnings about `syntax' are enabled by default, and the environment
1060 variable `WARNINGS', a comma separated list of categories, is
1061 honored. `autoconf -W CATEGORY' will actually behave as if you had
1064 autoconf --warnings=syntax,$WARNINGS,CATEGORY
1066 If you want to disable `autoconf''s defaults and `WARNINGS', but
1067 (for example) enable the warnings about obsolete constructs, you
1068 would use `-W none,obsolete'.
1070 `autoconf' displays a back trace for errors, but not for warnings;
1071 if you want them, just pass `-W error'. For instance, on this
1075 [AC_TRY_RUN([true])])
1086 configure.ac:8: warning: AC_TRY_RUN called without default \
1087 to allow cross compiling
1088 $ autoconf -Wcross,error
1089 configure.ac:8: error: AC_TRY_RUN called without default \
1090 to allow cross compiling
1091 acgeneral.m4:3044: AC_TRY_RUN is expanded from...
1092 configure.ac:2: INNER is expanded from...
1093 configure.ac:5: OUTER is expanded from...
1094 configure.ac:8: the top level
1096 `--trace=MACRO[:FORMAT]'
1098 Do not create the `configure' script, but list the calls to MACRO
1099 according to the FORMAT. Multiple `--trace' arguments can be used
1100 to list several macros. Multiple `--trace' arguments for a single
1101 macro are not cumulative; instead, you should just make FORMAT as
1104 The FORMAT is a regular string, with newlines if desired, and
1105 several special escape codes. It defaults to `$f:$l:$n:$%'; see
1106 below for details on the FORMAT.
1110 By default, `--trace' does not trace the initialization of the
1111 Autoconf macros (typically the `AC_DEFUN' definitions). This
1112 results in a noticeable speedup, but can be disabled by this
1115 It is often necessary to check the content of a `configure.ac' file,
1116 but parsing it yourself is extremely fragile and error-prone. It is
1117 suggested that you rely upon `--trace' to scan `configure.ac'.
1119 The FORMAT of `--trace' can use the following special escapes:
1125 The filename from which MACRO is called.
1128 The line number from which MACRO is called.
1131 The depth of the MACRO call. This is an M4 technical detail that
1132 you probably don't want to know about.
1135 The name of the MACRO.
1138 The NUMth argument of the call to MACRO.
1143 All the arguments passed to MACRO, separated by the character SEP
1144 or the string SEPARATOR (`,' by default). Each argument is
1145 quoted, i.e. enclosed in a pair of square brackets.
1150 As above, but the arguments are not quoted.
1155 As above, but the arguments are not quoted, all new line
1156 characters in the arguments are smashed, and the default separator
1159 The escape `$%' produces single-line trace outputs (unless you put
1160 newlines in the `separator'), while `$@' and `$*' do not.
1162 For instance, to find the list of variables that are substituted,
1165 $ autoconf -t AC_SUBST
1166 configure.ac:2:AC_SUBST:ECHO_C
1167 configure.ac:2:AC_SUBST:ECHO_N
1168 configure.ac:2:AC_SUBST:ECHO_T
1171 The example below highlights the difference between `$@', `$*', and
1175 AC_DEFINE(This, is, [an
1177 $ autoconf -t 'AC_DEFINE:@: $@
1184 $: This:is:an [example]
1186 The FORMAT gives you a lot of freedom:
1188 $ autoconf -t 'AC_SUBST:$$ac_subst{"$1"} = "$f:$l";'
1189 $ac_subst{"ECHO_C"} = "configure.ac:2";
1190 $ac_subst{"ECHO_N"} = "configure.ac:2";
1191 $ac_subst{"ECHO_T"} = "configure.ac:2";
1194 A long SEPARATOR can be used to improve the readability of complex
1195 structures, and to ease its parsing (for instance when no single
1196 character is suitable as a separator)):
1198 $ autoconf -t 'AM_MISSING_PROG:${|:::::|}*'
1199 ACLOCAL|:::::|aclocal|:::::|$missing_dir
1200 AUTOCONF|:::::|autoconf|:::::|$missing_dir
1201 AUTOMAKE|:::::|automake|:::::|$missing_dir
1205 File: autoconf.info, Node: autoreconf Invocation, Prev: autoconf Invocation, Up: Making configure Scripts
1207 Using `autoreconf' to Update `configure' Scripts
1208 ================================================
1210 If you have a lot of Autoconf-generated `configure' scripts, the
1211 `autoreconf' program can save you some work. It runs `autoconf' (and
1212 `autoheader', where appropriate) repeatedly to remake the Autoconf
1213 `configure' scripts and configuration header templates in the directory
1214 tree rooted at the current directory. By default, it only remakes
1215 those files that are older than their `configure.ac' or (if present)
1216 `aclocal.m4'. Since `autoheader' does not change the timestamp of its
1217 output file if the file wouldn't be changing, this is not necessarily
1218 the minimum amount of work. If you install a new version of Autoconf,
1219 you can make `autoreconf' remake _all_ of the files by giving it the
1222 If you give `autoreconf' the `--autoconf-dir=DIR' or
1223 `--localdir=DIR' options, it passes them down to `autoconf' and
1224 `autoheader' (with relative paths adjusted properly).
1226 `autoreconf' does not support having, in the same directory tree,
1227 both directories that are parts of a larger package (sharing
1228 `aclocal.m4' and `acconfig.h') and directories that are independent
1229 packages (each with their own `aclocal.m4' and `acconfig.h'). It
1230 assumes that they are all part of the same package if you use
1231 `--localdir', or that each directory is a separate package if you don't
1232 use it. This restriction may be removed in the future.
1234 *Note Automatic Remaking::, for `Makefile' rules to automatically
1235 remake `configure' scripts when their source files change. That method
1236 handles the timestamps of configuration header templates properly, but
1237 does not pass `--autoconf-dir=DIR' or `--localdir=DIR'.
1239 `autoreconf' accepts the following options:
1243 Print a summary of the command line options and exit.
1247 Print the version number of Autoconf and exit.
1250 Print the name of each directory where `autoreconf' runs
1251 `autoconf' (and `autoheader', if appropriate).
1255 Don't remove the temporary files.
1259 Remake even `configure' scripts and configuration headers that are
1260 newer than their input files (`configure.ac' and, if present,
1265 Copy missing auxiliary files. This option is similar to the option
1266 `--add-missing' in `automake'.
1270 Instead of copying missing auxiliary files, install symbolic links.
1274 Have `autoconf' and `autoheader' look for the package files
1275 `aclocal.m4' and (`autoheader' only) `acconfig.h' (but not
1276 `FILE.top' and `FILE.bot') in directory DIR instead of in the
1277 directory containing each `configure.ac'.
1279 `--autoconf-dir=DIR'
1281 Override the location where the installed Autoconf data files are
1282 looked for. You can also set the `AC_MACRODIR' environment
1283 variable to a directory; this option overrides the environment
1286 This option is rarely needed and dangerous; it is only used when
1287 one plays with different versions of Autoconf simultaneously.
1291 Specify location of additional macro files (`m4' by default).
1293 Additionally, the following options are recognized and passed to
1297 Assume program is part of Cygnus-style tree.
1300 Set strictness to foreign.
1303 Set strictness to gnits.
1306 Set strictness to gnu.
1309 Include generated dependencies in `Makefile.in'.
1312 File: autoconf.info, Node: Setup, Next: Existing Tests, Prev: Making configure Scripts, Up: Top
1314 Initialization and Output Files
1315 *******************************
1317 Autoconf-generated `configure' scripts need some information about
1318 how to initialize, such as how to find the package's source files; and
1319 about the output files to produce. The following sections describe
1320 initialization and the creation of output files.
1324 * Notices:: Copyright, version numbers in `configure'
1325 * Input:: Where Autoconf should find files
1326 * Output:: Outputting results from the configuration
1327 * Configuration Actions:: Preparing the output based on results
1328 * Configuration Files:: Creating output files
1329 * Makefile Substitutions:: Using output variables in `Makefile's
1330 * Configuration Headers:: Creating a configuration header file
1331 * Configuration Commands:: Running arbitrary instantiation commands
1332 * Configuration Links:: Links depending from the configuration
1333 * Subdirectories:: Configuring independent packages together
1334 * Default Prefix:: Changing the default installation prefix
1337 File: autoconf.info, Node: Notices, Next: Input, Prev: Setup, Up: Setup
1339 Notices in `configure'
1340 ======================
1342 The following macros manage version numbers for `configure' scripts.
1343 Using them is optional.
1345 - Macro: AC_PREREQ (VERSION)
1346 Ensure that a recent enough version of Autoconf is being used. If
1347 the version of Autoconf being used to create `configure' is earlier
1348 than VERSION, print an error message to the standard error output
1349 and do not create `configure'. For example:
1353 This macro is the only macro that may be used before `AC_INIT', but
1354 for consistency, you are invited not to do so.
1356 - Macro: AC_COPYRIGHT (COPYRIGHT-NOTICE)
1357 State that, in addition to the Free Software Foundation's
1358 copyright on the Autoconf macros, parts of your `configure' are
1359 covered by the COPYRIGHT-NOTICE.
1361 The COPYRIGHT-NOTICE will show up in both the head of `configure'
1362 and in `configure --version'.
1364 - Macro: AC_REVISION (REVISION-INFO)
1365 Copy revision stamp REVISION-INFO into the `configure' script,
1366 with any dollar signs or double-quotes removed. This macro lets
1367 you put a revision stamp from `configure.ac' into `configure'
1368 without RCS or `cvs' changing it when you check in `configure'.
1369 That way, you can determine easily which revision of
1370 `configure.ac' a particular `configure' corresponds to.
1372 For example, this line in `configure.ac':
1374 AC_REVISION($Revision: 1.1.1.1 $)
1376 produces this in `configure':
1379 # From configure.ac Revision: 1.30
1382 File: autoconf.info, Node: Input, Next: Output, Prev: Notices, Up: Setup
1384 Finding `configure' Input
1385 =========================
1387 Every `configure' script must call `AC_INIT' before doing anything
1388 else. The only other required macro is `AC_OUTPUT' (*note Output::).
1390 - Macro: AC_INIT (PACKAGE, VERSION, [BUG-REPORT-ADDRESS])
1391 Process any command-line arguments and perform various
1392 initializations and verifications. Set the name of the PACKAGE
1393 and its VERSION. The optional argument BUG-REPORT-ADDRESS should
1394 be the email to which users should send bug reports.
1396 - Macro: AC_CONFIG_SRCDIR (UNIQUE-FILE-IN-SOURCE-DIR)
1397 UNIQUE-FILE-IN-SOURCE-DIR is some file that is in the package's
1398 source directory; `configure' checks for this file's existence to
1399 make sure that the directory that it is told contains the source
1400 code in fact does. Occasionally people accidentally specify the
1401 wrong directory with `--srcdir'; this is a safety check. *Note
1402 configure Invocation::, for more information.
1404 Packages that do manual configuration or use the `install' program
1405 might need to tell `configure' where to find some other shell scripts
1406 by calling `AC_CONFIG_AUX_DIR', though the default places it looks are
1407 correct for most cases.
1409 - Macro: AC_CONFIG_AUX_DIR (DIR)
1410 Use the auxiliary build tools (e.g., `install-sh', `config.sub',
1411 `config.guess', Cygnus `configure', Automake and Libtool scripts
1412 etc.) that are in directory DIR. These are auxiliary files used
1413 in configuration. DIR can be either absolute or relative to
1414 `SRCDIR'. The default is `SRCDIR' or `SRCDIR/..' or
1415 `SRCDIR/../..', whichever is the first that contains `install-sh'.
1416 The other files are not checked for, so that using
1417 `AC_PROG_INSTALL' does not automatically require distributing the
1418 other auxiliary files. It checks for `install.sh' also, but that
1419 name is obsolete because some `make' have a rule that creates
1420 `install' from it if there is no `Makefile'.
1423 File: autoconf.info, Node: Output, Next: Configuration Actions, Prev: Input, Up: Setup
1428 Every Autoconf-generated `configure' script must finish by calling
1429 `AC_OUTPUT'. It is the macro that generates `config.status', which
1430 will create the `Makefile's and any other files resulting from
1431 configuration. The only other required macro is `AC_INIT' (*note
1435 Generate `config.status' and launch it. Call this macro once, at
1436 the end of `configure.ac'.
1438 `config.status' will take all the configuration actions: all the
1439 output files (see *Note Configuration Files::, macro
1440 `AC_CONFIG_FILES'), header files (see *Note Configuration
1441 Headers::, macro `AC_CONFIG_HEADERS'), commands (see *Note
1442 Configuration Commands::, macro `AC_CONFIG_COMMANDS'), links (see
1443 *Note Configuration Links::, macro `AC_CONFIG_LINKS'),
1444 subdirectories to configure (see *Note Subdirectories::, macro
1445 `AC_CONFIG_SUBDIRS') are honored.
1447 Historically, the usage of `AC_OUTPUT' was somewhat different.
1448 *Note Obsolete Macros::, for a description of the arguments that
1449 `AC_OUTPUT' used to support.
1451 If you run `make' on subdirectories, you should run it using the
1452 `make' variable `MAKE'. Most versions of `make' set `MAKE' to the name
1453 of the `make' program plus any options it was given. (But many do not
1454 include in it the values of any variables set on the command line, so
1455 those are not passed on automatically.) Some old versions of `make' do
1456 not set this variable. The following macro allows you to use it even
1457 with those versions.
1459 - Macro: AC_PROG_MAKE_SET
1460 If `make' predefines the variable `MAKE', define output variable
1461 `SET_MAKE' to be empty. Otherwise, define `SET_MAKE' to contain
1462 `MAKE=make'. Calls `AC_SUBST' for `SET_MAKE'.
1464 To use this macro, place a line like this in each `Makefile.in' that
1465 runs `MAKE' on other directories:
1470 File: autoconf.info, Node: Configuration Actions, Next: Configuration Files, Prev: Output, Up: Setup
1472 Taking Configuration Actions
1473 ============================
1475 `configure' is designed so that it appears to do everything itself,
1476 but there is actually a hidden slave: `config.status'. `configure' is
1477 in charge of examining your system, but it is `config.status' that
1478 actually takes the proper actions based on the results of `configure'.
1479 The most typical task of `config.status' is to _instantiate_ files.
1481 This section describes the common behavior of the four standard
1482 instantiating macros: `AC_CONFIG_FILES', `AC_CONFIG_HEADERS',
1483 `AC_CONFIG_COMMANDS' and `AC_CONFIG_LINKS'. They all have this
1486 AC_CONFIG_FOOS(TAG..., [COMMANDS], [INIT-CMDS])
1488 where the arguments are:
1491 A whitespace-separated list of tags, which are typically the names
1492 of the files to instantiate.
1495 Shell commands output literally into `config.status', and
1496 associated with a tag that the user can use to tell `config.status'
1497 which the commands to run. The commands are run each time a TAG
1498 request is given to `config.status'; typically, each time the file
1502 Shell commands output _unquoted_ near the beginning of
1503 `config.status', and executed each time `config.status' runs
1504 (regardless of the tag). Because they are unquoted, for example,
1505 `$var' will be output as the value of `var'. INIT-CMDS is
1506 typically used by `configure' to give `config.status' some
1507 variables it needs to run the COMMANDS.
1509 All these macros can be called multiple times, with different TAGs,
1512 You are encouraged to use literals as TAGS. In particular, you
1515 ... && my_foos="$my_foos fooo"
1516 ... && my_foos="$my_foos foooo"
1517 AC_CONFIG_FOOS($my_foos)
1519 and use this instead:
1521 ... && AC_CONFIG_FOOS(fooo)
1522 ... && AC_CONFIG_FOOS(foooo)
1524 The macro `AC_CONFIG_FILES' and `AC_CONFIG_HEADERS' use specials
1525 TAGs: they may have the form `OUTPUT' or `OUTPUT:INPUTS'. The file
1526 OUTPUT is instantiated from its templates, INPUTS if specified,
1527 defaulting to `OUTPUT.in'.
1529 For instance `AC_CONFIG_FILES(Makefile:boiler/top.mk:boiler/bot.mk)'
1530 asks for the creation of `Makefile' that will be the expansion of the
1531 output variables in the concatenation of `boiler/top.mk' and
1534 The special value `-' might be used to denote the standard output
1535 when used in OUTPUT, or the standard input when used in the INPUTS.
1536 You most probably don't need to use this in `configure.ac', but it is
1537 convenient when using the command line interface of `./config.status',
1538 see *Note config.status Invocation::, for more details.
1540 The INPUTS may be absolute or relative filenames. In the latter
1541 case they are first looked for in the build tree, and then in the source
1545 File: autoconf.info, Node: Configuration Files, Next: Makefile Substitutions, Prev: Configuration Actions, Up: Setup
1547 Creating Configuration Files
1548 ============================
1550 Be sure to read the previous section, *Note Configuration Actions::.
1552 - Macro: AC_CONFIG_FILES (FILE..., [CMDS], [INIT-CMDS])
1553 Make `AC_OUTPUT' create each `FILE' by copying an input file (by
1554 default `FILE.in'), substituting the output variable values. This
1555 macro is one of the instantiating macros, see *Note Configuration
1556 Actions::. *Note Makefile Substitutions::, for more information
1557 on using output variables. *Note Setting Output Variables::, for
1558 more information on creating them. This macro creates the
1559 directory that the file is in if it doesn't exist. Usually,
1560 `Makefile's are created this way, but other files, such as
1561 `.gdbinit', can be specified as well.
1563 Typical calls to `AC_CONFIG_FILES' look like this:
1565 AC_CONFIG_FILES(Makefile src/Makefile man/Makefile X/Imakefile)
1566 AC_CONFIG_FILES(autoconf, chmod +x autoconf)
1568 You can override an input file name by appending to FILE a
1569 colon-separated list of input files. Examples:
1571 AC_CONFIG_FILES(Makefile:boiler/top.mk:boiler/bot.mk
1572 lib/Makefile:boiler/lib.mk)
1574 Doing this allows you to keep your file names acceptable to
1575 MS-DOS, or to prepend and/or append boilerplate to the file.
1578 File: autoconf.info, Node: Makefile Substitutions, Next: Configuration Headers, Prev: Configuration Files, Up: Setup
1580 Substitutions in Makefiles
1581 ==========================
1583 Each subdirectory in a distribution that contains something to be
1584 compiled or installed should come with a file `Makefile.in', from which
1585 `configure' will create a `Makefile' in that directory. To create a
1586 `Makefile', `configure' performs a simple variable substitution,
1587 replacing occurrences of `@VARIABLE@' in `Makefile.in' with the value
1588 that `configure' has determined for that variable. Variables that are
1589 substituted into output files in this way are called "output
1590 variables". They are ordinary shell variables that are set in
1591 `configure'. To make `configure' substitute a particular variable into
1592 the output files, the macro `AC_SUBST' must be called with that
1593 variable name as an argument. Any occurrences of `@VARIABLE@' for
1594 other variables are left unchanged. *Note Setting Output Variables::,
1595 for more information on creating output variables with `AC_SUBST'.
1597 A software package that uses a `configure' script should be
1598 distributed with a file `Makefile.in', but no `Makefile'; that way, the
1599 user has to properly configure the package for the local system before
1602 *Note Makefile Conventions: (standards)Makefile Conventions, for
1603 more information on what to put in `Makefile's.
1607 * Preset Output Variables:: Output variables that are always set
1608 * Installation Directory Variables:: Other preset output variables
1609 * Build Directories:: Supporting multiple concurrent compiles
1610 * Automatic Remaking:: Makefile rules for configuring
1613 File: autoconf.info, Node: Preset Output Variables, Next: Installation Directory Variables, Prev: Makefile Substitutions, Up: Makefile Substitutions
1615 Preset Output Variables
1616 -----------------------
1618 Some output variables are preset by the Autoconf macros. Some of the
1619 Autoconf macros set additional output variables, which are mentioned in
1620 the descriptions for those macros. *Note Output Variable Index::, for a
1621 complete list of output variables. *Note Installation Directory
1622 Variables::, for the list of the preset ones related to installation
1623 directories. Below are listed the other preset ones. They all are
1624 precious variables (*note Setting Output Variables::, `AC_ARG_VAR').
1627 Debugging and optimization options for the C compiler. If it is
1628 not set in the environment when `configure' runs, the default
1629 value is set when you call `AC_PROG_CC' (or empty if you don't).
1630 `configure' uses this variable when compiling programs to test for
1633 - Variable: configure_input
1634 A comment saying that the file was generated automatically by
1635 `configure' and giving the name of the input file. `AC_OUTPUT'
1636 adds a comment line containing this variable to the top of every
1637 `Makefile' it creates. For other files, you should reference this
1638 variable in a comment at the top of each input file. For example,
1639 an input shell script should begin like this:
1644 The presence of that line also reminds people editing the file
1645 that it needs to be processed by `configure' in order to be used.
1647 - Variable: CPPFLAGS
1648 Header file search directory (`-IDIR') and any other miscellaneous
1649 options for the C and C++ preprocessors and compilers. If it is
1650 not set in the environment when `configure' runs, the default
1651 value is empty. `configure' uses this variable when compiling or
1652 preprocessing programs to test for C and C++ features.
1654 - Variable: CXXFLAGS
1655 Debugging and optimization options for the C++ compiler. If it is
1656 not set in the environment when `configure' runs, the default
1657 value is set when you call `AC_PROG_CXX' (or empty if you don't).
1658 `configure' uses this variable when compiling programs to test for
1662 `-D' options to pass to the C compiler. If `AC_CONFIG_HEADERS' is
1663 called, `configure' replaces `@DEFS@' with `-DHAVE_CONFIG_H'
1664 instead (*note Configuration Headers::). This variable is not
1665 defined while `configure' is performing its tests, only when
1666 creating the output files. *Note Setting Output Variables::, for
1667 how to check the results of previous tests.
1672 How does one suppress the trailing newline from `echo' for
1673 question-answer message pairs? These variables provide a way:
1675 echo $ECHO_N "And the winner is... $ECHO_C"
1677 echo "${ECHO_T}dead."
1679 Some old and uncommon `echo' implementations offer no means to
1680 achieve this, in which case `ECHO_T' is set to tab. You might not
1684 Debugging and optimization options for the Fortran 77 compiler.
1685 If it is not set in the environment when `configure' runs, the
1686 default value is set when you call `AC_PROG_F77' (or empty if you
1687 don't). `configure' uses this variable when compiling programs to
1688 test for Fortran 77 features.
1691 Stripping (`-s'), path (`-L'), and any other miscellaneous options
1692 for the linker. Don't use this variable to pass library names
1693 (`-l') to the linker, use `LIBS' instead. If it is not set in the
1694 environment when `configure' runs, the default value is empty.
1695 `configure' uses this variable when linking programs to test for
1696 C, C++ and Fortran 77 features.
1699 `-l' options to pass to the linker. The default value is empty,
1700 but some Autoconf macros may prepend extra libraries to this
1701 variable if those libraries are found and provide necessary
1702 functions, see *Note Libraries::. `configure' uses this variable
1703 when linking programs to test for C, C++ and Fortran 77 features.
1706 The directory that contains the source code for that `Makefile'.
1708 - Variable: top_srcdir
1709 The top-level source code directory for the package. In the
1710 top-level directory, this is the same as `srcdir'.
1713 File: autoconf.info, Node: Installation Directory Variables, Next: Build Directories, Prev: Preset Output Variables, Up: Makefile Substitutions
1715 Installation Directory Variables
1716 --------------------------------
1718 The following variables specify the directories where the package
1719 will be installed, see *Note Variables for Installation Directories:
1720 (standards)Directory Variables, for more information. See the end of
1721 this section for details on when and how to use these variables.
1724 The directory for installing executables that users run.
1727 The directory for installing read-only architecture-independent
1730 - Variable: exec_prefix
1731 The installation prefix for architecture-dependent files. By
1732 default it's the same as PREFIX. You should avoid installing
1733 anything directly to EXEC_PREFIX. However, the default value for
1734 directories containing architecture-dependent files should be
1735 relative to EXEC_PREFIX.
1737 - Variable: includedir
1738 The directory for installing C header files.
1741 The directory for installing documentation in Info format.
1744 The directory for installing object code libraries.
1746 - Variable: libexecdir
1747 The directory for installing executables that other programs run.
1749 - Variable: localstatedir
1750 The directory for installing modifiable single-machine data.
1753 The top-level directory for installing documentation in man format.
1755 - Variable: oldincludedir
1756 The directory for installing C header files for non-gcc compilers.
1759 The common installation prefix for all files. If EXEC_PREFIX is
1760 defined to a different value, PREFIX is used only for
1761 architecture-independent files.
1764 The directory for installing executables that system
1767 - Variable: sharedstatedir
1768 The directory for installing modifiable architecture-independent
1771 - Variable: sysconfdir
1772 The directory for installing read-only single-machine data.
1774 Most of these variables have values that rely on `prefix' or
1775 `exec_prefix'. It is on purpose that the directory output variables
1776 keep them unexpanded: typically `@datadir@' will be replaced by
1777 `${prefix}/share', not `/usr/local/share'.
1779 This behavior is mandated by the GNU coding standards, so that when
1783 she can still specify a different prefix from the one specified to
1784 `configure', in which case, if needed, the package shall hard code
1785 dependencies to her late desires.
1788 she can specify a different installation location, in which case
1789 the package _must_ still depend on the location which was compiled
1790 in (i.e., never recompile when `make install' is run). This is an
1791 extremely important feature, as many people may decide to install
1792 all the files of a package grouped together, and then install
1793 links from the final locations to there.
1795 In order to support these features, it is essential that `datadir'
1796 remains being defined as `${prefix}/share' to depend upon the current
1799 A corollary is that you should not use these variables but in
1800 Makefiles. For instance, instead of trying to evaluate `datadir' in
1801 `configure' and hardcoding it in Makefiles using e.g.
1802 `AC_DEFINE_UNQUOTED(DATADIR, "$datadir")', you should add
1803 `-DDATADIR="$(datadir)"' to your `CPPFLAGS'.
1805 Similarly you should not rely on `AC_OUTPUT_FILES' to replace
1806 `datadir' and friends in your shell scripts and other files, rather let
1807 `make' manage their replacement. For instance Autoconf ships templates
1808 of its shell scripts ending with `.sh', and uses this Makefile snippet:
1812 sed 's,@datadir\@,$(pkgdatadir),g' $< >$@.tmp
1816 Three things are noteworthy:
1819 The backslash prevents `configure' from replacing `@datadir@' in
1820 the sed expression itself.
1823 Don't use `@pkgdatadir@'! Use the matching makefile variable
1827 Don't use `/' in the sed expression(s) since most probably the
1828 variables you use, such as `$(pkgdatadir)', will contain some.
1831 File: autoconf.info, Node: Build Directories, Next: Automatic Remaking, Prev: Installation Directory Variables, Up: Makefile Substitutions
1836 You can support compiling a software package for several
1837 architectures simultaneously from the same copy of the source code.
1838 The object files for each architecture are kept in their own directory.
1840 To support doing this, `make' uses the `VPATH' variable to find the
1841 files that are in the source directory. GNU `make' and most other
1842 recent `make' programs can do this. Older `make' programs do not
1843 support `VPATH'; when using them, the source code must be in the same
1844 directory as the object files.
1846 To support `VPATH', each `Makefile.in' should contain two lines that
1852 Do not set `VPATH' to the value of another variable, for example
1853 `VPATH = $(srcdir)', because some versions of `make' do not do variable
1854 substitutions on the value of `VPATH'.
1856 `configure' substitutes in the correct value for `srcdir' when it
1857 produces `Makefile'.
1859 Do not use the `make' variable `$<', which expands to the file name
1860 of the file in the source directory (found with `VPATH'), except in
1861 implicit rules. (An implicit rule is one such as `.c.o', which tells
1862 how to create a `.o' file from a `.c' file.) Some versions of `make'
1863 do not set `$<' in explicit rules; they expand it to an empty value.
1865 Instead, `Makefile' command lines should always refer to source
1866 files by prefixing them with `$(srcdir)/'. For example:
1868 time.info: time.texinfo
1869 $(MAKEINFO) $(srcdir)/time.texinfo
1872 File: autoconf.info, Node: Automatic Remaking, Prev: Build Directories, Up: Makefile Substitutions
1877 You can put rules like the following in the top-level `Makefile.in'
1878 for a package to automatically update the configuration information when
1879 you change the configuration files. This example includes all of the
1880 optional files, such as `aclocal.m4' and those related to configuration
1881 header files. Omit from the `Makefile.in' rules for any of these files
1882 that your package does not use.
1884 The `$(srcdir)/' prefix is included because of limitations in the
1887 The `stamp-' files are necessary because the timestamps of
1888 `config.h.in' and `config.h' will not be changed if remaking them does
1889 not change their contents. This feature avoids unnecessary
1890 recompilation. You should include the file `stamp-h.in' your package's
1891 distribution, so `make' will consider `config.h.in' up to date. Don't
1892 use `touch' (*note Limitations of Usual Tools::), rather use `echo'
1893 (using `date' would cause needless differences, hence CVS conflicts
1896 $(srcdir)/configure: configure.ac aclocal.m4
1897 cd $(srcdir) && autoconf
1899 # autoheader might not change config.h.in, so touch a stamp file.
1900 $(srcdir)/config.h.in: stamp-h.in
1901 $(srcdir)/stamp-h.in: configure.ac aclocal.m4
1902 cd $(srcdir) && autoheader
1903 echo timestamp > $(srcdir)/stamp-h.in
1906 stamp-h: config.h.in config.status
1909 Makefile: Makefile.in config.status
1912 config.status: configure
1913 ./config.status --recheck
1915 (Be careful if you copy these lines directly into your Makefile, as you
1916 will need to convert the indented lines to start with the tab
1919 In addition, you should use `AC_CONFIG_FILES(stamp-h, echo timestamp
1920 > stamp-h)' so `config.status' will ensure that `config.h' is
1921 considered up to date. *Note Output::, for more information about
1924 *Note config.status Invocation::, for more examples of handling
1925 configuration-related dependencies.
1928 File: autoconf.info, Node: Configuration Headers, Next: Configuration Commands, Prev: Makefile Substitutions, Up: Setup
1930 Configuration Header Files
1931 ==========================
1933 When a package tests more than a few C preprocessor symbols, the
1934 command lines to pass `-D' options to the compiler can get quite long.
1935 This causes two problems. One is that the `make' output is hard to
1936 visually scan for errors. More seriously, the command lines can exceed
1937 the length limits of some operating systems. As an alternative to
1938 passing `-D' options to the compiler, `configure' scripts can create a
1939 C header file containing `#define' directives. The `AC_CONFIG_HEADERS'
1940 macro selects this kind of output. It should be called right after
1943 The package should `#include' the configuration header file before
1944 any other header files, to prevent inconsistencies in declarations (for
1945 example, if it redefines `const'). Use `#include <config.h>' instead
1946 of `#include "config.h"', and pass the C compiler a `-I.' option (or
1947 `-I..'; whichever directory contains `config.h'). That way, even if
1948 the source directory is configured itself (perhaps to make a
1949 distribution), other build directories can also be configured without
1950 finding the `config.h' from the source directory.
1952 - Macro: AC_CONFIG_HEADERS (HEADER ..., [CMDS], [INIT-CMDS])
1953 This macro is one of the instantiating macros, see *Note
1954 Configuration Actions::. Make `AC_OUTPUT' create the file(s) in
1955 the whitespace-separated list HEADER containing C preprocessor
1956 `#define' statements, and replace `@DEFS@' in generated files with
1957 `-DHAVE_CONFIG_H' instead of the value of `DEFS'. The usual name
1958 for HEADER is `config.h'.
1960 If HEADER already exists and its contents are identical to what
1961 `AC_OUTPUT' would put in it, it is left alone. Doing this allows
1962 some changes in configuration without needlessly causing object
1963 files that depend on the header file to be recompiled.
1965 Usually the input file is named `HEADER.in'; however, you can
1966 override the input file name by appending to HEADER, a
1967 colon-separated list of input files. Examples:
1969 AC_CONFIG_HEADERS(config.h:config.hin)
1970 AC_CONFIG_HEADERS(defines.h:defs.pre:defines.h.in:defs.post)
1972 Doing this allows you to keep your file names acceptable to
1973 MS-DOS, or to prepend and/or append boilerplate to the file.
1975 *Note Configuration Actions::, for more details on HEADER.
1979 * Header Templates:: Input for the configuration headers
1980 * autoheader Invocation:: How to create configuration templates
1981 * Autoheader Macros:: How to specify CPP templates
1984 File: autoconf.info, Node: Header Templates, Next: autoheader Invocation, Prev: Configuration Headers, Up: Configuration Headers
1986 Configuration Header Templates
1987 ------------------------------
1989 Your distribution should contain a template file that looks as you
1990 want the final header file to look, including comments, with `#undef'
1991 statements which are used as hooks. For example, suppose your
1992 `configure.ac' makes these calls:
1994 AC_CONFIG_HEADERS(conf.h)
1995 AC_CHECK_HEADERS(unistd.h)
1997 Then you could have code like the following in `conf.h.in'. On systems
1998 that have `unistd.h', `configure' will `#define' `HAVE_UNISTD_H' to 1.
1999 On other systems, the whole line will be commented out (in case the
2000 system predefines that symbol).
2002 /* Define as 1 if you have unistd.h. */
2003 #undef HAVE_UNISTD_H
2005 You can then decode the configuration header using the preprocessor
2011 # include <unistd.h>
2013 /* We are in trouble. */
2016 The use of old form templates, with `#define' instead of `#undef' is
2017 strongly discouraged.
2019 Since it is a tedious task to keep a template header up to date, you
2020 may use `autoheader' to generate it, see *Note autoheader Invocation::.
2023 File: autoconf.info, Node: autoheader Invocation, Next: Autoheader Macros, Prev: Header Templates, Up: Configuration Headers
2025 Using `autoheader' to Create `config.h.in'
2026 ------------------------------------------
2028 The `autoheader' program can create a template file of C `#define'
2029 statements for `configure' to use. If `configure.ac' invokes
2030 `AC_CONFIG_HEADERS(FILE)', `autoheader' creates `FILE.in'; if multiple
2031 file arguments are given, the first one is used. Otherwise,
2032 `autoheader' creates `config.h.in'.
2034 In order to do its job, `autoheader' needs you to document all of
2035 the symbols that you might use; i.e., there must be at least one
2036 `AC_DEFINE' or one `AC_DEFINE_UNQUOTED' using its third argument for
2037 each symbol (*note Defining Symbols::). An additional constraint is
2038 that the first argument of `AC_DEFINE' must be a literal. Note that
2039 all symbols defined by Autoconf's built-in tests are already documented
2040 properly; you only need to document those that you define yourself.
2042 You might wonder why `autoheader' is needed: after all, why would
2043 `configure' need to "patch" a `config.h.in' to produce a `config.h'
2044 instead of just creating `config.h' from scratch? Well, when
2045 everything rocks, the answer is just that we are wasting our time
2046 maintaining `autoheader': generating `config.h' directly is all that is
2047 needed. When things go wrong, however, you'll be thankful for the
2048 existence of `autoheader'.
2050 The fact that the symbols are documented is important in order to
2051 _check_ that `config.h' makes sense. The fact that there is a well
2052 defined list of symbols that should be `#define''d (or not) is also
2053 important for people who are porting packages to environments where
2054 `configure' cannot be run: they just have to _fill in the blanks_.
2056 But let's come back to the point: `autoheader''s invocation...
2058 If you give `autoheader' an argument, it uses that file instead of
2059 `configure.ac' and writes the header file to the standard output
2060 instead of to `config.h.in'. If you give `autoheader' an argument of
2061 `-', it reads the standard input instead of `configure.ac' and writes
2062 the header file to the standard output.
2064 `autoheader' accepts the following options:
2068 Print a summary of the command line options and exit.
2072 Print the version number of Autoconf and exit.
2076 Don't remove the temporary files.
2080 Report processing steps.
2082 `--autoconf-dir=DIR'
2084 Override the location where the installed Autoconf data files are
2085 looked for. You can also set the `AC_MACRODIR' environment
2086 variable to a directory; this option overrides the environment
2089 This option is rarely needed and dangerous; it is only used when
2090 one plays with different versions of Autoconf simultaneously.
2094 Look for the package files `aclocal.m4' and `acconfig.h' (but not
2095 `FILE.top' and `FILE.bot') in directory DIR instead of in the
2098 `--warnings=CATEGORY'
2100 Report the warnings related to CATEGORY (which can actually be a
2101 comma separated list). Current categories include:
2104 report the uses of obsolete constructs
2107 report all the warnings
2113 treats warnings as errors
2116 disable warnings falling into CATEGORY
2119 File: autoconf.info, Node: Autoheader Macros, Prev: autoheader Invocation, Up: Configuration Headers
2124 `autoheader' scans `configure.ac' and figures out which C
2125 preprocessor symbols it might define. It knows how to generate
2126 templates for symbols defined by `AC_CHECK_HEADERS', `AC_CHECK_FUNCS'
2127 etc., but if you `AC_DEFINE' any additional symbol, you must define a
2128 template for it. If there are missing templates, `autoheader' fails
2129 with an error message.
2131 The simplest way to create a template for a SYMBOL is to supply the
2132 DESCRIPTION argument to an `AC_DEFINE(SYMBOL)'; see *Note Defining
2133 Symbols::. You may also use one of the following macros.
2135 - Macro: AH_VERBATIM (KEY, TEMPLATE)
2136 Tell `autoheader' to include the TEMPLATE as-is in the header
2137 template file. This TEMPLATE is associated with the KEY, which is
2138 used to sort all the different templates and guarantee their
2139 uniqueness. It should be the symbol that can be `AC_DEFINE''d.
2143 AH_VERBATIM([_GNU_SOURCE],
2144 [/* Enable GNU extensions on systems that have them. */
2146 # define _GNU_SOURCE
2149 - Macro: AH_TEMPLATE (KEY, DESCRIPTION)
2150 Tell `autoheader' to generate a template for KEY. This macro
2151 generates standard templates just like `AC_DEFINE' when a
2152 DESCRIPTION is given.
2156 AH_TEMPLATE([CRAY_STACKSEG_END],
2157 [Define to one of _getb67, GETB67, getb67
2158 for Cray-2 and Cray-YMP systems. This
2159 function is required for alloca.c support
2162 will generate the following template, with the description properly
2165 /* Define to one of _getb67, GETB67, getb67 for Cray-2 and
2166 Cray-YMP systems. This function is required for alloca.c
2167 support on those systems. */
2168 #undef CRAY_STACKSEG_END
2170 - Macro: AH_TOP (TEXT)
2171 Include TEXT at the top of the header template file.
2173 - Macro: AH_BOTTOM (TEXT)
2174 Include TEXT at the bottom of the header template file.
2177 File: autoconf.info, Node: Configuration Commands, Next: Configuration Links, Prev: Configuration Headers, Up: Setup
2179 Running Arbitrary Configuration Commands
2180 ========================================
2182 You execute arbitrary commands either before, during and after
2183 `config.status' is run. The three following macros accumulate the
2184 commands to run when they are called multiple times.
2185 `AC_CONFIG_COMMANDS' replaces the obsolete macro `AC_OUTPUT_COMMANDS',
2186 see *Note Obsolete Macros::, for details.
2188 - Macro: AC_CONFIG_COMMANDS (TAG..., [CMDS], [INIT-CMDS])
2189 Specify additional shell commands to run at the end of
2190 `config.status', and shell commands to initialize any variables
2191 from `configure'. Associate the commands to the TAG. Since
2192 typically the CMDS create a file, TAG should naturally be the name
2193 of that file. This macro is one of the instantiating macros, see
2194 *Note Configuration Actions::.
2196 Here is an unrealistic example:
2198 AC_CONFIG_COMMANDS(fubar,
2199 [echo this is extra $fubar, and so on.],
2202 Here is a better one:
2203 AC_CONFIG_COMMANDS(time-stamp, [date >time-stamp])
2205 - Macro: AC_CONFIG_COMMANDS_PRE (CMDS)
2206 Execute the CMDS right before creating `config.status'. A typical
2207 use is computing values derived from variables built during the
2208 execution of `configure':
2210 AC_CONFIG_COMMANDS_PRE(
2211 [LTLIBOBJS=`echo $LIBOBJS | sed 's/\.o/\.lo/g'`
2212 AC_SUBST(LTLIBOBJS)])
2214 - Macro: AC_CONFIG_COMMANDS_POST (CMDS)
2215 Execute the CMDS right after creating `config.status'.
2218 File: autoconf.info, Node: Configuration Links, Next: Subdirectories, Prev: Configuration Commands, Up: Setup
2220 Creating Configuration Links
2221 ============================
2223 You may find it convenient to create links whose destinations depend
2224 upon results of tests. One can use `AC_CONFIG_COMMANDS' but the
2225 creation of relative symbolic links can be delicate when the package is
2226 built in another directory than its sources.
2228 - Macro: AC_CONFIG_LINKS (DEST:SOURCE..., [CMDS], [INIT-CMDS])
2229 Make `AC_OUTPUT' link each of the existing files SOURCE to the
2230 corresponding link name DEST. Makes a symbolic link if possible,
2231 otherwise a hard link. The DEST and SOURCE names should be
2232 relative to the top level source or build directory. This macro
2233 is one of the instantiating macros, see *Note Configuration
2236 For example, this call:
2238 AC_CONFIG_LINKS(host.h:config/$machine.h
2239 object.h:config/$obj_format.h)
2241 creates in the current directory `host.h' as a link to
2242 `SRCDIR/config/$machine.h', and `object.h' as a link to
2243 `SRCDIR/config/$obj_format.h'.
2245 The tempting value `.' for DEST is invalid: it makes it impossible
2246 for `config.status' to guess the links to establish.
2249 ./config.status host.h object.h
2251 to create the links.
2254 File: autoconf.info, Node: Subdirectories, Next: Default Prefix, Prev: Configuration Links, Up: Setup
2256 Configuring Other Packages in Subdirectories
2257 ============================================
2259 In most situations, calling `AC_OUTPUT' is sufficient to produce
2260 `Makefile's in subdirectories. However, `configure' scripts that
2261 control more than one independent package can use `AC_CONFIG_SUBDIRS'
2262 to run `configure' scripts for other packages in subdirectories.
2264 - Macro: AC_CONFIG_SUBDIRS (DIR ...)
2265 Make `AC_OUTPUT' run `configure' in each subdirectory DIR in the
2266 given whitespace-separated list. Each DIR should be a literal,
2267 i.e., please do not use:
2269 if test "$package_foo_enabled" = yes; then
2270 $my_subdirs="$my_subdirs foo"
2272 AC_CONFIG_SUBDIRS($my_subdirs)
2274 because this prevents `./configure --help=recursive' from
2275 displaying the options of the package `foo'. Rather, you should
2278 if test "$package_foo_enabled" = yes then;
2279 AC_CONFIG_SUBDIRS(foo)
2282 If a given DIR is not found, no error is reported, so a
2283 `configure' script can configure whichever parts of a large source
2284 tree are present. If a given DIR contains `configure.gnu', it is
2285 run instead of `configure'. This is for packages that might use a
2286 non-autoconf script `Configure', which can't be called through a
2287 wrapper `configure' since it would be the same file on
2288 case-insensitive filesystems. Likewise, if a DIR contains
2289 `configure.ac' but no `configure', the Cygnus `configure' script
2290 found by `AC_CONFIG_AUX_DIR' is used.
2292 The subdirectory `configure' scripts are given the same command
2293 line options that were given to this `configure' script, with minor
2294 changes if needed (e.g., to adjust a relative path for the cache
2295 file or source directory). This macro also sets the output
2296 variable `subdirs' to the list of directories `DIR ...'.
2297 `Makefile' rules can use this variable to determine which
2298 subdirectories to recurse into. This macro may be called multiple
2302 File: autoconf.info, Node: Default Prefix, Prev: Subdirectories, Up: Setup
2307 By default, `configure' sets the prefix for files it installs to
2308 `/usr/local'. The user of `configure' can select a different prefix
2309 using the `--prefix' and `--exec-prefix' options. There are two ways
2310 to change the default: when creating `configure', and when running it.
2312 Some software packages might want to install in a directory besides
2313 `/usr/local' by default. To accomplish that, use the
2314 `AC_PREFIX_DEFAULT' macro.
2316 - Macro: AC_PREFIX_DEFAULT (PREFIX)
2317 Set the default installation prefix to PREFIX instead of
2320 It may be convenient for users to have `configure' guess the
2321 installation prefix from the location of a related program that they
2322 have already installed. If you wish to do that, you can call
2323 `AC_PREFIX_PROGRAM'.
2325 - Macro: AC_PREFIX_PROGRAM (PROGRAM)
2326 If the user did not specify an installation prefix (using the
2327 `--prefix' option), guess a value for it by looking for PROGRAM in
2328 `PATH', the way the shell does. If PROGRAM is found, set the
2329 prefix to the parent of the directory containing PROGRAM;
2330 otherwise leave the prefix specified in `Makefile.in' unchanged.
2331 For example, if PROGRAM is `gcc' and the `PATH' contains
2332 `/usr/local/gnu/bin/gcc', set the prefix to `/usr/local/gnu'.
2335 File: autoconf.info, Node: Existing Tests, Next: Writing Tests, Prev: Setup, Up: Top
2340 These macros test for particular system features that packages might
2341 need or want to use. If you need to test for a kind of feature that
2342 none of these macros check for, you can probably do it by calling
2343 primitive test macros with appropriate arguments (*note Writing
2346 These tests print messages telling the user which feature they're
2347 checking for, and what they find. They cache their results for future
2348 `configure' runs (*note Caching Results::).
2350 Some of these macros set output variables. *Note Makefile
2351 Substitutions::, for how to get their values. The phrase "define NAME"
2352 is used below as a shorthand to mean "define C preprocessor symbol NAME
2353 to the value 1". *Note Defining Symbols::, for how to get those symbol
2354 definitions into your program.
2358 * Common Behavior:: Macros' standard schemes
2359 * Alternative Programs:: Selecting between alternative programs
2360 * Files:: Checking for the existence of files
2361 * Libraries:: Library archives that might be missing
2362 * Library Functions:: C library functions that might be missing
2363 * Header Files:: Header files that might be missing
2364 * Declarations:: Declarations that may be missing
2365 * Structures:: Structures or members that might be missing
2366 * Types:: Types that might be missing
2367 * Compilers and Preprocessors:: Checking for compiling programs
2368 * System Services:: Operating system services
2369 * UNIX Variants:: Special kludges for specific UNIX variants
2372 File: autoconf.info, Node: Common Behavior, Next: Alternative Programs, Prev: Existing Tests, Up: Existing Tests
2377 Much effort has been expended to make Autoconf easy to learn. The
2378 most obvious way to reach this goal is simply to enforce standard
2379 interfaces and behaviors, avoiding exceptions as much as possible.
2380 Because of history and inertia, unfortunately, there are still too many
2381 exceptions in Autoconf; nevertheless, this section describes some of
2386 * Standard Symbols:: Symbols defined by the macros
2387 * Default Includes:: Includes used by the generic macros
2390 File: autoconf.info, Node: Standard Symbols, Next: Default Includes, Prev: Common Behavior, Up: Common Behavior
2395 All the generic macros that `AC_DEFINE' a symbol as a result of
2396 their test transform their ARGUMENTs to a standard alphabet. First,
2397 ARGUMENT is converted to upper case and any asterisks (`*') are each
2398 converted to `P'. Any remaining characters that are not alphanumeric
2399 are converted to underscores.
2403 AC_CHECK_TYPES(struct $Expensive*)
2405 will define the symbol `HAVE_STRUCT__EXPENSIVEP' if the check succeeds.
2408 File: autoconf.info, Node: Default Includes, Prev: Standard Symbols, Up: Common Behavior
2413 Several tests depend upon a set of header files. Since these headers
2414 are not universally available, tests actually have to provide a set of
2415 protected includes, such as:
2417 #if TIME_WITH_SYS_TIME
2418 # include <sys/time.h>
2421 # if HAVE_SYS_TIME_H
2422 # include <sys/time.h>
2428 Unless you know exactly what you are doing, you should avoid using
2429 unconditional includes, and check the existence of the headers you
2430 include beforehand (*note Header Files::).
2432 Most generic macros provide the following default set of includes:
2435 #if HAVE_SYS_TYPES_H
2436 # include <sys/types.h>
2439 # include <sys/stat.h>
2442 # include <stdlib.h>
2443 # include <stddef.h>
2446 # include <stdlib.h>
2450 # if !STDC_HEADERS && HAVE_MEMORY_H
2451 # include <memory.h>
2453 # include <string.h>
2456 # include <strings.h>
2459 # include <inttypes.h>
2462 # include <stdint.h>
2466 # include <unistd.h>
2469 If the default includes are used, then Autoconf will automatically
2470 check for the presence of these headers and their compatibility, i.e.,
2471 you don't need to run `AC_HEADERS_STDC', nor check for `stdlib.h' etc.
2473 These headers are checked for in the same order as they are included.
2474 For instance, on some systems `string.h' and `strings.h' both exist,
2475 but conflict. Then `HAVE_STRING_H' will be defined, but
2476 `HAVE_STRINGS_H' won't.
2479 File: autoconf.info, Node: Alternative Programs, Next: Files, Prev: Common Behavior, Up: Existing Tests
2481 Alternative Programs
2482 ====================
2484 These macros check for the presence or behavior of particular
2485 programs. They are used to choose between several alternative programs
2486 and to decide what to do once one has been chosen. If there is no macro
2487 specifically defined to check for a program you need, and you don't need
2488 to check for any special properties of it, then you can use one of the
2489 general program-check macros.
2493 * Particular Programs:: Special handling to find certain programs
2494 * Generic Programs:: How to find other programs
2497 File: autoconf.info, Node: Particular Programs, Next: Generic Programs, Prev: Alternative Programs, Up: Alternative Programs
2499 Particular Program Checks
2500 -------------------------
2502 These macros check for particular programs--whether they exist, and
2503 in some cases whether they support certain features.
2505 - Macro: AC_PROG_AWK
2506 Check for `mawk', `gawk', `nawk', and `awk', in that order, and
2507 set output variable `AWK' to the first one that is found. It
2508 tries `mawk' first because that is reported to be the fastest
2511 - Macro: AC_PROG_INSTALL
2512 Set output variable `INSTALL' to the path of a BSD compatible
2513 `install' program, if one is found in the current `PATH'.
2514 Otherwise, set `INSTALL' to `DIR/install-sh -c', checking the
2515 directories specified to `AC_CONFIG_AUX_DIR' (or its default
2516 directories) to determine DIR (*note Output::). Also set the
2517 variables `INSTALL_PROGRAM' and `INSTALL_SCRIPT' to `${INSTALL}'
2518 and `INSTALL_DATA' to `${INSTALL} -m 644'.
2520 This macro screens out various instances of `install' known not to
2521 work. It prefers to find a C program rather than a shell script,
2522 for speed. Instead of `install-sh', it can also use `install.sh',
2523 but that name is obsolete because some `make' programs have a rule
2524 that creates `install' from it if there is no `Makefile'.
2526 Autoconf comes with a copy of `install-sh' that you can use. If
2527 you use `AC_PROG_INSTALL', you must include either `install-sh' or
2528 `install.sh' in your distribution, or `configure' will produce an
2529 error message saying it can't find them--even if the system you're
2530 on has a good `install' program. This check is a safety measure
2531 to prevent you from accidentally leaving that file out, which
2532 would prevent your package from installing on systems that don't
2533 have a BSD-compatible `install' program.
2535 If you need to use your own installation program because it has
2536 features not found in standard `install' programs, there is no
2537 reason to use `AC_PROG_INSTALL'; just put the file name of your
2538 program into your `Makefile.in' files.
2540 - Macro: AC_PROG_LEX
2541 If `flex' is found, set output variable `LEX' to `flex' and
2542 `LEXLIB' to `-lfl', if that library is in a standard place.
2543 Otherwise set `LEX' to `lex' and `LEXLIB' to `-ll'.
2545 Define `YYTEXT_POINTER' if `yytext' is a `char *' instead of a
2546 `char []'. Also set output variable `LEX_OUTPUT_ROOT' to the base
2547 of the file name that the lexer generates; usually `lex.yy', but
2548 sometimes something else. These results vary according to whether
2549 `lex' or `flex' is being used.
2551 You are encouraged to use Flex in your sources, since it is both
2552 more pleasant to use than plain Lex and the C source it produces
2553 is portable. In order to ensure portability, however, you must
2554 either provide a function `yywrap' or, if you don't use it (e.g.,
2555 your scanner has no `#include'-like feature), simply include a
2556 `%noyywrap' statement in the scanner's source. Once this done,
2557 the scanner is portable (unless _you_ felt free to use nonportable
2558 constructs) and does not depend on any library. In this case, and
2559 in this case only, it is suggested that you use this Autoconf
2563 if test "$LEX" != flex; then
2564 LEX="$SHELL $missing_dir/missing flex"
2565 AC_SUBST(LEX_OUTPUT_ROOT, lex.yy)
2566 AC_SUBST(LEXLIB, '')
2569 The shell script `missing' can be found in the Automake
2572 To ensure backward compatibility, Automake's `AM_PROG_LEX' invokes
2573 (indirectly) this macro twice, which will cause an annoying but
2574 benign "`AC_PROG_LEX' invoked multiple times" warning. Future
2575 versions of Automake will fix this issue, meanwhile, just ignore
2578 - Macro: AC_PROG_LN_S
2579 If `ln -s' works on the current file system (the operating system
2580 and file system support symbolic links), set the output variable
2581 `LN_S' to `ln -s'; otherwise, if `ln' works, set `LN_S' to `ln'
2582 and otherwise set it to `cp -p'.
2584 If you make a link a directory other than the current directory,
2585 its meaning depends on whether `ln' or `ln -s' is used. To safely
2586 create links using `$(LN_S)', either find out which form is used
2587 and adjust the arguments, or always invoke `ln' in the directory
2588 where the link is to be created.
2590 In other words, it does not work to do:
2595 (cd /x && $(LN_S) foo bar)
2597 - Macro: AC_PROG_RANLIB
2598 Set output variable `RANLIB' to `ranlib' if `ranlib' is found, and
2599 otherwise to `:' (do nothing).
2601 - Macro: AC_PROG_YACC
2602 If `bison' is found, set output variable `YACC' to `bison -y'.
2603 Otherwise, if `byacc' is found, set `YACC' to `byacc'. Otherwise
2604 set `YACC' to `yacc'.
2607 File: autoconf.info, Node: Generic Programs, Prev: Particular Programs, Up: Alternative Programs
2609 Generic Program and File Checks
2610 -------------------------------
2612 These macros are used to find programs not covered by the
2613 "particular" test macros. If you need to check the behavior of a
2614 program as well as find out whether it is present, you have to write
2615 your own test for it (*note Writing Tests::). By default, these macros
2616 use the environment variable `PATH'. If you need to check for a
2617 program that might not be in the user's `PATH', you can pass a modified
2618 path to use instead, like this:
2620 AC_PATH_PROG(INETD, inetd, /usr/libexec/inetd,
2621 $PATH:/usr/libexec:/usr/sbin:/usr/etc:etc)
2623 You are strongly encouraged to declare the VARIABLE passed to
2624 `AC_CHECK_PROG' etc. as precious, *Note Setting Output Variables::,
2625 `AC_ARG_VAR', for more details.
2627 - Macro: AC_CHECK_PROG (VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND,
2628 [VALUE-IF-NOT-FOUND], [PATH], [REJECT])
2629 Check whether program PROG-TO-CHECK-FOR exists in `PATH'. If it
2630 is found, set VARIABLE to VALUE-IF-FOUND, otherwise to
2631 VALUE-IF-NOT-FOUND, if given. Always pass over REJECT (an
2632 absolute file name) even if it is the first found in the search
2633 path; in that case, set VARIABLE using the absolute file name of
2634 the PROG-TO-CHECK-FOR found that is not REJECT. If VARIABLE was
2635 already set, do nothing. Calls `AC_SUBST' for VARIABLE.
2637 - Macro: AC_CHECK_PROGS (VARIABLE, PROGS-TO-CHECK-FOR,
2638 [VALUE-IF-NOT-FOUND], [PATH])
2639 Check for each program in the whitespace-separated list
2640 PROGS-TO-CHECK-FOR exists on the `PATH'. If it is found, set
2641 VARIABLE to the name of that program. Otherwise, continue
2642 checking the next program in the list. If none of the programs in
2643 the list are found, set VARIABLE to VALUE-IF-NOT-FOUND; if
2644 VALUE-IF-NOT-FOUND is not specified, the value of VARIABLE is not
2645 changed. Calls `AC_SUBST' for VARIABLE.
2647 - Macro: AC_CHECK_TOOL (VARIABLE, PROG-TO-CHECK-FOR,
2648 [VALUE-IF-NOT-FOUND], [PATH])
2649 Like `AC_CHECK_PROG', but first looks for PROG-TO-CHECK-FOR with a
2650 prefix of the host type as determined by `AC_CANONICAL_HOST',
2651 followed by a dash (*note Canonicalizing::). For example, if the
2652 user runs `configure --host=i386-gnu', then this call:
2653 AC_CHECK_TOOL(RANLIB, ranlib, :)
2655 sets `RANLIB' to `i386-gnu-ranlib' if that program exists in
2656 `PATH', or otherwise to `ranlib' if that program exists in `PATH',
2657 or to `:' if neither program exists.
2659 - Macro: AC_CHECK_TOOLS (VARIABLE, PROGS-TO-CHECK-FOR,
2660 [VALUE-IF-NOT-FOUND], [PATH])
2661 Like `AC_CHECK_TOOL', each of the tools in the list
2662 PROGS-TO-CHECK-FOR are checked with a prefix of the host type as
2663 determined by `AC_CANONICAL_HOST', followed by a dash (*note
2664 Canonicalizing::). If none of the tools can be found with a
2665 prefix, then the first one without a prefix is used. If a tool is
2666 found, set VARIABLE to the name of that program. If none of the
2667 tools in the list are found, set VARIABLE to VALUE-IF-NOT-FOUND; if
2668 VALUE-IF-NOT-FOUND is not specified, the value of VARIABLE is not
2669 changed. Calls `AC_SUBST' for VARIABLE.
2671 - Macro: AC_PATH_PROG (VARIABLE, PROG-TO-CHECK-FOR,
2672 [VALUE-IF-NOT-FOUND], [PATH])
2673 Like `AC_CHECK_PROG', but set VARIABLE to the entire path of
2674 PROG-TO-CHECK-FOR if found.
2676 - Macro: AC_PATH_PROGS (VARIABLE, PROGS-TO-CHECK-FOR,
2677 [VALUE-IF-NOT-FOUND], [PATH])
2678 Like `AC_CHECK_PROGS', but if any of PROGS-TO-CHECK-FOR are found,
2679 set VARIABLE to the entire path of the program found.
2681 - Macro: AC_PATH_TOOL (VARIABLE, PROG-TO-CHECK-FOR,
2682 [VALUE-IF-NOT-FOUND], [PATH])
2683 Like `AC_CHECK_TOOL', but set VARIABLE to the entire path of the
2684 program if it is found.
2687 File: autoconf.info, Node: Files, Next: Libraries, Prev: Alternative Programs, Up: Existing Tests
2692 You might also need to check for the existence of files. Before
2693 using these macros, ask yourself whether a run time test might not be a
2694 better solution. Be aware that, like most Autoconf macros, they test a
2695 feature of the host machine, and therefore, they die when
2698 - Macro: AC_CHECK_FILE (FILE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2699 Check whether file FILE exists on the native system. If it is
2700 found, execute ACTION-IF-FOUND, otherwise do ACTION-IF-NOT-FOUND,
2703 - Macro: AC_CHECK_FILES (FILES, [ACTION-IF-FOUND],
2704 [ACTION-IF-NOT-FOUND])
2705 Executes `AC_CHECK_FILE' once for each file listed in FILES.
2706 Additionally, defines `HAVE_FILE' (*note Standard Symbols::) for
2710 File: autoconf.info, Node: Libraries, Next: Library Functions, Prev: Files, Up: Existing Tests
2715 The following macros check for the presence of certain C, C++ or
2716 Fortran 77 library archive files.
2718 - Macro: AC_CHECK_LIB (LIBRARY, FUNCTION, [ACTION-IF-FOUND],
2719 [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
2720 Depending on the current language(*note Language Choice::), try to
2721 ensure that the C, C++, or Fortran 77 function FUNCTION is
2722 available by checking whether a test program can be linked with the
2723 library LIBRARY to get the function. LIBRARY is the base name of
2724 the library; e.g., to check for `-lmp', use `mp' as the LIBRARY
2727 ACTION-IF-FOUND is a list of shell commands to run if the link
2728 with the library succeeds; ACTION-IF-NOT-FOUND is a list of shell
2729 commands to run if the link fails. If ACTION-IF-FOUND is not
2730 specified, the default action will prepend `-lLIBRARY' to `LIBS'
2731 and define `HAVE_LIBLIBRARY' (in all capitals). This macro is
2732 intended to support building of `LIBS' in a right-to-left
2733 (least-dependent to most-dependent) fashion such that library
2734 dependencies are satisfied as a natural side-effect of consecutive
2735 tests. Some linkers are very sensitive to library ordering so the
2736 order in which `LIBS' is generated is important to reliable
2737 detection of libraries.
2739 If linking with LIBRARY results in unresolved symbols that would
2740 be resolved by linking with additional libraries, give those
2741 libraries as the OTHER-LIBRARIES argument, separated by spaces:
2742 e.g. `-lXt -lX11'. Otherwise, this macro will fail to detect that
2743 LIBRARY is present, because linking the test program will always
2744 fail with unresolved symbols. The OTHER-LIBRARIES argument should
2745 be limited to cases where it is desirable to test for one library
2746 in the presence of another that is not already in `LIBS'.
2748 - Macro: AC_SEARCH_LIBS (FUNCTION, SEARCH-LIBS, [ACTION-IF-FOUND],
2749 [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
2750 Search for a library defining FUNCTION if it's not already
2751 available. This equates to calling `AC_TRY_LINK_FUNC' first with
2752 no libraries, then for each library listed in SEARCH-LIBS.
2754 Add `-lLIBRARY' to `LIBS' for the first library found to contain
2755 FUNCTION, and run ACTION-IF-FOUND. If the function is not found,
2756 run ACTION-IF-NOT-FOUND.
2758 If linking with LIBRARY results in unresolved symbols that would
2759 be resolved by linking with additional libraries, give those
2760 libraries as the OTHER-LIBRARIES argument, separated by spaces:
2761 e.g. `-lXt -lX11'. Otherwise, this macro will fail to detect that
2762 FUNCTION is present, because linking the test program will always
2763 fail with unresolved symbols.
2766 File: autoconf.info, Node: Library Functions, Next: Header Files, Prev: Libraries, Up: Existing Tests
2771 The following macros check for particular C library functions. If
2772 there is no macro specifically defined to check for a function you need,
2773 and you don't need to check for any special properties of it, then you
2774 can use one of the general function-check macros.
2778 * Function Portability:: Pitfalls with usual functions
2779 * Particular Functions:: Special handling to find certain functions
2780 * Generic Functions:: How to find other functions
2783 File: autoconf.info, Node: Function Portability, Next: Particular Functions, Prev: Library Functions, Up: Library Functions
2785 Portability of Classical Functions
2786 ----------------------------------
2788 Most usual functions can either be missing, or be buggy, or be
2789 limited on some architectures. This section tries to make an inventory
2790 of these portability issues. By definition, this list will always
2791 require additions, please help us keeping it as complete as possible
2794 The POSIX spec says that `unlink' causes the given files to be
2795 removed only after there are no more open file handles for it.
2796 Not all OS's support this behaviour though. So even on systems
2797 that provide `unlink', you cannot portably assume it is OK to call
2798 it on files that are open. For example, on Windows 9x and ME,
2799 such a call would fail; on DOS it could even lead to file system
2800 corruption, as the file might end up being written to after the OS
2804 File: autoconf.info, Node: Particular Functions, Next: Generic Functions, Prev: Function Portability, Up: Library Functions
2806 Particular Function Checks
2807 --------------------------
2809 These macros check for particular C functions--whether they exist,
2810 and in some cases how they respond when given certain arguments.
2812 - Macro: AC_FUNC_ALLOCA
2813 Check how to get `alloca'. Tries to get a builtin version by
2814 checking for `alloca.h' or the predefined C preprocessor macros
2815 `__GNUC__' and `_AIX'. If this macro finds `alloca.h', it defines
2818 If those attempts fail, it looks for the function in the standard C
2819 library. If any of those methods succeed, it defines
2820 `HAVE_ALLOCA'. Otherwise, it sets the output variable `ALLOCA' to
2821 `alloca.o' and defines `C_ALLOCA' (so programs can periodically
2822 call `alloca(0)' to garbage collect). This variable is separate
2823 from `LIBOBJS' so multiple programs can share the value of
2824 `ALLOCA' without needing to create an actual library, in case only
2825 some of them use the code in `LIBOBJS'.
2827 This macro does not try to get `alloca' from the System V R3
2828 `libPW' or the System V R4 `libucb' because those libraries
2829 contain some incompatible functions that cause trouble. Some
2830 versions do not even contain `alloca' or contain a buggy version.
2831 If you still want to use their `alloca', use `ar' to extract
2832 `alloca.o' from them instead of compiling `alloca.c'.
2834 Source files that use `alloca' should start with a piece of code
2835 like the following, to declare it properly. In some versions of
2836 AIX, the declaration of `alloca' must precede everything else
2837 except for comments and preprocessor directives. The `#pragma'
2838 directive is indented so that pre-ANSI C compilers will ignore it,
2839 rather than choke on it.
2841 /* AIX requires this to be the first thing in the file. */
2844 # include <alloca.h>
2849 # ifndef alloca /* predefined by HP cc +Olibcalls */
2856 - Macro: AC_FUNC_CHOWN
2857 If the `chown' function is available and works (in particular, it
2858 should accept `-1' for `uid' and `gid'), define `HAVE_CHOWN'.
2860 - Macro: AC_FUNC_CLOSEDIR_VOID
2861 If the `closedir' function does not return a meaningful value,
2862 define `CLOSEDIR_VOID'. Otherwise, callers ought to check its
2863 return value for an error indicator.
2865 - Macro: AC_FUNC_ERROR_AT_LINE
2866 If the `error_at_line' function is not found, require an
2867 `AC_LIBOBJ' replacement of `error'.
2869 - Macro: AC_FUNC_FNMATCH
2870 If the `fnmatch' function is available and works (unlike the one on
2871 Solaris 2.4), define `HAVE_FNMATCH'.
2873 - Macro: AC_FUNC_FORK
2874 This macro checks for the `fork' and `vfork' functions. If a
2875 working `fork' is found, define `HAVE_WORKING_FORK'. This macro
2876 checks whether `fork' is just a stub by trying to run it.
2878 If `vfork.h' is found, define `HAVE_VFORK_H'. If a working `vfork'
2879 is found, define `HAVE_WORKING_VFORK'. Otherwise, define `vfork'
2880 to be `fork' for backward compatibility with previous versions of
2881 `autoconf'. This macro checks for several known errors in
2882 implementations of `vfork' and considers the system to not have a
2883 working `vfork' if it detects any of them. It is not considered to
2884 be an implementation error if a child's invocation of `signal'
2885 modifies the parent's signal handler, since child processes rarely
2886 change their signal handlers.
2888 Since this macro defines `vfork' only for backward compatibility
2889 with previous versions of `autoconf' you're encouraged to define it
2890 yourself in new code:
2891 #if !HAVE_WORKING_VFORK
2895 - Macro: AC_FUNC_FSEEKO
2896 If the `fseeko' function is available, define `HAVE_FSEEKO'.
2897 Define `_LARGEFILE_SOURCE' if necessary.
2899 - Macro: AC_FUNC_GETGROUPS
2900 If the `getgroups' function is available and works (unlike on
2901 Ultrix 4.3, where `getgroups (0, 0)' always fails), define
2902 `HAVE_GETGROUPS'. Set `GETGROUPS_LIBS' to any libraries needed to
2903 get that function. This macro runs `AC_TYPE_GETGROUPS'.
2905 - Macro: AC_FUNC_GETLOADAVG
2906 Check how to get the system load averages. If the system has the
2907 `getloadavg' function, define `HAVE_GETLOADAVG', and set
2908 `GETLOADAVG_LIBS' to any libraries needed to get that function.
2909 Also add `GETLOADAVG_LIBS' to `LIBS'.
2911 Otherwise, require an `AC_LIBOBJ' replacement (`getloadavg.c') of
2912 `getloadavg', and possibly define several other C preprocessor
2913 macros and output variables:
2915 1. Define `C_GETLOADAVG'.
2917 2. Define `SVR4', `DGUX', `UMAX', or `UMAX4_3' if on those
2920 3. If `nlist.h' is found, define `NLIST_STRUCT'.
2922 4. If `struct nlist' has an `n_un.n_name' member, define
2923 `HAVE_STRUCT_NLIST_N_UN_N_NAME'. The obsolete symbol
2924 `NLIST_NAME_UNION' is still defined, but do not depend upon
2927 5. Programs may need to be installed setgid (or setuid) for
2928 `getloadavg' to work. In this case, define
2929 `GETLOADAVG_PRIVILEGED', set the output variable `NEED_SETGID'
2930 to `true' (and otherwise to `false'), and set `KMEM_GROUP' to
2931 the name of the group that should own the installed program.
2933 - Macro: AC_FUNC_GETMNTENT
2934 Check for `getmntent' in the `sun', `seq', and `gen' libraries,
2935 for Irix 4, PTX, and Unixware, respectively. Then, if `getmntent'
2936 is available, define `HAVE_GETMNTENT'.
2938 - Macro: AC_FUNC_GETPGRP
2939 If `getpgrp' takes no argument (the POSIX.1 version), define
2940 `GETPGRP_VOID'. Otherwise, it is the BSD version, which takes a
2941 process ID as an argument. This macro does not check whether
2942 `getpgrp' exists at all; if you need to work in that situation,
2943 first call `AC_CHECK_FUNC' for `getpgrp'.
2945 - Macro: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
2946 If `link' is a symbolic link, then `lstat' should treat `link/'
2947 the same as `link/.'. However, many older `lstat' implementations
2948 incorrectly ignore trailing slashes.
2950 It is safe to assume that if `lstat' incorrectly ignores trailing
2951 slashes, then other symbolic-link-aware functions like `unlink'
2952 and `unlink' also incorrectly ignore trailing slashes.
2954 If `lstat' behaves properly, define
2955 `LSTAT_FOLLOWS_SLASHED_SYMLINK', otherwise require an `AC_LIBOBJ'
2956 replacement of `lstat'.
2958 - Macro: AC_FUNC_MALLOC
2959 If the `malloc' works correctly (`malloc (0)' returns a valid
2960 pointer), define `HAVE_MALLOC'.
2962 - Macro: AC_FUNC_MEMCMP
2963 If the `memcmp' function is not available, or does not work on
2964 8-bit data (like the one on SunOS 4.1.3), or fails when comparing
2965 16 bytes or more and with at least one buffer not starting on a
2966 4-byte boundary (such as the one on NeXT x86 OpenStep), require an
2967 `AC_LIBOBJ' replacement for `memcmp'.
2969 - Macro: AC_FUNC_MKTIME
2970 If the `mktime' function is not available, or does not work
2971 correctly, require an `AC_LIBOBJ' replacement for `mktime'.
2973 - Macro: AC_FUNC_MMAP
2974 If the `mmap' function exists and works correctly, define
2975 `HAVE_MMAP'. Only checks private fixed mapping of already-mapped
2978 - Macro: AC_FUNC_OBSTACK
2979 If the obstacks are found, define `HAVE_OBSTACK', else require an
2980 `AC_LIBOBJ' replacement for `obstack'.
2982 - Macro: AC_FUNC_SELECT_ARGTYPES
2983 Determines the correct type to be passed for each of the `select'
2984 function's arguments, and defines those types in
2985 `SELECT_TYPE_ARG1', `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'
2986 respectively. `SELECT_TYPE_ARG1' defaults to `int',
2987 `SELECT_TYPE_ARG234' defaults to `int *', and `SELECT_TYPE_ARG5'
2988 defaults to `struct timeval *'.
2990 - Macro: AC_FUNC_SETPGRP
2991 If `setpgrp' takes no argument (the POSIX.1 version), define
2992 `SETPGRP_VOID'. Otherwise, it is the BSD version, which takes two
2993 process IDs as arguments. This macro does not check whether
2994 `setpgrp' exists at all; if you need to work in that situation,
2995 first call `AC_CHECK_FUNC' for `setpgrp'.
2997 - Macro: AC_FUNC_STAT
2998 - Macro: AC_FUNC_LSTAT
2999 Determine whether `stat' or `lstat' have the bug that it succeeds
3000 when given the zero-length file name argument. The `stat' and
3001 `lstat' from SunOS 4.1.4 and the Hurd (as of 1998-11-01) do this.
3003 If it does, then define `HAVE_STAT_EMPTY_STRING_BUG' (or
3004 `HAVE_LSTAT_EMPTY_STRING_BUG') and ask for an `AC_LIBOBJ'
3007 - Macro: AC_FUNC_SETVBUF_REVERSED
3008 If `setvbuf' takes the buffering type as its second argument and
3009 the buffer pointer as the third, instead of the other way around,
3010 define `SETVBUF_REVERSED'.
3012 - Macro: AC_FUNC_STRCOLL
3013 If the `strcoll' function exists and works correctly, define
3014 `HAVE_STRCOLL'. This does a bit more than
3015 `AC_CHECK_FUNCS(strcoll)', because some systems have incorrect
3016 definitions of `strcoll' that should not be used.
3018 - Macro: AC_FUNC_STRTOD
3019 If the `strtod' function does not exist or doesn't work correctly,
3020 ask for an `AC_LIBOBJ' replacement of `strtod'. In this case,
3021 because `strtod.c' is likely to need `pow', set the output
3022 variable `POW_LIB' to the extra library needed.
3024 - Macro: AC_FUNC_STRERROR_R
3025 If `strerror_r' is available, define `HAVE_STRERROR_R'. If its
3026 implementation correctly returns a `char *', define
3027 `HAVE_WORKING_STRERROR_R'. On at least DEC UNIX 4.0[A-D] and HP-UX
3028 B.10.20, `strerror_r' returns `int'. Actually, this tests only
3029 whether it returns a scalar or an array, but that should be enough.
3030 This is used by the common `error.c'.
3032 - Macro: AC_FUNC_STRFTIME
3033 Check for `strftime' in the `intl' library, for SCO UNIX. Then,
3034 if `strftime' is available, define `HAVE_STRFTIME'.
3036 - Macro: AC_FUNC_UTIME_NULL
3037 If `utime(FILE, NULL)' sets FILE's timestamp to the present,
3038 define `HAVE_UTIME_NULL'.
3040 - Macro: AC_FUNC_VPRINTF
3041 If `vprintf' is found, define `HAVE_VPRINTF'. Otherwise, if
3042 `_doprnt' is found, define `HAVE_DOPRNT'. (If `vprintf' is
3043 available, you may assume that `vfprintf' and `vsprintf' are also
3047 File: autoconf.info, Node: Generic Functions, Prev: Particular Functions, Up: Library Functions
3049 Generic Function Checks
3050 -----------------------
3052 These macros are used to find functions not covered by the
3053 "particular" test macros. If the functions might be in libraries other
3054 than the default C library, first call `AC_CHECK_LIB' for those
3055 libraries. If you need to check the behavior of a function as well as
3056 find out whether it is present, you have to write your own test for it
3057 (*note Writing Tests::).
3059 - Macro: AC_CHECK_FUNC (FUNCTION, [ACTION-IF-FOUND],
3060 [ACTION-IF-NOT-FOUND])
3061 If C function FUNCTION is available, run shell commands
3062 ACTION-IF-FOUND, otherwise ACTION-IF-NOT-FOUND. If you just want
3063 to define a symbol if the function is available, consider using
3064 `AC_CHECK_FUNCS' instead. This macro checks for functions with C
3065 linkage even when `AC_LANG(C++)' has been called, since C is more
3066 standardized than C++. (*note Language Choice::, for more
3067 information about selecting the language for checks.)
3069 - Macro: AC_CHECK_FUNCS (FUNCTION..., [ACTION-IF-FOUND],
3070 [ACTION-IF-NOT-FOUND])
3071 For each FUNCTION in the whitespace-separated argument list,
3072 define `HAVE_FUNCTION' (in all capitals) if it is available. If
3073 ACTION-IF-FOUND is given, it is additional shell code to execute
3074 when one of the functions is found. You can give it a value of
3075 `break' to break out of the loop on the first match. If
3076 ACTION-IF-NOT-FOUND is given, it is executed when one of the
3077 functions is not found.
3079 Autoconf follows a philosophy that was formed over the years by those
3080 who have struggled for portability: isolate the portability issues in
3081 specific files, and then program as if you were in a POSIX environment.
3082 Some functions may be missing or unfixable, and your package must be
3083 ready to replace them.
3085 Use the first three of the following macros to specify a function to
3086 be replaced, and the last one (`AC_REPLACE_FUNCS') to check for and
3087 replace the function if needed.
3089 - Macro: AC_LIBOBJ (FUNCTION)
3090 Specify that `FUNCTION.c' must be included in the executables to
3091 replace a missing or broken implementation of FUNCTION.
3093 Technically, it adds `FUNCTION.$ac_objext' to the output variable
3094 `LIBOBJS' and calls `AC_LIBSOURCE' for `FUNCTION.c'. You should
3095 not directly change `LIBOBJS', since this is not traceable.
3097 - Macro: AC_LIBSOURCE (FILE)
3098 Specify that FILE might be needed to compile the project. If you
3099 need to know what files might be needed by a `configure.ac', you
3100 should trace `AC_LIBSOURCE'. FILE must be a literal.
3102 This macro is called automatically from `AC_LIBOBJ', but you must
3103 call it explicitly if you pass a shell variable to `AC_LIBOBJ'. In
3104 that case, since shell variables cannot be traced statically, you
3105 must pass to `AC_LIBSOURCE' any possible files that the shell
3106 variable might cause `AC_LIBOBJ' to need. For example, if you
3107 want to pass a variable `$foo_or_bar' to `AC_LIBOBJ' that holds
3108 either `"foo"' or `"bar"', you should do:
3112 AC_LIBOBJ($foo_or_bar)
3114 There is usually a way to avoid this, however, and you are
3115 encouraged to simply call `AC_LIBOBJ' with literal arguments.
3117 Note that this macro replaces the obsolete `AC_LIBOBJ_DECL', with
3118 slightly different semantics: the old macro took the function name,
3119 e.g. `foo', as its argument rather than the file name.
3121 - Macro: AC_LIBSOURCES (FILES)
3122 Like `AC_LIBSOURCE', but accepts one or more FILES in a
3123 comma-separated M4 list. Thus, the above example might be
3126 AC_LIBSOURCES([foo.c, bar.c])
3127 AC_LIBOBJ($foo_or_bar)
3129 - Macro: AC_REPLACE_FUNCS (FUNCTION...)
3130 Like `AC_CHECK_FUNCS', but uses `AC_LIBOBJ(FUNCTION)' as
3131 ACTION-IF-NOT-FOUND. You can declare your replacement function by
3132 enclosing the prototype in `#if !HAVE_FUNCTION'. If the system
3133 has the function, it probably declares it in a header file you
3134 should be including, so you shouldn't redeclare it lest your
3135 declaration conflict.
3138 File: autoconf.info, Node: Header Files, Next: Declarations, Prev: Library Functions, Up: Existing Tests
3143 The following macros check for the presence of certain C header
3144 files. If there is no macro specifically defined to check for a header
3145 file you need, and you don't need to check for any special properties of
3146 it, then you can use one of the general header-file check macros.
3150 * Particular Headers:: Special handling to find certain headers
3151 * Generic Headers:: How to find other headers
3154 File: autoconf.info, Node: Particular Headers, Next: Generic Headers, Prev: Header Files, Up: Header Files
3156 Particular Header Checks
3157 ------------------------
3159 These macros check for particular system header files--whether they
3160 exist, and in some cases whether they declare certain symbols.
3162 - Macro: AC_HEADER_DIRENT
3163 Check for the following header files. For the first one that is
3164 found and defines `DIR', define the listed C preprocessor macro:
3166 `dirent.h' `HAVE_DIRENT_H'
3167 `sys/ndir.h' `HAVE_SYS_NDIR_H'
3168 `sys/dir.h' `HAVE_SYS_DIR_H'
3169 `ndir.h' `HAVE_NDIR_H'
3171 The directory-library declarations in your source code should look
3172 something like the following:
3175 # include <dirent.h>
3176 # define NAMLEN(dirent) strlen((dirent)->d_name)
3178 # define dirent direct
3179 # define NAMLEN(dirent) (dirent)->d_namlen
3180 # if HAVE_SYS_NDIR_H
3181 # include <sys/ndir.h>
3184 # include <sys/dir.h>
3191 Using the above declarations, the program would declare variables
3192 to be of type `struct dirent', not `struct direct', and would
3193 access the length of a directory entry name by passing a pointer
3194 to a `struct dirent' to the `NAMLEN' macro.
3196 This macro also checks for the SCO Xenix `dir' and `x' libraries.
3198 - Macro: AC_HEADER_MAJOR
3199 If `sys/types.h' does not define `major', `minor', and `makedev',
3200 but `sys/mkdev.h' does, define `MAJOR_IN_MKDEV'; otherwise, if
3201 `sys/sysmacros.h' does, define `MAJOR_IN_SYSMACROS'.
3203 - Macro: AC_HEADER_STAT
3204 If the macros `S_ISDIR', `S_ISREG' et al. defined in `sys/stat.h'
3205 do not work properly (returning false positives), define
3206 `STAT_MACROS_BROKEN'. This is the case on Tektronix UTekV, Amdahl
3207 UTS and Motorola System V/88.
3209 - Macro: AC_HEADER_STDC
3210 Define `STDC_HEADERS' if the system has ANSI C header files.
3211 Specifically, this macro checks for `stdlib.h', `stdarg.h',
3212 `string.h', and `float.h'; if the system has those, it probably
3213 has the rest of the ANSI C header files. This macro also checks
3214 whether `string.h' declares `memchr' (and thus presumably the
3215 other `mem' functions), whether `stdlib.h' declare `free' (and
3216 thus presumably `malloc' and other related functions), and whether
3217 the `ctype.h' macros work on characters with the high bit set, as
3220 Use `STDC_HEADERS' instead of `__STDC__' to determine whether the
3221 system has ANSI-compliant header files (and probably C library
3222 functions) because many systems that have GCC do not have ANSI C
3225 On systems without ANSI C headers, there is so much variation that
3226 it is probably easier to declare the functions you use than to
3227 figure out exactly what the system header files declare. Some
3228 systems contain a mix of functions ANSI and BSD; some are mostly
3229 ANSI but lack `memmove'; some define the BSD functions as macros in
3230 `string.h' or `strings.h'; some have only the BSD functions but
3231 `string.h'; some declare the memory functions in `memory.h', some
3232 in `string.h'; etc. It is probably sufficient to check for one
3233 string function and one memory function; if the library has the
3234 ANSI versions of those then it probably has most of the others.
3235 If you put the following in `configure.ac':
3238 AC_CHECK_FUNCS(strchr memcpy)
3240 then, in your code, you can put declarations like this:
3243 # include <string.h>
3246 # define strchr index
3247 # define strrchr rindex
3249 char *strchr (), *strrchr ();
3251 # define memcpy(d, s, n) bcopy ((s), (d), (n))
3252 # define memmove(d, s, n) bcopy ((s), (d), (n))
3256 If you use a function like `memchr', `memset', `strtok', or
3257 `strspn', which have no BSD equivalent, then macros won't suffice;
3258 you must provide an implementation of each function. An easy way
3259 to incorporate your implementations only when needed (since the
3260 ones in system C libraries may be hand optimized) is to, taking
3261 `memchr' for example, put it in `memchr.c' and use
3262 `AC_REPLACE_FUNCS(memchr)'.
3264 - Macro: AC_HEADER_SYS_WAIT
3265 If `sys/wait.h' exists and is compatible with POSIX.1, define
3266 `HAVE_SYS_WAIT_H'. Incompatibility can occur if `sys/wait.h' does
3267 not exist, or if it uses the old BSD `union wait' instead of `int'
3268 to store a status value. If `sys/wait.h' is not POSIX.1
3269 compatible, then instead of including it, define the POSIX.1
3270 macros with their usual interpretations. Here is an example:
3272 #include <sys/types.h>
3274 # include <sys/wait.h>
3277 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
3280 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
3283 `_POSIX_VERSION' is defined when `unistd.h' is included on POSIX.1
3284 systems. If there is no `unistd.h', it is definitely not a POSIX.1
3285 system. However, some non-POSIX.1 systems do have `unistd.h'.
3287 The way to check if the system supports POSIX.1 is:
3290 # include <sys/types.h>
3291 # include <unistd.h>
3294 #ifdef _POSIX_VERSION
3295 /* Code for POSIX.1 systems. */
3298 - Macro: AC_HEADER_TIME
3299 If a program may include both `time.h' and `sys/time.h', define
3300 `TIME_WITH_SYS_TIME'. On some older systems, `sys/time.h'
3301 includes `time.h', but `time.h' is not protected against multiple
3302 inclusion, so programs should not explicitly include both files.
3303 This macro is useful in programs that use, for example, `struct
3304 timeval' or `struct timezone' as well as `struct tm'. It is best
3305 used in conjunction with `HAVE_SYS_TIME_H', which can be checked
3306 for using `AC_CHECK_HEADERS(sys/time.h)'.
3308 #if TIME_WITH_SYS_TIME
3309 # include <sys/time.h>
3312 # if HAVE_SYS_TIME_H
3313 # include <sys/time.h>
3319 - Macro: AC_HEADER_TIOCGWINSZ
3320 If the use of `TIOCGWINSZ' requires `<sys/ioctl.h>', then define
3321 `GWINSZ_IN_SYS_IOCTL'. Otherwise `TIOCGWINSZ' can be found in
3327 # include <termios.h>
3330 #if GWINSZ_IN_SYS_IOCTL
3331 # include <sys/ioctl.h>
3335 File: autoconf.info, Node: Generic Headers, Prev: Particular Headers, Up: Header Files
3337 Generic Header Checks
3338 ---------------------
3340 These macros are used to find system header files not covered by the
3341 "particular" test macros. If you need to check the contents of a header
3342 as well as find out whether it is present, you have to write your own
3343 test for it (*note Writing Tests::).
3345 - Macro: AC_CHECK_HEADER (HEADER-FILE, [ACTION-IF-FOUND],
3346 [ACTION-IF-NOT-FOUND], [INCLUDES])
3347 If the system header file HEADER-FILE is usable, execute shell
3348 commands ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND.
3349 If you just want to define a symbol if the header file is
3350 available, consider using `AC_CHECK_HEADERS' instead.
3352 The meaning of "usable" depends upon the content of INCLUDES:
3354 if INCLUDES is empty
3359 can be _preprocessed_ without error.
3365 #include <HEADER-FILE>
3367 can be _compiled_ without error. You may use
3368 `AC_CHECK_HEADER' (and `AC_CHECK_HEADERS') to check whether
3369 two headers are compatible.
3371 You may pass any kind of dummy content for INCLUDES, such as a
3372 single space, a comment, to check whether HEADER-FILE compiles
3375 - Macro: AC_CHECK_HEADERS (HEADER-FILE..., [ACTION-IF-FOUND],
3376 [ACTION-IF-NOT-FOUND], [INCLUDES])
3377 For each given system header file HEADER-FILE in the
3378 whitespace-separated argument list that exists, define
3379 `HAVE_HEADER-FILE' (in all capitals). If ACTION-IF-FOUND is
3380 given, it is additional shell code to execute when one of the
3381 header files is found. You can give it a value of `break' to
3382 break out of the loop on the first match. If ACTION-IF-NOT-FOUND
3383 is given, it is executed when one of the header files is not found.
3385 Be sure to read the documentation of `AC_CHECK_HEADER' to
3386 understand the influence of INCLUDES.
3389 File: autoconf.info, Node: Declarations, Next: Structures, Prev: Header Files, Up: Existing Tests
3394 The following macros check for the declaration of variables and
3395 functions. If there is no macro specifically defined to check for a
3396 symbol you need, then you can use the general macros (*note Generic
3397 Declarations::) or, for more complex tests, you may use
3398 `AC_TRY_COMPILE' (*note Examining Syntax::).
3402 * Particular Declarations:: Macros to check for certain declarations
3403 * Generic Declarations:: How to find other declarations
3406 File: autoconf.info, Node: Particular Declarations, Next: Generic Declarations, Prev: Declarations, Up: Declarations
3408 Particular Declaration Checks
3409 -----------------------------
3411 The following macros check for certain declarations.
3413 - Macro: AC_DECL_SYS_SIGLIST
3414 Define `SYS_SIGLIST_DECLARED' if the variable `sys_siglist' is
3415 declared in a system header file, either `signal.h' or `unistd.h'.
3418 File: autoconf.info, Node: Generic Declarations, Prev: Particular Declarations, Up: Declarations
3420 Generic Declaration Checks
3421 --------------------------
3423 These macros are used to find declarations not covered by the
3424 "particular" test macros.
3426 - Macro: AC_CHECK_DECL (SYMBOL, [ACTION-IF-FOUND],
3427 [ACTION-IF-NOT-FOUND], [INCLUDES])
3428 If SYMBOL (a function or a variable) is not declared in INCLUDES
3429 and a declaration is needed, run the shell commands
3430 ACTION-IF-NOT-FOUND, otherwise ACTION-IF-FOUND. If no INCLUDES
3431 are specified, the default includes are used (*note Default
3434 This macro actually tests whether it is valid to use SYMBOL as an
3435 r-value, not if it is really declared, because it is much safer to
3436 avoid introducing extra declarations when they are not needed.
3438 - Macro: AC_CHECK_DECLS (SYMBOLS, [ACTION-IF-FOUND],
3439 [ACTION-IF-NOT-FOUND], [INCLUDES])
3440 For each of the SYMBOLS (_comma_-separated list), define
3441 `HAVE_DECL_SYMBOL' (in all capitals) to `1' if SYMBOL is declared,
3442 otherwise to `0'. If ACTION-IF-NOT-FOUND is given, it is
3443 additional shell code to execute when one of the function
3444 declarations is needed, otherwise ACTION-IF-FOUND is executed.
3446 This macro uses an m4 list as first argument:
3447 AC_CHECK_DECLS(strdup)
3448 AC_CHECK_DECLS([strlen])
3449 AC_CHECK_DECLS([malloc, realloc, calloc, free])
3451 Unlike the other `AC_CHECK_*S' macros, when a SYMBOL is not
3452 declared, `HAVE_DECL_SYMBOL' is defined to `0' instead of leaving
3453 `HAVE_DECL_SYMBOL' undeclared. When you are _sure_ that the check
3454 was performed, use `HAVE_DECL_SYMBOL' just like any other result
3457 #if !HAVE_DECL_SYMBOL
3458 extern char *symbol;
3461 If the test may have not been performed, however, because it is
3462 safer _not_ to declare a symbol than to use a declaration that
3463 conflicts with the system's one, you should use:
3465 #if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC
3466 char *malloc (size_t *s);
3469 You fall into the second category only in extreme situations:
3470 either your files may be used without being configured, or they
3471 are used during the configuration. In most cases the traditional
3475 File: autoconf.info, Node: Structures, Next: Types, Prev: Declarations, Up: Existing Tests
3480 The following macros check for the presence of certain members in C
3481 structures. If there is no macro specifically defined to check for a
3482 member you need, then you can use the general structure-member macro
3483 (*note Generic Structures::) or, for more complex tests, you may use
3484 `AC_TRY_COMPILE' (*note Examining Syntax::).
3488 * Particular Structures:: Macros to check for certain structure members
3489 * Generic Structures:: How to find other structure members
3492 File: autoconf.info, Node: Particular Structures, Next: Generic Structures, Prev: Structures, Up: Structures
3494 Particular Structure Checks
3495 ---------------------------
3497 The following macros check for certain structures or structure
3500 - Macro: AC_STRUCT_ST_BLKSIZE
3501 If `struct stat' contains an `st_blksize' member, define
3502 `HAVE_STRUCT_STAT_ST_BLKSIZE'. The former name, `HAVE_ST_BLKSIZE'
3503 is to be avoided, as its support will cease in the future. This
3504 macro is obsoleted, and should be replaced by
3506 AC_CHECK_MEMBERS([struct stat.st_blksize])
3508 - Macro: AC_STRUCT_ST_BLOCKS
3509 If `struct stat' contains an `st_blocks' member, define
3510 `HAVE_STRUCT STAT_ST_BLOCKS'. Otherwise, require an `AC_LIBOBJ'
3511 replacement of `fileblocks'. The former name, `HAVE_ST_BLOCKS' is
3512 to be avoided, as its support will cease in the future.
3514 - Macro: AC_STRUCT_ST_RDEV
3515 If `struct stat' contains an `st_rdev' member, define
3516 `HAVE_STRUCT_STAT_ST_RDEV'. The former name for this macro,
3517 `HAVE_ST_RDEV', is to be avoided as it will cease to be supported
3518 in the future. Actually, even the new macro is obsolete, and
3519 should be replaced by:
3520 AC_CHECK_MEMBERS([struct stat.st_rdev])
3522 - Macro: AC_STRUCT_TM
3523 If `time.h' does not define `struct tm', define `TM_IN_SYS_TIME',
3524 which means that including `sys/time.h' had better define `struct
3527 - Macro: AC_STRUCT_TIMEZONE
3528 Figure out how to get the current timezone. If `struct tm' has a
3529 `tm_zone' member, define `HAVE_STRUCT_TM_TM_ZONE' (and the
3530 obsoleted `HAVE_TM_ZONE'). Otherwise, if the external array
3531 `tzname' is found, define `HAVE_TZNAME'.
3534 File: autoconf.info, Node: Generic Structures, Prev: Particular Structures, Up: Structures
3536 Generic Structure Checks
3537 ------------------------
3539 These macros are used to find structure members not covered by the
3540 "particular" test macros.
3542 - Macro: AC_CHECK_MEMBER (AGGREGATE.MEMBER, [ACTION-IF-FOUND],
3543 [ACTION-IF-NOT-FOUND], [INCLUDES])
3544 Check whether MEMBER is a member of the aggregate AGGREGATE. If
3545 no INCLUDES are specified, the default includes are used (*note
3546 Default Includes::).
3548 AC_CHECK_MEMBER(struct passwd.pw_gecos,,
3549 [AC_MSG_ERROR([We need `passwd.pw_gecos'!])],
3552 You can use this macro for sub-members:
3554 AC_CHECK_MEMBER(struct top.middle.bot)
3556 - Macro: AC_CHECK_MEMBERS (MEMBERS, [ACTION-IF-FOUND],
3557 [ACTION-IF-NOT-FOUND], [INCLUDES])
3558 Check for the existence of each `AGGREGATE.MEMBER' of MEMBERS
3559 using the previous macro. When MEMBER belongs to AGGREGATE,
3560 define `HAVE_AGGREGATE_MEMBER' (in all capitals, with spaces and
3561 dots replaced by underscores).
3563 This macro uses m4 lists:
3564 AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blksize])
3567 File: autoconf.info, Node: Types, Next: Compilers and Preprocessors, Prev: Structures, Up: Existing Tests
3572 The following macros check for C types, either builtin or typedefs.
3573 If there is no macro specifically defined to check for a type you need,
3574 and you don't need to check for any special properties of it, then you
3575 can use a general type-check macro.
3579 * Particular Types:: Special handling to find certain types
3580 * Generic Types:: How to find other types
3583 File: autoconf.info, Node: Particular Types, Next: Generic Types, Prev: Types, Up: Types
3585 Particular Type Checks
3586 ----------------------
3588 These macros check for particular C types in `sys/types.h',
3589 `stdlib.h' and others, if they exist.
3591 - Macro: AC_TYPE_GETGROUPS
3592 Define `GETGROUPS_T' to be whichever of `gid_t' or `int' is the
3593 base type of the array argument to `getgroups'.
3595 - Macro: AC_TYPE_MODE_T
3596 Equivalent to `AC_CHECK_TYPE(mode_t, int)'.
3598 - Macro: AC_TYPE_OFF_T
3599 Equivalent to `AC_CHECK_TYPE(off_t, long)'.
3601 - Macro: AC_TYPE_PID_T
3602 Equivalent to `AC_CHECK_TYPE(pid_t, int)'.
3604 - Macro: AC_TYPE_SIGNAL
3605 If `signal.h' declares `signal' as returning a pointer to a
3606 function returning `void', define `RETSIGTYPE' to be `void';
3607 otherwise, define it to be `int'.
3609 Define signal handlers as returning type `RETSIGTYPE':
3617 - Macro: AC_TYPE_SIZE_T
3618 Equivalent to `AC_CHECK_TYPE(size_t, unsigned)'.
3620 - Macro: AC_TYPE_UID_T
3621 If `uid_t' is not defined, define `uid_t' to be `int' and `gid_t'
3625 File: autoconf.info, Node: Generic Types, Prev: Particular Types, Up: Types
3630 These macros are used to check for types not covered by the
3631 "particular" test macros.
3633 - Macro: AC_CHECK_TYPE (TYPE, [ACTION-IF-FOUND],
3634 [ACTION-IF-NOT-FOUND], [INCLUDES])
3635 Check whether TYPE is defined. It may be a compiler builtin type
3636 or defined by the [INCLUDES] (*note Default Includes::).
3638 - Macro: AC_CHECK_TYPES (TYPES, [ACTION-IF-FOUND],
3639 [ACTION-IF-NOT-FOUND], [INCLUDES])
3640 For each TYPE of the TYPES that is defined, define `HAVE_TYPE' (in
3641 all capitals). If no INCLUDES are specified, the default includes
3642 are used (*note Default Includes::). If ACTION-IF-FOUND is given,
3643 it is additional shell code to execute when one of the types is
3644 found. If ACTION-IF-NOT-FOUND is given, it is executed when one
3645 of the types is not found.
3647 This macro uses m4 lists:
3648 AC_CHECK_TYPES(ptrdiff_t)
3649 AC_CHECK_TYPES([unsigned long long, uintmax_t])
3652 Autoconf, up to 2.13, used to provide to another version of
3653 `AC_CHECK_TYPE', broken by design. In order to keep backward
3654 compatibility, a simple heuristics, quite safe but not totally, is
3655 implemented. In case of doubt, read the documentation of the former
3656 `AC_CHECK_TYPE', see *Note Obsolete Macros::.
3659 File: autoconf.info, Node: Compilers and Preprocessors, Next: System Services, Prev: Types, Up: Existing Tests
3661 Compilers and Preprocessors
3662 ===========================
3664 All the tests for compilers (`AC_PROG_CC', `AC_PROG_CXX',
3665 `AC_PROG_F77') define the output variable `EXEEXT' based on the output
3666 of the compiler, typically to the empty string if Unix and `.exe' if
3669 They also define the output variable `OBJEXT' based on the output of
3670 the compiler, after .c files have been excluded, typically to `o' if
3671 Unix, `obj' if Win32.
3673 If the compiler being used does not produce executables, they fail.
3674 If the executables can't be run, and cross-compilation is not enabled,
3675 they fail too. *Note Manual Configuration::, for more on support for
3680 * Generic Compiler Characteristics:: Language independent tests
3681 * C Compiler:: Checking its characteristics
3682 * C++ Compiler:: Likewise
3683 * Fortran 77 Compiler:: Likewise
3686 File: autoconf.info, Node: Generic Compiler Characteristics, Next: C Compiler, Prev: Compilers and Preprocessors, Up: Compilers and Preprocessors
3688 Generic Compiler Characteristics
3689 --------------------------------
3691 - Macro: AC_CHECK_SIZEOF (TYPE, [UNUSED], [INCLUDES])
3692 Define `SIZEOF_TYPE' (*note Standard Symbols::) to be the size in
3693 bytes of TYPE. If `type' is unknown, it gets a size of 0. If no
3694 INCLUDES are specified, the default includes are used (*note
3695 Default Includes::). If you provide INCLUDE, make sure to include
3696 `stdio.h' which is required for this macro to run.
3698 This macro now works even when cross-compiling. The UNUSED
3699 argument was used when cross-compiling.
3701 For example, the call
3703 AC_CHECK_SIZEOF(int *)
3705 defines `SIZEOF_INT_P' to be 8 on DEC Alpha AXP systems.
3708 File: autoconf.info, Node: C Compiler, Next: C++ Compiler, Prev: Generic Compiler Characteristics, Up: Compilers and Preprocessors
3710 C Compiler Characteristics
3711 --------------------------
3713 - Macro: AC_PROG_CC ([COMPILER-SEARCH-LIST])
3714 Determine a C compiler to use. If `CC' is not already set in the
3715 environment, check for `gcc' and `cc', then for other C compilers.
3716 Set output variable `CC' to the name of the compiler found.
3718 This macro may, however, be invoked with an optional first argument
3719 which, if specified, must be a space separated list of C compilers
3720 to search for. This just gives the user an opportunity to specify
3721 an alternative search list for the C compiler. For example, if
3722 you didn't like the default order, then you could invoke
3723 `AC_PROG_CC' like this:
3725 AC_PROG_CC(cl egcs gcc cc)
3727 If using the GNU C compiler, set shell variable `GCC' to `yes'.
3728 If output variable `CFLAGS' was not already set, set it to `-g
3729 -O2' for the GNU C compiler (`-O2' on systems where GCC does not
3730 accept `-g'), or `-g' for other compilers.
3732 - Macro: AC_PROG_CC_C_O
3733 If the C compiler does not accept the `-c' and `-o' options
3734 simultaneously, define `NO_MINUS_C_MINUS_O'. This macro actually
3735 tests both the compiler found by `AC_PROG_CC', and, if different,
3736 the first `cc' in the path. The test fails if one fails. This
3737 macro was created for GNU Make to choose the default C compilation
3740 - Macro: AC_PROG_CC_STDC
3741 If the C compiler is not in ANSI C mode by default, try to add an
3742 option to output variable `CC' to make it so. This macro tries
3743 various options that select ANSI C on some system or another. It
3744 considers the compiler to be in ANSI C mode if it handles function
3745 prototypes correctly.
3747 If you use this macro, you should check after calling it whether
3748 the C compiler has been set to accept ANSI C; if not, the shell
3749 variable `ac_cv_prog_cc_stdc' is set to `no'. If you wrote your
3750 source code in ANSI C, you can make an un-ANSIfied copy of it by
3751 using the program `ansi2knr', which comes with Automake.
3753 - Macro: AC_PROG_CPP
3754 Set output variable `CPP' to a command that runs the C
3755 preprocessor. If `$CC -E' doesn't work, `/lib/cpp' is used. It
3756 is only portable to run `CPP' on files with a `.c' extension.
3758 If the current language is C (*note Language Choice::), many of the
3759 specific test macros use the value of `CPP' indirectly by calling
3760 `AC_TRY_CPP', `AC_CHECK_HEADER', `AC_EGREP_HEADER', or
3763 Some preprocessors don't indicate missing include files by the
3764 error status. For such preprocessors an internal variable is set
3765 that causes other macros to check the standard error from the
3766 preprocessor and consider the test failed if any warnings have
3769 The following macros check for C compiler or machine architecture
3770 features. To check for characteristics not listed here, use
3771 `AC_TRY_COMPILE' (*note Examining Syntax::) or `AC_TRY_RUN' (*note Run
3774 - Macro: AC_C_BIGENDIAN
3775 If words are stored with the most significant byte first (like
3776 Motorola and SPARC, but not Intel and VAX, CPUs), define
3780 If the C compiler does not fully support the ANSI C qualifier
3781 `const', define `const' to be empty. Some C compilers that do not
3782 define `__STDC__' do support `const'; some compilers that define
3783 `__STDC__' do not completely support `const'. Programs can simply
3784 use `const' as if every C compiler supported it; for those that
3785 don't, the `Makefile' or configuration header file will define it
3788 Occasionally installers use a C++ compiler to compile C code,
3789 typically because they lack a C compiler. This causes problems
3790 with `const', because C and C++ treat `const' differently. For
3795 is valid in C but not in C++. These differences unfortunately
3796 cannot be papered over by defining `const' to be empty.
3798 If `autoconf' detects this situation, it leaves `const' alone, as
3799 this generally yields better results in practice. However, using a
3800 C++ compiler to compile C code is not recommended or supported, and
3801 installers who run into trouble in this area should get a C
3802 compiler like GCC to compile their C code.
3804 - Macro: AC_C_VOLATILE
3805 If the C compiler does not understand the keyword `volatile',
3806 define `volatile' to be empty. Programs can simply use `volatile'
3807 as if every C compiler supported it; for those that do not, the
3808 `Makefile' or configuration header will define it as empty.
3810 If the correctness of your program depends on the semantics of
3811 `volatile', simply defining it to be empty does, in a sense, break
3812 your code. However, given that the compiler does not support
3813 `volatile', you are at its mercy anyway. At least your program
3814 will compile, when it wouldn't before.
3816 In general, the `volatile' keyword is a feature of ANSI C, so you
3817 might expect that `volatile' is available only when `__STDC__' is
3818 defined. However, Ultrix 4.3's native compiler does support
3819 volatile, but does not defined `__STDC__'.
3821 - Macro: AC_C_INLINE
3822 If the C compiler supports the keyword `inline', do nothing.
3823 Otherwise define `inline' to `__inline__' or `__inline' if it
3824 accepts one of those, otherwise define `inline' to be empty.
3826 - Macro: AC_C_CHAR_UNSIGNED
3827 If the C type `char' is unsigned, define `__CHAR_UNSIGNED__',
3828 unless the C compiler predefines it.
3830 - Macro: AC_C_LONG_DOUBLE
3831 If the C compiler supports the `long double' type, define
3832 `HAVE_LONG_DOUBLE'. Some C compilers that do not define
3833 `__STDC__' do support the `long double' type; some compilers that
3834 define `__STDC__' do not support `long double'.
3836 - Macro: AC_C_STRINGIZE
3837 If the C preprocessor supports the stringizing operator, define
3838 `HAVE_STRINGIZE'. The stringizing operator is `#' and is found in
3839 macros such as this:
3843 - Macro: AC_C_PROTOTYPES
3844 Check to see if function prototypes are understood by the
3845 compiler. If so, define `PROTOTYPES'. In the case the compiler
3846 does not handle prototypes, you should use `ansi2knr', which comes
3847 with the Automake distribution, to unprotoize function
3848 definitions. For function prototypes, you should first define
3853 # define PARAMS(protos) protos
3854 # else /* no PROTOTYPES */
3855 # define PARAMS(protos) ()
3856 # endif /* no PROTOTYPES */
3859 then use it this way:
3861 size_t my_strlen PARAMS ((const char *));
3863 - Macro: AC_PROG_GCC_TRADITIONAL
3864 Add `-traditional' to output variable `CC' if using the GNU C
3865 compiler and `ioctl' does not work properly without
3866 `-traditional'. That usually happens when the fixed header files
3867 have not been installed on an old system. Since recent versions
3868 of the GNU C compiler fix the header files automatically when
3869 installed, this is becoming a less prevalent problem.
3872 File: autoconf.info, Node: C++ Compiler, Next: Fortran 77 Compiler, Prev: C Compiler, Up: Compilers and Preprocessors
3874 C++ Compiler Characteristics
3875 ----------------------------
3877 - Macro: AC_PROG_CXX ([COMPILER-SEARCH-LIST])
3878 Determine a C++ compiler to use. Check if the environment variable
3879 `CXX' or `CCC' (in that order) is set; if so, then set output
3880 variable `CXX' to its value.
3882 Otherwise, if the macro is invoked without an argument, then
3883 search for a C++ compiler under the likely names (first `g++' and
3884 `c++' then other names). If none of those checks succeed, then as
3885 a last resort set `CXX' to `g++'.
3887 This macro may, however, be invoked with an optional first argument
3888 which, if specified, must be a space separated list of C++
3889 compilers to search for. This just gives the user an opportunity
3890 to specify an alternative search list for the C++ compiler. For
3891 example, if you didn't like the default order, then you could
3892 invoke `AC_PROG_CXX' like this:
3894 AC_PROG_CXX(cl KCC CC cxx cc++ xlC aCC c++ g++ egcs gcc)
3896 If using the GNU C++ compiler, set shell variable `GXX' to `yes'.
3897 If output variable `CXXFLAGS' was not already set, set it to `-g
3898 -O2' for the GNU C++ compiler (`-O2' on systems where G++ does not
3899 accept `-g'), or `-g' for other compilers.
3901 - Macro: AC_PROG_CXXCPP
3902 Set output variable `CXXCPP' to a command that runs the C++
3903 preprocessor. If `$CXX -E' doesn't work, `/lib/cpp' is used. It
3904 is only portable to run `CXXCPP' on files with a `.c', `.C', or
3907 If the current language is C++ (*note Language Choice::), many of
3908 the specific test macros use the value of `CXXCPP' indirectly by
3909 calling `AC_TRY_CPP', `AC_CHECK_HEADER', `AC_EGREP_HEADER', or
3912 Some preprocessors don't indicate missing include files by the
3913 error status. For such preprocessors an internal variable is set
3914 that causes other macros to check the standard error from the
3915 preprocessor and consider the test failed if any warnings have
3916 been reported. However, it is not known whether such broken
3917 preprocessors exist for C++.
3920 File: autoconf.info, Node: Fortran 77 Compiler, Prev: C++ Compiler, Up: Compilers and Preprocessors
3922 Fortran 77 Compiler Characteristics
3923 -----------------------------------
3925 - Macro: AC_PROG_F77 ([COMPILER-SEARCH-LIST])
3926 Determine a Fortran 77 compiler to use. If `F77' is not already
3927 set in the environment, then check for `g77' and `f77', and then
3928 some other names. Set the output variable `F77' to the name of
3931 This macro may, however, be invoked with an optional first argument
3932 which, if specified, must be a space separated list of Fortran 77
3933 compilers to search for. This just gives the user an opportunity
3934 to specify an alternative search list for the Fortran 77 compiler.
3935 For example, if you didn't like the default order, then you could
3936 invoke `AC_PROG_F77' like this:
3938 AC_PROG_F77(fl32 f77 fort77 xlf cf77 g77 f90 xlf90)
3940 If using `g77' (the GNU Fortran 77 compiler), then `AC_PROG_F77'
3941 will set the shell variable `G77' to `yes'. If the output
3942 variable `FFLAGS' was not already set in the environment, then set
3943 it to `-g -02' for `g77' (or `-O2' where `g77' does not accept
3944 `-g'). Otherwise, set `FFLAGS' to `-g' for all other Fortran 77
3947 - Macro: AC_PROG_F77_C_O
3948 Test if the Fortran 77 compiler accepts the options `-c' and `-o'
3949 simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.
3951 The following macros check for Fortran 77 compiler characteristics.
3952 To check for characteristics not listed here, use `AC_TRY_COMPILE'
3953 (*note Examining Syntax::) or `AC_TRY_RUN' (*note Run Time::), making
3954 sure to first set the current language to Fortran 77 `AC_LANG(Fortran
3955 77)' (*note Language Choice::).
3957 - Macro: AC_F77_LIBRARY_LDFLAGS
3958 Determine the linker flags (e.g. `-L' and `-l') for the "Fortran
3959 77 intrinsic and run-time libraries" that are required to
3960 successfully link a Fortran 77 program or shared library. The
3961 output variable `FLIBS' is set to these flags.
3963 This macro is intended to be used in those situations when it is
3964 necessary to mix, e.g. C++ and Fortran 77 source code into a single
3965 program or shared library (*note Mixing Fortran 77 With C and C++:
3966 (automake)Mixing Fortran 77 With C and C++.).
3968 For example, if object files from a C++ and Fortran 77 compiler
3969 must be linked together, then the C++ compiler/linker must be used
3970 for linking (since special C++-ish things need to happen at link
3971 time like calling global constructors, instantiating templates,
3972 enabling exception support, etc.).
3974 However, the Fortran 77 intrinsic and run-time libraries must be
3975 linked in as well, but the C++ compiler/linker doesn't know by
3976 default how to add these Fortran 77 libraries. Hence, the macro
3977 `AC_F77_LIBRARY_LDFLAGS' was created to determine these Fortran 77
3980 The macro `AC_F77_DUMMY_MAIN' or `AC_F77_MAIN' will probably also
3981 be necessary to link C/C++ with Fortran; see below.
3983 - Macro: AC_F77_DUMMY_MAIN ([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3984 With many compilers, the Fortran libraries detected by
3985 `AC_F77_LIBRARY_LDFLAGS' provide their own `main' entry function
3986 that initializes things like Fortran I/O, and which then calls a
3987 user-provided entry function named e.g. `MAIN__' to run the user's
3988 program. The `AC_F77_DUMMY_MAIN' or `AC_F77_MAIN' macro figures
3989 out how to deal with this interaction.
3991 When using Fortran for purely numerical functions (no I/O,
3992 etcetera), users often prefer to provide their own `main' and skip
3993 the Fortran library initializations. In this case, however, one
3994 may still need to provide a dummy `MAIN__' routine in order to
3995 prevent linking errors on some systems. `AC_F77_DUMMY_MAIN'
3996 detects whether any such routine is _required_ for linking, and
3997 what its name is; the shell variable `F77_DUMMY_MAIN' holds this
3998 name, `unknown' when no solution was found, and `none' when no
3999 such dummy main is needed.
4001 By default, ACTION-IF-FOUND defines `F77_DUMMY_MAIN' to the name
4002 of this routine (e.g. `MAIN__') _if_ it is required.
4003 [ACTION-IF-NOT-FOUND] defaults to exiting with an error.
4005 In order to link with Fortran routines, the user's C/C++ program
4006 should then include the following code to define the dummy main if
4009 #ifdef F77_DUMMY_MAIN
4013 int F77_DUMMY_MAIN() { return 1; }
4016 Note that `AC_F77_DUMMY_MAIN' is called automatically from
4017 `AC_F77_WRAPPERS'; there is generally no need to call it explicitly
4018 unless one wants to change the default actions.
4020 - Macro: AC_F77_MAIN
4021 As discussed above for `AC_F77_DUMMY_MAIN', many Fortran libraries
4022 allow you to provide an entry point called e.g. `MAIN__' instead of
4023 the usual `main', which is then called by a `main' function in the
4024 Fortran libraries that initializes things like Fortran I/O. The
4025 `AC_F77_MAIN' macro detects whether it is _possible_ to utilize
4026 such an alternate main function, and defines `F77_MAIN' to the
4027 name of the function. (If no alternate main function name is
4028 found, `F77_MAIN' is simply defined to `main'.)
4030 Thus, when calling Fortran routines from C that perform things
4031 like I/O, one should use this macro and name the "main" function
4032 `F77_MAIN' instead of `main'.
4034 - Macro: AC_F77_WRAPPERS
4035 Defines C macros `F77_FUNC(name,NAME)' and `F77_FUNC_(name,NAME)'
4036 to properly mangle the names of C/C++ identifiers, and identifiers
4037 with underscores, respectively, so that they match the
4038 name-mangling scheme used by the Fortran 77 compiler.
4040 Fortran 77 is case-insensitive, and in order to achieve this the
4041 Fortran 77 compiler converts all identifiers into a canonical case
4042 and format. To call a Fortran 77 subroutine from C or to write a
4043 C function that is callable from Fortran 77, the C program must
4044 explicitly use identifiers in the format expected by the Fortran
4045 77 compiler. In order to do this, one simply wraps all C
4046 identifiers in one of the macros provided by `AC_F77_WRAPPERS'.
4047 For example, suppose you have the following Fortran 77 subroutine:
4049 subroutine foobar(x,y)
4050 double precision x, y
4055 You would then declare its prototype in C or C++ as:
4057 #define FOOBAR_F77 F77_FUNC(foobar,FOOBAR)
4059 extern "C" /* prevent C++ name mangling */
4061 void FOOBAR_F77(double *x, double *y);
4063 Note that we pass both the lowercase and uppercase versions of the
4064 function name to `F77_FUNC' so that it can select the right one.
4065 Note also that all parameters to Fortran 77 routines are passed as
4066 pointers (*note Mixing Fortran 77 With C and C++: (automake)Mixing
4067 Fortran 77 With C and C++.).
4069 Although Autoconf tries to be intelligent about detecting the
4070 name-mangling scheme of the Fortran 77 compiler, there may be
4071 Fortran 77 compilers that it doesn't support yet. In this case,
4072 the above code will generate a compile-time error, but some other
4073 behavior (e.g. disabling Fortran-related features) can be induced
4074 by checking whether the `F77_FUNC' macro is defined.
4076 Now, to call that routine from a C program, we would do something
4080 double x = 2.7183, y;
4084 If the Fortran 77 identifier contains an underscore (e.g.
4085 `foo_bar'), you should use `F77_FUNC_' instead of `F77_FUNC' (with
4086 the same arguments). This is because some Fortran 77 compilers
4087 mangle names differently if they contain an underscore.
4089 - Macro: AC_F77_FUNC (NAME, [SHELLVAR])
4090 Given an identifier NAME, set the shell variable SHELLVAR to hold
4091 the mangled version NAME according to the rules of the Fortran 77
4092 linker (see also `AC_F77_WRAPPERS'). SHELLVAR is optional; if it
4093 is not supplied, the shell variable will be simply NAME. The
4094 purpose of this macro is to give the caller a way to access the
4095 name-mangling information other than through the C preprocessor as
4096 above; for example, to call Fortran routines from some language
4100 File: autoconf.info, Node: System Services, Next: UNIX Variants, Prev: Compilers and Preprocessors, Up: Existing Tests
4105 The following macros check for operating system services or
4109 Try to locate the X Window System include files and libraries. If
4110 the user gave the command line options `--x-includes=DIR' and
4111 `--x-libraries=DIR', use those directories. If either or both
4112 were not given, get the missing values by running `xmkmf' on a
4113 trivial `Imakefile' and examining the `Makefile' that it produces.
4114 If that fails (such as if `xmkmf' is not present), look for them
4115 in several directories where they often reside. If either method
4116 is successful, set the shell variables `x_includes' and
4117 `x_libraries' to their locations, unless they are in directories
4118 the compiler searches by default.
4120 If both methods fail, or the user gave the command line option
4121 `--without-x', set the shell variable `no_x' to `yes'; otherwise
4122 set it to the empty string.
4124 - Macro: AC_PATH_XTRA
4125 An enhanced version of `AC_PATH_X'. It adds the C compiler flags
4126 that X needs to output variable `X_CFLAGS', and the X linker flags
4127 to `X_LIBS'. Define `X_DISPLAY_MISSING' if X is not available.
4129 This macro also checks for special libraries that some systems
4130 need in order to compile X programs. It adds any that the system
4131 needs to output variable `X_EXTRA_LIBS'. And it checks for
4132 special X11R6 libraries that need to be linked with before
4133 `-lX11', and adds any found to the output variable `X_PRE_LIBS'.
4136 - Macro: AC_SYS_INTERPRETER
4137 Check whether the system supports starting scripts with a line of
4138 the form `#! /bin/csh' to select the interpreter to use for the
4139 script. After running this macro, shell code in `configure.ac'
4140 can check the shell variable `interpval'; it will be set to `yes'
4141 if the system supports `#!', `no' if not.
4143 - Macro: AC_SYS_LARGEFILE
4144 Arrange for large-file support(1). On some hosts, one must use
4145 special compiler options to build programs that can access large
4146 files. Append any such options to the output variable `CC'.
4147 Define `_FILE_OFFSET_BITS' and `_LARGE_FILES' if necessary.
4149 Large-file support can be disabled by configuring with the
4150 `--disable-largefile' option.
4152 If you use this macro, check that your program works even when
4153 `off_t' is longer than `long', since this is common when
4154 large-file support is enabled. For example, it is not correct to
4155 print an arbitrary `off_t' value `X' with `printf ("%ld", (long)
4158 - Macro: AC_SYS_LONG_FILE_NAMES
4159 If the system supports file names longer than 14 characters, define
4160 `HAVE_LONG_FILE_NAMES'.
4162 - Macro: AC_SYS_POSIX_TERMIOS
4163 Check to see if POSIX termios headers and functions are available
4164 on the system. If so, set the shell variable
4165 `am_cv_sys_posix_termios' to `yes'. If not, set the variable to
4168 ---------- Footnotes ----------
4170 (1) large-file support,
4171 <http://www.sas.com/standards/large.file/x_open.20Mar96.html>.
4174 File: autoconf.info, Node: UNIX Variants, Prev: System Services, Up: Existing Tests
4179 The following macros check for certain operating systems that need
4180 special treatment for some programs, due to exceptional oddities in
4181 their header files or libraries. These macros are warts; they will be
4182 replaced by a more systematic approach, based on the functions they make
4183 available or the environments they provide.
4186 If on AIX, define `_ALL_SOURCE'. Allows the use of some BSD
4187 functions. Should be called before any macros that run the C
4190 - Macro: AC_ISC_POSIX
4191 If on a POSIXized ISC UNIX, define `_POSIX_SOURCE' and add
4192 `-posix' (for the GNU C compiler) or `-Xp' (for other C compilers)
4193 to output variable `CC'. This allows the use of POSIX facilities.
4194 Must be called after `AC_PROG_CC' and before any other macros
4195 that run the C compiler.
4198 If on Minix, define `_MINIX' and `_POSIX_SOURCE' and define
4199 `_POSIX_1_SOURCE' to be 2. This allows the use of POSIX
4200 facilities. Should be called before any macros that run the C
4204 File: autoconf.info, Node: Writing Tests, Next: Results, Prev: Existing Tests, Up: Top
4209 If the existing feature tests don't do something you need, you have
4210 to write new ones. These macros are the building blocks. They provide
4211 ways for other macros to check whether various kinds of features are
4212 available and report the results.
4214 This chapter contains some suggestions and some of the reasons why
4215 the existing tests are written the way they are. You can also learn a
4216 lot about how to write Autoconf tests by looking at the existing ones.
4217 If something goes wrong in one or more of the Autoconf tests, this
4218 information can help you understand the assumptions behind them, which
4219 might help you figure out how to best solve the problem.
4221 These macros check the output of the C compiler system. They do not
4222 cache the results of their tests for future use (*note Caching
4223 Results::), because they don't know enough about the information they
4224 are checking for to generate a cache variable name. They also do not
4225 print any messages, for the same reason. The checks for particular
4226 kinds of C features call these macros and do cache their results and
4227 print messages about what they're checking for.
4229 When you write a feature test that could be applicable to more than
4230 one software package, the best thing to do is encapsulate it in a new
4231 macro. *Note Writing Autoconf Macros::, for how to do that.
4235 * Examining Declarations:: Detecting header files and declarations
4236 * Examining Syntax:: Detecting language syntax features
4237 * Examining Libraries:: Detecting functions and global variables
4238 * Run Time:: Testing for run-time features
4239 * Systemology:: A zoology of operating systems
4240 * Multiple Cases:: Tests for several possible values
4241 * Language Choice:: Selecting which language to use for testing
4244 File: autoconf.info, Node: Examining Declarations, Next: Examining Syntax, Prev: Writing Tests, Up: Writing Tests
4246 Examining Declarations
4247 ======================
4249 The macro `AC_TRY_CPP' is used to check whether particular header
4250 files exist. You can check for one at a time, or more than one if you
4251 need several header files to all exist for some purpose.
4253 - Macro: AC_TRY_CPP (INCLUDES, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
4254 INCLUDES is C or C++ `#include' statements and declarations, on
4255 which shell variable, back quote, and backslash substitutions are
4256 performed. (Actually, it can be any C program, but other
4257 statements are probably not useful.) If the preprocessor produces
4258 no error messages while processing it, run shell commands
4259 ACTION-IF-TRUE. Otherwise run shell commands ACTION-IF-FALSE.
4261 This macro uses `CPPFLAGS', but not `CFLAGS', because `-g', `-O',
4262 etc. are not valid options to many C preprocessors.
4264 Here is how to find out whether a header file contains a particular
4265 declaration, such as a typedef, a structure, a structure member, or a
4266 function. Use `AC_EGREP_HEADER' instead of running `grep' directly on
4267 the header file; on some systems the symbol might be defined in another
4268 header file that the file you are checking `#include's.
4270 - Macro: AC_EGREP_HEADER (PATTERN, HEADER-FILE, ACTION-IF-FOUND,
4271 [ACTION-IF-NOT-FOUND])
4272 If the output of running the preprocessor on the system header file
4273 HEADER-FILE matches the `egrep' regular expression PATTERN,
4274 execute shell commands ACTION-IF-FOUND, otherwise execute
4275 ACTION-IF-NOT-FOUND.
4277 To check for C preprocessor symbols, either defined by header files
4278 or predefined by the C preprocessor, use `AC_EGREP_CPP'. Here is an
4279 example of the latter:
4285 ], is_aix=yes, is_aix=no)
4287 - Macro: AC_EGREP_CPP (PATTERN, PROGRAM, [ACTION-IF-FOUND],
4288 [ACTION-IF-NOT-FOUND])
4289 PROGRAM is the text of a C or C++ program, on which shell
4290 variable, back quote, and backslash substitutions are performed.
4291 If the output of running the preprocessor on PROGRAM matches the
4292 `egrep' regular expression PATTERN, execute shell commands
4293 ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND.
4295 This macro calls `AC_PROG_CPP' or `AC_PROG_CXXCPP' (depending on
4296 which language is current, *note Language Choice::), if it hasn't
4297 been called already.
4300 File: autoconf.info, Node: Examining Syntax, Next: Examining Libraries, Prev: Examining Declarations, Up: Writing Tests
4305 To check for a syntax feature of the C, C++ or Fortran 77 compiler,
4306 such as whether it recognizes a certain keyword, use `AC_TRY_COMPILE' to
4307 try to compile a small program that uses that feature. You can also use
4308 it to check for structures and structure members that are not present on
4311 - Macro: AC_TRY_COMPILE (INCLUDES, FUNCTION-BODY, [ACTION-IF-FOUND],
4312 [ACTION-IF-NOT-FOUND])
4313 Create a C, C++ or Fortran 77 test program (depending on which
4314 language is current, *note Language Choice::), to see whether a
4315 function whose body consists of FUNCTION-BODY can be compiled.
4317 For C and C++, INCLUDES is any `#include' statements needed by the
4318 code in FUNCTION-BODY (INCLUDES will be ignored if the currently
4319 selected language is Fortran 77). This macro also uses `CFLAGS'
4320 or `CXXFLAGS' if either C or C++ is the currently selected
4321 language, as well as `CPPFLAGS', when compiling. If Fortran 77 is
4322 the currently selected language then `FFLAGS' will be used when
4325 If the file compiles successfully, run shell commands
4326 ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.
4328 This macro does not try to link; use `AC_TRY_LINK' if you need to
4329 do that (*note Examining Libraries::).
4332 File: autoconf.info, Node: Examining Libraries, Next: Run Time, Prev: Examining Syntax, Up: Writing Tests
4337 To check for a library, a function, or a global variable, Autoconf
4338 `configure' scripts try to compile and link a small program that uses
4339 it. This is unlike Metaconfig, which by default uses `nm' or `ar' on
4340 the C library to try to figure out which functions are available.
4341 Trying to link with the function is usually a more reliable approach
4342 because it avoids dealing with the variations in the options and output
4343 formats of `nm' and `ar' and in the location of the standard libraries.
4344 It also allows configuring for cross-compilation or checking a
4345 function's runtime behavior if needed. On the other hand, it can be
4346 slower than scanning the libraries once.
4348 A few systems have linkers that do not return a failure exit status
4349 when there are unresolved functions in the link. This bug makes the
4350 configuration scripts produced by Autoconf unusable on those systems.
4351 However, some of them can be given options that make the exit status
4352 correct. This is a problem that Autoconf does not currently handle
4353 automatically. If users encounter this problem, they might be able to
4354 solve it by setting `LDFLAGS' in the environment to pass whatever
4355 options the linker needs (for example, `-Wl,-dn' on MIPS RISC/OS).
4357 `AC_TRY_LINK' is used to compile test programs to test for functions
4358 and global variables. It is also used by `AC_CHECK_LIB' to check for
4359 libraries (*note Libraries::), by adding the library being checked for
4360 to `LIBS' temporarily and trying to link a small program.
4362 - Macro: AC_TRY_LINK (INCLUDES, FUNCTION-BODY, [ACTION-IF-FOUND],
4363 [ACTION-IF-NOT-FOUND])
4364 Depending on the current language (*note Language Choice::),
4365 create a test program to see whether a function whose body
4366 consists of FUNCTION-BODY can be compiled and linked.
4368 For C and C++, INCLUDES is any `#include' statements needed by the
4369 code in FUNCTION-BODY (INCLUDES will be ignored if the currently
4370 selected language is Fortran 77). This macro also uses `CFLAGS'
4371 or `CXXFLAGS' if either C or C++ is the currently selected
4372 language, as well as `CPPFLAGS', when compiling. If Fortran 77 is
4373 the currently selected language then `FFLAGS' will be used when
4374 compiling. However, both `LDFLAGS' and `LIBS' will be used during
4375 linking in all cases.
4377 If the file compiles and links successfully, run shell commands
4378 ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.
4380 - Macro: AC_TRY_LINK_FUNC (FUNCTION, [ACTION-IF-FOUND],
4381 [ACTION-IF-NOT-FOUND])
4382 Depending on the current language (*note Language Choice::),
4383 create a test program to see whether a program whose body consists
4384 of a prototype of and a call to FUNCTION can be compiled and
4387 If the file compiles and links successfully, run shell commands
4388 ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND.
4391 File: autoconf.info, Node: Run Time, Next: Systemology, Prev: Examining Libraries, Up: Writing Tests
4393 Checking Run Time Behavior
4394 ==========================
4396 Sometimes you need to find out how a system performs at run time,
4397 such as whether a given function has a certain capability or bug. If
4398 you can, make such checks when your program runs instead of when it is
4399 configured. You can check for things like the machine's endianness when
4400 your program initializes itself.
4402 If you really need to test for a run-time behavior while configuring,
4403 you can write a test program to determine the result, and compile and
4404 run it using `AC_TRY_RUN'. Avoid running test programs if possible,
4405 because this prevents people from configuring your package for
4410 * Test Programs:: Running test programs
4411 * Guidelines:: General rules for writing test programs
4412 * Test Functions:: Avoiding pitfalls in test programs
4415 File: autoconf.info, Node: Test Programs, Next: Guidelines, Prev: Run Time, Up: Run Time
4417 Running Test Programs
4418 ---------------------
4420 Use the following macro if you need to test run-time behavior of the
4421 system while configuring.
4423 - Macro: AC_TRY_RUN (PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE],
4424 [ACTION-IF-CROSS-COMPILING])
4425 PROGRAM is the text of a C program, on which shell variable and
4426 back quote substitutions are performed. If it compiles and links
4427 successfully and returns an exit status of 0 when executed, run
4428 shell commands ACTION-IF-TRUE. Otherwise, run shell commands
4429 ACTION-IF-FALSE; the exit status of the program is available in
4430 the shell variable `$?'. This macro uses `CFLAGS' or `CXXFLAGS',
4431 `CPPFLAGS', `LDFLAGS', and `LIBS' when compiling.
4433 If the C compiler being used does not produce executables that run
4434 on the system where `configure' is being run, then the test
4435 program is not run. If the optional shell commands
4436 ACTION-IF-CROSS-COMPILING are given, they are run instead.
4437 Otherwise, `configure' prints an error message and exits.
4439 Try to provide a pessimistic default value to use when
4440 cross-compiling makes run-time tests impossible. You do this by
4441 passing the optional last argument to `AC_TRY_RUN'. `autoconf' prints
4442 a warning message when creating `configure' each time it encounters a
4443 call to `AC_TRY_RUN' with no ACTION-IF-CROSS-COMPILING argument given.
4444 You may ignore the warning, though users will not be able to configure
4445 your package for cross-compiling. A few of the macros distributed with
4446 Autoconf produce this warning message.
4448 To configure for cross-compiling you can also choose a value for
4449 those parameters based on the canonical system name (*note Manual
4450 Configuration::). Alternatively, set up a test results cache file with
4451 the correct values for the host system (*note Caching Results::).
4453 To provide a default for calls of `AC_TRY_RUN' that are embedded in
4454 other macros, including a few of the ones that come with Autoconf, you
4455 can call `AC_PROG_CC' before running them. Then, if the shell variable
4456 `cross_compiling' is set to `yes', use an alternate method to get the
4457 results instead of calling the macros.
4460 File: autoconf.info, Node: Guidelines, Next: Test Functions, Prev: Test Programs, Up: Run Time
4462 Guidelines for Test Programs
4463 ----------------------------
4465 Test programs should not write anything to the standard output. They
4466 should return 0 if the test succeeds, nonzero otherwise, so that success
4467 can be distinguished easily from a core dump or other failure;
4468 segmentation violations and other failures produce a nonzero exit
4469 status. Test programs should `exit', not `return', from `main',
4470 because on some systems (old Suns, at least) the argument to `return'
4471 in `main' is ignored.
4473 Test programs can use `#if' or `#ifdef' to check the values of
4474 preprocessor macros defined by tests that have already run. For
4475 example, if you call `AC_HEADER_STDC', then later on in `configure.ac'
4476 you can have a test program that includes an ANSI C header file
4480 # include <stdlib.h>
4483 If a test program needs to use or create a data file, give it a name
4484 that starts with `conftest', such as `conftest.data'. The `configure'
4485 script cleans up by running `rm -rf conftest*' after running test
4486 programs and if the script is interrupted.
4489 File: autoconf.info, Node: Test Functions, Prev: Guidelines, Up: Run Time
4494 Function declarations in test programs should have a prototype
4495 conditionalized for C++. In practice, though, test programs rarely need
4496 functions that take arguments.
4504 Functions that test programs declare should also be conditionalized
4505 for C++, which requires `extern "C"' prototypes. Make sure to not
4506 include any header files containing clashing prototypes.
4509 extern "C" void *malloc (size_t);
4514 If a test program calls a function with invalid parameters (just to
4515 see whether it exists), organize the program to ensure that it never
4516 invokes that function. You can do this by calling it in another
4517 function that is never invoked. You can't do it by putting it after a
4518 call to `exit', because GCC version 2 knows that `exit' never returns
4519 and optimizes out any code that follows it in the same block.
4521 If you include any header files, make sure to call the functions
4522 relevant to them with the correct number of arguments, even if they are
4523 just 0, to avoid compilation errors due to prototypes. GCC version 2
4524 has internal prototypes for several functions that it automatically
4525 inlines; for example, `memcpy'. To avoid errors when checking for
4526 them, either pass them the correct number of arguments or redeclare them
4527 with a different return type (such as `char').
4530 File: autoconf.info, Node: Systemology, Next: Multiple Cases, Prev: Run Time, Up: Writing Tests
4535 This section aims at presenting some systems and pointers to
4536 documentation. It may help you addressing particular problems reported
4540 QNX is a realtime operating system running on Intel architecture
4541 meant to be scalable from the small embedded systems to hundred
4542 processor super-computer. It claims to be POSIX certified. More
4543 information is available on the QNX home page(1), including the QNX
4546 ---------- Footnotes ----------
4548 (1) QNX home page, <www.qnx.com>.
4550 (2) QNX man pages, <http://support.qnx.com/support/docs/qnx4/>.
4553 File: autoconf.info, Node: Multiple Cases, Next: Language Choice, Prev: Systemology, Up: Writing Tests
4558 Some operations are accomplished in several possible ways, depending
4559 on the UNIX variant. Checking for them essentially requires a "case
4560 statement". Autoconf does not directly provide one; however, it is
4561 easy to simulate by using a shell variable to keep track of whether a
4562 way to perform the operation has been found yet.
4564 Here is an example that uses the shell variable `fstype' to keep
4565 track of whether the remaining cases need to be checked.
4567 AC_MSG_CHECKING([how to get file system type])
4569 # The order of these tests is important.
4570 AC_TRY_CPP([#include <sys/statvfs.h>
4571 #include <sys/fstyp.h>],
4572 [AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4])
4573 if test $fstype = no; then
4574 AC_TRY_CPP([#include <sys/statfs.h>
4575 #include <sys/fstyp.h>],
4576 [AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3])
4578 if test $fstype = no; then
4579 AC_TRY_CPP([#include <sys/statfs.h>
4580 #include <sys/vmount.h>],
4581 [AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX])
4583 # (more cases omitted here)
4584 AC_MSG_RESULT([$fstype])
4587 File: autoconf.info, Node: Language Choice, Prev: Multiple Cases, Up: Writing Tests
4592 Autoconf-generated `configure' scripts check for the C compiler and
4593 its features by default. Packages that use other programming languages
4594 (maybe more than one, e.g. C and C++) need to test features of the
4595 compilers for the respective languages. The following macros determine
4596 which programming language is used in the subsequent tests in
4599 - Macro: AC_LANG (LANGUAGE)
4600 Do compilation tests using the compiler, preprocessor and file
4601 extensions for the specified LANGUAGE.
4603 Supported languages are:
4606 Do compilation tests using `CC' and `CPP' and use extension
4607 `.c' for test programs.
4610 Do compilation tests using `CXX' and `CXXCPP' and use
4611 extension `.C' for test programs.
4614 Do compilation tests using `F77' and use extension `.f' for
4617 - Macro: AC_LANG_PUSH (LANGUAGE)
4618 Remember the current language (as set by `AC_LANG') on a stack, and
4619 then select the LANGUAGE. Use this macro and `AC_LANG_POP' in
4620 macros that need to temporarily switch to a particular language.
4622 - Macro: AC_LANG_POP ([LANGUAGE])
4623 Select the language that is saved on the top of the stack, as set
4624 by `AC_LANG_PUSH', and remove it from the stack.
4626 If given, LANGUAGE specifies the language we just _quit_. It is a
4627 good idea to specify it when it's known (which should be the
4628 case...), since Autoconf will detect inconsistencies.
4630 AC_LANG_PUSH(Fortran 77)
4631 # Perform some tests on Fortran 77.
4633 AC_LANG_POP(Fortran 77)
4635 - Macro: AC_REQUIRE_CPP
4636 Ensure that whichever preprocessor would currently be used for
4637 tests has been found. Calls `AC_REQUIRE' (*note Prerequisite
4638 Macros::) with an argument of either `AC_PROG_CPP' or
4639 `AC_PROG_CXXCPP', depending on which language is current.
4642 File: autoconf.info, Node: Results, Next: Programming in M4, Prev: Writing Tests, Up: Top
4647 Once `configure' has determined whether a feature exists, what can
4648 it do to record that information? There are four sorts of things it can
4649 do: define a C preprocessor symbol, set a variable in the output files,
4650 save the result in a cache file for future `configure' runs, and print
4651 a message letting the user know the result of the test.
4655 * Defining Symbols:: Defining C preprocessor symbols
4656 * Setting Output Variables:: Replacing variables in output files
4657 * Caching Results:: Speeding up subsequent `configure' runs
4658 * Printing Messages:: Notifying `configure' users
4661 File: autoconf.info, Node: Defining Symbols, Next: Setting Output Variables, Prev: Results, Up: Results
4663 Defining C Preprocessor Symbols
4664 ===============================
4666 A common action to take in response to a feature test is to define a
4667 C preprocessor symbol indicating the results of the test. That is done
4668 by calling `AC_DEFINE' or `AC_DEFINE_UNQUOTED'.
4670 By default, `AC_OUTPUT' places the symbols defined by these macros
4671 into the output variable `DEFS', which contains an option
4672 `-DSYMBOL=VALUE' for each symbol defined. Unlike in Autoconf version
4673 1, there is no variable `DEFS' defined while `configure' is running.
4674 To check whether Autoconf macros have already defined a certain C
4675 preprocessor symbol, test the value of the appropriate cache variable,
4678 AC_CHECK_FUNC(vprintf, [AC_DEFINE(HAVE_VPRINTF)])
4679 if test "$ac_cv_func_vprintf" != yes; then
4680 AC_CHECK_FUNC(_doprnt, [AC_DEFINE(HAVE_DOPRNT)])
4683 If `AC_CONFIG_HEADERS' has been called, then instead of creating
4684 `DEFS', `AC_OUTPUT' creates a header file by substituting the correct
4685 values into `#define' statements in a template file. *Note
4686 Configuration Headers::, for more information about this kind of output.
4688 - Macro: AC_DEFINE (VARIABLE, [VALUE], [DESCRIPTION])
4689 Define C preprocessor variable VARIABLE. If VALUE is given, set
4690 VARIABLE to that value (verbatim), otherwise set it to 1. VALUE
4691 should not contain literal newlines, and if you are not using
4692 `AC_CONFIG_HEADERS' it should not contain any `#' characters, as
4693 `make' tends to eat them. To use a shell variable (which you need
4694 to do in order to define a value containing the M4 quote
4695 characters `[' or `]'), use `AC_DEFINE_UNQUOTED' instead.
4696 DESCRIPTION is only useful if you are using `AC_CONFIG_HEADERS'.
4697 In this case, DESCRIPTION is put into the generated `config.h.in'
4698 as the comment before the macro define. The following example
4699 defines the C preprocessor variable `EQUATION' to be the string
4700 constant `"$a > $b"':
4702 AC_DEFINE(EQUATION, "$a > $b")
4704 - Macro: AC_DEFINE_UNQUOTED (VARIABLE, [VALUE], [DESCRIPTION])
4705 Like `AC_DEFINE', but three shell expansions are
4706 performed--once--on VARIABLE and VALUE: variable expansion (`$'),
4707 command substitution (``'), and backslash escaping (`\'). Single
4708 and double quote characters in the value have no special meaning.
4709 Use this macro instead of `AC_DEFINE' when VARIABLE or VALUE is a
4710 shell variable. Examples:
4712 AC_DEFINE_UNQUOTED(config_machfile, "$machfile")
4713 AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups)
4714 AC_DEFINE_UNQUOTED($ac_tr_hdr)
4716 Due to the syntactical bizarreness of the Bourne shell, do not use
4717 semicolons to separate `AC_DEFINE' or `AC_DEFINE_UNQUOTED' calls from
4718 other macro calls or shell code; that can cause syntax errors in the
4719 resulting `configure' script. Use either spaces or newlines. That is,
4722 AC_CHECK_HEADER(elf.h, [AC_DEFINE(SVR4) LIBS="$LIBS -lelf"])
4726 AC_CHECK_HEADER(elf.h,
4728 LIBS="$LIBS -lelf"])
4732 AC_CHECK_HEADER(elf.h, [AC_DEFINE(SVR4); LIBS="$LIBS -lelf"])
4735 File: autoconf.info, Node: Setting Output Variables, Next: Caching Results, Prev: Defining Symbols, Up: Results
4737 Setting Output Variables
4738 ========================
4740 Another way to record the results of tests is to set "output
4741 variables", which are shell variables whose values are substituted into
4742 files that `configure' outputs. The two macros below create new output
4743 variables. *Note Preset Output Variables::, for a list of output
4744 variables that are always available.
4746 - Macro: AC_SUBST (VARIABLE, [VALUE])
4747 Create an output variable from a shell variable. Make `AC_OUTPUT'
4748 substitute the variable VARIABLE into output files (typically one
4749 or more `Makefile's). This means that `AC_OUTPUT' will replace
4750 instances of `@VARIABLE@' in input files with the value that the
4751 shell variable VARIABLE has when `AC_OUTPUT' is called. This
4752 value of VARIABLE should not contain literal newlines.
4754 If VALUE is given, in addition assign it to `variable'.
4756 - Macro: AC_SUBST_FILE (VARIABLE)
4757 Another way to create an output variable from a shell variable.
4758 Make `AC_OUTPUT' insert (without substitutions) the contents of
4759 the file named by shell variable VARIABLE into output files. This
4760 means that `AC_OUTPUT' will replace instances of `@VARIABLE@' in
4761 output files (such as `Makefile.in') with the contents of the file
4762 that the shell variable VARIABLE names when `AC_OUTPUT' is called.
4763 Set the variable to `/dev/null' for cases that do not have a file
4766 This macro is useful for inserting `Makefile' fragments containing
4767 special dependencies or other `make' directives for particular host
4768 or target types into `Makefile's. For example, `configure.ac'
4771 AC_SUBST_FILE(host_frag)
4772 host_frag=$srcdir/conf/sun4.mh
4774 and then a `Makefile.in' could contain:
4778 Running `configure' in different environments can be extremely
4779 dangerous. If for instance the user runs `CC=bizarre-cc ./configure',
4780 then the cache, `config.h' and many other output files will depend upon
4781 `bizarre-cc' being the C compiler. If for some reason the user runs
4782 `/configure' again, or if it is run via `./config.status --recheck',
4783 (*Note Automatic Remaking::, and *note config.status Invocation::),
4784 then the configuration can be inconsistent, composed of results
4785 depending upon two different compilers.
4787 Such variables are named "precious variables", and can be declared
4788 as such by `AC_ARG_VAR'.
4790 - Macro: AC_ARG_VAR (VARIABLE, DESCRIPTION)
4791 Declare VARIABLE is a precious variable, and include its
4792 DESCRIPTION in the variable section of `./configure --help'.
4794 Being precious means that
4795 - VARIABLE is `AC_SUBST''d.
4797 - VARIABLE is kept in the cache including if it was not
4798 specified on the `./configure' command line. Indeed, while
4799 `configure' can notice the definition of `CC' in `./configure
4800 CC=bizarre-cc', it is impossible to notice it in
4801 `CC=bizarre-cc ./configure', which, unfortunately, is what
4804 - VARIABLE is checked for consistency between two `configure'
4807 $ ./configure --silent --config-cache
4808 $ CC=cc ./configure --silent --config-cache
4809 configure: error: `CC' was not set in the previous run
4810 configure: error: changes in the environment can compromise \
4812 configure: error: run `make distclean' and/or \
4813 `rm config.cache' and start over
4815 and similarly if the variable is unset, or if its content is
4818 - VARIABLE is kept during automatic reconfiguration (*note
4819 config.status Invocation::) as if it had been passed as a
4820 command line argument, including when no cache is used:
4822 $ CC=/usr/bin/cc ./configure undeclared_var=raboof --silent
4823 $ ./config.status --recheck
4824 running /bin/sh ./configure undeclared_var=raboof --silent \
4825 CC=/usr/bin/cc --no-create --no-recursion
4828 File: autoconf.info, Node: Caching Results, Next: Printing Messages, Prev: Setting Output Variables, Up: Results
4833 To avoid checking for the same features repeatedly in various
4834 `configure' scripts (or in repeated runs of one script), `configure'
4835 can optionally save the results of many checks in a "cache file" (*note
4836 Cache Files::). If a `configure' script runs with caching enabled and
4837 finds a cache file, it reads the results of previous runs from the
4838 cache and avoids rerunning those checks. As a result, `configure' can
4839 then run much faster than if it had to perform all of the checks every
4842 - Macro: AC_CACHE_VAL (CACHE-ID, COMMANDS-TO-SET-IT)
4843 Ensure that the results of the check identified by CACHE-ID are
4844 available. If the results of the check were in the cache file
4845 that was read, and `configure' was not given the `--quiet' or
4846 `--silent' option, print a message saying that the result was
4847 cached; otherwise, run the shell commands COMMANDS-TO-SET-IT. If
4848 the shell commands are run to determine the value, the value will
4849 be saved in the cache file just before `configure' creates its
4850 output files. *Note Cache Variable Names::, for how to choose the
4851 name of the CACHE-ID variable.
4853 The COMMANDS-TO-SET-IT _must have no side effects_ except for
4854 setting the variable CACHE-ID, see below.
4856 - Macro: AC_CACHE_CHECK (MESSAGE, CACHE-ID, COMMANDS-TO-SET-IT)
4857 A wrapper for `AC_CACHE_VAL' that takes care of printing the
4858 messages. This macro provides a convenient shorthand for the most
4859 common way to use these macros. It calls `AC_MSG_CHECKING' for
4860 MESSAGE, then `AC_CACHE_VAL' with the CACHE-ID and COMMANDS
4861 arguments, and `AC_MSG_RESULT' with CACHE-ID.
4863 The COMMANDS-TO-SET-IT _must have no side effects_ except for
4864 setting the variable CACHE-ID, see below.
4866 It is very common to find buggy macros using `AC_CACHE_VAL' or
4867 `AC_CACHE_CHECK', because people are tempted to call `AC_DEFINE' in the
4868 COMMANDS-TO-SET-IT. Instead, the code that _follows_ the call to
4869 `AC_CACHE_VAL' should call `AC_DEFINE', by examining the value of the
4870 cache variable. For instance, the following macro is broken:
4872 AC_DEFUN([AC_SHELL_TRUE],
4873 [AC_CACHE_CHECK([whether true(1) works], [ac_cv_shell_true_works],
4874 [ac_cv_shell_true_works=no
4875 true && ac_cv_shell_true_works=yes
4876 if test $ac_cv_shell_true_works = yes; then
4877 AC_DEFINE([TRUE_WORKS], 1
4878 [Define if `true(1)' works properly.])
4882 This fails if the cache is enabled: the second time this macro is run,
4883 `TRUE_WORKS' _will not be defined_. The proper implementation is:
4885 AC_DEFUN([AC_SHELL_TRUE],
4886 [AC_CACHE_CHECK([whether true(1) works], [ac_cv_shell_true_works],
4887 [ac_cv_shell_true_works=no
4888 true && ac_cv_shell_true_works=yes])
4889 if test $ac_cv_shell_true_works = yes; then
4890 AC_DEFINE([TRUE_WORKS], 1
4891 [Define if `true(1)' works properly.])
4895 Also, COMMANDS-TO-SET-IT should not print any messages, for example
4896 with `AC_MSG_CHECKING'; do that before calling `AC_CACHE_VAL', so the
4897 messages are printed regardless of whether the results of the check are
4898 retrieved from the cache or determined by running the shell commands.
4902 * Cache Variable Names:: Shell variables used in caches
4903 * Cache Files:: Files `configure' uses for caching
4904 * Cache Checkpointing:: Loading and saving the cache file
4907 File: autoconf.info, Node: Cache Variable Names, Next: Cache Files, Prev: Caching Results, Up: Caching Results
4909 Cache Variable Names
4910 --------------------
4912 The names of cache variables should have the following format:
4914 PACKAGE-PREFIX_cv_VALUE-TYPE_SPECIFIC-VALUE_[ADDITIONAL-OPTIONS]
4916 for example, `ac_cv_header_stat_broken' or
4917 `ac_cv_prog_gcc_traditional'. The parts of the variable name are:
4920 An abbreviation for your package or organization; the same prefix
4921 you begin local Autoconf macros with, except lowercase by
4922 convention. For cache values used by the distributed Autoconf
4923 macros, this value is `ac'.
4926 Indicates that this shell variable is a cache value. This string
4927 _must_ be present in the variable name, including the leading
4931 A convention for classifying cache values, to produce a rational
4932 naming system. The values used in Autoconf are listed in *Note
4936 Which member of the class of cache values this test applies to.
4937 For example, which function (`alloca'), program (`gcc'), or output
4938 variable (`INSTALL').
4941 Any particular behavior of the specific member that this test
4942 applies to. For example, `broken' or `set'. This part of the
4943 name may be omitted if it does not apply.
4945 The values assigned to cache variables may not contain newlines.
4946 Usually, their values will be boolean (`yes' or `no') or the names of
4947 files or functions; so this is not an important restriction.
4950 File: autoconf.info, Node: Cache Files, Next: Cache Checkpointing, Prev: Cache Variable Names, Up: Caching Results
4955 A cache file is a shell script that caches the results of configure
4956 tests run on one system so they can be shared between configure scripts
4957 and configure runs. It is not useful on other systems. If its contents
4958 are invalid for some reason, the user may delete or edit it.
4960 By default, `configure' uses no cache file (technically, it uses
4961 `--cache-file=/dev/null'), to avoid problems caused by accidental use
4962 of stale cache files.
4964 To enable caching, `configure' accepts `--config-cache' (or `-C') to
4965 cache results in the file `config.cache'. Alternatively,
4966 `--cache-file=FILE' specifies that FILE be the cache file. The cache
4967 file is created if it does not exist already. When `configure' calls
4968 `configure' scripts in subdirectories, it uses the `--cache-file'
4969 argument so that they share the same cache. *Note Subdirectories::,
4970 for information on configuring subdirectories with the
4971 `AC_CONFIG_SUBDIRS' macro.
4973 `config.status' only pays attention to the cache file if it is given
4974 the `--recheck' option, which makes it rerun `configure'.
4976 It is wrong to try to distribute cache files for particular system
4977 types. There is too much room for error in doing that, and too much
4978 administrative overhead in maintaining them. For any features that
4979 can't be guessed automatically, use the standard method of the canonical
4980 system type and linking files (*note Manual Configuration::).
4982 The site initialization script can specify a site-wide cache file to
4983 use, instead of the usual per-program cache. In this case, the cache
4984 file will gradually accumulate information whenever someone runs a new
4985 `configure' script. (Running `configure' merges the new cache results
4986 with the existing cache file.) This may cause problems, however, if
4987 the system configuration (e.g. the installed libraries or compilers)
4988 changes and the stale cache file is not deleted.
4991 File: autoconf.info, Node: Cache Checkpointing, Prev: Cache Files, Up: Caching Results
4996 If your configure script, or a macro called from configure.ac,
4997 happens to abort the configure process, it may be useful to checkpoint
4998 the cache a few times at key points using `AC_CACHE_SAVE'. Doing so
4999 will reduce the amount of time it takes to re-run the configure script
5000 with (hopefully) the error that caused the previous abort corrected.
5002 - Macro: AC_CACHE_LOAD
5003 Loads values from existing cache file, or creates a new cache file
5004 if a cache file is not found. Called automatically from `AC_INIT'.
5006 - Macro: AC_CACHE_SAVE
5007 Flushes all cached values to the cache file. Called automatically
5008 from `AC_OUTPUT', but it can be quite useful to call
5009 `AC_CACHE_SAVE' at key points in configure.ac.
5013 ... AC_INIT, etc. ...
5014 # Checks for programs.
5016 AC_PROG_GCC_TRADITIONAL
5017 ... more program checks ...
5020 # Checks for libraries.
5021 AC_CHECK_LIB(nsl, gethostbyname)
5022 AC_CHECK_LIB(socket, connect)
5023 ... more lib checks ...
5027 AM_PATH_GTK(1.0.2,, (exit 1); exit)
5028 AM_PATH_GTKMM(0.9.5,, (exit 1); exit)
5029 ... AC_OUTPUT, etc. ...
5032 File: autoconf.info, Node: Printing Messages, Prev: Caching Results, Up: Results
5037 `configure' scripts need to give users running them several kinds of
5038 information. The following macros print messages in ways appropriate
5039 for each kind. The arguments to all of them get enclosed in shell
5040 double quotes, so the shell performs variable and back-quote
5041 substitution on them.
5043 These macros are all wrappers around the `echo' shell command.
5044 `configure' scripts should rarely need to run `echo' directly to print
5045 messages for the user. Using these macros makes it easy to change how
5046 and when each kind of message is printed; such changes need only be
5047 made to the macro definitions and all of the callers will change
5050 To diagnose static issues, i.e., when `autoconf' is run, see *Note
5051 Reporting Messages::.
5053 - Macro: AC_MSG_CHECKING (FEATURE-DESCRIPTION)
5054 Notify the user that `configure' is checking for a particular
5055 feature. This macro prints a message that starts with `checking '
5056 and ends with `...' and no newline. It must be followed by a call
5057 to `AC_MSG_RESULT' to print the result of the check and the
5058 newline. The FEATURE-DESCRIPTION should be something like
5059 `whether the Fortran compiler accepts C++ comments' or `for c89'.
5061 This macro prints nothing if `configure' is run with the `--quiet'
5062 or `--silent' option.
5064 - Macro: AC_MSG_RESULT (RESULT-DESCRIPTION)
5065 Notify the user of the results of a check. RESULT-DESCRIPTION is
5066 almost always the value of the cache variable for the check,
5067 typically `yes', `no', or a file name. This macro should follow a
5068 call to `AC_MSG_CHECKING', and the RESULT-DESCRIPTION should be
5069 the completion of the message printed by the call to
5072 This macro prints nothing if `configure' is run with the `--quiet'
5073 or `--silent' option.
5075 - Macro: AC_MSG_NOTICE (MESSAGE)
5076 Deliver the MESSAGE to the user. It is useful mainly to print a
5077 general description of the overall purpose of a group of feature
5080 AC_MSG_NOTICE([checking if stack overflow is detectable])
5082 This macro prints nothing if `configure' is run with the `--quiet'
5083 or `--silent' option.
5085 - Macro: AC_MSG_ERROR (ERROR-DESCRIPTION, [EXIT-STATUS])
5086 Notify the user of an error that prevents `configure' from
5087 completing. This macro prints an error message to the standard
5088 error output and exits `configure' with EXIT-STATUS (1 by default).
5089 ERROR-DESCRIPTION should be something like `invalid value $HOME
5092 The ERROR-DESCRIPTION should start with a lower-case letter, and
5093 "cannot" is preferred to "can't".
5095 - Macro: AC_MSG_WARN (PROBLEM-DESCRIPTION)
5096 Notify the `configure' user of a possible problem. This macro
5097 prints the message to the standard error output; `configure'
5098 continues running afterward, so macros that call `AC_MSG_WARN'
5099 should provide a default (back-up) behavior for the situations
5100 they warn about. PROBLEM-DESCRIPTION should be something like `ln
5101 -s seems to make hard links'.
5104 File: autoconf.info, Node: Programming in M4, Next: Writing Autoconf Macros, Prev: Results, Up: Top
5109 Autoconf is written on top of two layers: "M4sugar", which provides
5110 convenient macros for pure M4 programming, and "M4sh", which provides
5111 macros dedicated to shell script generation.
5113 As of this version of Autoconf, these two layers are still
5114 experimental, and their interface might change in the future. As a
5115 matter of fact, _anything that is not documented must not be used_.
5119 * M4 Quotation:: Protecting macros from unwanted expansion
5120 * Programming in M4sugar:: Convenient pure M4 macros
5123 File: autoconf.info, Node: M4 Quotation, Next: Programming in M4sugar, Prev: Programming in M4, Up: Programming in M4
5128 The most common brokenness of existing macros is an improper
5129 quotation. This section, which users of Autoconf can skip, but which
5130 macro writers _must_ read, first justifies the quotation scheme that
5131 was chosen for Autoconf and then ends with a rule of thumb.
5132 Understanding the former helps one to follow the latter.
5136 * Active Characters:: Characters that change the behavior of m4
5137 * One Macro Call:: Quotation and one macro call
5138 * Quotation and Nested Macros:: Macros calling macros
5139 * Quadrigraphs:: Another way to escape special characters
5140 * Quotation Rule Of Thumb:: One parenthesis, one quote
5143 File: autoconf.info, Node: Active Characters, Next: One Macro Call, Prev: M4 Quotation, Up: M4 Quotation
5148 To fully understand where proper quotation is important, you first
5149 need to know what are the special characters in Autoconf: `#' introduces
5150 a comment inside which no macro expansion is performed, `,' separates
5151 arguments, `[' and `]' are the quotes themselves, and finally `(' and
5152 `)' (which `m4' tries to match by pairs).
5154 In order to understand the delicate case of macro calls, we first
5155 have to present some obvious failures. Below they are "obvious-ified",
5156 although you find them in real life, they are usually in disguise.
5158 Comments, introduced by a hash and running up to the newline, are
5159 opaque tokens to the top level: active characters are turned off, and
5160 there is no macro expansion:
5162 # define([def], ine)
5163 =># define([def], ine)
5165 Each time there can be a macro expansion, there is a quotation
5166 expansion; i.e., one level of quotes is stripped:
5173 Without this in mind, the reader will try hopelessly to use her macro
5176 define([array], [int tab[10];])
5182 How can you correctly output the intended results(1)?
5184 ---------- Footnotes ----------
5189 File: autoconf.info, Node: One Macro Call, Next: Quotation and Nested Macros, Prev: Active Characters, Up: M4 Quotation
5194 Let's proceed on the interaction between active characters and macros
5195 with this small macro, which just returns its first argument:
5199 The two pairs of quotes above are not part of the arguments of
5200 `define'; rather, they are understood by the top level when it tries to
5201 find the arguments of `define'. Therefore, it is equivalent to write:
5205 But, while it is acceptable for a `configure.ac' to avoid unneeded
5206 quotes, it is bad practice for Autoconf macros which must both be more
5207 robust and also advocate perfect style.
5209 At the top level, there are only two possible quotings: either you
5214 [car(foo, bar, baz)]
5215 =>car(foo, bar, baz)
5217 Let's pay attention to the special characters:
5220 error-->EOF in argument list
5222 The closing parenthesis is hidden in the comment; with a hypothetical
5223 quoting, the top level understood it this way:
5227 Proper quotation, of course, fixes the problem:
5232 The reader will easily understand the following examples:
5247 With this in mind, we can explore the cases where macros invoke
5251 File: autoconf.info, Node: Quotation and Nested Macros, Next: Quadrigraphs, Prev: One Macro Call, Up: M4 Quotation
5253 Quotation and Nested Macros
5254 ---------------------------
5256 The examples below use the following macros:
5259 define([active], [ACT, IVE])
5260 define([array], [int tab[10]])
5262 Each additional embedded macro call introduces other possible
5263 interesting quotations:
5272 In the first case, the top level looks for the arguments of `car',
5273 and finds `active'. Because `m4' evaluates its arguments before
5274 applying the macro, `active' is expanded, which results in:
5279 In the second case, the top level gives `active' as first and only
5280 argument of `car', which results in:
5285 i.e., the argument is evaluated _after_ the macro that invokes it. In
5286 the third case, `car' receives `[active]', which results in:
5291 exactly as we already saw above.
5293 The example above, applied to a more realistic example, gives:
5299 car([[int tab[10];]])
5302 Huh? The first case is easily understood, but why is the second wrong,
5303 and the third right? To understand that, you must know that after `m4'
5304 expands a macro, the resulting text is immediately subjected to macro
5305 expansion and quote removal. This means that the quote removal occurs
5306 twice--first before the argument is passed to the `car' macro, and
5307 second after the `car' macro expands to the first argument.
5309 As the author of the Autoconf macro `car', you then consider it to
5310 be incorrect that your users have to double-quote the arguments of
5311 `car', so you "fix" your macro. Let's call it `qar' for quoted car:
5313 define([qar], [[$1]])
5315 and check that `qar' is properly fixed:
5320 Ahhh! That's much better.
5322 But note what you've done: now that the arguments are literal
5323 strings, if the user wants to use the results of expansions as
5324 arguments, she has to use an _unquoted_ macro call:
5329 where she wanted to reproduce what she used to do with `car':
5334 Worse yet: she wants to use a macro that produces a set of `cpp' macros:
5336 define([my_includes], [#include <stdio.h>])
5338 =>#include <stdio.h>
5340 error-->EOF in argument list
5342 This macro, `qar', because it double quotes its arguments, forces
5343 its users to leave their macro calls unquoted, which is dangerous.
5344 Commas and other active symbols are interpreted by `m4' before they are
5345 given to the macro, often not in the way the users expect. Also,
5346 because `qar' behaves differently from the other macros, it's an
5347 exception that should be avoided in Autoconf.
5350 File: autoconf.info, Node: Quadrigraphs, Next: Quotation Rule Of Thumb, Prev: Quotation and Nested Macros, Up: M4 Quotation
5355 When writing an autoconf macro you may occasionally need to generate
5356 special characters that are difficult to express with the standard
5357 autoconf quoting rules. For example, you may need to output the regular
5358 expression `[^[]', which matches any character other than `['. This
5359 expression contains unbalanced brackets so it cannot be put easily into
5362 You can work around this problem by using one of the following
5377 Quadrigraphs are replaced at a late stage of the translation process,
5378 after `m4' is run, so they do not get in the way of M4 quoting. For
5379 example, the string `[^@<:@]', if properly quoted, will appear as
5380 `[^[]' in the `configure' script.
5383 File: autoconf.info, Node: Quotation Rule Of Thumb, Prev: Quadrigraphs, Up: M4 Quotation
5385 Quotation Rule Of Thumb
5386 -----------------------
5388 To conclude, the quotation rule of thumb is:
5390 _One pair of quotes per pair of parentheses._
5392 Never over-quote, never under-quote, in particular in the definition
5393 of macros. In the few places where the macros need to use brackets
5394 (usually in C program text or regular expressions), properly quote _the
5397 It is common to read Autoconf programs with snippets like:
5400 changequote(<<, >>)dnl
5402 #ifndef tzname /* For SGI. */
5403 extern char *tzname[]; /* RS6000 and others reject char **tzname. */
5405 changequote([, ])dnl
5406 [atoi (*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)
5408 which is incredibly useless since `AC_TRY_LINK' is _already_ double
5409 quoting, so you just need:
5413 #ifndef tzname /* For SGI. */
5414 extern char *tzname[]; /* RS6000 and others reject char **tzname. */
5417 [ac_cv_var_tzname=yes],
5418 [ac_cv_var_tzname=no])
5420 The M4-fluent reader will note that these two examples are rigorously
5421 equivalent, since `m4' swallows both the `changequote(<<, >>)' and `<<'
5422 `>>' when it "collects" the arguments: these quotes are not part of the
5425 Simplified, the example above is just doing this:
5427 changequote(<<, >>)dnl
5429 changequote([, ])dnl
5435 With macros that do not double quote their arguments (which is the
5436 rule), double-quote the (risky) literals:
5438 AC_LINK_IFELSE([AC_LANG_PROGRAM(
5440 #ifndef tzname /* For SGI. */
5441 extern char *tzname[]; /* RS6000 and others reject char **tzname. */
5443 [atoi (*tzname);])],
5444 [ac_cv_var_tzname=yes],
5445 [ac_cv_var_tzname=no])
5447 See *Note Quadrigraphs::, for what to do if you run into a hopeless
5448 case where quoting does not suffice.
5450 When you create a `configure' script using newly written macros,
5451 examine it carefully to check whether you need to add more quotes in
5452 your macros. If one or more words have disappeared in the `m4' output,
5453 you need more quotes. When in doubt, quote.
5455 However, it's also possible to put on too many layers of quotes. If
5456 this happens, the resulting `configure' script will contain unexpanded
5457 macros. The `autoconf' program checks for this problem by doing `grep
5461 File: autoconf.info, Node: Programming in M4sugar, Prev: M4 Quotation, Up: Programming in M4
5463 Programming in M4sugar
5464 ======================
5466 M4 by itself provides only a small, but sufficient, set of
5467 all-purpose macros. M4sugar introduces additional generic macros. Its
5468 name was coined by Lars J. Aas: "Readability And Greater Understanding
5473 * Redefined M4 Macros:: M4 builtins changed in M4sugar
5474 * Forbidden Patterns:: Catching unexpanded macros
5477 File: autoconf.info, Node: Redefined M4 Macros, Next: Forbidden Patterns, Prev: Programming in M4sugar, Up: Programming in M4sugar
5482 All the M4 native macros are moved in the `m4_' pseudo-namespace,
5483 e.g., M4sugar renames `define' as `m4_define' etc. There is one
5484 exception: `dnl' kept its original name, and no `m4_dnl' is defined.
5486 M4sugar redefines some M4 macros, and made them slightly incompatible
5487 with their native equivalent.
5489 - Macro: m4_defn (MACRO)
5490 Contrary to the M4 builtin, this macro fails if MACRO is not
5491 defined. See `m4_undefine'.
5493 - Macro: m4_undefine (MACRO)
5494 Contrary to the M4 builtin, this macro fails if MACRO is not
5497 m4_ifdef([MACRO], [m4_undefine([MACRO])])
5499 to recover the behavior of the builtin.
5501 - Macro: m4_popdef (MACRO)
5502 Contrary to the M4 builtin, this macro fails if MACRO is not
5503 defined. See `m4_undefine'.
5506 File: autoconf.info, Node: Forbidden Patterns, Prev: Redefined M4 Macros, Up: Programming in M4sugar
5511 M4sugar provides a means to define suspicious patterns, patterns
5512 describing tokens which should not be found in the output. For
5513 instance, if an Autoconf `configure' script includes tokens such as
5514 `AC_DEFINE', or `dnl', then most probably something went wrong
5515 (typically a macro was not evaluated because of over quotation).
5517 M4sugar forbids all the tokens matching `^m4_' and `^dnl$'.
5519 - Macro: m4_pattern_forbid (PATTERN)
5520 Declare no token matching PATTERN must be found in the output.
5521 Comments are not checked; this can be a problem if, for instance,
5522 you have some macro left unexpanded after an `#include'. No
5523 consensus is currently found in the Autoconf community, as some
5524 people consider it should be valid to name macros in comments
5525 (which doesn't makes sense to the author of this documentation, as
5526 `#'-comments should document the output, not the input, documented
5529 Of course, you might encounter exceptions to these generic rules, for
5530 instance you might have to refer to `$m4_flags'.
5532 - Macro: m4_pattern_allow (PATTERN)
5533 Any token matching PATTERN is allowed, including if it matches an
5534 `m4_pattern_forbid' pattern.
5537 File: autoconf.info, Node: Writing Autoconf Macros, Next: Portable Shell, Prev: Programming in M4, Up: Top
5539 Writing Autoconf Macros
5540 ***********************
5542 When you write a feature test that could be applicable to more than
5543 one software package, the best thing to do is encapsulate it in a new
5544 macro. Here are some instructions and guidelines for writing Autoconf
5549 * Macro Definitions:: Basic format of an Autoconf macro
5550 * Macro Names:: What to call your new macros
5551 * Reporting Messages:: Notifying `autoconf' users
5552 * Dependencies Between Macros:: What to do when macros depend on other macros
5553 * Obsoleting Macros:: Warning about old ways of doing things
5554 * Coding Style:: Writing Autoconf macros a` la Autoconf
5557 File: autoconf.info, Node: Macro Definitions, Next: Macro Names, Prev: Writing Autoconf Macros, Up: Writing Autoconf Macros
5562 Autoconf macros are defined using the `AC_DEFUN' macro, which is
5563 similar to the M4 builtin `define' macro. In addition to defining a
5564 macro, `AC_DEFUN' adds to it some code that is used to constrain the
5565 order in which macros are called (*note Prerequisite Macros::).
5567 An Autoconf macro definition looks like this:
5569 AC_DEFUN(MACRO-NAME, MACRO-BODY)
5571 You can refer to any arguments passed to the macro as `$1', `$2',
5572 etc. *Note How to define new macros: (m4.info)Definitions, for more
5573 complete information on writing M4 macros.
5575 Be sure to properly quote both the MACRO-BODY _and_ the MACRO-NAME
5576 to avoid any problems if the macro happens to have been previously
5579 Each macro should have a header comment that gives its prototype,
5580 and a brief description. When arguments have default values, display
5581 them in the prototype. For example:
5583 # AC_MSG_ERROR(ERROR, [EXIT-STATUS = 1])
5584 # --------------------------------------
5585 define([AC_MSG_ERROR],
5586 [{ _AC_ECHO([configure: error: $1], 2); exit m4_default([$2], 1); }])
5588 Comments about the macro should be left in the header comment. Most
5589 other comments will make their way into `configure', so just keep using
5590 `#' to introduce comments.
5592 If you have some very special comments about pure M4 code, comments
5593 that make no sense in `configure' and in the header comment, then use
5594 the builtin `dnl': it causes `m4' to discard the text through the next
5597 Keep in mind that `dnl' is rarely needed to introduce comments;
5598 `dnl' is more useful to get rid of the newlines following macros that
5599 produce no output, such as `AC_REQUIRE'.
5602 File: autoconf.info, Node: Macro Names, Next: Reporting Messages, Prev: Macro Definitions, Up: Writing Autoconf Macros
5607 All of the Autoconf macros have all-uppercase names starting with
5608 `AC_' to prevent them from accidentally conflicting with other text.
5609 All shell variables that they use for internal purposes have
5610 mostly-lowercase names starting with `ac_'. To ensure that your macros
5611 don't conflict with present or future Autoconf macros, you should
5612 prefix your own macro names and any shell variables they use with some
5613 other sequence. Possibilities include your initials, or an abbreviation
5614 for the name of your organization or software package.
5616 Most of the Autoconf macros' names follow a structured naming
5617 convention that indicates the kind of feature check by the name. The
5618 macro names consist of several words, separated by underscores, going
5619 from most general to most specific. The names of their cache variables
5620 use the same convention (*note Cache Variable Names::, for more
5621 information on them).
5623 The first word of the name after `AC_' usually tells the category of
5624 feature being tested. Here are the categories used in Autoconf for
5625 specific test macros, the kind of macro that you are more likely to
5626 write. They are also used for cache variables, in all-lowercase. Use
5627 them where applicable; where they're not, invent your own categories.
5630 C language builtin features.
5633 Declarations of C variables in header files.
5636 Functions in libraries.
5639 UNIX group owners of files.
5648 The full path names to files, including programs.
5651 The base names of programs.
5654 Members of aggregates.
5657 Operating system features.
5660 C builtin or declared types.
5663 C variables in libraries.
5665 After the category comes the name of the particular feature being
5666 tested. Any further words in the macro name indicate particular aspects
5667 of the feature. For example, `AC_FUNC_UTIME_NULL' checks the behavior
5668 of the `utime' function when called with a `NULL' pointer.
5670 An internal macro should have a name that starts with an underscore;
5671 Autoconf internals should therefore start with `_AC_'. Additionally, a
5672 macro that is an internal subroutine of another macro should have a
5673 name that starts with an underscore and the name of that other macro,
5674 followed by one or more words saying what the internal macro does. For
5675 example, `AC_PATH_X' has internal macros `_AC_PATH_X_XMKMF' and
5676 `_AC_PATH_X_DIRECT'.
5679 File: autoconf.info, Node: Reporting Messages, Next: Dependencies Between Macros, Prev: Macro Names, Up: Writing Autoconf Macros
5684 When macros statically diagnose abnormal situations, benign or fatal,
5685 they should report them using these macros. For dynamic issues, i.e.,
5686 when `configure' is run, see *Note Printing Messages::.
5688 - Macro: AC_DIAGNOSE (CATEGORY, MESSAGE)
5689 Report MESSAGE as a warning (or as an error if requested by the
5690 user) if it falls into the CATEGORY. You are encouraged to use
5691 standard categories, which currently include:
5694 messages that don't fall into one of the following category.
5695 Use of an empty CATEGORY is equivalent.
5698 related to cross compilation issues.
5701 use of an obsolete construct.
5704 dubious syntactic constructs, incorrectly ordered macro calls.
5706 - Macro: AC_WARNING (MESSAGE)
5707 Equivalent to `AC_DIAGNOSE([syntax], MESSAGE)', but you are
5708 strongly encouraged to use a finer grained category.
5710 - Macro: AC_FATAL (MESSAGE)
5711 Report a severe error MESSAGE, and have `autoconf' die.
5713 When the user runs `autoconf -W error', warnings from `AC_DIAGNOSE'
5714 and `AC_WARNING' are reported as error, see *Note autoconf Invocation::.
5717 File: autoconf.info, Node: Dependencies Between Macros, Next: Obsoleting Macros, Prev: Reporting Messages, Up: Writing Autoconf Macros
5719 Dependencies Between Macros
5720 ===========================
5722 Some Autoconf macros depend on other macros having been called first
5723 in order to work correctly. Autoconf provides a way to ensure that
5724 certain macros are called if needed and a way to warn the user if
5725 macros are called in an order that might cause incorrect operation.
5729 * Prerequisite Macros:: Ensuring required information
5730 * Suggested Ordering:: Warning about possible ordering problems
5733 File: autoconf.info, Node: Prerequisite Macros, Next: Suggested Ordering, Prev: Dependencies Between Macros, Up: Dependencies Between Macros
5738 A macro that you write might need to use values that have previously
5739 been computed by other macros. For example, `AC_DECL_YYTEXT' examines
5740 the output of `flex' or `lex', so it depends on `AC_PROG_LEX' having
5741 been called first to set the shell variable `LEX'.
5743 Rather than forcing the user of the macros to keep track of the
5744 dependencies between them, you can use the `AC_REQUIRE' macro to do it
5745 automatically. `AC_REQUIRE' can ensure that a macro is only called if
5746 it is needed, and only called once.
5748 - Macro: AC_REQUIRE (MACRO-NAME)
5749 If the M4 macro MACRO-NAME has not already been called, call it
5750 (without any arguments). Make sure to quote MACRO-NAME with
5751 square brackets. MACRO-NAME must have been defined using
5752 `AC_DEFUN' or else contain a call to `AC_PROVIDE' to indicate that
5755 `AC_REQUIRE' must be used inside an `AC_DEFUN''d macro; it must
5756 not be called from the top level.
5758 `AC_REQUIRE' is often misunderstood. It really implements
5759 dependencies between macros in the sense that if one macro depends upon
5760 another, the latter will be expanded _before_ the body of the former.
5761 In particular, `AC_REQUIRE(FOO)' is not replaced with the body of
5762 `FOO'. For instance, this definition of macros:
5764 AC_DEFUN([TRAVOLTA],
5765 [test "$body_temparature_in_celsius" -gt "38" &&
5766 dance_floor=occupied])
5767 AC_DEFUN([NEWTON_JOHN],
5768 [test "$hair_style" = "curly" &&
5769 dance_floor=occupied])
5771 AC_DEFUN([RESERVE_DANCE_FLOOR],
5772 [if date | grep '^Sat.*pm' >/dev/null 2>&1; then
5773 AC_REQUIRE([TRAVOLTA])
5774 AC_REQUIRE([NEWTON_JOHN])
5777 with this `configure.ac'
5781 if test "$dance_floor" = occupied; then
5782 AC_MSG_ERROR([cannot pick up here, let's move])
5785 will not leave you with a better chance to meet a kindred soul at other
5786 times than Saturday night since it expands into:
5788 test "$body_temperature_in_Celsius" -gt "38" &&
5789 dance_floor=occupied
5790 test "$hair_style" = "curly" &&
5791 dance_floor=occupied
5793 if date | grep '^Sat.*pm' >/dev/null 2>&1; then
5798 This behavior was chosen on purpose: (i) it prevents messages in
5799 required macros from interrupting the messages in the requiring macros;
5800 (ii) it avoids bad surprises when shell conditionals are used, as in:
5803 AC_REQUIRE([SOME_CHECK])
5808 You are encouraged to put all `AC_REQUIRE's at the beginning of a
5809 macro. You can use `dnl' to avoid the empty lines they leave.
5812 File: autoconf.info, Node: Suggested Ordering, Prev: Prerequisite Macros, Up: Dependencies Between Macros
5817 Some macros should be run before another macro if both are called,
5818 but neither _requires_ that the other be called. For example, a macro
5819 that changes the behavior of the C compiler should be called before any
5820 macros that run the C compiler. Many of these dependencies are noted in
5823 Autoconf provides the `AC_BEFORE' macro to warn users when macros
5824 with this kind of dependency appear out of order in a `configure.ac'
5825 file. The warning occurs when creating `configure' from
5826 `configure.ac', not when running `configure'.
5828 For example, `AC_PROG_CPP' checks whether the C compiler can run the
5829 C preprocessor when given the `-E' option. It should therefore be
5830 called after any macros that change which C compiler is being used,
5831 such as `AC_PROG_CC'. So `AC_PROG_CC' contains:
5833 AC_BEFORE([$0], [AC_PROG_CPP])dnl
5835 This warns the user if a call to `AC_PROG_CPP' has already occurred
5836 when `AC_PROG_CC' is called.
5838 - Macro: AC_BEFORE (THIS-MACRO-NAME, CALLED-MACRO-NAME)
5839 Make `m4' print a warning message to the standard error output if
5840 CALLED-MACRO-NAME has already been called. THIS-MACRO-NAME should
5841 be the name of the macro that is calling `AC_BEFORE'. The macro
5842 CALLED-MACRO-NAME must have been defined using `AC_DEFUN' or else
5843 contain a call to `AC_PROVIDE' to indicate that it has been called.
5846 File: autoconf.info, Node: Obsoleting Macros, Next: Coding Style, Prev: Dependencies Between Macros, Up: Writing Autoconf Macros
5851 Configuration and portability technology has evolved over the years.
5852 Often better ways of solving a particular problem are developed, or
5853 ad-hoc approaches are systematized. This process has occurred in many
5854 parts of Autoconf. One result is that some of the macros are now
5855 considered "obsolete"; they still work, but are no longer considered
5856 the best thing to do, hence they should be replaced with more modern
5857 macros. Ideally, `autoupdate' should substitute the old macro calls
5858 with their modern implementation.
5860 Autoconf provides a simple means to obsolete a macro.
5862 - Macro: AU_DEFUN (OLD-MACRO, IMPLEMENTATION, [MESSAGE])
5863 Define OLD-MACRO as IMPLEMENTATION. The only difference with
5864 `AC_DEFUN' is that the user will be warned that OLD-MACRO is now
5867 If she then uses `autoupdate', the call to OLD-MACRO will be
5868 replaced by the modern IMPLEMENTATION. The additional MESSAGE is
5872 File: autoconf.info, Node: Coding Style, Prev: Obsoleting Macros, Up: Writing Autoconf Macros
5877 The Autoconf macros follow a strict coding style. You are
5878 encouraged to follow this style, especially if you intend to distribute
5879 your macro, either by contributing it to Autoconf itself, or via other
5882 The first requirement is to pay great attention to the quotation, for
5883 more details, see *Note Autoconf Language::, and *Note M4 Quotation::.
5885 Do not try to invent new interfaces. It is likely that there is a
5886 macro in Autoconf that resembles the macro you are defining: try to
5887 stick to this existing interface (order of arguments, default values,
5888 etc.). We _are_ conscious that some of these interfaces are not
5889 perfect; nevertheless, when harmless, homogeneity should be preferred
5892 Be careful about clashes both between M4 symbols and between shell
5895 If you stick to the suggested M4 naming scheme (*note Macro Names::),
5896 you are unlikely to generate conflicts. Nevertheless, when you need to
5897 set a special value, _avoid using a regular macro name_; rather, use an
5898 "impossible" name. For instance, up to version 2.13, the macro
5899 `AC_SUBST' used to remember what SYMBOLs were already defined by
5900 setting `AC_SUBST_SYMBOL', which is a regular macro name. But since
5901 there is a macro named `AC_SUBST_FILE', it was just impossible to
5902 `AC_SUBST(FILE)'! In this case, `AC_SUBST(SYMBOL)' or
5903 `_AC_SUBST(SYMBOL)' should have been used (yes, with the
5904 parentheses)...or better yet, high-level macros such as
5907 No Autoconf macro should ever enter the user-variable name space;
5908 i.e., except for the variables that are the actual result of running the
5909 macro, all shell variables should start with `ac_'. In addition, small
5910 macros or any macro that is likely to be embedded in other macros
5911 should be careful not to use obvious names.
5913 Do not use `dnl' to introduce comments: most of the comments you are
5914 likely to write are either header comments which are not output anyway,
5915 or comments that should make their way into `configure'. There are
5916 exceptional cases where you do want to comment special M4 constructs,
5917 in which case `dnl' is right, but keep in mind that it is unlikely.
5919 M4 ignores the leading spaces before each argument, use this feature
5920 to indent in such a way that arguments are (more or less) aligned with
5921 the opening parenthesis of the macro being called. For instance,
5924 AC_CACHE_CHECK(for EMX OS/2 environment,
5926 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __EMX__;])],
5927 [ac_cv_emxos2=yes], [ac_cv_emxos2=no])])
5931 AC_CACHE_CHECK([for EMX OS/2 environment], [ac_cv_emxos2],
5932 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return __EMX__;])],
5934 [ac_cv_emxos2=no])])
5938 AC_CACHE_CHECK([for EMX OS/2 environment],
5940 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
5941 [return __EMX__;])],
5943 [ac_cv_emxos2=no])])
5945 When using `AC_TRY_RUN' or any macro that cannot work when
5946 cross-compiling, provide a pessimistic value (typically `no').
5948 Feel free to use various tricks to prevent auxiliary tools, such as
5949 syntax-highlighting editors, from behaving improperly. For instance,
5952 patsubst([$1], [$"])
5956 patsubst([$1], [$""])
5958 so that Emacsen do not open a endless "string" at the first quote. For
5959 the same reasons, avoid:
5967 Otherwise, the closing bracket would be hidden inside a `#'-comment,
5968 breaking the bracket-matching highlighting from Emacsen. Note the
5969 preferred style to escape from M4: `$[1]', `$[@]', etc. Do not escape
5970 when it is unneeded. Common examples of useless quotation are `[$]$1'
5971 (write `$$1'), `[$]var' (use `$var'), etc. If you add portability
5972 issues to the picture, you'll prefer `${1+"$[@]"}' to `"[$]@"', and
5973 you'll prefer do something better than hacking Autoconf `:-)'.
5975 When using `sed', don't use `-e' except for indenting purpose. With
5976 the `s' command, the preferred separator is `/' unless `/' itself is
5977 used in the command, in which case you should use `,'.
5979 *Note Macro Definitions::, for details on how to define a macro. If
5980 a macro doesn't use `AC_REQUIRE' and it is expected to never be the
5981 object of an `AC_REQUIRE' directive, then use `define'. In case of
5982 doubt, use `AC_DEFUN'. All the `AC_REQUIRE' statements should be at
5983 the beginning of the macro, `dnl''ed.
5985 You should not rely on the number of arguments: instead of checking
5986 whether an argument is missing, test that it is not empty. It provides
5987 both a simpler and a more predictable interface to the user, and saves
5988 room for further arguments.
5990 Unless the macro is short, try to leave the closing `])' at the
5991 beginning of a line, followed by a comment that repeats the name of the
5992 macro being defined. This introduces an additional newline in
5993 `configure'; normally, that is not a problem, but if you want to remove
5994 it you can use `[]dnl' on the last line. You can similarly use `[]dnl'
5995 after a macro call to remove its newline. `[]dnl' is recommended
5996 instead of `dnl' to ensure that M4 does not interpret the `dnl' as
5997 being attached to the preceding text or macro output. For example,
6000 AC_DEFUN([AC_PATH_X],
6001 [AC_MSG_CHECKING([for X])
6004 AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
6009 AC_DEFUN([AC_PATH_X],
6010 [AC_REQUIRE_CPP()[]dnl
6011 AC_MSG_CHECKING([for X])
6013 AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
6017 If the macro is long, try to split it into logical chunks.
6018 Typically, macros that check for a bug in a function and prepare its
6019 `AC_LIBOBJ' replacement should have an auxiliary macro to perform this
6020 setup. Do not hesitate to introduce auxiliary macros to factor your
6023 In order to highlight the recommended coding style, here is a macro
6024 written the old way:
6026 dnl Check for EMX on OS/2.
6028 AC_DEFUN(_AC_EMXOS2,
6029 [AC_CACHE_CHECK(for EMX OS/2 environment, ac_cv_emxos2,
6030 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, return __EMX__;)],
6031 ac_cv_emxos2=yes, ac_cv_emxos2=no)])
6032 test "$ac_cv_emxos2" = yes && EMXOS2=yes])
6038 # Check for EMX on OS/2.
6039 define([_AC_EMXOS2],
6040 [AC_CACHE_CHECK([for EMX OS/2 environment], [ac_cv_emxos2],
6041 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return __EMX__;])],
6043 [ac_cv_emxos2=no])])
6044 test "$ac_cv_emxos2" = yes && EMXOS2=yes[]dnl
6048 File: autoconf.info, Node: Portable Shell, Next: Manual Configuration, Prev: Writing Autoconf Macros, Up: Top
6050 Portable Shell Programming
6051 **************************
6053 When writing your own checks, there are some shell-script programming
6054 techniques you should avoid in order to make your code portable. The
6055 Bourne shell and upward-compatible shells like the Korn shell and Bash
6056 have evolved over the years, but to prevent trouble, do not take
6057 advantage of features that were added after UNIX version 7, circa 1977.
6058 You should not use shell functions, aliases, negated character
6059 classes, or other features that are not found in all Bourne-compatible
6060 shells; restrict yourself to the lowest common denominator. Even
6061 `unset' is not supported by all shells! Also, include a space after
6062 the exclamation point in interpreter specifications, like this:
6066 If you omit the space before the path, then 4.2BSD based systems (such
6067 as Sequent DYNIX) will ignore the line, because they interpret `#! /'
6068 as a 4-byte magic number.
6070 The set of external programs you should run in a `configure' script
6071 is fairly small. *Note Utilities in Makefiles: (standards)Utilities in
6072 Makefiles, for the list. This restriction allows users to start out
6073 with a fairly small set of programs and build the rest, avoiding too
6074 many interdependencies between packages.
6076 Some of these external utilities have a portable subset of features;
6077 see *Note Limitations of Usual Tools::.
6081 * Shellology:: A zoology of shells
6082 * Here-Documents:: Quirks and tricks
6083 * File Descriptors:: FDs and redirections
6084 * File System Conventions:: File- and pathnames
6085 * Shell Substitutions:: Variable and command expansions
6086 * Assignments:: Varying side effects of assignments
6087 * Special Shell Variables:: Variables you should not change
6088 * Limitations of Builtins:: Portable use of not so portable /bin/sh
6089 * Limitations of Usual Tools:: Portable use of portable tools
6090 * Limitations of Make:: Portable Makefiles
6093 File: autoconf.info, Node: Shellology, Next: Here-Documents, Prev: Portable Shell, Up: Portable Shell
6098 There are several families of shells, most prominently the Bourne
6099 family and the C shell family which are deeply incompatible. If you
6100 want to write portable shell scripts, avoid members of the C shell
6103 Below we describe some of the members of the Bourne shell family.
6106 `ash' is often used on GNU/Linux and BSD systems as a light-weight
6107 Bourne-compatible shell. Ash 0.2 has some bugs that are fixed in
6108 the 0.3.x series, but portable shell scripts should workaround
6109 them, since version 0.2 is still shipped with many GNU/Linux
6112 To be compatible with Ash 0.2:
6114 - don't use `$?' after expanding empty or unset variables:
6119 echo "Don't use it: $?"
6121 - don't use command substitution within variable expansion:
6125 - beware that single builtin substitutions are not performed by
6126 a sub shell, hence their effect applies to the current shell!
6127 *Note Shell Substitutions::, item "Command Substitution".
6130 To detect whether you are running `bash', test if `BASH_VERSION'
6131 is set. To disable its extensions and require POSIX
6132 compatibility, run `set -o posix'. *Note Bash POSIX Mode:
6133 (bash)Bash POSIX Mode, for details.
6135 `/usr/xpg4/bin/sh' on Solaris
6136 The POSIX-compliant Bourne shell on a Solaris system is
6137 `/usr/xpg4/bin/sh' and is part of an extra optional package.
6138 There is no extra charge for this package, but it is also not part
6139 of a minimal OS install and therefore some folks may not have it.
6142 To detect whether you are running `zsh', test if `ZSH_VERSION' is
6143 set. By default `zsh' is _not_ compatible with the Bourne shell:
6144 you have to run `emulate sh' and set `NULLCMD' to `:'. *Note
6145 Compatibility: (zsh)Compatibility, for details.
6147 Zsh 3.0.8 is the native `/bin/sh' on Mac OS X 10.0.3.
6149 The following discussion between Russ Allbery and Robert Lipe is
6154 The GNU assumption that `/bin/sh' is the one and only shell leads
6155 to a permanent deadlock. Vendors don't want to break user's
6156 existant shell scripts, and there are some corner cases in the
6157 Bourne shell that are not completely compatible with a POSIX
6158 shell. Thus, vendors who have taken this route will _never_
6159 (OK..."never say never") replace the Bourne shell (as `/bin/sh')
6164 This is exactly the problem. While most (at least most System
6165 V's) do have a bourne shell that accepts shell functions most
6166 vendor `/bin/sh' programs are not the POSIX shell.
6168 So while most modern systems do have a shell _somewhere_ that
6169 meets the POSIX standard, the challenge is to find it.
6172 File: autoconf.info, Node: Here-Documents, Next: File Descriptors, Prev: Shellology, Up: Portable Shell
6177 Don't rely on `\' being preserved just because it has no special
6178 meaning together with the next symbol. in the native `/bin/sh' on
6179 OpenBSD 2.7 `\"' expands to `"' in here-documents with unquoted
6180 delimiter. As a general rule, if `\\' expands to `\' use `\\' to get
6183 With OpenBSD 2.7's `/bin/sh'
6192 bash-2.04$ cat <<EOF
6197 Many older shells (including the Bourne shell) implement
6198 here-documents inefficiently. Users can generally speed things up by
6199 using a faster shell, e.g., by using the command `bash ./configure'
6200 rather than plain `./configure'.
6202 Some shells can be extremely inefficient when there are a lot of
6203 here-documents inside a single statement. For instance if your
6204 `configure.ac' includes something like:
6206 if <cross_compiling>; then
6207 assume this and that
6211 check something else
6217 A shell parses the whole `if'/`fi' construct, creating temporary
6218 files for each here document in it. Some shells create links for such
6219 here-documents on every `fork', so that the clean-up code they had
6220 installed correctly removes them. It is creating the links that the
6221 shell can take forever.
6223 Moving the tests out of the `if'/`fi', or creating multiple
6224 `if'/`fi' constructs, would improve the performance significantly.
6225 Anyway, this kind of construct is not exactly the typical use of
6226 Autoconf. In fact, it's even not recommended, because M4 macros can't
6227 look into shell conditionals, so we may fail to expand a macro when it
6228 was expanded before in a conditional path, and the condition turned out
6229 to be false at run-time, and we end up not executing the macro at all.
6232 File: autoconf.info, Node: File Descriptors, Next: File System Conventions, Prev: Here-Documents, Up: Portable Shell
6237 Some file descriptors shall not be used, since some systems,
6238 admittedly arcane, use them for special purpose:
6241 some systems may open it to `/dev/tty'.
6244 used on the Kubota Titan.
6246 Don't redirect several times the same file descriptor, as you are
6247 doomed to failure under Ultrix.
6249 ULTRIX V4.4 (Rev. 69) System #31: Thu Aug 10 19:42:23 GMT 1995
6251 $ eval 'echo matter >fullness' >void
6253 $ eval '(echo matter >fullness)' >void
6255 $ (eval '(echo matter >fullness)') >void
6256 Ambiguous output redirect.
6258 In each case the expected result is of course `fullness' containing
6259 `matter' and `void' being empty.
6261 Don't try to redirect the standard error of a command substitution:
6262 it must be done _inside_ the command substitution: when running `: `cd
6263 /zorglub` 2>/dev/null' expect the error message to escape, while `: `cd
6264 /zorglub 2>/dev/null`' works properly.
6266 It is worth noting that Zsh (but not Ash nor Bash) makes it possible
6267 in assignments though: `foo=`cd /zorglub` 2>/dev/null'.
6269 Most shells, if not all (including Bash, Zsh, Ash), output traces on
6270 stderr, even for sub-shells. This might result in undesired content if
6271 you meant to capture the standard-error output of the inner command:
6273 $ ash -x -c '(eval "echo foo >&2") 2>stderr'
6278 $ bash -x -c '(eval "echo foo >&2") 2>stderr'
6280 + eval 'echo foo >&2'
6283 $ zsh -x -c '(eval "echo foo >&2") 2>stderr'
6284 # Traces on startup files deleted here.
6286 +zsh:1> eval echo foo >&2
6290 You'll appreciate the various levels of detail...
6292 One workaround is to grep out uninteresting lines, hoping not to
6296 File: autoconf.info, Node: File System Conventions, Next: Shell Substitutions, Prev: File Descriptors, Up: Portable Shell
6298 File System Conventions
6299 =======================
6301 While `autoconf' and friends will usually be run on some Unix
6302 variety, it can and will be used on other systems, most notably DOS
6303 variants. This impacts several assumptions regarding file and path
6306 For example, the following code:
6312 foo_dir=$dots$foo_dir ;;
6315 will fail to properly detect absolute paths on those systems, because
6316 they can use a drivespec, and will usually use a backslash as directory
6317 separator. The canonical way to check for absolute paths is:
6320 [\\/]* | ?:[\\/]* ) # Absolute
6323 foo_dir=$dots$foo_dir ;;
6326 Make sure you quote the brackets if appropriate and keep the backslash
6327 as first character (*note Limitations of Builtins::).
6329 Also, because the colon is used as part of a drivespec, these
6330 systems don't use it as path separator. When creating or accessing
6331 paths, use `$ac_path_separator' instead (or the `PATH_SEPARATOR' output
6332 variable). `autoconf' sets this to the appropriate value (`:' or `;')
6335 File names need extra care as well. While DOS-based environments
6336 that are Unixy enough to run `autoconf' (such as DJGPP) will usually be
6337 able to handle long file names properly, there are still limitations
6338 that can seriously break packages. Several of these issues can be
6339 easily detected by the doschk(1) package.
6341 A short overview follows; problems are marked with SFN/LFN to
6342 indicate where they apply: SFN means the issues are only relevant to
6343 plain DOS, not to DOS boxes under Windows, while LFN identifies
6344 problems that exist even under Windows.
6346 No multiple dots (SFN)
6347 DOS cannot handle multiple dots in filenames. This is an
6348 especially important thing to remember when building a portable
6349 configure script, as `autoconf' uses a .in suffix for template
6352 This is perfectly OK on Unices:
6354 AC_CONFIG_HEADER(config.h)
6355 AC_CONFIG_FILES([source.c foo.bar])
6358 but it causes problems on DOS, as it requires `config.h.in',
6359 `source.c.in' and `foo.bar.in'. To make your package more portable
6360 to DOS-based environments, you should use this instead:
6362 AC_CONFIG_HEADER(config.h:config.hin)
6363 AC_CONFIG_FILES([source.c:source.cin foo.bar:foobar.in])
6366 No leading dot (SFN)
6367 DOS cannot handle filenames that start with a dot. This is usually
6368 not a very important issue for `autoconf'.
6370 Case insensitivity (LFN)
6371 DOS is case insensitive, so you cannot, for example, have both a
6372 file called `INSTALL' and a directory called `install'. This also
6373 affects `make'; if there's a file called `INSTALL' in the
6374 directory, `make install' will do nothing (unless the `install'
6375 target is marked as PHONY).
6378 Because the DOS file system only stores the first 8 characters of
6379 the filename and the first 3 of the extension, those must be
6380 unique. That means that `foobar-part1.c', `foobar-part2.c' and
6381 `foobar-prettybird.c' all resolve to the same filename
6382 (`FOOBAR-P.C'). The same goes for `foo.bar' and `foo.bartender'.
6384 Note: This is not usually a problem under Windows, as it uses
6385 numeric tails in the short version of filenames to make them
6386 unique. However, a registry setting can turn this behaviour off.
6387 While this makes it possible to share file trees containing long
6388 file names between SFN and LFN environments, it also means the
6389 above problem applies there as well.
6392 Some characters are invalid in DOS filenames, and should therefore
6393 be avoided. In a LFN environment, these are `/', `\', `?', `*',
6394 `:', `<', `>', `|' and `"'. In a SFN environment, other
6395 characters are also invalid. These include `+', `,', `[' and `]'.
6397 ---------- Footnotes ----------
6399 (1) doschk, <ftp://ftp.gnu.org/gnu/non-gnu/doschk/doschk-1.1.tar.gz>.
6402 File: autoconf.info, Node: Shell Substitutions, Next: Assignments, Prev: File System Conventions, Up: Portable Shell
6407 Contrary to a persistent urban legend, the Bourne shell does not
6408 systematically split variables and backquoted expressions, in particular
6409 on the right-hand side of assignments and in the argument of `case'.
6410 For instance, the following code:
6412 case "$given_srcdir" in
6413 .) top_srcdir="`echo "$dots" | sed 's,/$,,'`"
6414 *) top_srcdir="$dots$given_srcdir" ;;
6417 is more readable when written as:
6419 case $given_srcdir in
6420 .) top_srcdir=`echo "$dots" | sed 's,/$,,'`
6421 *) top_srcdir=$dots$given_srcdir ;;
6424 and in fact it is even _more_ portable: in the first case of the first
6425 attempt, the computation of `top_srcdir' is not portable, since not all
6426 shells properly understand `"`..."..."...`"'. Worse yet, not all
6427 shells understand `"`...\"...\"...`"' the same way. There is just no
6428 portable way to use double-quoted strings inside double-quoted
6429 backquoted expressions (pfew!).
6432 One of the most famous shell-portability issues is related to
6433 `"$@"': when there are no positional arguments, it is supposed to
6434 be equivalent to nothing. But some shells, for instance under
6435 Digital Unix 4.0 and 5.0, will then replace it with an empty
6436 argument. To be portable, use `${1+"$@"}'.
6439 Old BSD shells, including the Ultrix `sh', don't accept the colon
6440 for any shell substitution, and complain and die.
6445 : ${var='Some words'}
6447 otherwise some shells, such as on Digital Unix V 5.0, will die
6448 because of a "bad substitution".
6450 Solaris' `/bin/sh' has a frightening bug in its interpretation of
6451 this. Imagine you need set a variable to a string containing `}'.
6452 This `}' character confuses Solaris' `/bin/sh' when the affected
6453 variable was already set. This bug can be exercised by running:
6459 $ foo=${foo='}' # no error; this hints to what the bug is
6467 It seems that `}' is interpreted as matching `${', even though it
6468 is enclosed in single quotes. The problem doesn't happen using
6471 `${VAR=EXPANDED-VALUE}'
6477 will set VAR to `M-yM-uM-,M-yM-aM-a', i.e., the 8th bit of each
6478 char will be set. You won't observe the phenomenon using a simple
6479 `echo $var' since apparently the shell resets the 8th bit when it
6480 expands $var. Here are two means to make this shell confess its
6489 $ set | grep '^var=' | cat -v
6491 One classic incarnation of this bug is:
6494 : ${list="$default"}
6499 You'll get `a b c' on a single line. Why? Because there are no
6500 spaces in `$list': there are `M- ', i.e., spaces with the 8th bit
6501 set, hence no IFS splitting is performed!!!
6503 One piece of good news is that Ultrix works fine with `:
6504 ${list=$default}'; i.e., if you _don't_ quote. The bad news is
6505 then that QNX 4.25 then sets LIST to the _last_ item of DEFAULT!
6507 The portable way out consists in using a double assignment, to
6508 switch the 8th bit twice on Ultrix:
6510 list=${list="$default"}
6512 ...but beware of the `}' bug from Solaris (see above). For safety,
6515 test "${var+set}" = set || var={VALUE}
6518 While in general it makes no sense, do not substitute a single
6519 builtin with side effects as Ash 0.2, trying to optimize, does not
6520 fork a sub-shell to perform the command.
6522 For instance, if you wanted to check that `cd' is silent, do not
6523 use `test -z "`cd /`"' because the following can happen:
6527 $ test -n "`cd /`" && pwd
6530 The result of `foo=`exit 1`' is left as an exercise to the reader.
6533 This construct is meant to replace ``COMMANDS`'; they can be
6534 nested while this is impossible to do portably with back quotes.
6535 Unfortunately it is not yet widely supported. Most notably, even
6536 recent releases of Solaris don't support it:
6538 $ showrev -c /bin/sh | grep version
6539 Command version: SunOS 5.8 Generic 109324-02 February 2001
6541 syntax error: `(' unexpected
6543 nor does IRIX 6.5's Bourne shell:
6545 IRIX firebird-image 6.5 07151432 IP22
6550 File: autoconf.info, Node: Assignments, Next: Special Shell Variables, Prev: Shell Substitutions, Up: Portable Shell
6555 When setting several variables in a row, be aware that the order of
6556 the evaluation is undefined. For instance `foo=1 foo=2; echo $foo'
6557 gives `1' with sh on Solaris, but `2' with Bash. You must use `;' to
6558 enforce the order: `foo=1; foo=2; echo $foo'.
6560 Don't rely on the exit status of an assignment: Ash 0.2 does not
6561 change the status and propagates that of the last statement:
6563 $ false || foo=bar; echo $?
6565 $ false || foo=`:`; echo $?
6568 and to make things even worse, QNX 4.25 just sets the exit status to 0
6571 $ foo=`exit 1`; echo $?
6574 To assign default values, follow this algorithm:
6576 1. If the default value is a literal and does not contain any closing
6579 : ${var='my literal'}
6581 2. If the default value contains no closing brace, has to be
6582 expanded, and the variable being initialized will never be
6583 IFS-split (i.e., it's not a list), then use:
6587 3. If the default value contains no closing brace, has to be
6588 expanded, and the variable being initialized will be IFS-split
6589 (i.e., it's a list), then use:
6591 var=${var="$default"}
6593 4. If the default value contains a closing brace, then use:
6595 test "${var+set}" = set || var='${indirection}'
6597 In most cases `var=${var="$default"}' is fine, but in case of doubt,
6598 just use the latter. *Note Shell Substitutions::, items
6599 `${VAR:-VALUE}' and `${VAR=VALUE}' for the rationale.
6602 File: autoconf.info, Node: Special Shell Variables, Next: Limitations of Builtins, Prev: Assignments, Up: Portable Shell
6604 Special Shell Variables
6605 =======================
6607 Some shell variables should not be used, since they can have a deep
6608 influence on the behavior of the shell. In order to recover a sane
6609 behavior from the shell, some variables should be unset, but `unset' is
6610 not portable (*note Limitations of Builtins::) and a fallback value is
6611 needed. We list these values below.
6614 When this variable is set `cd' is verbose, so idioms such as
6615 `abs=`cd $rel && pwd`' break because `abs' receives the path twice.
6617 Setting `CDPATH' to the empty value is not enough for most shells.
6618 A simple colon is enough except for `zsh', which prefers a leading
6621 zsh-3.1.6 % mkdir foo && (CDPATH=: cd foo)
6623 zsh-3.1.6 % (CDPATH=:. cd foo)
6625 zsh-3.1.6 % (CDPATH=.: cd foo)
6628 (of course we could just `unset' `CDPATH', since it also behaves
6629 properly if set to the empty string).
6631 Life wouldn't be so much fun if `bash' and `zsh' had the same
6634 bash-2.02 % (CDPATH=:. cd foo)
6635 bash-2.02 % (CDPATH=.: cd foo)
6638 Therefore, a portable solution to neutralize `CDPATH' is
6640 CDPATH=${ZSH_VERSION+.}:
6642 Note that since `zsh' supports `unset', you may unset `CDPATH'
6643 using `:' as a fallback, see *Note Limitations of Builtins::.
6646 Don't set the first character of `IFS' to backslash. Indeed,
6647 Bourne shells use the first character (backslash) when joining the
6648 components in `"$@"' and some shells then re-interpret (!) the
6649 backslash escapes, so you can end up with backspace and other
6660 These must not be set unconditionally because not all systems
6661 understand e.g. `LANG=C' (notably SCO). Fixing `LC_MESSAGES'
6662 prevents Solaris `sh' from translating var values in `set'! Non-C
6663 `LC_CTYPE' values break the ctype check. Fixing `LC_COLLATE'
6664 makes scripts more portable in some cases. For example, it causes
6665 the regular expression `[a-z]' to match only lower-case letters on
6666 ASCII platforms. However, `[a-z]' does not work in general even
6667 when `LC_COLLATE' is fixed; for example, it does not work for
6668 EBCDIC platforms. For maximum portability, you should use regular
6669 expressions like `[abcdefghijklmnopqrstuvwxyz]' that list
6670 characters explicitly instead of relying on ranges.
6672 _If_ one of these variables is set, you should try to unset it,
6673 using `C' as a fall back value. see *Note Limitations of
6674 Builtins::, builtin `unset', for more details.
6677 When executing the command `>foo', `zsh' executes `$NULLCMD >foo'.
6678 The Bourne shell considers `NULLCMD' is `:', while `zsh', even in
6679 Bourne shell compatibility mode, sets `NULLCMD' to `cat'. If you
6680 forgot to set `NULLCMD', your script might be suspended waiting
6681 for data on its standard input.
6684 This variable is an alias to `$?' for `zsh' (at least 3.1.6),
6685 hence read-only. Do not use it.
6688 On DJGPP systems, the `PATH_SEPARATOR' variable can be set to
6689 either `:' or `;' to control the path separator `bash' uses to set
6690 up certain environment variables (such as `PATH'). Since this only
6691 works inside bash, you want autoconf to detect the regular DOS
6692 path separator `;', so it can be safely substituted in files that
6693 may not support `;' as path separator. So either unset this
6694 variable or set it to `;'.
6697 Many shells provide `RANDOM', a variable that returns a different
6698 integer when used. Most of the time, its value does not change
6699 when it is not used, but on IRIX 6.5 the value changes all the
6700 time. This can be observed by using `set'.
6703 File: autoconf.info, Node: Limitations of Builtins, Next: Limitations of Usual Tools, Prev: Special Shell Variables, Up: Portable Shell
6705 Limitations of Shell Builtins
6706 =============================
6708 No, no, we are serious: some shells do have limitations! :)
6710 You should always keep in mind that any built-in or command may
6711 support options, and therefore have a very different behavior with
6712 arguments starting with a dash. For instance, the innocent `echo
6713 "$word"' can give unexpected results when `word' starts with a dash.
6714 It is often possible to avoid this problem using `echo "x$word"', taking
6715 the `x' into account later in the pipe.
6718 You can't use `!', you'll have to rewrite your code.
6721 The use of `break 2', etcetera, is safe.
6724 You don't need to quote the argument; no splitting is performed.
6726 You don't need the final `;;', but you should use it.
6728 Because of a bug in its `fnmatch', `bash' fails to properly handle
6729 backslashes in character classes:
6731 bash-2.02$ case /tmp in [/\\]*) echo OK;; esac
6734 This is extremely unfortunate, since you are likely to use this
6735 code to handle UNIX or MS-DOS absolute paths. To work around this
6736 bug, always put the backslash first:
6738 bash-2.02$ case '\TMP' in [\\/]*) echo OK;; esac
6740 bash-2.02$ case /tmp in [\\/]*) echo OK;; esac
6744 The simple `echo' is probably the most surprising source of
6745 portability troubles. It is not possible to use `echo' portably
6746 unless both options and escape sequences are omitted. New
6747 applications which are not aiming at portability should use
6748 `printf' instead of `echo'.
6750 Don't expect any option. *Note Preset Output Variables::, `ECHO_N'
6751 etc. for a means to simulate `-c'.
6753 Do not use backslashes in the arguments, as there is no consensus
6754 on their handling. On `echo '\n' | wc -l', the `sh' of Digital
6755 Unix 4.0, MIPS RISC/OS 4.52, answer 2, but the Solaris' `sh', Bash
6756 and Zsh (in `sh' emulation mode) report 1. Please note that the
6757 problem is truly `echo': all the shells understand `'\n'' as the
6758 string composed of a backslash and an `n'.
6760 Because of these problems, do not pass a string containing
6761 arbitrary characters to `echo'. For example, `echo "$foo"' is safe
6762 if you know that FOO's value cannot contain backslashes and cannot
6763 start with `-', but otherwise you should use a here-document like
6771 The default value of `exit' is supposed to be `$?'; unfortunately,
6772 some shells, such as the DJGPP port of Bash 2.04, just perform
6775 bash-2.04$ foo=`exit 1` || echo fail
6777 bash-2.04$ foo=`(exit 1)` || echo fail
6779 bash-2.04$ foo=`(exit 1); exit` || echo fail
6782 Using `exit $?' restores the expected behavior.
6784 Some shell scripts, such as those generated by `autoconf', use a
6785 trap to clean up before exiting. If the last shell command exited
6786 with nonzero status, the trap also exits with nonzero status so
6787 that the invoker can tell that an error occurred.
6789 Unfortunately, in some shells, such as Solaris 8 `sh', an exit
6790 trap ignores the `exit' command's status. In these shells, a trap
6791 cannot determine whether it was invoked by plain `exit' or by
6792 `exit 1'. Instead of calling `exit' directly, use the
6793 `AC_MSG_ERROR' macro that has a workaround for this problem.
6796 The builtin `export' dubs "environment variable" a shell variable.
6797 Each update of exported variables corresponds to an update of the
6798 environment variables. Conversely, each environment variable
6799 received by the shell when it is launched should be imported as a
6800 shell variable marked as exported.
6802 Alas, many shells, such as Solaris 2.5, IRIX 6.3, IRIX 5.2, AIX
6803 4.1.5 and DU 4.0, forget to `export' the environment variables they
6804 receive. As a result, two variables are coexisting: the
6805 environment variable and the shell variable. The following code
6806 demonstrates this failure:
6814 when run with `FOO=foo' in the environment, these shells will print
6815 alternately `foo' and `bar', although it should only print `foo'
6816 and then a sequence of `bar's.
6818 Therefore you should `export' again each environment variable that
6822 Don't expect `false' to exit with status 1: in the native Bourne
6823 shell of Solaris 8, it exits with status 255.
6826 To loop over positional arguments, use:
6833 You may _not_ leave the `do' on the same line as `for', since some
6834 shells improperly grok:
6840 If you want to explicitly refer to the positional arguments, given
6841 the `$@' bug (*note Shell Substitutions::), use:
6843 for arg in ${1+"$@"}; do
6848 Using `!' is not portable. Instead of:
6850 if ! cmp -s file file.new; then
6856 if cmp -s file file.new; then :; else
6860 There are shells that do not reset the exit status from an `if':
6862 $ if (exit 42); then true; fi; echo $?
6865 whereas a proper shell should have printed `0'. This is especially
6866 bad in Makefiles since it produces false failures. This is why
6867 properly written Makefiles, such as Automake's, have such hairy
6870 if test -f "$file"; then
6871 install "$file" "$dest"
6877 This builtin faces the usual problem with arguments starting with a
6878 dash. Modern shells such as Bash or Zsh understand `--' to specify
6879 the end of the options (any argument after `--' is a parameters,
6880 even `-x' for instance), but most shells simply stop the option
6881 processing as soon as a non-option argument is found. Therefore,
6882 use `dummy' or simply `x' to end the option processing, and use
6883 `shift' to pop it out:
6885 set x $my_list; shift
6888 Not only is `shift'ing a bad idea when there is nothing left to
6889 shift, but in addition it is not portable: the shell of MIPS
6890 RISC/OS 4.52 refuses to do it.
6893 The `test' program is the way to perform many file and string
6894 tests. It is often invoked by the alternate name `[', but using
6895 that name in Autoconf code is asking for trouble since it is an M4
6898 If you need to make multiple checks using `test', combine them with
6899 the shell operators `&&' and `||' instead of using the `test'
6900 operators `-a' and `-o'. On System V, the precedence of `-a' and
6901 `-o' is wrong relative to the unary operators; consequently, POSIX
6902 does not specify them, so using them is nonportable. If you
6903 combine `&&' and `||' in the same statement, keep in mind that
6904 they have equal precedence.
6906 You may use `!' with `test', but not with `if': `test ! -r foo ||
6910 To enable `configure' scripts to support cross-compilation, they
6911 shouldn't do anything that tests features of the build system
6912 instead of the host system. But occasionally you may find it
6913 necessary to check whether some arbitrary file exists. To do so,
6914 use `test -f' or `test -r'. Do not use `test -x', because 4.3BSD
6915 does not have it. Do not use `test -e' either, because Solaris
6916 2.5 does not have it.
6919 Avoid `test "STRING"', in particular if STRING might start with a
6920 dash, since `test' might interpret its argument as an option
6921 (e.g., `STRING = "-n"').
6923 Contrary to a common belief, `test -n STRING' and `test -z STRING'
6924 *are* portable, nevertheless many shells (such as Solaris 2.5, AIX
6925 3.2, UNICOS 10.0.0.6, Digital Unix 4 etc.) have bizarre precedence
6926 and may be confused if STRING looks like an operator:
6929 test: argument expected
6931 If there are risks, use `test "xSTRING" = x' or `test "xSTRING" !=
6934 It is frequent to find variations of the following idiom:
6936 test -n "`echo $ac_feature | sed 's/[-a-zA-Z0-9_]//g'`" &&
6939 to take an action when a token matches a given pattern. Such
6940 constructs should always be avoided by using:
6942 echo "$ac_feature" | grep '[^-a-zA-Z0-9_]' >/dev/null 2>&1 &&
6945 Use `case' where possible since it is faster, being a shell
6949 *[!-a-zA-Z0-9_]*) ACTION;;
6952 Alas, negated character classes are probably not portable,
6953 although no shell is known to not support the POSIX.2 syntax
6954 `[!...]' (when in interactive mode, `zsh' is confused by the
6955 `[!...]' syntax and looks for an event in its history because of
6956 `!'). Many shells do not support the alternative syntax `[^...]'
6957 (Solaris, Digital Unix, etc.).
6959 One solution can be:
6961 expr "$ac_feature" : '.*[^-a-zA-Z0-9_]' >/dev/null &&
6966 expr "x$ac_feature" : '.*[^-a-zA-Z0-9_]' >/dev/null &&
6969 `expr "XFOO" : "XBAR"' is more robust than `echo "XFOO" | grep
6970 "^XBAR"', because it avoids problems when `FOO' contains
6974 It is safe to trap at least the signals 1, 2, 13 and 15. You can
6975 also trap 0, i.e., have the `trap' run when the script ends
6976 (either via an explicit `exit', or the end of the script).
6978 Although POSIX is not absolutely clear on this point, it is widely
6979 admitted that when entering the trap `$?' should be set to the exit
6980 status of the last command run before the trap. The ambiguity can
6981 be summarized as: "when the trap is launched by an `exit', what is
6982 the _last_ command run: that before `exit', or `exit' itself?"
6984 Bash considers `exit' to be the last command, while Zsh and
6985 Solaris 8 `sh' consider that when the trap is run it is _still_ in
6986 the `exit', hence it is the previous exit status that the trap
6997 The portable solution is then simple: when you want to `exit 42',
6998 run `(exit 42); exit 42', the first `exit' being used to set the
6999 exit status to 42 for Zsh, and the second to trigger the trap and
7000 pass 42 as exit status for Bash.
7002 The shell in FreeBSD 4.0 has the following bug: `$?' is reset to 0
7003 by empty lines if the code is inside `trap'.
7011 Fortunately, this bug only affects `trap'.
7014 Don't worry: as far as we know `true' is portable. Nevertheless,
7015 it's not always a builtin (e.g., Bash 1.x), and the portable shell
7016 community tends to prefer using `:'. This has a funny side
7017 effect: when asked whether `false' is more portable than `true'
7018 Alexandre Oliva answered:
7020 In a sense, yes, because if it doesn't exist, the shell will
7021 produce an exit status of failure, which is correct for
7022 `false', but not for `true'.
7025 You cannot assume the support of `unset', nevertheless, because it
7026 is extremely useful to disable embarrassing variables such as
7027 `CDPATH' or `LANG', you can test for its existence and use it
7028 _provided_ you give a neutralizing value when `unset' is not
7031 if (unset FOO) >/dev/null 2>&1; then
7036 $unset CDPATH || CDPATH=:
7038 *Note Special Shell Variables::, for some neutralizing values.
7039 Also, see *Note Limitations of Builtins::, documentation of
7040 `export', for the case of environment variables.
7043 File: autoconf.info, Node: Limitations of Usual Tools, Next: Limitations of Make, Prev: Limitations of Builtins, Up: Portable Shell
7045 Limitations of Usual Tools
7046 ==========================
7048 The small set of tools you can expect to find on any machine can
7049 still include some limitations you should be aware of.
7052 Don't leave white spaces before the parentheses in user functions
7053 calls, GNU awk will reject it:
7055 $ gawk 'function die () { print "Aaaaarg!" }
7057 gawk: cmd. line:2: BEGIN { die () }
7058 gawk: cmd. line:2: ^ parse error
7059 $ gawk 'function die () { print "Aaaaarg!" }
7063 If you want your program to be deterministic, don't depend on `for'
7073 $ gawk -f for.awk </dev/null
7076 $ nawk -f for.awk </dev/null
7080 Some AWK, such as HPUX 11.0's native one, have regex engines
7081 fragile to inner anchors:
7083 $ echo xfoo | $AWK '/foo|^bar/ { print }'
7084 $ echo bar | $AWK '/foo|^bar/ { print }'
7086 $ echo xfoo | $AWK '/^bar|foo/ { print }'
7088 $ echo bar | $AWK '/^bar|foo/ { print }'
7091 Either do not depend on such patterns (i.e., use `/^(.*foo|bar)/',
7092 or use a simple test to reject such AWK.
7095 Don't rely on any option. The option `-v', which displays
7096 non-printing characters, _seems_ portable, though.
7099 When a compilation such as `cc foo.c -o foo' fails, some compilers
7100 (such as CDS on Reliant UNIX) leave a `foo.o'.
7103 `cmp' performs a raw data comparison of two files, while `diff'
7104 compares two text files. Therefore, if you might compare DOS
7105 files, even if only checking whether two files are different, use
7106 `diff' to avoid spurious differences due to differences of newline
7110 SunOS `cp' does not support `-f', although its `mv' does. It's
7111 possible to deduce why `mv' and `cp' are different with respect to
7112 `-f'. `mv' prompts by default before overwriting a read-only
7113 file. `cp' does not. Therefore, `mv' requires a `-f' option, but
7114 `cp' does not. `mv' and `cp' behave differently with respect to
7115 read-only files because the simplest form of `cp' cannot overwrite
7116 a read-only file, but the simplest form of `mv' can. This is
7117 because `cp' opens the target for write access, whereas `mv'
7118 simply calls `link' (or, in newer systems, `rename').
7121 Option `-u' is nonportable.
7123 Some implementations, such as Tru64's, fail when comparing to
7124 `/dev/null'. Use an empty file instead.
7127 Not all hosts have `dirname', but it is reasonably easy to
7130 dir=`expr "x$file" : 'x\(.*\)/[^/]*' \|
7133 But there are a few subtilities, e.g., under UN*X, should `//1'
7134 give `/'? Paul Eggert answers:
7136 No, under some older flavors of Unix, leading `//' is a
7137 special path name: it refers to a "super-root" and is used to
7138 access other machines' files. Leading `///', `////', etc.
7139 are equivalent to `/'; but leading `//' is special. I think
7140 this tradition started with Apollo Domain/OS, an OS that is
7141 still in use on some older hosts.
7143 POSIX.2 allows but does not require the special treatment for
7144 `//'. It says that the behavior of dirname on path names of
7145 the form `//([^/]+/*)?' is implementation defined. In these
7146 cases, GNU `dirname' returns `/', but it's more portable to
7147 return `//' as this works even on those older flavors of Unix.
7149 I have heard rumors that this special treatment of `//' may be
7150 dropped in future versions of POSIX, but for now it's still
7154 The empty alternative is not portable, use `?' instead. For
7155 instance with Digital Unix v5.0:
7157 > printf "foo\n|foo\n" | egrep '^(|foo|bar)$'
7159 > printf "bar\nbar|\n" | egrep '^(foo|bar|)$'
7161 > printf "foo\nfoo|\n|bar\nbar\n" | egrep '^(foo||bar)$'
7165 `egrep' also suffers the limitations of `grep'.
7168 No `expr' keyword starts with `x', so use `expr x"WORD" :
7169 'xREGEX'' to keep `expr' from misinterpreting WORD.
7171 Don't use `length', `substr', `match' and `index'.
7174 You can use `|'. Although POSIX does require that `expr '''
7175 return the empty string, it does not specify the result when you
7176 `|' together the empty string (or zero) with the empty string. For
7181 GNU/Linux and POSIX.2-1992 return the empty string for this case,
7182 but traditional Unix returns `0' (Solaris is one such example).
7183 In the latest POSIX draft, the specification has been changed to
7184 match traditional Unix's behavior (which is bizarre, but it's too
7185 late to fix this). Please note that the same problem does arise
7186 when the empty string results from a computation, as in:
7188 expr bar : foo \| foo : bar
7190 Avoid this portability problem by avoiding the empty string.
7193 Don't use `\?', `\+' and `\|' in patterns, they are not supported
7196 The POSIX.2-1992 standard is ambiguous as to whether `expr a : b'
7197 (and `expr 'a' : '\(b\)'') output `0' or the empty string. In
7198 practice, it outputs the empty string on most platforms, but
7199 portable scripts should not assume this. For instance, the QNX
7200 4.25 native `expr' returns `0'.
7202 You may believe that one means to get a uniform behavior would be
7203 to use the empty string as a default value:
7207 unfortunately this behaves exactly as the original expression, see
7208 the ``expr' (`:')' entry for more information.
7210 Older `expr' implementations (e.g. SunOS 4 `expr' and Solaris 8
7211 `/usr/ucb/expr') have a silly length limit that causes `expr' to
7212 fail if the matched substring is longer than 120 bytes. In this
7213 case, you might want to fall back on `echo|sed' if `expr' fails.
7215 Don't leave, there is some more!
7217 The QNX 4.25 `expr', in addition of preferring `0' to the empty
7218 string, has a funny behavior in its exit status: it's always 1
7219 when parentheses are used!
7221 $ val=`expr 'a' : 'a'`; echo "$?: $val"
7223 $ val=`expr 'a' : 'b'`; echo "$?: $val"
7226 $ val=`expr 'a' : '\(a\)'`; echo "?: $val"
7228 $ val=`expr 'a' : '\(b\)'`; echo "?: $val"
7231 In practice this can be a big problem if you are ready to catch
7232 failures of `expr' programs with some other method (such as using
7233 `sed'), since you may get twice the result. For instance
7235 $ expr 'a' : '\(a\)' || echo 'a' | sed 's/^\(a\)$/\1/'
7237 will output `a' on most hosts, but `aa' on QNX 4.25. A simple
7238 work around consists in testing `expr' and use a variable set to
7239 `expr' or to `false' according to the result.
7242 The option `-maxdepth' seems to be GNU specific. Tru64 v5.1,
7243 NetBSD 1.5 and Solaris 2.5 `find' commands do not understand it.
7246 Don't use `grep -s' to suppress output, because `grep -s' on
7247 System V does not suppress output, only error messages. Instead,
7248 redirect the standard output and standard error (in case the file
7249 doesn't exist) of `grep' to `/dev/null'. Check the exit status of
7250 `grep' to determine whether it found a match.
7252 Don't use multiple regexps with `-e', as some `grep' will only
7253 honor the last pattern (eg., IRIX 6.5 and Solaris 2.5.1). Anyway,
7254 Stardent Vistra SVR4 `grep' lacks `-e'... Instead, use
7255 alternation and `egrep'.
7258 Don't rely on `ln' having a `-f' option. Symbolic links are not
7259 available on old systems, use `ln' as a fall back.
7261 For versions of the DJGPP before 2.04, `ln' emulates soft links
7262 for executables by generating a stub that in turn calls the real
7263 program. This feature also works with nonexistent files like in
7264 the Unix spec. So `ln -s file link' will generate `link.exe',
7265 which will attempt to call `file.exe' if run. But this feature only
7266 works for executables, so `cp -p' is used instead for these
7267 systems. DJGPP versions 2.04 and later have full symlink support.
7270 The only portable options are `-f' and `-i'.
7272 Moving individual files between file systems is portable (it was
7273 in V6), but it is not always atomic: when doing `mv new existing',
7274 there's a critical section where neither the old nor the new
7275 version of `existing' actually exists.
7277 Moving directories across mount points is not portable, use `cp'
7281 Patterns should not include the separator (unless escaped), even
7282 as part of a character class. In conformance with POSIX, the Cray
7283 `sed' will reject `s/[^/]*$//': use `s,[^/]*$,,'.
7285 Sed scripts should not use branch labels longer than 8 characters
7286 and should not contain comments.
7288 Don't include extra `;', as some `sed', such as NetBSD 1.4.2's,
7289 try to interpret the second as a command:
7291 $ echo a | sed 's/x/x/;;s/x/x/'
7292 sed: 1: "s/x/x/;;s/x/x/": invalid command code ;
7294 Input should have reasonably long lines, since some `sed' have an
7295 input buffer limited to 4000 bytes.
7297 Alternation, `\|', is common but not portable. Anchors (`^' and
7298 `$') inside groups are not portable.
7300 Nested groups are extremely portable, but there is at least one
7301 `sed' (System V/68 Base Operating System R3V7.1) that does not
7304 Of course the option `-e' is portable, but it is not needed. No
7305 valid Sed program can start with a dash, so it does not help
7306 disambiguating. Its sole usefulness is helping enforcing
7309 sed -e INSTRUCTION-1 \
7314 sed INSTRUCTION-1;INSTRUCTION-2
7316 Contrary to yet another urban legend, you may portably use `&' in
7317 the replacement part of the `s' command to mean "what was matched".
7320 Some old systems have `sed' that "forget" to reset their `t' flag
7321 when starting a new cycle. For instance on MIPS RISC/OS, and on
7322 IRIX 5.3, if you run the following `sed' script (the line numbers
7323 are not actual part of the texts):
7325 s/keep me/kept/g # a
7351 Why? When processing 1, a matches, therefore sets the t flag, b
7352 jumps to d, and the output is produced. When processing line 2,
7353 the t flag is still set (this is the bug). Line a fails to match,
7354 but `sed' is not supposed to clear the t flag when a substitution
7355 fails. Line b sees that the flag is set, therefore it clears it,
7356 and jumps to d, hence you get `delete me' instead of `deleted'.
7357 When processing 3 t is clear, a matches, so the flag is set, hence
7358 b clears the flags and jumps. Finally, since the flag is clear, 4
7359 is processed properly.
7361 There are two things one should remind about `t' in `sed'.
7362 Firstly, always remember that `t' jumps if _some_ substitution
7363 succeeded, not only the immediately preceding substitution,
7364 therefore, always use a fake `t clear; : clear' to reset the t
7367 Secondly, you cannot rely on `sed' to clear the flag at each new
7370 One portable implementation of the script above is:
7380 On some old BSD systems, `touch' or any command that results in an
7381 empty file does not update the timestamps, so use a command like
7382 `echo' as a workaround.
7384 GNU `touch' 3.16r (and presumably all before that) fails to work
7385 on SunOS 4.1.3 when the empty file is on an NFS-mounted 4.2 volume.
7388 File: autoconf.info, Node: Limitations of Make, Prev: Limitations of Usual Tools, Up: Portable Shell
7393 Make itself suffers a great number of limitations, only a few of
7394 which being listed here. First of all, remember that since commands are
7395 executed by the shell, all its weaknesses are inherited...
7397 Leading underscore in macro names
7398 Some Make don't support leading underscores in macro names, such
7404 all:; @echo this is test
7407 Make: Must be a separator on rules line 2. Stop.
7412 all:; @echo this is test
7418 Don't use it! For instance any assignment to `VPATH' causes Sun
7419 `make' to only execute the first set of double-colon rules.
7422 File: autoconf.info, Node: Manual Configuration, Next: Site Configuration, Prev: Portable Shell, Up: Top
7424 Manual Configuration
7425 ********************
7427 A few kinds of features can't be guessed automatically by running
7428 test programs. For example, the details of the object-file format, or
7429 special options that need to be passed to the compiler or linker. You
7430 can check for such features using ad-hoc means, such as having
7431 `configure' check the output of the `uname' program, or looking for
7432 libraries that are unique to particular systems. However, Autoconf
7433 provides a uniform method for handling unguessable features.
7437 * Specifying Names:: Specifying the system type
7438 * Canonicalizing:: Getting the canonical system type
7439 * Using System Type:: What to do with the system type
7442 File: autoconf.info, Node: Specifying Names, Next: Canonicalizing, Prev: Manual Configuration, Up: Manual Configuration
7444 Specifying the System Type
7445 ==========================
7447 Like other GNU `configure' scripts, Autoconf-generated `configure'
7448 scripts can make decisions based on a canonical name for the system
7449 type, which has the form: `CPU-VENDOR-OS', where OS can be `SYSTEM' or
7452 `configure' can usually guess the canonical name for the type of
7453 system it's running on. To do so it runs a script called
7454 `config.guess', which infers the name using the `uname' command or
7455 symbols predefined by the C preprocessor.
7457 Alternately, the user can specify the system type with command line
7458 arguments to `configure'. Doing so is necessary when cross-compiling.
7459 In the most complex case of cross-compiling, three system types are
7460 involved. The options to specify them are(1):
7462 `--build=BUILD-TYPE'
7463 the type of system on which the package is being configured and
7467 the type of system on which the package will run.
7469 `--target=TARGET-TYPE'
7470 the type of system for which any compiler tools in the package will
7471 produce code (rarely needed). By default, it is the same as host.
7473 They all default to the result of running `config.guess', unless you
7474 specify either `--build' or `--host'. In this case, the default
7475 becomes the system type you specified. If you specify both, and
7476 they're different, `configure' will enter cross compilation mode, so it
7477 won't run any tests that require execution.
7479 Hint: if you mean to override the result of `config.guess', prefer
7480 `--build' over `--host'. In the future, `--host' will not override the
7481 name of the build system type. Also, if you specify `--host', but not
7482 `--build', when `configure' performs the first compiler test it will
7483 try to run an executable produced by the compiler. If the execution
7484 fails, it will enter cross-compilation mode. Note, however, that it
7485 won't guess the build-system type, since this may require running test
7486 programs. Moreover, by the time the compiler test is performed, it may
7487 be too late to modify the build-system type: other tests may have
7488 already been performed. Therefore, whenever you specify `--host', be
7489 sure to specify `--build' too.
7491 ./configure --build=i686-pc-linux-gnu --host=m68k-coff
7493 will enter cross-compilation mode, but `configure' will fail if it
7494 can't run the code generated by the specified compiler if you configure
7497 ./configure CC=m68k-coff-gcc
7499 `configure' recognizes short aliases for many system types; for
7500 example, `decstation' can be used instead of `mips-dec-ultrix4.2'.
7501 `configure' runs a script called `config.sub' to canonicalize system
7504 ---------- Footnotes ----------
7506 (1) For backward compatibility, `configure' will accept a system
7507 type as an option by itself. Such an option will override the defaults
7508 for build, host and target system types. The following configure
7509 statement will configure a cross toolchain that will run on
7510 NetBSD/alpha but generate code for GNU Hurd/sparc, which is also the
7513 ./configure --host=alpha-netbsd sparc-gnu
7516 File: autoconf.info, Node: Canonicalizing, Next: Using System Type, Prev: Specifying Names, Up: Manual Configuration
7518 Getting the Canonical System Type
7519 =================================
7521 The following macros make the system type available to `configure'
7524 The variables `build_alias', `host_alias', and `target_alias' are
7525 always exactly the arguments of `--build', `--host', and `--target'; in
7526 particular, they are left empty if the user did not use them, even if
7527 the corresponding `AC_CANONICAL' macro was run. Any configure script
7528 may use these variables anywhere. These are the variables that should
7529 be used when in interaction with the user.
7531 If you need to recognize some special environments based on their
7532 system type, run the following macros to get canonical system names.
7533 These variables are not set before the macro call.
7535 If you use these macros, you must distribute `config.guess' and
7536 `config.sub' along with your source code. *Note Output::, for
7537 information about the `AC_CONFIG_AUX_DIR' macro which you can use to
7538 control in which directory `configure' looks for those scripts.
7540 - Macro: AC_CANONICAL_BUILD
7541 Compute the canonical build-system type variable, `build', and its
7542 three individual parts `build_cpu', `build_vendor', and `build_os'.
7544 If `--build' was specified, then `build' is the canonicalization
7545 of `build_alias' by `config.sub', otherwise it is determined by
7546 the shell script `config.guess'.
7548 - Macro: AC_CANONICAL_HOST
7549 Compute the canonical host-system type variable, `host', and its
7550 three individual parts `host_cpu', `host_vendor', and `host_os'.
7552 If `--host' was specified, then `host' is the canonicalization of
7553 `host_alias' by `config.sub', otherwise it defaults to `build'.
7555 For temporary backward-compatibility, when `--host' is specified
7556 by `--build' isn't, the build system will be assumed to be the
7557 same as `--host', and `build_alias' will be set to that value.
7558 Eventually, this historically incorrect behavior will go away.
7561 - Macro: AC_CANONICAL_TARGET
7562 Compute the canonical target-system type variable, `target', and
7563 its three individual parts `target_cpu', `target_vendor', and
7566 If `--target' was specified, then `target' is the canonicalization
7567 of `target_alias' by `config.sub', otherwise it defaults to `host'.
7570 File: autoconf.info, Node: Using System Type, Prev: Canonicalizing, Up: Manual Configuration
7572 Using the System Type
7573 =====================
7575 How do you use a canonical system type? Usually, you use it in one
7576 or more `case' statements in `configure.ac' to select system-specific C
7577 files. Then, using `AC_CONFIG_LINKS', link those files which have
7578 names based on the system name, to generic names, such as `host.h' or
7579 `target.c' (*note Configuration Links::). The `case' statement
7580 patterns can use shell wild cards to group several cases together, like
7584 i386-*-mach* | i386-*-gnu*)
7585 obj_format=aout emulation=mach bfd_gas=yes ;;
7586 i960-*-bout) obj_format=bout ;;
7589 and in `configure.ac', use:
7591 AC_CONFIG_LINKS(host.h:config/$machine.h
7592 object.h:config/$obj_format.h)
7594 You can also use the host system type to find cross-compilation
7595 tools. *Note Generic Programs::, for information about the
7596 `AC_CHECK_TOOL' macro which does that.
7599 File: autoconf.info, Node: Site Configuration, Next: Running configure scripts, Prev: Manual Configuration, Up: Top
7604 `configure' scripts support several kinds of local configuration
7605 decisions. There are ways for users to specify where external software
7606 packages are, include or exclude optional features, install programs
7607 under modified names, and set default values for `configure' options.
7611 * External Software:: Working with other optional software
7612 * Package Options:: Selecting optional features
7613 * Pretty Help Strings:: Formating help string
7614 * Site Details:: Configuring site details
7615 * Transforming Names:: Changing program names when installing
7616 * Site Defaults:: Giving `configure' local defaults
7619 File: autoconf.info, Node: External Software, Next: Package Options, Prev: Site Configuration, Up: Site Configuration
7621 Working With External Software
7622 ==============================
7624 Some packages require, or can optionally use, other software packages
7625 that are already installed. The user can give `configure' command line
7626 options to specify which such external software to use. The options
7627 have one of these forms:
7629 --with-PACKAGE=[ARG]
7632 For example, `--with-gnu-ld' means work with the GNU linker instead
7633 of some other linker. `--with-x' means work with The X Window System.
7635 The user can give an argument by following the package name with `='
7636 and the argument. Giving an argument of `no' is for packages that are
7637 used by default; it says to _not_ use the package. An argument that is
7638 neither `yes' nor `no' could include a name or number of a version of
7639 the other package, to specify more precisely which other package this
7640 program is supposed to work with. If no argument is given, it defaults
7641 to `yes'. `--without-PACKAGE' is equivalent to `--with-PACKAGE=no'.
7643 `configure' scripts do not complain about `--with-PACKAGE' options
7644 that they do not support. This behavior permits configuring a source
7645 tree containing multiple packages with a top-level `configure' script
7646 when the packages support different options, without spurious error
7647 messages about options that some of the packages support. An
7648 unfortunate side effect is that option spelling errors are not
7649 diagnosed. No better approach to this problem has been suggested so
7652 For each external software package that may be used, `configure.ac'
7653 should call `AC_ARG_WITH' to detect whether the `configure' user asked
7654 to use it. Whether each package is used or not by default, and which
7655 arguments are valid, is up to you.
7657 - Macro: AC_ARG_WITH (PACKAGE, HELP-STRING, [ACTION-IF-GIVEN],
7658 [ACTION-IF-NOT-GIVEN])
7659 If the user gave `configure' the option `--with-PACKAGE' or
7660 `--without-PACKAGE', run shell commands ACTION-IF-GIVEN. If
7661 neither option was given, run shell commands ACTION-IF-NOT-GIVEN.
7662 The name PACKAGE indicates another software package that this
7663 program should work with. It should consist only of alphanumeric
7664 characters and dashes.
7666 The option's argument is available to the shell commands
7667 ACTION-IF-GIVEN in the shell variable `withval', which is actually
7668 just the value of the shell variable `with_PACKAGE', with any `-'
7669 characters changed into `_'. You may use that variable instead,
7672 The argument HELP-STRING is a description of the option that looks
7674 --with-readline support fancy command line editing
7676 HELP-STRING may be more than one line long, if more detail is
7677 needed. Just make sure the columns line up in `configure --help'.
7678 Avoid tabs in the help string. You'll need to enclose it in `['
7679 and `]' in order to produce the leading spaces.
7681 You should format your HELP-STRING with the macro `AC_HELP_STRING'
7682 (*note Pretty Help Strings::).
7684 - Macro: AC_WITH (PACKAGE, ACTION-IF-GIVEN, [ACTION-IF-NOT-GIVEN])
7685 This is an obsolete version of `AC_ARG_WITH' that does not support
7686 providing a help string.
7689 File: autoconf.info, Node: Package Options, Next: Pretty Help Strings, Prev: External Software, Up: Site Configuration
7691 Choosing Package Options
7692 ========================
7694 If a software package has optional compile-time features, the user
7695 can give `configure' command line options to specify whether to compile
7696 them. The options have one of these forms:
7698 --enable-FEATURE=[ARG]
7701 These options allow users to choose which optional features to build
7702 and install. `--enable-FEATURE' options should never make a feature
7703 behave differently or cause one feature to replace another. They
7704 should only cause parts of the program to be built rather than left out.
7706 The user can give an argument by following the feature name with `='
7707 and the argument. Giving an argument of `no' requests that the feature
7708 _not_ be made available. A feature with an argument looks like
7709 `--enable-debug=stabs'. If no argument is given, it defaults to `yes'.
7710 `--disable-FEATURE' is equivalent to `--enable-FEATURE=no'.
7712 `configure' scripts do not complain about `--enable-FEATURE' options
7713 that they do not support. This behavior permits configuring a source
7714 tree containing multiple packages with a top-level `configure' script
7715 when the packages support different options, without spurious error
7716 messages about options that some of the packages support. An
7717 unfortunate side effect is that option spelling errors are not
7718 diagnosed. No better approach to this problem has been suggested so
7721 For each optional feature, `configure.ac' should call
7722 `AC_ARG_ENABLE' to detect whether the `configure' user asked to include
7723 it. Whether each feature is included or not by default, and which
7724 arguments are valid, is up to you.
7726 - Macro: AC_ARG_ENABLE (FEATURE, HELP-STRING, [ACTION-IF-GIVEN],
7727 [ACTION-IF-NOT-GIVEN])
7728 If the user gave `configure' the option `--enable-FEATURE' or
7729 `--disable-FEATURE', run shell commands ACTION-IF-GIVEN. If
7730 neither option was given, run shell commands ACTION-IF-NOT-GIVEN.
7731 The name FEATURE indicates an optional user-level facility. It
7732 should consist only of alphanumeric characters and dashes.
7734 The option's argument is available to the shell commands
7735 ACTION-IF-GIVEN in the shell variable `enableval', which is
7736 actually just the value of the shell variable `enable_FEATURE',
7737 with any `-' characters changed into `_'. You may use that
7738 variable instead, if you wish. The HELP-STRING argument is like
7739 that of `AC_ARG_WITH' (*note External Software::).
7741 You should format your HELP-STRING with the macro `AC_HELP_STRING'
7742 (*note Pretty Help Strings::).
7744 - Macro: AC_ENABLE (FEATURE, ACTION-IF-GIVEN, [ACTION-IF-NOT-GIVEN])
7745 This is an obsolete version of `AC_ARG_ENABLE' that does not
7746 support providing a help string.
7749 File: autoconf.info, Node: Pretty Help Strings, Next: Site Details, Prev: Package Options, Up: Site Configuration
7751 Making Your Help Strings Look Pretty
7752 ====================================
7754 Properly formatting the `help strings' which are used in
7755 `AC_ARG_WITH' (*note External Software::) and `AC_ARG_ENABLE' (*note
7756 Package Options::) can be challenging. Specifically, you want your own
7757 `help strings' to line up in the appropriate columns of `configure
7758 --help' just like the standard Autoconf `help strings' do. This is the
7759 purpose of the `AC_HELP_STRING' macro.
7761 - Macro: AC_HELP_STRING (LEFT-HAND-SIDE, RIGHT-HAND-SIDE)
7762 Expands into an help string that looks pretty when the user
7763 executes `configure --help'. It is typically used in `AC_ARG_WITH'
7764 (*note External Software::) or `AC_ARG_ENABLE' (*note Package
7765 Options::). The following example will make this clearer.
7767 AC_DEFUN(TEST_MACRO,
7769 AC_HELP_STRING([--with-foo],
7770 [use foo (default is NO)]),
7771 ac_cv_use_foo=$withval, ac_cv_use_foo=no),
7772 AC_CACHE_CHECK(whether to use foo,
7773 ac_cv_use_foo, ac_cv_use_foo=no)])
7775 Please note that the call to `AC_HELP_STRING' is *unquoted*. Then
7776 the last few lines of `configure --help' will appear like this:
7778 --enable and --with options recognized:
7779 --with-foo use foo (default is NO)
7781 The `AC_HELP_STRING' macro is particularly helpful when the
7782 LEFT-HAND-SIDE and/or RIGHT-HAND-SIDE are composed of macro
7783 arguments, as shown in the following example.
7785 AC_DEFUN(MY_ARG_WITH,
7787 AC_HELP_STRING([--with-$1], [use $1 (default is $2)]),
7788 ac_cv_use_$1=$withval, ac_cv_use_$1=no),
7789 AC_CACHE_CHECK(whether to use $1, ac_cv_use_$1, ac_cv_use_$1=$2)])
7792 File: autoconf.info, Node: Site Details, Next: Transforming Names, Prev: Pretty Help Strings, Up: Site Configuration
7794 Configuring Site Details
7795 ========================
7797 Some software packages require complex site-specific information.
7798 Some examples are host names to use for certain services, company
7799 names, and email addresses to contact. Since some configuration
7800 scripts generated by Metaconfig ask for such information interactively,
7801 people sometimes wonder how to get that information in
7802 Autoconf-generated configuration scripts, which aren't interactive.
7804 Such site configuration information should be put in a file that is
7805 edited _only by users_, not by programs. The location of the file can
7806 either be based on the `prefix' variable, or be a standard location
7807 such as the user's home directory. It could even be specified by an
7808 environment variable. The programs should examine that file at run
7809 time, rather than at compile time. Run time configuration is more
7810 convenient for users and makes the configuration process simpler than
7811 getting the information while configuring. *Note Variables for
7812 Installation Directories: (standards)Directory Variables, for more
7813 information on where to put data files.
7816 File: autoconf.info, Node: Transforming Names, Next: Site Defaults, Prev: Site Details, Up: Site Configuration
7818 Transforming Program Names When Installing
7819 ==========================================
7821 Autoconf supports changing the names of programs when installing
7822 them. In order to use these transformations, `configure.ac' must call
7823 the macro `AC_ARG_PROGRAM'.
7825 - Macro: AC_ARG_PROGRAM
7826 Place in output variable `program_transform_name' a sequence of
7827 `sed' commands for changing the names of installed programs.
7829 If any of the options described below are given to `configure',
7830 program names are transformed accordingly. Otherwise, if
7831 `AC_CANONICAL_TARGET' has been called and a `--target' value is
7832 given that differs from the host type (specified with `--host'),
7833 the target type followed by a dash is used as a prefix.
7834 Otherwise, no program name transformation is done.
7838 * Transformation Options:: `configure' options to transform names
7839 * Transformation Examples:: Sample uses of transforming names
7840 * Transformation Rules:: `Makefile' uses of transforming names
7843 File: autoconf.info, Node: Transformation Options, Next: Transformation Examples, Prev: Transforming Names, Up: Transforming Names
7845 Transformation Options
7846 ----------------------
7848 You can specify name transformations by giving `configure' these
7849 command line options:
7851 `--program-prefix=PREFIX'
7852 prepend PREFIX to the names;
7854 `--program-suffix=SUFFIX'
7855 append SUFFIX to the names;
7857 `--program-transform-name=EXPRESSION'
7858 perform `sed' substitution EXPRESSION on the names.
7861 File: autoconf.info, Node: Transformation Examples, Next: Transformation Rules, Prev: Transformation Options, Up: Transforming Names
7863 Transformation Examples
7864 -----------------------
7866 These transformations are useful with programs that can be part of a
7867 cross-compilation development environment. For example, a
7868 cross-assembler running on a Sun 4 configured with
7869 `--target=i960-vxworks' is normally installed as `i960-vxworks-as',
7870 rather than `as', which could be confused with a native Sun 4 assembler.
7872 You can force a program name to begin with `g', if you don't want
7873 GNU programs installed on your system to shadow other programs with the
7874 same name. For example, if you configure GNU `diff' with
7875 `--program-prefix=g', then when you run `make install' it is installed
7876 as `/usr/local/bin/gdiff'.
7878 As a more sophisticated example, you could use
7880 --program-transform-name='s/^/g/; s/^gg/g/; s/^gless/less/'
7882 to prepend `g' to most of the program names in a source tree, excepting
7883 those like `gdb' that already have one and those like `less' and
7884 `lesskey' that aren't GNU programs. (That is assuming that you have a
7885 source tree containing those programs that is set up to use this
7888 One way to install multiple versions of some programs simultaneously
7889 is to append a version number to the name of one or both. For example,
7890 if you want to keep Autoconf version 1 around for awhile, you can
7891 configure Autoconf version 2 using `--program-suffix=2' to install the
7892 programs as `/usr/local/bin/autoconf2', `/usr/local/bin/autoheader2',
7893 etc. Nevertheless, pay attention that only the binaries are renamed,
7894 therefore you'd have problems with the library files which might
7898 File: autoconf.info, Node: Transformation Rules, Prev: Transformation Examples, Up: Transforming Names
7900 Transformation Rules
7901 --------------------
7903 Here is how to use the variable `program_transform_name' in a
7906 transform = @program_transform_name@
7908 $(INSTALL_PROGRAM) myprog $(bindir)/`echo myprog | \
7912 rm -f $(bindir)/`echo myprog | sed '$(transform)'`
7914 If you have more than one program to install, you can do it in a loop:
7918 for p in $(PROGRAMS); do \
7919 $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p | \
7920 sed '$(transform)'`; \
7924 for p in $(PROGRAMS); do \
7925 rm -f $(bindir)/`echo $$p | sed '$(transform)'`; \
7928 It is guaranteed that `program_transform_name' is never empty, and
7929 that there are no useless separators. Therefore you may safely embed
7930 `program_transform_name' within a sed program using `;':
7932 transform = @program_transform_name@
7933 transform_exe = s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/
7935 Whether to do the transformations on documentation files (Texinfo or
7936 `man') is a tricky question; there seems to be no perfect answer, due
7937 to the several reasons for name transforming. Documentation is not
7938 usually particular to a specific architecture, and Texinfo files do not
7939 conflict with system documentation. But they might conflict with
7940 earlier versions of the same files, and `man' pages sometimes do
7941 conflict with system documentation. As a compromise, it is probably
7942 best to do name transformations on `man' pages but not on Texinfo
7946 File: autoconf.info, Node: Site Defaults, Prev: Transforming Names, Up: Site Configuration
7948 Setting Site Defaults
7949 =====================
7951 Autoconf-generated `configure' scripts allow your site to provide
7952 default values for some configuration values. You do this by creating
7953 site- and system-wide initialization files.
7955 If the environment variable `CONFIG_SITE' is set, `configure' uses
7956 its value as the name of a shell script to read. Otherwise, it reads
7957 the shell script `PREFIX/share/config.site' if it exists, then
7958 `PREFIX/etc/config.site' if it exists. Thus, settings in
7959 machine-specific files override those in machine-independent ones in
7962 Site files can be arbitrary shell scripts, but only certain kinds of
7963 code are really appropriate to be in them. Because `configure' reads
7964 any cache file after it has read any site files, a site file can define
7965 a default cache file to be shared between all Autoconf-generated
7966 `configure' scripts run on that system (*note Cache Files::). If you
7967 set a default cache file in a site file, it is a good idea to also set
7968 the output variable `CC' in that site file, because the cache file is
7969 only valid for a particular compiler, but many systems have several
7972 You can examine or override the value set by a command line option to
7973 `configure' in a site file; options set shell variables that have the
7974 same names as the options, with any dashes turned into underscores.
7975 The exceptions are that `--without-' and `--disable-' options are like
7976 giving the corresponding `--with-' or `--enable-' option and the value
7977 `no'. Thus, `--cache-file=localcache' sets the variable `cache_file'
7978 to the value `localcache'; `--enable-warnings=no' or
7979 `--disable-warnings' sets the variable `enable_warnings' to the value
7980 `no'; `--prefix=/usr' sets the variable `prefix' to the value `/usr';
7983 Site files are also good places to set default values for other
7984 output variables, such as `CFLAGS', if you need to give them non-default
7985 values: anything you would normally do, repetitively, on the command
7986 line. If you use non-default values for PREFIX or EXEC_PREFIX
7987 (wherever you locate the site file), you can set them in the site file
7988 if you specify it with the `CONFIG_SITE' environment variable.
7990 You can set some cache values in the site file itself. Doing this is
7991 useful if you are cross-compiling, so it is impossible to check features
7992 that require running a test program. You could "prime the cache" by
7993 setting those values correctly for that system in
7994 `PREFIX/etc/config.site'. To find out the names of the cache variables
7995 you need to set, look for shell variables with `_cv_' in their names in
7996 the affected `configure' scripts, or in the Autoconf M4 source code for
7999 The cache file is careful to not override any variables set in the
8000 site files. Similarly, you should not override command-line options in
8001 the site files. Your code should check that variables such as `prefix'
8002 and `cache_file' have their default values (as set near the top of
8003 `configure') before changing them.
8005 Here is a sample file `/usr/share/local/gnu/share/config.site'. The
8006 command `configure --prefix=/usr/share/local/gnu' would read this file
8007 (if `CONFIG_SITE' is not set to a different file).
8009 # config.site for configure
8011 # Change some defaults.
8012 test "$prefix" = NONE && prefix=/usr/share/local/gnu
8013 test "$exec_prefix" = NONE && exec_prefix=/usr/local/gnu
8014 test "$sharedstatedir" = '$prefix/com' && sharedstatedir=/var
8015 test "$localstatedir" = '$prefix/var' && localstatedir=/var
8017 # Give Autoconf 2.x generated configure scripts a shared default
8018 # cache file for feature test results, architecture-specific.
8019 if test "$cache_file" = /dev/null; then
8020 cache_file="$prefix/var/config.cache"
8021 # A cache file is only valid for one C compiler.
8026 File: autoconf.info, Node: Running configure scripts, Next: config.status Invocation, Prev: Site Configuration, Up: Top
8028 Running `configure' Scripts
8029 ***************************
8031 Below are instructions on how to configure a package that uses a
8032 `configure' script, suitable for inclusion as an `INSTALL' file in the
8033 package. A plain-text version of `INSTALL' which you may use comes
8038 * Basic Installation:: Instructions for typical cases
8039 * Compilers and Options:: Selecting compilers and optimization
8040 * Multiple Architectures:: Compiling for multiple architectures at once
8041 * Installation Names:: Installing in different directories
8042 * Optional Features:: Selecting optional features
8043 * System Type:: Specifying the system type
8044 * Sharing Defaults:: Setting site-wide defaults for `configure'
8045 * Environment Variables:: Defining environment variables.
8046 * configure Invocation:: Changing how `configure' runs
8049 File: autoconf.info, Node: Basic Installation, Next: Compilers and Options, Up: Running configure scripts
8054 These are generic installation instructions.
8056 The `configure' shell script attempts to guess correct values for
8057 various system-dependent variables used during compilation. It uses
8058 those values to create a `Makefile' in each directory of the package.
8059 It may also create one or more `.h' files containing system-dependent
8060 definitions. Finally, it creates a shell script `config.status' that
8061 you can run in the future to recreate the current configuration, and a
8062 file `config.log' containing compiler output (useful mainly for
8063 debugging `configure').
8065 It can also use an optional file (typically called `config.cache'
8066 and enabled with `--cache-file=config.cache' or simply `-C') that saves
8067 the results of its tests to speed up reconfiguring. (Caching is
8068 disabled by default to prevent problems with accidental use of stale
8071 If you need to do unusual things to compile the package, please try
8072 to figure out how `configure' could check whether to do them, and mail
8073 diffs or instructions to the address given in the `README' so they can
8074 be considered for the next release. If you are using the cache, and at
8075 some point `config.cache' contains results you don't want to keep, you
8076 may remove or edit it.
8078 The file `configure.ac' (or `configure.in') is used to create
8079 `configure' by a program called `autoconf'. You only need
8080 `configure.ac' if you want to change it or regenerate `configure' using
8081 a newer version of `autoconf'.
8083 The simplest way to compile this package is:
8085 1. `cd' to the directory containing the package's source code and type
8086 `./configure' to configure the package for your system. If you're
8087 using `csh' on an old version of System V, you might need to type
8088 `sh ./configure' instead to prevent `csh' from trying to execute
8091 Running `configure' takes awhile. While running, it prints some
8092 messages telling which features it is checking for.
8094 2. Type `make' to compile the package.
8096 3. Optionally, type `make check' to run any self-tests that come with
8099 4. Type `make install' to install the programs and any data files and
8102 5. You can remove the program binaries and object files from the
8103 source code directory by typing `make clean'. To also remove the
8104 files that `configure' created (so you can compile the package for
8105 a different kind of computer), type `make distclean'. There is
8106 also a `make maintainer-clean' target, but that is intended mainly
8107 for the package's developers. If you use it, you may have to get
8108 all sorts of other programs in order to regenerate files that came
8109 with the distribution.
8112 File: autoconf.info, Node: Compilers and Options, Next: Multiple Architectures, Prev: Basic Installation, Up: Running configure scripts
8114 Compilers and Options
8115 =====================
8117 Some systems require unusual options for compilation or linking that
8118 the `configure' script does not know about. Run `./configure --help'
8119 for details on some of the pertinent environment variables.
8121 You can give `configure' initial values for variables by setting
8122 them in the environment. You can do that on the command line like this:
8124 ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
8126 *Note Environment Variables::, for more details.
8129 File: autoconf.info, Node: Multiple Architectures, Next: Installation Names, Prev: Compilers and Options, Up: Running configure scripts
8131 Compiling For Multiple Architectures
8132 ====================================
8134 You can compile the package for more than one kind of computer at the
8135 same time, by placing the object files for each architecture in their
8136 own directory. To do this, you must use a version of `make' that
8137 supports the `VPATH' variable, such as GNU `make'. `cd' to the
8138 directory where you want the object files and executables to go and run
8139 the `configure' script. `configure' automatically checks for the
8140 source code in the directory that `configure' is in and in `..'.
8142 If you have to use a `make' that does not support the `VPATH'
8143 variable, you have to compile the package for one architecture at a time
8144 in the source code directory. After you have installed the package for
8145 one architecture, use `make distclean' before reconfiguring for another
8149 File: autoconf.info, Node: Installation Names, Next: Optional Features, Prev: Multiple Architectures, Up: Running configure scripts
8154 By default, `make install' will install the package's files in
8155 `/usr/local/bin', `/usr/local/man', etc. You can specify an
8156 installation prefix other than `/usr/local' by giving `configure' the
8157 option `--prefix=PATH'.
8159 You can specify separate installation prefixes for
8160 architecture-specific files and architecture-independent files. If you
8161 give `configure' the option `--exec-prefix=PATH', the package will use
8162 PATH as the prefix for installing programs and libraries.
8163 Documentation and other data files will still use the regular prefix.
8165 In addition, if you use an unusual directory layout you can give
8166 options like `--bindir=PATH' to specify different values for particular
8167 kinds of files. Run `configure --help' for a list of the directories
8168 you can set and what kinds of files go in them.
8170 If the package supports it, you can cause programs to be installed
8171 with an extra prefix or suffix on their names by giving `configure' the
8172 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
8175 File: autoconf.info, Node: Optional Features, Next: System Type, Prev: Installation Names, Up: Running configure scripts
8180 Some packages pay attention to `--enable-FEATURE' options to
8181 `configure', where FEATURE indicates an optional part of the package.
8182 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
8183 is something like `gnu-as' or `x' (for the X Window System). The
8184 `README' should mention any `--enable-' and `--with-' options that the
8187 For packages that use the X Window System, `configure' can usually
8188 find the X include and library files automatically, but if it doesn't,
8189 you can use the `configure' options `--x-includes=DIR' and
8190 `--x-libraries=DIR' to specify their locations.
8193 File: autoconf.info, Node: System Type, Next: Sharing Defaults, Prev: Optional Features, Up: Running configure scripts
8195 Specifying the System Type
8196 ==========================
8198 There may be some features `configure' cannot figure out
8199 automatically, but needs to determine by the type of host the package
8200 will run on. Usually `configure' can figure that out, but if it prints
8201 a message saying it cannot guess the host type, give it the
8202 `--build=TYPE' option. TYPE can either be a short name for the system
8203 type, such as `sun4', or a canonical name which has the form:
8207 where SYSTEM can have one of these forms:
8212 See the file `config.sub' for the possible values of each field. If
8213 `config.sub' isn't included in this package, then this package doesn't
8214 need to know the host type.
8216 If you are _building_ compiler tools for cross-compiling, you should
8217 use the `--target=TYPE' option to select the type of system they will
8220 If you want to _use_ a cross compiler, that generates code for a
8221 platform different from the build platform, you should specify the host
8222 platform (i.e., that on which the generated programs will eventually be
8223 run) with `--host=TYPE'. In this case, you should also specify the
8224 build platform with `--build=TYPE', because, in this case, it may not
8225 be possible to guess the build platform (it sometimes involves
8226 compiling and running simple test programs, and this can't be done if
8227 the compiler is a cross compiler).
8230 File: autoconf.info, Node: Sharing Defaults, Next: Environment Variables, Prev: System Type, Up: Running configure scripts
8235 If you want to set default values for `configure' scripts to share,
8236 you can create a site shell script called `config.site' that gives
8237 default values for variables like `CC', `cache_file', and `prefix'.
8238 `configure' looks for `PREFIX/share/config.site' if it exists, then
8239 `PREFIX/etc/config.site' if it exists. Or, you can set the
8240 `CONFIG_SITE' environment variable to the location of the site script.
8241 A warning: not all `configure' scripts look for a site script.
8244 File: autoconf.info, Node: Environment Variables, Next: configure Invocation, Prev: Sharing Defaults, Up: Running configure scripts
8246 Environment Variables
8247 =====================
8249 Variables not defined in a site shell script can be set in the
8250 environment passed to configure. However, some packages may run
8251 configure again during the build, and the customized values of these
8252 variables may be lost. In order to avoid this problem, you should set
8253 them in the `configure' command line, using `VAR=value'. For example:
8255 ./configure CC=/usr/local2/bin/gcc
8257 will cause the specified gcc to be used as the C compiler (unless it is
8258 overridden in the site shell script).
8261 File: autoconf.info, Node: configure Invocation, Prev: Environment Variables, Up: Running configure scripts
8263 `configure' Invocation
8264 ======================
8266 `configure' recognizes the following options to control how it
8271 Print a summary of the options to `configure', and exit.
8275 Print the version of Autoconf used to generate the `configure'
8279 Enable the cache: use and save the results of the tests in FILE,
8280 traditionally `config.cache'. FILE defaults to `/dev/null' to
8285 Alias for `--cache-file=config.cache'.
8290 Do not print messages saying which checks are being made. To
8291 suppress all normal output, redirect it to `/dev/null' (any error
8292 messages will still be shown).
8295 Look for the package's source code in directory DIR. Usually
8296 `configure' can determine that directory automatically.
8298 `configure' also accepts some other, not widely useful, options. Run
8299 `configure --help' for more details.
8302 File: autoconf.info, Node: config.status Invocation, Next: Obsolete Constructs, Prev: Running configure scripts, Up: Top
8304 Recreating a Configuration
8305 **************************
8307 The `configure' script creates a file named `config.status', which
8308 actually configures, "instantiates", the template files. It also
8309 records the configuration options that were specified when the package
8310 was last configured in case reconfiguring is needed.
8313 ./config.status OPTION... [FILE...]
8315 It configures the FILES, if none are specified, all the templates
8316 are instantiated. The files must be specified without their
8319 ./config.status foobar
8323 ./config.status foobar:foo.in:bar.in
8325 The supported OPTIONs are:
8329 Print a summary of the command line options, the list of the
8330 template files and exit.
8334 Print the version number of Autoconf and exit.
8338 Don't remove the temporary files.
8340 `--file=FILE[:TEMPLATE]'
8341 Require that FILE be instantiated as if
8342 `AC_CONFIG_FILES(FILE:TEMPLATE)' was used. Both FILE and TEMPLATE
8343 may be `-' in which case the standard output and/or standard
8344 input, respectively, is used. If a TEMPLATE filename is relative,
8345 it is first looked for in the build tree, and then in the source
8346 tree. *Note Configuration Actions::, for more details.
8348 This option and the following ones provide one way for separately
8349 distributed packages to share the values computed by `configure'.
8350 Doing so can be useful if some of the packages need a superset of
8351 the features that one of them, perhaps a common library, does.
8352 These options allow a `config.status' file to create files other
8353 than the ones that its `configure.ac' specifies, so it can be used
8354 for a different package.
8356 `--header=FILE[:TEMPLATE]'
8357 Same as `--file' above, but with `AC_CONFIG_HEADERS'.
8360 Ask `config.status' to update itself and exit (no instantiation).
8361 This option is useful if you change `configure', so that the
8362 results of some tests might be different from the previous run.
8363 The `--recheck' option re-runs `configure' with the same arguments
8364 you used before, plus the `--no-create' option, which prevents
8365 `configure' from running `config.status' and creating `Makefile'
8366 and other files, and the `--no-recursion' option, which prevents
8367 `configure' from running other `configure' scripts in
8368 subdirectories. (This is so other `Makefile' rules can run
8369 `config.status' when it changes; *note Automatic Remaking::, for
8372 `config.status' checks several optional environment variables that
8373 can alter its behavior:
8375 - Variable: CONFIG_SHELL
8376 The shell with which to run `configure' for the `--recheck'
8377 option. It must be Bourne-compatible. The default is `/bin/sh'.
8379 - Variable: CONFIG_STATUS
8380 The file name to use for the shell script that records the
8381 configuration. The default is `./config.status'. This variable is
8382 useful when one package uses parts of another and the `configure'
8383 scripts shouldn't be merged because they are maintained separately.
8385 You can use `./config.status' in your Makefiles. For example, in
8386 the dependencies given above (*note Automatic Remaking::),
8387 `config.status' is run twice when `configure.ac' has changed. If that
8388 bothers you, you can make each run only regenerate the files for that
8391 stamp-h: config.h.in config.status
8392 ./config.status config.h
8395 Makefile: Makefile.in config.status
8396 ./config.status Makefile
8398 The calling convention of `config.status' has changed, see *Note
8399 Obsolete config.status Use::, for details.
8402 File: autoconf.info, Node: Obsolete Constructs, Next: Questions, Prev: config.status Invocation, Up: Top
8407 Autoconf changes, and throughout the years some constructs are
8408 obsoleted. Most of the changes involve the macros, but the tools
8409 themselves, or even some concepts, are now considered obsolete.
8411 You may completely skip this chapter if you are new to Autoconf, its
8412 intention is mainly to help maintainers updating their packages by
8413 understanding how to move to more modern constructs.
8417 * Obsolete config.status Use:: Different calling convention
8418 * acconfig.h:: Additional entries in `config.h.in'
8419 * autoupdate Invocation:: Automatic update of `configure.ac'
8420 * Obsolete Macros:: Backward compatibility macros
8421 * Autoconf 1:: Tips for upgrading your files
8422 * Autoconf 2.13:: Some fresher tips
8425 File: autoconf.info, Node: Obsolete config.status Use, Next: acconfig.h, Prev: Obsolete Constructs, Up: Obsolete Constructs
8427 Obsolete `config.status' Invocation
8428 ===================================
8430 `config.status' now supports arguments to specify the files to
8431 instantiate, see *Note config.status Invocation::, for more details.
8432 Before, environment variables had to be used.
8434 - Variable: CONFIG_COMMANDS
8435 The tags of the commands to execute. The default is the arguments
8436 given to `AC_OUTPUT' and `AC_CONFIG_COMMANDS' in `configure.ac'.
8438 - Variable: CONFIG_FILES
8439 The files in which to perform `@VARIABLE@' substitutions. The
8440 default is the arguments given to `AC_OUTPUT' and
8441 `AC_CONFIG_FILES' in `configure.ac'.
8443 - Variable: CONFIG_HEADERS
8444 The files in which to substitute C `#define' statements. The
8445 default is the arguments given to `AC_CONFIG_HEADERS'; if that
8446 macro was not called, `config.status' ignores this variable.
8448 - Variable: CONFIG_LINKS
8449 The symbolic links to establish. The default is the arguments
8450 given to `AC_CONFIG_LINKS'; if that macro was not called,
8451 `config.status' ignores this variable.
8453 In *Note config.status Invocation::, using this old interface, the
8457 stamp-h: config.h.in config.status
8458 CONFIG_COMMANDS= CONFIG_LINKS= CONFIG_FILES= \
8459 CONFIG_HEADERS=config.h ./config.status
8462 Makefile: Makefile.in config.status
8463 CONFIG_COMMANDS= CONFIG_LINKS= CONFIG_HEADERS= \
8464 CONFIG_FILES=Makefile ./config.status
8466 (If `configure.ac' does not call `AC_CONFIG_HEADERS', there is no need
8467 to set `CONFIG_HEADERS' in the `make' rules, equally for
8468 `CONFIG_COMMANDS' etc.)
8471 File: autoconf.info, Node: acconfig.h, Next: autoupdate Invocation, Prev: Obsolete config.status Use, Up: Obsolete Constructs
8476 In order to produce `config.h.in', `autoheader' needs to build or to
8477 find templates for each symbol. Modern releases of Autoconf use
8478 `AH_VERBATIM' and `AH_TEMPLATE' (*note Autoheader Macros::), but in
8479 older releases a file, `acconfig.h', contained the list of needed
8480 templates. `autoheader' copies comments and `#define' and `#undef'
8481 statements from `acconfig.h' in the current directory, if present.
8482 This file used to be mandatory if you `AC_DEFINE' any additional
8485 Modern releases of Autoconf also provide `AH_TOP' and `AH_BOTTOM' if
8486 you need to prepend/append some information to `config.h.in'. Ancient
8487 versions of Autoconf had a similar feature: if `./acconfig.h' contains
8488 the string `@TOP@', `autoheader' copies the lines before the line
8489 containing `@TOP@' into the top of the file that it generates.
8490 Similarly, if `./acconfig.h' contains the string `@BOTTOM@',
8491 `autoheader' copies the lines after that line to the end of the file it
8492 generates. Either or both of those strings may be omitted. An even
8493 older alternate way to produce the same effect in jurasik versions of
8494 Autoconf is to create the files `FILE.top' (typically `config.h.top')
8495 and/or `FILE.bot' in the current directory. If they exist,
8496 `autoheader' copies them to the beginning and end, respectively, of its
8499 In former versions of Autoconf, the files used in preparing a
8500 software package for distribution were:
8501 configure.ac --. .------> autoconf* -----> configure
8503 [aclocal.m4] --+ `---.
8505 +--> [autoheader*] -> [config.h.in]
8506 [acconfig.h] ----. |
8511 Use only the `AH_' macros, `configure.ac' should be self-contained,
8512 and should not depend upon `acconfig.h' etc.
8515 File: autoconf.info, Node: autoupdate Invocation, Next: Obsolete Macros, Prev: acconfig.h, Up: Obsolete Constructs
8517 Using `autoupdate' to Modernize `configure.ac'
8518 ==============================================
8520 The `autoupdate' program updates a `configure.ac' file that calls
8521 Autoconf macros by their old names to use the current macro names. In
8522 version 2 of Autoconf, most of the macros were renamed to use a more
8523 uniform and descriptive naming scheme. *Note Macro Names::, for a
8524 description of the new scheme. Although the old names still work
8525 (*note Obsolete Macros::, for a list of the old macros and the
8526 corresponding new names), you can make your `configure.ac' files more
8527 readable and make it easier to use the current Autoconf documentation
8528 if you update them to use the new macro names.
8530 If given no arguments, `autoupdate' updates `configure.ac', backing
8531 up the original version with the suffix `~' (or the value of the
8532 environment variable `SIMPLE_BACKUP_SUFFIX', if that is set). If you
8533 give `autoupdate' an argument, it reads that file instead of
8534 `configure.ac' and writes the updated file to the standard output.
8536 `autoupdate' accepts the following options:
8540 Print a summary of the command line options and exit.
8544 Print the version number of Autoconf and exit.
8548 Report processing steps.
8552 Don't remove the temporary files.
8554 `--autoconf-dir=DIR'
8556 Override the location where the installed Autoconf data files are
8557 looked for. You can also set the `AC_MACRODIR' environment
8558 variable to a directory; this option overrides the environment
8561 This option is rarely needed and dangerous; it is only used when
8562 one plays with different versions of Autoconf simultaneously.
8566 Look for the package file `aclocal.m4' in directory DIR instead of
8567 in the current directory.
8570 File: autoconf.info, Node: Obsolete Macros, Next: Autoconf 1, Prev: autoupdate Invocation, Up: Obsolete Constructs
8575 Several macros are obsoleted in Autoconf, for various reasons
8576 (typically they failed to quote properly, couldn't be extended for more
8577 recent issues etc.). They are still supported, but deprecated: their
8578 use should be avoided.
8580 During the jump from Autoconf version 1 to version 2, most of the
8581 macros were renamed to use a more uniform and descriptive naming scheme,
8582 but their signature did not change. *Note Macro Names::, for a
8583 description of the new naming scheme. Below, there is just the mapping
8584 from old names to new names for these macros, the reader is invited to
8585 refer to the definition of the new macro for the signature and the
8591 - Macro: AC_ARG_ARRAY
8592 removed because of limited usefulness
8595 This macro is obsolete; it does nothing.
8597 - Macro: AC_CANONICAL_SYSTEM
8598 Determine the system type and set output variables to the names of
8599 the canonical system types. *Note Canonicalizing::, for details
8600 about the variables this macro sets.
8602 The user is encouraged to use either `AC_CANONICAL_BUILD', or
8603 `AC_CANONICAL_HOST', or `AC_CANONICAL_TARGET', depending on the
8604 needs. Using `AC_CANONICAL_TARGET' is enough to run the two other
8607 - Macro: AC_CHAR_UNSIGNED
8608 `AC_C_CHAR_UNSIGNED'
8610 - Macro: AC_CHECK_TYPE (TYPE, DEFAULT)
8611 Autoconf, up to 2.13, used to provide this version of
8612 `AC_CHECK_TYPE', deprecated because of its flaws. Firstly,
8613 although it is a member of the `CHECK' clan, singular sub-family,
8614 it does more than just checking. Second, missing types are not
8615 `typedef''d, they are `#define''d, which can lead to incompatible
8616 code in the case of pointer types.
8618 This use of `AC_CHECK_TYPE' is obsolete and discouraged, see *Note
8619 Generic Types::, for the description of the current macro.
8621 If the type TYPE is not defined, define it to be the C (or C++)
8622 builtin type DEFAULT; e.g., `short' or `unsigned'.
8624 This macro is equivalent to:
8626 AC_CHECK_TYPE([TYPE],
8627 [AC_DEFINE([TYPE], [DEFAULT],
8628 [Define to `DEFAULT' if <sys/types.h>
8629 does not define.])])
8631 In order to keep backward compatibility, the two versions of
8632 `AC_CHECK_TYPE' are implemented, selected by a simple heuristics:
8634 1. If there are three or four arguments, the modern version is
8637 2. If the second argument appears to be a C or C++ type, then the
8638 obsolete version is used. This happens if the argument is a
8639 C or C++ _builtin_ type or a C identifier ending in `_t',
8640 optionally followed by one of `[(* ' and then by a string of
8641 zero or more characters taken from the set `[]()* _a-zA-Z0-9'.
8643 3. If the second argument is spelled with the alphabet of valid
8644 C and C++ types, the user is warned and the modern version is
8647 4. Otherwise, the modern version is used.
8649 You are encouraged either to use a valid builtin type, or to use
8650 the equivalent modern code (see above), or better yet, to use
8651 `AC_CHECK_TYPES' together with
8654 typedef loff_t off_t;
8657 - Macro: AC_CHECKING (FEATURE-DESCRIPTION)
8658 Same as `AC_MSG_NOTICE([checking FEATURE-DESCRIPTION...]'.
8660 - Macro: AC_COMPILE_CHECK (ECHO-TEXT, INCLUDES, FUNCTION-BODY,
8661 ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND])
8662 This is an obsolete version of `AC_TRY_LINK' (*note Examining
8663 Libraries::), with the addition that it prints `checking for
8664 ECHO-TEXT' to the standard output first, if ECHO-TEXT is
8665 non-empty. Use `AC_MSG_CHECKING' and `AC_MSG_RESULT' instead to
8666 print messages (*note Printing Messages::).
8671 - Macro: AC_CROSS_CHECK
8672 Same as `AC_C_CROSS', which is obsolete too, and does nothing
8676 Check for the Cygwin environment in which case the shell variable
8677 `CYGWIN' is set to `yes'. Don't use this macro, the dignified
8678 means to check the nature of the host is using
8679 `AC_CANONICAL_HOST'. As a matter of fact this macro is defined as:
8681 AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
8683 *cygwin* ) CYGWIN=yes;;
8687 Beware that the variable `CYGWIN' has a very special meaning when
8688 running CygWin32, and should not be changed. That's yet another
8689 reason not to use this macro.
8691 - Macro: AC_DECL_YYTEXT
8692 Does nothing, now integrated in `AC_PROG_LEX'.
8694 - Macro: AC_DIR_HEADER
8695 Like calling `AC_FUNC_CLOSEDIR_VOID' and`AC_HEADER_DIRENT', but
8696 defines a different set of C preprocessor macros to indicate which
8697 header file is found:
8699 Header Old Symbol New Symbol
8700 `dirent.h' `DIRENT' `HAVE_DIRENT_H'
8701 `sys/ndir.h' `SYSNDIR' `HAVE_SYS_NDIR_H'
8702 `sys/dir.h' `SYSDIR' `HAVE_SYS_DIR_H'
8703 `ndir.h' `NDIR' `HAVE_NDIR_H'
8705 - Macro: AC_DYNIX_SEQ
8706 If on Dynix/PTX (Sequent UNIX), add `-lseq' to output variable
8707 `LIBS'. This macro used to be defined as
8709 AC_CHECK_LIB(seq, getmntent, LIBS="-lseq $LIBS")
8711 now it is just `AC_FUNC_GETMNTENT'.
8714 Defined the output variable `EXEEXT' based on the output of the
8715 compiler, which is now done automatically. Typically set to empty
8716 string if Unix and `.exe' if Win32 or OS/2.
8719 Similar to `AC_CYGWIN' but checks for the EMX environment on OS/2
8728 - Macro: AC_FIND_XTRA
8731 - Macro: AC_FUNC_CHECK
8734 - Macro: AC_FUNC_WAIT3
8735 If `wait3' is found and fills in the contents of its third argument
8736 (a `struct rusage *'), which HP-UX does not do, define
8739 These days portable programs should use `waitpid', not `wait3', as
8740 `wait3' is being removed from the Open Group standards, and will
8741 not appear in the next revision of POSIX.
8743 - Macro: AC_GCC_TRADITIONAL
8744 `AC_PROG_GCC_TRADITIONAL'
8746 - Macro: AC_GETGROUPS_T
8749 - Macro: AC_GETLOADAVG
8750 `AC_FUNC_GETLOADAVG'
8752 - Macro: AC_HAVE_FUNCS
8755 - Macro: AC_HAVE_HEADERS
8758 - Macro: AC_HAVE_LIBRARY (LIBRARY, [ACTION-IF-FOUND],
8759 [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
8760 This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION
8761 argument of `main'. In addition, LIBRARY can be written as any of
8762 `foo', `-lfoo', or `libfoo.a'. In all of those cases, the
8763 compiler is passed `-lfoo'. However, LIBRARY cannot be a shell
8764 variable; it must be a literal name.
8766 - Macro: AC_HAVE_POUNDBANG
8767 `AC_SYS_INTERPRETER' (different calling convention)
8769 - Macro: AC_HEADER_CHECK
8772 - Macro: AC_HEADER_EGREP
8775 - Macro: AC_INIT (UNIQUE-FILE-IN-SOURCE-DIR)
8776 Formerly `AC_INIT' used to have a single argument, and was
8780 AC_CONFIG_SRCDIR(UNIQUE-FILE-IN-SOURCE-DIR)
8785 - Macro: AC_INT_16_BITS
8786 If the C type `int' is 16 bits wide, define `INT_16_BITS'. Use
8787 `AC_CHECK_SIZEOF(int)' instead.
8789 - Macro: AC_IRIX_SUN
8790 If on IRIX (Silicon Graphics UNIX), add `-lsun' to output `LIBS'.
8791 If you were using it to get `getmntent', use `AC_FUNC_GETMNTENT'
8792 instead. If you used it for the NIS versions of the password and
8793 group functions, use `AC_CHECK_LIB(sun, getpwnam)'. Up to
8794 Autoconf 2.13, it used to be
8796 AC_CHECK_LIB(sun, getmntent, LIBS="-lsun $LIBS")
8798 now it is defined as
8801 AC_CHECK_LIB(sun, getpwnam)
8804 Same as `AC_LANG(C)'.
8806 - Macro: AC_LANG_CPLUSPLUS
8807 Same as `AC_LANG(C++)'.
8809 - Macro: AC_LANG_FORTRAN77
8810 Same as `AC_LANG(Fortran 77)'.
8812 - Macro: AC_LANG_RESTORE
8813 Select the LANGUAGE that is saved on the top of the stack, as set
8814 by `AC_LANG_SAVE', remove it from the stack, and call
8815 `AC_LANG(LANGUAGE)'.
8817 - Macro: AC_LANG_SAVE
8818 Remember the current language (as set by `AC_LANG') on a stack.
8819 The current language does not change. `AC_LANG_PUSH' is preferred.
8821 - Macro: AC_LINK_FILES (SOURCE..., DEST...)
8822 This is an obsolete version of `AC_CONFIG_LINKS'. An updated
8825 AC_LINK_FILES(config/$machine.h config/$obj_format.h,
8830 AC_CONFIG_LINKS(host.h:config/$machine.h
8831 object.h:config/$obj_format.h)
8836 - Macro: AC_LONG_64_BITS
8837 Define `LONG_64_BITS' if the C type `long int' is 64 bits wide.
8838 Use the generic macro `AC_CHECK_SIZEOF([long int])' instead.
8840 - Macro: AC_LONG_DOUBLE
8843 - Macro: AC_LONG_FILE_NAMES
8844 `AC_SYS_LONG_FILE_NAMES'
8846 - Macro: AC_MAJOR_HEADER
8849 - Macro: AC_MEMORY_H
8850 Used to define `NEED_MEMORY_H' if the `mem' functions were defined
8851 in `memory.h'. Today it is equivalent to
8852 `AC_CHECK_HEADERS(memory.h)'. Adjust your code to depend upon
8853 `HAVE_MEMORY_H', not `NEED_MEMORY_H', see *Note Standard Symbols::.
8856 Similar to `AC_CYGWIN' but checks for the MingW32 compiler
8857 environment and sets `MINGW32'.
8859 - Macro: AC_MINUS_C_MINUS_O
8869 Defined the output variable `OBJEXT' based on the output of the
8870 compiler, after .c files have been excluded. Typically set to `o'
8871 if Unix, `obj' if Win32. Now the compiler checking macros handle
8874 - Macro: AC_OBSOLETE (THIS-MACRO-NAME, [SUGGESTION])
8875 Make `m4' print a message to the standard error output warning that
8876 THIS-MACRO-NAME is obsolete, and giving the file and line number
8877 where it was called. THIS-MACRO-NAME should be the name of the
8878 macro that is calling `AC_OBSOLETE'. If SUGGESTION is given, it
8879 is printed at the end of the warning message; for example, it can
8880 be a suggestion for what to use instead of THIS-MACRO-NAME.
8884 AC_OBSOLETE([$0], [; use AC_CHECK_HEADERS(unistd.h) instead])dnl
8886 You are encouraged to use `AU_DEFUN' instead, since it gives better
8887 services to the user.
8892 - Macro: AC_OUTPUT ([FILE]..., [EXTRA-CMDS], [INIT-CMDS])
8893 The use of `AC_OUTPUT' with argument is deprecated, this obsoleted
8894 interface is equivalent to:
8896 AC_CONFIG_FILES(FILE...)
8897 AC_CONFIG_COMMANDS([default],
8898 EXTRA-CMDS, INIT-CMDS)
8901 - Macro: AC_OUTPUT_COMMANDS (EXTRA-CMDS, [INIT-CMDS])
8902 Specify additional shell commands to run at the end of
8903 `config.status', and shell commands to initialize any variables
8904 from `configure'. This macro may be called multiple times. It is
8905 obsolete, replaced by `AC_CONFIG_COMMANDS'.
8907 Here is an unrealistic example:
8910 AC_OUTPUT_COMMANDS([echo this is extra $fubar, and so on.],
8912 AC_OUTPUT_COMMANDS([echo this is another, extra, bit],
8915 Aside from the fact that `AC_CONFIG_COMMANDS' requires an
8916 additional key, an important difference is that
8917 `AC_OUTPUT_COMMANDS' is quoting its arguments twice, while
8918 `AC_CONFIG_COMMANDS'. This means that `AC_CONFIG_COMMANDS' can
8919 safely be given macro calls as arguments:
8921 AC_CONFIG_COMMANDS(foo, [my_FOO()])
8923 conversely, where one level of quoting was enough for literal
8924 strings with `AC_OUTPUT_COMMANDS', you need two with
8925 `AC_CONFIG_COMMANDS'. The following lines are equivalent:
8927 AC_OUTPUT_COMMANDS([echo "Square brackets: []"])
8928 AC_CONFIG_COMMANDS(default, [[echo "Square brackets: []"]])
8936 - Macro: AC_PROGRAMS_CHECK
8939 - Macro: AC_PROGRAMS_PATH
8942 - Macro: AC_PROGRAM_CHECK
8945 - Macro: AC_PROGRAM_EGREP
8948 - Macro: AC_PROGRAM_PATH
8951 - Macro: AC_REMOTE_TAPE
8952 removed because of limited usefulness
8954 - Macro: AC_RESTARTABLE_SYSCALLS
8955 `AC_SYS_RESTARTABLE_SYSCALLS'
8957 - Macro: AC_RETSIGTYPE
8961 Removed because of limited usefulness.
8963 - Macro: AC_SCO_INTL
8964 If on SCO UNIX, add `-lintl' to output variable `LIBS'. This
8967 AC_CHECK_LIB(intl, strftime, LIBS="-lintl $LIBS")
8969 now it just calls `AC_FUNC_STRFTIME' instead.
8971 - Macro: AC_SETVBUF_REVERSED
8972 `AC_FUNC_SETVBUF_REVERSED'
8974 - Macro: AC_SET_MAKE
8977 - Macro: AC_SIZEOF_TYPE
8983 - Macro: AC_STAT_MACROS_BROKEN
8986 - Macro: AC_STDC_HEADERS
8992 - Macro: AC_ST_BLKSIZE
8993 `AC_STRUCT_ST_BLKSIZE'
8995 - Macro: AC_ST_BLOCKS
8996 `AC_STRUCT_ST_BLOCKS'
9001 - Macro: AC_SYS_RESTARTABLE_SYSCALLS
9002 If the system automatically restarts a system call that is
9003 interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'. This
9004 macro does not check if system calls are restarted in general-it
9005 tests whether a signal handler installed with `signal' (but not
9006 `sigaction') causes system calls to be restarted. It does not test
9007 if system calls can be restarted when interrupted by signals that
9010 These days portable programs should use `sigaction' with
9011 `SA_RESTART' if they want restartable system calls. They should
9012 not rely on `HAVE_RESTARTABLE_SYSCALLS', since nowadays whether a
9013 system call is restartable is a dynamic issue, not a
9014 configuration-time issue.
9016 - Macro: AC_SYS_SIGLIST_DECLARED
9017 `AC_DECL_SYS_SIGLIST'
9019 - Macro: AC_TEST_CPP
9022 - Macro: AC_TEST_PROGRAM
9025 - Macro: AC_TIMEZONE
9026 `AC_STRUCT_TIMEZONE'
9028 - Macro: AC_TIME_WITH_SYS_TIME
9034 - Macro: AC_UNISTD_H
9035 Same as `AC_CHECK_HEADERS(unistd.h)'.
9038 Define `USG' if the BSD string functions are defined in
9039 `strings.h'. You should no longer depend upon `USG', but on
9040 `HAVE_STRING_H', see *Note Standard Symbols::.
9042 - Macro: AC_UTIME_NULL
9043 `AC_FUNC_UTIME_NULL'
9045 - Macro: AC_VALIDATE_CACHED_SYSTEM_TUPLE ([CMD])
9046 If the cache file is inconsistent with the current host, target and
9047 build system types, it used to execute CMD or print a default
9050 This is now handled by default.
9052 - Macro: AC_VERBOSE (RESULT-DESCRIPTION)
9067 - Macro: AC_WORDS_BIGENDIAN
9070 - Macro: AC_XENIX_DIR
9071 This macro used to add `-lx' to output variable `LIBS' if on
9072 Xenix. Also, if `dirent.h' is being checked for, added `-ldir' to
9073 `LIBS'. Now it is merely an alias of `AC_HEADER_DIRENT' instead,
9074 plus some code to detect whether running XENIX on which you should
9077 AC_MSG_CHECKING([for Xenix])
9079 [#if defined M_XENIX && !defined M_UNIX
9082 [AC_MSG_RESULT([yes]); XENIX=yes],
9083 [AC_MSG_RESULT([no]); XENIX=])
9085 - Macro: AC_YYTEXT_POINTER
9089 File: autoconf.info, Node: Autoconf 1, Next: Autoconf 2.13, Prev: Obsolete Macros, Up: Obsolete Constructs
9091 Upgrading From Version 1
9092 ========================
9094 Autoconf version 2 is mostly backward compatible with version 1.
9095 However, it introduces better ways to do some things, and doesn't
9096 support some of the ugly things in version 1. So, depending on how
9097 sophisticated your `configure.ac' files are, you might have to do some
9098 manual work in order to upgrade to version 2. This chapter points out
9099 some problems to watch for when upgrading. Also, perhaps your
9100 `configure' scripts could benefit from some of the new features in
9101 version 2; the changes are summarized in the file `NEWS' in the
9102 Autoconf distribution.
9106 * Changed File Names:: Files you might rename
9107 * Changed Makefiles:: New things to put in `Makefile.in'
9108 * Changed Macros:: Macro calls you might replace
9109 * Changed Results:: Changes in how to check test results
9110 * Changed Macro Writing:: Better ways to write your own macros
9113 File: autoconf.info, Node: Changed File Names, Next: Changed Makefiles, Prev: Autoconf 1, Up: Autoconf 1
9118 If you have an `aclocal.m4' installed with Autoconf (as opposed to
9119 in a particular package's source directory), you must rename it to
9120 `acsite.m4'. *Note autoconf Invocation::.
9122 If you distribute `install.sh' with your package, rename it to
9123 `install-sh' so `make' builtin rules won't inadvertently create a file
9124 called `install' from it. `AC_PROG_INSTALL' looks for the script under
9125 both names, but it is best to use the new name.
9127 If you were using `config.h.top', `config.h.bot', or `acconfig.h',
9128 you still can, but you will have less clutter if you use the `AH_'
9129 macros. *Note Autoheader Macros::.
9132 File: autoconf.info, Node: Changed Makefiles, Next: Changed Macros, Prev: Changed File Names, Up: Autoconf 1
9137 Add `@CFLAGS@', `@CPPFLAGS@', and `@LDFLAGS@' in your `Makefile.in'
9138 files, so they can take advantage of the values of those variables in
9139 the environment when `configure' is run. Doing this isn't necessary,
9140 but it's a convenience for users.
9142 Also add `@configure_input@' in a comment to each input file for
9143 `AC_OUTPUT', so that the output files will contain a comment saying
9144 they were produced by `configure'. Automatically selecting the right
9145 comment syntax for all the kinds of files that people call `AC_OUTPUT'
9146 on became too much work.
9148 Add `config.log' and `config.cache' to the list of files you remove
9149 in `distclean' targets.
9151 If you have the following in `Makefile.in':
9154 exec_prefix = $(prefix)
9156 you must change it to:
9159 exec_prefix = @exec_prefix@
9161 The old behavior of replacing those variables without `@' characters
9162 around them has been removed.
9165 File: autoconf.info, Node: Changed Macros, Next: Changed Results, Prev: Changed Makefiles, Up: Autoconf 1
9170 Many of the macros were renamed in Autoconf version 2. You can still
9171 use the old names, but the new ones are clearer, and it's easier to find
9172 the documentation for them. *Note Obsolete Macros::, for a table
9173 showing the new names for the old macros. Use the `autoupdate' program
9174 to convert your `configure.ac' to using the new macro names. *Note
9175 autoupdate Invocation::.
9177 Some macros have been superseded by similar ones that do the job
9178 better, but are not call-compatible. If you get warnings about calling
9179 obsolete macros while running `autoconf', you may safely ignore them,
9180 but your `configure' script will generally work better if you follow
9181 the advice it prints about what to replace the obsolete macros with. In
9182 particular, the mechanism for reporting the results of tests has
9183 changed. If you were using `echo' or `AC_VERBOSE' (perhaps via
9184 `AC_COMPILE_CHECK'), your `configure' script's output will look better
9185 if you switch to `AC_MSG_CHECKING' and `AC_MSG_RESULT'. *Note Printing
9186 Messages::. Those macros work best in conjunction with cache
9187 variables. *Note Caching Results::.
9190 File: autoconf.info, Node: Changed Results, Next: Changed Macro Writing, Prev: Changed Macros, Up: Autoconf 1
9195 If you were checking the results of previous tests by examining the
9196 shell variable `DEFS', you need to switch to checking the values of the
9197 cache variables for those tests. `DEFS' no longer exists while
9198 `configure' is running; it is only created when generating output
9199 files. This difference from version 1 is because properly quoting the
9200 contents of that variable turned out to be too cumbersome and
9201 inefficient to do every time `AC_DEFINE' is called. *Note Cache
9204 For example, here is a `configure.ac' fragment written for Autoconf
9207 AC_HAVE_FUNCS(syslog)
9210 *) # syslog is not in the default libraries. See if it's in some other.
9212 for lib in bsd socket inet; do
9213 AC_CHECKING(for syslog in -l$lib)
9214 LIBS="$saved_LIBS -l$lib"
9215 AC_HAVE_FUNCS(syslog)
9217 *-DHAVE_SYSLOG*) break ;;
9224 Here is a way to write it for version 2:
9226 AC_CHECK_FUNCS(syslog)
9227 if test $ac_cv_func_syslog = no; then
9228 # syslog is not in the default libraries. See if it's in some other.
9229 for lib in bsd socket inet; do
9230 AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG)
9231 LIBS="$LIBS -l$lib"; break])
9235 If you were working around bugs in `AC_DEFINE_UNQUOTED' by adding
9236 backslashes before quotes, you need to remove them. It now works
9237 predictably, and does not treat quotes (except back quotes) specially.
9238 *Note Setting Output Variables::.
9240 All of the boolean shell variables set by Autoconf macros now use
9241 `yes' for the true value. Most of them use `no' for false, though for
9242 backward compatibility some use the empty string instead. If you were
9243 relying on a shell variable being set to something like 1 or `t' for
9244 true, you need to change your tests.
9247 File: autoconf.info, Node: Changed Macro Writing, Prev: Changed Results, Up: Autoconf 1
9249 Changed Macro Writing
9250 ---------------------
9252 When defining your own macros, you should now use `AC_DEFUN' instead
9253 of `define'. `AC_DEFUN' automatically calls `AC_PROVIDE' and ensures
9254 that macros called via `AC_REQUIRE' do not interrupt other macros, to
9255 prevent nested `checking...' messages on the screen. There's no actual
9256 harm in continuing to use the older way, but it's less convenient and
9257 attractive. *Note Macro Definitions::.
9259 You probably looked at the macros that came with Autoconf as a guide
9260 for how to do things. It would be a good idea to take a look at the new
9261 versions of them, as the style is somewhat improved and they take
9262 advantage of some new features.
9264 If you were doing tricky things with undocumented Autoconf internals
9265 (macros, variables, diversions), check whether you need to change
9266 anything to account for changes that have been made. Perhaps you can
9267 even use an officially supported technique in version 2 instead of
9268 kludging. Or perhaps not.
9270 To speed up your locally written feature tests, add caching to them.
9271 See whether any of your tests are of general enough usefulness to
9272 encapsulate into macros that you can share.
9275 File: autoconf.info, Node: Autoconf 2.13, Prev: Autoconf 1, Up: Obsolete Constructs
9277 Upgrading From Version 2.13
9278 ===========================
9280 The introduction of the previous section (*note Autoconf 1::)
9281 perfectly suits this section...
9283 Autoconf version 2.50 is mostly backward compatible with version
9284 2.13. However, it introduces better ways to do some things, and
9285 doesn't support some of the ugly things in version 2.13. So,
9286 depending on how sophisticated your `configure.ac' files are, you
9287 might have to do some manual work in order to upgrade to version
9288 2.50. This chapter points out some problems to watch for when
9289 upgrading. Also, perhaps your `configure' scripts could benefit
9290 from some of the new features in version 2.50; the changes are
9291 summarized in the file `NEWS' in the Autoconf distribution.
9295 * Changed Quotation:: Broken code which used to work
9296 * New Macros:: Interaction with foreign macros
9299 File: autoconf.info, Node: Changed Quotation, Next: New Macros, Prev: Autoconf 2.13, Up: Autoconf 2.13
9304 The most important changes are invisible to you: the implementation
9305 of most macros have completely changed. This allowed more
9306 factorization of the code, better error messages, a higher uniformity
9307 of the user's interface etc. Unfortunately, as a side effect, some
9308 construct which used to (miraculously) work might break starting with
9309 Autoconf 2.50. The most common culprit is bad quotation.
9311 For instance, in the following example, the message is not properly
9315 AC_CHECK_HEADERS(foo.h,,
9316 AC_MSG_ERROR(cannot find foo.h, bailing out))
9319 Autoconf 2.13 simply ignores it:
9321 $ autoconf-2.13; ./configure --silent
9322 creating cache ./config.cache
9323 configure: error: cannot find foo.h
9326 while Autoconf 2.50 will produce a broken `configure':
9328 $ autoconf-2.50; ./configure --silent
9329 configure: error: cannot find foo.h
9330 ./configure: exit: bad non-numeric arg `bailing'
9331 ./configure: exit: bad non-numeric arg `bailing'
9334 The message needs to be quoted, and the `AC_MSG_ERROR' invocation
9338 AC_CHECK_HEADERS(foo.h,,
9339 [AC_MSG_ERROR([cannot find foo.h, bailing out])])
9342 Many many (and many more) Autoconf macros were lacking proper
9343 quotation, including no less than... `AC_DEFUN' itself!
9346 AC_DEFUN([AC_PROG_INSTALL],
9347 [# My own much better version
9353 autoconf: Undefined macros:
9354 ***BUG in Autoconf--please report*** AC_FD_MSG
9355 ***BUG in Autoconf--please report*** AC_EPI
9356 configure.in:1:AC_DEFUN([AC_PROG_INSTALL],
9357 configure.in:5:AC_PROG_INSTALL
9362 File: autoconf.info, Node: New Macros, Prev: Changed Quotation, Up: Autoconf 2.13
9367 Because Autoconf has been dormant for years, Automake provided
9368 Autoconf-like macros for a while. Autoconf 2.50 now provides better
9369 versions of these macros, integrated in the `AC_' namespace, instead of
9370 `AM_'. But in order to ease the upgrading via `autoupdate', bindings
9371 to such `AM_' macros are provided.
9373 Unfortunately Automake did not quote the name of these macros!
9374 Therefore, when `m4' find in `aclocal.m4' something like
9375 `AC_DEFUN(AM_TYPE_PTRDIFF_T, ...)', `AM_TYPE_PTRDIFF_T' is expanded,
9376 replaced with its Autoconf definition.
9378 Fortunately Autoconf catches pre-`AC_INIT' expansions, and will
9379 complain, in its own words:
9386 ./aclocal.m4:17: error: m4_defn: undefined macro: _m4_divert_diversion
9387 actypes.m4:289: AM_TYPE_PTRDIFF_T is expanded from...
9388 ./aclocal.m4:17: the top level
9391 Future versions of Automake will simply no longer define most of
9392 these macros, and will properly quote the names of the remaining macros.
9393 But you don't have to wait for it to happen to do the right thing right
9394 now: do not depend upon macros from Automake as it is simply not its job
9395 to provide macros (but the one it requires by itself):
9402 autoupdate: `configure.in' is updated
9405 AC_CHECK_TYPES([ptrdiff_t])
9411 File: autoconf.info, Node: Questions, Next: History, Prev: Obsolete Constructs, Up: Top
9413 Questions About Autoconf
9414 ************************
9416 Several questions about Autoconf come up occasionally. Here some of
9421 * Distributing:: Distributing `configure' scripts
9422 * Why GNU m4:: Why not use the standard M4?
9423 * Bootstrapping:: Autoconf and GNU M4 require each other?
9424 * Why Not Imake:: Why GNU uses `configure' instead of Imake
9427 File: autoconf.info, Node: Distributing, Next: Why GNU m4, Prev: Questions, Up: Questions
9429 Distributing `configure' Scripts
9430 ================================
9432 What are the restrictions on distributing `configure'
9433 scripts that Autoconf generates? How does that affect my
9434 programs that use them?
9436 There are no restrictions on how the configuration scripts that
9437 Autoconf produces may be distributed or used. In Autoconf version 1,
9438 they were covered by the GNU General Public License. We still encourage
9439 software authors to distribute their work under terms like those of the
9440 GPL, but doing so is not required to use Autoconf.
9442 Of the other files that might be used with `configure',
9443 `config.h.in' is under whatever copyright you use for your
9444 `configure.ac'. `config.sub' and `config.guess' have an exception to
9445 the GPL when they are used with an Autoconf-generated `configure'
9446 script, which permits you to distribute them under the same terms as
9447 the rest of your package. `install-sh' is from the X Consortium and is
9451 File: autoconf.info, Node: Why GNU m4, Next: Bootstrapping, Prev: Distributing, Up: Questions
9456 Why does Autoconf require GNU M4?
9458 Many M4 implementations have hard-coded limitations on the size and
9459 number of macros that Autoconf exceeds. They also lack several builtin
9460 macros that it would be difficult to get along without in a
9461 sophisticated application like Autoconf, including:
9469 Autoconf requires version 1.4 or above of GNU M4 because it uses
9472 Since only software maintainers need to use Autoconf, and since GNU
9473 M4 is simple to configure and install, it seems reasonable to require
9474 GNU M4 to be installed also. Many maintainers of GNU and other free
9475 software already have most of the GNU utilities installed, since they
9479 File: autoconf.info, Node: Bootstrapping, Next: Why Not Imake, Prev: Why GNU m4, Up: Questions
9481 How Can I Bootstrap?
9482 ====================
9484 If Autoconf requires GNU M4 and GNU M4 has an Autoconf
9485 `configure' script, how do I bootstrap? It seems like a chicken
9488 This is a misunderstanding. Although GNU M4 does come with a
9489 `configure' script produced by Autoconf, Autoconf is not required in
9490 order to run the script and install GNU M4. Autoconf is only required
9491 if you want to change the M4 `configure' script, which few people have
9492 to do (mainly its maintainer).
9495 File: autoconf.info, Node: Why Not Imake, Prev: Bootstrapping, Up: Questions
9500 Why not use Imake instead of `configure' scripts?
9502 Several people have written addressing this question, so I include
9503 adaptations of their explanations here.
9505 The following answer is based on one written by Richard Pixley:
9507 Autoconf generated scripts frequently work on machines that it has
9508 never been set up to handle before. That is, it does a good job of
9509 inferring a configuration for a new system. Imake cannot do this.
9511 Imake uses a common database of host specific data. For X11, this
9512 makes sense because the distribution is made as a collection of
9513 tools, by one central authority who has control over the database.
9515 GNU tools are not released this way. Each GNU tool has a
9516 maintainer; these maintainers are scattered across the world.
9517 Using a common database would be a maintenance nightmare.
9518 Autoconf may appear to be this kind of database, but in fact it is
9519 not. Instead of listing host dependencies, it lists program
9522 If you view the GNU suite as a collection of native tools, then the
9523 problems are similar. But the GNU development tools can be
9524 configured as cross tools in almost any host+target permutation.
9525 All of these configurations can be installed concurrently. They
9526 can even be configured to share host independent files across
9527 hosts. Imake doesn't address these issues.
9529 Imake templates are a form of standardization. The GNU coding
9530 standards address the same issues without necessarily imposing the
9533 Here is some further explanation, written by Per Bothner:
9535 One of the advantages of Imake is that it easy to generate large
9536 Makefiles using `cpp''s `#include' and macro mechanisms. However,
9537 `cpp' is not programmable: it has limited conditional facilities,
9538 and no looping. And `cpp' cannot inspect its environment.
9540 All of these problems are solved by using `sh' instead of `cpp'.
9541 The shell is fully programmable, has macro substitution, can
9542 execute (or source) other shell scripts, and can inspect its
9545 Paul Eggert elaborates more:
9547 With Autoconf, installers need not assume that Imake itself is
9548 already installed and working well. This may not seem like much
9549 of an advantage to people who are accustomed to Imake. But on
9550 many hosts Imake is not installed or the default installation is
9551 not working well, and requiring Imake to install a package hinders
9552 the acceptance of that package on those hosts. For example, the
9553 Imake template and configuration files might not be installed
9554 properly on a host, or the Imake build procedure might wrongly
9555 assume that all source files are in one big directory tree, or the
9556 Imake configuration might assume one compiler whereas the package
9557 or the installer needs to use another, or there might be a version
9558 mismatch between the Imake expected by the package and the Imake
9559 supported by the host. These problems are much rarer with
9560 Autoconf, where each package comes with its own independent
9561 configuration processor.
9563 Also, Imake often suffers from unexpected interactions between
9564 `make' and the installer's C preprocessor. The fundamental problem
9565 here is that the C preprocessor was designed to preprocess C
9566 programs, not `Makefile's. This is much less of a problem with
9567 Autoconf, which uses the general-purpose preprocessor `m4', and
9568 where the package's author (rather than the installer) does the
9569 preprocessing in a standard way.
9571 Finally, Mark Eichin notes:
9573 Imake isn't all that extensible, either. In order to add new
9574 features to Imake, you need to provide your own project template,
9575 and duplicate most of the features of the existing one. This
9576 means that for a sophisticated project, using the vendor-provided
9577 Imake templates fails to provide any leverage--since they don't
9578 cover anything that your own project needs (unless it is an X11
9581 On the other side, though:
9583 The one advantage that Imake has over `configure': `Imakefile's
9584 tend to be much shorter (likewise, less redundant) than
9585 `Makefile.in's. There is a fix to this, however--at least for the
9586 Kerberos V5 tree, we've modified things to call in common
9587 `post.in' and `pre.in' `Makefile' fragments for the entire tree.
9588 This means that a lot of common things don't have to be
9589 duplicated, even though they normally are in `configure' setups.
9592 File: autoconf.info, Node: History, Next: Environment Variable Index, Prev: Questions, Up: Top
9597 You may be wondering, Why was Autoconf originally written? How did
9598 it get into its present form? (Why does it look like gorilla spit?) If
9599 you're not wondering, then this chapter contains no information useful
9600 to you, and you might as well skip it. If you _are_ wondering, then
9601 let there be light...
9605 * Genesis:: Prehistory and naming of `configure'
9606 * Exodus:: The plagues of M4 and Perl
9607 * Leviticus:: The priestly code of portability arrives
9608 * Numbers:: Growth and contributors
9609 * Deuteronomy:: Approaching the promises of easy configuration
9612 File: autoconf.info, Node: Genesis, Next: Exodus, Prev: History, Up: History
9617 In June 1991 I was maintaining many of the GNU utilities for the
9618 Free Software Foundation. As they were ported to more platforms and
9619 more programs were added, the number of `-D' options that users had to
9620 select in the `Makefile' (around 20) became burdensome. Especially for
9621 me--I had to test each new release on a bunch of different systems. So
9622 I wrote a little shell script to guess some of the correct settings for
9623 the fileutils package, and released it as part of fileutils 2.0. That
9624 `configure' script worked well enough that the next month I adapted it
9625 (by hand) to create similar `configure' scripts for several other GNU
9626 utilities packages. Brian Berliner also adapted one of my scripts for
9627 his CVS revision control system.
9629 Later that summer, I learned that Richard Stallman and Richard Pixley
9630 were developing similar scripts to use in the GNU compiler tools; so I
9631 adapted my `configure' scripts to support their evolving interface:
9632 using the file name `Makefile.in' as the templates; adding `+srcdir',
9633 the first option (of many); and creating `config.status' files.
9636 File: autoconf.info, Node: Exodus, Next: Leviticus, Prev: Genesis, Up: History
9641 As I got feedback from users, I incorporated many improvements, using
9642 Emacs to search and replace, cut and paste, similar changes in each of
9643 the scripts. As I adapted more GNU utilities packages to use
9644 `configure' scripts, updating them all by hand became impractical.
9645 Rich Murphey, the maintainer of the GNU graphics utilities, sent me
9646 mail saying that the `configure' scripts were great, and asking if I
9647 had a tool for generating them that I could send him. No, I thought,
9648 but I should! So I started to work out how to generate them. And the
9649 journey from the slavery of hand-written `configure' scripts to the
9650 abundance and ease of Autoconf began.
9652 Cygnus `configure', which was being developed at around that time,
9653 is table driven; it is meant to deal mainly with a discrete number of
9654 system types with a small number of mainly unguessable features (such as
9655 details of the object file format). The automatic configuration system
9656 that Brian Fox had developed for Bash takes a similar approach. For
9657 general use, it seems to me a hopeless cause to try to maintain an
9658 up-to-date database of which features each variant of each operating
9659 system has. It's easier and more reliable to check for most features on
9660 the fly--especially on hybrid systems that people have hacked on
9661 locally or that have patches from vendors installed.
9663 I considered using an architecture similar to that of Cygnus
9664 `configure', where there is a single `configure' script that reads
9665 pieces of `configure.in' when run. But I didn't want to have to
9666 distribute all of the feature tests with every package, so I settled on
9667 having a different `configure' made from each `configure.in' by a
9668 preprocessor. That approach also offered more control and flexibility.
9670 I looked briefly into using the Metaconfig package, by Larry Wall,
9671 Harlan Stenn, and Raphael Manfredi, but I decided not to for several
9672 reasons. The `Configure' scripts it produces are interactive, which I
9673 find quite inconvenient; I didn't like the ways it checked for some
9674 features (such as library functions); I didn't know that it was still
9675 being maintained, and the `Configure' scripts I had seen didn't work on
9676 many modern systems (such as System V R4 and NeXT); it wasn't very
9677 flexible in what it could do in response to a feature's presence or
9678 absence; I found it confusing to learn; and it was too big and complex
9679 for my needs (I didn't realize then how much Autoconf would eventually
9682 I considered using Perl to generate my style of `configure' scripts,
9683 but decided that M4 was better suited to the job of simple textual
9684 substitutions: it gets in the way less, because output is implicit.
9685 Plus, everyone already has it. (Initially I didn't rely on the GNU
9686 extensions to M4.) Also, some of my friends at the University of
9687 Maryland had recently been putting M4 front ends on several programs,
9688 including `tvtwm', and I was interested in trying out a new language.
9691 File: autoconf.info, Node: Leviticus, Next: Numbers, Prev: Exodus, Up: History
9696 Since my `configure' scripts determine the system's capabilities
9697 automatically, with no interactive user intervention, I decided to call
9698 the program that generates them Autoconfig. But with a version number
9699 tacked on, that name would be too long for old UNIX file systems, so I
9700 shortened it to Autoconf.
9702 In the fall of 1991 I called together a group of fellow questers
9703 after the Holy Grail of portability (er, that is, alpha testers) to
9704 give me feedback as I encapsulated pieces of my handwritten scripts in
9705 M4 macros and continued to add features and improve the techniques used
9706 in the checks. Prominent among the testers were Franc,ois Pinard, who
9707 came up with the idea of making an `autoconf' shell script to run `m4'
9708 and check for unresolved macro calls; Richard Pixley, who suggested
9709 running the compiler instead of searching the file system to find
9710 include files and symbols, for more accurate results; Karl Berry, who
9711 got Autoconf to configure TeX and added the macro index to the
9712 documentation; and Ian Lance Taylor, who added support for creating a C
9713 header file as an alternative to putting `-D' options in a `Makefile',
9714 so he could use Autoconf for his UUCP package. The alpha testers
9715 cheerfully adjusted their files again and again as the names and
9716 calling conventions of the Autoconf macros changed from release to
9717 release. They all contributed many specific checks, great ideas, and
9721 File: autoconf.info, Node: Numbers, Next: Deuteronomy, Prev: Leviticus, Up: History
9726 In July 1992, after months of alpha testing, I released Autoconf 1.0,
9727 and converted many GNU packages to use it. I was surprised by how
9728 positive the reaction to it was. More people started using it than I
9729 could keep track of, including people working on software that wasn't
9730 part of the GNU Project (such as TCL, FSP, and Kerberos V5). Autoconf
9731 continued to improve rapidly, as many people using the `configure'
9732 scripts reported problems they encountered.
9734 Autoconf turned out to be a good torture test for M4 implementations.
9735 UNIX `m4' started to dump core because of the length of the macros that
9736 Autoconf defined, and several bugs showed up in GNU `m4' as well.
9737 Eventually, we realized that we needed to use some features that only
9738 GNU M4 has. 4.3BSD `m4', in particular, has an impoverished set of
9739 builtin macros; the System V version is better, but still doesn't
9740 provide everything we need.
9742 More development occurred as people put Autoconf under more stresses
9743 (and to uses I hadn't anticipated). Karl Berry added checks for X11.
9744 david zuhn contributed C++ support. Franc,ois Pinard made it diagnose
9745 invalid arguments. Jim Blandy bravely coerced it into configuring GNU
9746 Emacs, laying the groundwork for several later improvements. Roland
9747 McGrath got it to configure the GNU C Library, wrote the `autoheader'
9748 script to automate the creation of C header file templates, and added a
9749 `--verbose' option to `configure'. Noah Friedman added the
9750 `--autoconf-dir' option and `AC_MACRODIR' environment variable. (He
9751 also coined the term "autoconfiscate" to mean "adapt a software package
9752 to use Autoconf".) Roland and Noah improved the quoting protection in
9753 `AC_DEFINE' and fixed many bugs, especially when I got sick of dealing
9754 with portability problems from February through June, 1993.
9757 File: autoconf.info, Node: Deuteronomy, Prev: Numbers, Up: History
9762 A long wish list for major features had accumulated, and the effect
9763 of several years of patching by various people had left some residual
9764 cruft. In April 1994, while working for Cygnus Support, I began a major
9765 revision of Autoconf. I added most of the features of the Cygnus
9766 `configure' that Autoconf had lacked, largely by adapting the relevant
9767 parts of Cygnus `configure' with the help of david zuhn and Ken
9768 Raeburn. These features include support for using `config.sub',
9769 `config.guess', `--host', and `--target'; making links to files; and
9770 running `configure' scripts in subdirectories. Adding these features
9771 enabled Ken to convert GNU `as', and Rob Savoye to convert DejaGNU, to
9774 I added more features in response to other peoples' requests. Many
9775 people had asked for `configure' scripts to share the results of the
9776 checks between runs, because (particularly when configuring a large
9777 source tree, like Cygnus does) they were frustratingly slow. Mike
9778 Haertel suggested adding site-specific initialization scripts. People
9779 distributing software that had to unpack on MS-DOS asked for a way to
9780 override the `.in' extension on the file names, which produced file
9781 names like `config.h.in' containing two dots. Jim Avera did an
9782 extensive examination of the problems with quoting in `AC_DEFINE' and
9783 `AC_SUBST'; his insights led to significant improvements. Richard
9784 Stallman asked that compiler output be sent to `config.log' instead of
9785 `/dev/null', to help people debug the Emacs `configure' script.
9787 I made some other changes because of my dissatisfaction with the
9788 quality of the program. I made the messages showing results of the
9789 checks less ambiguous, always printing a result. I regularized the
9790 names of the macros and cleaned up coding style inconsistencies. I
9791 added some auxiliary utilities that I had developed to help convert
9792 source code packages to use Autoconf. With the help of Franc,ois
9793 Pinard, I made the macros not interrupt each others' messages. (That
9794 feature revealed some performance bottlenecks in GNU `m4', which he
9795 hastily corrected!) I reorganized the documentation around problems
9796 people want to solve. And I began a test suite, because experience had
9797 shown that Autoconf has a pronounced tendency to regress when we change
9800 Again, several alpha testers gave invaluable feedback, especially
9801 Franc,ois Pinard, Jim Meyering, Karl Berry, Rob Savoye, Ken Raeburn,
9804 Finally, version 2.0 was ready. And there was much rejoicing. (And
9805 I have free time again. I think. Yeah, right.)
9808 File: autoconf.info, Node: Environment Variable Index, Next: Output Variable Index, Prev: History, Up: Top
9810 Environment Variable Index
9811 **************************
9813 This is an alphabetical list of the environment variables that
9818 * AC_MACRODIR <1>: autoupdate Invocation.
9819 * AC_MACRODIR <2>: autoheader Invocation.
9820 * AC_MACRODIR <3>: autoreconf Invocation.
9821 * AC_MACRODIR <4>: autoconf Invocation.
9822 * AC_MACRODIR: autoscan Invocation.
9823 * CDPATH: Special Shell Variables.
9824 * CONFIG_COMMANDS: Obsolete config.status Use.
9825 * CONFIG_FILES: Obsolete config.status Use.
9826 * CONFIG_HEADERS: Obsolete config.status Use.
9827 * CONFIG_LINKS: Obsolete config.status Use.
9828 * CONFIG_SHELL: config.status Invocation.
9829 * CONFIG_SITE: Site Defaults.
9830 * CONFIG_STATUS: config.status Invocation.
9831 * IFS: Special Shell Variables.
9832 * LANG: Special Shell Variables.
9833 * LANGUAGE: Special Shell Variables.
9834 * LC_ALL: Special Shell Variables.
9835 * LC_COLLATE: Special Shell Variables.
9836 * LC_CTYPE: Special Shell Variables.
9837 * LC_MESSAGES: Special Shell Variables.
9838 * LC_NUMERIC: Special Shell Variables.
9839 * LC_TIME: Special Shell Variables.
9840 * NULLCMD: Special Shell Variables.
9841 * PATH_SEPARATOR: Special Shell Variables.
9842 * RANDOM: Special Shell Variables.
9843 * SIMPLE_BACKUP_SUFFIX: autoupdate Invocation.
9844 * status: Special Shell Variables.
9845 * WARNINGS <1>: autoheader Invocation.
9846 * WARNINGS: autoconf Invocation.
9849 File: autoconf.info, Node: Output Variable Index, Next: Preprocessor Symbol Index, Prev: Environment Variable Index, Up: Top
9851 Output Variable Index
9852 *********************
9854 This is an alphabetical list of the variables that Autoconf can
9855 substitute into files that it creates, typically one or more
9856 `Makefile's. *Note Setting Output Variables::, for more information on
9861 * ALLOCA: Particular Functions.
9862 * AWK: Particular Programs.
9863 * bindir: Installation Directory Variables.
9864 * build: Canonicalizing.
9865 * build_alias: Canonicalizing.
9866 * build_cpu: Canonicalizing.
9867 * build_os: Canonicalizing.
9868 * build_vendor: Canonicalizing.
9869 * CC <1>: UNIX Variants.
9870 * CC <2>: System Services.
9872 * CFLAGS <1>: C Compiler.
9873 * CFLAGS: Preset Output Variables.
9874 * configure_input: Preset Output Variables.
9876 * CPPFLAGS: Preset Output Variables.
9877 * cross_compiling: Specifying Names.
9878 * CXX: C++ Compiler.
9879 * CXXCPP: C++ Compiler.
9880 * CXXFLAGS <1>: C++ Compiler.
9881 * CXXFLAGS: Preset Output Variables.
9882 * datadir: Installation Directory Variables.
9883 * DEFS: Preset Output Variables.
9884 * ECHO_C: Preset Output Variables.
9885 * ECHO_N: Preset Output Variables.
9886 * ECHO_T: Preset Output Variables.
9887 * exec_prefix: Installation Directory Variables.
9888 * EXEEXT <1>: Obsolete Macros.
9889 * EXEEXT: Compilers and Preprocessors.
9890 * F77: Fortran 77 Compiler.
9891 * FFLAGS <1>: Fortran 77 Compiler.
9892 * FFLAGS: Preset Output Variables.
9893 * FLIBS: Fortran 77 Compiler.
9894 * GETGROUPS_LIBS: Particular Functions.
9895 * GETLOADAVG_LIBS: Particular Functions.
9896 * host: Canonicalizing.
9897 * host_alias: Canonicalizing.
9898 * host_cpu: Canonicalizing.
9899 * host_os: Canonicalizing.
9900 * host_vendor: Canonicalizing.
9901 * includedir: Installation Directory Variables.
9902 * infodir: Installation Directory Variables.
9903 * INSTALL: Particular Programs.
9904 * INSTALL_DATA: Particular Programs.
9905 * INSTALL_PROGRAM: Particular Programs.
9906 * INSTALL_SCRIPT: Particular Programs.
9907 * KMEM_GROUP: Particular Functions.
9908 * LDFLAGS: Preset Output Variables.
9909 * LEX: Particular Programs.
9910 * LEX_OUTPUT_ROOT: Particular Programs.
9911 * LEXLIB: Particular Programs.
9912 * libdir: Installation Directory Variables.
9913 * libexecdir: Installation Directory Variables.
9914 * LIBOBJS <1>: Particular Structures.
9915 * LIBOBJS <2>: Generic Functions.
9916 * LIBOBJS: Particular Functions.
9917 * LIBS <1>: Obsolete Macros.
9918 * LIBS: Preset Output Variables.
9919 * LN_S: Particular Programs.
9920 * localstatedir: Installation Directory Variables.
9921 * mandir: Installation Directory Variables.
9922 * NEED_SETGID: Particular Functions.
9923 * OBJEXT <1>: Obsolete Macros.
9924 * OBJEXT: Compilers and Preprocessors.
9925 * oldincludedir: Installation Directory Variables.
9926 * POW_LIB: Particular Functions.
9927 * prefix: Installation Directory Variables.
9928 * program_transform_name: Transforming Names.
9929 * RANLIB: Particular Programs.
9930 * sbindir: Installation Directory Variables.
9932 * sharedstatedir: Installation Directory Variables.
9933 * srcdir: Preset Output Variables.
9934 * subdirs: Subdirectories.
9935 * sysconfdir: Installation Directory Variables.
9936 * target: Canonicalizing.
9937 * target_alias: Canonicalizing.
9938 * target_cpu: Canonicalizing.
9939 * target_os: Canonicalizing.
9940 * target_vendor: Canonicalizing.
9941 * top_srcdir: Preset Output Variables.
9942 * X_CFLAGS: System Services.
9943 * X_EXTRA_LIBS: System Services.
9944 * X_LIBS: System Services.
9945 * X_PRE_LIBS: System Services.
9946 * YACC: Particular Programs.
9949 File: autoconf.info, Node: Preprocessor Symbol Index, Next: Autoconf Macro Index, Prev: Output Variable Index, Up: Top
9951 Preprocessor Symbol Index
9952 *************************
9954 This is an alphabetical list of the C preprocessor symbols that the
9955 Autoconf macros define. To work with Autoconf, C source code needs to
9956 use these names in `#if' directives.
9960 * __CHAR_UNSIGNED__: C Compiler.
9961 * _ALL_SOURCE: UNIX Variants.
9962 * _FILE_OFFSET_BITS: System Services.
9963 * _LARGE_FILES: System Services.
9964 * _LARGEFILE_SOURCE: Particular Functions.
9965 * _MINIX: UNIX Variants.
9966 * _POSIX_1_SOURCE: UNIX Variants.
9967 * _POSIX_SOURCE: UNIX Variants.
9968 * _POSIX_VERSION: Particular Headers.
9969 * C_ALLOCA: Particular Functions.
9970 * C_GETLOADAVG: Particular Functions.
9971 * CLOSEDIR_VOID: Particular Functions.
9972 * const: C Compiler.
9973 * DGUX: Particular Functions.
9974 * DIRENT: Obsolete Macros.
9975 * F77_DUMMY_MAIN: Fortran 77 Compiler.
9976 * F77_FUNC: Fortran 77 Compiler.
9977 * F77_FUNC_: Fortran 77 Compiler.
9978 * F77_MAIN: Fortran 77 Compiler.
9979 * F77_NO_MINUS_C_MINUS_O: Fortran 77 Compiler.
9980 * GETGROUPS_T: Particular Types.
9981 * GETLODAVG_PRIVILEGED: Particular Functions.
9982 * GETPGRP_VOID: Particular Functions.
9983 * gid_t: Particular Types.
9984 * GWINSZ_IN_SYS_IOCTL: Particular Headers.
9985 * HAVE_ALLOCA_H: Particular Functions.
9986 * HAVE_CONFIG_H: Configuration Headers.
9987 * HAVE_DECL_SYMBOL: Generic Declarations.
9988 * HAVE_DIRENT_H: Particular Headers.
9989 * HAVE_DOPRNT: Particular Functions.
9990 * HAVE_FUNCTION: Generic Functions.
9991 * HAVE_GETMNTENT: Particular Functions.
9992 * HAVE_HEADER: Generic Headers.
9993 * HAVE_LONG_DOUBLE: C Compiler.
9994 * HAVE_LONG_FILE_NAMES: System Services.
9995 * HAVE_LSTAT_EMPTY_STRING_BUG: Particular Functions.
9996 * HAVE_MMAP: Particular Functions.
9997 * HAVE_NDIR_H: Particular Headers.
9998 * HAVE_OBSTACK: Particular Functions.
9999 * HAVE_RESTARTABLE_SYSCALLS: Obsolete Macros.
10000 * HAVE_ST_BLKSIZE: Particular Structures.
10001 * HAVE_ST_BLOCKS: Particular Structures.
10002 * HAVE_ST_RDEV: Particular Structures.
10003 * HAVE_STAT_EMPTY_STRING_BUG: Particular Functions.
10004 * HAVE_STRCOLL: Particular Functions.
10005 * HAVE_STRERROR_R: Particular Functions.
10006 * HAVE_STRFTIME: Particular Functions.
10007 * HAVE_STRINGIZE: C Compiler.
10008 * HAVE_STRUCT_STAT_ST_BLKSIZE: Particular Structures.
10009 * HAVE_STRUCT_STAT_ST_BLOCKS: Particular Structures.
10010 * HAVE_STRUCT_STAT_ST_RDEV: Particular Structures.
10011 * HAVE_SYS_DIR_H: Particular Headers.
10012 * HAVE_SYS_NDIR_H: Particular Headers.
10013 * HAVE_SYS_WAIT_H: Particular Headers.
10014 * HAVE_TM_ZONE: Particular Structures.
10015 * HAVE_TZNAME: Particular Structures.
10016 * HAVE_UTIME_NULL: Particular Functions.
10017 * HAVE_VFORK_H: Particular Functions.
10018 * HAVE_VPRINTF: Particular Functions.
10019 * HAVE_WAIT3: Obsolete Macros.
10020 * HAVE_WORKING_FORK: Particular Functions.
10021 * HAVE_WORKING_STRERROR_R: Particular Functions.
10022 * HAVE_WORKING_VFORK: Particular Functions.
10023 * inline: C Compiler.
10024 * INT_16_BITS: Obsolete Macros.
10025 * LONG_64_BITS: Obsolete Macros.
10026 * LSTAT_FOLLOWS_SLASHED_SYMLINK: Particular Functions.
10027 * MAJOR_IN_MKDEV: Particular Headers.
10028 * MAJOR_IN_SYSMACROS: Particular Headers.
10029 * mode_t: Particular Types.
10030 * NDIR: Obsolete Macros.
10031 * NEED_MEMORY_H: Obsolete Macros.
10032 * NEED_SETGID: Particular Functions.
10033 * NLIST_NAME_UNION: Particular Functions.
10034 * NLIST_STRUCT: Particular Functions.
10035 * NO_MINUS_C_MINUS_O: C Compiler.
10036 * off_t: Particular Types.
10037 * PARAMS: C Compiler.
10038 * pid_t: Particular Types.
10039 * PROTOTYPES: C Compiler.
10040 * RETSIGTYPE: Particular Types.
10041 * SELECT_TYPE_ARG1: Particular Functions.
10042 * SELECT_TYPE_ARG234: Particular Functions.
10043 * SELECT_TYPE_ARG5: Particular Functions.
10044 * SETPGRP_VOID: Particular Functions.
10045 * SETVBUF_REVERSED: Particular Functions.
10046 * size_t: Particular Types.
10047 * STDC_HEADERS: Particular Headers.
10048 * SVR4: Particular Functions.
10049 * SYS_SIGLIST_DECLARED: Particular Declarations.
10050 * SYSDIR: Obsolete Macros.
10051 * SYSNDIR: Obsolete Macros.
10052 * TIME_WITH_SYS_TIME: Particular Headers.
10053 * TM_IN_SYS_TIME: Particular Structures.
10054 * uid_t: Particular Types.
10055 * UMAX: Particular Functions.
10056 * UMAX4_3: Particular Functions.
10057 * USG: Obsolete Macros.
10058 * vfork: Particular Functions.
10059 * volatile: C Compiler.
10060 * WORDS_BIGENDIAN: C Compiler.
10061 * X_DISPLAY_MISSING: System Services.
10062 * YYTEXT_POINTER: Particular Programs.
10065 File: autoconf.info, Node: Autoconf Macro Index, Next: M4 Macro Index, Prev: Preprocessor Symbol Index, Up: Top
10067 Autoconf Macro Index
10068 ********************
10070 This is an alphabetical list of the Autoconf macros. To make the
10071 list easier to use, the macros are listed without their preceding `AC_'.
10075 * AH_BOTTOM: Autoheader Macros.
10076 * AH_TEMPLATE: Autoheader Macros.
10077 * AH_TOP: Autoheader Macros.
10078 * AH_VERBATIM: Autoheader Macros.
10079 * AIX: UNIX Variants.
10080 * ALLOCA: Obsolete Macros.
10081 * ARG_ARRAY: Obsolete Macros.
10082 * ARG_ENABLE: Package Options.
10083 * ARG_PROGRAM: Transforming Names.
10084 * ARG_VAR: Setting Output Variables.
10085 * ARG_WITH: External Software.
10086 * AU_DEFUN: Obsoleting Macros.
10087 * BEFORE: Suggested Ordering.
10088 * BOTTOM: Autoheader Macros.
10089 * C_BIGENDIAN: C Compiler.
10090 * C_CHAR_UNSIGNED: C Compiler.
10091 * C_CONST: C Compiler.
10092 * C_CROSS: Obsolete Macros.
10093 * C_INLINE: C Compiler.
10094 * C_LONG_DOUBLE: C Compiler.
10095 * C_PROTOTYPES: C Compiler.
10096 * C_STRINGIZE: C Compiler.
10097 * C_VOLATILE: C Compiler.
10098 * CACHE_CHECK: Caching Results.
10099 * CACHE_LOAD: Cache Checkpointing.
10100 * CACHE_SAVE: Cache Checkpointing.
10101 * CACHE_VAL: Caching Results.
10102 * CANONICAL_BUILD: Canonicalizing.
10103 * CANONICAL_HOST: Canonicalizing.
10104 * CANONICAL_SYSTEM: Obsolete Macros.
10105 * CANONICAL_TARGET: Canonicalizing.
10106 * CHAR_UNSIGNED: Obsolete Macros.
10107 * CHECK_DECL: Generic Declarations.
10108 * CHECK_DECLS: Generic Declarations.
10109 * CHECK_FILE: Files.
10110 * CHECK_FILES: Files.
10111 * CHECK_FUNC: Generic Functions.
10112 * CHECK_FUNCS: Generic Functions.
10113 * CHECK_HEADER: Generic Headers.
10114 * CHECK_HEADERS: Generic Headers.
10115 * CHECK_LIB: Libraries.
10116 * CHECK_MEMBER: Generic Structures.
10117 * CHECK_MEMBERS: Generic Structures.
10118 * CHECK_PROG: Generic Programs.
10119 * CHECK_PROGS: Generic Programs.
10120 * CHECK_SIZEOF: Generic Compiler Characteristics.
10121 * CHECK_TOOL: Generic Programs.
10122 * CHECK_TOOLS: Generic Programs.
10123 * CHECK_TYPE <1>: Obsolete Macros.
10124 * CHECK_TYPE: Generic Types.
10125 * CHECK_TYPES: Generic Types.
10126 * CHECKING: Obsolete Macros.
10127 * COMPILE_CHECK: Obsolete Macros.
10128 * CONFIG_AUX_DIR: Input.
10129 * CONFIG_COMMANDS: Configuration Commands.
10130 * CONFIG_FILES: Configuration Files.
10131 * CONFIG_HEADERS: Configuration Headers.
10132 * CONFIG_LINKS: Configuration Links.
10133 * CONFIG_SRCDIR: Input.
10134 * CONFIG_SUBDIRS: Subdirectories.
10135 * CONST: Obsolete Macros.
10136 * COPYRIGHT: Notices.
10137 * CROSS_CHECK: Obsolete Macros.
10138 * CYGWIN: Obsolete Macros.
10139 * DECL_SYS_SIGLIST: Particular Declarations.
10140 * DECL_YYTEXT: Obsolete Macros.
10141 * DEFINE: Defining Symbols.
10142 * DEFINE_UNQUOTED: Defining Symbols.
10143 * DEFUN <1>: Obsoleting Macros.
10144 * DEFUN: Macro Definitions.
10145 * DIAGNOSE: Reporting Messages.
10146 * DIR_HEADER: Obsolete Macros.
10147 * DYNIX_SEQ: Obsolete Macros.
10148 * EGREP_CPP: Examining Declarations.
10149 * EGREP_HEADER: Examining Declarations.
10150 * EMXOS2: Obsolete Macros.
10151 * ENABLE: Package Options.
10152 * ERROR: Obsolete Macros.
10153 * EXEEXT: Obsolete Macros.
10154 * F77_DUMMY_MAIN: Fortran 77 Compiler.
10155 * F77_FUNC: Fortran 77 Compiler.
10156 * F77_LIBRARY_LDFLAGS: Fortran 77 Compiler.
10157 * F77_MAIN: Fortran 77 Compiler.
10158 * F77_WRAPPERS: Fortran 77 Compiler.
10159 * FATAL: Reporting Messages.
10160 * FIND_X: Obsolete Macros.
10161 * FIND_XTRA: Obsolete Macros.
10162 * FUNC_ALLOCA: Particular Functions.
10163 * FUNC_CHECK: Obsolete Macros.
10164 * FUNC_CHOWN: Particular Functions.
10165 * FUNC_CLOSEDIR_VOID: Particular Functions.
10166 * FUNC_ERROR_AT_LINE: Particular Functions.
10167 * FUNC_FNMATCH: Particular Functions.
10168 * FUNC_FORK: Particular Functions.
10169 * FUNC_FSEEKO: Particular Functions.
10170 * FUNC_GETGROUPS: Particular Functions.
10171 * FUNC_GETLOADAVG: Particular Functions.
10172 * FUNC_GETMNTENT: Particular Functions.
10173 * FUNC_GETPGRP: Particular Functions.
10174 * FUNC_LSTAT: Particular Functions.
10175 * FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK: Particular Functions.
10176 * FUNC_MALLOC: Particular Functions.
10177 * FUNC_MEMCMP: Particular Functions.
10178 * FUNC_MKTIME: Particular Functions.
10179 * FUNC_MMAP: Particular Functions.
10180 * FUNC_OBSTACK: Particular Functions.
10181 * FUNC_SELECT_ARGTYPES: Particular Functions.
10182 * FUNC_SETPGRP: Particular Functions.
10183 * FUNC_SETVBUF_REVERSED: Particular Functions.
10184 * FUNC_STAT: Particular Functions.
10185 * FUNC_STRCOLL: Particular Functions.
10186 * FUNC_STRERROR_R: Particular Functions.
10187 * FUNC_STRFTIME: Particular Functions.
10188 * FUNC_STRTOD: Particular Functions.
10189 * FUNC_UTIME_NULL: Particular Functions.
10190 * FUNC_VPRINTF: Particular Functions.
10191 * FUNC_WAIT3: Obsolete Macros.
10192 * GCC_TRADITIONAL: Obsolete Macros.
10193 * GETGROUPS_T: Obsolete Macros.
10194 * GETLOADAVG: Obsolete Macros.
10195 * HAVE_FUNCS: Obsolete Macros.
10196 * HAVE_HEADERS: Obsolete Macros.
10197 * HAVE_LIBRARY: Obsolete Macros.
10198 * HAVE_POUNDBANG: Obsolete Macros.
10199 * HEADER_CHECK: Obsolete Macros.
10200 * HEADER_DIRENT: Particular Headers.
10201 * HEADER_EGREP: Obsolete Macros.
10202 * HEADER_MAJOR: Particular Headers.
10203 * HEADER_STAT: Particular Headers.
10204 * HEADER_STDC: Particular Headers.
10205 * HEADER_SYS_WAIT: Particular Headers.
10206 * HEADER_TIME: Particular Headers.
10207 * HEADER_TIOCGWINSZ: Particular Headers.
10208 * HELP_STRING: Pretty Help Strings.
10209 * INIT <1>: Obsolete Macros.
10211 * INLINE: Obsolete Macros.
10212 * INT_16_BITS: Obsolete Macros.
10213 * IRIX_SUN: Obsolete Macros.
10214 * ISC_POSIX: UNIX Variants.
10215 * LANG_C: Obsolete Macros.
10216 * LANG_CPLUSPLUS: Obsolete Macros.
10217 * LANG_FORTRAN77: Obsolete Macros.
10218 * LANG_POP: Language Choice.
10219 * LANG_PUSH: Language Choice.
10220 * LANG_RESTORE: Obsolete Macros.
10221 * LANG_SAVE: Obsolete Macros.
10222 * LIBOBJ: Generic Functions.
10223 * LIBSOURCE: Generic Functions.
10224 * LIBSOURCES: Generic Functions.
10225 * LINK_FILES: Obsolete Macros.
10226 * LN_S: Obsolete Macros.
10227 * LONG_64_BITS: Obsolete Macros.
10228 * LONG_DOUBLE: Obsolete Macros.
10229 * LONG_FILE_NAMES: Obsolete Macros.
10230 * MAJOR_HEADER: Obsolete Macros.
10231 * MEMORY_H: Obsolete Macros.
10232 * MINGW32: Obsolete Macros.
10233 * MINIX: UNIX Variants.
10234 * MINUS_C_MINUS_O: Obsolete Macros.
10235 * MMAP: Obsolete Macros.
10236 * MODE_T: Obsolete Macros.
10237 * MSG_CHECKING: Printing Messages.
10238 * MSG_ERROR: Printing Messages.
10239 * MSG_NOTICE: Printing Messages.
10240 * MSG_RESULT: Printing Messages.
10241 * MSG_WARN: Printing Messages.
10242 * OBJEXT: Obsolete Macros.
10243 * OBSOLETE: Obsolete Macros.
10244 * OFF_T: Obsolete Macros.
10245 * OUTPUT <1>: Obsolete Macros.
10247 * OUTPUT_COMMANDS: Obsolete Macros.
10248 * OUTPUT_COMMANDS_POST: Configuration Commands.
10249 * OUTPUT_COMMANDS_PRE: Configuration Commands.
10250 * PATH_PROG: Generic Programs.
10251 * PATH_PROGS: Generic Programs.
10252 * PATH_TOOL: Generic Programs.
10253 * PATH_X: System Services.
10254 * PATH_XTRA: System Services.
10255 * PID_T: Obsolete Macros.
10256 * PREFIX: Obsolete Macros.
10257 * PREFIX_DEFAULT: Default Prefix.
10258 * PREFIX_PROGRAM: Default Prefix.
10260 * PROG_AWK: Particular Programs.
10261 * PROG_CC: C Compiler.
10262 * PROG_CC_C_O: C Compiler.
10263 * PROG_CC_STDC: C Compiler.
10264 * PROG_CPP: C Compiler.
10265 * PROG_CXX: C++ Compiler.
10266 * PROG_CXXCPP: C++ Compiler.
10267 * PROG_F77_C_O: Fortran 77 Compiler.
10268 * PROG_FORTRAN: Fortran 77 Compiler.
10269 * PROG_GCC_TRADITIONAL: C Compiler.
10270 * PROG_INSTALL: Particular Programs.
10271 * PROG_LEX: Particular Programs.
10272 * PROG_LN_S: Particular Programs.
10273 * PROG_MAKE_SET: Output.
10274 * PROG_RANLIB: Particular Programs.
10275 * PROG_YACC: Particular Programs.
10276 * PROGRAM_CHECK: Obsolete Macros.
10277 * PROGRAM_EGREP: Obsolete Macros.
10278 * PROGRAM_PATH: Obsolete Macros.
10279 * PROGRAMS_CHECK: Obsolete Macros.
10280 * PROGRAMS_PATH: Obsolete Macros.
10281 * REMOTE_TAPE: Obsolete Macros.
10282 * REPLACE_FUNCS: Generic Functions.
10283 * REQUIRE: Prerequisite Macros.
10284 * REQUIRE_CPP: Language Choice.
10285 * RESTARTABLE_SYSCALLS: Obsolete Macros.
10286 * RETSIGTYPE: Obsolete Macros.
10287 * REVISION: Notices.
10288 * RSH: Obsolete Macros.
10289 * SCO_INTL: Obsolete Macros.
10290 * SEARCH_LIBS: Libraries.
10291 * SET_MAKE: Obsolete Macros.
10292 * SETVBUF_REVERSED: Obsolete Macros.
10293 * SIZE_T: Obsolete Macros.
10294 * SIZEOF_TYPE: Obsolete Macros.
10295 * ST_BLKSIZE: Obsolete Macros.
10296 * ST_BLOCKS: Obsolete Macros.
10297 * ST_RDEV: Obsolete Macros.
10298 * STAT_MACROS_BROKEN <1>: Obsolete Macros.
10299 * STAT_MACROS_BROKEN: Particular Headers.
10300 * STDC_HEADERS: Obsolete Macros.
10301 * STRCOLL: Obsolete Macros.
10302 * STRUCT_ST_BLKSIZE: Particular Structures.
10303 * STRUCT_ST_BLOCKS: Particular Structures.
10304 * STRUCT_ST_RDEV: Particular Structures.
10305 * STRUCT_TIMEZONE: Particular Structures.
10306 * STRUCT_TM: Particular Structures.
10307 * SUBST: Setting Output Variables.
10308 * SUBST_FILE: Setting Output Variables.
10309 * SYS_INTERPRETER: System Services.
10310 * SYS_LARGEFILE: System Services.
10311 * SYS_LONG_FILE_NAMES: System Services.
10312 * SYS_POSIX_TERMIOS: System Services.
10313 * SYS_RESTARTABLE_SYSCALLS: Obsolete Macros.
10314 * SYS_SIGLIST_DECLARED: Obsolete Macros.
10315 * TEMPLATE: Autoheader Macros.
10316 * TEST_CPP: Obsolete Macros.
10317 * TEST_PROGRAM: Obsolete Macros.
10318 * TIME_WITH_SYS_TIME: Obsolete Macros.
10319 * TIMEZONE: Obsolete Macros.
10320 * TOP: Autoheader Macros.
10321 * TRY_COMPILE: Examining Syntax.
10322 * TRY_CPP: Examining Declarations.
10323 * TRY_LINK: Examining Libraries.
10324 * TRY_LINK_FUNC: Examining Libraries.
10325 * TRY_RUN: Test Programs.
10326 * TYPE_GETGROUPS: Particular Types.
10327 * TYPE_MODE_T: Particular Types.
10328 * TYPE_OFF_T: Particular Types.
10329 * TYPE_PID_T: Particular Types.
10330 * TYPE_SIGNAL: Particular Types.
10331 * TYPE_SIZE_T: Particular Types.
10332 * TYPE_UID_T: Particular Types.
10333 * UID_T: Obsolete Macros.
10334 * UNISTD_H: Obsolete Macros.
10335 * USG: Obsolete Macros.
10336 * UTIME_NULL: Obsolete Macros.
10337 * VALIDATE_CACHED_SYSTEM_TUPLE: Obsolete Macros.
10338 * VERBATIM: Autoheader Macros.
10339 * VERBOSE: Obsolete Macros.
10340 * VFORK: Obsolete Macros.
10341 * VPRINTF: Obsolete Macros.
10342 * WAIT3: Obsolete Macros.
10343 * WARN: Obsolete Macros.
10344 * WARNING: Reporting Messages.
10345 * WITH: External Software.
10346 * WORDS_BIGENDIAN: Obsolete Macros.
10347 * XENIX_DIR: Obsolete Macros.
10348 * YYTEXT_POINTER: Obsolete Macros.
10351 File: autoconf.info, Node: M4 Macro Index, Next: Concept Index, Prev: Autoconf Macro Index, Up: Top
10356 This is an alphabetical list of the M4, M4sugar, and M4sh macros. To
10357 make the list easier to use, the macros are listed without their
10358 preceding `m4_' or `AS_'.
10362 * defn: Redefined M4 Macros.
10363 * pattern_allow: Forbidden Patterns.
10364 * pattern_forbid: Forbidden Patterns.
10365 * undefine: Redefined M4 Macros.
10368 File: autoconf.info, Node: Concept Index, Prev: M4 Macro Index, Up: Top
10373 This is an alphabetical list of the files, tools, and concepts
10374 introduced in this document.
10378 * !: Limitations of Builtins.
10379 * "$@": Shell Substitutions.
10380 * $(COMMANDS): Shell Substitutions.
10381 * ${VAR:-VALUE}: Shell Substitutions.
10382 * ${VAR=EXPANDED-VALUE}: Shell Substitutions.
10383 * ${VAR=LITERAL}: Shell Substitutions.
10384 * /usr/xpg4/bin/sh on Solaris: Shellology.
10385 * :: Limitations of Builtins.
10386 * @%:@: Quadrigraphs.
10387 * @:>@: Quadrigraphs.
10388 * @<:@: Quadrigraphs.
10389 * @S|@: Quadrigraphs.
10390 * `COMMANDS`: Shell Substitutions.
10391 * acconfig.h: acconfig.h.
10392 * aclocal.m4: Making configure Scripts.
10394 * autoconf: autoconf Invocation.
10395 * autoheader: autoheader Invocation.
10396 * Automake: Automake.
10397 * autoreconf: autoreconf Invocation.
10398 * autoscan: autoscan Invocation.
10399 * autoupdate: autoupdate Invocation.
10400 * awk: Limitations of Usual Tools.
10401 * Back trace: autoconf Invocation.
10402 * Bash: Shellology.
10403 * break: Limitations of Builtins.
10404 * Cache: Caching Results.
10405 * Cache variable: Cache Variable Names.
10406 * Cache, enabling: configure Invocation.
10407 * case: Limitations of Builtins.
10408 * cat: Limitations of Usual Tools.
10409 * cmp: Limitations of Usual Tools.
10410 * Command Substitution: Shell Substitutions.
10411 * config.h: Configuration Headers.
10412 * config.h.bot: acconfig.h.
10413 * config.h.in: Header Templates.
10414 * config.h.top: acconfig.h.
10415 * config.status: config.status Invocation.
10416 * Configuration Header: Configuration Headers.
10417 * Configuration Header Template: Header Templates.
10418 * configure <1>: Running configure scripts.
10419 * configure: Making configure Scripts.
10420 * configure.ac: Making configure Scripts.
10421 * configure.in: Making configure Scripts.
10422 * Copyright Notice: Notices.
10423 * cp: Limitations of Usual Tools.
10424 * Declaration, checking: Declarations.
10425 * diff: Limitations of Usual Tools.
10426 * dirname: Limitations of Usual Tools.
10427 * dnl <1>: Coding Style.
10428 * dnl: Macro Definitions.
10429 * echo: Limitations of Builtins.
10430 * egrep: Limitations of Usual Tools.
10431 * Endianness: C Compiler.
10432 * exit: Limitations of Builtins.
10433 * export: Limitations of Builtins.
10434 * expr: Limitations of Usual Tools.
10435 * expr (|): Limitations of Usual Tools.
10436 * false: Limitations of Builtins.
10437 * File, checking: Files.
10438 * for: Limitations of Builtins.
10439 * Function, checking: Particular Functions.
10440 * grep: Limitations of Usual Tools.
10441 * Header, checking: Header Files.
10442 * if: Limitations of Builtins.
10443 * ifnames: ifnames Invocation.
10444 * Includes, default: Default Includes.
10445 * Instantiation: Output.
10446 * Language: Language Choice.
10447 * Library, checking: Libraries.
10448 * Libtool: Libtool.
10449 * Links: Configuration Links.
10450 * ln: Limitations of Usual Tools.
10451 * M4sugar: Programming in M4sugar.
10452 * Macro invocation stack: autoconf Invocation.
10453 * Messages, from autoconf: Reporting Messages.
10454 * Messages, from configure: Printing Messages.
10455 * mv: Limitations of Usual Tools.
10456 * obstack: Particular Functions.
10457 * POSIX termios headers: System Services.
10458 * Previous Variable: Setting Output Variables.
10459 * Programs, checking: Alternative Programs.
10460 * QNX 4.25: Systemology.
10461 * quadrigraphs: Quadrigraphs.
10462 * quotation <1>: M4 Quotation.
10463 * quotation: Autoconf Language.
10464 * Revision: Notices.
10465 * sed: Limitations of Usual Tools.
10466 * sed (t): Limitations of Usual Tools.
10467 * set: Limitations of Builtins.
10468 * shift: Limitations of Builtins.
10469 * Structure, checking: Structures.
10470 * Symbolic links: Limitations of Usual Tools.
10471 * termios POSIX headers: System Services.
10472 * test: Limitations of Builtins.
10473 * touch: Limitations of Usual Tools.
10474 * trap: Limitations of Builtins.
10475 * true: Limitations of Builtins.
10476 * undefined macro: _m4_divert_diversion: New Macros.
10477 * unset: Limitations of Builtins.
10478 * Variable, Precious: Setting Output Variables.
10479 * Version: Notices.
10480 * VPATH: Limitations of Make.
10487 Node: Introduction
\x7f14208
10488 Ref: Introduction-Footnote-1
\x7f19049
10489 Ref: Introduction-Footnote-2
\x7f19130
10490 Ref: Introduction-Footnote-3
\x7f19230
10491 Ref: Introduction-Footnote-4
\x7f19344
10492 Node: The GNU build system
\x7f19419
10493 Node: Automake
\x7f20337
10494 Node: Libtool
\x7f22756
10495 Node: Pointers
\x7f24176
10496 Ref: Pointers-Footnote-1
\x7f25485
10497 Ref: Pointers-Footnote-2
\x7f25544
10498 Ref: Pointers-Footnote-3
\x7f25603
10499 Ref: Pointers-Footnote-4
\x7f25660
10500 Ref: Pointers-Footnote-5
\x7f25801
10501 Ref: Pointers-Footnote-6
\x7f25875
10502 Ref: Pointers-Footnote-7
\x7f25947
10503 Node: Making configure Scripts
\x7f26022
10504 Node: Writing configure.ac
\x7f29063
10505 Node: Shell Script Compiler
\x7f30523
10506 Node: Autoconf Language
\x7f32815
10507 Node: configure.ac Layout
\x7f37438
10508 Node: autoscan Invocation
\x7f38833
10509 Node: ifnames Invocation
\x7f41579
10510 Node: autoconf Invocation
\x7f42773
10511 Node: autoreconf Invocation
\x7f49959
10512 Node: Setup
\x7f53633
10513 Node: Notices
\x7f54837
10514 Node: Input
\x7f56455
10515 Node: Output
\x7f58495
10516 Node: Configuration Actions
\x7f60470
10517 Node: Configuration Files
\x7f63367
10518 Node: Makefile Substitutions
\x7f64827
10519 Node: Preset Output Variables
\x7f66508
10520 Node: Installation Directory Variables
\x7f71057
10521 Node: Build Directories
\x7f75385
10522 Node: Automatic Remaking
\x7f77028
10523 Node: Configuration Headers
\x7f79194
10524 Node: Header Templates
\x7f81890
10525 Node: autoheader Invocation
\x7f83164
10526 Node: Autoheader Macros
\x7f86618
10527 Node: Configuration Commands
\x7f88809
10528 Node: Configuration Links
\x7f90487
10529 Node: Subdirectories
\x7f91859
10530 Node: Default Prefix
\x7f94004
10531 Node: Existing Tests
\x7f95391
10532 Node: Common Behavior
\x7f97108
10533 Node: Standard Symbols
\x7f97764
10534 Node: Default Includes
\x7f98356
10535 Node: Alternative Programs
\x7f100279
10536 Node: Particular Programs
\x7f100961
10537 Node: Generic Programs
\x7f105940
10538 Node: Files
\x7f109830
10539 Node: Libraries
\x7f110708
10540 Node: Library Functions
\x7f113561
10541 Node: Function Portability
\x7f114179
10542 Node: Particular Functions
\x7f115174
10543 Node: Generic Functions
\x7f125722
10544 Node: Header Files
\x7f129951
10545 Node: Particular Headers
\x7f130510
10546 Node: Generic Headers
\x7f137475
10547 Node: Declarations
\x7f139534
10548 Node: Particular Declarations
\x7f140118
10549 Node: Generic Declarations
\x7f140531
10550 Node: Structures
\x7f142893
10551 Node: Particular Structures
\x7f143495
10552 Node: Generic Structures
\x7f145203
10553 Node: Types
\x7f146436
10554 Node: Particular Types
\x7f146950
10555 Node: Generic Types
\x7f148104
10556 Node: Compilers and Preprocessors
\x7f149466
10557 Node: Generic Compiler Characteristics
\x7f150470
10558 Node: C Compiler
\x7f151318
10559 Node: C++ Compiler
\x7f158638
10560 Node: Fortran 77 Compiler
\x7f160865
10561 Node: System Services
\x7f169412
10562 Ref: System Services-Footnote-1
\x7f172520
10563 Node: UNIX Variants
\x7f172611
10564 Node: Writing Tests
\x7f173782
10565 Node: Examining Declarations
\x7f175713
10566 Node: Examining Syntax
\x7f178203
10567 Node: Examining Libraries
\x7f179645
10568 Node: Run Time
\x7f182655
10569 Node: Test Programs
\x7f183631
10570 Node: Guidelines
\x7f185887
10571 Node: Test Functions
\x7f187077
10572 Node: Systemology
\x7f188624
10573 Ref: Systemology-Footnote-1
\x7f189246
10574 Ref: Systemology-Footnote-2
\x7f189284
10575 Node: Multiple Cases
\x7f189352
10576 Node: Language Choice
\x7f190604
10577 Node: Results
\x7f192626
10578 Node: Defining Symbols
\x7f193375
10579 Node: Setting Output Variables
\x7f196621
10580 Node: Caching Results
\x7f200805
10581 Node: Cache Variable Names
\x7f204481
10582 Node: Cache Files
\x7f206061
10583 Node: Cache Checkpointing
\x7f208081
10584 Node: Printing Messages
\x7f209411
10585 Node: Programming in M4
\x7f212590
10586 Node: M4 Quotation
\x7f213262
10587 Node: Active Characters
\x7f214067
10588 Ref: Active Characters-Footnote-1
\x7f215436
10589 Node: One Macro Call
\x7f215458
10590 Node: Quotation and Nested Macros
\x7f217012
10591 Node: Quadrigraphs
\x7f219969
10592 Node: Quotation Rule Of Thumb
\x7f220888
10593 Node: Programming in M4sugar
\x7f223522
10594 Node: Redefined M4 Macros
\x7f224025
10595 Node: Forbidden Patterns
\x7f224983
10596 Node: Writing Autoconf Macros
\x7f226337
10597 Node: Macro Definitions
\x7f227138
10598 Node: Macro Names
\x7f228941
10599 Node: Reporting Messages
\x7f231547
10600 Node: Dependencies Between Macros
\x7f232881
10601 Node: Prerequisite Macros
\x7f233500
10602 Node: Suggested Ordering
\x7f236287
10603 Node: Obsoleting Macros
\x7f237796
10604 Node: Coding Style
\x7f238914
10605 Node: Portable Shell
\x7f245916
10606 Node: Shellology
\x7f247999
10607 Node: Here-Documents
\x7f250969
10608 Node: File Descriptors
\x7f252923
10609 Node: File System Conventions
\x7f254924
10610 Ref: File System Conventions-Footnote-1
\x7f259038
10611 Node: Shell Substitutions
\x7f259112
10612 Node: Assignments
\x7f264013
10613 Node: Special Shell Variables
\x7f265643
10614 Node: Limitations of Builtins
\x7f269677
10615 Node: Limitations of Usual Tools
\x7f282004
10616 Node: Limitations of Make
\x7f294746
10617 Node: Manual Configuration
\x7f295748
10618 Node: Specifying Names
\x7f296574
10619 Ref: Specifying Names-Footnote-1
\x7f299378
10620 Node: Canonicalizing
\x7f299778
10621 Node: Using System Type
\x7f302172
10622 Node: Site Configuration
\x7f303214
10623 Node: External Software
\x7f304043
10624 Node: Package Options
\x7f307350
10625 Node: Pretty Help Strings
\x7f310209
10626 Node: Site Details
\x7f312179
10627 Node: Transforming Names
\x7f313406
10628 Node: Transformation Options
\x7f314546
10629 Node: Transformation Examples
\x7f315039
10630 Node: Transformation Rules
\x7f316747
10631 Node: Site Defaults
\x7f318582
10632 Node: Running configure scripts
\x7f322498
10633 Node: Basic Installation
\x7f323512
10634 Node: Compilers and Options
\x7f326353
10635 Node: Multiple Architectures
\x7f326988
10636 Node: Installation Names
\x7f327980
10637 Node: Optional Features
\x7f329171
10638 Node: System Type
\x7f329948
10639 Node: Sharing Defaults
\x7f331469
10640 Node: Environment Variables
\x7f332103
10641 Node: configure Invocation
\x7f332782
10642 Node: config.status Invocation
\x7f333907
10643 Node: Obsolete Constructs
\x7f337733
10644 Node: Obsolete config.status Use
\x7f338656
10645 Node: acconfig.h
\x7f340449
10646 Node: autoupdate Invocation
\x7f342457
10647 Node: Obsolete Macros
\x7f344412
10648 Node: Autoconf 1
\x7f360698
10649 Node: Changed File Names
\x7f361757
10650 Node: Changed Makefiles
\x7f362521
10651 Node: Changed Macros
\x7f363603
10652 Node: Changed Results
\x7f364849
10653 Node: Changed Macro Writing
\x7f366950
10654 Node: Autoconf 2.13
\x7f368214
10655 Node: Changed Quotation
\x7f369216
10656 Node: New Macros
\x7f371112
10657 Node: Questions
\x7f372735
10658 Node: Distributing
\x7f373256
10659 Node: Why GNU m4
\x7f374319
10660 Node: Bootstrapping
\x7f375207
10661 Node: Why Not Imake
\x7f375813
10662 Node: History
\x7f380512
10663 Node: Genesis
\x7f381308
10664 Node: Exodus
\x7f382497
10665 Node: Leviticus
\x7f385540
10666 Node: Numbers
\x7f387067
10667 Node: Deuteronomy
\x7f388981
10668 Node: Environment Variable Index
\x7f391647
10669 Node: Output Variable Index
\x7f393806
10670 Node: Preprocessor Symbol Index
\x7f399618
10671 Node: Autoconf Macro Index
\x7f406223
10672 Node: M4 Macro Index
\x7f422711
10673 Node: Concept Index
\x7f423270