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