Windows: link against LIBHEIMBASE for json functionality
[heimdal.git] / cf / check-getpwnam_r-posix.m4
blob0e9167f07903bc41585f01080a4ca661af47d110
1 dnl $Id$
2 dnl
3 dnl check for getpwnam_r, and if it's posix or not; also check for getpwuid_r
5 AC_DEFUN([AC_CHECK_GETPWNAM_R_POSIX],[
6 AC_FIND_FUNC_NO_LIBS(getpwnam_r,c_r)
7 if test "$ac_cv_func_getpwnam_r" = yes; then
8         AC_CACHE_CHECK(if getpwnam_r is posix,ac_cv_func_getpwnam_r_posix,
9         ac_libs="$LIBS"
10         LIBS="$LIBS $LIB_getpwnam_r"
11         AC_RUN_IFELSE([AC_LANG_SOURCE([[
12 #define _POSIX_PTHREAD_SEMANTICS
13 #include <pwd.h>
14 int main(int argc, char **argv)
16         struct passwd pw, *pwd;
17         return getpwnam_r("", &pw, 0, 0, &pwd) < 0;
19 ]])],[ac_cv_func_getpwnam_r_posix=yes],[ac_cv_func_getpwnam_r_posix=no],[:])
20 LIBS="$ac_libs")
21         AC_CACHE_CHECK(if _POSIX_PTHREAD_SEMANTICS is needed,ac_cv_func_getpwnam_r_posix_def,
22         ac_libs="$LIBS"
23         LIBS="$LIBS $LIB_getpwnam_r"
24         AC_RUN_IFELSE([AC_LANG_SOURCE([[
25 #include <pwd.h>
26 int main(int argc, char **argv)
28         struct passwd pw, *pwd;
29         return getpwnam_r("", &pw, 0, 0, &pwd) < 0;
31 ]])],[ac_cv_func_getpwnam_r_posix_def=no],[ac_cv_func_getpwnam_r_posix_def=yes],[:])
32 LIBS="$ac_libs")
33 if test "$ac_cv_func_getpwnam_r_posix" = yes; then
34         AC_DEFINE(POSIX_GETPWNAM_R, 1, [Define if getpwnam_r has POSIX flavour.])
36 if test "$ac_cv_func_getpwnam_r_posix" = yes -a "$ac_cv_func_getpwnam_r_posix_def" = yes; then
37         AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to get POSIX getpwnam_r in some systems.])
42 AC_DEFUN([AC_CHECK_GETPWUID_R_POSIX],[
43 AC_FIND_FUNC_NO_LIBS(getpwuid_r,c_r)
44 if test "$ac_cv_func_getpwuid_r" = yes; then
45         AC_CACHE_CHECK(if getpwuid_r is posix,ac_cv_func_getpwuid_r_posix,
46         ac_libs="$LIBS"
47         LIBS="$LIBS $LIB_getpwuid_r"
48         AC_RUN_IFELSE([AC_LANG_SOURCE([[
49 #define _POSIX_PTHREAD_SEMANTICS
50 #include <pwd.h>
51 int main(int argc, char **argv)
53         struct passwd pw, *pwd;
54         return getpwuid_r(0, &pw, 0, 0, &pwd) < 0;
56 ]])],[ac_cv_func_getpwuid_r_posix=yes],[ac_cv_func_getpwuid_r_posix=no],[:])
57 LIBS="$ac_libs")
58         AC_CACHE_CHECK(if _POSIX_PTHREAD_SEMANTICS is needed,ac_cv_func_getpwuid_r_posix_def,
59         ac_libs="$LIBS"
60         LIBS="$LIBS $LIB_getpwuid_r"
61         AC_RUN_IFELSE([AC_LANG_SOURCE([[
62 #include <pwd.h>
63 int main(int argc, char **argv)
65         struct passwd pw, *pwd;
66         return getpwuid_r("", &pw, 0, 0, &pwd) < 0;
68 ]])],[ac_cv_func_getpwuid_r_posix_def=no],[ac_cv_func_getpwuid_r_posix_def=yes],[:])
69 LIBS="$ac_libs")
70 if test "$ac_cv_func_getpwuid_r_posix" = yes; then
71         AC_DEFINE(POSIX_GETPWUID_R, 1, [Define if getpwuid_r has POSIX flavour.])