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