]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Restore AC_HAVE_LIBRARY.
authorAkim Demaille <akim@epita.fr>
Thu, 10 Feb 2000 08:42:26 +0000 (08:42 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 10 Feb 2000 08:42:26 +0000 (08:42 +0000)
* acgeneral.m4 (AC_HAVE_LIBRARY): AU_DEFUNed in terms of
AC_CHECK_LIB.
* doc/autoconf.texi (Libraries): Document.

ChangeLog
TODO
acgeneral.m4
autoconf.texi
doc/autoconf.texi
lib/autoconf/general.m4

index bb08601f87543d55fc503e9a1762a16e6dfa1e93..4cf6ba6eac9fc303ecb056920df3360d8fc70b45 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-02-10  Akim Demaille  <akim@epita.fr>
+
+       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  <akim@epita.fr>
 
        Fix the handling of `./configure foo=bar' and test it.
diff --git a/TODO b/TODO
index 227d96caf513d6ca27d21f29bd27bbfe44a74ab6..201d572eaee92d8b9582941a9e7a048792a3f413 100644 (file)
--- 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(<<AC_LIB_NAME>>, dnl
-   patsubst(patsubst($1, <<lib\([^\.]*\)\.a>>, <<\1>>), <<-l>>, <<>>))dnl
-   define(<<AC_CV_NAME>>, 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.
 
index 976b150aea921a11f81e80cdedc4cb563c4c2d38..f9a34c4ebfc11f77820abcd19988994ad2098046 100644 (file)
@@ -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
+])
+
 
 
 ## ------------------------ ##
index 41791d09e724729b7135647b89e1515eee7dc828..201085e18bcfa7bbd08ddc6ea343d6705412d4fc 100644 (file)
@@ -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
index 41791d09e724729b7135647b89e1515eee7dc828..201085e18bcfa7bbd08ddc6ea343d6705412d4fc 100644 (file)
@@ -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
index 976b150aea921a11f81e80cdedc4cb563c4c2d38..f9a34c4ebfc11f77820abcd19988994ad2098046 100644 (file)
@@ -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
+])
+
 
 
 ## ------------------------ ##