+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.
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.
rm -fr conftest*])
+
## ------------------------ ##
## Checking for libraries. ##
## ------------------------ ##
-# 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
+])
+
## ------------------------ ##
and SPARC, but not Intel and VAX, CPUs), define @code{WORDS_BIGENDIAN}.
@end defmac
+
@defmac AC_C_CONST
@maindex C_CONST
@cvindex const
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
and SPARC, but not Intel and VAX, CPUs), define @code{WORDS_BIGENDIAN}.
@end defmac
+
@defmac AC_C_CONST
@maindex C_CONST
@cvindex const
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
rm -fr conftest*])
+
## ------------------------ ##
## Checking for libraries. ##
## ------------------------ ##
-# 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
+])
+
## ------------------------ ##