1235 |
|
|
1236 |
@cindex Back trace |
@cindex Back trace |
1237 |
@cindex Macro invocation stack |
@cindex Macro invocation stack |
1238 |
@command{autoconf} displays a back trace for errors, but not for |
Because @command{autoconf} uses @command{autom4te} behind the scenes, it |
1239 |
warnings; if you want them, just pass @option{-W error}. For instance, |
displays a back trace for errors, but not for warnings; if you want |
1240 |
on this @file{configure.ac}: |
them, just pass @option{-W error}. @xref{Invoking autom4te}, for some |
1241 |
|
examples. |
|
@example |
|
|
AC_DEFUN([INNER], |
|
|
[AC_TRY_RUN([exit (0)])]) |
|
|
|
|
|
AC_DEFUN([OUTER], |
|
|
[INNER]) |
|
|
|
|
|
AC_INIT |
|
|
OUTER |
|
|
@end example |
|
|
|
|
|
@noindent |
|
|
you get: |
|
|
|
|
|
@example |
|
|
$ @kbd{autoconf -Wcross} |
|
|
configure.ac:8: warning: AC_TRY_RUN called without default \ |
|
|
to allow cross compiling |
|
|
$ @kbd{autoconf -Wcross,error} |
|
|
configure.ac:8: error: AC_TRY_RUN called without default \ |
|
|
to allow cross compiling |
|
|
acgeneral.m4:3044: AC_TRY_RUN is expanded from... |
|
|
configure.ac:2: INNER is expanded from... |
|
|
configure.ac:5: OUTER is expanded from... |
|
|
configure.ac:8: the top level |
|
|
@end example |
|
1242 |
|
|
1243 |
@item --trace=@var{macro}[:@var{format}] |
@item --trace=@var{macro}[:@var{format}] |
1244 |
@itemx -t @var{macro}[:@var{format}] |
@itemx -t @var{macro}[:@var{format}] |
1250 |
|
|
1251 |
The @var{format} is a regular string, with newlines if desired, and |
The @var{format} is a regular string, with newlines if desired, and |
1252 |
several special escape codes. It defaults to @samp{$f:$l:$n:$%}; see |
several special escape codes. It defaults to @samp{$f:$l:$n:$%}; see |
1253 |
below for details on the @var{format}. |
@ref{Invoking autom4te}, for details on the @var{format}. |
1254 |
|
|
1255 |
@item --initialization |
@item --initialization |
1256 |
@itemx -i |
@itemx -i |
1263 |
It is often necessary to check the content of a @file{configure.ac} |
It is often necessary to check the content of a @file{configure.ac} |
1264 |
file, but parsing it yourself is extremely fragile and error-prone. It |
file, but parsing it yourself is extremely fragile and error-prone. It |
1265 |
is suggested that you rely upon @option{--trace} to scan |
is suggested that you rely upon @option{--trace} to scan |
1266 |
@file{configure.ac}. |
@file{configure.ac}. For instance, to find the list of variables that |
1267 |
|
are substituted, use: |
|
The @var{format} of @option{--trace} can use the following special |
|
|
escapes: |
|
|
|
|
|
@table @samp |
|
|
@item $$ |
|
|
The character @samp{$}. |
|
|
|
|
|
@item $f |
|
|
The filename from which @var{macro} is called. |
|
|
|
|
|
@item $l |
|
|
The line number from which @var{macro} is called. |
|
|
|
|
|
@item $d |
|
|
The depth of the @var{macro} call. This is an M4 technical detail that |
|
|
you probably don't want to know about. |
|
|
|
|
|
@item $n |
|
|
The name of the @var{macro}. |
|
|
|
|
|
@item $@var{num} |
|
|
The @var{num}th argument of the call to @var{macro}. |
|
|
|
|
|
@item $@@ |
|
|
@itemx $@var{sep}@@ |
|
|
@itemx $@{@var{separator}@}@@ |
|
|
All the arguments passed to @var{macro}, separated by the character |
|
|
@var{sep} or the string @var{separator} (@samp{,} by default). Each |
|
|
argument is quoted, i.e., enclosed in a pair of square brackets. |
|
|
|
|
|
@item $* |
|
|
@itemx $@var{sep}* |
|
|
@itemx $@{@var{separator}@}* |
|
|
As above, but the arguments are not quoted. |
|
|
|
|
|
@item $% |
|
|
@itemx $@var{sep}% |
|
|
@itemx $@{@var{separator}@}% |
|
|
As above, but the arguments are not quoted, all new line characters in |
|
|
the arguments are smashed, and the default separator is @samp{:}. |
|
|
|
|
|
The escape @samp{$%} produces single-line trace outputs (unless you put |
|
|
newlines in the @samp{separator}), while @samp{$@@} and @samp{$*} do |
|
|
not. |
|
|
@end table |
|
|
|
|
|
For instance, to find the list of variables that are substituted, use: |
|
1268 |
|
|
1269 |
@example |
@example |
1270 |
@group |
@group |
3313 |
@defmac AC_SEARCH_LIBS (@var{function}, @var{search-libs}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{other-libraries}) |
@defmac AC_SEARCH_LIBS (@var{function}, @var{search-libs}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{other-libraries}) |
3314 |
@acindex SEARCH_LIBS |
@acindex SEARCH_LIBS |
3315 |
Search for a library defining @var{function} if it's not already |
Search for a library defining @var{function} if it's not already |
3316 |
available. This equates to calling @code{AC_TRY_LINK_FUNC} first |
available. This equates to calling |
3317 |
with no libraries, then for each library listed in @var{search-libs}. |
@samp{AC_LINK_IFELSE([AC_LANG_CALL([@var{function}])])} first with no |
3318 |
|
libraries, then for each library listed in @var{search-libs}. |
3319 |
|
|
3320 |
Add @option{-l@var{library}} to @code{LIBS} for the first library found |
Add @option{-l@var{library}} to @code{LIBS} for the first library found |
3321 |
to contain @var{function}, and run @var{action-if-found}. If the |
to contain @var{function}, and run @var{action-if-found}. If the |
4958 |
The following macros check for C compiler or machine architecture |
The following macros check for C compiler or machine architecture |
4959 |
features. To check for characteristics not listed here, use |
features. To check for characteristics not listed here, use |
4960 |
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}) or |
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}) or |
4961 |
@code{AC_TRY_RUN} (@pxref{Run Time}) |
@code{AC_RUN_IFELSE} (@pxref{Run Time}). |
4962 |
|
|
4963 |
@defmac AC_C_BACKSLASH_A |
@defmac AC_C_BACKSLASH_A |
4964 |
@acindex HAVE_C_BACKSLASH_A |
@acindex HAVE_C_BACKSLASH_A |
5212 |
|
|
5213 |
The following macros check for Fortran 77 compiler characteristics. To |
The following macros check for Fortran 77 compiler characteristics. To |
5214 |
check for characteristics not listed here, use @code{AC_COMPILE_IFELSE} |
check for characteristics not listed here, use @code{AC_COMPILE_IFELSE} |
5215 |
(@pxref{Running the Compiler}) or @code{AC_TRY_RUN} (@pxref{Run Time}), |
(@pxref{Running the Compiler}) or @code{AC_RUN_IFELSE} (@pxref{Run |
5216 |
making sure to first set the current language to Fortran 77 |
Time}), making sure to first set the current language to Fortran 77 |
5217 |
@code{AC_LANG(Fortran 77)} (@pxref{Language Choice}). |
@code{AC_LANG(Fortran 77)} (@pxref{Language Choice}). |
5218 |
|
|
5219 |
|
|
6035 |
|
|
6036 |
If you really need to test for a run-time behavior while configuring, |
If you really need to test for a run-time behavior while configuring, |
6037 |
you can write a test program to determine the result, and compile and |
you can write a test program to determine the result, and compile and |
6038 |
run it using @code{AC_TRY_RUN}. Avoid running test programs if |
run it using @code{AC_RUN_IFELSE}. Avoid running test programs if |
6039 |
possible, because this prevents people from configuring your package for |
possible, because this prevents people from configuring your package for |
6040 |
cross-compiling. |
cross-compiling. |
6041 |
|
|
6042 |
@defmac AC_TRY_RUN (@var{program}, @ovar{action-if-true}, @ovar{action-if-false}, @ovar{action-if-cross-compiling}) |
@defmac AC_RUN_IFELSE (@var{input}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{action-if-cross-compiling}) |
6043 |
@acindex TRY_RUN |
@acindex RUN_IFELSE |
6044 |
If @var{program} compiles and links successfully and returns an exit |
If @var{program} compiles and links successfully and returns an exit |
6045 |
status of 0 when executed, run shell commands @var{action-if-true}. |
status of 0 when executed, run shell commands @var{action-if-true}. |
6046 |
Otherwise, run shell commands @var{action-if-false}. |
Otherwise, run shell commands @var{action-if-false}. |
6047 |
|
|
6048 |
This macro double quotes @var{program}, the text of a program in the |
The @var{input} can be made by @code{AC_LANG_PROGRAM} and friends. This |
6049 |
current language (@pxref{Language Choice}), on which shell variable and |
macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, |
6050 |
back quote substitutions are performed. This macro uses @code{CFLAGS} |
@code{LDFLAGS}, and @code{LIBS} |
|
or @code{CXXFLAGS}, @code{CPPFLAGS}, @code{LDFLAGS}, and @code{LIBS} |
|
|
when compiling. |
|
6051 |
|
|
6052 |
If the C compiler being used does not produce executables that run on |
If the compiler being used does not produce executables that run on the |
6053 |
the system where @command{configure} is being run, then the test program is |
system where @command{configure} is being run, then the test program is |
6054 |
not run. If the optional shell commands @var{action-if-cross-compiling} |
not run. If the optional shell commands @var{action-if-cross-compiling} |
6055 |
are given, they are run instead. Otherwise, @command{configure} prints |
are given, they are run instead. Otherwise, @command{configure} prints |
6056 |
an error message and exits. |
an error message and exits. |
6067 |
|
|
6068 |
Try to provide a pessimistic default value to use when cross-compiling |
Try to provide a pessimistic default value to use when cross-compiling |
6069 |
makes run-time tests impossible. You do this by passing the optional |
makes run-time tests impossible. You do this by passing the optional |
6070 |
last argument to @code{AC_TRY_RUN}. @command{autoconf} prints a warning |
last argument to @code{AC_RUN_IFELSE}. @command{autoconf} prints a |
6071 |
message when creating @command{configure} each time it encounters a call to |
warning message when creating @command{configure} each time it |
6072 |
@code{AC_TRY_RUN} with no @var{action-if-cross-compiling} argument |
encounters a call to @code{AC_RUN_IFELSE} with no |
6073 |
given. You may ignore the warning, though users will not be able to |
@var{action-if-cross-compiling} argument given. You may ignore the |
6074 |
configure your package for cross-compiling. A few of the macros |
warning, though users will not be able to configure your package for |
6075 |
distributed with Autoconf produce this warning message. |
cross-compiling. A few of the macros distributed with Autoconf produce |
6076 |
|
this warning message. |
6077 |
|
|
6078 |
To configure for cross-compiling you can also choose a value for those |
To configure for cross-compiling you can also choose a value for those |
6079 |
parameters based on the canonical system name (@pxref{Manual |
parameters based on the canonical system name (@pxref{Manual |
6080 |
Configuration}). Alternatively, set up a test results cache file with |
Configuration}). Alternatively, set up a test results cache file with |
6081 |
the correct values for the host system (@pxref{Caching Results}). |
the correct values for the host system (@pxref{Caching Results}). |
6082 |
|
|
6083 |
To provide a default for calls of @code{AC_TRY_RUN} that are embedded in |
To provide a default for calls of @code{AC_RUN_IFELSE} that are embedded |
6084 |
other macros, including a few of the ones that come with Autoconf, you |
in other macros, including a few of the ones that come with Autoconf, |
6085 |
can call @code{AC_PROG_CC} before running them. Then, if the shell |
you can test whether the shell variable @code{cross_compiling} is set to |
6086 |
variable @code{cross_compiling} is set to @samp{yes}, use an alternate |
@samp{yes}, and then use an alternate method to get the results instead |
6087 |
method to get the results instead of calling the macros. |
of calling the macros. |
|
|
|
6088 |
|
|
6089 |
|
|
6090 |
@node Systemology |
@node Systemology |
6156 |
AC_MSG_CHECKING([how to get file system type]) |
AC_MSG_CHECKING([how to get file system type]) |
6157 |
fstype=no |
fstype=no |
6158 |
# The order of these tests is important. |
# The order of these tests is important. |
6159 |
AC_TRY_CPP([#include <sys/statvfs.h> |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statvfs.h> |
6160 |
#include <sys/fstyp.h>], |
#include <sys/fstyp.h>]])], |
6161 |
[AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4]) |
[AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4]) |
6162 |
if test $fstype = no; then |
if test $fstype = no; then |
6163 |
AC_TRY_CPP([#include <sys/statfs.h> |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statfs.h> |
6164 |
#include <sys/fstyp.h>], |
#include <sys/fstyp.h>]])], |
6165 |
[AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3]) |
[AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3]) |
6166 |
fi |
fi |
6167 |
if test $fstype = no; then |
if test $fstype = no; then |
6168 |
AC_TRY_CPP([#include <sys/statfs.h> |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/statfs.h> |
6169 |
#include <sys/vmount.h>], |
#include <sys/vmount.h>]])]), |
6170 |
[AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX]) |
[AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX]) |
6171 |
fi |
fi |
6172 |
# (more cases omitted here) |
# (more cases omitted here) |
6173 |
AC_MSG_RESULT([$fstype]) |
AC_MSG_RESULT([$fstype]) |
7381 |
|
|
7382 |
@example |
@example |
7383 |
AC_DEFUN([INNER], |
AC_DEFUN([INNER], |
7384 |
[AC_TRY_RUN([exit (0)])]) |
[AC_RUN_IFELSE([AC_LANG_PROGRAM([exit (0)])])]) |
7385 |
|
|
7386 |
AC_DEFUN([OUTER], |
AC_DEFUN([OUTER], |
7387 |
[INNER]) |
[INNER]) |
7395 |
|
|
7396 |
@example |
@example |
7397 |
$ @kbd{autom4te -l autoconf -Wcross} |
$ @kbd{autom4te -l autoconf -Wcross} |
7398 |
configure.ac:8: warning: AC_TRY_RUN called without default \ |
configure.ac:8: warning: AC_RUN_IFELSE called without default \ |
7399 |
to allow cross compiling |
to allow cross compiling |
7400 |
$ @kbd{autom4te -l autoconf -Wcross,error} |
$ @kbd{autom4te -l autoconf -Wcross,error -f} |
7401 |
configure.ac:8: error: AC_TRY_RUN called without default \ |
configure.ac:8: error: AC_RUN_IFELSE called without default \ |
7402 |
to allow cross compiling |
to allow cross compiling |
7403 |
acgeneral.m4:3044: AC_TRY_RUN is expanded from... |
acgeneral.m4:3044: AC_RUN_IFELSE is expanded from... |
7404 |
configure.ac:2: INNER is expanded from... |
configure.ac:2: INNER is expanded from... |
7405 |
configure.ac:5: OUTER is expanded from... |
configure.ac:5: OUTER is expanded from... |
7406 |
configure.ac:8: the top level |
configure.ac:8: the top level |
7407 |
@end example |
@end example |
7408 |
|
|
7409 |
|
|
7410 |
@item --melt |
@item --melt |
7411 |
@itemx -m |
@itemx -m |
7412 |
Do not use frozen files. Any argument @code{@var{file}.m4f} will be |
Do not use frozen files. Any argument @code{@var{file}.m4f} will be |
8293 |
[ac_cv_emxos2=no])]) |
[ac_cv_emxos2=no])]) |
8294 |
@end example |
@end example |
8295 |
|
|
8296 |
When using @code{AC_TRY_RUN} or any macro that cannot work when |
When using @code{AC_RUN_IFELSE} or any macro that cannot work when |
8297 |
cross-compiling, provide a pessimistic value (typically @samp{no}). |
cross-compiling, provide a pessimistic value (typically @samp{no}). |
8298 |
|
|
8299 |
Feel free to use various tricks to prevent auxiliary tools, such as |
Feel free to use various tricks to prevent auxiliary tools, such as |
12346 |
|
|
12347 |
@defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found}, @ovar{action-if-not-found}) |
@defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found}, @ovar{action-if-not-found}) |
12348 |
@acindex COMPILE_CHECK |
@acindex COMPILE_CHECK |
12349 |
This is an obsolete version of @code{AC_TRY_COMPILE} (@pxref{Running the |
This is an obsolete version of @code{AC_TRY_COMPILE} itself replaced by |
12350 |
Compiler}), with the addition that it prints @samp{checking for |
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}), with the |
12351 |
@var{echo-text}} to the standard output first, if @var{echo-text} is |
addition that it prints @samp{checking for @var{echo-text}} to the |
12352 |
non-empty. Use @code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead |
standard output first, if @var{echo-text} is non-empty. Use |
12353 |
to print messages (@pxref{Printing Messages}). |
@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead to print |
12354 |
|
messages (@pxref{Printing Messages}). |
12355 |
@end defmac |
@end defmac |
12356 |
|
|
12357 |
@defmac AC_CONST |
@defmac AC_CONST |
12913 |
|
|
12914 |
@defmac AC_TEST_PROGRAM |
@defmac AC_TEST_PROGRAM |
12915 |
@acindex TEST_PROGRAM |
@acindex TEST_PROGRAM |
12916 |
@code{AC_TRY_RUN} |
@code{AC_TRY_RUN}, replaced with @code{AC_RUN_IFELSE}. |
12917 |
@end defmac |
@end defmac |
12918 |
|
|
12919 |
@defmac AC_TIMEZONE |
@defmac AC_TIMEZONE |
12986 |
[@var{action-if-false}])}. |
[@var{action-if-false}])}. |
12987 |
@end defmac |
@end defmac |
12988 |
|
|
12989 |
|
@defmac AC_TRY_RUN (@var{program}, @ovar{action-if-true}, @ovar{action-if-false}, @ovar{action-if-cross-compiling}) |
12990 |
|
@acindex TRY_RUN |
12991 |
|
Same as @samp{AC_RUN_IFELSE([AC_LANG_SOURCE([[@var{program}]], |
12992 |
|
[@var{action-if-true}], [@var{action-if-false}], |
12993 |
|
[@var{action-if-cross-compiling}])} (@pxref{Run Time}). |
12994 |
|
@end defmac |
12995 |
|
|
12996 |
|
|
12997 |
@defmac AC_UID_T |
@defmac AC_UID_T |
12998 |
@acindex UID_T |
@acindex UID_T |
12999 |
@code{AC_TYPE_UID_T} |
@code{AC_TYPE_UID_T} |