diff --git a/NEWS b/NEWS index 26fdb0c2..3134b8c1 100644 --- a/NEWS +++ b/NEWS @@ -49,8 +49,10 @@ Major changes in release 2.0: execute on success. * AC_REMOTE_TAPE and AC_RSH removed; too specific to tar and cpio, and better maintained with them. +* AC_ARG_ARRAY removed because no one was likely using it. * AC_HAVE_POUNDBANG replaced with AC_SYS_INTERPRETER, which doesn't take arguments. +* Checking for C functions in C++ works. ** New utilities: * autoscan to generate a preliminary configure.in for a package by diff --git a/TODO b/TODO index c074f671..736eea57 100644 --- a/TODO +++ b/TODO @@ -96,11 +96,8 @@ in a dnl comment. (Seems to be hard.) ------------------------------------------------------------------------------ -* Prototypes and IEEE math contributed macros. - ------------------------------------------------------------------------------- - -* Functions to check for C++ functions, or C functions under C++. +* Look at user contributed macros: prototypes, IEEE double precision math, +shared libraries, various other things. ------------------------------------------------------------------------------ diff --git a/acconfig.h b/acconfig.h index 939be7b8..f0757865 100644 --- a/acconfig.h +++ b/acconfig.h @@ -170,10 +170,6 @@ /* Define if you have . */ #undef NLIST_STRUCT -/* Define if you can't use the address of an argument to a function - as the start of an array. */ -#undef NO_ARG_ARRAY - /* Define if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O diff --git a/acgeneral.m4 b/acgeneral.m4 index bd955063..c2eb678e 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -35,7 +35,7 @@ Install it before installing Autoconf or set the M4 environment variable to its path name. )m4exit(2)])dnl dnl -define(AC_ACVERSION, 1.103)dnl +define(AC_ACVERSION, 1.104)dnl dnl This is defined by the --version option of the autoconf script. ifdef([AC_PRINT_VERSION], [Autoconf version AC_ACVERSION m4exit(0)])dnl @@ -84,9 +84,7 @@ ac_help=])dnl dnl dnl AC_INIT_PARSE_ARGS() AC_DEFUN(AC_INIT_PARSE_ARGS, -[AC_BEFORE([$0], [AC_ARG_ENABLE])dnl -AC_BEFORE([$0], [AC_ARG_WITH])dnl -# Save the original args to write them into config.status later. +[# Save the original args to write them into config.status later. configure_args="[$]@" # Omit some internal, obsolete, or unimplemented options to make the @@ -381,13 +379,7 @@ divert(AC_DIVERSION_NORMAL)dnl dnl dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR) AC_DEFUN(AC_INIT_PREPARE, -[AC_BEFORE([$0], [AC_ARG_ENABLE])dnl -AC_BEFORE([$0], [AC_ARG_WITH])dnl -AC_BEFORE([$0], [AC_CONFIG_HEADER])dnl -AC_BEFORE([$0], [AC_REVISION])dnl -AC_BEFORE([$0], [AC_PREREQ])dnl -dnl AC_BEFORE([$0], [AC_CONFIG_SUBDIRS])dnl -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 +[trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 trap 'rm -fr confdefs* $ac_clean_files' 0 # File descriptor usage: @@ -1139,12 +1131,15 @@ dnl dnl AC_TRY_LINK(INCLUDES, FUNCTION-BODY, dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) AC_DEFUN(AC_TRY_LINK, -[dnl We use return because because C++ requires a prototype for exit. -cat > conftest.${ac_ext} < conftest.${ac_ext} < conftest.${ac_ext} < -#include +# include +# include #endif #ifdef HAVE_DIRENT_H # include # define NAMLEN(dirent) (strlen((dirent)->d_name)) -#else /* !HAVE_DIRENT_H */ +#else # define dirent direct # define NAMLEN(dirent) ((dirent)->d_namlen) # ifdef HAVE_SYS_NDIR_H # include -# endif /* HAVE_SYS_NDIR_H */ +# endif # ifdef HAVE_SYS_DIR_H # include -# endif /* HAVE_SYS_DIR_H */ +# endif # ifdef HAVE_NDIR_H # include -# endif /* HAVE_NDIR_H */ -#endif /* !HAVE_DIRENT_H */ +# endif +#endif @end group @end example @@ -1024,15 +1024,14 @@ Then, in the code, use a test like this: @example @group +/* memory.h might conflict with an ANSI string.h, or strings.h. */ #if STDC_HEADERS || HAVE_STRING_H # include -/* An ANSI string.h and pre-ANSI memory.h might conflict. */ # if !STDC_HEADERS && HAVE_MEMORY_H # include -# endif /* not STDC_HEADERS and HAVE_MEMORY_H */ -#else /* not STDC_HEADERS and not HAVE_STRING_H */ +# endif +#else # include -/* memory.h and strings.h conflict on some systems. */ # ifndef strchr # define strchr index # endif @@ -1045,7 +1044,7 @@ Then, in the code, use a test like this: # ifndef memcmp # define memcmp(s1, s2, n) bcmp ((s1), (s2), (n)) # endif -#endif /* not STDC_HEADERS and not HAVE_STRING_H */ +#endif @end group @end example @@ -1424,15 +1423,6 @@ macro calls @code{AC_STRUCT_TM} if it hasn't been called already. The following macros check for C compiler or machine architecture features: -@defmac AC_C_ARG_ARRAY -@maindex C_ARG_ARRAY -@cvindex NO_ARG_ARRAY -If the address of an argument to a C function can not be used like -the start of an array, define @code{NO_ARG_ARRAY}. This ability allows -a sequence of arguments with the same type to be accessed as if they -were an array of values. -@end defmac - @defmac AC_C_BIGENDIAN @maindex C_BIGENDIAN @cvindex WORDS_BIGENDIAN @@ -1991,7 +1981,8 @@ macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, backquote substitutions are performed. If it compiles and links successfully and returns an exit status of 0 when executed, run shell commands @var{action-if-true}. Otherwise run shell commands -@var{action-if-false}. This macro uses @code{CFLAGS} or +@var{action-if-false}; the exit status of the program is available in +the shell variable @samp{$?}. This macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, @code{LDFLAGS}, and @code{LIBS} when compiling. @@ -2015,12 +2006,15 @@ future use (@pxref{Caching Values}, for more information). @defmac AC_CHECK_FUNC (@var{function}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) @maindex CHECK_FUNC -If @var{function} is available, run shell commands +If C function @var{function} is available, run shell commands @var{action-if-found}, otherwise @var{action-if-not-found}. If the functions might be in libraries other than the default C library, first call @code{AC_CHECK_LIB} for those libraries. If you just want to define a symbol if the function is available, consider using -@code{AC_CHECK_FUNCS} instead. +@code{AC_CHECK_FUNCS} instead. This macro checks for functions with C +linkage even when @code{AC_LANG_CPLUSPLUS} has been called, since C++ is +more standardized than C is. (@pxref{Language Choice}, for more +information about selecting the language for checks.) @end defmac @defmac AC_CHECK_FUNCS (@var{function}@dots{} @r{[}, @var{action}@r{]}) @@ -2983,13 +2977,23 @@ tests impossible. You do this by passing the optional last argument to @node Guidelines, Tricks, , Test Programs @subsection Guidelines for Test Programs -Test programs should return 0 if the test succeeds, nonzero otherwise, -so that success can be distinguished easily from a core dump or other -failure; segmentation violations and other failures produce a nonzero -exit status. Test programs should @code{exit}, not @code{return}, from -@code{main}, because on some systems the argument to @code{return} in -@code{main} is ignored. They should not write anything to the standard -output. +Test programs should not write anything to the standard output. They +should return 0 if the test succeeds, nonzero otherwise, so that success +can be distinguished easily from a core dump or other failure; +segmentation violations and other failures produce a nonzero exit +status. Test programs should @code{exit}, not @code{return}, from +@code{main}, because on some systems (old Suns, at least) the argument +to @code{return} in @code{main} is ignored. Functions that take +arguments should have a prototype conditionalized for C++. In practice, +test programs rarely need functions that take arguments. + +@example +#ifdef __cplusplus +foo(int i) +#else +foo(i) int i; +#endif +@end example Test programs can use @code{#if} or @code{#ifdef} to check the values of preprocessor macros defined by tests that have already run. For @@ -3108,11 +3112,13 @@ By default, configure uses @file{./config.cache} as the cache file, creating it if it does not exist already. @code{configure} accepts the @samp{--cache-file=@var{file}} option to use a different cache file; that is what @code{configure} does when it calls @code{configure} -scripts in subdirectories, so they share the cache. @xref{Setup}, for -information on configuring subdirectories with the -@code{AC_CONFIG_SUBDIRS} macro. @file{config.status} only pays -attention to the cache file if it is given the @samp{--recheck} option, -which makes it rerun @code{configure}. +scripts in subdirectories, so they share the cache. Giving +@samp{--cache-file=/dev/null} disables caching, for debugging +@code{configure}. @xref{Setup}, for information on configuring +subdirectories with the @code{AC_CONFIG_SUBDIRS} macro. +@file{config.status} only pays attention to the cache file if it is +given the @samp{--recheck} option, which makes it rerun +@code{configure}. It is wrong to try to distribute cache files for particular system types. There is too much room for error in doing that, and too much @@ -3349,6 +3355,7 @@ stamp-h.in: configure.in aclocal.m4 acconfig.h config.h.top config.h.bot # config.status might not change config.h # Don't rerun config.status if we just configured. +# Use || so the command line always returns success. config.h: stamp-h stamp-h: config.h.in config.status test ! -f stamp-h || ./config.status @@ -3543,7 +3550,7 @@ for backward compatibility, the old names are considered obsolete. @code{AC_FUNC_ALLOCA} @item AC_ARG_ARRAY @maindex ARG_ARRAY -@code{AC_C_ARG_ARRAY} +removed because of limited usefulness @item AC_CHAR_UNSIGNED @maindex CHAR_UNSIGNED @code{AC_C_CHAR_UNSIGNED} diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 01d0f9fc..34c5803d 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -6,8 +6,8 @@ @c @setchapternewpage odd @c %**end of header -@set EDITION 1.103 -@set VERSION 1.103 +@set EDITION 1.104 +@set VERSION 1.104 @set UPDATED August 1994 @iftex @@ -954,26 +954,26 @@ something like the following, which assumes that you have also called @example @group #ifdef HAVE_UNISTD_H -#include -#include +# include +# include #endif #ifdef HAVE_DIRENT_H # include # define NAMLEN(dirent) (strlen((dirent)->d_name)) -#else /* !HAVE_DIRENT_H */ +#else # define dirent direct # define NAMLEN(dirent) ((dirent)->d_namlen) # ifdef HAVE_SYS_NDIR_H # include -# endif /* HAVE_SYS_NDIR_H */ +# endif # ifdef HAVE_SYS_DIR_H # include -# endif /* HAVE_SYS_DIR_H */ +# endif # ifdef HAVE_NDIR_H # include -# endif /* HAVE_NDIR_H */ -#endif /* !HAVE_DIRENT_H */ +# endif +#endif @end group @end example @@ -1024,15 +1024,14 @@ Then, in the code, use a test like this: @example @group +/* memory.h might conflict with an ANSI string.h, or strings.h. */ #if STDC_HEADERS || HAVE_STRING_H # include -/* An ANSI string.h and pre-ANSI memory.h might conflict. */ # if !STDC_HEADERS && HAVE_MEMORY_H # include -# endif /* not STDC_HEADERS and HAVE_MEMORY_H */ -#else /* not STDC_HEADERS and not HAVE_STRING_H */ +# endif +#else # include -/* memory.h and strings.h conflict on some systems. */ # ifndef strchr # define strchr index # endif @@ -1045,7 +1044,7 @@ Then, in the code, use a test like this: # ifndef memcmp # define memcmp(s1, s2, n) bcmp ((s1), (s2), (n)) # endif -#endif /* not STDC_HEADERS and not HAVE_STRING_H */ +#endif @end group @end example @@ -1424,15 +1423,6 @@ macro calls @code{AC_STRUCT_TM} if it hasn't been called already. The following macros check for C compiler or machine architecture features: -@defmac AC_C_ARG_ARRAY -@maindex C_ARG_ARRAY -@cvindex NO_ARG_ARRAY -If the address of an argument to a C function can not be used like -the start of an array, define @code{NO_ARG_ARRAY}. This ability allows -a sequence of arguments with the same type to be accessed as if they -were an array of values. -@end defmac - @defmac AC_C_BIGENDIAN @maindex C_BIGENDIAN @cvindex WORDS_BIGENDIAN @@ -1991,7 +1981,8 @@ macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, backquote substitutions are performed. If it compiles and links successfully and returns an exit status of 0 when executed, run shell commands @var{action-if-true}. Otherwise run shell commands -@var{action-if-false}. This macro uses @code{CFLAGS} or +@var{action-if-false}; the exit status of the program is available in +the shell variable @samp{$?}. This macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, @code{LDFLAGS}, and @code{LIBS} when compiling. @@ -2015,12 +2006,15 @@ future use (@pxref{Caching Values}, for more information). @defmac AC_CHECK_FUNC (@var{function}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) @maindex CHECK_FUNC -If @var{function} is available, run shell commands +If C function @var{function} is available, run shell commands @var{action-if-found}, otherwise @var{action-if-not-found}. If the functions might be in libraries other than the default C library, first call @code{AC_CHECK_LIB} for those libraries. If you just want to define a symbol if the function is available, consider using -@code{AC_CHECK_FUNCS} instead. +@code{AC_CHECK_FUNCS} instead. This macro checks for functions with C +linkage even when @code{AC_LANG_CPLUSPLUS} has been called, since C++ is +more standardized than C is. (@pxref{Language Choice}, for more +information about selecting the language for checks.) @end defmac @defmac AC_CHECK_FUNCS (@var{function}@dots{} @r{[}, @var{action}@r{]}) @@ -2983,13 +2977,23 @@ tests impossible. You do this by passing the optional last argument to @node Guidelines, Tricks, , Test Programs @subsection Guidelines for Test Programs -Test programs should return 0 if the test succeeds, nonzero otherwise, -so that success can be distinguished easily from a core dump or other -failure; segmentation violations and other failures produce a nonzero -exit status. Test programs should @code{exit}, not @code{return}, from -@code{main}, because on some systems the argument to @code{return} in -@code{main} is ignored. They should not write anything to the standard -output. +Test programs should not write anything to the standard output. They +should return 0 if the test succeeds, nonzero otherwise, so that success +can be distinguished easily from a core dump or other failure; +segmentation violations and other failures produce a nonzero exit +status. Test programs should @code{exit}, not @code{return}, from +@code{main}, because on some systems (old Suns, at least) the argument +to @code{return} in @code{main} is ignored. Functions that take +arguments should have a prototype conditionalized for C++. In practice, +test programs rarely need functions that take arguments. + +@example +#ifdef __cplusplus +foo(int i) +#else +foo(i) int i; +#endif +@end example Test programs can use @code{#if} or @code{#ifdef} to check the values of preprocessor macros defined by tests that have already run. For @@ -3108,11 +3112,13 @@ By default, configure uses @file{./config.cache} as the cache file, creating it if it does not exist already. @code{configure} accepts the @samp{--cache-file=@var{file}} option to use a different cache file; that is what @code{configure} does when it calls @code{configure} -scripts in subdirectories, so they share the cache. @xref{Setup}, for -information on configuring subdirectories with the -@code{AC_CONFIG_SUBDIRS} macro. @file{config.status} only pays -attention to the cache file if it is given the @samp{--recheck} option, -which makes it rerun @code{configure}. +scripts in subdirectories, so they share the cache. Giving +@samp{--cache-file=/dev/null} disables caching, for debugging +@code{configure}. @xref{Setup}, for information on configuring +subdirectories with the @code{AC_CONFIG_SUBDIRS} macro. +@file{config.status} only pays attention to the cache file if it is +given the @samp{--recheck} option, which makes it rerun +@code{configure}. It is wrong to try to distribute cache files for particular system types. There is too much room for error in doing that, and too much @@ -3349,6 +3355,7 @@ stamp-h.in: configure.in aclocal.m4 acconfig.h config.h.top config.h.bot # config.status might not change config.h # Don't rerun config.status if we just configured. +# Use || so the command line always returns success. config.h: stamp-h stamp-h: config.h.in config.status test ! -f stamp-h || ./config.status @@ -3543,7 +3550,7 @@ for backward compatibility, the old names are considered obsolete. @code{AC_FUNC_ALLOCA} @item AC_ARG_ARRAY @maindex ARG_ARRAY -@code{AC_C_ARG_ARRAY} +removed because of limited usefulness @item AC_CHAR_UNSIGNED @maindex CHAR_UNSIGNED @code{AC_C_CHAR_UNSIGNED} diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index bd955063..c2eb678e 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -35,7 +35,7 @@ Install it before installing Autoconf or set the M4 environment variable to its path name. )m4exit(2)])dnl dnl -define(AC_ACVERSION, 1.103)dnl +define(AC_ACVERSION, 1.104)dnl dnl This is defined by the --version option of the autoconf script. ifdef([AC_PRINT_VERSION], [Autoconf version AC_ACVERSION m4exit(0)])dnl @@ -84,9 +84,7 @@ ac_help=])dnl dnl dnl AC_INIT_PARSE_ARGS() AC_DEFUN(AC_INIT_PARSE_ARGS, -[AC_BEFORE([$0], [AC_ARG_ENABLE])dnl -AC_BEFORE([$0], [AC_ARG_WITH])dnl -# Save the original args to write them into config.status later. +[# Save the original args to write them into config.status later. configure_args="[$]@" # Omit some internal, obsolete, or unimplemented options to make the @@ -381,13 +379,7 @@ divert(AC_DIVERSION_NORMAL)dnl dnl dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR) AC_DEFUN(AC_INIT_PREPARE, -[AC_BEFORE([$0], [AC_ARG_ENABLE])dnl -AC_BEFORE([$0], [AC_ARG_WITH])dnl -AC_BEFORE([$0], [AC_CONFIG_HEADER])dnl -AC_BEFORE([$0], [AC_REVISION])dnl -AC_BEFORE([$0], [AC_PREREQ])dnl -dnl AC_BEFORE([$0], [AC_CONFIG_SUBDIRS])dnl -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 +[trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 trap 'rm -fr confdefs* $ac_clean_files' 0 # File descriptor usage: @@ -1139,12 +1131,15 @@ dnl dnl AC_TRY_LINK(INCLUDES, FUNCTION-BODY, dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) AC_DEFUN(AC_TRY_LINK, -[dnl We use return because because C++ requires a prototype for exit. -cat > conftest.${ac_ext} < conftest.${ac_ext} < conftest.${ac_ext} <