Move all the pdb_get...() and pdb_set...() functions to a new file.
[ira/wip.git] / source / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(include/includes.h)
3 AC_CONFIG_HEADER(include/config.h)
4 # we want to be compatible with older versions of Samba
5 AC_PREFIX_DEFAULT(/usr/local/samba)
6
7 dnl Unique-to-Samba variables we'll be playing with.
8 AC_SUBST(SHELL)
9 AC_SUBST(RUNPROG)
10 AC_SUBST(MPROGS)
11 AC_SUBST(LDSHFLAGS)
12 AC_SUBST(SHLD)
13 AC_SUBST(HOST_OS)
14 AC_SUBST(PAM_MOD)
15 AC_SUBST(WRAP)
16 AC_SUBST(WRAP32)
17 AC_SUBST(PICFLAG)
18 AC_SUBST(PICSUFFIX)
19 AC_SUBST(POBAD_CC)
20 AC_SUBST(SHLIBEXT)
21 AC_SUBST(LIBSMBCLIENT_SHARED)
22
23 # compile with optimisation and without debugging by default
24 CFLAGS="-O ${CFLAGS}"
25
26 AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging [default=no]],
27     [if eval "test x$enable_debug = xyes"; then
28         CFLAGS="${CFLAGS} -g"
29     fi])
30
31 AC_ARG_ENABLE(developer, [  --enable-developer      turn on developer warnings and debugging [default=no]],
32     [if eval "test x$enable_developer = xyes"; then
33         CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
34     fi])
35
36 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc          enable heap debugging [default=no]])
37
38 if test "x$enable_dmalloc" = xyes
39 then
40         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
41         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
42                   [Define to check invariants around some common functions])
43         LIBS="$LIBS -ldmalloc"  
44 fi
45
46 dnl Checks for programs.
47 AC_PROG_CC
48 AC_PROG_INSTALL
49 AC_PROG_AWK
50
51 dnl needed before AC_TRY_COMPILE
52 AC_ISC_POSIX
53
54 dnl Check if C compiler understands -c and -o at the same time
55 AC_PROG_CC_C_O
56 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
57       BROKEN_CC=
58 else
59       BROKEN_CC=#
60 fi
61 AC_SUBST(BROKEN_CC)
62
63 dnl Check if the C compiler understands volatile (it should, being ANSI).
64 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
65     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
66         samba_cv_volatile=yes,samba_cv_volatile=no)])
67 if test x"$samba_cv_volatile" = x"yes"; then
68    AC_DEFINE(HAVE_VOLATILE)
69 fi
70
71
72 AC_CANONICAL_SYSTEM
73
74 dnl Add #include for broken IRIX header files
75   case "$host_os" in
76         *irix6*) AC_ADD_INCLUDE(<standards.h>)
77         ;;
78 esac
79
80 AC_VALIDATE_CACHE_SYSTEM_TYPE
81
82 #
83 # Config CPPFLAG settings for strange OS's that must be set
84 # before other tests.
85 #
86 case "$host_os" in
87 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
88     *hpux*)
89       AC_PROG_CC_FLAG(Ae)
90       # mmap on HPUX is completely broken...
91       AC_DEFINE(MMAP_BLACKLIST)
92       if test $ac_cv_prog_cc_Ae = yes; then
93         CPPFLAGS="$CPPFLAGS -Ae"
94       fi
95 #
96 # Defines needed for HPUX support.
97 # HPUX has bigcrypt but (sometimes?) doesn't use it for
98 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
99 #
100       case `uname -r` in
101                         *9*|*10*)
102                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE"
103                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
104                                 ;;
105                         *11*)
106                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE"
107                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
108                                 ;;
109       esac
110       ;;
111
112 #
113 # CRAY Unicos has broken const handling
114        *unicos*)
115           AC_MSG_RESULT([disabling const])
116           CPPFLAGS="$CPPFLAGS -Dconst="
117           ;;
118         
119 #
120 # AIX4.x doesn't even admit to having large
121 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
122 #
123     *aix4*)
124           AC_MSG_RESULT([enabling large file support])
125       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
126       ;;    
127 #
128 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
129 # to the existance of large files..
130 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
131 # recommendations on large file support, however it makes the
132 # compile work using gcc 2.7 and 2.8, whereas using the Sun
133 # recommendation makes the compile fail on gcc2.7. JRA.
134 #
135         *solaris*)
136                 case `uname -r` in
137                         5.0*|5.1*|5.2*|5.3*|5.5*)
138                                 AC_MSG_RESULT([no large file support])
139                                 ;;
140                         5.*)
141                         AC_MSG_RESULT([enabling large file support])
142                         if test "$ac_cv_prog_gcc" = yes; then
143                                 ${CC-cc} -v >conftest.c 2>&1
144                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
145                                 rm -fr conftest.c
146                                 case "$ac_cv_gcc_compiler_version_number" in
147                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
148                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
149                                                 ;;
150                                         *)
151                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
152                                                 ;;
153                                 esac
154                         else
155                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
156                         fi
157                         ;;
158                 esac
159                 ;;
160 #
161 # Tests needed for SINIX large file support.
162 #
163     *sysv4*)
164       if test $host = mips-sni-sysv4 ; then
165         AC_MSG_CHECKING([for LFS support])
166         old_CPPFLAGS="$CPPFLAGS"
167         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
168         AC_TRY_RUN([
169 #include <unistd.h>
170 main () {
171 #if _LFS64_LARGEFILE == 1
172 exit(0);
173 #else
174 exit(1);
175 #endif
176 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
177         CPPFLAGS="$old_CPPFLAGS"
178         if test x$SINIX_LFS_SUPPORT = xyes ; then
179           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
180           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
181           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
182           LIBS="`getconf LFS64_LIBS` $LIBS"
183         fi
184       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
185       fi
186     ;;
187
188 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
189 #
190     *linux*)
191         AC_MSG_CHECKING([for LFS support])
192         old_CPPFLAGS="$CPPFLAGS"
193         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
194        AC_TRY_RUN([
195 #include <unistd.h>
196 #include <sys/utsname.h>
197 main() {
198 #if _LFS64_LARGEFILE == 1
199        struct utsname uts;
200        char *release;
201        int major, minor;
202
203        /* Ensure this is glibc 2.2 or higher */
204 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
205        int libc_major = __GLIBC__;
206        int libc_minor = __GLIBC_MINOR__;
207
208        if (libc_major < 2)
209               exit(1);
210        if (libc_minor < 2)
211               exit(1);
212 #endif
213
214        /* Ensure this is kernel 2.4 or higher */
215
216        uname(&uts);
217        release = uts.release;
218        major = atoi(strsep(&release, "."));
219        minor = atoi(strsep(&release, "."));
220
221        if (major > 2 || (major == 2 && minor > 3))
222                exit(0);
223        exit(1);
224 #else
225        exit(1);
226 #endif
227 }
228 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
229         CPPFLAGS="$old_CPPFLAGS"
230         if test x$LINUX_LFS_SUPPORT = xyes ; then
231           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
232         fi
233        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
234                 ;;
235
236     *hurd*)
237         AC_MSG_CHECKING([for LFS support])
238         old_CPPFLAGS="$CPPFLAGS"
239         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
240         AC_TRY_RUN([
241 #include <unistd.h>
242 main () {
243 #if _LFS64_LARGEFILE == 1
244 exit(0);
245 #else
246 exit(1);
247 #endif
248 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
249         CPPFLAGS="$old_CPPFLAGS"
250         if test x$GLIBC_LFS_SUPPORT = xyes ; then
251           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
252         fi
253       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
254     ;;
255
256 esac
257
258 AC_INLINE
259 AC_HEADER_STDC
260 AC_HEADER_DIRENT
261 AC_HEADER_TIME
262 AC_HEADER_SYS_WAIT
263 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
264 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
265 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
266 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
267 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
268 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
269 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
270 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h ldap.h lber.h)
271
272 #
273 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
274 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
275 #
276 case "$host_os" in
277     *hpux*)
278                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
279                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
280                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
281                    AC_DEFINE(HAVE_SHADOW_H)
282                 fi
283         ;;
284 esac
285 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
286 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
287 AC_CHECK_HEADERS(stropts.h poll.h)
288 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
289 AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
290
291 # For experimental utmp support (lastlog on some BSD-like systems)
292 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
293  
294 # For quotas on Veritas VxFS filesystems
295 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
296
297 # For quotas on Linux XFS filesystems
298 AC_CHECK_HEADERS(linux/xqm.h)
299
300 AC_CHECK_SIZEOF(int,cross)
301 AC_CHECK_SIZEOF(long,cross)
302 AC_CHECK_SIZEOF(short,cross)
303
304 AC_C_CONST
305 AC_C_INLINE
306 AC_C_BIGENDIAN
307 AC_C_CHAR_UNSIGNED
308
309 AC_TYPE_SIGNAL
310 AC_TYPE_UID_T
311 AC_TYPE_MODE_T
312 AC_TYPE_OFF_T
313 AC_TYPE_SIZE_T
314 AC_TYPE_PID_T
315 AC_STRUCT_ST_RDEV
316 AC_DIRENT_D_OFF
317 AC_CHECK_TYPE(ino_t,unsigned)
318 AC_CHECK_TYPE(loff_t,off_t)
319 AC_CHECK_TYPE(offset_t,loff_t)
320 AC_CHECK_TYPE(ssize_t, int)
321 AC_CHECK_TYPE(wchar_t, unsigned short)
322
323 ############################################
324 # for cups support we need libcups, and a handful of header files
325
326 AC_CHECK_LIB(cups,httpConnect)
327
328 # I wonder if there is a nicer way of doing this?
329
330 if test x"$ac_cv_lib_cups_httpConnect" = x"yes"; then
331         AC_CHECK_HEADERS(cups/cups.h cups/language.h)
332         if test x"$ac_cv_header_cups_cups_h" = x"yes"; then
333                 if test x"$ac_cv_header_cups_language_h" = x"yes"; then
334                         AC_DEFINE(HAVE_CUPS)
335                 fi
336         fi
337 fi
338
339 ############################################
340 # we need libdl for PAM and the new VFS code
341 AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
342         AC_DEFINE(HAVE_LIBDL)])
343
344 ############################################
345 # check if the compiler can do immediate structures
346 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
347     AC_TRY_COMPILE([
348 #include <stdio.h>],
349 [
350    #define X_FOOBAR(x) ((FOOBAR) { x })
351    typedef struct {unsigned x;} FOOBAR;
352    FOOBAR f = X_FOOBAR(1);   
353 ],
354         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
355 if test x"$samba_cv_immediate_structures" = x"yes"; then
356    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES)
357 fi
358
359 ############################################
360 # check for unix domain sockets
361 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
362     AC_TRY_COMPILE([
363 #include <sys/types.h>
364 #include <stdlib.h>
365 #include <stddef.h>
366 #include <sys/socket.h>
367 #include <sys/un.h>],
368 [
369   struct sockaddr_un sunaddr; 
370   sunaddr.sun_family = AF_UNIX;
371 ],
372         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
373 if test x"$samba_cv_unixsocket" = x"yes"; then
374    AC_DEFINE(HAVE_UNIXSOCKET)
375 fi
376
377
378 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
379     AC_TRY_COMPILE([
380 #include <sys/types.h>
381 #if STDC_HEADERS
382 #include <stdlib.h>
383 #include <stddef.h>
384 #endif
385 #include <sys/socket.h>],[socklen_t i = 0],
386         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
387 if test x"$samba_cv_socklen_t" = x"yes"; then
388    AC_DEFINE(HAVE_SOCKLEN_T_TYPE)
389 fi
390
391 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
392     AC_TRY_COMPILE([
393 #include <sys/types.h>
394 #if STDC_HEADERS
395 #include <stdlib.h>
396 #include <stddef.h>
397 #endif
398 #include <signal.h>],[sig_atomic_t i = 0],
399         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
400 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
401    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE)
402 fi
403
404 # stupid headers have the functions but no declaration. grrrr.
405 AC_HAVE_DECL(errno, [#include <errno.h>])
406 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
407 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
408 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
409 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
410 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
411 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
412
413 # and glibc has setresuid under linux but the function does
414 # nothing until kernel 2.1.44! very dumb.
415 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
416     AC_TRY_RUN([#include <errno.h>
417 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
418         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
419 if test x"$samba_cv_have_setresuid" = x"yes"; then
420     AC_DEFINE(HAVE_SETRESUID)
421 fi
422
423 # Do the same check for setresguid...
424 #
425 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
426     AC_TRY_RUN([#include <unistd.h>
427 #include <errno.h>
428 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
429         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
430 if test x"$samba_cv_have_setresgid" = x"yes"; then
431     AC_DEFINE(HAVE_SETRESGID)
432 fi
433
434 AC_FUNC_MEMCMP
435
436 ###############################################
437 # test for where we get crypt() from
438 AC_CHECK_FUNCS(crypt)
439 if test x"$ac_cv_func_crypt" = x"no"; then
440     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
441         AC_DEFINE(HAVE_CRYPT)])
442 fi
443
444
445 ###############################################
446 # Readline included by default unless explicitly asked not to
447 test "${with_readline+set}" != "set" && with_readline=yes
448
449 # test for where we get readline() from
450 AC_MSG_CHECKING(whether to use readline)
451 AC_ARG_WITH(readline,
452 [  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto) ],
453 [  case "$with_readline" in
454   yes)
455     AC_MSG_RESULT(yes)
456
457     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
458     AC_CHECK_HEADERS(readline/history.h)
459
460     AC_CHECK_HEADERS(readline.h readline/readline.h,[
461       for termlib in ncurses curses termcap terminfo termlib; do
462        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
463       done
464       AC_CHECK_LIB(readline, rl_callback_handler_install,
465        [TERMLIBS="-lreadline $TERMLIBS"
466        AC_DEFINE(HAVE_LIBREADLINE)
467        break], [TERMLIBS=], $TERMLIBS)])
468     ;;
469   no)
470     AC_MSG_RESULT(no)
471     ;;
472   *)
473     AC_MSG_RESULT(yes)
474
475     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
476     # alternate readline path
477     _ldflags=${LDFLAGS}
478     _cppflags=${CPPFLAGS}
479
480     # Add additional search path
481     LDFLAGS="-L$with_readline/lib $LDFLAGS"
482     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
483
484     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
485     AC_CHECK_HEADERS(readline/history.h)
486
487     AC_CHECK_HEADERS(readline.h readline/readline.h,[
488       for termlib in ncurses curses termcap terminfo termlib; do
489        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
490       done
491       AC_CHECK_LIB(readline, rl_callback_handler_install,
492        [TERMLDFLAGS="-L$with_readline/lib"
493        TERMCPPFLAGS="-I$with_readline/include"
494        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
495        TERMLIBS="-lreadline $TERMLIBS"
496        AC_DEFINE(HAVE_LIBREADLINE)
497        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
498
499     LDFLAGS=$_ldflags
500     ;;
501   esac],
502   AC_MSG_RESULT(no)
503 )
504 AC_SUBST(TERMLIBS)
505 AC_SUBST(TERMLDFLAGS)
506
507 # The readline API changed slightly from readline3 to readline4, so
508 # code will generate warnings on one of them unless we have a few
509 # special cases.
510 AC_CHECK_LIB(readline, rl_completion_matches,
511              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
512                         [Do we have rl_completion_matches?])],
513              [],
514              [$TERMLIBS])
515
516 # The following test taken from the cvs sources
517 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
518 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
519 # libsocket.so which has a bad implementation of gethostbyname (it
520 # only looks in /etc/hosts), so we only look for -lsocket if we need
521 # it.
522 AC_CHECK_FUNCS(connect)
523 if test x"$ac_cv_func_connect" = x"no"; then
524     case "$LIBS" in
525     *-lnsl*) ;;
526     *) AC_CHECK_LIB(nsl_s, printf) ;;
527     esac
528     case "$LIBS" in
529     *-lnsl*) ;;
530     *) AC_CHECK_LIB(nsl, printf) ;;
531     esac
532     case "$LIBS" in
533     *-lsocket*) ;;
534     *) AC_CHECK_LIB(socket, connect) ;;
535     esac
536     case "$LIBS" in
537     *-linet*) ;;
538     *) AC_CHECK_LIB(inet, connect) ;;
539     esac
540     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
541     dnl has been cached.
542     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
543        test x"$ac_cv_lib_inet_connect" = x"yes"; then
544         # ac_cv_func_connect=yes
545         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
546         AC_DEFINE(HAVE_CONNECT)
547     fi
548 fi
549
550 ###############################################
551 # test for where we get get_yp_default_domain() from
552 AC_CHECK_FUNCS(yp_get_default_domain)
553 if test x"$ac_cv_func_yp_get_default_domain" = x"no"; then
554         AC_CHECK_LIB(nsl, yp_get_default_domain, [LIBS="$LIBS -lnsl";
555         AC_DEFINE(HAVE_YP_GET_DEFAULT_DOMAIN)]) 
556 fi
557
558 # Check if we have execl, if not we need to compile smbrun.
559 AC_CHECK_FUNCS(execl)
560 if test x"$ac_cv_func_execl" = x"no"; then
561     RUNPROG="bin/smbrun"
562 else
563     RUNPROG=""
564 fi
565
566 AC_CHECK_FUNCS(waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
567 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
568 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
569 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
570 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
571 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
572 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
573 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
574 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
575 AC_CHECK_FUNCS(syslog vsyslog)
576 # setbuffer is needed for smbtorture
577 AC_CHECK_FUNCS(setbuffer)
578
579 # syscall() is needed for smbwrapper.
580 AC_CHECK_FUNCS(syscall)
581
582 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
583 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
584 AC_CHECK_FUNCS(__getcwd _getcwd)
585 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
586 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
587 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
588 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
589 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
590 AC_CHECK_FUNCS(_write __write _fork __fork)
591 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
592 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
593 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
594 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
595 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
596
597 #
598 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
599 #
600
601 if test x$ac_cv_func_stat64 = xno ; then
602   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
603   AC_TRY_LINK([
604 #if defined(HAVE_UNISTD_H)
605 #include <unistd.h>
606 #endif
607 #include <sys/stat.h>
608 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
609   AC_MSG_RESULT([$ac_cv_func_stat64])
610   if test x$ac_cv_func_stat64 = xyes ; then
611     AC_DEFINE(HAVE_STAT64)
612   fi
613 fi
614
615 if test x$ac_cv_func_lstat64 = xno ; then
616   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
617   AC_TRY_LINK([
618 #if defined(HAVE_UNISTD_H)
619 #include <unistd.h>
620 #endif
621 #include <sys/stat.h>
622 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
623   AC_MSG_RESULT([$ac_cv_func_lstat64])
624   if test x$ac_cv_func_lstat64 = xyes ; then
625     AC_DEFINE(HAVE_LSTAT64)
626   fi
627 fi
628
629 if test x$ac_cv_func_fstat64 = xno ; then
630   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
631   AC_TRY_LINK([
632 #if defined(HAVE_UNISTD_H)
633 #include <unistd.h>
634 #endif
635 #include <sys/stat.h>
636 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
637   AC_MSG_RESULT([$ac_cv_func_fstat64])
638   if test x$ac_cv_func_fstat64 = xyes ; then
639     AC_DEFINE(HAVE_FSTAT64)
640   fi
641 fi
642
643 #####################################
644 # we might need the resolv library on some systems
645 AC_CHECK_LIB(resolv, dn_expand)
646
647 #
648 # Check for the functions putprpwnam, set_auth_parameters,
649 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
650 # Needed for OSF1 and HPUX.
651 #
652
653 AC_LIBTESTFUNC(security, putprpwnam)
654 AC_LIBTESTFUNC(sec, putprpwnam)
655
656 AC_LIBTESTFUNC(security, set_auth_parameters)
657 AC_LIBTESTFUNC(sec, set_auth_parameters)
658
659 # UnixWare 7.x has its getspnam in -lgen
660 AC_LIBTESTFUNC(gen, getspnam)
661
662 AC_LIBTESTFUNC(security, getspnam)
663 AC_LIBTESTFUNC(sec, getspnam)
664
665 AC_LIBTESTFUNC(security, bigcrypt)
666 AC_LIBTESTFUNC(sec, bigcrypt)
667
668 AC_LIBTESTFUNC(security, getprpwnam)
669 AC_LIBTESTFUNC(sec, getprpwnam)
670
671 # this bit needs to be modified for each OS that is suported by
672 # smbwrapper. You need to specify how to created a shared library and
673 # how to compile C code to produce PIC object files
674
675 # these are the defaults, good for lots of systems
676 HOST_OS="$host_os"
677 LDSHFLAGS="-shared"
678 SHLD="\${CC}"
679 PICFLAG=""
680 PICSUFFIX="po"
681 POBAD_CC="#"
682 SHLIBEXT="so"
683 # Assume non-shared by default and override below
684 BLDSHARED="false"
685 AC_MSG_CHECKING([ability to build shared libraries])
686
687 # and these are for particular systems
688 case "$host_os" in
689                 *linux*)   AC_DEFINE(LINUX)
690                         BLDSHARED="true"
691                         LDSHFLAGS="-shared" 
692                         PICFLAG="-fPIC"
693                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
694                 ;;
695                 *solaris*) AC_DEFINE(SUNOS5)
696                         BLDSHARED="true"
697                         LDSHFLAGS="-h \$@ -G"
698                         if test "${ac_cv_prog_CC}" = "gcc"; then
699                                 PICFLAG="-fPIC"
700                         else
701                                 PICFLAG="-KPIC"
702                                 POBAD_CC=""
703                                 PICSUFFIX="po.o"
704                         fi
705                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
706                 ;;
707                 *sunos*) AC_DEFINE(SUNOS4)
708                         BLDSHARED="true"
709                         LDSHFLAGS="-Wl,-h,\$@ -G"
710                         PICFLAG="-KPIC"   # Is this correct for SunOS
711                 ;;
712                 *bsd*)  BLDSHARED="true"
713                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
714                         PICFLAG="-fPIC"
715                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
716                 ;;
717                 *irix*) AC_DEFINE(IRIX)
718                         case "$host_os" in
719                         *irix6*) AC_DEFINE(IRIX6)
720                         ;;
721                         esac
722                         ATTEMPT_WRAP32_BUILD=yes
723                         BLDSHARED="true"
724                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
725                         if test "${ac_cv_prog_CC}" = "gcc"; then
726                                 PICFLAG="-fPIC"
727                         else 
728                                 PICFLAG="-KPIC"
729                         fi
730                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
731                 ;;
732                 *aix*) AC_DEFINE(AIX)
733                         BLDSHARED="true"
734                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
735                         PICFLAG="-O2 -qmaxmem=6000"
736                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE)
737                 ;;
738                 *hpux*) AC_DEFINE(HPUX)
739                         SHLIBEXT="sl"
740                         # Use special PIC flags for the native HP-UX compiler.
741                         if test $ac_cv_prog_cc_Ae = yes; then
742                                 #BLDSHARED="true"
743                                 LDSHFLAGS="-b -z +h \$@"
744                                 PICFLAG="+z"
745                         fi
746                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192)
747                 ;;
748                 *qnx*) AC_DEFINE(QNX);;
749                 *osf*) AC_DEFINE(OSF1)
750                         BLDSHARED="true"
751                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
752                         PICFLAG="-fPIC"
753                 ;;
754                 *sco*) AC_DEFINE(SCO);;
755                 *unixware*) AC_DEFINE(UNIXWARE)
756                         BLDSHARED="true"
757                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
758                         PICFLAG="-KPIC"
759                 ;;
760                 *next2*) AC_DEFINE(NEXT2);;
761                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
762                 *sysv4*)
763                         case "$host" in
764                                 *-univel-*)     if [ test "$GCC" != yes ]; then
765                                                                         AC_DEFINE(HAVE_MEMSET)
766                                                                 fi
767                                                                 LDSHFLAGS="-G"
768                                 ;;
769                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX);;
770                         esac
771                         ;;
772                 *sysv5*)
773                         if [ test "$GCC" != yes ]; then
774                                 AC_DEFINE(HAVE_MEMSET)
775                         fi
776                         LDSHFLAGS="-G"
777                         ;;
778 esac
779 AC_MSG_RESULT($BLDSHARED)
780 AC_MSG_CHECKING([linker flags for shared libraries])
781 AC_MSG_RESULT([$LDSHFLAGS])
782 AC_MSG_CHECKING([compiler flags for position-independent code])
783 AC_MSG_RESULT([$PICFLAGS])
784
785 #######################################################
786 # test whether building a shared library actually works
787 if test $BLDSHARED = true; then
788 AC_CACHE_CHECK([whether building shared libraries actually works], 
789                [ac_cv_shlib_works],[
790    ac_cv_shlib_works=no
791    # try building a trivial shared library
792    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/tests/shlib.c &&
793      $CC $CPPFLAGS $CFLAGS $LDSHFLAGS -o shlib.so shlib.po &&
794      ac_cv_shlib_works=yes
795    rm -f shlib.so shlib.po
796 ])
797 if test $ac_cv_shlib_works = no; then
798    BLDSHARED=false
799 fi
800 fi
801
802
803 # this updates our target list if we can build shared libs
804 if test $BLDSHARED = true; then
805    LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
806 else
807    LIBSMBCLIENT_SHARED=
808 fi
809
810 ################
811
812 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
813 AC_TRY_RUN([#include <stdio.h>
814 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
815 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
816 if test x"$samba_cv_have_longlong" = x"yes"; then
817     AC_DEFINE(HAVE_LONGLONG)
818 fi
819
820 #
821 # Check if the compiler supports the LL prefix on long long integers.
822 # AIX needs this.
823
824 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
825     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
826         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
827 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
828    AC_DEFINE(COMPILER_SUPPORTS_LL)
829 fi
830
831   
832 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
833 AC_TRY_RUN([#include <stdio.h>
834 #include <sys/stat.h>
835 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
836 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
837 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
838     AC_DEFINE(SIZEOF_OFF_T,8)
839 fi
840
841 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
842 AC_TRY_RUN([
843 #if defined(HAVE_UNISTD_H)
844 #include <unistd.h>
845 #endif
846 #include <stdio.h>
847 #include <sys/stat.h>
848 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
849 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
850 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
851     AC_DEFINE(HAVE_OFF64_T)
852 fi
853
854 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
855 AC_TRY_RUN([#include <stdio.h>
856 #include <sys/stat.h>
857 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
858 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
859 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
860     AC_DEFINE(SIZEOF_INO_T,8)
861 fi
862
863 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
864 AC_TRY_RUN([
865 #if defined(HAVE_UNISTD_H)
866 #include <unistd.h>
867 #endif
868 #include <stdio.h>
869 #include <sys/stat.h>
870 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
871 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
872 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
873     AC_DEFINE(HAVE_INO64_T)
874 fi
875
876 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
877 AC_TRY_RUN([
878 #if defined(HAVE_UNISTD_H)
879 #include <unistd.h>
880 #endif
881 #include <stdio.h>
882 #include <sys/stat.h>
883 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
884 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
885 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
886     AC_DEFINE(HAVE_DEV64_T)
887 fi
888
889 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
890 AC_TRY_COMPILE([
891 #if defined(HAVE_UNISTD_H)
892 #include <unistd.h>
893 #endif
894 #include <sys/types.h>
895 #include <dirent.h>],
896 [struct dirent64 de;],
897 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
898 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes"; then
899     AC_DEFINE(HAVE_STRUCT_DIRENT64)
900 fi
901
902 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
903 AC_TRY_RUN([
904 #if defined(HAVE_UNISTD_H)
905 #include <unistd.h>
906 #endif
907 #include <sys/types.h>
908 main() { dev_t dev; int i = major(dev); return 0; }],
909 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
910 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
911     AC_DEFINE(HAVE_DEVICE_MAJOR_FN)
912 fi
913
914 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
915 AC_TRY_RUN([
916 #if defined(HAVE_UNISTD_H)
917 #include <unistd.h>
918 #endif
919 #include <sys/types.h>
920 main() { dev_t dev; int i = minor(dev); return 0; }],
921 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
922 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
923     AC_DEFINE(HAVE_DEVICE_MINOR_FN)
924 fi
925
926 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
927 AC_TRY_RUN([#include <stdio.h>
928 main() { char c; c=250; exit((c > 0)?0:1); }],
929 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
930 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
931     AC_DEFINE(HAVE_UNSIGNED_CHAR)
932 fi
933
934 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
935 AC_TRY_COMPILE([#include <sys/types.h>
936 #include <sys/socket.h>
937 #include <netinet/in.h>],
938 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
939 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
940 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
941     AC_DEFINE(HAVE_SOCK_SIN_LEN)
942 fi
943
944 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
945 AC_TRY_COMPILE([#include <sys/types.h>
946 #include <dirent.h>
947 void seekdir(DIR *d, long loc) { return; }],[return 0;],
948 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
949 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
950     AC_DEFINE(SEEKDIR_RETURNS_VOID)
951 fi
952
953 AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
954 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
955 samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
956 if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
957     AC_DEFINE(HAVE_FILE_MACRO)
958 fi
959
960 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
961 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
962 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
963 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
964     AC_DEFINE(HAVE_FUNCTION_MACRO)
965 fi
966
967 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
968 AC_TRY_RUN([
969 #include <sys/time.h>
970 #include <unistd.h>
971 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
972            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
973 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
974     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
975 fi
976
977 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
978 AC_TRY_RUN([
979 #include <sys/types.h>
980 #include <stdarg.h>
981 void foo(const char *format, ...) { 
982        va_list ap;
983        int len;
984        char buf[5];
985
986        va_start(ap, format);
987        len = vsnprintf(0, 0, format, ap);
988        va_end(ap);
989        if (len != 5) exit(1);
990
991        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
992
993        exit(0);
994 }
995 main() { foo("hello"); }
996 ],
997 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
998 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
999     AC_DEFINE(HAVE_C99_VSNPRINTF)
1000 fi
1001
1002 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1003 AC_TRY_RUN([#include <sys/types.h>
1004 #include <dirent.h>
1005 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1006 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1007 di->d_name[0] == 0) exit(0); exit(1);} ],
1008 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1009 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1010     AC_DEFINE(HAVE_BROKEN_READDIR)
1011 fi
1012
1013 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1014 AC_TRY_COMPILE([#include <sys/types.h>
1015 #include <utime.h>],
1016 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1017 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1018 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1019     AC_DEFINE(HAVE_UTIMBUF)
1020 fi
1021
1022 dnl  utmp and utmpx come in many flavours
1023 dnl  We need to check for many of them
1024 dnl  But we don't need to do each and every one, because our code uses
1025 dnl  mostly just the utmp (not utmpx) fields.
1026
1027 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1028
1029 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1030 AC_TRY_COMPILE([#include <sys/types.h>
1031 #include <utmp.h>],
1032 [struct utmp ut;  ut.ut_name[0] = 'a';],
1033 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1034 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1035     AC_DEFINE(HAVE_UT_UT_NAME)
1036 fi 
1037
1038 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1039 AC_TRY_COMPILE([#include <sys/types.h>
1040 #include <utmp.h>],
1041 [struct utmp ut;  ut.ut_user[0] = 'a';],
1042 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1043 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1044     AC_DEFINE(HAVE_UT_UT_USER)
1045 fi 
1046
1047 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1048 AC_TRY_COMPILE([#include <sys/types.h>
1049 #include <utmp.h>],
1050 [struct utmp ut;  ut.ut_id[0] = 'a';],
1051 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1052 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1053     AC_DEFINE(HAVE_UT_UT_ID)
1054 fi 
1055
1056 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1057 AC_TRY_COMPILE([#include <sys/types.h>
1058 #include <utmp.h>],
1059 [struct utmp ut;  ut.ut_host[0] = 'a';],
1060 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1061 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1062     AC_DEFINE(HAVE_UT_UT_HOST)
1063 fi 
1064
1065 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1066 AC_TRY_COMPILE([#include <sys/types.h>
1067 #include <utmp.h>],
1068 [struct utmp ut;  time_t t; ut.ut_time = t;],
1069 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1070 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1071     AC_DEFINE(HAVE_UT_UT_TIME)
1072 fi 
1073
1074 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1075 AC_TRY_COMPILE([#include <sys/types.h>
1076 #include <utmp.h>],
1077 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1078 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1079 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1080     AC_DEFINE(HAVE_UT_UT_TV)
1081 fi 
1082
1083 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1084 AC_TRY_COMPILE([#include <sys/types.h>
1085 #include <utmp.h>],
1086 [struct utmp ut;  ut.ut_type = 0;],
1087 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1088 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1089     AC_DEFINE(HAVE_UT_UT_TYPE)
1090 fi 
1091
1092 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1093 AC_TRY_COMPILE([#include <sys/types.h>
1094 #include <utmp.h>],
1095 [struct utmp ut;  ut.ut_pid = 0;],
1096 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1097 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1098     AC_DEFINE(HAVE_UT_UT_PID)
1099 fi 
1100
1101 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1102 AC_TRY_COMPILE([#include <sys/types.h>
1103 #include <utmp.h>],
1104 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1105 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1106 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1107     AC_DEFINE(HAVE_UT_UT_EXIT)
1108 fi 
1109
1110 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1111 AC_TRY_COMPILE([#include <sys/types.h>
1112 #include <utmp.h>],
1113 [struct utmp ut;  ut.ut_addr = 0;],
1114 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1115 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1116     AC_DEFINE(HAVE_UT_UT_ADDR)
1117 fi 
1118
1119 if test x$ac_cv_func_pututline = xyes ; then
1120   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1121   AC_TRY_COMPILE([#include <sys/types.h>
1122 #include <utmp.h>],
1123   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1124   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1125   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1126       AC_DEFINE(PUTUTLINE_RETURNS_UTMP)
1127   fi
1128 fi
1129
1130 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1131 AC_TRY_COMPILE([#include <sys/types.h>
1132 #include <utmpx.h>],
1133 [struct utmpx ux;  ux.ut_syslen = 0;],
1134 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1135 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1136     AC_DEFINE(HAVE_UX_UT_SYSLEN)
1137 fi 
1138
1139
1140 #################################################
1141 # check for libiconv support
1142 AC_MSG_CHECKING(whether to use libiconv)
1143 AC_ARG_WITH(libiconv,
1144 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1145 [ case "$withval" in
1146   no)
1147     AC_MSG_RESULT(no)
1148     ;;
1149   *)
1150     AC_MSG_RESULT(yes)
1151     CFLAGS="$CFLAGS -I$withval/include"
1152     LDFLAGS="$LDFLAGS -L$withval/lib"
1153     AC_CHECK_LIB(iconv, iconv_open)
1154     AC_DEFINE_UNQUOTED(WITH_LIBICONV, "${withval}")
1155     ;;
1156   esac ],
1157   AC_MSG_RESULT(no)
1158 )
1159
1160
1161 ############
1162 # check for iconv in libc
1163 AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1164 AC_TRY_RUN([
1165 #include <iconv.h>
1166 main() {
1167        iconv_t cd = iconv_open("ASCII", "UCS-2LE");
1168        if (cd == 0 || cd == (iconv_t)-1) return -1;
1169        return 0;
1170 }
1171 ],
1172 samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
1173 if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1174     AC_DEFINE(HAVE_NATIVE_ICONV)
1175 fi
1176
1177
1178 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1179 AC_TRY_RUN([
1180 #include <sys/types.h>
1181 #include <fcntl.h>
1182 #ifndef F_GETLEASE
1183 #define F_GETLEASE      1025
1184 #endif
1185 main() {
1186        int fd = open("/dev/null", O_RDONLY);
1187        return fcntl(fd, F_GETLEASE, 0) == -1;
1188 }
1189 ],
1190 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1191 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1192     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX)
1193 fi
1194
1195 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1196 AC_TRY_RUN([
1197 #include <sys/types.h>
1198 #include <fcntl.h>
1199 #include <signal.h>
1200 #ifndef F_NOTIFY
1201 #define F_NOTIFY 1026
1202 #endif
1203 main() {
1204         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1205 }
1206 ],
1207 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1208 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1209     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY)
1210 fi
1211
1212 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1213 AC_TRY_RUN([
1214 #include <sys/types.h>
1215 #include <fcntl.h>
1216 #include <signal.h>
1217 #include <sys/file.h>
1218 #ifndef LOCK_MAND
1219 #define LOCK_MAND       32
1220 #define LOCK_READ       64
1221 #endif
1222 main() {
1223         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1224 }
1225 ],
1226 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1227 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1228     AC_DEFINE(HAVE_KERNEL_SHARE_MODES)
1229 fi
1230
1231
1232
1233
1234 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1235 AC_TRY_COMPILE([#include <sys/types.h>
1236 #include <fcntl.h>],
1237 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1238 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1239 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1240     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX)
1241 fi
1242
1243 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1244 AC_TRY_RUN([#include <sys/types.h>
1245 #include <sys/capability.h>
1246 main() {
1247  cap_t cap;
1248  if ((cap = cap_get_proc()) == NULL)
1249    exit(1);
1250  cap->cap_effective |= CAP_NETWORK_MGT;
1251  cap->cap_inheritable |= CAP_NETWORK_MGT;
1252  cap_set_proc(cap);
1253  exit(0);
1254 }
1255 ],
1256 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1257 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1258     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES)
1259 fi
1260
1261 #
1262 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1263 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1264 #
1265
1266 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1267 AC_TRY_COMPILE([#include <sys/types.h>
1268 #if defined(HAVE_RPC_RPC_H)
1269 #include <rpc/rpc.h>
1270 #endif],
1271 [int16 testvar;],
1272 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1273 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1274     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H)
1275 fi
1276
1277 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1278 AC_TRY_COMPILE([#include <sys/types.h>
1279 #if defined(HAVE_RPC_RPC_H)
1280 #include <rpc/rpc.h>
1281 #endif],
1282 [uint16 testvar;],
1283 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1284 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1285     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H)
1286 fi
1287
1288 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1289 AC_TRY_COMPILE([#include <sys/types.h>
1290 #if defined(HAVE_RPC_RPC_H)
1291 #include <rpc/rpc.h>
1292 #endif],
1293 [int32 testvar;],
1294 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1295 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1296     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H)
1297 fi
1298
1299 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1300 AC_TRY_COMPILE([#include <sys/types.h>
1301 #if defined(HAVE_RPC_RPC_H)
1302 #include <rpc/rpc.h>
1303 #endif],
1304 [uint32 testvar;],
1305 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1306 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1307     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H)
1308 fi
1309
1310 dnl
1311 dnl Some systems (SCO) have a problem including
1312 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1313 dnl as a #define in <prot.h> and as part of an enum
1314 dnl in <rpc/rpc.h>.
1315 dnl
1316
1317 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1318 AC_TRY_COMPILE([#include <sys/types.h>
1319 #ifdef HAVE_SYS_SECURITY_H
1320 #include <sys/security.h>
1321 #include <prot.h>
1322 #endif  /* HAVE_SYS_SECURITY_H */
1323 #if defined(HAVE_RPC_RPC_H)
1324 #include <rpc/rpc.h>
1325 #endif],
1326 [int testvar;],
1327 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1328 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1329     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT)
1330 fi
1331
1332 AC_MSG_CHECKING([for test routines])
1333 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1334            AC_MSG_RESULT(yes),
1335            AC_MSG_ERROR([cant find test code. Aborting config]),
1336            AC_MSG_WARN([cannot run when cross-compiling]))
1337
1338 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1339 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1340            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1341 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1342     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
1343 fi
1344
1345 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1346 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1347            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1348            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1349            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1350 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1351 then
1352     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1353 fi
1354
1355 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1356 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1357            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1358 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1359     AC_DEFINE(HAVE_BROKEN_GETGROUPS)
1360 fi
1361
1362 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1363 SAVE_CPPFLAGS="$CPPFLAGS"
1364 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/smbwrapper"
1365 AC_TRY_COMPILE([
1366 #define REPLACE_GETPASS 1
1367 #define NO_CONFIG_H 1
1368 #define main dont_declare_main
1369 #include "${srcdir-.}/lib/getsmbpass.c"
1370 #undef main
1371 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1372 CPPFLAGS="$SAVE_CPPFLAGS"
1373 ])
1374 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1375         AC_DEFINE(REPLACE_GETPASS)
1376 fi
1377
1378 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1379 AC_TRY_RUN([
1380 #include <stdio.h>
1381 #include <sys/types.h>
1382 #include <netinet/in.h>
1383 #ifdef HAVE_ARPA_INET_H
1384 #include <arpa/inet.h>
1385 #endif
1386 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1387 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1388     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1389 exit(1);}],
1390            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1391 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1392     AC_DEFINE(REPLACE_INET_NTOA)
1393 fi
1394
1395 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1396 AC_TRY_RUN([#include <stdlib.h>
1397 #include <sys/types.h>
1398 #include <sys/stat.h>
1399 #include <unistd.h>
1400 main() { 
1401   struct stat st;
1402   char tpl[20]="/tmp/test.XXXXXX"; 
1403   int fd = mkstemp(tpl); 
1404   if (fd == -1) exit(1);
1405   unlink(tpl);
1406   if (fstat(fd, &st) != 0) exit(1);
1407   if ((st.st_mode & 0777) != 0600) exit(1);
1408   exit(0);
1409 }],
1410 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1411 samba_cv_HAVE_SECURE_MKSTEMP=no,
1412 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1413 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1414     AC_DEFINE(HAVE_SECURE_MKSTEMP)
1415 fi
1416
1417 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1418 AC_TRY_RUN([#include <unistd.h>
1419 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1420 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1421 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1422     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX)
1423 fi
1424
1425 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1426 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1427            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1428 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1429     AC_DEFINE(HAVE_ROOT)
1430 else
1431     AC_MSG_WARN(running as non-root will disable some tests)
1432 fi
1433
1434 ##################
1435 # look for a method of finding the list of network interfaces
1436 iface=no;
1437 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1438 AC_TRY_RUN([
1439 #define HAVE_IFACE_AIX 1
1440 #define AUTOCONF_TEST 1
1441 #include "confdefs.h"
1442 #include "${srcdir-.}/lib/interfaces.c"],
1443            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1444 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1445     iface=yes;AC_DEFINE(HAVE_IFACE_AIX)
1446 fi
1447
1448 if test $iface = no; then
1449 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1450 AC_TRY_RUN([
1451 #define HAVE_IFACE_IFCONF 1
1452 #define AUTOCONF_TEST 1
1453 #include "confdefs.h"
1454 #include "${srcdir-.}/lib/interfaces.c"],
1455            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1456 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1457     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF)
1458 fi
1459 fi
1460
1461 if test $iface = no; then
1462 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1463 AC_TRY_RUN([
1464 #define HAVE_IFACE_IFREQ 1
1465 #define AUTOCONF_TEST 1
1466 #include "confdefs.h"
1467 #include "${srcdir-.}/lib/interfaces.c"],
1468            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1469 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1470     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ)
1471 fi
1472 fi
1473
1474
1475 ################################################
1476 # look for a method of setting the effective uid
1477 seteuid=no;
1478 if test $seteuid = no; then
1479 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1480 AC_TRY_RUN([
1481 #define AUTOCONF_TEST 1
1482 #define USE_SETRESUID 1
1483 #include "confdefs.h"
1484 #include "${srcdir-.}/lib/util_sec.c"],
1485            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1486 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1487     seteuid=yes;AC_DEFINE(USE_SETRESUID)
1488 fi
1489 fi
1490
1491
1492 if test $seteuid = no; then
1493 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1494 AC_TRY_RUN([
1495 #define AUTOCONF_TEST 1
1496 #define USE_SETREUID 1
1497 #include "confdefs.h"
1498 #include "${srcdir-.}/lib/util_sec.c"],
1499            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1500 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1501     seteuid=yes;AC_DEFINE(USE_SETREUID)
1502 fi
1503 fi
1504
1505 if test $seteuid = no; then
1506 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1507 AC_TRY_RUN([
1508 #define AUTOCONF_TEST 1
1509 #define USE_SETEUID 1
1510 #include "confdefs.h"
1511 #include "${srcdir-.}/lib/util_sec.c"],
1512            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1513 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1514     seteuid=yes;AC_DEFINE(USE_SETEUID)
1515 fi
1516 fi
1517
1518 if test $seteuid = no; then
1519 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1520 AC_TRY_RUN([
1521 #define AUTOCONF_TEST 1
1522 #define USE_SETUIDX 1
1523 #include "confdefs.h"
1524 #include "${srcdir-.}/lib/util_sec.c"],
1525            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1526 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1527     seteuid=yes;AC_DEFINE(USE_SETUIDX)
1528 fi
1529 fi
1530
1531
1532 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1533 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1534            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1535 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1536     AC_DEFINE(HAVE_MMAP)
1537 fi
1538
1539 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1540 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1541            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1542 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1543     AC_DEFINE(FTRUNCATE_NEEDS_ROOT)
1544 fi
1545
1546 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1547 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1548            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1549 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1550     AC_DEFINE(HAVE_FCNTL_LOCK)
1551 fi
1552
1553 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1554 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1555            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1556 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1557     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS)
1558
1559 else
1560
1561 dnl
1562 dnl Don't check for 64 bit fcntl locking if we know that the
1563 dnl glibc2.1 broken check has succeeded.
1564 dnl 
1565
1566   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1567   AC_TRY_RUN([
1568 #if defined(HAVE_UNISTD_H)
1569 #include <unistd.h>
1570 #endif
1571 #include <stdio.h>
1572 #include <stdlib.h>
1573
1574 #ifdef HAVE_FCNTL_H
1575 #include <fcntl.h>
1576 #endif
1577
1578 #ifdef HAVE_SYS_FCNTL_H
1579 #include <sys/fcntl.h>
1580 #endif
1581 main() { struct flock64 fl64;
1582 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1583 exit(0);
1584 #else
1585 exit(1);
1586 #endif
1587 }],
1588        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1589
1590   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1591       AC_DEFINE(HAVE_STRUCT_FLOCK64)
1592   fi
1593 fi
1594
1595 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1596 AC_TRY_COMPILE([#include <sys/types.h>
1597 #include <sys/stat.h>
1598 #include <unistd.h>],
1599 [struct stat st;  st.st_blocks = 0;],
1600 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1601 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1602     AC_DEFINE(HAVE_STAT_ST_BLOCKS)
1603 fi 
1604
1605 case "$host_os" in
1606 *linux*)
1607 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1608 AC_TRY_COMPILE([
1609 #ifdef HAVE_SYS_VFS_H
1610 #include <sys/vfs.h>
1611 #endif
1612 #ifdef HAVE_SYS_CAPABILITY_H
1613 #include <sys/capability.h>
1614 #endif
1615 ],[int i;],
1616    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1617 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1618    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS)
1619 fi
1620 ;;
1621 esac
1622
1623 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1624 AC_TRY_COMPILE([#include <sys/acl.h>
1625 #if defined(HAVE_RPCSVC_NIS_H)
1626 #include <rpcsvc/nis.h>
1627 #endif],
1628 [int i;],
1629 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1630 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1631     AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES)
1632 fi
1633
1634
1635 #################################################
1636 # check for smbwrapper support
1637 AC_MSG_CHECKING(whether to use smbwrapper)
1638 AC_ARG_WITH(smbwrapper,
1639 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
1640 [ case "$withval" in
1641   yes)
1642     AC_MSG_RESULT(yes)
1643     AC_DEFINE(WITH_SMBWRAPPER)
1644         WRAP="bin/smbsh bin/smbwrapper.$SHLIBEXT"
1645
1646         if test x$ATTEMPT_WRAP32_BUILD = x; then
1647                 WRAP32=""
1648         else
1649                         WRAP32=bin/smbwrapper.32.$SHLIBEXT
1650         fi
1651
1652 # Conditions under which smbwrapper should not be built.
1653
1654         if test x$PICFLAG = x; then
1655            echo No support for PIC code - disabling smbwrapper and smbsh
1656            WRAP=""
1657            WRAP32=""
1658         elif test x$ac_cv_func_syscall = xno; then
1659            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
1660            WRAP=""
1661            WRAP32=""
1662         fi
1663     ;;
1664   *)
1665     AC_MSG_RESULT(no)
1666     ;;
1667   esac ],
1668   AC_MSG_RESULT(no)
1669 )
1670
1671 #################################################
1672 # check for AFS clear-text auth support
1673 AC_MSG_CHECKING(whether to use AFS clear-text auth)
1674 AC_ARG_WITH(afs,
1675 [  --with-afs              Include AFS clear-text auth support (default=no) ],
1676 [ case "$withval" in
1677   yes)
1678     AC_MSG_RESULT(yes)
1679     AC_DEFINE(WITH_AFS)
1680     ;;
1681   *)
1682     AC_MSG_RESULT(no)
1683     ;;
1684   esac ],
1685   AC_MSG_RESULT(no)
1686 )
1687
1688
1689 #################################################
1690 # check for the DFS clear-text auth system
1691 AC_MSG_CHECKING(whether to use DFS clear-text auth)
1692 AC_ARG_WITH(dfs,
1693 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
1694 [ case "$withval" in
1695   yes)
1696     AC_MSG_RESULT(yes)
1697     AC_DEFINE(WITH_DFS)
1698     ;;
1699   *)
1700     AC_MSG_RESULT(no)
1701     ;;
1702   esac ],
1703   AC_MSG_RESULT(no)
1704 )
1705
1706
1707 #################################################
1708 # see if this box has the RedHat location for kerberos
1709 AC_MSG_CHECKING(for /usr/kerberos)
1710 if test -d /usr/kerberos; then
1711     LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
1712     CFLAGS="$CFLAGS -I/usr/kerberos/include"
1713     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
1714     AC_MSG_RESULT(yes)
1715 else
1716     AC_MSG_RESULT(no)
1717 fi
1718
1719 #################################################
1720 # check for location of Kerberos 5 install
1721 AC_MSG_CHECKING(for kerberos 5 install path)
1722 AC_ARG_WITH(krb5,
1723 [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
1724 [ case "$withval" in
1725   no)
1726     AC_MSG_RESULT(no)
1727     ;;
1728   *)
1729     AC_MSG_RESULT(yes)
1730     LIBS="$LIBS -lkrb5"
1731     CFLAGS="$CFLAGS -I$withval/include"
1732     CPPFLAGS="$CPPFLAGS -I$withval/include"
1733     LDFLAGS="$LDFLAGS -L$withval/lib"
1734     ;;
1735   esac ],
1736   AC_MSG_RESULT(no)
1737 )
1738
1739 # now check for krb5.h. Some systems have the libraries without the headers!
1740 # note that this check is done here to allow for different kerberos
1741 # include paths
1742 AC_CHECK_HEADERS(krb5.h)
1743
1744 # now check for gssapi headers.  This is also done here to allow for
1745 # different kerberos include paths
1746 AC_CHECK_HEADERS(gssapi/gssapi_generic.h gssapi/gssapi.h)
1747
1748 ##################################################################
1749 # we might need the k5crypto and com_err libraries on some systems
1750 AC_CHECK_LIB(com_err, _et_list, [LIBS="$LIBS -lcom_err"])
1751 AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"])
1752 AC_CHECK_LIB(gssapi_krb5, gss_display_status, [LIBS="$LIBS -lgssapi_krb5"])
1753
1754
1755 ########################################################
1756 # now see if we can find the krb5 libs in standard paths
1757 # or as specified above
1758 AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
1759         AC_DEFINE(HAVE_KRB5)])
1760
1761 ########################################################
1762 # now see if we can find the gssapi libs in standard paths
1763 AC_CHECK_LIB(gssapi_krb5, gss_display_status, [AC_DEFINE(HAVE_GSSAPI)])
1764
1765
1766 ##################################################################
1767 # we might need the lber lib on some systems. To avoid link errors
1768 # this test must be before the libldap test
1769 AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"])
1770
1771 ########################################################
1772 # now see if we can find the ldap libs in standard paths
1773 if test x$have_ldap != xyes; then
1774 AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
1775         AC_DEFINE(HAVE_LDAP)])
1776 fi
1777
1778 #################################################
1779 # check for automount support
1780 AC_MSG_CHECKING(whether to use AUTOMOUNT)
1781 AC_ARG_WITH(automount,
1782 [  --with-automount        Include AUTOMOUNT support (default=no)],
1783 [ case "$withval" in
1784   yes)
1785     AC_MSG_RESULT(yes)
1786     AC_DEFINE(WITH_AUTOMOUNT)
1787     ;;
1788   *)
1789     AC_MSG_RESULT(no)
1790     ;;
1791   esac ],
1792   AC_MSG_RESULT(no)
1793 )
1794
1795 #################################################
1796 # check for smbmount support
1797 AC_MSG_CHECKING(whether to use SMBMOUNT)
1798 AC_ARG_WITH(smbmount,
1799 [  --with-smbmount         Include SMBMOUNT (Linux only) support (default=no)],
1800 [ case "$withval" in
1801   yes)
1802         case "$host_os" in
1803         *linux*)
1804                 AC_MSG_RESULT(yes)
1805                 AC_DEFINE(WITH_SMBMOUNT)
1806                 MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
1807                 ;;
1808         *)
1809                 AC_MSG_ERROR(not on a linux system!)
1810                 ;;
1811         esac
1812     ;;
1813   *)
1814     AC_MSG_RESULT(no)
1815     MPROGS=
1816     ;;
1817   esac ],
1818   AC_MSG_RESULT(no)
1819   MPROGS=
1820 )
1821
1822
1823 #################################################
1824 # check for a PAM clear-text auth, accounts, password and session support
1825 with_pam_for_crypt=no
1826 AC_MSG_CHECKING(whether to use PAM)
1827 AC_ARG_WITH(pam,
1828 [  --with-pam              Include PAM support (default=no)],
1829 [ case "$withval" in
1830   yes)
1831     AC_MSG_RESULT(yes)
1832     AC_DEFINE(WITH_PAM)
1833     LIBS="$LIBS -lpam"
1834     with_pam_for_crypt=yes
1835     ;;
1836   *)
1837     AC_MSG_RESULT(no)
1838     ;;
1839   esac ],
1840   AC_MSG_RESULT(no)
1841 )
1842
1843 # we can't build a pam module if we don't have pam.
1844 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM)])
1845
1846 #################################################
1847 # check for pam_smbpass support
1848 AC_MSG_CHECKING(whether to use pam_smbpass)
1849 AC_ARG_WITH(pam_smbpass,
1850 [  --with-pam_smbpass      Build a PAM module to allow other applications to use our smbpasswd file (default=no)],
1851 [ case "$withval" in
1852   yes)
1853     AC_MSG_RESULT(yes)
1854
1855 # Conditions under which pam_smbpass should not be built.
1856
1857        if test x$PICFLAG = x; then
1858           AC_MSG_RESULT([No support for PIC code - disabling pam_smbpass])
1859           PAM_MOD=""
1860        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
1861           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
1862           PAM_MOD=""
1863        else
1864           PAM_MOD="bin/pam_smbpass.so"
1865        fi
1866     ;;
1867   *)
1868     AC_MSG_RESULT(no)
1869     ;;
1870   esac ],
1871   AC_MSG_RESULT(no)
1872 )
1873
1874
1875 ###############################################
1876 # test for where we get crypt() from, but only
1877 # if not using PAM
1878 if test $with_pam_for_crypt = no; then
1879 AC_CHECK_FUNCS(crypt)
1880 if test x"$ac_cv_func_crypt" = x"no"; then
1881     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
1882         AC_DEFINE(HAVE_CRYPT)])
1883 fi
1884 fi
1885
1886 ##
1887 ## moved after the check for -lcrypt in order to
1888 ## ensure that the necessary libraries are included
1889 ## check checking for truncated salt.  Wrapped by the
1890 ## $with_pam_for_crypt variable as above   --jerry
1891 ##
1892 if test $with_pam_for_crypt = no; then
1893 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1894 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
1895         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
1896 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1897         AC_DEFINE(HAVE_TRUNCATED_SALT)
1898 fi
1899 fi
1900
1901
1902
1903 ########################################################################################
1904 ##
1905 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
1906 ##
1907 ########################################################################################
1908
1909 ## set the with_smbpasswd_sam as the default
1910 with_smbpasswd_sam=yes
1911
1912
1913 #################################################
1914 # check for a TDB password database
1915 AC_MSG_CHECKING(whether to use TDB SAM database)
1916 AC_ARG_WITH(tdbsam,
1917 [  --with-tdbsam           Include experimental TDB SAM support (default=no)],
1918 [ case "$withval" in
1919   yes)
1920     AC_MSG_RESULT(yes)
1921     AC_DEFINE(WITH_TDB_SAM)
1922     with_smbpasswd_sam=no
1923     ;;
1924   *)
1925     AC_MSG_RESULT(no)
1926     ;;
1927   esac ],
1928   AC_MSG_RESULT(no)
1929 )
1930
1931 #################################################
1932 # check for a LDAP password database
1933 AC_MSG_CHECKING(whether to use LDAP SAM database)
1934 AC_ARG_WITH(ldapsam,
1935 [  --with-ldapsam          Include experimental LDAP SAM support (default=no)],
1936 [ case "$withval" in
1937   yes)
1938     AC_MSG_RESULT(yes)
1939     AC_DEFINE(WITH_LDAP_SAM)
1940     LIBS="-lldap -llber $LIBS"
1941     with_smbpasswd_sam=no
1942     ;;
1943   *)
1944     AC_MSG_RESULT(no)
1945     ;;
1946   esac ],
1947   AC_MSG_RESULT(no)
1948 )
1949
1950 #################################################
1951 # check for a NISPLUS password database
1952 AC_MSG_CHECKING(whether to use NISPLUS SAM database)
1953 AC_ARG_WITH(nisplussam,
1954 [  --with-nisplussam       Include NISPLUS SAM support (default=no)],
1955 [ case "$withval" in
1956   yes)
1957     AC_MSG_RESULT(yes)
1958     AC_DEFINE(WITH_NISPLUS_SAM)
1959     with_smbpasswd_sam=no
1960     ;;
1961   *)
1962     AC_MSG_RESULT(no)
1963     ;;
1964   esac ],
1965   AC_MSG_RESULT(no)
1966 )
1967
1968 ################################################
1969 # This test should come last because the
1970 # smbpasswd SAM is only used if another format
1971 # has not been defined
1972 AC_MSG_CHECKING(whether to use traditional smbpasswd file)
1973 if test $with_smbpasswd_sam = yes; then
1974         AC_MSG_RESULT(yes)
1975         AC_DEFINE(WITH_SMBPASSWD_SAM)
1976 else
1977         AC_MSG_RESULT(no)
1978 fi
1979
1980 ########################################################################################
1981 ##
1982 ## END OF TESTS FOR SAM BACKENDS.  
1983 ##
1984 ########################################################################################
1985
1986 #################################################
1987 # check for a NISPLUS_HOME support 
1988 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
1989 AC_ARG_WITH(nisplus-home,
1990 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
1991 [ case "$withval" in
1992   yes)
1993     AC_MSG_RESULT(yes)
1994     AC_DEFINE(WITH_NISPLUS_HOME)
1995     ;;
1996   *)
1997     AC_MSG_RESULT(no)
1998     ;;
1999   esac ],
2000   AC_MSG_RESULT(no)
2001 )
2002
2003 #################################################
2004 # check for the secure socket layer
2005 AC_MSG_CHECKING(whether to use SSL)
2006 AC_ARG_WITH(ssl,
2007 [  --with-ssl              Include SSL support (default=no)
2008   --with-sslinc=DIR          Where the SSL includes are (defaults to /usr/local/ssl/include)
2009   --with-ssllib=DIR          Where the SSL libraries are (defaults to /usr/local/ssl/lib)],
2010 [ case "$withval" in
2011   yes)
2012     AC_MSG_RESULT(yes)
2013     AC_DEFINE(WITH_SSL)
2014     withval="/usr/local/ssl"     # default
2015
2016     if test "${with_sslinc+set}" = set; then
2017
2018         withval="$with_sslinc"
2019         case "$withval" in
2020         yes|no)
2021           echo "configure: warning: --with-sslinc called without argument - will use default" 1>&w
2022           CFLAGS="-I/usr/local/ssl/include $CFLAGS"
2023         ;;
2024         * )
2025           CFLAGS="-I${withval} $CFLAGS"
2026         ;;
2027         esac
2028
2029     else
2030
2031         CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
2032
2033     fi
2034
2035     if test "${with_ssllib+set}" = set; then
2036
2037         withval="$with_ssllib"
2038         case "$withval" in
2039         yes|no)
2040           echo "configure: warning: --with-ssllib called without argument - will use default" 1>&w
2041           LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2042         ;;
2043         * )
2044           LDFLAGS="-L${withval}/lib $LDFLAGS"
2045         ;;
2046         esac
2047
2048     else
2049
2050         LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2051
2052     fi
2053
2054     LIBS="-lssl -lcrypto $LIBS"
2055
2056 #    if test ! -d ${withval}; then
2057 #      echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
2058 #      exit 1
2059 #    fi 
2060
2061     CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
2062
2063     ;;
2064   *)
2065     AC_MSG_RESULT(no)
2066     ;;
2067   esac ],
2068   AC_MSG_RESULT(no)
2069 )
2070
2071 #################################################
2072 # check for syslog logging
2073 AC_MSG_CHECKING(whether to use syslog logging)
2074 AC_ARG_WITH(syslog,
2075 [  --with-syslog           Include experimental SYSLOG support (default=no)],
2076 [ case "$withval" in
2077   yes)
2078     AC_MSG_RESULT(yes)
2079     AC_DEFINE(WITH_SYSLOG)
2080     ;;
2081   *)
2082     AC_MSG_RESULT(no)
2083     ;;
2084   esac ],
2085   AC_MSG_RESULT(no)
2086 )
2087
2088 #################################################
2089 # check for a shared memory profiling support
2090 AC_MSG_CHECKING(whether to use profiling)
2091 AC_ARG_WITH(profiling-data,
2092 [  --with-profiling-data   Include gathering source code profile information (default=no)],
2093 [ case "$withval" in
2094   yes)
2095     AC_MSG_RESULT(yes)
2096     AC_DEFINE(WITH_PROFILE)
2097     ;;
2098   *)
2099     AC_MSG_RESULT(no)
2100     ;;
2101   esac ],
2102   AC_MSG_RESULT(no)
2103 )
2104
2105
2106 #################################################
2107 # check for experimental disk-quotas support
2108 QUOTAOBJS=smbd/noquotas.o
2109
2110 AC_MSG_CHECKING(whether to support disk-quotas)
2111 AC_ARG_WITH(quotas,
2112 [  --with-quotas           Include experimental disk-quota support (default=no)],
2113 [ case "$withval" in
2114   yes)
2115     AC_MSG_RESULT(yes)
2116     case "$host_os" in
2117       *linux*)
2118         # Check for kernel 2.4.x quota braindamage...
2119         AC_CACHE_CHECK([for linux 2.4.x quota braindamage..],samba_cv_linux_2_4_quota_braindamage, [
2120         AC_TRY_COMPILE([#include <stdio.h>
2121 #include <sys/types.h>
2122 #include <asm/types.h>
2123 #include <linux/quota.h>
2124 #include <mntent.h>
2125 #include <linux/unistd.h>],[struct mem_dqblk D;],
2126       samba_cv_linux_2_4_quota_braindamage=yes,samba_cv_linux_2_4_quota_braindamage=no)])
2127 if test x"$samba_cv_linux_2_4_quota_braindamage" = x"yes"; then
2128         AC_DEFINE(LINUX_QUOTAS_2)
2129 else
2130         AC_DEFINE(LINUX_QUOTAS_1)
2131 fi
2132         ;;
2133       *)
2134         ;;
2135     esac
2136     QUOTAOBJS=smbd/quotas.o
2137     AC_DEFINE(WITH_QUOTAS)
2138     ;;
2139   *)
2140     AC_MSG_RESULT(no)
2141     ;;
2142   esac ],
2143   AC_MSG_RESULT(no)
2144 )
2145 AC_SUBST(QUOTAOBJS)
2146
2147 #################################################
2148 # check for experimental utmp accounting
2149
2150 AC_MSG_CHECKING(whether to support utmp accounting)
2151 AC_ARG_WITH(utmp,
2152 [  --with-utmp             Include experimental utmp accounting (default=no)],
2153 [ case "$withval" in
2154   yes)
2155     AC_MSG_RESULT(yes)
2156     AC_DEFINE(WITH_UTMP)
2157     ;;
2158   *)
2159     AC_MSG_RESULT(no)
2160     ;;
2161   esac ],
2162   AC_MSG_RESULT(no)
2163 )
2164
2165 #################################################
2166 # set private directory location
2167 AC_ARG_WITH(privatedir,
2168 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
2169 [ case "$withval" in
2170   yes|no)
2171   #
2172   # Just in case anybody calls it without argument
2173   #
2174     AC_MSG_WARN([--with-privatedir called without argument - will use default])
2175     privatedir='${prefix}/private'
2176   ;;
2177   * )
2178     privatedir="$withval"
2179     ;;
2180   esac
2181   AC_SUBST(privatedir)],
2182   [privatedir='${prefix}/private'
2183    AC_SUBST(privatedir)]
2184 )
2185
2186 #################################################
2187 # set lock directory location
2188 AC_ARG_WITH(lockdir,
2189 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
2190 [ case "$withval" in
2191   yes|no)
2192   #
2193   # Just in case anybody calls it without argument
2194   #
2195     AC_MSG_WARN([--with-lockdir called without argument - will use default])
2196     lockdir='$(VARDIR)/locks'
2197   ;;
2198   * )
2199     lockdir="$withval"
2200     ;;
2201   esac
2202   AC_SUBST(lockdir)],
2203   [lockdir='$(VARDIR)/locks'
2204    AC_SUBST(lockdir)]
2205 )
2206
2207 #################################################
2208 # set SWAT directory location
2209 AC_ARG_WITH(swatdir,
2210 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
2211 [ case "$withval" in
2212   yes|no)
2213   #
2214   # Just in case anybody does it
2215   #
2216     AC_MSG_WARN([--with-swatdir called without argument - will use default])
2217     swatdir='${prefix}/swat'
2218   ;;
2219   * )
2220     swatdir="$withval"
2221     ;;
2222   esac
2223   AC_SUBST(swatdir)],
2224   [swatdir='${prefix}/swat'
2225    AC_SUBST(swatdir)]
2226 )
2227
2228 #################################################
2229 # choose native language(s) of man pages
2230 AC_MSG_CHECKING(chosen man pages' language(s))
2231 AC_ARG_WITH(manpages-langs,
2232 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
2233 [ case "$withval" in
2234   yes|no)
2235     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
2236     manlangs="en"
2237   ;;
2238   *)
2239     manlangs="$withval"
2240   ;;
2241   esac
2242
2243   AC_MSG_RESULT($manlangs)
2244   manlangs=`echo $manlangs | sed "s/,/ /"`   # replacing commas with spaces to produce a list
2245   AC_SUBST(manlangs)],
2246
2247   [manlangs="en"
2248   AC_MSG_RESULT($manlangs)
2249   AC_SUBST(manlangs)]
2250 )
2251
2252 #################################################
2253 # these tests are taken from the GNU fileutils package
2254 AC_CHECKING(how to get filesystem space usage)
2255 space=no
2256
2257 # Test for statvfs64.
2258 if test $space = no; then
2259   # SVR4
2260   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
2261   [AC_TRY_RUN([
2262 #if defined(HAVE_UNISTD_H)
2263 #include <unistd.h>
2264 #endif
2265 #include <sys/types.h>
2266 #include <sys/statvfs.h>
2267   main ()
2268   {
2269     struct statvfs64 fsd;
2270     exit (statvfs64 (".", &fsd));
2271   }],
2272   fu_cv_sys_stat_statvfs64=yes,
2273   fu_cv_sys_stat_statvfs64=no,
2274   fu_cv_sys_stat_statvfs64=cross)])
2275   if test $fu_cv_sys_stat_statvfs64 = yes; then
2276     space=yes
2277     AC_DEFINE(STAT_STATVFS64)
2278   fi
2279 fi
2280
2281 # Perform only the link test since it seems there are no variants of the
2282 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
2283 # because that got a false positive on SCO OSR5.  Adding the declaration
2284 # of a `struct statvfs' causes this test to fail (as it should) on such
2285 # systems.  That system is reported to work fine with STAT_STATFS4 which
2286 # is what it gets when this test fails.
2287 if test $space = no; then
2288   # SVR4
2289   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
2290                  [AC_TRY_LINK([#include <sys/types.h>
2291 #include <sys/statvfs.h>],
2292                               [struct statvfs fsd; statvfs (0, &fsd);],
2293                               fu_cv_sys_stat_statvfs=yes,
2294                               fu_cv_sys_stat_statvfs=no)])
2295   if test $fu_cv_sys_stat_statvfs = yes; then
2296     space=yes
2297     AC_DEFINE(STAT_STATVFS)
2298   fi
2299 fi
2300
2301 if test $space = no; then
2302   # DEC Alpha running OSF/1
2303   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
2304   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
2305   [AC_TRY_RUN([
2306 #include <sys/param.h>
2307 #include <sys/types.h>
2308 #include <sys/mount.h>
2309   main ()
2310   {
2311     struct statfs fsd;
2312     fsd.f_fsize = 0;
2313     exit (statfs (".", &fsd, sizeof (struct statfs)));
2314   }],
2315   fu_cv_sys_stat_statfs3_osf1=yes,
2316   fu_cv_sys_stat_statfs3_osf1=no,
2317   fu_cv_sys_stat_statfs3_osf1=no)])
2318   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
2319   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
2320     space=yes
2321     AC_DEFINE(STAT_STATFS3_OSF1)
2322   fi
2323 fi
2324
2325 if test $space = no; then
2326 # AIX
2327   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
2328 member (AIX, 4.3BSD)])
2329   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
2330   [AC_TRY_RUN([
2331 #ifdef HAVE_SYS_PARAM_H
2332 #include <sys/param.h>
2333 #endif
2334 #ifdef HAVE_SYS_MOUNT_H
2335 #include <sys/mount.h>
2336 #endif
2337 #ifdef HAVE_SYS_VFS_H
2338 #include <sys/vfs.h>
2339 #endif
2340   main ()
2341   {
2342   struct statfs fsd;
2343   fsd.f_bsize = 0;
2344   exit (statfs (".", &fsd));
2345   }],
2346   fu_cv_sys_stat_statfs2_bsize=yes,
2347   fu_cv_sys_stat_statfs2_bsize=no,
2348   fu_cv_sys_stat_statfs2_bsize=no)])
2349   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
2350   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
2351     space=yes
2352     AC_DEFINE(STAT_STATFS2_BSIZE)
2353   fi
2354 fi
2355
2356 if test $space = no; then
2357 # SVR3
2358   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
2359   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
2360   [AC_TRY_RUN([#include <sys/types.h>
2361 #include <sys/statfs.h>
2362   main ()
2363   {
2364   struct statfs fsd;
2365   exit (statfs (".", &fsd, sizeof fsd, 0));
2366   }],
2367     fu_cv_sys_stat_statfs4=yes,
2368     fu_cv_sys_stat_statfs4=no,
2369     fu_cv_sys_stat_statfs4=no)])
2370   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
2371   if test $fu_cv_sys_stat_statfs4 = yes; then
2372     space=yes
2373     AC_DEFINE(STAT_STATFS4)
2374   fi
2375 fi
2376
2377 if test $space = no; then
2378 # 4.4BSD and NetBSD
2379   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
2380 member (4.4BSD and NetBSD)])
2381   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
2382   [AC_TRY_RUN([#include <sys/types.h>
2383 #ifdef HAVE_SYS_PARAM_H
2384 #include <sys/param.h>
2385 #endif
2386 #ifdef HAVE_SYS_MOUNT_H
2387 #include <sys/mount.h>
2388 #endif
2389   main ()
2390   {
2391   struct statfs fsd;
2392   fsd.f_fsize = 0;
2393   exit (statfs (".", &fsd));
2394   }],
2395   fu_cv_sys_stat_statfs2_fsize=yes,
2396   fu_cv_sys_stat_statfs2_fsize=no,
2397   fu_cv_sys_stat_statfs2_fsize=no)])
2398   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
2399   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
2400     space=yes
2401     AC_DEFINE(STAT_STATFS2_FSIZE)
2402   fi
2403 fi
2404
2405 if test $space = no; then
2406   # Ultrix
2407   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
2408   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
2409   [AC_TRY_RUN([#include <sys/types.h>
2410 #ifdef HAVE_SYS_PARAM_H
2411 #include <sys/param.h>
2412 #endif
2413 #ifdef HAVE_SYS_MOUNT_H
2414 #include <sys/mount.h>
2415 #endif
2416 #ifdef HAVE_SYS_FS_TYPES_H
2417 #include <sys/fs_types.h>
2418 #endif
2419   main ()
2420   {
2421   struct fs_data fsd;
2422   /* Ultrix's statfs returns 1 for success,
2423      0 for not mounted, -1 for failure.  */
2424   exit (statfs (".", &fsd) != 1);
2425   }],
2426   fu_cv_sys_stat_fs_data=yes,
2427   fu_cv_sys_stat_fs_data=no,
2428   fu_cv_sys_stat_fs_data=no)])
2429   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2430   if test $fu_cv_sys_stat_fs_data = yes; then
2431     space=yes
2432     AC_DEFINE(STAT_STATFS2_FS_DATA)
2433   fi
2434 fi
2435
2436 #
2437 # As a gating factor for large file support, in order to
2438 # use <4GB files we must have the following minimal support
2439 # available.
2440 # long long, and a 64 bit off_t or off64_t.
2441 # If we don't have all of these then disable large
2442 # file support.
2443 #
2444 AC_MSG_CHECKING([if large file support can be enabled])
2445 AC_TRY_COMPILE([
2446 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2447 #include <sys/types.h>
2448 #else
2449 __COMPILE_ERROR_
2450 #endif
2451 ],
2452 [int i],
2453 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2454 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2455     AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
2456 fi
2457 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
2458
2459 AC_ARG_WITH(spinlocks, 
2460 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
2461 if test "x$with_spinlocks" = "xyes"; then
2462     AC_DEFINE(USE_SPINLOCKS)
2463
2464     case "$host_cpu" in
2465         sparc)
2466             AC_DEFINE(SPARC_SPINLOCKS)
2467             ;;
2468
2469         i386|i486|i586|i686)
2470             AC_DEFINE(INTEL_SPINLOCKS)
2471             ;;
2472
2473         mips)
2474             AC_DEFINE(MIPS_SPINLOCKS)
2475             ;;
2476
2477         powerpc)
2478             AC_DEFINE(POWERPC_SPINLOCKS)
2479             ;;
2480     esac
2481 fi
2482
2483 #################################################
2484 # check for ACL support
2485
2486 AC_MSG_CHECKING(whether to support ACLs)
2487 AC_ARG_WITH(acl-support,
2488 [  --with-acl-support      Include ACL support (default=no)],
2489 [ case "$withval" in
2490   yes)
2491
2492         case "$host_os" in
2493         *sysv5*)
2494                 AC_MSG_RESULT(Using UnixWare ACLs)
2495                 AC_DEFINE(HAVE_UNIXWARE_ACLS)
2496                 ;;
2497         *solaris*)
2498                 AC_MSG_RESULT(Using solaris ACLs)
2499                 AC_DEFINE(HAVE_SOLARIS_ACLS)
2500                 ;;
2501         *hpux*)
2502                 AC_MSG_RESULT(Using HPUX ACLs)
2503                 AC_DEFINE(HAVE_HPUX_ACLS)
2504                 ;;
2505         *irix*)
2506                 AC_MSG_RESULT(Using IRIX ACLs)
2507                 AC_DEFINE(HAVE_IRIX_ACLS)
2508                 ;;
2509         *aix*)
2510                 AC_MSG_RESULT(Using AIX ACLs)
2511                 AC_DEFINE(HAVE_AIX_ACLS)
2512                 ;;
2513         *osf*)
2514                 AC_MSG_RESULT(Using Tru64 ACLs)
2515                 AC_DEFINE(HAVE_TRU64_ACLS)
2516                 LIBS="$LIBS -lpacl"
2517                 ;;
2518         *)
2519                 AC_CHECK_LIB(acl,acl_get_file)
2520                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
2521                 AC_TRY_LINK([#include <sys/types.h>
2522 #include <sys/acl.h>],
2523 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
2524 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
2525                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
2526                                 AC_MSG_RESULT(Using posix ACLs)
2527                                 AC_DEFINE(HAVE_POSIX_ACLS)
2528                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
2529                                 AC_TRY_LINK([#include <sys/types.h>
2530 #include <sys/acl.h>],
2531 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
2532 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
2533                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
2534                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP)
2535                                 fi
2536                         fi
2537             ;;
2538         esac
2539         ;;
2540   *)
2541     AC_MSG_RESULT(no)
2542     AC_DEFINE(HAVE_NO_ACLS)
2543     ;;
2544   esac ],
2545   AC_DEFINE(HAVE_NO_ACLS)
2546   AC_MSG_RESULT(no)
2547 )
2548
2549 #################################################
2550 # Check whether winbind is supported on this platform.  If so we need to
2551 # build and install client programs (WINBIND_TARGETS), sbin programs
2552 # (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
2553
2554 AC_MSG_CHECKING(whether to build winbind)
2555
2556 # Initially, the value of $host_os decides whether winbind is supported
2557
2558 case "$host_os" in 
2559         *linux*|*solaris*|*irix*)
2560                 HAVE_WINBIND=yes
2561                 ;;
2562         *)
2563                 HAVE_WINBIND=no
2564                 winbind_no_reason=", unsupported on $host_os"
2565                 ;;
2566 esac
2567
2568 # Check the setting of --with-winbindd
2569
2570 AC_ARG_WITH(winbind,
2571 [  --with-winbind          Build winbind (default, if supported by OS)],
2572
2573   case "$withval" in
2574         yes)
2575                 HAVE_WINBIND=yes
2576                 ;;
2577         no)
2578                 HAVE_WINBIND=no
2579                 winbind_reason=""
2580                 ;;
2581   esac ],
2582 )
2583
2584 # We need unix domain sockets for winbind
2585
2586 if test x"$HAVE_WINBIND" = x"yes"; then
2587         if test x"$samba_cv_unixsocket" = x"no"; then
2588                 winbind_no_reason=", no unix domain socket support on $host_os"
2589                 HAVE_WINBIND=no
2590         fi
2591 fi
2592
2593 # Display test results
2594
2595
2596 WINBIND_TARGETS=""
2597 WINBIND_STARGETS=""
2598 WINBIND_LTARGETS=""
2599 WINBIND_PAM_PROGS=""
2600
2601 if test x"$HAVE_WINBIND" = x"yes"; then
2602         AC_MSG_RESULT(yes)
2603
2604         WINBIND_TARGETS="bin/wbinfo"
2605         WINBIND_STARGETS="bin/winbindd"
2606         if test x"$BLDSHARED" = x"true"; then
2607                 WINBIND_LTARGETS="nsswitch/libnss_winbind.so"
2608                 if test x"$with_pam" = x"yes"; then
2609                         WINBIND_PAM_TARGETS="nsswitch/pam_winbind.so"
2610                 fi
2611         fi
2612 else
2613         AC_MSG_RESULT(no$winbind_no_reason)
2614 fi
2615
2616 # Substitution time!
2617
2618 AC_SUBST(WINBIND_TARGETS)
2619 AC_SUBST(WINBIND_STARGETS)
2620 AC_SUBST(WINBIND_LTARGETS)
2621 AC_SUBST(WINBIND_PAM_TARGETS)
2622
2623 #################################################
2624 # Check to see if we should use the included popt 
2625
2626 AC_ARG_WITH(included-popt,
2627 [  --with-included-popt    use bundled popt library, not from system],
2628
2629   case "$withval" in
2630         yes)
2631                 INCLUDED_POPT=yes
2632                 ;;
2633         no)
2634                 INCLUDED_POPT=no
2635                 ;;
2636   esac ],
2637 )
2638 if test x"$INCLUDED_POPT" != x"yes"; then
2639     AC_CHECK_LIB(popt, poptGetContext,
2640                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
2641 fi
2642
2643 AC_MSG_CHECKING(whether to use included popt)
2644 if test x"$INCLUDED_POPT" = x"yes"; then
2645     AC_MSG_RESULT($srcdir/popt)
2646     BUILD_POPT='$(POPT_OBJS)'
2647     FLAGS1="-I$srcdir/popt"
2648 else
2649     AC_MSG_RESULT(no)
2650     LIBS="$LIBS -lpopt"
2651 fi
2652 AC_SUBST(BUILD_POPT)
2653 AC_SUBST(FLAGS1)
2654
2655 #################################################
2656 # final configure stuff
2657
2658 echo "checking configure summary"
2659 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
2660            echo "configure OK";,
2661            AC_MSG_ERROR([summary failure. Aborting config]),:)
2662
2663 builddir=`pwd`
2664 AC_SUBST(builddir)
2665
2666 AC_OUTPUT(include/stamp-h Makefile)
2667
2668 #################################################
2669 # Print very concise instructions on building/use
2670 if test "x$enable_dmalloc" = xyes
2671 then
2672         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
2673         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
2674 fi