D. Autoconf Macro Reference

This is an alphabetical list of each Autoconf macro used in this book,along with a description of what each does. They are provided for yourreference while reading this book. The descriptions are only brief; seethe appropriate reference manual for a complete description.

AC_ARG_ENABLE(feature, help-text, [if-given], [if-not-given])
This macro allows the maintainer to specify additional package optionsaccepted by `configure'--for example, `--enable-zlib'. Theaction shell code may access any arguments to the option in the shellvariable enableval. For example, `--enable-buffers=128'would cause `configure' to set enableval to `128'.

AC_ARG_PROGRAM
This macro places a sed transformation program into the outputvariable program_transform_name that can be used to transform thefilenames of installed programs. If the `--program-prefix', `--program-suffix' or
`--program-transform-name' optionsare passed to `configure', an appropriate transformation programwill be generated. If no options are given, but the type of the hostsystem differs from the type of the target system, program names aretransformed by prefixing them with the type of the target(eg. arm-elf-gcc).

AC_ARG_WITH(package, help-text, [if-given], [if-not-given])
This macro allows the maintainer to specify additional packages thatthis package should work with (for example, a library to manipulateshadow passwords). The user indicates this preference by invoking `configure' with an option such as `--with-shadow'. If anoptional argument is given, this value is available to shell code in theshell variable withval.

AC_CACHE_CHECK(message, cache-variable, commands)
This macro is a convenient front-end to the AC_CACHE_VAL macrothat takes care of printing messages to the user, including whether ornot the result was found in the cache. It should be used in preferenceto AC_CACHE_VAL.

