dnl AC_COMPILE_CHECK(ECHO-TEXT, INCLUDES, FUNCTION-BODY,
dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_COMPILE_CHECK,
-[AC_OBSOLETE([$0], [; instead use AC_TRY_COMPILE or AC_TRY_LINK])dnl
+[AC_OBSOLETE([$0], [; instead use AC_TRY_COMPILE or AC_TRY_LINK, and AC_MSG_CHECKING and AC_MSG_RESULT])dnl
ifelse([$1], , , [AC_CHECKING([for $1])
])dnl
AC_TRY_LINK([$2], [$3], [$4], [$5])dnl
[AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_func_$1,
[AC_TRY_LINK(
-[#include <ctype.h> /* Arbitrary system header to define __stub macros. */], [
+[#include <ctype.h> /* Arbitrary system header to define __stub macros. */
+/* Override any gcc2 internal prototype to avoid an error. */
+]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
+extern "C"
+#endif
+])dnl
+[char $1();
+], [
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$1) || defined (__stub___$1)
choke me
#else
-/* Override any gcc2 internal prototype to avoid an error. */
-]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])dnl
-[char $1(); $1();
+$1();
#endif
], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")])dnl
if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
@end group
@end display
+It is best to put each macro call on its own line in
+@file{configure.in}. Most of the macros don't add extra newlines; they
+rely on the newline after the macro call to terminate the commands.
+This approach makes the generated @code{configure} script a little
+easier to read by not inserting lots of blank lines. It is generally
+safe to set shell variables on the same line as a macro call, because
+the shell allows assignments without intervening newlines.
+
When calling macros that take arguments, there must not be any blank
space between the macro name and the open parenthesis. Arguments can be
more than one line long if they are enclosed within the @code{m4} quote
speed. Instead of @file{install-sh}, it can also use @file{install.sh},
but that name is obsolete because some @code{make} programs have a rule
that creates @file{install} from it if there is no @file{Makefile}.
+A copy of @file{install-sh} which you may use comes with Autoconf.
If you need to use your own installation program because it has
features not found in standard @code{install} programs, there is no
@node Particular Typedefs, Generic Typedefs, , Typedefs
@subsection Particular Typedef Checks
-These macros check for particular C typedefs.
+These macros check for particular C typedefs in @file{sys/types.h} and
+@file{stdlib.h} (if it exists).
@defmac AC_TYPE_GETGROUPS
@maindex TYPE_GETGROUPS
@defmac AC_TYPE_MODE_T
@maindex TYPE_MODE_T
@cvindex mode_t
-If @code{mode_t} is not defined in @file{sys/types.h}, define
-@code{mode_t} to be @code{int}.
+If @code{mode_t} is not defined, define @code{mode_t} to be @code{int}.
@end defmac
@defmac AC_TYPE_OFF_T
@maindex TYPE_OFF_T
@cvindex off_t
-If @code{off_t} is not defined in @file{sys/types.h}, define
-@code{off_t} to be @code{long}.
+If @code{off_t} is not defined, define @code{off_t} to be @code{long}.
@end defmac
@defmac AC_TYPE_PID_T
@maindex TYPE_PID_T
@cvindex pid_t
-If @code{pid_t} is not defined in @file{sys/types.h}, define
-@code{pid_t} to be @code{int}.
+If @code{pid_t} is not defined, define @code{pid_t} to be @code{int}.
@end defmac
@defmac AC_TYPE_SIGNAL
@defmac AC_TYPE_SIZE_T
@maindex TYPE_SIZE_T
@cvindex size_t
-If @code{size_t} is not defined in @file{sys/types.h}, define
-@code{size_t} to be @code{unsigned}.
+If @code{size_t} is not defined, define @code{size_t} to be
+@code{unsigned}.
@end defmac
@defmac AC_TYPE_UID_T
@maindex TYPE_UID_T
@cvindex uid_t
@cvindex gid_t
-If @code{uid_t} is not defined in @file{sys/types.h}, define
-@code{uid_t} to be @code{int} and @code{gid_t} to be @code{int}.
+If @code{uid_t} is not defined, define @code{uid_t} to be @code{int} and
+@code{gid_t} to be @code{int}.
@end defmac
@node Generic Typedefs, , Particular Typedefs, Typedefs
@defmac AC_CHECK_TYPE (@var{type}, @var{default})
@maindex CHECK_TYPE
If the type @var{type} is not defined in @file{sys/types.h} or
-@file{stdlib.h} (if that is present), define it to be the C (or C++)
+@file{stdlib.h} (if it exists), define it to be the C (or C++)
builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}.
@end defmac
@maindex COMPILE_CHECK
This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it
prints @samp{checking for @var{echo-text}} to the standard output first,
-if @var{echo-text} is non-empty.
+if @var{echo-text} is non-empty. Use @code{AC_MSG_CHECKING} and
+@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}).
@end defmac
@node Run Time, Portable Shell, Examining Libraries, Writing Tests
Below are instructions on how to configure a package that uses a
@code{configure} script, suitable for inclusion as an @file{INSTALL}
-file in the package.
+file in the package. A plain-text version of @file{INSTALL} which you
+may use comes with Autoconf.
@menu
* Basic Installation:: Instructions for typical cases.
Some macros have been superseded by similar ones that do the job better,
but are not call-compatible. If you get warnings about calling obsolete
-macros while running @code{autoconf}, you may safely ignore them, but your
-@code{configure} script will generally work better if you follow the
-advice it prints about what to replace the obsolete macros with. In
+macros while running @code{autoconf}, you may safely ignore them, but
+your @code{configure} script will generally work better if you follow
+the advice it prints about what to replace the obsolete macros with. In
particular, the mechanism for reporting the results of tests has
-changed. If you were using @code{echo} or @code{AC_VERBOSE}, your
-@code{configure} script's output will look better if you switch to
-@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT}. @xref{Printing
-Messages}. Those macros work best in conjunction with cache variables.
-@xref{Caching Results}.
+changed. If you were using @code{echo} or @code{AC_VERBOSE} (perhaps
+via @code{AC_COMPILE_CHECK}), your @code{configure} script's output will
+look better if you switch to @code{AC_MSG_CHECKING} and
+@code{AC_MSG_RESULT}. @xref{Printing Messages}. Those macros work best
+in conjunction with cache variables. @xref{Caching Results}.
@node Invoking autoupdate, Changed Results, Changed Macros, Upgrading
@section Using @code{autoupdate} to Modernize @code{configure}
}
print CONF "\ndnl Checks for libraries.\n";
foreach $word (sort keys %libraries) {
- print CONF "AC_HAVE_LIBRARY($word)\n";
+ print CONF "dnl Replace `\main\' with a function in -l$word:\n";
+ print CONF "AC_CHECK_LIB($word, main)\n";
}
}
}
print CONF "\ndnl Checks for libraries.\n";
foreach $word (sort keys %libraries) {
- print CONF "AC_HAVE_LIBRARY($word)\n";
+ print CONF "dnl Replace `\main\' with a function in -l$word:\n";
+ print CONF "AC_CHECK_LIB($word, main)\n";
}
}
}
print CONF "\ndnl Checks for libraries.\n";
foreach $word (sort keys %libraries) {
- print CONF "AC_HAVE_LIBRARY($word)\n";
+ print CONF "dnl Replace `\main\' with a function in -l$word:\n";
+ print CONF "AC_CHECK_LIB($word, main)\n";
}
}
@end group
@end display
+It is best to put each macro call on its own line in
+@file{configure.in}. Most of the macros don't add extra newlines; they
+rely on the newline after the macro call to terminate the commands.
+This approach makes the generated @code{configure} script a little
+easier to read by not inserting lots of blank lines. It is generally
+safe to set shell variables on the same line as a macro call, because
+the shell allows assignments without intervening newlines.
+
When calling macros that take arguments, there must not be any blank
space between the macro name and the open parenthesis. Arguments can be
more than one line long if they are enclosed within the @code{m4} quote
speed. Instead of @file{install-sh}, it can also use @file{install.sh},
but that name is obsolete because some @code{make} programs have a rule
that creates @file{install} from it if there is no @file{Makefile}.
+A copy of @file{install-sh} which you may use comes with Autoconf.
If you need to use your own installation program because it has
features not found in standard @code{install} programs, there is no
@node Particular Typedefs, Generic Typedefs, , Typedefs
@subsection Particular Typedef Checks
-These macros check for particular C typedefs.
+These macros check for particular C typedefs in @file{sys/types.h} and
+@file{stdlib.h} (if it exists).
@defmac AC_TYPE_GETGROUPS
@maindex TYPE_GETGROUPS
@defmac AC_TYPE_MODE_T
@maindex TYPE_MODE_T
@cvindex mode_t
-If @code{mode_t} is not defined in @file{sys/types.h}, define
-@code{mode_t} to be @code{int}.
+If @code{mode_t} is not defined, define @code{mode_t} to be @code{int}.
@end defmac
@defmac AC_TYPE_OFF_T
@maindex TYPE_OFF_T
@cvindex off_t
-If @code{off_t} is not defined in @file{sys/types.h}, define
-@code{off_t} to be @code{long}.
+If @code{off_t} is not defined, define @code{off_t} to be @code{long}.
@end defmac
@defmac AC_TYPE_PID_T
@maindex TYPE_PID_T
@cvindex pid_t
-If @code{pid_t} is not defined in @file{sys/types.h}, define
-@code{pid_t} to be @code{int}.
+If @code{pid_t} is not defined, define @code{pid_t} to be @code{int}.
@end defmac
@defmac AC_TYPE_SIGNAL
@defmac AC_TYPE_SIZE_T
@maindex TYPE_SIZE_T
@cvindex size_t
-If @code{size_t} is not defined in @file{sys/types.h}, define
-@code{size_t} to be @code{unsigned}.
+If @code{size_t} is not defined, define @code{size_t} to be
+@code{unsigned}.
@end defmac
@defmac AC_TYPE_UID_T
@maindex TYPE_UID_T
@cvindex uid_t
@cvindex gid_t
-If @code{uid_t} is not defined in @file{sys/types.h}, define
-@code{uid_t} to be @code{int} and @code{gid_t} to be @code{int}.
+If @code{uid_t} is not defined, define @code{uid_t} to be @code{int} and
+@code{gid_t} to be @code{int}.
@end defmac
@node Generic Typedefs, , Particular Typedefs, Typedefs
@defmac AC_CHECK_TYPE (@var{type}, @var{default})
@maindex CHECK_TYPE
If the type @var{type} is not defined in @file{sys/types.h} or
-@file{stdlib.h} (if that is present), define it to be the C (or C++)
+@file{stdlib.h} (if it exists), define it to be the C (or C++)
builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}.
@end defmac
@maindex COMPILE_CHECK
This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it
prints @samp{checking for @var{echo-text}} to the standard output first,
-if @var{echo-text} is non-empty.
+if @var{echo-text} is non-empty. Use @code{AC_MSG_CHECKING} and
+@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}).
@end defmac
@node Run Time, Portable Shell, Examining Libraries, Writing Tests
Below are instructions on how to configure a package that uses a
@code{configure} script, suitable for inclusion as an @file{INSTALL}
-file in the package.
+file in the package. A plain-text version of @file{INSTALL} which you
+may use comes with Autoconf.
@menu
* Basic Installation:: Instructions for typical cases.
Some macros have been superseded by similar ones that do the job better,
but are not call-compatible. If you get warnings about calling obsolete
-macros while running @code{autoconf}, you may safely ignore them, but your
-@code{configure} script will generally work better if you follow the
-advice it prints about what to replace the obsolete macros with. In
+macros while running @code{autoconf}, you may safely ignore them, but
+your @code{configure} script will generally work better if you follow
+the advice it prints about what to replace the obsolete macros with. In
particular, the mechanism for reporting the results of tests has
-changed. If you were using @code{echo} or @code{AC_VERBOSE}, your
-@code{configure} script's output will look better if you switch to
-@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT}. @xref{Printing
-Messages}. Those macros work best in conjunction with cache variables.
-@xref{Caching Results}.
+changed. If you were using @code{echo} or @code{AC_VERBOSE} (perhaps
+via @code{AC_COMPILE_CHECK}), your @code{configure} script's output will
+look better if you switch to @code{AC_MSG_CHECKING} and
+@code{AC_MSG_RESULT}. @xref{Printing Messages}. Those macros work best
+in conjunction with cache variables. @xref{Caching Results}.
@node Invoking autoupdate, Changed Results, Changed Macros, Upgrading
@section Using @code{autoupdate} to Modernize @code{configure}
dnl AC_COMPILE_CHECK(ECHO-TEXT, INCLUDES, FUNCTION-BODY,
dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_COMPILE_CHECK,
-[AC_OBSOLETE([$0], [; instead use AC_TRY_COMPILE or AC_TRY_LINK])dnl
+[AC_OBSOLETE([$0], [; instead use AC_TRY_COMPILE or AC_TRY_LINK, and AC_MSG_CHECKING and AC_MSG_RESULT])dnl
ifelse([$1], , , [AC_CHECKING([for $1])
])dnl
AC_TRY_LINK([$2], [$3], [$4], [$5])dnl
[AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_func_$1,
[AC_TRY_LINK(
-[#include <ctype.h> /* Arbitrary system header to define __stub macros. */], [
+[#include <ctype.h> /* Arbitrary system header to define __stub macros. */
+/* Override any gcc2 internal prototype to avoid an error. */
+]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
+extern "C"
+#endif
+])dnl
+[char $1();
+], [
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$1) || defined (__stub___$1)
choke me
#else
-/* Override any gcc2 internal prototype to avoid an error. */
-]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])dnl
-[char $1(); $1();
+$1();
#endif
], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")])dnl
if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then