Autoconf Creating Automatic Configuration Scripts for Version 2.69, 24 April 2012
Total Page:16
File Type:pdf, Size:1020Kb
Autoconf Creating Automatic Configuration Scripts for version 2.69, 24 April 2012 David MacKenzie Ben Elliston Akim Demaille This manual (24 April 2012) is for GNU Autoconf (version 2.69), a package for creating scripts to configure source code packages using templates and an M4 macro package. Copyright c 1992-1996, 1998-2012 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License." i Table of Contents 1 Introduction::::::::::::::::::::::::::::::::::::: 1 2 The GNU Build System:::::::::::::::::::::::: 3 2.1 Automake:::::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2.2 Gnulib ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2.3 Libtool::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 2.4 Pointers:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 4 3 Making configure Scripts :::::::::::::::::::::: 5 3.1 Writing `configure.ac' :::::::::::::::::::::::::::::::::::::::: 6 3.1.1 A Shell Script Compiler ::::::::::::::::::::::::::::::::::: 6 3.1.2 The Autoconf Language ::::::::::::::::::::::::::::::::::: 7 3.1.3 Standard `configure.ac' Layout :::::::::::::::::::::::::: 9 3.2 Using autoscan to Create `configure.ac'::::::::::::::::::::: 10 3.3 Using ifnames to List Conditionals:::::::::::::::::::::::::::: 11 3.4 Using autoconf to Create configure ::::::::::::::::::::::::: 11 3.5 Using autoreconf to Update configure Scripts ::::::::::::::: 13 4 Initialization and Output Files ::::::::::::::: 17 4.1 Initializing configure::::::::::::::::::::::::::::::::::::::::: 17 4.2 Dealing with Autoconf versions:::::::::::::::::::::::::::::::: 18 4.3 Notices in configure ::::::::::::::::::::::::::::::::::::::::: 18 4.4 Finding configure Input ::::::::::::::::::::::::::::::::::::: 19 4.5 Outputting Files :::::::::::::::::::::::::::::::::::::::::::::: 20 4.6 Performing Configuration Actions ::::::::::::::::::::::::::::: 21 4.7 Creating Configuration Files :::::::::::::::::::::::::::::::::: 23 4.8 Substitutions in Makefiles ::::::::::::::::::::::::::::::::::::: 23 4.8.1 Preset Output Variables :::::::::::::::::::::::::::::::::: 23 4.8.2 Installation Directory Variables::::::::::::::::::::::::::: 27 4.8.3 Changed Directory Variables ::::::::::::::::::::::::::::: 30 4.8.4 Build Directories ::::::::::::::::::::::::::::::::::::::::: 31 4.8.5 Automatic Remaking::::::::::::::::::::::::::::::::::::: 32 4.9 Configuration Header Files :::::::::::::::::::::::::::::::::::: 33 4.9.1 Configuration Header Templates:::::::::::::::::::::::::: 34 4.9.2 Using autoheader to Create `config.h.in'::::::::::::::: 35 4.9.3 Autoheader Macros :::::::::::::::::::::::::::::::::::::: 36 4.10 Running Arbitrary Configuration Commands ::::::::::::::::: 37 4.11 Creating Configuration Links::::::::::::::::::::::::::::::::: 38 4.12 Configuring Other Packages in Subdirectories::::::::::::::::: 38 4.13 Default Prefix:::::::::::::::::::::::::::::::::::::::::::::::: 39 ii Autoconf 5 Existing Tests:::::::::::::::::::::::::::::::::: 41 5.1 Common Behavior :::::::::::::::::::::::::::::::::::::::::::: 41 5.1.1 Standard Symbols :::::::::::::::::::::::::::::::::::::::: 41 5.1.2 Default Includes:::::::::::::::::::::::::::::::::::::::::: 41 5.2 Alternative Programs ::::::::::::::::::::::::::::::::::::::::: 43 5.2.1 Particular Program Checks ::::::::::::::::::::::::::::::: 43 5.2.2 Generic Program and File Checks :::::::::::::::::::::::: 46 5.3 Files :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49 5.4 Library Files :::::::::::::::::::::::::::::::::::::::::::::::::: 49 5.5 Library Functions ::::::::::::::::::::::::::::::::::::::::::::: 50 5.5.1 Portability of C Functions :::::::::::::::::::::::::::::::: 50 5.5.2 Particular Function Checks ::::::::::::::::::::::::::::::: 53 5.5.3 Generic Function Checks ::::::::::::::::::::::::::::::::: 61 5.6 Header Files :::::::::::::::::::::::::::::::::::::::::::::::::: 63 5.6.1 Portability of Headers :::::::::::::::::::::::::::::::::::: 63 5.6.2 Particular Header Checks::::::::::::::::::::::::::::::::: 65 5.6.3 Generic Header Checks ::::::::::::::::::::::::::::::::::: 70 5.7 Declarations :::::::::::::::::::::::::::::::::::::::::::::::::: 71 5.7.1 Particular Declaration Checks :::::::::::::::::::::::::::: 71 5.7.2 Generic Declaration Checks :::::::::::::::::::::::::::::: 71 5.8 Structures :::::::::::::::::::::::::::::::::::::::::::::::::::: 73 5.8.1 Particular Structure Checks :::::::::::::::::::::::::::::: 73 5.8.2 Generic Structure Checks::::::::::::::::::::::::::::::::: 74 5.9 Types::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 74 5.9.1 Particular Type Checks :::::::::::::::::::::::::::::::::: 74 5.9.2 Generic Type Checks ::::::::::::::::::::::::::::::::::::: 77 5.10 Compilers and Preprocessors ::::::::::::::::::::::::::::::::: 78 5.10.1 Specific Compiler Characteristics :::::::::::::::::::::::: 78 5.10.2 Generic Compiler Characteristics :::::::::::::::::::::::: 78 5.10.3 C Compiler Characteristics :::::::::::::::::::::::::::::: 80 5.10.4 C++ Compiler Characteristics :::::::::::::::::::::::::: 86 5.10.5 Objective C Compiler Characteristics:::::::::::::::::::: 86 5.10.6 Objective C++ Compiler Characteristics :::::::::::::::: 87 5.10.7 Erlang Compiler and Interpreter Characteristics ::::::::: 87 5.10.8 Fortran Compiler Characteristics :::::::::::::::::::::::: 88 5.10.9 Go Compiler Characteristics::::::::::::::::::::::::::::: 96 5.11 System Services :::::::::::::::::::::::::::::::::::::::::::::: 96 5.12 Posix Variants ::::::::::::::::::::::::::::::::::::::::::::::: 98 5.13 Erlang Libraries ::::::::::::::::::::::::::::::::::::::::::::: 98 iii 6 Writing Tests ::::::::::::::::::::::::::::::::: 101 6.1 Language Choice::::::::::::::::::::::::::::::::::::::::::::: 101 6.2 Writing Test Programs ::::::::::::::::::::::::::::::::::::::: 103 6.2.1 Guidelines for Test Programs :::::::::::::::::::::::::::: 103 6.2.2 Test Functions :::::::::::::::::::::::::::::::::::::::::: 103 6.2.3 Generating Sources:::::::::::::::::::::::::::::::::::::: 104 6.3 Running the Preprocessor :::::::::::::::::::::::::::::::::::: 107 6.4 Running the Compiler ::::::::::::::::::::::::::::::::::::::: 108 6.5 Running the Linker :::::::::::::::::::::::::::::::::::::::::: 108 6.6 Checking Runtime Behavior :::::::::::::::::::::::::::::::::: 109 6.7 Systemology ::::::::::::::::::::::::::::::::::::::::::::::::: 111 6.8 Multiple Cases ::::::::::::::::::::::::::::::::::::::::::::::: 111 7 Results of Tests :::::::::::::::::::::::::::::: 113 7.1 Defining C Preprocessor Symbols::::::::::::::::::::::::::::: 113 7.2 Setting Output Variables::::::::::::::::::::::::::::::::::::: 114 7.3 Special Characters in Output Variables::::::::::::::::::::::: 116 7.4 Caching Results:::::::::::::::::::::::::::::::::::::::::::::: 117 7.4.1 Cache Variable Names :::::::::::::::::::::::::::::::::: 118 7.4.2 Cache Files ::::::::::::::::::::::::::::::::::::::::::::: 119 7.4.3 Cache Checkpointing :::::::::::::::::::::::::::::::::::: 119 7.5 Printing Messages:::::::::::::::::::::::::::::::::::::::::::: 120 8 Programming in M4 ::::::::::::::::::::::::: 123 8.1 M4 Quotation ::::::::::::::::::::::::::::::::::::::::::::::: 123 8.1.1 Active Characters ::::::::::::::::::::::::::::::::::::::: 123 8.1.2 One Macro Call ::::::::::::::::::::::::::::::::::::::::: 124 8.1.3 Quoting and Parameters :::::::::::::::::::::::::::::::: 125 8.1.4 Quotation and Nested Macros ::::::::::::::::::::::::::: 126 8.1.5 changequote is Evil::::::::::::::::::::::::::::::::::::: 127 8.1.6 Quadrigraphs ::::::::::::::::::::::::::::::::::::::::::: 128 8.1.7 Dealing with unbalanced parentheses :::::::::::::::::::: 129 8.1.8 Quotation Rule Of Thumb :::::::::::::::::::::::::::::: 131 8.2 Using autom4te:::::::::::::::::::::::::::::::::::::::::::::: 132 8.2.1 Invoking autom4te :::::::::::::::::::::::::::::::::::::: 132 8.2.2 Customizing autom4te :::::::::::::::::::::::::::::::::: 136 8.3 Programming in M4sugar :::::::::::::::::::::::::::::::::::: 137 8.3.1 Redefined M4 Macros ::::::::::::::::::::::::::::::::::: 137 8.3.2 Diagnostic messages from M4sugar :::::::::::::::::::::: 140 8.3.3 Diversion support ::::::::::::::::::::::::::::::::::::::: 141 8.3.4 Conditional constructs :::::::::::::::::::::::::::::::::: 144 8.3.5 Looping constructs :::::::::::::::::::::::::::::::::::::: 147 8.3.6 Evaluation Macros :::::::::::::::::::::::::::::::::::::: 151 8.3.7 String manipulation in M4 :::::::::::::::::::::::::::::: 155 8.3.8 Arithmetic computation in M4 :::::::::::::::::::::::::: 158 8.3.9 Set manipulation in M4 ::::::::::::::::::::::::::::::::: 160 8.3.10 Forbidden Patterns :::::::::::::::::::::::::::::::::::: 164 8.4 Debugging via autom4te ::::::::::::::::::::::::::::::::::::: 164 iv Autoconf 9 Programming in M4sh ::::::::::::::::::::::: 167 9.1 Common Shell Constructs:::::::::::::::::::::::::::::::::::: 167 9.2 Support for indirect variable names :::::::::::::::::::::::::: 170 9.3 Initialization Macros ::::::::::::::::::::::::::::::::::::::::: 173 9.4 File Descriptor Macros ::::::::::::::::::::::::::::::::::::::: 175 10 Writing Autoconf Macros :::::::::::::::::: 177 10.1 Macro Definitions ::::::::::::::::::::::::::::::::::::::::::: 177 10.2 Macro Names ::::::::::::::::::::::::::::::::::::::::::::::: 178 10.3 Reporting Messages ::::::::::::::::::::::::::::::::::::::::: 179 10.4 Dependencies