AC_CACHE_VAL(cache-variable, commands)
This is a low-level macro which implements the Autoconf cache feature.If the named variable is set at runtime (for instance, if it was readfrom `config.cache'), then this macro does nothing. Otherwise, itruns the shell code in commands, which is assumed to set the cachevariable.

AC_CANONICAL_HOST
This macro determines the type of the host system and sets the outputvariable `host', as well as other more obscure variables.

AC_CANONICAL_SYSTEM
This macro determines the type of the build, host and target systems andsets the output variables `build', `host' and `target',amongst other more obscure variables.

AC_CHECK_FILE(file, [if-found], [if-not-found])
This macro tests for the existence of a file in the file system of thebuild system, and runs the appropriate shell code depending on whetheror not the file is found.

AC_CHECK_FUNCS(function-list, [if-found], [if-not-found])
This looks for a series of functions. If the function quux isfound, the C preprocessor macro HAVE_QUUX will be defined. Inaddition, if the if-found argument is given, it will be run (asshell code) when a function is found -- this code can use the sh break command to prevent AC_CHECK_FUNCS from looking forthe remaining functions in the list. The shell code in if-not-found is run if a function is not found.

AC_CHECK_HEADER(header, [if-found], [if-not-found])
This macro executes some specified shell code if a header file exists.If it is not present, alternative shell code is executed instead.

AC_CHECK_HEADERS(header-list, [if-found], [if-not-found])
This looks for a series of headers. If the header quux.h isfound, the C preprocessor macro HAVE_QUUX_H will be defined. Inaddition, if the if-found argument is given, it will be run (asshell code) when a header is found -- this code can use the sh break command to prevent AC_CHECK_HEADERS from looking forthe remaining headers in the list. The shell code in if-not-foundis run if a header is not found.

AC_CHECK_LIB(library, function, [if-found], [if-not-found], [other-libraries])
This looks for the named function in the named library specified by itsbase name. For instance the math library, `libm.a', would be namedsimply `m'. If the function is found in the library `foo',then the C preprocessor macro HAVE_LIBFOO is defined.

AC_CHECK_PROG(variable, program-name, value-if-found, [value-if-not-found], [path], [reject])
Checks to see if the program named by program-name exists in thepath path. If found, it sets the shell variable variable tothe value value-if-found; if not it uses the value value-if-not-found. If variable is already set at runtime,this macro does nothing.

AC_CHECK_SIZEOF(type, [size-if-cross-compiling])
This macro determines the size of C and C++ built-in types and defines SIZEOF_type to the size, where type is transformed--allcharacters to upper case, spaces to underscores and `*' to `P'. If the type is unknown to the compiler, the size is set to 0.An optional argument specifies a default size when cross-compiling. The `configure' script will abort with an error message if it tries tocross-compile without this default size.

AC_CONFIG_AUX_DIR(directory)
This macro allows an alternative directory to be specified for thelocation of auxiliary scripts such as `config.guess', `config.sub' and `install-sh'. By default, `$srcdir', `$srcdir/..' and `$srcdir/../..' are searched for these files.

AC_CONFIG_HEADER(header-list)
This indicates that you want to use a config header, as opposed tohaving all the C preprocessor macros defined via -D options inthe DEFS `Makefile' variable. Each header named in header-list is created at runtime by `configure' (via AC_OUTPUT). There are a variety of optional features for usewith config headers (different naming schemes and so forth); see thereference manual for more information.

AC_C_CONST
This macro defines the C preprocessor macro const to the string const if the C compiler supports the const keyword.Otherwise it is defined to be the empty string.

AC_C_INLINE
This macro tests if the C compiler can accept the inline keyword.It defines the C preprocessor macro inline to be the keywordaccepted by the compiler or the empty string if it is not accepted atall.

AC_DEFINE(variable, [value], [description])
This is used to define C preprocessor macros. The first argument is thename of the macro to define. The value argument, if given, is thevalue of the macro. The final argument can be used to avoid adding an `#undef' for the macro to `acconfig.h'.

AC_DEFINE_UNQUOTED(variable, [value], [description])
This is like AC_DEFINE, but it handles the quoting of valuedifferently. This macro is used when you want to compute the valueinstead of having it used verbatim.

AC_DEFUN(name, body)
This macro is used to define new macros. It is similar to M4's define macro, except that it performs additional internalfunctions.

AC_DISABLE_FAST_INSTALL
This macro can be used to disable Libtool's `fast install' feature.

AC_DISABLE_SHARED
This macro changes the default behavior of AC_PROG_LIBTOOL sothat shared libraries will not be built by default. The user can stilloverride this new default by using `--enable-shared'.

AC_DISABLE_STATIC
This macro changes the default behavior of AC_PROG_LIBTOOL sothat static libraries will not be built by default. The user can stilloverride this new default by using `--enable-static'.

AC_EXEEXT
Sets the output variable EXEEXT to the extension of executablesproduced by the compiler. It is usually set to the empty string on Unixsystems and `.exe' on Windows.

AC_FUNC_ALLOCA
This macro defines the C preprocessor macro HAVE_ALLOCA if thevarious tests indicate that the C compiler has built-in allocasupport. If there is an `alloca.h' header file, this macro defines HAVE_ALLOCA_H. If, instead, the alloca function is foundin the standard C library, this macro defines C_ALLOCA and setsthe output variable ALLOCA to alloca.o.

AC_FUNC_GETPGRP
This macro tests if the getpgrp function takes a process ID as anargument or not. If it does not, the C preprocessor macro GETPGRP_VOID is defined.

AC_FUNC_MEMCMP
This macro tests for a working version of the memcmp function.If absent, or it does not work correctly, `memcmp.o' is added tothe LIBOBJS output variable.

AC_FUNC_MMAP
Defines the C preprocessor macro HAVE_MMAP if the mmapfunction exists and works.

AC_FUNC_SETVBUF_REVERSED
On some systems, the order of the mode and buf argumentsis reversed with respect to the ANSI C standard. If so, this macrodefines the C preprocessor macro SETVBUF_REVERSED.

AC_FUNC_UTIME_NULL
Defines the C preprocessor macro HAVE_UTIME_NULL if a call to utime with a NULL utimbuf pointer sets the file'stimestamp to the current time.

AC_FUNC_VPRINTF
Defines the C preprocessor macro HAVE_VPRINTF if the vprintf function is available. If not and the _doprntfunction is available instead, this macro defines HAVE_DOPRNT.

AC_HEADER_DIRENT
This macro searches a number of specific header files for a declarationof the C type DIR. Depending on which header file thedeclaration is found in, this macro may define one of the C preprocessormacros HAVE_DIRENT_H, HAVE_SYS_NDIR_H, HAVE_SYS_DIR_H or HAVE_NDIR_H. Refer to the Autoconfmanual for an example of how these macros should be used in your sourcecode.

AC_HEADER_STDC
This macro defines the C preprocessor macro STDC_HEADERS if thesystem has the ANSI standard C header files. It determines this bytesting for the existence of the `stdlib.h', `stdarg.h', `string.h' and `float.h' header files and testing if `string.h' declares memchr, `stdlib.h' declares free, and `ctype.h' macros such as isdigit work with8-bit characters.

AC_INIT(filename)
This macro performs essential initialization for the generated `configure' script. An optional argument may provide the name of afile from the source directory to ensure that the directory has beenspecified correctly.

AC_LIBTOOL_DLOPEN
Call this macro before AC_PROG_LIBTOOL to indicate that yourpackage wants to use Libtool's support for dlopened modules.

AC_LIBTOOL_WIN32_DLL
Call this macro before AC_PROG_LIBTOOL to indicate that yourpackage has been written to build DLLs on Windows. If this macrois not called, Libtool will only build static libraries on Windows.

AC_LIB_LTDL
This macro does the configure-time checks needed to cause `ltdl.c' to be compiled correctly. That is, this is used to enabledynamic loading via libltdl.

AC_LINK_FILES(source-list, dest-list)
Use this macro to create a set of links; if possible, symlinks are made.The two arguments are parallel lists: the first element of dest-list is the name of a to-be-created link whose target is thefirst element of source-list.

AC_MSG_CHECKING(message)
This macro outputs a message to the user in the usual style of `configure' scripts: leading with the word `checking' andending in `...'. This message gives the user an indication thatthe `configure' script is still working. A subsequent invocationof AC_MSG_RESULT should be used to output the result of a test.

AC_MSG_ERROR(message)
This macro outputs an error message to standard error and aborts the `configure' script. It should only be used for fatal errorconditions.

AC_MSG_RESULT(message)
This macro should be invoked after a corresponding invocation of AC_MSG_CHECKING with the result of a test. Often the resultstring can be as simple as `yes' or `no'.

AC_MSG_WARN(message)
This macro outputs a warning to standard error, but allows the `configure' script to continue. It should be used to notify theuser of abnormal, but non-fatal, conditions.

AC_OBJEXT
Sets the output variable OBJEXT to the extension of object filesproduced by the compiler. Usually, it is set to `.o' on Unixsystems and `.obj' on Windows.

AC_OUTPUT(files, [extra-commands], [init-commands])
This macro must be called at the end of every `configure.in'. Itcreates each file listed in files. For a given file, by default, configure reads the template file whose name is the name of theinput file with `.in' appended -- for instance, `Makefile' isgenerated from `Makefile.in'. This default can be overridden byusing a special naming convention for the file.

For each name `foo' given as an argument to AC_SUBST,configure will replace any occurrence of `@foo@' in thetemplate file with the value of the shell variable `foo' in thegenerated file. This macro also generates the config header, ifAC_CONFIG_HEADER was called, and any links, ifAC_LINK_FILES was called. The additional arguments can be usedto further tailor the output processing.

AC_OUTPUT_COMMANDS(extra-commands, [init-commands])
This macro works like the optional final arguments of AC_OUTPUT,except that it can be called more than once from `configure.in'.(This makes it possible for macros to use this feature and yet remainmodular.) See the reference manual for the precise definition of thismacro.

AC_PROG_AWK
This macro searches for an awk program and sets the outputvariable AWK to be the best one it finds.

AC_PROG_CC
This checks for the C compiler to use and sets the shell variable CC to the value. If the GNU C compiler is being used, thissets the shell variable GCC to `yes'. This macro sets theshell variable CFLAGS if it has not already been set. It alsocalls AC_SUBST on CC and CFLAGS.

AC_PROG_CC_STDC
This macro attempts to discover a necessary command line option to havethe C compiler accept ANSI C. If so, it adds the option to the CC. If it were not possible to get the C compiler to acceptANSI, the shell variable ac_cv_prog_cc_stdc will be set to `no'.

AC_PROG_CPP
This macro sets the output variable CPP to a command that runsthe C preprocessor. If `$CC -E' does not work, it will set thevariable to `/lib/cpp'.

AC_PROG_CXX
This is like AC_PROG_CC, but it checks for the C++ compiler, andsets the variables CXX, GXX and CXXFLAGS.

AC_PROG_GCC_TRADITIONAL
This macro determines if GCC requires the `-traditional'option in order to compile code that uses ioctl and, if so, adds `-traditional' to the CC output variable. This condition israrely encountered, thought mostly on old systems.

AC_PROG_INSTALL
This looks for an install program and sets the output variables INSTALL, INSTALL_DATA, INSTALL_PROGRAM, and INSTALL_SCRIPT. This macro assumes that if an installprogram cannot be found on the system, your package will have `install-sh' available in the directory chosen by AC_CONFIG_AUX_DIR.

AC_PROG_LEX
This looks for a lex-like program and sets the `Makefile'variable LEX to the result. It also sets LEXLIB towhatever might be needed to link against lex output.

AC_PROG_LIBTOOL
This macro is the primary way to integrate Libtool support into `configure'. If you are using Libtool, you should call this macroin `configure.in'. Among other things, it adds support for the `--enable-shared' configure flag.

AC_PROG_LN_S
This sets the `Makefile' variable LN_S to `ln -s' ifsymbolic links work in the current working directory. Otherwise it sets LN_S to just `ln'.

AC_PROG_MAKE_SET
Some versions of make need to have the `Makefile' variable MAKE set in `Makefile' in order for recursive builds towork. This macro checks whether this is needed, and, if so, it sets the `Makefile' variable SET_MAKE to the result. AM_INIT_AUTOMAKE calls this macro, so if you are using Automake,you don't need to call it or use SET_MAKE in `Makefile.am'.

AC_PROG_RANLIB
This searches for the ranlib program. It sets the `Makefile' variable RANLIB to the result. If ranlib isnot found, or not needed on the system, then the result is :.

AC_PROG_YACC
This searches for the yacc program -- it tries bison, byacc, and yacc. It sets the `Makefile' variable YACC to the result.

AC_REPLACE_FUNCS(function list)
This macro takes a single argument, which is a list of functions. For agiven function `func', `configure' will do a link test to tryto find it. If the function cannot be found, then `func.o' will beadded to LIBOBJS. If function can be found, then `configure' will define the C preprocessor symbol HAVE_FUNC.

AC_REQUIRE(macro-name)
This macro takes a single argument, which is the name of another macro.(Note that you must quote the argument correctly: AC_REQUIRE([FOO]) is correct, while AC_REQUIRE(FOO) isnot.) If the named macro has already been invoked, then AC_REQUIRE does nothing. Otherwise, it invokes the named macrowith no arguments.

AC_REVISION(revision)
This macro takes a single argument, a version string. Autoconf willcopy this string into the generated `configure' file.

AC_STRUCT_ST_BLKSIZE
Defines the C preprocessor macro HAVE_ST_BLKSIZE if structstat has an st_blksize member.

AC_STRUCT_ST_BLOCKS
Defines the C preprocessor macro HAVE_ST_BLOCKS if structstat has an st_blocks member.

AC_STRUCT_ST_RDEV
Defines the C preprocessor macro HAVE_ST_RDEV if structstat has an st_rdev member.

AC_STRUCT_TM
This macro looks for struct tm in `time.h' and defines TM_IN_SYS_TIME if it is not found there.

AC_SUBST(name)
This macro takes a single argument, which is the name of a shellvariable. When configure generates the files listed in AC_OUTPUT (e.g., `Makefile'), it will substitute thevariable's value (at the end of the configure run -- the valuecan be changed after AC_SUBST is called) anywhere a string of theform `@name@' is seen.

AC_TRY_COMPILE(includes, body, [if-ok], [if-not-ok])
This macro is used to try to compile a given function, whose body isgiven in body. includes lists any `#include'statements needed to compile the function. If the code compilescorrectly, the shell commands in if-ok are run; if not, if-not-ok is run. Note that this macro will not try to link thetest program -- it will only try to compile it.

AC_TRY_LINK(includes, body, [if-found], [if-not-found])
This is used like AC_TRY_COMPILE, but it tries to link theresulting program. The libraries and options in the LIBS shellvariable are passed to the link.

AC_TRY_RUN(program, [if-true, [if-false], [if-cross-compiling])
This macro tries to compile and link the program whose text is in program. If the program compiles, links, and runs successfully,the shell code if-true is run. Otherwise, the shell code if-false is run. If the current configure is a cross-configure,then the program is not run, and on a successful compile and link, theshell code if-cross-compiling is run.

AC_TYPE_SIGNAL
This macro defines the C preprocessor macro RETSIGTYPE to be thecorrect return type of signal handlers. For instance, it might be `void' or `int'.

AC_TYPE_SIZE_T
This macro looks for the type size_t. If not defined on thesystem, it defines it (as a macro) to be `unsigned'.

AM_CONDITIONAL(name, testcode)
This Automake macro takes two arguments: the name of a conditional and ashell statement that is used to determine whether the conditional shouldbe true or false. If the shell code returns a successful (0) status,then the conditional will be true. Any conditional in your `configure.in' is automatically available for use in any `Makefile.am' in that project.

AM_CONFIG_HEADER(header)
This is just like AC_CONFIG_HEADER, but does some additionalsetup required by Automake. If you are using Automake, use this macro.Otherwise, use AC_CONFIG_HEADER.

AM_INIT_AUTOMAKE(package, version, [nodefine])
This macro is used to do all the standard initialization required byAutomake. It has two required arguments: the package name and theversion number. This macro sets and calls AC_SUBST on the shellvariables PACKAGE and VERSION. By default it also definesthese variables (via AC_DEFINE_UNQUOTED). However, this macroalso accepts an optional third argument which, if not empty, means thatthe AC_DEFINE_UNQUOTED calls for PACKAGE and VERSION should be suppressed.

AM_MAINTAINER_MODE
This macro is used to enable a special Automake feature, maintainermode, which we've documented elsewhere (see section 5.3 Maintaining Input Files).

AM_PROG_CC_STDC
This macro takes no arguments. It is used to try to get the C compilerto be ANSI compatible. It does this by adding different optionsknown to work with various system compilers. This macro is mosttypically used in conjunction with Automake when you want to use theautomatic de-ANSI-fication feature.

AM_PROG_LEX
This is like AC_PROG_LEX, but it does some additional processingused by Automake-generated `Makefile's. If you are using Automake,then you should use this. Otherwise, you should use AC_PROG_LEX(and perhaps AC_DECL_YYTEXT, which AM_PROG_LEX calls).

AM_WITH_DMALLOC
This macro adds support for the `--with-dmalloc' flag to configure. If the user chooses to enable dmalloc support,then this macro will define the preprocessor symbol `WITH_DMALLOC'and will add `-ldmalloc' to the `Makefile' variable `LIBS'.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值