From c979e7622ffaeddebf6e4914c90d3fb74da8f26c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 10 Feb 2000 08:42:26 +0000 Subject: [PATCH] Restore AC_HAVE_LIBRARY. * acgeneral.m4 (AC_HAVE_LIBRARY): AU_DEFUNed in terms of AC_CHECK_LIB. * doc/autoconf.texi (Libraries): Document. --- ChangeLog | 8 ++++++++ TODO | 45 ----------------------------------------- acgeneral.m4 | 22 +++++++++++++++++--- autoconf.texi | 20 ++++++++++-------- doc/autoconf.texi | 20 ++++++++++-------- lib/autoconf/general.m4 | 22 +++++++++++++++++--- 6 files changed, 70 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb08601f..4cf6ba6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2000-02-10 Akim Demaille + + Restore AC_HAVE_LIBRARY. + + * acgeneral.m4 (AC_HAVE_LIBRARY): AU_DEFUNed in terms of + AC_CHECK_LIB. + * doc/autoconf.texi (Libraries): Document. + 2000-02-09 Akim Demaille Fix the handling of `./configure foo=bar' and test it. diff --git a/TODO b/TODO index 227d96ca..201d572e 100644 --- a/TODO +++ b/TODO @@ -13,51 +13,6 @@ These are things mandatory to fulfill before releasing 2.15. There are also suggestions we should either satisfy right now (they're easy), or remove (obsoleted since then). -** Check my definition of AC_HAVE_LIBRARY -The original definition was: - - dnl AC_HAVE_LIBRARY(LIBRARY, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND - dnl [, OTHER-LIBRARIES]]]) - AC_DEFUN(AC_HAVE_LIBRARY, - [AC_OBSOLETE([$0], [; instead use AC_CHECK_LIB])dnl - changequote(<<, >>)dnl - define(<>, dnl - patsubst(patsubst($1, <>, <<\1>>), <<-l>>, <<>>))dnl - define(<>, ac_cv_lib_<<>>AC_LIB_NAME)dnl - changequote([, ])dnl - AC_MSG_CHECKING([for -l[]AC_LIB_NAME]) - AC_CACHE_VAL(AC_CV_NAME, - [ac_save_LIBS="$LIBS" - LIBS="-l[]AC_LIB_NAME[] $4 $LIBS" - AC_TRY_LINK( , [main()], AC_CV_NAME=yes, AC_CV_NAME=no) - LIBS="$ac_save_LIBS" - ])dnl - AC_MSG_RESULT($AC_CV_NAME) - if test "$AC_CV_NAME" = yes; then - ifelse([$2], , - [AC_DEFINE([HAVE_LIB]translit(AC_LIB_NAME, [a-z], [A-Z])) - LIBS="-l[]AC_LIB_NAME[] $LIBS" - ], [$2]) - ifelse([$3], , , [else - $3 - ])dnl - fi - undefine([AC_LIB_NAME])dnl - undefine([AC_CV_NAME])dnl - ]) - -I used this: - - AU_DEFUN(AC_HAVE_LIBRARY, - [pushdef([AC_LIB_NAME], - patsubst(patsubst([[$1]], [lib\([^\.]*\)\.a], [\1]), [-l], []))dnl - AC_CHECK_LIB(AC_LIB_NAME, main, [$2], [$3], [$4])dnl - popdef([AC_LIB_NAME])dnl - ]) - -The only difference I see is the name of the cache var, which we can -easily reflect at the end, but do we want that? - ** AU_ Document. diff --git a/acgeneral.m4 b/acgeneral.m4 index 976b150a..f9a34c4e 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -2259,6 +2259,7 @@ fi rm -fr conftest*]) + ## ------------------------ ## ## Checking for libraries. ## ## ------------------------ ## @@ -2357,9 +2358,24 @@ AC_VAR_POPDEF([ac_Lib])dnl -# AC_HAVE_LIBRARY -# --------------- -AC_DEFUNCT(AC_HAVE_LIBRARY, [; instead use AC_CHECK_LIB]) +# AC_HAVE_LIBRARY(LIBRARY, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [OTHER-LIBRARIES]) +# --------------------------------------------------------- +# +# This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION +# argument of `main'. In addition, LIBRARY can be written as any of +# `foo', `-lfoo', or `libfoo.a'. In all of those cases, the compiler +# is passed `-lfoo'. However, LIBRARY cannot be a shell variable; +# it must be a literal name. +AU_DEFUN(AC_HAVE_LIBRARY, +[pushdef([AC_Lib_Name], + patsubst(patsubst([[$1]], [lib\([^\.]*\)\.a], [\1]), [-l], []))dnl +AC_CHECK_LIB(AC_Lib_Name, main, [$2], [$3], [$4])dnl +ac_cv_lib_[]AC_Lib_Name()=ac_cv_lib_[]AC_Lib_Name()_main +popdef([AC_Lib_Name])dnl +]) + ## ------------------------ ## diff --git a/autoconf.texi b/autoconf.texi index 41791d09..201085e1 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -3334,6 +3334,7 @@ If words are stored with the most significant byte first (like Motorola and SPARC, but not Intel and VAX, CPUs), define @code{WORDS_BIGENDIAN}. @end defmac + @defmac AC_C_CONST @maindex C_CONST @cvindex const @@ -3345,17 +3346,20 @@ can simply use @code{const} as if every C compiler supported it; for those that don't, the @file{Makefile} or configuration header file will define it as empty. -If ever you happen to have the sad idea to use a C++ compiler for -@samp{CC}, this test will @strong{not} test the validity of -@code{const}, and will trust it. The main difference between C and C++ -is that C++ does not allow to define a @code{const} variable without -initializer: +Occasionally installers use a C++ compiler to compile C code, typically +because they lack a C compiler. This causes problems with @code{const}, +because C and C++ treat @code{const} differently. For example: @example const int foo; @end example -while ANSI C supports this. After long debates, it has been decided to -trust the @code{const} of C++ compilers in all the cases, even if it is -not ANSI C conforming. +is valid in C but not in C++. These differences unfortunately cannot be +papered over by defining @code{const} to be empty. + +If @code{autoconf} detects this situation, it leaves @code{const} alone, +as this generally yields better results in practice. However, using a +C++ compiler to compile C code is not recommended or supported, and +installers who run into trouble in this area should get a C compiler +like GCC to compile their C code. @end defmac @defmac AC_C_VOLATILE diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 41791d09..201085e1 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -3334,6 +3334,7 @@ If words are stored with the most significant byte first (like Motorola and SPARC, but not Intel and VAX, CPUs), define @code{WORDS_BIGENDIAN}. @end defmac + @defmac AC_C_CONST @maindex C_CONST @cvindex const @@ -3345,17 +3346,20 @@ can simply use @code{const} as if every C compiler supported it; for those that don't, the @file{Makefile} or configuration header file will define it as empty. -If ever you happen to have the sad idea to use a C++ compiler for -@samp{CC}, this test will @strong{not} test the validity of -@code{const}, and will trust it. The main difference between C and C++ -is that C++ does not allow to define a @code{const} variable without -initializer: +Occasionally installers use a C++ compiler to compile C code, typically +because they lack a C compiler. This causes problems with @code{const}, +because C and C++ treat @code{const} differently. For example: @example const int foo; @end example -while ANSI C supports this. After long debates, it has been decided to -trust the @code{const} of C++ compilers in all the cases, even if it is -not ANSI C conforming. +is valid in C but not in C++. These differences unfortunately cannot be +papered over by defining @code{const} to be empty. + +If @code{autoconf} detects this situation, it leaves @code{const} alone, +as this generally yields better results in practice. However, using a +C++ compiler to compile C code is not recommended or supported, and +installers who run into trouble in this area should get a C compiler +like GCC to compile their C code. @end defmac @defmac AC_C_VOLATILE diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 976b150a..f9a34c4e 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2259,6 +2259,7 @@ fi rm -fr conftest*]) + ## ------------------------ ## ## Checking for libraries. ## ## ------------------------ ## @@ -2357,9 +2358,24 @@ AC_VAR_POPDEF([ac_Lib])dnl -# AC_HAVE_LIBRARY -# --------------- -AC_DEFUNCT(AC_HAVE_LIBRARY, [; instead use AC_CHECK_LIB]) +# AC_HAVE_LIBRARY(LIBRARY, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [OTHER-LIBRARIES]) +# --------------------------------------------------------- +# +# This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION +# argument of `main'. In addition, LIBRARY can be written as any of +# `foo', `-lfoo', or `libfoo.a'. In all of those cases, the compiler +# is passed `-lfoo'. However, LIBRARY cannot be a shell variable; +# it must be a literal name. +AU_DEFUN(AC_HAVE_LIBRARY, +[pushdef([AC_Lib_Name], + patsubst(patsubst([[$1]], [lib\([^\.]*\)\.a], [\1]), [-l], []))dnl +AC_CHECK_LIB(AC_Lib_Name, main, [$2], [$3], [$4])dnl +ac_cv_lib_[]AC_Lib_Name()=ac_cv_lib_[]AC_Lib_Name()_main +popdef([AC_Lib_Name])dnl +]) + ## ------------------------ ##