]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
fix messages and library checking
authorDavid MacKenzie <djm@djmnet.org>
Wed, 10 Aug 1994 23:54:30 +0000 (23:54 +0000)
committerDavid MacKenzie <djm@djmnet.org>
Wed, 10 Aug 1994 23:54:30 +0000 (23:54 +0000)
NEWS
acgeneral.m4
acspecific.m4
autoconf.texi
doc/autoconf.texi
lib/autoconf/general.m4
lib/autoconf/specific.m4

diff --git a/NEWS b/NEWS
index c41d821c75d5684490a235c43b005597b1acd286..f5e03bbbc5cec16299a3c373182b5283342a77fb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Major changes in release 2.0:
   configure --verbose no longer has any effect.
 * AC_PREFIX_PROGRAM, which obsoletes AC_PREFIX.
 * AC_HEADER_DIRENT, which obsoletes AC_DIR_HEADER.
+* AC_CHECK_LIB, which obsoletes AC_HAVE_LIBRARY.
 * AC_ARG_ENABLE and AC_ARG_WITH, which obsolete AC_ENABLE and AC_WITH.
 * AC_SUBST_FILE, to insert one file into another.
 
index 83f5fdb9bde1e99237b91a902f7f44de5b254bf5..aca3adf5bc7dd19390c892fb159b994da81a69ed 100644 (file)
@@ -756,7 +756,7 @@ fi
 for ac_site_dir in $ac_site_dirs; do
   ac_site_file=$ac_site_dir/lib/config.site
   if test -r "$ac_site_file"; then
-    echo "loading site initialization script $ac_site_file"
+    echo "loading site script $ac_site_file"
     . $ac_site_file
   fi
 done
