1dnl AC_CHECK_STATICLIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND
2dnl		 [, ACTION-IF-NOT-FOUND  [, OTHER-LIBRARIES]]])
3dnl Like AC_CHECK_LIB but looking for static libraries.
4dnl LIBRARY must be of the form libxxx.a.
5dnl The current language must be C (AC_LANG_C).
6AC_DEFUN([AC_CHECK_STATICLIB],
7[AC_MSG_CHECKING([for $2 in $1])
8dnl Use a cache variable name containing both the library and function name,
9dnl because the test really is for library $1 defining function $2, not
10dnl just for library $1.  Separate tests with the same $1 and different $2s
11dnl may have different results.
12ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
13AC_CACHE_VAL(ac_cv_lib_static_$ac_lib_var,
14if test -r /etc/ld.so.conf ; then
15  ld_so_paths="/lib /usr/lib `cat /etc/ld.so.conf`"
16else
17  ld_so_paths="/lib /usr/lib"
18fi
19for path in $ld_so_paths; do
20  [ac_save_LIBS="$LIBS"
21  LIBS="$path/$1 $5 $LIBS"
22  AC_TRY_LINK(dnl
23  ifelse([$2], [main], , dnl Avoid conflicting decl of main.
24  [/* Override any gcc2 internal prototype to avoid an error.  */
25  ]dnl
26  [/* We use char because int might match the return type of a gcc2
27      builtin and then its argument prototype would still apply.  */
28  char $2();
29  ]),
30	      [$2()],
31	      eval "ac_cv_lib_static_$ac_lib_var=$path/$1",
32	      eval "ac_cv_lib_static_$ac_lib_var=no")
33  LIBS="$ac_save_LIBS"
34  if eval "test \"`echo '$ac_cv_lib_static_'$ac_lib_var`\" != no"; then
35    break
36  fi
37done
38])dnl
39eval result=\"`echo '$ac_cv_lib_static_'$ac_lib_var`\"
40if test "$result" != no; then
41  AC_MSG_RESULT($result)
42  ifelse([$3], ,
43[changequote(, )dnl
44  ac_tr_lib=HAVE_`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
45    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
46changequote([, ])dnl
47  AC_DEFINE_UNQUOTED($ac_tr_lib, 1, Define if static library is available.)
48  LIBS="$result $LIBS"
49], [$3])
50else
51  AC_MSG_RESULT(no)
52ifelse([$4], , , [$4
53])dnl
54fi
55])
56
57AC_DEFUN([BASH_CHECK_GETPW_FUNCS],
58[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
59AC_CACHE_VAL(bash_cv_can_redecl_getpw,
60[AC_TRY_COMPILE([#include <sys/types.h>
61#include <pwd.h>
62extern struct passwd *getpwent();
63extern struct passwd *getpwuid();
64extern struct passwd *getpwnam();],
65[struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");],
66  bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
67AC_MSG_RESULT($bash_cv_can_redecl_getpw)
68if test $bash_cv_can_redecl_getpw = no; then
69AC_DEFINE([HAVE_GETPW_DECLS], 1, [Define this when you are able to redeclare getpw functions.])
70fi
71])
72