@@ -764,16 +764,16 @@ done
 dnl
 define(AC_CACHE_LOAD,
 [if test -r "$cache_file"; then
-  echo "loading test results from cache file $cache_file"
+  echo "loading cache $cache_file"
   . $cache_file
 else
-  echo "creating new cache file $cache_file"
+  echo "creating cache $cache_file"
   > $cache_file
 fi])dnl
 dnl
 define(AC_CACHE_SAVE,
 [if test -w $cache_file; then
-echo "saving test results in cache file $cache_file"
+echo "updating cache $cache_file"
 cat > $cache_file <<\CEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -798,7 +798,7 @@ dnl
 dnl AC_CACHE_VAL(CACHE-ID, COMMANDS-TO-SET-IT)
 dnl The name of shell var CACHE-ID must contain `_cv_' in order to get saved.
 define(AC_CACHE_VAL,
-[AC_REQUIRE([AC_MSG_ECHO_N])dnl
+[AC_REQUIRE([AC_PROG_ECHO_N])dnl
 dnl We used to use the below line, but it fails if the 1st arg is a
 dnl shell variable, so we need the eval.
 dnl if test "${$1+set}" = set; then
@@ -932,37 +932,20 @@ dnl
 dnl ### Printing messages
 dnl
 dnl
-dnl Check whether to use -n, \c, or newline-tab to separate
-dnl checking messages from result messages.
-define(AC_MSG_ECHO_N,
-[AC_PROVIDE([$0])dnl
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
-  if (echo -n testing; echo 1,2,3) | grep -e -n > /dev/null; then
-    ac_n= ac_c='
-' ac_t='       '
-  else
-    ac_n=-n ac_c= ac_t=
-  fi
-else
-  ac_n= ac_c='\c' ac_t=
-fi])dnl
-dnl
 dnl AC_MSG_CHECKING(FEATURE-DESCRIPTION)
 define(AC_MSG_CHECKING,
-[AC_REQUIRE([AC_MSG_ECHO_N])dnl
-echo $ac_n "checking $1""...$ac_c" 1>&4])dnl
+[AC_REQUIRE([AC_PROG_ECHO_N])dnl
+echo $ac_n "checking $1""... $ac_c" 1>&4])dnl
 dnl
-dnl Obsolete version.
 define(AC_CHECKING,
 [AC_OBSOLETE([$0], [; instead use AC_MSG_CHECKING])dnl
 echo "checking $1" 1>&4])dnl
 dnl
 dnl AC_MSG_RESULT(RESULT-DESCRIPTION)
 define(AC_MSG_RESULT,
-[AC_REQUIRE([AC_MSG_ECHO_N])dnl
+[AC_REQUIRE([AC_PROG_ECHO_N])dnl
 echo "$ac_t""$1" 1>&4])dnl
 dnl
-dnl Obsolete version.
 define(AC_VERBOSE,
 [AC_OBSOLETE([$0], [; instead use AC_MSG_RESULT])dnl
 echo " $1" 1>&4])dnl
@@ -1115,10 +1098,10 @@ done
 ifelse([$3], , , [test -n "[$]$1" || $1="$3"
 ])])dnl
 dnl
-dnl AC_CHECK_LIB(LIBRARY [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl AC_CHECK_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
 dnl                 [, OTHER-LIBRARIES]]])
-define(AC_CHECK_LIB, [dnl
-changequote(/, /)dnl
+define(AC_CHECK_LIB,
+[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
@@ -1126,24 +1109,31 @@ changequote([, ])dnl
 AC_MSG_CHECKING([for -l[]AC_LIB_NAME])
 AC_CACHE_VAL(AC_CV_NAME,
 [ac_save_LIBS="${LIBS}"
-LIBS="${LIBS} -l[]AC_LIB_NAME[] $4"
-AC_TRY_LINK( , [main();], AC_CV_NAME=yes, AC_CV_NAME=no)dnl
+LIBS="${LIBS} -l[]AC_LIB_NAME[] $5"
+AC_TRY_LINK( , [$2()], AC_CV_NAME=yes, AC_CV_NAME=no)dnl
 LIBS="${ac_save_LIBS}"
 ])dnl
 AC_MSG_RESULT($AC_CV_NAME)
 if test "${AC_CV_NAME}" = yes; then
-  ifelse([$2], , 
+  ifelse([$3], , 
 [AC_DEFINE([HAVE_LIB]translit(AC_LIB_NAME, [a-z], [A-Z]))
   LIBS="${LIBS} -l[]AC_LIB_NAME[]"
-], [$2])
-ifelse([$3], , , [else
-  $3
+], [$3])
+ifelse([$4], , , [else
+  $4
 ])dnl
 fi
 undefine(AC_LIB_NAME)dnl
 undefine(AC_CV_NAME)dnl
 ])dnl
 dnl
+dnl AC_HAVE_LIBRARY(LIBRARY, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl                 [, OTHER-LIBRARIES]]])
+define(AC_HAVE_LIBRARY,
+[AC_OBSOLETE([$0], [; instead use AC_CHECK_LIB])dnl
+AC_CHECK_LIB([$1], main, [$2], [$3], [$4])dnl
+])dnl
+dnl
 dnl
 dnl ### Checking for C features - fundamental (no caching)
 dnl
index a0327b328dd9c2adfa49ff70e1277f07a0b2696f..baab919c4bb3b678189cd8a7d7da8223f2c911b3 100644 (file)
@@ -24,6 +24,23 @@ dnl
 dnl ### Checks for programs
 dnl
 dnl
+dnl Check whether to use -n, \c, or newline-tab to separate
+dnl checking messages from result messages.
+dnl Idea borrowed from dist 3.0.
+dnl Internal use only.
+define(AC_PROG_ECHO_N,
+[AC_PROVIDE([$0])dnl
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  if (echo -n testing; echo 1,2,3) | grep -e -n > /dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi])dnl
+dnl
 define(AC_PROG_CC,
 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
 AC_PROVIDE([$0])dnl
@@ -213,7 +230,7 @@ AC_MSG_CHECKING(for $LEX library)
 if test -z "$LEXLIB"
 then
   case "$LEX" in
-  flex*) AC_CHECK_LIB(fl, LEXLIB="-lfl") ;;
+  flex*) AC_CHECK_LIB(fl, main, LEXLIB="-lfl") ;;
   *) LEXLIB="-ll" ;;
   esac
 fi
@@ -953,15 +970,15 @@ AC_SUBST(NEED_SETGID)dnl
 ac_have_func=no
 
 # Check for the 4.4BSD definition of getloadavg.
-AC_CHECK_LIB(util, [LIBS="$LIBS -lutil" ac_have_func=yes
+AC_CHECK_LIB(util, getloadavg, [LIBS="$LIBS -lutil" ac_have_func=yes
 # Some systems with -lutil have (and need) -lkvm as well, some do not.
-AC_CHECK_LIB(kvm, LIBS="$LIBS -lkvm")])
+AC_CHECK_LIB(kvm, kvm_open,  LIBS="$LIBS -lkvm")])
 
 if test $ac_have_func = no; then
 # There is a commonly available library for RS/6000 AIX.
 # Since it is not a standard part of AIX, it might be installed locally.
 ac_save_LIBS="$LIBS" LIBS="-L/usr/local/lib $LIBS"
-AC_CHECK_LIB(getloadavg, LIBS="$LIBS -lgetloadavg", LIBS="$ac_save_LIBS")
+AC_CHECK_LIB(getloadavg, getloadavg, LIBS="$LIBS -lgetloadavg", LIBS="$ac_save_LIBS")
 fi
 
 # Make sure it is really in the library, if we think we found it.
@@ -973,15 +990,14 @@ else
 ac_have_func=no
 AC_CHECK_HEADER(sys/dg_sys_info.h,
 [ac_have_func=yes AC_DEFINE(DGUX)
-# Some versions of DGUX need -ldgc for dg_sys_info.
-AC_CHECK_LIB(dgc)])
+AC_CHECK_LIB(dgc, dg_sys_info)])
 if test $ac_have_func = no; then
 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
 # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
 # Irix 4.0.5F has the header but not the library.
-AC_CHECK_LIB(elf,
+AC_CHECK_LIB(elf, elf_read,
   [LIBS="$LIBS -lelf" ac_have_func=yes AC_DEFINE(SVR4)
-  AC_CHECK_LIB(kvm, LIBS="$LIBS -lkvm")])
+  AC_CHECK_LIB(kvm, kvm_open, LIBS="$LIBS -lkvm")])
 fi
 if test $ac_have_func = no; then
 AC_CHECK_HEADER(inq_stats/cpustats.h,
@@ -1547,9 +1563,9 @@ dnl
 dnl Internal subroutine of AC_PATH_X.
 define(AC_PATH_X_DIRECT,
 [AC_CHECKING(for X include and library files directly)
-test -z "$x_direct_TRY_library" && x_direct_TRY_library=Xt
-test -z "$x_direct_TRY_include" && x_direct_TRY_include=X11/Intrinsic.h
-AC_TRY_CPP([#include <$x_direct_TRY_include>], no_x=,
+test -z "$x_direct_test_library" && x_direct_test_library=Xt
+test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
+AC_TRY_CPP([#include <$x_direct_test_include>], no_x=,
   for ac_dir in               \
     /usr/X11R6/include        \
     /usr/X11R5/include        \
@@ -1587,7 +1603,7 @@ AC_TRY_CPP([#include <$x_direct_TRY_include>], no_x=,
     /usr/openwin/share/include \
     ; \
   do
-    if test -r "$ac_dir/$x_direct_TRY_include"; then
+    if test -r "$ac_dir/$x_direct_test_include"; then
       test -z "$ac_cv_x_includes" && ac_cv_x_includes=$ac_dir
       no_x=
       break
@@ -1596,7 +1612,7 @@ AC_TRY_CPP([#include <$x_direct_TRY_include>], no_x=,
 
 # Check for the libraries.  First see if replacing the include by
 # lib works.
-AC_CHECK_LIB("$x_direct_TRY_library", no_x=,
+AC_HAVE_LIBRARY("$x_direct_test_library", no_x=,
 for ac_dir in `echo "$ac_cv_x_includes" | sed s/include/lib/` \
     /usr/X11R6/lib        \
     /usr/X11R5/lib        \
@@ -1635,7 +1651,7 @@ for ac_dir in `echo "$ac_cv_x_includes" | sed s/include/lib/` \
     ; \
 do
   for ac_extension in a so sl; do
-    if test -r $ac_dir/lib${x_direct_TRY_library}.$ac_extension; then
+    if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
       test -z "$ac_cv_x_libraries" && ac_cv_x_libraries=$ac_dir
       no_x=
       break 2
@@ -1674,16 +1690,17 @@ else
   # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
   # libraries were built with DECnet support.  And karl@cs.umb.edu says
   # the Alpha needs dnet_stub (dnet does not exist).
-  AC_CHECK_LIB(dnet,
+  AC_CHECK_LIB(dnet, dnet_ntoa,
     [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" ac_have_dnet=yes], ac_have_dnet=no)
   if test "$ac_have_dnet" = no; then
-    AC_CHECK_LIB(dnet_stub, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
+    AC_CHECK_LIB(dnet_stub, dnet_ntoa,
+      [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
   fi
   # lieder@skyler.mavd.honeywell.com says without -lsocket,
   # socket/setsockopt and other routines are undefined under SCO ODT 2.0.
   # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch.
   if test "`(uname) 2>/dev/null`" != IRIX; then
-    AC_CHECK_LIB(socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"])
+    AC_CHECK_LIB(socket, socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"])
   fi
 fi
 #
@@ -1766,13 +1783,13 @@ fi
 ])dnl
 dnl
 define(AC_OS_SCO,
-[AC_CHECK_LIB(intl, LIBS="$LIBS -lintl")
+[AC_CHECK_LIB(intl, strftime, LIBS="$LIBS -lintl")
 ])dnl
 dnl
 define(AC_OS_IRIX,
-[AC_CHECK_LIB(sun, LIBS="$LIBS -lsun")
+[AC_CHECK_LIB(sun, getmntent, LIBS="$LIBS -lsun")
 ])dnl
 dnl
 define(AC_OS_DYNIX,
-[AC_CHECK_LIB(seq, LIBS="$LIBS -lseq")
+[AC_CHECK_LIB(seq, getmntent, LIBS="$LIBS -lseq")
 ])dnl
index fc236549753135974d1749fd1454cafa2d41cd8f..eddb52f8a56e1fce8cc9cfb31dfdfaaa8cf7a31a 100644 (file)
@@ -1904,18 +1904,21 @@ produces this in @file{configure}:
 
 These macros check whether particular files exist.
 
-@defmac AC_CHECK_LIB (@var{library} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
+@defmac AC_CHECK_LIB (@var{library}, @var{function}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
 @maindex CHECK_LIB
 Create a test C program to see whether that program can be linked with
-the library @var{library}.  @var{action-if-found} is a list of shell
-commands to run if the link succeeds (which means that the library is
-present); @var{action-if-not-found} is a list of shell commands to run
-if the link fails.  If @var{action-if-found} and
-@var{action-if-not-found} are not specified, the default action is to
-add @samp{-lfoo} to @code{LIBS} and define @samp{HAVE_LIBfoo}
-for library @samp{foo}.  @var{library} can be written as any of
-@samp{foo}, @samp{-lfoo}, or @samp{libfoo.a}.  In all of those cases,
-the compiler is passed @samp{-lfoo}.
+the library @var{library}.  @var{function} should be the name of a
+function that that library contains, to force the linker to try to link
+with the library to resolve the name.
+
+@var{action-if-found} is a list of shell commands to run if the link
+succeeds (which means that the library is present);
+@var{action-if-not-found} is a list of shell commands to run if the link
+fails.  If @var{action-if-found} and @var{action-if-not-found} are not
+specified, the default action is to add @samp{-lfoo} to @code{LIBS} and
+define @samp{HAVE_LIBfoo} for library @samp{foo}.  @var{library} can be
+written as any of @samp{foo}, @samp{-lfoo}, or @samp{libfoo.a}.  In all
+of those cases, the compiler is passed @samp{-lfoo}.
 
 If linking with @var{library} results in unresolved symbols, which would
 be resolved by linking with additional libraries, give those libraries
@@ -1925,6 +1928,14 @@ present, because linking the test program will always fail with
 unresolved symbols.
 @end defmac
 
+@defmac AC_HAVE_LIBRARY (@var{library}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
+@maindex HAVE_LIBRARY
+This macro is equivalent to calling @code{AC_CHECK_LIB} with a
+@var{function} argument of @code{main}.  It is considered obsolete,
+because some linkers (e.g., Apollo's) do not fail when asked to link
+with a nonexistent library if there are no unresolved sybols.
+@end defmac
+
 @defmac AC_PREFIX (@var{program})
 @maindex PREFIX
 This macro is like @code{AC_PREFIX_PROGRAM}, except that it prevents
@@ -2087,7 +2098,8 @@ shell commands @var{action-if-false}.
 
 This macro calls @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP} (depending
 on which language is current, @pxref{Language Choice}), if it hasn't
-been called already.
+been called already.  It does not use @code{CFLAGS}, because -g, -O,
+etc. are not valid options to many C preprocessors. 
 @end defmac
 
 @defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
@@ -2096,7 +2108,9 @@ Create a test C program to see whether a function whose body consists of
 @var{function-body} can be compiled and linked; @var{includes} is any
 @code{#include} statements needed by the code in @var{function-body}.
 If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
+@var{action-if-found}, otherwise run @var{action-if-not-found}.  This
+macro uses @code{CFLAGS} and @code{LDFLAGS} and @code{LIBS} when
+compiling.
 @end defmac
 
 @defmac AC_TRY_RUN (@var{program}, @var{action-if-true} @r{[}, @var{action-if-false} @r{[}, @var{action-if-cross-compiling}@r{]]})
@@ -2105,14 +2119,18 @@ If the file compiles and links successfully, run shell commands
 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}.
+@var{action-if-false}.  This macro uses @code{CFLAGS} and @code{LDFLAGS}
+and @code{LIBS} when compiling.
 
-If the optional argument @var{action-if-cross-compiling} is given and
-the C compiler being used does not produce executables that run on the
-system where @code{configure} is being run, then the test program is not
-run.  Instead, the shell commands @var{action-if-cross-compiling} are
-run.  If that argument is given, this macro calls @code{AC_C_CROSS}
+If the C compiler being used does not produce executables that run on
+the system where @code{configure} is being run, then the test program is
+not run.  If the optional shell commands @var{action-if-cross-compiling}
+are given, they are run instead and this macro calls @code{AC_C_CROSS}
 if it has not already been called (@pxref{Compiler Characteristics}).
+Otherwise, @code{configure} prints an error message and exits.
+
+It is preferable to use @code{AC_TRY_LINK} instead of @code{AC_TRY_RUN},
+when possible.  @xref{Test Programs}, for more information.
 @end defmac
 
 @node Command Line, Setting Variables, C Features, General Purpose Macros
@@ -2945,7 +2963,7 @@ exists on the system or has a certain value, then you can't use
 test program by hand.  You can compile and run it using
 @code{AC_TRY_RUN} (@pxref{C Features}).
 
-Try to avoid writing test programs if possible, because using them
+Try to avoid running test programs if possible, because using them
 prevents people from configuring your package for cross-compiling.  If
 it's really best that you test for a run-time behavior, try to provide a
 default ``worst case'' value to use when cross-compiling makes run-time
@@ -3477,11 +3495,12 @@ code are really appropriate to be in them.  Besides a cache file, they
 are good places to set default values for other shell variables like
 @code{CC}, if you need to give them unusual values: anything you would
 normally do, repetitively, on the command line.  If you use non-default
-values for @var{prefix} or @var{exec_prefix}, you can't set them in the
-site file, since you have to specify them on the command line in order
-for @code{configure} to find the site file!
+values for @var{prefix} or @var{exec_prefix} (wherever you locate the
+site file), you can't set them in the site file, since you have to
+specify them on the command line in order for @code{configure} to find
+the site file!
 
-In addition, it is possible to set some cache values in the site file.
+It is possible to set some cache values in the site file.
 If you are cross-compiling, it is impossible to check features that
 require running a test program.  You could ``prime the cache'' by
 setting those values correctly for that system in
@@ -3492,6 +3511,20 @@ check that variables such as @code{prefix} and @code{cache_file} have
 their default values (as set near the top of @code{configure}) before
 changing them.
 
+Here is a sample file @file{/usr/share/local/gnu/lib/config.site}.
+@samp{configure --prefix=/usr/share/local/gnu} would read this file.
+
+@example
+# config.site for configure
+#
+# Give Autoconf 2.x generated configure scripts a shared default
+# cache file for feature test results, architecture-specific.
+test $cache_file = ./config.cache &&
+  cache_file=/usr/local/gnu/lib/config.cache
+# Also, if you give --prefix, you get --exec-prefix automatically.
+test $exec_prefix = NONE && exec_prefix=/usr/local/gnu
+@end example
+
 @node Old Macro Names, Example, Site Default Values, Top
 @chapter Old Macro Names
 
@@ -3539,10 +3572,6 @@ for backward compatibility, the old names are considered obsolete.
 @vindex PROGRAMS_PATH
 @vindex PATH_PROGS
 @code{AC_PATH_PROGS}
-@item AC_HAVE_LIBRARY
-@vindex HAVE_LIBRARY
-@vindex CHECK_LIB
-@code{AC_CHECK_LIB}
 @item AC_HEADER_EGREP
 @vindex HEADER_EGREP
 @vindex EGREP_HEADER
index fc236549753135974d1749fd1454cafa2d41cd8f..eddb52f8a56e1fce8cc9cfb31dfdfaaa8cf7a31a 100644 (file)
@@ -1904,18 +1904,21 @@ produces this in @file{configure}:
 
 These macros check whether particular files exist.
 
-@defmac AC_CHECK_LIB (@var{library} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
+@defmac AC_CHECK_LIB (@var{library}, @var{function}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
 @maindex CHECK_LIB
 Create a test C program to see whether that program can be linked with
-the library @var{library}.  @var{action-if-found} is a list of shell
-commands to run if the link succeeds (which means that the library is
-present); @var{action-if-not-found} is a list of shell commands to run
-if the link fails.  If @var{action-if-found} and
-@var{action-if-not-found} are not specified, the default action is to
-add @samp{-lfoo} to @code{LIBS} and define @samp{HAVE_LIBfoo}
-for library @samp{foo}.  @var{library} can be written as any of
-@samp{foo}, @samp{-lfoo}, or @samp{libfoo.a}.  In all of those cases,
-the compiler is passed @samp{-lfoo}.
+the library @var{library}.  @var{function} should be the name of a
+function that that library contains, to force the linker to try to link
+with the library to resolve the name.
+
+@var{action-if-found} is a list of shell commands to run if the link
+succeeds (which means that the library is present);
+@var{action-if-not-found} is a list of shell commands to run if the link
+fails.  If @var{action-if-found} and @var{action-if-not-found} are not
+specified, the default action is to add @samp{-lfoo} to @code{LIBS} and
+define @samp{HAVE_LIBfoo} for library @samp{foo}.  @var{library} can be
+written as any of @samp{foo}, @samp{-lfoo}, or @samp{libfoo.a}.  In all
+of those cases, the compiler is passed @samp{-lfoo}.
 
 If linking with @var{library} results in unresolved symbols, which would
 be resolved by linking with additional libraries, give those libraries
@@ -1925,6 +1928,14 @@ present, because linking the test program will always fail with
 unresolved symbols.
 @end defmac
 
+@defmac AC_HAVE_LIBRARY (@var{library}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
+@maindex HAVE_LIBRARY
+This macro is equivalent to calling @code{AC_CHECK_LIB} with a
+@var{function} argument of @code{main}.  It is considered obsolete,
+because some linkers (e.g., Apollo's) do not fail when asked to link
+with a nonexistent library if there are no unresolved sybols.
+@end defmac
+
 @defmac AC_PREFIX (@var{program})
 @maindex PREFIX
 This macro is like @code{AC_PREFIX_PROGRAM}, except that it prevents
@@ -2087,7 +2098,8 @@ shell commands @var{action-if-false}.
 
 This macro calls @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP} (depending
 on which language is current, @pxref{Language Choice}), if it hasn't
-been called already.
+been called already.  It does not use @code{CFLAGS}, because -g, -O,
+etc. are not valid options to many C preprocessors. 
 @end defmac
 
 @defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
@@ -2096,7 +2108,9 @@ Create a test C program to see whether a function whose body consists of
 @var{function-body} can be compiled and linked; @var{includes} is any
 @code{#include} statements needed by the code in @var{function-body}.
 If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
+@var{action-if-found}, otherwise run @var{action-if-not-found}.  This
+macro uses @code{CFLAGS} and @code{LDFLAGS} and @code{LIBS} when
+compiling.
 @end defmac
 
 @defmac AC_TRY_RUN (@var{program}, @var{action-if-true} @r{[}, @var{action-if-false} @r{[}, @var{action-if-cross-compiling}@r{]]})
@@ -2105,14 +2119,18 @@ If the file compiles and links successfully, run shell commands
 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}.
+@var{action-if-false}.  This macro uses @code{CFLAGS} and @code{LDFLAGS}
+and @code{LIBS} when compiling.
 
-If the optional argument @var{action-if-cross-compiling} is given and
-the C compiler being used does not produce executables that run on the
-system where @code{configure} is being run, then the test program is not
-run.  Instead, the shell commands @var{action-if-cross-compiling} are
-run.  If that argument is given, this macro calls @code{AC_C_CROSS}
+If the C compiler being used does not produce executables that run on
+the system where @code{configure} is being run, then the test program is
+not run.  If the optional shell commands @var{action-if-cross-compiling}
+are given, they are run instead and this macro calls @code{AC_C_CROSS}
 if it has not already been called (@pxref{Compiler Characteristics}).
+Otherwise, @code{configure} prints an error message and exits.
+
+It is preferable to use @code{AC_TRY_LINK} instead of @code{AC_TRY_RUN},
+when possible.  @xref{Test Programs}, for more information.
 @end defmac
 
 @node Command Line, Setting Variables, C Features, General Purpose Macros
@@ -2945,7 +2963,7 @@ exists on the system or has a certain value, then you can't use
 test program by hand.  You can compile and run it using
 @code{AC_TRY_RUN} (@pxref{C Features}).
 
-Try to avoid writing test programs if possible, because using them
+Try to avoid running test programs if possible, because using them
 prevents people from configuring your package for cross-compiling.  If
 it's really best that you test for a run-time behavior, try to provide a
 default ``worst case'' value to use when cross-compiling makes run-time
@@ -3477,11 +3495,12 @@ code are really appropriate to be in them.  Besides a cache file, they
 are good places to set default values for other shell variables like
 @code{CC}, if you need to give them unusual values: anything you would
 normally do, repetitively, on the command line.  If you use non-default
-values for @var{prefix} or @var{exec_prefix}, you can't set them in the
-site file, since you have to specify them on the command line in order
-for @code{configure} to find the site file!
+values for @var{prefix} or @var{exec_prefix} (wherever you locate the
+site file), you can't set them in the site file, since you have to
+specify them on the command line in order for @code{configure} to find
+the site file!
 
-In addition, it is possible to set some cache values in the site file.
+It is possible to set some cache values in the site file.
 If you are cross-compiling, it is impossible to check features that
 require running a test program.  You could ``prime the cache'' by
 setting those values correctly for that system in
@@ -3492,6 +3511,20 @@ check that variables such as @code{prefix} and @code{cache_file} have
 their default values (as set near the top of @code{configure}) before
 changing them.
 
+Here is a sample file @file{/usr/share/local/gnu/lib/config.site}.
+@samp{configure --prefix=/usr/share/local/gnu} would read this file.
+
+@example
+# config.site for configure
+#
+# Give Autoconf 2.x generated configure scripts a shared default
+# cache file for feature test results, architecture-specific.
+test $cache_file = ./config.cache &&
+  cache_file=/usr/local/gnu/lib/config.cache
+# Also, if you give --prefix, you get --exec-prefix automatically.
+test $exec_prefix = NONE && exec_prefix=/usr/local/gnu
+@end example
+
 @node Old Macro Names, Example, Site Default Values, Top
 @chapter Old Macro Names
 
@@ -3539,10 +3572,6 @@ for backward compatibility, the old names are considered obsolete.
 @vindex PROGRAMS_PATH
 @vindex PATH_PROGS
 @code{AC_PATH_PROGS}
-@item AC_HAVE_LIBRARY
-@vindex HAVE_LIBRARY
-@vindex CHECK_LIB
-@code{AC_CHECK_LIB}
 @item AC_HEADER_EGREP
 @vindex HEADER_EGREP
 @vindex EGREP_HEADER
index 83f5fdb9bde1e99237b91a902f7f44de5b254bf5..aca3adf5bc7dd19390c892fb159b994da81a69ed 100644 (file)
@@ -756,7 +756,7 @@ fi
 for ac_site_dir in $ac_site_dirs; do
   ac_site_file=$ac_site_dir/lib/config.site
   if test -r "$ac_site_file"; then
-    echo "loading site initialization script $ac_site_file"
+    echo "loading site script $ac_site_file"
     . $ac_site_file
   fi
 done
@@ -764,16 +764,16 @@ done
 dnl
 define(AC_CACHE_LOAD,
 [if test -r "$cache_file"; then
-  echo "loading test results from cache file $cache_file"
+  echo "loading cache $cache_file"
   . $cache_file
 else
-  echo "creating new cache file $cache_file"
+  echo "creating cache $cache_file"
   > $cache_file
 fi])dnl
 dnl
 define(AC_CACHE_SAVE,
 [if test -w $cache_file; then
-echo "saving test results in cache file $cache_file"
+echo "updating cache $cache_file"
 cat > $cache_file <<\CEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -798,7 +798,7 @@ dnl
 dnl AC_CACHE_VAL(CACHE-ID, COMMANDS-TO-SET-IT)
 dnl The name of shell var CACHE-ID must contain `_cv_' in order to get saved.
 define(AC_CACHE_VAL,
-[AC_REQUIRE([AC_MSG_ECHO_N])dnl
+[AC_REQUIRE([AC_PROG_ECHO_N])dnl
 dnl We used to use the below line, but it fails if the 1st arg is a
 dnl shell variable, so we need the eval.
 dnl if test "${$1+set}" = set; then
@@ -932,37 +932,20 @@ dnl
 dnl ### Printing messages
 dnl
 dnl
-dnl Check whether to use -n, \c, or newline-tab to separate
-dnl checking messages from result messages.
-define(AC_MSG_ECHO_N,
-[AC_PROVIDE([$0])dnl
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
-  if (echo -n testing; echo 1,2,3) | grep -e -n > /dev/null; then
-    ac_n= ac_c='
-' ac_t='       '
-  else
-    ac_n=-n ac_c= ac_t=
-  fi
-else
-  ac_n= ac_c='\c' ac_t=
-fi])dnl
-dnl
 dnl AC_MSG_CHECKING(FEATURE-DESCRIPTION)
 define(AC_MSG_CHECKING,
-[AC_REQUIRE([AC_MSG_ECHO_N])dnl
-echo $ac_n "checking $1""...$ac_c" 1>&4])dnl
+[AC_REQUIRE([AC_PROG_ECHO_N])dnl
+echo $ac_n "checking $1""... $ac_c" 1>&4])dnl
 dnl
-dnl Obsolete version.
 define(AC_CHECKING,
 [AC_OBSOLETE([$0], [; instead use AC_MSG_CHECKING])dnl
 echo "checking $1" 1>&4])dnl
 dnl
 dnl AC_MSG_RESULT(RESULT-DESCRIPTION)
 define(AC_MSG_RESULT,
-[AC_REQUIRE([AC_MSG_ECHO_N])dnl
+[AC_REQUIRE([AC_PROG_ECHO_N])dnl
 echo "$ac_t""$1" 1>&4])dnl
 dnl
-dnl Obsolete version.
 define(AC_VERBOSE,
 [AC_OBSOLETE([$0], [; instead use AC_MSG_RESULT])dnl
 echo " $1" 1>&4])dnl
@@ -1115,10 +1098,10 @@ done
 ifelse([$3], , , [test -n "[$]$1" || $1="$3"
 ])])dnl
 dnl
-dnl AC_CHECK_LIB(LIBRARY [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl AC_CHECK_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
 dnl                 [, OTHER-LIBRARIES]]])
-define(AC_CHECK_LIB, [dnl
-changequote(/, /)dnl
+define(AC_CHECK_LIB,
+[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
@@ -1126,24 +1109,31 @@ changequote([, ])dnl
 AC_MSG_CHECKING([for -l[]AC_LIB_NAME])
 AC_CACHE_VAL(AC_CV_NAME,
 [ac_save_LIBS="${LIBS}"
-LIBS="${LIBS} -l[]AC_LIB_NAME[] $4"
-AC_TRY_LINK( , [main();], AC_CV_NAME=yes, AC_CV_NAME=no)dnl
+LIBS="${LIBS} -l[]AC_LIB_NAME[] $5"
+AC_TRY_LINK( , [$2()], AC_CV_NAME=yes, AC_CV_NAME=no)dnl
 LIBS="${ac_save_LIBS}"
 ])dnl
 AC_MSG_RESULT($AC_CV_NAME)
 if test "${AC_CV_NAME}" = yes; then
-  ifelse([$2], , 
+  ifelse([$3], , 
 [AC_DEFINE([HAVE_LIB]translit(AC_LIB_NAME, [a-z], [A-Z]))
   LIBS="${LIBS} -l[]AC_LIB_NAME[]"
-], [$2])
-ifelse([$3], , , [else
-  $3
+], [$3])
+ifelse([$4], , , [else
+  $4
 ])dnl
 fi
 undefine(AC_LIB_NAME)dnl
 undefine(AC_CV_NAME)dnl
 ])dnl
 dnl
+dnl AC_HAVE_LIBRARY(LIBRARY, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl                 [, OTHER-LIBRARIES]]])
+define(AC_HAVE_LIBRARY,
+[AC_OBSOLETE([$0], [; instead use AC_CHECK_LIB])dnl
+AC_CHECK_LIB([$1], main, [$2], [$3], [$4])dnl
+])dnl
+dnl
 dnl
 dnl ### Checking for C features - fundamental (no caching)
 dnl
index a0327b328dd9c2adfa49ff70e1277f07a0b2696f..baab919c4bb3b678189cd8a7d7da8223f2c911b3 100644 (file)
@@ -24,6 +24,23 @@ dnl
 dnl ### Checks for programs
 dnl
 dnl
+dnl Check whether to use -n, \c, or newline-tab to separate
+dnl checking messages from result messages.
+dnl Idea borrowed from dist 3.0.
+dnl Internal use only.
+define(AC_PROG_ECHO_N,
+[AC_PROVIDE([$0])dnl
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  if (echo -n testing; echo 1,2,3) | grep -e -n > /dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi])dnl
+dnl
 define(AC_PROG_CC,
 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
 AC_PROVIDE([$0])dnl
@@ -213,7 +230,7 @@ AC_MSG_CHECKING(for $LEX library)
 if test -z "$LEXLIB"
 then
   case "$LEX" in
-  flex*) AC_CHECK_LIB(fl, LEXLIB="-lfl") ;;
+  flex*) AC_CHECK_LIB(fl, main, LEXLIB="-lfl") ;;
   *) LEXLIB="-ll" ;;
   esac
 fi
@@ -953,15 +970,15 @@ AC_SUBST(NEED_SETGID)dnl
 ac_have_func=no
 
 # Check for the 4.4BSD definition of getloadavg.
-AC_CHECK_LIB(util, [LIBS="$LIBS -lutil" ac_have_func=yes
+AC_CHECK_LIB(util, getloadavg, [LIBS="$LIBS -lutil" ac_have_func=yes
 # Some systems with -lutil have (and need) -lkvm as well, some do not.
-AC_CHECK_LIB(kvm, LIBS="$LIBS -lkvm")])
+AC_CHECK_LIB(kvm, kvm_open,  LIBS="$LIBS -lkvm")])
 
 if test $ac_have_func = no; then
 # There is a commonly available library for RS/6000 AIX.
 # Since it is not a standard part of AIX, it might be installed locally.
 ac_save_LIBS="$LIBS" LIBS="-L/usr/local/lib $LIBS"
-AC_CHECK_LIB(getloadavg, LIBS="$LIBS -lgetloadavg", LIBS="$ac_save_LIBS")
+AC_CHECK_LIB(getloadavg, getloadavg, LIBS="$LIBS -lgetloadavg", LIBS="$ac_save_LIBS")
 fi
 
 # Make sure it is really in the library, if we think we found it.
@@ -973,15 +990,14 @@ else
 ac_have_func=no
 AC_CHECK_HEADER(sys/dg_sys_info.h,
 [ac_have_func=yes AC_DEFINE(DGUX)
-# Some versions of DGUX need -ldgc for dg_sys_info.
-AC_CHECK_LIB(dgc)])
+AC_CHECK_LIB(dgc, dg_sys_info)])
 if test $ac_have_func = no; then
 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
 # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
 # Irix 4.0.5F has the header but not the library.
-AC_CHECK_LIB(elf,
+AC_CHECK_LIB(elf, elf_read,
   [LIBS="$LIBS -lelf" ac_have_func=yes AC_DEFINE(SVR4)
-  AC_CHECK_LIB(kvm, LIBS="$LIBS -lkvm")])
+  AC_CHECK_LIB(kvm, kvm_open, LIBS="$LIBS -lkvm")])
 fi
 if test $ac_have_func = no; then
 AC_CHECK_HEADER(inq_stats/cpustats.h,
@@ -1547,9 +1563,9 @@ dnl
 dnl Internal subroutine of AC_PATH_X.
 define(AC_PATH_X_DIRECT,
 [AC_CHECKING(for X include and library files directly)
-test -z "$x_direct_TRY_library" && x_direct_TRY_library=Xt
-test -z "$x_direct_TRY_include" && x_direct_TRY_include=X11/Intrinsic.h
-AC_TRY_CPP([#include <$x_direct_TRY_include>], no_x=,
+test -z "$x_direct_test_library" && x_direct_test_library=Xt
+test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
+AC_TRY_CPP([#include <$x_direct_test_include>], no_x=,
   for ac_dir in               \
     /usr/X11R6/include        \
     /usr/X11R5/include        \
@@ -1587,7 +1603,7 @@ AC_TRY_CPP([#include <$x_direct_TRY_include>], no_x=,
     /usr/openwin/share/include \
     ; \
   do
-    if test -r "$ac_dir/$x_direct_TRY_include"; then
+    if test -r "$ac_dir/$x_direct_test_include"; then
       test -z "$ac_cv_x_includes" && ac_cv_x_includes=$ac_dir
       no_x=
       break
@@ -1596,7 +1612,7 @@ AC_TRY_CPP([#include <$x_direct_TRY_include>], no_x=,
 
 # Check for the libraries.  First see if replacing the include by
 # lib works.
-AC_CHECK_LIB("$x_direct_TRY_library", no_x=,
+AC_HAVE_LIBRARY("$x_direct_test_library", no_x=,
 for ac_dir in `echo "$ac_cv_x_includes" | sed s/include/lib/` \
     /usr/X11R6/lib        \
     /usr/X11R5/lib        \
@@ -1635,7 +1651,7 @@ for ac_dir in `echo "$ac_cv_x_includes" | sed s/include/lib/` \
     ; \
 do
   for ac_extension in a so sl; do
-    if test -r $ac_dir/lib${x_direct_TRY_library}.$ac_extension; then
+    if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
       test -z "$ac_cv_x_libraries" && ac_cv_x_libraries=$ac_dir
       no_x=
       break 2
@@ -1674,16 +1690,17 @@ else
   # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X
   # libraries were built with DECnet support.  And karl@cs.umb.edu says
   # the Alpha needs dnet_stub (dnet does not exist).
-  AC_CHECK_LIB(dnet,
+  AC_CHECK_LIB(dnet, dnet_ntoa,
     [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" ac_have_dnet=yes], ac_have_dnet=no)
   if test "$ac_have_dnet" = no; then
-    AC_CHECK_LIB(dnet_stub, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
+    AC_CHECK_LIB(dnet_stub, dnet_ntoa,
+      [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
   fi
   # lieder@skyler.mavd.honeywell.com says without -lsocket,
   # socket/setsockopt and other routines are undefined under SCO ODT 2.0.
   # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch.
   if test "`(uname) 2>/dev/null`" != IRIX; then
-    AC_CHECK_LIB(socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"])
+    AC_CHECK_LIB(socket, socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"])
   fi
 fi
 #
@@ -1766,13 +1783,13 @@ fi
 ])dnl
 dnl
 define(AC_OS_SCO,
-[AC_CHECK_LIB(intl, LIBS="$LIBS -lintl")
+[AC_CHECK_LIB(intl, strftime, LIBS="$LIBS -lintl")
 ])dnl
 dnl
 define(AC_OS_IRIX,
-[AC_CHECK_LIB(sun, LIBS="$LIBS -lsun")
+[AC_CHECK_LIB(sun, getmntent, LIBS="$LIBS -lsun")
 ])dnl
 dnl
 define(AC_OS_DYNIX,
-[AC_CHECK_LIB(seq, LIBS="$LIBS -lseq")
+[AC_CHECK_LIB(seq, getmntent, LIBS="$LIBS -lseq")
 ])dnl