Set default st_blocksize, added Volker's directory fix - save the attributes
[Samba.git] / source / configure.in
blob093f7eee79896e676cf49833b516f9193a407502
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(include/includes.h)
3 AC_CONFIG_HEADER(include/config.h)
5 #################################################
6 # Directory handling stuff to support both the
7 # legacy SAMBA directories and FHS compliant
8 # ones...
9 AC_PREFIX_DEFAULT(/usr/local/samba)
11 AC_ARG_WITH(fhs, 
12 [  --with-fhs              Use FHS-compliant paths (default=no)],
13     codepagedir="\$(DATADIR)/samba/codepages"
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     codepagedir="\$(LIBDIR)/codepages"
21     configdir="\$(LIBDIR)"
22     logfilebase="\$(VARDIR)"
23     lockdir="\${VARDIR}/locks"
24     piddir="\$(VARDIR)/locks"
25     privatedir="\${prefix}/private"
26     swatdir="\${prefix}/swat")
28 #################################################
29 # set private directory location
30 AC_ARG_WITH(privatedir,
31 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
32 [ case "$withval" in
33   yes|no)
34   #
35   # Just in case anybody calls it without argument
36   #
37     AC_MSG_WARN([--with-privatedir called without argument - will use default])
38   ;;
39   * )
40     privatedir="$withval"
41     ;;
42   esac])
44 #################################################
45 # set lock directory location
46 AC_ARG_WITH(lockdir,
47 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
48 [ case "$withval" in
49   yes|no)
50   #
51   # Just in case anybody calls it without argument
52   #
53     AC_MSG_WARN([--with-lockdir called without argument - will use default])
54   ;;
55   * )
56     lockdir="$withval"
57     ;;
58   esac])
60 #################################################
61 # set pid directory location
62 AC_ARG_WITH(piddir,
63 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
64 [ case "$withval" in
65   yes|no)
66   #
67   # Just in case anybody calls it without argument
68   #
69     AC_MSG_WARN([--with-piddir called without argument - will use default])
70   ;;
71   * )
72     piddir="$withval"
73     ;;
74   esac])
76 #################################################
77 # set SWAT directory location
78 AC_ARG_WITH(swatdir,
79 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
80 [ case "$withval" in
81   yes|no)
82   #
83   # Just in case anybody does it
84   #
85     AC_MSG_WARN([--with-swatdir called without argument - will use default])
86   ;;
87   * )
88     swatdir="$withval"
89     ;;
90   esac])
92 #################################################
93 # set configuration directory location
94 AC_ARG_WITH(configdir,
95 [  --with-configdir=DIR    Where to put configuration files (\$libdir)],
96 [ case "$withval" in
97   yes|no)
98   #
99   # Just in case anybody does it
100   #
101     AC_MSG_WARN([--with-configdir called without argument - will use default])
102   ;;
103   * )
104     configdir="$withval"
105     ;;
106   esac])
108 #################################################
109 # set codepage directory location
110 AC_ARG_WITH(codepagedir,
111 [  --with-codepagedir=DIR  Where to put codepage files (\$libdir/codepages)],
112 [ case "$withval" in
113   yes|no)
114   #
115   # Just in case anybody does it
116   #
117     AC_MSG_WARN([--with-codepagedir called without argument - will use default])
118   ;;
119   * )
120     codepagedir="$withval"
121     ;;
122   esac])
124 #################################################
125 # set log directory location
126 AC_ARG_WITH(logfilebase,
127 [  --with-logfilebase=DIR  Where to put log files (\$(VARDIR))],
128 [ case "$withval" in
129   yes|no)
130   #
131   # Just in case anybody does it
132   #
133     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
134   ;;
135   * )
136     logfilebase="$withval"
137     ;;
138   esac])
140 AC_SUBST(codepagedir)
141 AC_SUBST(configdir)
142 AC_SUBST(lockdir)
143 AC_SUBST(piddir)
144 AC_SUBST(logfilebase)
145 AC_SUBST(privatedir)
146 AC_SUBST(swatdir)
147 AC_SUBST(bindir)
148 AC_SUBST(sbindir)
150 dnl Unique-to-Samba variables we'll be playing with.
151 AC_SUBST(SHELL)
152 AC_SUBST(RUNPROG)
153 AC_SUBST(MPROGS)
154 AC_SUBST(LDSHFLAGS)
155 AC_SUBST(SONAMEFLAG)
156 AC_SUBST(SHLD) 
157 AC_SUBST(HOST_OS)
158 AC_SUBST(PAM_MOD)
159 AC_SUBST(PDBEDIT)
160 AC_SUBST(WRAP)
161 AC_SUBST(WRAP32)
162 AC_SUBST(WRAPPROG)
163 AC_SUBST(PICFLAG)
164 AC_SUBST(PICSUFFIX)
165 AC_SUBST(SHLIBEXT)
166 AC_SUBST(BLDSHARED)
167 AC_SUBST(LIBSMBCLIENT_SHARED)
168 AC_SUBST(LIBSMBCLIENT)
170 # compile with optimization and without debugging by default
171 CFLAGS="-O ${CFLAGS}"
173 AC_ARG_ENABLE(debug, 
174 [  --enable-debug          Turn on compiler debugging information (default=no)],
175     [if eval "test x$enable_debug = xyes"; then
176         CFLAGS="${CFLAGS} -g"
177     fi])
181 dnl Checks for programs.
182 AC_PROG_CC
183 AC_PROG_INSTALL
184 AC_PROG_AWK
185 dnl Check if we use GNU ld
186 LD=ld
187 AC_PROG_LD_GNU
188 AC_PATH_PROG(passwd_program, passwd, /bin/passwd)
189 AC_SUBST(passwd_program)
191 dnl Check if C compiler understands -c and -o at the same time
192 AC_PROG_CC_C_O
193 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
194       BROKEN_CC=
195 else
196       BROKEN_CC=#
198 AC_SUBST(BROKEN_CC)
200 dnl Check if the C compiler understands volatile (it should, being ANSI).
201 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
202     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
203         samba_cv_volatile=yes,samba_cv_volatile=no)])
204 if test x"$samba_cv_volatile" = x"yes"; then
205    AC_DEFINE(HAVE_VOLATILE)
210 AC_CANONICAL_SYSTEM
212 dnl Add #include for broken IRIX header files
213   case "$host_os" in
214         *irix6*) AC_ADD_INCLUDE(<standards.h>)
215         ;;
216 esac
218 AC_VALIDATE_CACHE_SYSTEM_TYPE
220 DYNEXP=
223 # Config CPPFLAG settings for strange OS's that must be set
224 # before other tests.
226 case "$host_os" in
227 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
228     *hpux*)
229       AC_PROG_CC_FLAG(Ae)
230       # mmap on HPUX is completely broken...
231       AC_DEFINE(MMAP_BLACKLIST)
232       if test $ac_cv_prog_cc_Ae = yes; then
233         CPPFLAGS="$CPPFLAGS -Ae"
234       fi
236 # Defines needed for HPUX support.
237 # HPUX has bigcrypt but (sometimes?) doesn't use it for
238 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
240       case `uname -r` in
241                         *9*|*10*)
242                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
243                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
244                                 AC_DEFINE(_HPUX_SOURCE)
245                                 AC_DEFINE(_POSIX_SOURCE)
246                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1)
247                                 AC_DEFINE(_MAX_ALIGNMENT,4)
248                                 ;;
249                         *11*)
250                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
251                                 AC_DEFINE(_HPUX_SOURCE)
252                                 AC_DEFINE(_POSIX_SOURCE)
253                                 AC_DEFINE(_LARGEFILE64_SOURCE)
254                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1)
255                                 AC_DEFINE(_MAX_ALIGNMENT,4)
256                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
257                                 ;;
258       esac
259       DYNEXP="-Wl,-E"
260       ;;
264 # CRAY Unicos has broken const handling
265         *unicos*)
266                 AC_MSG_RESULT([disabling const])
267                 CPPFLAGS="$CPPFLAGS -Dconst="
268                 ;;
271 # AIX4.x doesn't even admit to having large
272 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
274     *aix4*)
275           AC_MSG_RESULT([enabling large file support])
276       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
277       AC_DEFINE(_LARGE_FILES)
278       ;;    
280 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
281 # to the existance of large files..
282 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
283 # recommendations on large file support, however it makes the
284 # compile work using gcc 2.7 and 2.8, whereas using the Sun
285 # recommendation makes the compile fail on gcc2.7. JRA.
287         *solaris*)
288                 case `uname -r` in
289                         5.0*|5.1*|5.2*|5.3*|5.5*)
290                                 AC_MSG_RESULT([no large file support])
291                                 ;;
292                         5.*)
293                         AC_MSG_RESULT([enabling large file support])
294                         if test "$ac_cv_prog_gcc" = yes; then
295                                 ${CC-cc} -v >conftest.c 2>&1
296                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
297                                 rm -fr conftest.c
298                                 case "$ac_cv_gcc_compiler_version_number" in
299                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
300                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
301                                                 AC_DEFINE(_LARGEFILE64_SOURCE)
302                                                 ;;
303                                         *)
304                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
305                                                 AC_DEFINE(_LARGEFILE64_SOURCE)
306                                                 AC_DEFINE(_FILE_OFFSET_BITS,64)
307                                                 ;;
308                                 esac
309                         else
310                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
311                                 AC_DEFINE(_LARGEFILE64_SOURCE)
312                                 AC_DEFINE(_FILE_OFFSET_BITS,64)
313                         fi
314                         ;;
315                 esac
316                 ;;
318 # Tests needed for SINIX large file support.
320     *sysv4*)
321       if test $host = mips-sni-sysv4 ; then
322         AC_MSG_CHECKING([for LFS support])
323         old_CPPFLAGS="$CPPFLAGS"
324         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
325         AC_TRY_RUN([
326 #include <unistd.h>
327 main () {
328 #if _LFS64_LARGEFILE == 1
329 exit(0);
330 #else
331 exit(1);
332 #endif
333 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
334         CPPFLAGS="$old_CPPFLAGS"
335         if test x$SINIX_LFS_SUPPORT = xyes ; then
336           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
337           AC_DEFINE(_LARGEFILE64_SOURCE)
338           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
339           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
340           LIBS="`getconf LFS64_LIBS` $LIBS"
341         fi
342       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
343       fi
344     ;;
346 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
348     *linux*)
349         AC_MSG_CHECKING([for LFS support])
350         old_CPPFLAGS="$CPPFLAGS"
351         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
352        AC_TRY_RUN([
353 #include <unistd.h>
354 #include <sys/utsname.h>
355 main() {
356 #if _LFS64_LARGEFILE == 1
357        struct utsname uts;
358        char *release;
359        int major, minor;
361        /* Ensure this is glibc 2.2 or higher */
362 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
363        int libc_major = __GLIBC__;
364        int libc_minor = __GLIBC_MINOR__;
366        if (libc_major < 2)
367               exit(1);
368        if (libc_minor < 2)
369               exit(1);
370 #endif
372        /* Ensure this is kernel 2.4 or higher */
374        uname(&uts);
375        release = uts.release;
376        major = atoi(strsep(&release, "."));
377        minor = atoi(strsep(&release, "."));
379        if (major > 2 || (major == 2 && minor > 3))
380                exit(0);
381        exit(1);
382 #else
383        exit(1);
384 #endif
386 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
387         CPPFLAGS="$old_CPPFLAGS"
388         if test x$LINUX_LFS_SUPPORT = xyes ; then
389           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
390           AC_DEFINE(_LARGEFILE64_SOURCE)
391           AC_DEFINE(_FILE_OFFSET_BITS,64)
392           AC_DEFINE(_GNU_SOURCE)
393         fi
394        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
395                 ;;
397     *hurd*)
398         AC_MSG_CHECKING([for LFS support])
399         old_CPPFLAGS="$CPPFLAGS"
400         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
401         AC_TRY_RUN([
402 #include <unistd.h>
403 main () {
404 #if _LFS64_LARGEFILE == 1
405 exit(0);
406 #else
407 exit(1);
408 #endif
409 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
410         CPPFLAGS="$old_CPPFLAGS"
411         if test x$GLIBC_LFS_SUPPORT = xyes ; then
412           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
413           AC_DEFINE(_LARGEFILE64_SOURCE)
414           AC_DEFINE(_GNU_SOURCE)
415         fi
416       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
417     ;;
419 esac
421 AC_INLINE
422 AC_HEADER_STDC
423 AC_HEADER_DIRENT
424 AC_HEADER_TIME
425 AC_HEADER_SYS_WAIT
426 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
427 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
428 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
429 AC_CHECK_HEADERS(stdlib.h string.h strings.h syslog.h sys/file.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 sys/socket.h)
432 AC_CHECK_HEADERS(syslog.h sys/syslog.h 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 dlfcn.h synch.h pthread.h nsswitch.h)
437 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
438 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
440 case "$host_os" in
441     *hpux*)
442                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
443                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
444                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
445                    AC_DEFINE(HAVE_SHADOW_H)
446                 fi
447         ;;
448 esac
449 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
450 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
451 AC_CHECK_HEADERS(stropts.h poll.h)
452 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
453 AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
455 # For experimental utmp support (lastlog on some BSD-like systems)
456 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
458 # For quotas on Veritas VxFS filesystems
459 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
461 # For quotas on Linux XFS filesystems
462 AC_CHECK_HEADERS(linux/xqm.h)
464 AC_CHECK_SIZEOF(int,cross)
465 AC_CHECK_SIZEOF(long,cross)
466 AC_CHECK_SIZEOF(short,cross)
468 AC_C_CONST
469 AC_C_INLINE
470 AC_C_BIGENDIAN
471 AC_C_CHAR_UNSIGNED
473 AC_TYPE_SIGNAL
474 AC_TYPE_UID_T
475 AC_TYPE_MODE_T
476 AC_TYPE_OFF_T
477 AC_TYPE_SIZE_T
478 AC_TYPE_PID_T
479 AC_STRUCT_ST_RDEV
480 AC_DIRENT_D_OFF
481 AC_CHECK_TYPE(ino_t,unsigned)
482 AC_CHECK_TYPE(loff_t,off_t)
483 AC_CHECK_TYPE(offset_t,loff_t)
484 AC_CHECK_TYPE(ssize_t, int)
485 AC_CHECK_TYPE(wchar_t, unsigned short)
487 ############################################
488 # for cups support we need libcups, and a handful of header files
490 AC_ARG_ENABLE(cups,
491 [  --enable-cups           Turn on CUPS support (default=auto)])
493 if test x$enable_cups != xno; then
494         AC_PATH_PROG(CUPS_CONFIG, cups-config)
496         if test "x$CUPS_CONFIG" != x; then
497                 AC_DEFINE(HAVE_CUPS)
498                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
499                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
500                 LIBS="$LIBS `$CUPS_CONFIG --libs`"
501         fi
504 ############################################
505 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the new VFS code
506 AC_CHECK_FUNCS(dlopen)
507 if test x"$ac_cv_func_dlopen" = x"no"; then
508         AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
509         AC_DEFINE(HAVE_DLOPEN)])
511 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
513 ############################################
514 # check if the compiler can do immediate structures
515 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
516     AC_TRY_COMPILE([
517 #include <stdio.h>],
519         typedef struct {unsigned x;} FOOBAR;
520 #define X_FOOBAR(x) ((FOOBAR) { x })
521 #define FOO_ONE X_FOOBAR(1)
522         FOOBAR f = FOO_ONE;
523         static struct {
524         FOOBAR y;
525         } f2[] = {
526                 {FOO_ONE}
527         };
529         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
530 if test x"$samba_cv_immediate_structures" = x"yes"; then
531    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES)
534 ############################################
535 # check for unix domain sockets
536 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
537     AC_TRY_COMPILE([
538 #include <sys/types.h>
539 #include <stdlib.h>
540 #include <stddef.h>
541 #include <sys/socket.h>
542 #include <sys/un.h>],
544   struct sockaddr_un sunaddr; 
545   sunaddr.sun_family = AF_UNIX;
547         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
548 if test x"$samba_cv_unixsocket" = x"yes"; then
549    AC_DEFINE(HAVE_UNIXSOCKET)
552 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
553     AC_TRY_COMPILE([
554 #include <sys/types.h>
555 #if STDC_HEADERS
556 #include <stdlib.h>
557 #include <stddef.h>
558 #endif
559 #include <sys/socket.h>],[socklen_t i = 0],
560     samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
561 if test x"$samba_cv_socklen_t" = x"yes"; then
562    AC_DEFINE(HAVE_SOCKLEN_T_TYPE)
565 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
566     AC_TRY_COMPILE([
567 #include <sys/types.h>
568 #if STDC_HEADERS
569 #include <stdlib.h>
570 #include <stddef.h>
571 #endif
572 #include <signal.h>],[sig_atomic_t i = 0],
573         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
574 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
575    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE)
578 # stupid headers have the functions but no declaration. grrrr.
579 AC_HAVE_DECL(errno, [#include <errno.h>])
580 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
581 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
582 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
583 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
584 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
585 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
587 # and glibc has setresuid under linux but the function does
588 # nothing until kernel 2.1.44! very dumb.
589 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
590     AC_TRY_RUN([#include <errno.h>
591 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
592         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
593 if test x"$samba_cv_have_setresuid" = x"yes"; then
594     AC_DEFINE(HAVE_SETRESUID)
597 # Do the same check for setresguid...
599 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
600     AC_TRY_RUN([#include <unistd.h>
601 #include <errno.h>
602 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
603         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
604 if test x"$samba_cv_have_setresgid" = x"yes"; then
605     AC_DEFINE(HAVE_SETRESGID)
608 AC_FUNC_MEMCMP
610 ###############################################
611 # Readline included by default unless explicitly asked not to
612 test "${with_readline+set}" != "set" && with_readline=yes
614 # test for where we get readline() from
615 AC_MSG_CHECKING(whether to use readline)
616 AC_ARG_WITH(readline,
617 [  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto)],
618 [  case "$with_readline" in
619   yes)
620     AC_MSG_RESULT(yes)
622     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
623     AC_CHECK_HEADERS(readline/history.h)
625     AC_CHECK_HEADERS(readline.h readline/readline.h,[
626       for termlib in ncurses curses termcap terminfo termlib; do
627        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
628       done
629       AC_CHECK_LIB(readline, rl_callback_handler_install,
630        [TERMLIBS="-lreadline $TERMLIBS"
631        AC_DEFINE(HAVE_LIBREADLINE)
632        break], [TERMLIBS=], $TERMLIBS)])
633     ;;
634   no)
635     AC_MSG_RESULT(no)
636     ;;
637   *)
638     AC_MSG_RESULT(yes)
640     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
641     # alternate readline path
642     _ldflags=${LDFLAGS}
643     _cppflags=${CPPFLAGS}
645     # Add additional search path
646     LDFLAGS="-L$with_readline/lib $LDFLAGS"
647     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
649     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
650     AC_CHECK_HEADERS(readline/history.h)
652     AC_CHECK_HEADERS(readline.h readline/readline.h,[
653       for termlib in ncurses curses termcap terminfo termlib; do
654        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
655       done
656       AC_CHECK_LIB(readline, rl_callback_handler_install,
657        [TERMLDFLAGS="-L$with_readline/lib"
658        TERMCPPFLAGS="-I$with_readline/include"
659        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
660        TERMLIBS="-lreadline $TERMLIBS"
661        AC_DEFINE(HAVE_LIBREADLINE)
662        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
664     LDFLAGS=$_ldflags
665     ;;
666   esac],
667   AC_MSG_RESULT(no)
669 AC_SUBST(TERMLIBS)
670 AC_SUBST(TERMLDFLAGS)
672 # The following test taken from the cvs sources
673 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
674 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
675 # libsocket.so which has a bad implementation of gethostbyname (it
676 # only looks in /etc/hosts), so we only look for -lsocket if we need
677 # it.
678 AC_CHECK_FUNCS(connect)
679 if test x"$ac_cv_func_connect" = x"no"; then
680     case "$LIBS" in
681     *-lnsl*) ;;
682     *) AC_CHECK_LIB(nsl_s, printf) ;;
683     esac
684     case "$LIBS" in
685     *-lnsl*) ;;
686     *) AC_CHECK_LIB(nsl, printf) ;;
687     esac
688     case "$LIBS" in
689     *-lsocket*) ;;
690     *) AC_CHECK_LIB(socket, connect) ;;
691     esac
692     case "$LIBS" in
693     *-linet*) ;;
694     *) AC_CHECK_LIB(inet, connect) ;;
695     esac
696     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
697     dnl has been cached.
698     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
699        test x"$ac_cv_lib_inet_connect" = x"yes"; then
700         # ac_cv_func_connect=yes
701         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
702         AC_DEFINE(HAVE_CONNECT)
703     fi
706 ###############################################
707 # test for where we get get_yp_default_domain() from
708 AC_CHECK_FUNCS(yp_get_default_domain)
709 if test x"$ac_cv_func_yp_get_default_domain" = x"no"; then
710         AC_CHECK_LIB(nsl, yp_get_default_domain, [LIBS="$LIBS -lnsl";
711         AC_DEFINE(HAVE_YP_GET_DEFAULT_DOMAIN)]) 
714 # Check if we have execl, if not we need to compile smbrun.
715 AC_CHECK_FUNCS(execl)
716 if test x"$ac_cv_func_execl" = x"no"; then
717     RUNPROG="bin/smbrun"
718 else
719     RUNPROG=""
722 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link)
723 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid mknod mknod64)
724 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
725 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
726 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
727 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
728 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
729 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
730 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
731 AC_CHECK_FUNCS(syslog vsyslog)
733 # syscall() is needed for smbwrapper.
734 AC_CHECK_FUNCS(syscall)
736 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
737 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
738 AC_CHECK_FUNCS(__getcwd _getcwd)
739 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
740 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
741 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
742 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
743 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
744 AC_CHECK_FUNCS(_write __write _fork __fork)
745 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
746 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
747 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
748 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
749 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
752 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
755 if test x$ac_cv_func_stat64 = xno ; then
756   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
757   AC_TRY_LINK([
758 #if defined(HAVE_UNISTD_H)
759 #include <unistd.h>
760 #endif
761 #include <sys/stat.h>
762 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
763   AC_MSG_RESULT([$ac_cv_func_stat64])
764   if test x$ac_cv_func_stat64 = xyes ; then
765     AC_DEFINE(HAVE_STAT64)
766   fi
769 if test x$ac_cv_func_lstat64 = xno ; then
770   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
771   AC_TRY_LINK([
772 #if defined(HAVE_UNISTD_H)
773 #include <unistd.h>
774 #endif
775 #include <sys/stat.h>
776 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
777   AC_MSG_RESULT([$ac_cv_func_lstat64])
778   if test x$ac_cv_func_lstat64 = xyes ; then
779     AC_DEFINE(HAVE_LSTAT64)
780   fi
783 if test x$ac_cv_func_fstat64 = xno ; then
784   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
785   AC_TRY_LINK([
786 #if defined(HAVE_UNISTD_H)
787 #include <unistd.h>
788 #endif
789 #include <sys/stat.h>
790 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
791   AC_MSG_RESULT([$ac_cv_func_fstat64])
792   if test x$ac_cv_func_fstat64 = xyes ; then
793     AC_DEFINE(HAVE_FSTAT64)
794   fi
798 # If no strcasecmp, check for it in some known places
799 # It is in -lresolv on ReliantUNIX and UnixWare
800 #   -lresolve *must* follow -lnsl for name resolution to work properly
803 if test x$ac_cv_func_strcasecmp = xno ; then
804         AC_CHECK_LIB(resolv,strcasecmp,[LIBS="$LIBS -lresolv"]
805                 AC_DEFINE(HAVE_STRCASECMP))
809 # Check for the functions putprpwnam, set_auth_parameters,
810 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
811 # Needed for OSF1 and HPUX.
814 AC_LIBTESTFUNC(security, putprpwnam)
815 AC_LIBTESTFUNC(sec, putprpwnam)
817 AC_LIBTESTFUNC(security, set_auth_parameters)
818 AC_LIBTESTFUNC(sec, set_auth_parameters)
820 # UnixWare 7.x has its getspnam in -lgen
821 AC_LIBTESTFUNC(gen, getspnam)
823 AC_LIBTESTFUNC(security, getspnam)
824 AC_LIBTESTFUNC(sec, getspnam)
826 AC_LIBTESTFUNC(security, bigcrypt)
827 AC_LIBTESTFUNC(sec, bigcrypt)
829 AC_LIBTESTFUNC(security, getprpwnam)
830 AC_LIBTESTFUNC(sec, getprpwnam)
832 # this bit needs to be modified for each OS that is suported by
833 # smbwrapper. You need to specify how to created a shared library and
834 # how to compile C code to produce PIC object files
836 # these are the defaults, good for lots of systems
837 HOST_OS="$host_os"
838 LDSHFLAGS="-shared"
839 SONAMEFLAG="#"
840 SHLD="\${CC}" 
841 PICFLAG=""
842 PICSUFFIX="po.o"
843 SHLIBEXT="so"
844 # Assume non-shared by default and override below
845 BLDSHARED="false" 
846 AC_MSG_CHECKING([ability to build shared libraries])
848 # and these are for particular systems
849 case "$host_os" in
850                 *linux*)   AC_DEFINE(LINUX)
851                         BLDSHARED="true"
852                         LDSHFLAGS="-shared"
853                         DYNEXP="-Wl,--export-dynamic"
854                         PICFLAG="-fPIC"
855                         SONAMEFLAG="-Wl,-soname="
856                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
857                         ;;
858                 *solaris*) AC_DEFINE(SUNOS5)
859                         BLDSHARED="true"
860                         LDSHFLAGS="-G"
861                         SONAMEFLAG="-h "
862                         if test "${GCC}" = "yes"; then
863                                 PICFLAG="-fPIC"
864                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
865                                         DYNEXP="-Wl,-E"
866                                 fi
867                         else
868                                 PICFLAG="-KPIC"
869                                 ## ${CFLAGS} added for building 64-bit shared 
870                                 ## libs using Sun's Compiler
871                                 LDSHFLAGS="-G \${CFLAGS}"
872                                 POBAD_CC=""
873                                 PICSUFFIX="po.o"
874                         fi
875                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
876                 ;;
877                 *sunos*) AC_DEFINE(SUNOS4)
878                         BLDSHARED="true"
879                         LDSHFLAGS="-G"
880                         SONAMEFLAG="-Wl,-h,"
881                         PICFLAG="-KPIC"   # Is this correct for SunOS
882                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
883                 ;;
884                 *freebsd*)  BLDSHARED="true"
885                         LDSHFLAGS="-shared"
886                         DYNEXP="-Wl,--export-dynamic"
887                         SONAMEFLAG="-Wl,-soname,"
888                         PICFLAG="-fPIC -DPIC"
889                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
890                 ;;
891                 *openbsd*)  BLDSHARED="true"
892                         LDSHFLAGS="-shared"
893                         DYNEXP="-Wl,-Bdynamic"
894                         SONAMEFLAG="-Wl,-soname,"
895                         PICFLAG="-fPIC"
896                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
897                 ;;
898                 *irix*) AC_DEFINE(IRIX)
899                         case "$host_os" in
900                         *irix6*) AC_DEFINE(IRIX6)
901                         ;;
902                         esac
903                         ATTEMPT_WRAP32_BUILD=yes
904                         BLDSHARED="true"
905                         LDSHFLAGS="-set_version sgi1.0 -shared"
906                         SONAMEFLAG="-soname "
907                         SHLD="\${LD}" 
908                         if test "${GCC}" = "yes"; then
909                                 PICFLAG="-fPIC"
910                         else 
911                                 PICFLAG="-KPIC"
912                         fi
913                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
914                 ;;
915                 *aix*) AC_DEFINE(AIX)
916                         BLDSHARED="true"
917                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
918                         DYNEXP="-Wl,-brtl,-bexpall"
919                         PICFLAG="-O2"
920                         if test "${GCC}" != "yes"; then
921                                 ## for funky AIX compiler using strncpy()
922                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
923                         fi
925                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE)
926                 ;;
927                 *hpux*) AC_DEFINE(HPUX)
928                         SHLIBEXT="sl"
929                         # Use special PIC flags for the native HP-UX compiler.
930                         if test $ac_cv_prog_cc_Ae = yes; then
931                                 BLDSHARED="true"
932                                 SHLD="/usr/bin/ld"
933                                 LDSHFLAGS="-B symbolic -b -z"
934                                 SONAMEFLAG="+h "
935                                 PICFLAG="+z"
936                         fi
937                         DYNEXP="-Wl,-E"
938                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192)
939                         ;;
940                 *qnx*) AC_DEFINE(QNX)
941                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
942                         ;;
943                 *osf*) AC_DEFINE(OSF1)
944                         BLDSHARED="true"
945                         LDSHFLAGS="-shared"
946                         SONAMEFLAG="-Wl,-soname,"
947                         PICFLAG="-fPIC"
948                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
949                 ;;
950                 *sco*) AC_DEFINE(SCO)
951                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
952                         ;;
953                 *unixware*) AC_DEFINE(UNIXWARE)
954                         BLDSHARED="true"
955                         LDSHFLAGS="-shared"
956                         SONAMEFLAG="-Wl,-soname,"
957                         PICFLAG="-KPIC"
958                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
959                 ;;
960                 *next2*) AC_DEFINE(NEXT2)
961                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
962                         ;;
963                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
964                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
965                         ;;
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                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
977                         ;;
978                 *sysv5*)
979                         if [ test "$GCC" != yes ]; then
980                                 AC_DEFINE(HAVE_MEMSET)
981                         fi
982                         LDSHFLAGS="-G"
983                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
984                         ;;
985                 *)
986                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
987                         ;;
988 esac
989 AC_SUBST(DYNEXP)
990 AC_MSG_RESULT($BLDSHARED)
991 AC_MSG_CHECKING([linker flags for shared libraries])
992 AC_MSG_RESULT([$LDSHFLAGS])
993 AC_MSG_CHECKING([compiler flags for position-independent code])
994 AC_MSG_RESULT([$PICFLAGS])
996 # try to work out how to produce pic code with this compiler
997 if test x$PICFLAG = x; then
998   AC_PROG_CC_FLAG(fpic)
999   if test $ac_cv_prog_cc_fpic = yes; then
1000       PICFLAG="-fpic";
1001   fi
1003 if test x$PICFLAG = x; then
1004   AC_PROG_CC_FLAG(KPIC)
1005   if test $ac_cv_prog_cc_KPIC = yes; then
1006     PICFLAG="-KPIC";
1007   fi
1009 if test x$PICFLAG = x; then
1010   AC_PROG_CC_FLAG(Kpic)
1011   if test $ac_cv_prog_cc_Kpic = yes; then
1012     PICFLAG="-Kpic";
1013   fi
1016 ################
1018 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1019 AC_TRY_RUN([#include <stdio.h>
1020 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1021 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1022 if test x"$samba_cv_have_longlong" = x"yes"; then
1023     AC_DEFINE(HAVE_LONGLONG)
1027 # Check if the compiler supports the LL prefix on long long integers.
1028 # AIX needs this.
1030 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1031     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1032         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1033 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1034    AC_DEFINE(COMPILER_SUPPORTS_LL)
1037   
1038 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1039 AC_TRY_RUN([#include <stdio.h>
1040 #include <sys/stat.h>
1041 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1042 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1043 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1044     AC_DEFINE(SIZEOF_OFF_T,8)
1047 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1048 AC_TRY_RUN([
1049 #if defined(HAVE_UNISTD_H)
1050 #include <unistd.h>
1051 #endif
1052 #include <stdio.h>
1053 #include <sys/stat.h>
1054 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1055 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1056 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1057     AC_DEFINE(HAVE_OFF64_T)
1060 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1061 AC_TRY_RUN([#include <stdio.h>
1062 #include <sys/stat.h>
1063 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1064 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1065 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1066     AC_DEFINE(SIZEOF_INO_T,8)
1069 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1070 AC_TRY_RUN([
1071 #if defined(HAVE_UNISTD_H)
1072 #include <unistd.h>
1073 #endif
1074 #include <stdio.h>
1075 #include <sys/stat.h>
1076 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1077 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1078 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1079     AC_DEFINE(HAVE_INO64_T)
1082 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1083 AC_TRY_RUN([
1084 #if defined(HAVE_UNISTD_H)
1085 #include <unistd.h>
1086 #endif
1087 #include <stdio.h>
1088 #include <sys/stat.h>
1089 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1090 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1091 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1092     AC_DEFINE(HAVE_DEV64_T)
1095 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1096 AC_TRY_COMPILE([
1097 #if defined(HAVE_UNISTD_H)
1098 #include <unistd.h>
1099 #endif
1100 #include <sys/types.h>
1101 #include <dirent.h>],
1102 [struct dirent64 de;],
1103 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1104 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1105     AC_DEFINE(HAVE_STRUCT_DIRENT64)
1108 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1109 AC_TRY_RUN([
1110 #if defined(HAVE_UNISTD_H)
1111 #include <unistd.h>
1112 #endif
1113 #include <sys/types.h>
1114 main() { dev_t dev; int i = major(dev); return 0; }],
1115 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1116 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1117     AC_DEFINE(HAVE_DEVICE_MAJOR_FN)
1120 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1121 AC_TRY_RUN([
1122 #if defined(HAVE_UNISTD_H)
1123 #include <unistd.h>
1124 #endif
1125 #include <sys/types.h>
1126 main() { dev_t dev; int i = minor(dev); return 0; }],
1127 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1128 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1129     AC_DEFINE(HAVE_DEVICE_MINOR_FN)
1132 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV_FN,[
1133 AC_TRY_RUN([
1134 #if defined(HAVE_UNISTD_H)
1135 #include <unistd.h>
1136 #endif
1137 #include <sys/types.h>
1138 main() { dev_t dev = makedev(1,2); return 0; }],
1139 samba_cv_HAVE_MAKEDEV_FN=yes,samba_cv_HAVE_MAKEDEV_FN=no,samba_cv_HAVE_MAKEDEV_FN=cross)])
1140 if test x"$samba_cv_HAVE_MAKEDEV_FN" = x"yes"; then
1141     AC_DEFINE(MAKEDEV_FN)
1144 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1145 AC_TRY_RUN([#include <stdio.h>
1146 main() { char c; c=250; exit((c > 0)?0:1); }],
1147 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1148 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1149     AC_DEFINE(HAVE_UNSIGNED_CHAR)
1152 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1153 AC_TRY_COMPILE([#include <sys/types.h>
1154 #include <sys/socket.h>
1155 #include <netinet/in.h>],
1156 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1157 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1158 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1159     AC_DEFINE(HAVE_SOCK_SIN_LEN)
1162 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1163 AC_TRY_COMPILE([#include <sys/types.h>
1164 #include <dirent.h>
1165 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1166 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1167 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1168     AC_DEFINE(SEEKDIR_RETURNS_VOID)
1171 AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
1172 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
1173 samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
1174 if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
1175     AC_DEFINE(HAVE_FILE_MACRO)
1178 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1179 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1180 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1181 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1182     AC_DEFINE(HAVE_FUNCTION_MACRO)
1185 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1186 AC_TRY_RUN([
1187 #include <sys/time.h>
1188 #include <unistd.h>
1189 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1190            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1191 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1192     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
1195 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
1196 AC_TRY_LINK([#include <stdarg.h>
1197 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1198 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
1199 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1200     AC_DEFINE(HAVE_VA_COPY)
1203 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1204 AC_TRY_RUN([
1205 #include <sys/types.h>
1206 #include <stdarg.h>
1207 void foo(const char *format, ...) {
1208         va_list ap;
1209         int len;
1210         char buf[5];
1212         va_start(ap, format);
1213         len = vsnprintf(buf, 0, format, ap);
1214         va_end(ap);
1215         if (len != 5) exit(1);
1217         va_start(ap, format);
1218         len = vsnprintf(0, 0, format, ap);
1219         va_end(ap);
1220         if (len != 5) exit(1);
1222         if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1224         exit(0);
1226 main() { foo("hello"); }
1228 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1229 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1230         AC_DEFINE(HAVE_C99_VSNPRINTF)
1233 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1234 AC_TRY_RUN([#include <sys/types.h>
1235 #include <dirent.h>
1236 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1237 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1238 di->d_name[0] == 0) exit(0); exit(1);} ],
1239 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1240 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1241     AC_DEFINE(HAVE_BROKEN_READDIR)
1244 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1245 AC_TRY_COMPILE([#include <sys/types.h>
1246 #include <utime.h>],
1247 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1248 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1249 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1250     AC_DEFINE(HAVE_UTIMBUF)
1253 dnl  utmp and utmpx come in many flavours
1254 dnl  We need to check for many of them
1255 dnl  But we don't need to do each and every one, because our code uses
1256 dnl  mostly just the utmp (not utmpx) fields.
1258 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1260 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1261 AC_TRY_COMPILE([#include <sys/types.h>
1262 #include <utmp.h>],
1263 [struct utmp ut;  ut.ut_name[0] = 'a';],
1264 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1265 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1266     AC_DEFINE(HAVE_UT_UT_NAME)
1267 fi 
1269 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1270 AC_TRY_COMPILE([#include <sys/types.h>
1271 #include <utmp.h>],
1272 [struct utmp ut;  ut.ut_user[0] = 'a';],
1273 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1274 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1275     AC_DEFINE(HAVE_UT_UT_USER)
1276 fi 
1278 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1279 AC_TRY_COMPILE([#include <sys/types.h>
1280 #include <utmp.h>],
1281 [struct utmp ut;  ut.ut_id[0] = 'a';],
1282 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1283 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1284     AC_DEFINE(HAVE_UT_UT_ID)
1285 fi 
1287 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1288 AC_TRY_COMPILE([#include <sys/types.h>
1289 #include <utmp.h>],
1290 [struct utmp ut;  ut.ut_host[0] = 'a';],
1291 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1292 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1293     AC_DEFINE(HAVE_UT_UT_HOST)
1294 fi 
1296 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1297 AC_TRY_COMPILE([#include <sys/types.h>
1298 #include <utmp.h>],
1299 [struct utmp ut;  time_t t; ut.ut_time = t;],
1300 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1301 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1302     AC_DEFINE(HAVE_UT_UT_TIME)
1303 fi 
1305 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1306 AC_TRY_COMPILE([#include <sys/types.h>
1307 #include <utmp.h>],
1308 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1309 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1310 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1311     AC_DEFINE(HAVE_UT_UT_TV)
1312 fi 
1314 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1315 AC_TRY_COMPILE([#include <sys/types.h>
1316 #include <utmp.h>],
1317 [struct utmp ut;  ut.ut_type = 0;],
1318 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1319 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1320     AC_DEFINE(HAVE_UT_UT_TYPE)
1321 fi 
1323 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1324 AC_TRY_COMPILE([#include <sys/types.h>
1325 #include <utmp.h>],
1326 [struct utmp ut;  ut.ut_pid = 0;],
1327 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1328 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1329     AC_DEFINE(HAVE_UT_UT_PID)
1330 fi 
1332 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1333 AC_TRY_COMPILE([#include <sys/types.h>
1334 #include <utmp.h>],
1335 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1336 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1337 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1338     AC_DEFINE(HAVE_UT_UT_EXIT)
1339 fi 
1341 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1342 AC_TRY_COMPILE([#include <sys/types.h>
1343 #include <utmp.h>],
1344 [struct utmp ut;  ut.ut_addr = 0;],
1345 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1346 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1347     AC_DEFINE(HAVE_UT_UT_ADDR)
1348 fi 
1350 if test x$ac_cv_func_pututline = xyes ; then
1351   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1352   AC_TRY_COMPILE([#include <sys/types.h>
1353 #include <utmp.h>],
1354   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1355   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1356   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1357       AC_DEFINE(PUTUTLINE_RETURNS_UTMP)
1358   fi
1361 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1362 AC_TRY_COMPILE([#include <sys/types.h>
1363 #include <utmpx.h>],
1364 [struct utmpx ux;  ux.ut_syslen = 0;],
1365 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1366 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1367     AC_DEFINE(HAVE_UX_UT_SYSLEN)
1368 fi 
1370 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1371 AC_TRY_RUN([
1372 #include <sys/types.h>
1373 #include <fcntl.h>
1374 #ifndef F_GETLEASE
1375 #define F_GETLEASE      1025
1376 #endif
1377 main() {
1378        int fd = open("/dev/null", O_RDONLY);
1379        return fcntl(fd, F_GETLEASE, 0) == -1;
1382 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1383 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1384     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX)
1387 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1388 AC_TRY_RUN([
1389 #include <sys/types.h>
1390 #include <fcntl.h>
1391 #include <signal.h>
1392 #ifndef F_NOTIFY
1393 #define F_NOTIFY 1026
1394 #endif
1395 main() {
1396         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1399 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1400 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" && test x"$target_cpu" != x"s390"; then
1401     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY)
1404 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1405 AC_TRY_RUN([
1406 #include <sys/types.h>
1407 #include <fcntl.h>
1408 #include <signal.h>
1409 #include <sys/file.h>
1410 #ifndef LOCK_MAND
1411 #define LOCK_MAND       32
1412 #define LOCK_READ       64
1413 #endif
1414 main() {
1415         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1418 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1419 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1420     AC_DEFINE(HAVE_KERNEL_SHARE_MODES)
1426 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1427 AC_TRY_COMPILE([#include <sys/types.h>
1428 #include <fcntl.h>],
1429 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1430 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1431 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1432     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX)
1435 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1436 AC_TRY_RUN([#include <sys/types.h>
1437 #include <sys/capability.h>
1438 main() {
1439  cap_t cap;
1440  if ((cap = cap_get_proc()) == NULL)
1441    exit(1);
1442  cap->cap_effective |= CAP_NETWORK_MGT;
1443  cap->cap_inheritable |= CAP_NETWORK_MGT;
1444  cap_set_proc(cap);
1445  exit(0);
1448 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1449 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1450     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES)
1454 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1455 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1458 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1459 AC_TRY_COMPILE([#include <sys/types.h>
1460 #if defined(HAVE_RPC_RPC_H)
1461 #include <rpc/rpc.h>
1462 #endif],
1463 [int16 testvar;],
1464 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1465 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1466     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H)
1469 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1470 AC_TRY_COMPILE([#include <sys/types.h>
1471 #if defined(HAVE_RPC_RPC_H)
1472 #include <rpc/rpc.h>
1473 #endif],
1474 [uint16 testvar;],
1475 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1476 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1477     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H)
1480 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1481 AC_TRY_COMPILE([#include <sys/types.h>
1482 #if defined(HAVE_RPC_RPC_H)
1483 #include <rpc/rpc.h>
1484 #endif],
1485 [int32 testvar;],
1486 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1487 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1488     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H)
1491 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1492 AC_TRY_COMPILE([#include <sys/types.h>
1493 #if defined(HAVE_RPC_RPC_H)
1494 #include <rpc/rpc.h>
1495 #endif],
1496 [uint32 testvar;],
1497 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1498 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1499     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H)
1503 dnl Some systems (SCO) have a problem including
1504 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1505 dnl as a #define in <prot.h> and as part of an enum
1506 dnl in <rpc/rpc.h>.
1509 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1510 AC_TRY_COMPILE([#include <sys/types.h>
1511 #ifdef HAVE_SYS_SECURITY_H
1512 #include <sys/security.h>
1513 #include <prot.h>
1514 #endif  /* HAVE_SYS_SECURITY_H */
1515 #if defined(HAVE_RPC_RPC_H)
1516 #include <rpc/rpc.h>
1517 #endif],
1518 [int testvar;],
1519 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1520 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1521     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT)
1524 AC_MSG_CHECKING([for test routines])
1525 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1526            AC_MSG_RESULT(yes),
1527            AC_MSG_ERROR([cant find test code. Aborting config]),
1528            AC_MSG_WARN([cannot run when cross-compiling]))
1530 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1531 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1532            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1533 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1534     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
1537 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1538 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1539            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1540 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1541     AC_DEFINE(HAVE_BROKEN_GETGROUPS)
1544 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1545 SAVE_CPPFLAGS="$CPPFLAGS"
1546 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
1547 AC_TRY_COMPILE([
1548 #define REPLACE_GETPASS 1
1549 #define NO_CONFIG_H 1
1550 #define main dont_declare_main
1551 #include "${srcdir-.}/lib/getsmbpass.c"
1552 #undef main
1553 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1554 CPPFLAGS="$SAVE_CPPFLAGS"
1556 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1557         AC_DEFINE(REPLACE_GETPASS)
1560 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1561 AC_TRY_RUN([
1562 #include <stdio.h>
1563 #include <sys/types.h>
1564 #include <netinet/in.h>
1565 #ifdef HAVE_ARPA_INET_H
1566 #include <arpa/inet.h>
1567 #endif
1568 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1569 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1570     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1571 exit(1);}],
1572            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1573 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1574     AC_DEFINE(REPLACE_INET_NTOA)
1577 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1578 AC_TRY_RUN([#include <stdlib.h>
1579 #include <sys/types.h>
1580 #include <sys/stat.h>
1581 #include <unistd.h>
1582 main() { 
1583   struct stat st;
1584   char tpl[20]="/tmp/test.XXXXXX"; 
1585   int fd = mkstemp(tpl); 
1586   if (fd == -1) exit(1);
1587   unlink(tpl);
1588   if (fstat(fd, &st) != 0) exit(1);
1589   if ((st.st_mode & 0777) != 0600) exit(1);
1590   exit(0);
1592 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1593 samba_cv_HAVE_SECURE_MKSTEMP=no,
1594 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1595 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1596     AC_DEFINE(HAVE_SECURE_MKSTEMP)
1599 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1600 AC_TRY_RUN([#include <unistd.h>
1601 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1602 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1603 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1604     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX)
1607 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1608 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1609            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1610 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1611     AC_DEFINE(HAVE_ROOT)
1612 else
1613     AC_MSG_WARN(running as non-root will disable some tests)
1616 ##################
1617 # look for a method of finding the list of network interfaces
1618 iface=no;
1619 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1620 AC_TRY_RUN([
1621 #define HAVE_IFACE_AIX 1
1622 #define AUTOCONF_TEST 1
1623 #include "confdefs.h"
1624 #include "${srcdir-.}/lib/interfaces.c"],
1625            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1626 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1627     iface=yes;AC_DEFINE(HAVE_IFACE_AIX)
1630 if test $iface = no; then
1631 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1632 AC_TRY_RUN([
1633 #define HAVE_IFACE_IFCONF 1
1634 #define AUTOCONF_TEST 1
1635 #include "confdefs.h"
1636 #include "${srcdir-.}/lib/interfaces.c"],
1637            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1638 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1639     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF)
1643 if test $iface = no; then
1644 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1645 AC_TRY_RUN([
1646 #define HAVE_IFACE_IFREQ 1
1647 #define AUTOCONF_TEST 1
1648 #include "confdefs.h"
1649 #include "${srcdir-.}/lib/interfaces.c"],
1650            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1651 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1652     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ)
1657 ################################################
1658 # look for a method of setting the effective uid
1659 seteuid=no;
1660 if test $seteuid = no; then
1661 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1662 AC_TRY_RUN([
1663 #define AUTOCONF_TEST 1
1664 #define USE_SETRESUID 1
1665 #include "confdefs.h"
1666 #include "${srcdir-.}/lib/util_sec.c"],
1667            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1668 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1669     seteuid=yes;AC_DEFINE(USE_SETRESUID)
1674 if test $seteuid = no; then
1675 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1676 AC_TRY_RUN([
1677 #define AUTOCONF_TEST 1
1678 #define USE_SETREUID 1
1679 #include "confdefs.h"
1680 #include "${srcdir-.}/lib/util_sec.c"],
1681            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1682 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1683     seteuid=yes;AC_DEFINE(USE_SETREUID)
1687 if test $seteuid = no; then
1688 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1689 AC_TRY_RUN([
1690 #define AUTOCONF_TEST 1
1691 #define USE_SETEUID 1
1692 #include "confdefs.h"
1693 #include "${srcdir-.}/lib/util_sec.c"],
1694            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1695 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1696     seteuid=yes;AC_DEFINE(USE_SETEUID)
1700 if test $seteuid = no; then
1701 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1702 AC_TRY_RUN([
1703 #define AUTOCONF_TEST 1
1704 #define USE_SETUIDX 1
1705 #include "confdefs.h"
1706 #include "${srcdir-.}/lib/util_sec.c"],
1707            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1708 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1709     seteuid=yes;AC_DEFINE(USE_SETUIDX)
1714 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1715 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1716            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1717 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1718     AC_DEFINE(HAVE_MMAP)
1721 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1722 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1723            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1724 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1725     AC_DEFINE(FTRUNCATE_NEEDS_ROOT)
1728 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1729 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1730            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1731 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1732     AC_DEFINE(HAVE_FCNTL_LOCK)
1735 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1736 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1737            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1738 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1739     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS)
1741 else
1744 dnl Don't check for 64 bit fcntl locking if we know that the
1745 dnl glibc2.1 broken check has succeeded.
1746 dnl 
1748   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1749   AC_TRY_RUN([
1750 #if defined(HAVE_UNISTD_H)
1751 #include <unistd.h>
1752 #endif
1753 #include <stdio.h>
1754 #include <stdlib.h>
1756 #ifdef HAVE_FCNTL_H
1757 #include <fcntl.h>
1758 #endif
1760 #ifdef HAVE_SYS_FCNTL_H
1761 #include <sys/fcntl.h>
1762 #endif
1763 main() { struct flock64 fl64;
1764 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1765 exit(0);
1766 #else
1767 exit(1);
1768 #endif
1770        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1772   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1773       AC_DEFINE(HAVE_STRUCT_FLOCK64)
1774   fi
1777 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1778 AC_TRY_COMPILE([#include <sys/types.h>
1779 #include <sys/stat.h>
1780 #include <unistd.h>],
1781 [struct stat st;  st.st_blocks = 0;],
1782 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1783 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1784     AC_DEFINE(HAVE_STAT_ST_BLOCKS)
1785 fi 
1787 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
1788 AC_TRY_COMPILE([#include <sys/types.h>
1789 #include <sys/stat.h>
1790 #include <unistd.h>],
1791 [struct stat st;  st.st_blksize = 0;],
1792 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
1793 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
1794     AC_DEFINE(HAVE_STAT_ST_BLKSIZE)
1797 case "$host_os" in
1798 *linux*)
1799 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1800 AC_TRY_COMPILE([
1801 #ifdef HAVE_SYS_VFS_H
1802 #include <sys/vfs.h>
1803 #endif
1804 #ifdef HAVE_SYS_CAPABILITY_H
1805 #include <sys/capability.h>
1806 #endif
1807 ],[int i;],
1808    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1809 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1810    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS)
1813 esac
1815 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1816 AC_TRY_COMPILE([#include <sys/acl.h>
1817 #if defined(HAVE_RPCSVC_NIS_H)
1818 #include <rpcsvc/nis.h>
1819 #endif],
1820 [int i;],
1821 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1822 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1823     AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES)
1827 #################################################
1828 # check for smbwrapper support
1829 AC_MSG_CHECKING(whether to use smbwrapper)
1830 AC_ARG_WITH(smbwrapper,
1831 [  --with-smbwrapper       Include SMB wrapper support (default=no)],
1832 [ case "$withval" in
1833   yes)
1834     AC_MSG_RESULT(yes)
1835     AC_DEFINE(WITH_SMBWRAPPER)
1836         WRAPPROG="bin/smbsh"
1837         WRAP="bin/smbwrapper.$SHLIBEXT"
1839         if test x$ATTEMPT_WRAP32_BUILD = x; then
1840                 WRAP32=""
1841         else
1842                         WRAP32=bin/smbwrapper.32.$SHLIBEXT
1843         fi
1845 # Conditions under which smbwrapper should not be built.
1847         if test x$PICFLAG = x; then
1848            echo No support for PIC code - disabling smbwrapper and smbsh
1849            WRAPPROG=""
1850            WRAP=""
1851            WRAP32=""
1852         elif test x$ac_cv_func_syscall = xno; then
1853            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
1854            WRAPPROG=""
1855            WRAP=""
1856            WRAP32=""
1857         fi
1858     ;;
1859   *)
1860     AC_MSG_RESULT(no)
1861     ;;
1862   esac ],
1863   AC_MSG_RESULT(no)
1866 #################################################
1867 # check for the AFS filesystem
1868 AC_MSG_CHECKING(whether to use AFS)
1869 AC_ARG_WITH(afs,
1870 [  --with-afs              Include AFS support (default=no)],
1871 [ case "$withval" in
1872   yes)
1873     AC_MSG_RESULT(yes)
1874     AC_DEFINE(WITH_AFS)
1875     ;;
1876   *)
1877     AC_MSG_RESULT(no)
1878     ;;
1879   esac ],
1880   AC_MSG_RESULT(no)
1884 #################################################
1885 # check for the DFS auth system
1886 AC_MSG_CHECKING(whether to use DCE/DFS auth)
1887 AC_ARG_WITH(dfs,
1888 [  --with-dce-dfs          Include DCE/DFS support (default=no)],
1889 [ case "$withval" in
1890   yes)
1891     AC_MSG_RESULT(yes)
1892     AC_DEFINE(WITH_DFS)
1893     ;;
1894   *)
1895     AC_MSG_RESULT(no)
1896     ;;
1897   esac ],
1898   AC_MSG_RESULT(no)
1901 #################################################
1902 # check for Kerberos IV auth system
1903 AC_MSG_CHECKING(whether to use Kerberos IV)
1904 AC_ARG_WITH(krb4,
1905 [  --with-krb4=base-dir    Include Kerberos IV support (default=no)],
1906 [ case "$withval" in
1907   yes)
1908     AC_MSG_RESULT(yes)
1909     AC_DEFINE(KRB4_AUTH)
1910     AC_CHECK_LIB(resolv, dn_expand)
1911     LIBS="$LIBS -lkrb -ldes"
1912     CFLAGS="$CFLAGS -I$withval/include"
1913     LDFLAGS="$LDFLAGS -L$withval/lib"
1914     ;;
1915   *)
1916     AC_MSG_RESULT(no)
1917     ;;
1918   esac ],
1919   AC_MSG_RESULT(no)
1922 #################################################
1923 # check for Kerberos 5 auth system
1924 AC_MSG_CHECKING(whether to use Kerberos 5)
1925 AC_ARG_WITH(krb5,
1926 [  --with-krb5=base-dir    Include Kerberos 5 support (default=no)],
1927 [ case "$withval" in
1928   yes)
1929     AC_MSG_RESULT(yes)
1930     AC_DEFINE(KRB5_AUTH)
1931     LIBS="$LIBS -ldes425 -lkrb5 -lcrypto -lcom_err"
1932     CFLAGS="$CFLAGS -I$withval/include"
1933     LDFLAGS="$LDFLAGS -L$withval/lib"
1934     ;;
1935   *)
1936     AC_MSG_RESULT(no)
1937     ;;
1938   esac ],
1939   AC_MSG_RESULT(no)
1942 #################################################
1943 # check for automount support
1944 AC_MSG_CHECKING(whether to use AUTOMOUNT)
1945 AC_ARG_WITH(automount,
1946 [  --with-automount        Include AUTOMOUNT support (default=no)],
1947 [ case "$withval" in
1948   yes)
1949     AC_MSG_RESULT(yes)
1950     AC_DEFINE(WITH_AUTOMOUNT)
1951     ;;
1952   *)
1953     AC_MSG_RESULT(no)
1954     ;;
1955   esac ],
1956   AC_MSG_RESULT(no)
1959 #################################################
1960 # check for smbmount support
1961 AC_MSG_CHECKING(whether to use SMBMOUNT)
1962 AC_ARG_WITH(smbmount,
1963 [  --with-smbmount         Include SMBMOUNT (Linux only) support (default=no)],
1964 [ case "$withval" in
1965   yes)
1966         case "$host_os" in
1967         *linux*)
1968                 AC_MSG_RESULT(yes)
1969                 AC_DEFINE(WITH_SMBMOUNT)
1970                 MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
1971                 ;;
1972         *)
1973                 AC_MSG_ERROR(not on a linux system!)
1974                 ;;
1975         esac
1976     ;;
1977   *)
1978     AC_MSG_RESULT(no)
1979     MPROGS=
1980     ;;
1981   esac ],
1982   AC_MSG_RESULT(no)
1983   MPROGS=
1987 #################################################
1988 # check for a PAM password database
1989 with_pam_for_crypt=no
1990 AC_MSG_CHECKING(whether to use PAM password database)
1991 AC_ARG_WITH(pam,
1992 [  --with-pam              Include PAM password database support (default=no)],
1993 [ case "$withval" in
1994   yes)
1995     AC_MSG_RESULT(yes)
1996     AC_DEFINE(WITH_PAM)
1997     LIBS="$LIBS -lpam"
1998     with_pam_for_crypt=yes
1999     ;;
2000   *)
2001     AC_MSG_RESULT(no)
2002     ;;
2003   esac ],
2004   AC_MSG_RESULT(no)
2007 # we can't build a pam module if we don't have pam.
2008 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM)])
2010 #################################################
2011 # check for pam_smbpass support
2012 AC_MSG_CHECKING(whether to use pam_smbpass)
2013 AC_ARG_WITH(pam_smbpass,
2014 [  --with-pam_smbpass      Include the smbpass PAM module (default=no)],
2015 [ case "$withval" in
2016   yes)
2017     AC_MSG_RESULT(yes)
2019 # Conditions under which pam_smbpass should not be built.
2021        if test x$PICFLAG = x; then
2022           AC_MSG_RESULT([No support for PIC code - disabling pam_smbpass])
2023           PAM_MOD=""
2024        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
2025           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
2026           PAM_MOD=""
2027        else
2028           AC_DEFINE(WITH_PAM_SMBPASS)
2029           PAM_MOD="bin/pam_smbpass.so"
2030        fi
2031     ;;
2032   *)
2033     AC_MSG_RESULT(no)
2034     ;;
2035   esac ],
2036   AC_MSG_RESULT(no)
2040 ###############################################
2041 # test for where we get crypt() from, but only
2042 # if not using PAM
2043 if test $with_pam_for_crypt = no; then
2044 AC_CHECK_FUNCS(crypt)
2045 if test x"$ac_cv_func_crypt" = x"no"; then
2046     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
2047         AC_DEFINE(HAVE_CRYPT)])
2052 ## moved after the check for -lcrypt in order to
2053 ## ensure that the necessary libraries are included
2054 ## check checking for truncated salt.  Wrapped by the
2055 ## $with_pam_for_crypt variable as above   --jerry
2057 if test $with_pam_for_crypt = no; then
2058 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
2059 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
2060         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
2061 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
2062         AC_DEFINE(HAVE_TRUNCATED_SALT)
2067 ########################################################################################
2069 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
2071 ########################################################################################
2073 ## set the with_smbpasswd_sam as the default
2074 with_smbpasswd_sam=yes
2078 #################################################
2079 # check for a TDB password database
2080 AC_MSG_CHECKING(whether to use TDB SAM database)
2081 AC_ARG_WITH(tdbsam,
2082 [  --with-tdbsam           Include experimental TDB SAM support (default=no)],
2083 [ case "$withval" in
2084   yes)
2085     AC_MSG_RESULT(yes)
2086     AC_DEFINE(WITH_TDB_SAM)
2087     with_smbpasswd_sam=no
2088     ;;
2089   *)
2090     AC_MSG_RESULT(no)
2091     ;;
2092   esac ],
2093   AC_MSG_RESULT(no)
2096 #################################################
2097 # check for a LDAP password database
2098 AC_MSG_CHECKING(whether to use LDAP SAM database)
2099 AC_ARG_WITH(ldapsam,
2100 [  --with-ldapsam          Include experimental LDAP SAM support (default=no)],
2101 [ case "$withval" in
2102   yes)
2103     AC_MSG_RESULT(yes)
2104     AC_DEFINE(WITH_LDAP_SAM)
2105     LDAPLIBS="-lldap"
2106     AC_CHECK_LIB(lber, ber_bvfree, [LDAPLIBS="$LDAPLIBS -llber"])
2107     ## remove -lresolv as this should be included by the -lsasl dependency 
2108     ## in the OpenLDAP clients.  By not requiring it specifically, we avoid
2109     ## issues on platforms that don't have it
2110     LDAPLIBS="$LDAPLIBS"
2111     old_LDFLAGS="$LDFLAGS"
2112     LDFLAGS="$LDFLAGS $LDAPLIBS"
2113     AC_CHECK_FUNCS(ldap_start_tls_s)
2114     LDFLAGS="$old_LDFLAGS"
2115     with_smbpasswd_sam=no
2116     AC_SUBST(LDAPLIBS)
2117     ;;
2118   *)
2119     AC_MSG_RESULT(no)
2120     ;;
2121   esac ],
2122   AC_MSG_RESULT(no)
2125 #################################################
2126 # check for a NISPLUS password database
2127 AC_MSG_CHECKING(whether to use NISPLUS SAM database)
2128 AC_ARG_WITH(nisplussam,
2129 [  --with-nisplussam       Include NISPLUS SAM support (default=no)],
2130 [ case "$withval" in
2131   yes)
2132     AC_MSG_RESULT(yes)
2133     AC_DEFINE(WITH_NISPLUS_SAM)
2134     with_smbpasswd_sam=no
2135     ;;
2136   *)
2137     AC_MSG_RESULT(no)
2138     ;;
2139   esac ],
2140   AC_MSG_RESULT(no)
2143 ################################################
2144 # This test should come last because the
2145 # smbpasswd SAM is only used if another format
2146 # has not been defined
2147 AC_MSG_CHECKING(whether to use traditional smbpasswd file)
2148 if test $with_smbpasswd_sam = yes; then
2149         AC_MSG_RESULT(yes)
2150         AC_DEFINE(WITH_SMBPASSWD_SAM)
2151         PDBEDIT=""
2152 else
2153         AC_MSG_RESULT(no)
2154         PDBEDIT=bin/pdbedit
2157 ########################################################################################
2159 ## END OF TESTS FOR SAM BACKENDS.  
2161 ########################################################################################
2163 #################################################
2164 # check for a NISPLUS_HOME support 
2165 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
2166 AC_ARG_WITH(nisplus-home,
2167 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
2168 [ case "$withval" in
2169   yes)
2170     AC_MSG_RESULT(yes)
2171     AC_DEFINE(WITH_NISPLUS_HOME)
2172     ;;
2173   *)
2174     AC_MSG_RESULT(no)
2175     ;;
2176   esac ],
2177   AC_MSG_RESULT(no)
2180 #################################################
2181 # check for the secure socket layer
2182 AC_MSG_CHECKING(whether to use SSL)
2183 AC_ARG_WITH(ssl,
2184 [  --with-ssl              Include SSL support (default=no)
2185   --with-sslinc=DIR          Where the SSL includes are (defaults to /usr/local/ssl/include)
2186   --with-ssllib=DIR          Where the SSL libraries are (defaults to /usr/local/ssl/lib)],
2187 [ case "$withval" in
2188   yes)
2189     AC_MSG_RESULT(yes)
2190     AC_DEFINE(WITH_SSL)
2191     withval="/usr/local/ssl"     # default
2193     if test "${with_sslinc+set}" = set; then
2195         withval="$with_sslinc"
2196         case "$withval" in
2197         yes|no)
2198           echo "configure: warning: --with-sslinc called without argument - will use default" 1>&w
2199           CFLAGS="-I/usr/local/ssl/include $CFLAGS"
2200         ;;
2201         * )
2202           CFLAGS="-I${withval} $CFLAGS"
2203         ;;
2204         esac
2206     else
2208         CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
2210     fi
2212     if test "${with_ssllib+set}" = set; then
2214         withval="$with_ssllib"
2215         case "$withval" in
2216         yes|no)
2217           echo "configure: warning: --with-ssllib called without argument - will use default" 1>&w
2218           LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2219         ;;
2220         * )
2221           LDFLAGS="-L${withval}/lib $LDFLAGS"
2222         ;;
2223         esac
2225     else
2227         LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2229     fi
2231     LIBS="-lssl -lcrypto $LIBS"
2233 #    if test ! -d ${withval}; then
2234 #      echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
2235 #      exit 1
2236 #    fi 
2238     CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
2240     ;;
2241   *)
2242     AC_MSG_RESULT(no)
2243     ;;
2244   esac ],
2245   AC_MSG_RESULT(no)
2248 #################################################
2249 # check for syslog logging
2250 AC_MSG_CHECKING(whether to use syslog logging)
2251 AC_ARG_WITH(syslog,
2252 [  --with-syslog           Include experimental SYSLOG support (default=no)],
2253 [ case "$withval" in
2254   yes)
2255     AC_MSG_RESULT(yes)
2256     AC_DEFINE(WITH_SYSLOG)
2257     ;;
2258   *)
2259     AC_MSG_RESULT(no)
2260     ;;
2261   esac ],
2262   AC_MSG_RESULT(no)
2265 #################################################
2266 # check for a shared memory profiling support
2267 AC_MSG_CHECKING(whether to use profiling)
2268 AC_ARG_WITH(profiling-data,
2269 [  --with-profiling-data   Include gathering source code profile information (default=no)],
2270 [ case "$withval" in
2271   yes)
2272     AC_MSG_RESULT(yes)
2273     AC_DEFINE(WITH_PROFILE)
2274     ;;
2275   *)
2276     AC_MSG_RESULT(no)
2277     ;;
2278   esac ],
2279   AC_MSG_RESULT(no)
2283 #################################################
2284 # check for experimental disk-quotas support
2285 QUOTAOBJS=smbd/noquotas.o
2287 AC_MSG_CHECKING(whether to support disk-quotas)
2288 AC_ARG_WITH(quotas,
2289 [  --with-quotas           Include experimental disk-quota support (default=no)],
2290 [ case "$withval" in
2291   yes)
2292     AC_MSG_RESULT(yes)
2293     QUOTAOBJS=smbd/quotas.o
2294     ;;
2295   *)
2296     AC_MSG_RESULT(no)
2297     ;;
2298   esac ],
2299   AC_MSG_RESULT(no)
2301 AC_SUBST(QUOTAOBJS)
2303 #################################################
2304 # check for experimental utmp accounting
2306 AC_MSG_CHECKING(whether to support utmp accounting)
2307 AC_ARG_WITH(utmp,
2308 [  --with-utmp             Include experimental utmp accounting (default=no)],
2309 [ case "$withval" in
2310   yes)
2311     AC_MSG_RESULT(yes)
2312     AC_DEFINE(WITH_UTMP)
2313     ;;
2314   *)
2315     AC_MSG_RESULT(no)
2316     ;;
2317   esac ],
2318   AC_MSG_RESULT(no)
2321 #################################################
2322 # check for MS Dfs support
2324 AC_MSG_CHECKING(whether to support Microsoft Dfs)
2325 AC_ARG_WITH(msdfs,
2326 [  --with-msdfs            Include MS Dfs support (default=no)],
2327 [ case "$withval" in
2328   yes)
2329      AC_MSG_RESULT(yes)
2330      AC_DEFINE(WITH_MSDFS)
2331      ;;
2332   *)
2333     AC_MSG_RESULT(no)
2334     ;;
2335   esac ],
2336   AC_MSG_RESULT(no)
2339 #################################################
2340 # should we build libsmbclient?
2342 LIBSMBCLIENT_SHARED=
2343 LIBSMBCLIENT=
2344 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
2345 AC_ARG_WITH(libsmbclient,
2346 [  --with-libsmbclient     Build the libsmbclient shared library (default=no)],
2347 [ case "$withval" in
2348   yes)
2349      if test $BLDSHARED = true; then
2350         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
2351         LIBSMBCLIENT=libsmbclient
2352         AC_MSG_RESULT(yes)
2353      else
2354         AC_MSG_RESULT(no shared library support)
2355      fi
2356      ;;
2357   *)
2358     AC_MSG_RESULT(no)
2359     ;;
2360   esac ],
2361   AC_MSG_RESULT(no)
2364 #################################################
2365 # these tests are taken from the GNU fileutils package
2366 AC_CHECKING(how to get filesystem space usage)
2367 space=no
2369 # Test for statvfs64.
2370 if test $space = no; then
2371   # SVR4
2372   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
2373   [AC_TRY_RUN([
2374 #if defined(HAVE_UNISTD_H)
2375 #include <unistd.h>
2376 #endif
2377 #include <sys/types.h>
2378 #include <sys/statvfs.h>
2379   main ()
2380   {
2381     struct statvfs64 fsd;
2382     exit (statvfs64 (".", &fsd));
2383   }],
2384   fu_cv_sys_stat_statvfs64=yes,
2385   fu_cv_sys_stat_statvfs64=no,
2386   fu_cv_sys_stat_statvfs64=cross)])
2387   if test $fu_cv_sys_stat_statvfs64 = yes; then
2388     space=yes
2389     AC_DEFINE(STAT_STATVFS64)
2390   fi
2393 # Perform only the link test since it seems there are no variants of the
2394 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
2395 # because that got a false positive on SCO OSR5.  Adding the declaration
2396 # of a `struct statvfs' causes this test to fail (as it should) on such
2397 # systems.  That system is reported to work fine with STAT_STATFS4 which
2398 # is what it gets when this test fails.
2399 if test $space = no; then
2400   # SVR4
2401   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
2402                  [AC_TRY_LINK([#include <sys/types.h>
2403 #include <sys/statvfs.h>],
2404                               [struct statvfs fsd; statvfs (0, &fsd);],
2405                               fu_cv_sys_stat_statvfs=yes,
2406                               fu_cv_sys_stat_statvfs=no)])
2407   if test $fu_cv_sys_stat_statvfs = yes; then
2408     space=yes
2409     AC_DEFINE(STAT_STATVFS)
2410   fi
2413 if test $space = no; then
2414   # DEC Alpha running OSF/1
2415   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
2416   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
2417   [AC_TRY_RUN([
2418 #include <sys/param.h>
2419 #include <sys/types.h>
2420 #include <sys/mount.h>
2421   main ()
2422   {
2423     struct statfs fsd;
2424     fsd.f_fsize = 0;
2425     exit (statfs (".", &fsd, sizeof (struct statfs)));
2426   }],
2427   fu_cv_sys_stat_statfs3_osf1=yes,
2428   fu_cv_sys_stat_statfs3_osf1=no,
2429   fu_cv_sys_stat_statfs3_osf1=no)])
2430   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
2431   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
2432     space=yes
2433     AC_DEFINE(STAT_STATFS3_OSF1)
2434   fi
2437 if test $space = no; then
2438 # AIX
2439   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
2440 member (AIX, 4.3BSD)])
2441   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
2442   [AC_TRY_RUN([
2443 #ifdef HAVE_SYS_PARAM_H
2444 #include <sys/param.h>
2445 #endif
2446 #ifdef HAVE_SYS_MOUNT_H
2447 #include <sys/mount.h>
2448 #endif
2449 #ifdef HAVE_SYS_VFS_H
2450 #include <sys/vfs.h>
2451 #endif
2452   main ()
2453   {
2454   struct statfs fsd;
2455   fsd.f_bsize = 0;
2456   exit (statfs (".", &fsd));
2457   }],
2458   fu_cv_sys_stat_statfs2_bsize=yes,
2459   fu_cv_sys_stat_statfs2_bsize=no,
2460   fu_cv_sys_stat_statfs2_bsize=no)])
2461   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
2462   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
2463     space=yes
2464     AC_DEFINE(STAT_STATFS2_BSIZE)
2465   fi
2468 if test $space = no; then
2469 # SVR3
2470   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
2471   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
2472   [AC_TRY_RUN([#include <sys/types.h>
2473 #include <sys/statfs.h>
2474   main ()
2475   {
2476   struct statfs fsd;
2477   exit (statfs (".", &fsd, sizeof fsd, 0));
2478   }],
2479     fu_cv_sys_stat_statfs4=yes,
2480     fu_cv_sys_stat_statfs4=no,
2481     fu_cv_sys_stat_statfs4=no)])
2482   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
2483   if test $fu_cv_sys_stat_statfs4 = yes; then
2484     space=yes
2485     AC_DEFINE(STAT_STATFS4)
2486   fi
2489 if test $space = no; then
2490 # 4.4BSD and NetBSD
2491   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
2492 member (4.4BSD and NetBSD)])
2493   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
2494   [AC_TRY_RUN([#include <sys/types.h>
2495 #ifdef HAVE_SYS_PARAM_H
2496 #include <sys/param.h>
2497 #endif
2498 #ifdef HAVE_SYS_MOUNT_H
2499 #include <sys/mount.h>
2500 #endif
2501   main ()
2502   {
2503   struct statfs fsd;
2504   fsd.f_fsize = 0;
2505   exit (statfs (".", &fsd));
2506   }],
2507   fu_cv_sys_stat_statfs2_fsize=yes,
2508   fu_cv_sys_stat_statfs2_fsize=no,
2509   fu_cv_sys_stat_statfs2_fsize=no)])
2510   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
2511   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
2512     space=yes
2513     AC_DEFINE(STAT_STATFS2_FSIZE)
2514   fi
2517 if test $space = no; then
2518   # Ultrix
2519   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
2520   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
2521   [AC_TRY_RUN([#include <sys/types.h>
2522 #ifdef HAVE_SYS_PARAM_H
2523 #include <sys/param.h>
2524 #endif
2525 #ifdef HAVE_SYS_MOUNT_H
2526 #include <sys/mount.h>
2527 #endif
2528 #ifdef HAVE_SYS_FS_TYPES_H
2529 #include <sys/fs_types.h>
2530 #endif
2531   main ()
2532   {
2533   struct fs_data fsd;
2534   /* Ultrix's statfs returns 1 for success,
2535      0 for not mounted, -1 for failure.  */
2536   exit (statfs (".", &fsd) != 1);
2537   }],
2538   fu_cv_sys_stat_fs_data=yes,
2539   fu_cv_sys_stat_fs_data=no,
2540   fu_cv_sys_stat_fs_data=no)])
2541   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2542   if test $fu_cv_sys_stat_fs_data = yes; then
2543     space=yes
2544     AC_DEFINE(STAT_STATFS2_FS_DATA)
2545   fi
2549 # As a gating factor for large file support, in order to
2550 # use <4GB files we must have the following minimal support
2551 # available.
2552 # long long, and a 64 bit off_t or off64_t.
2553 # If we don't have all of these then disable large
2554 # file support.
2556 AC_MSG_CHECKING(if large file support can be enabled)
2557 AC_TRY_COMPILE([
2558 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2559 #include <sys/types.h>
2560 #else
2561 __COMPILE_ERROR_
2562 #endif
2564 [int i],
2565 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2566 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2567     AC_MSG_RESULT(yes)
2568     AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
2569 else
2570     AC_MSG_RESULT(no)
2573 AC_ARG_WITH(spinlocks, 
2574 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no)])
2575 if test "x$with_spinlocks" = "xyes"; then
2576     AC_DEFINE(USE_SPINLOCKS)
2578     case "$host_cpu" in
2579         sparc)
2580             AC_DEFINE(SPARC_SPINLOCKS)
2581             ;;
2583         i386|i486|i586|i686)
2584             AC_DEFINE(INTEL_SPINLOCKS)
2585             ;;
2587         mips)
2588             AC_DEFINE(MIPS_SPINLOCKS)
2589             ;;
2591         powerpc)
2592             AC_DEFINE(POWERPC_SPINLOCKS)
2593             ;;
2594     esac
2597 #################################################
2598 # check for ACL support
2600 AC_MSG_CHECKING(whether to support ACLs)
2601 AC_ARG_WITH(acl-support,
2602 [  --with-acl-support      Include ACL support (default=no)],
2603 [ case "$withval" in
2604   yes)
2606                 case "$host_os" in
2607                 *sysv5*)
2608                         AC_MSG_RESULT(Using UnixWare ACLs)
2609                         AC_DEFINE(HAVE_UNIXWARE_ACLS)
2610                         ;;
2611                 *solaris*)
2612                         AC_MSG_RESULT(Using solaris ACLs)
2613                         AC_DEFINE(HAVE_SOLARIS_ACLS)
2614                         ;;
2615                 *hpux*)
2616                         AC_MSG_RESULT(Using HPUX ACLs)
2617                         AC_DEFINE(HAVE_HPUX_ACLS)
2618                         ;;
2619                 *irix*)
2620                         AC_MSG_RESULT(Using IRIX ACLs)
2621                         AC_DEFINE(HAVE_IRIX_ACLS)
2622                         ;;
2623                 *aix*)
2624                         AC_MSG_RESULT(Using AIX ACLs)
2625                         AC_DEFINE(HAVE_AIX_ACLS)
2626                         ;;
2627                 *osf*)
2628                         AC_MSG_RESULT(Using Tru64 ACLs)
2629                         AC_DEFINE(HAVE_TRU64_ACLS)
2630                         LIBS="$LIBS -lpacl"
2631                         ;;
2632                 *)
2633                     AC_CHECK_LIB(acl,acl_get_file)
2634                         AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
2635                         AC_TRY_LINK([#include <sys/types.h>
2636 #include <sys/acl.h>],
2637 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
2638 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
2639                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
2640                             AC_MSG_RESULT(Using posix ACLs)
2641                             AC_DEFINE(HAVE_POSIX_ACLS)
2642                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
2643                                 AC_TRY_LINK([#include <sys/types.h>
2644 #include <sys/acl.h>],
2645 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
2646 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
2647                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
2648                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP)
2649                                 fi
2650                         fi
2651                         ;;
2652                 esac
2653                 ;;
2654   *)
2655     AC_MSG_RESULT(no)
2656         AC_DEFINE(HAVE_NO_ACLS)
2657     ;;
2658   esac ],
2659   AC_DEFINE(HAVE_NO_ACLS)
2660   AC_MSG_RESULT(no)
2663 #################################################
2664 # check for the historical SAMBA installation
2666 if test "x$prefix" = xNONE -a "$sbindir" = "\${exec_prefix}/sbin"; then
2667         # Put all binaries under the /usr/local/samba/bin directory.
2668         sbindir="$bindir"
2671 #################################################
2672 # check for sendfile support
2674 AC_MSG_CHECKING(whether to check for support sendfile)
2675 AC_ARG_WITH(sendfile-support,
2676 [  --with-sendfile-support      Check for sendfile support (default=no)],
2677 [ case "$withval" in
2678   yes)
2680         AC_MSG_RESULT(yes);
2682         case "$host_os" in
2683         *linux*)
2684                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
2685                 AC_TRY_LINK([#include <sys/sendfile.h>],
2687 int tofd, fromfd;
2688 off64_t offset;
2689 size_t total;
2690 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
2692 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
2694                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
2695                 AC_TRY_LINK([#include <sys/sendfile.h>],
2697 int tofd, fromfd;
2698 off_t offset;
2699 size_t total;
2700 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
2702 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
2704 # Try and cope with broken Linux sendfile....
2705                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
2706                 AC_TRY_LINK([\
2707 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
2708 #undef _FILE_OFFSET_BITS
2709 #endif
2710 #include <sys/sendfile.h>],
2712 int tofd, fromfd;
2713 off_t offset;
2714 size_t total;
2715 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
2717 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
2719         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
2720                 AC_DEFINE(HAVE_SENDFILE64)
2721                 AC_DEFINE(LINUX_SENDFILE_API)
2722                 AC_DEFINE(WITH_SENDFILE)
2723         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
2724                 AC_DEFINE(HAVE_SENDFILE)
2725                 AC_DEFINE(LINUX_SENDFILE_API)
2726                 AC_DEFINE(WITH_SENDFILE)
2727         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
2728                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API)
2729                 AC_DEFINE(WITH_SENDFILE)
2730         else
2731                 AC_MSG_RESULT(no);
2732         fi
2734         ;;
2735         *freebsd*)
2736                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
2737                 AC_TRY_LINK([\
2738 #include <sys/types.h>
2739 #include <sys/socket.h>
2740 #include <sys/uio.h>],
2742 #define NULL (void *)0
2743         int fromfd, tofd, ret, total;
2744         off_t offset, nwritten;
2745         struct sf_hdtr {
2746                 struct iovec *headers;
2747                 int hdr_cnt;
2748                 struct iovec *trailers;
2749                 int trl_cnt;
2750         } hdr;
2751         struct iovec hdtrl;
2752         hdr.headers = &hdtrl;
2753         hdr.hdr_cnt = 1;
2754         hdr.trailers = NULL;
2755         hdr.trl_cnt = 0;
2756         hdtrl.iov_base = NULL;
2757         hdtrl.iov_len = 0;
2758         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
2760 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
2762         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
2763                 AC_DEFINE(HAVE_SENDFILE)
2764                 AC_DEFINE(FREEBSD_SENDFILE_API)
2765                 AC_DEFINE(WITH_SENDFILE)
2766         else
2767                 AC_MSG_RESULT(no);
2768         fi
2769         ;;
2771         *hpux*)
2772                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
2773                 AC_TRY_LINK([\
2774 #include <sys/socket.h>
2775 #include <sys/uio.h>],
2777         int fromfd, tofd;
2778         size_t total=0;
2779         struct iovec hdtrl[2];
2780         ssize_t nwritten;
2781         off64_t offset;
2783         hdtrl[0].iov_base = 0;
2784         hdtrl[0].iov_len = 0;
2786         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
2788 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
2789         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
2790                 AC_DEFINE(HAVE_SENDFILE64)
2791                 AC_DEFINE(HPUX_SENDFILE_API)
2792                 AC_DEFINE(WITH_SENDFILE)
2793         else
2794                 AC_MSG_RESULT(no);
2795         fi
2797                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
2798                 AC_TRY_LINK([\
2799 #include <sys/socket.h>
2800 #include <sys/uio.h>],
2802         int fromfd, tofd;
2803         size_t total=0;
2804         struct iovec hdtrl[2];
2805         ssize_t nwritten;
2806         off_t offset;
2808         hdtrl[0].iov_base = 0;
2809         hdtrl[0].iov_len = 0;
2811         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
2813 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
2814         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
2815                 AC_DEFINE(HAVE_SENDFILE)
2816                 AC_DEFINE(HPUX_SENDFILE_API)
2817                 AC_DEFINE(WITH_SENDFILE)
2818         else
2819                 AC_MSG_RESULT(no);
2820         fi
2821         ;;
2823         *solaris*)
2824                 LIBS="$LIBS -lsendfile"
2825                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
2826                 AC_TRY_LINK([\
2827 #include <sys/sendfile.h>],
2829         int sfvcnt;
2830         size_t xferred;
2831         struct sendfilevec vec[2];
2832         ssize_t nwritten;
2833         int tofd;
2835         sfvcnt = 2;
2837         vec[0].sfv_fd = SFV_FD_SELF;
2838         vec[0].sfv_flag = 0;
2839         vec[0].sfv_off = 0;
2840         vec[0].sfv_len = 0;
2842         vec[1].sfv_fd = 0;
2843         vec[1].sfv_flag = 0;
2844         vec[1].sfv_off = 0;
2845         vec[1].sfv_len = 0;
2846         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
2848 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
2850         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
2851                 AC_DEFINE(HAVE_SENDFILEV64)
2852                 AC_DEFINE(SOLARIS_SENDFILE_API)
2853                 AC_DEFINE(WITH_SENDFILE)
2854         else
2855                 AC_MSG_RESULT(no);
2856         fi
2858                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
2859                 AC_TRY_LINK([\
2860 #include <sys/sendfile.h>],
2862         int sfvcnt;
2863         size_t xferred;
2864         struct sendfilevec vec[2];
2865         ssize_t nwritten;
2866         int tofd;
2868         sfvcnt = 2;
2870         vec[0].sfv_fd = SFV_FD_SELF;
2871         vec[0].sfv_flag = 0;
2872         vec[0].sfv_off = 0;
2873         vec[0].sfv_len = 0;
2875         vec[1].sfv_fd = 0;
2876         vec[1].sfv_flag = 0;
2877         vec[1].sfv_off = 0;
2878         vec[1].sfv_len = 0;
2879         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
2881 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
2883         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
2884                 AC_DEFINE(HAVE_SENDFILEV)
2885                 AC_DEFINE(SOLARIS_SENDFILE_API)
2886                 AC_DEFINE(WITH_SENDFILE)
2887         else
2888                 AC_MSG_RESULT(no);
2889         fi
2890         ;;
2892         *)
2893         ;;
2894         esac
2895         ;;
2896   *)
2897     AC_MSG_RESULT(no)
2898     ;;
2899   esac ],
2900   AC_MSG_RESULT(no)
2903 #################################################
2904 # Check whether winbind is supported on this platform.  If so we need to
2905 # build and install client programs (WINBIND_TARGETS), sbin programs
2906 # (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
2908 AC_MSG_CHECKING(whether to build winbind)
2910 # Initially, the value of $host_os decides whether winbind is supported
2912 case "$host_os" in 
2913         *linux*|*irix*)
2914                 HAVE_WINBIND=yes
2915                 ;;
2916         *solaris*)
2917                 HAVE_WINBIND=yes
2918                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
2919                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
2920                 ;;
2921         *hpux11*)
2922                 HAVE_WINBIND=yes
2923                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
2924                ;;
2925         *aix4*)
2926                 HAVE_WINBIND=yes
2927                 ;;
2928         *)
2929                 HAVE_WINBIND=no
2930                 winbind_no_reason=", unsupported on $host_os"
2931                 ;;
2932 esac
2934 # Check the setting of --with-winbindd
2936 AC_ARG_WITH(winbind,
2937 [  --with-winbind          Build winbind (default, if supported by OS)],
2939   case "$withval" in
2940         yes)
2941                 HAVE_WINBIND=yes
2942                 ;;
2943         no)
2944                 HAVE_WINBIND=no
2945                 winbind_reason=""
2946                 ;;
2947   esac ],
2950 # We need unix domain sockets for winbind
2952 if test x"$HAVE_WINBIND" = x"yes"; then
2953         if test x"$samba_cv_unixsocket" = x"no"; then
2954                 winbind_no_reason=", no unix domain socket support on $host_os"
2955                 HAVE_WINBIND=no
2956         fi
2959 # Display test results
2961 if test x"$HAVE_WINBIND" = x"yes"; then
2963         AC_MSG_RESULT(yes)
2965         AC_MSG_CHECKING(whether to enable winbind auth challenge/response code)
2966         AC_ARG_WITH(winbind-auth-challenge,
2967         [  --with-winbind-auth-challenge   Enable winbindd_pam_auth_crap() functionality (default no)],
2968         [ 
2969           case "$withval" in
2970                 yes)
2971                         AC_DEFINE(WITH_WINBIND_AUTH_CRAP)
2972                         AC_MSG_RESULT(yes)
2973                         ;;
2974                 *)
2975                         AC_MSG_RESULT(no)
2976                         ;;
2977           esac ],
2978           AC_MSG_RESULT(no)
2979         )
2981 # Check for FreeBSD problem with getgroups
2983         WINBIND_TARGETS="bin/wbinfo"
2984         WINBIND_STARGETS="bin/winbindd"
2985         case "$host_os" in
2986         *irix*)
2987                 WINBIND_LTARGETS="nsswitch/libns_winbind.so"
2988                 ;;
2989         *)
2990                 WINBIND_LTARGETS="nsswitch/libnss_winbind.so"
2991                 ;;
2992         esac
2995         case "$with_pam" in
2996                 yes)
2997                         WINBIND_PAM_TARGETS="nsswitch/pam_winbind.so"
2998                 ;;
2999         esac
3001 # Check for Horrible winbindd ldap hack.
3003         AC_MSG_CHECKING(whether to enable winbind ldap hack)
3004         AC_ARG_WITH(winbind-ldap-hack,
3005         [  --with-winbind-ldap-hack   Enable winbindd_ldap_hack() functionality (default no)],
3006         [
3007           case "$withval" in
3008                 yes)
3009                         AC_DEFINE(WITH_HORRIBLE_LDAP_NATIVE_MODE_HACK)
3010                         LIBS="$LIBS -lldap";
3011                         AC_MSG_RESULT(yes)
3012                         ;;
3013                 no)
3014                         AC_MSG_RESULT(no)
3015                         ;;
3016           esac ],
3017           AC_MSG_RESULT(no)
3018         )
3020 else
3021         AC_MSG_RESULT(no$winbind_no_reason)
3023         WINBIND_TARGETS=""
3024         WINBIND_STARGETS=""
3025         WINBIND_LTARGETS=""
3026         WINBIND_PAM_TARGETS=""
3030 # Check for FreeBSD problem with getgroups
3031 # It returns EGID too many times in the list of groups
3032 # and causes a security problem
3033 AC_CACHE_CHECK([whether or not getgroups returns EGID too many times],
3034     samba_cv_have_getgroups_too_many_egids,[AC_TRY_RUN([
3035 #include <sys/types.h>
3036 #include <stdio.h>
3038 int main(int argc, char *argv[])
3040   gid_t groups[10];
3041   int n = 10;
3043   n = getgroups(n, &groups);
3044   /* Could actually pass back the number of EGIDs there ... */
3045   exit((n > 1 && groups[0] == getegid() && groups[1] == getegid()) ? 1 : 0);
3047         samba_cv_have_getgroups_too_many_egids=no,samba_cv_have_getgroups_too_many_egids=yes, samba_cv_have_getgroups_too_many_egids=cross)])
3048 if test x"$samba_cv_have_getgroups_too_many_egids" = x"yes"; then
3049     AC_DEFINE(HAVE_GETGROUPS_TOO_MANY_EGIDS)
3052 # Substitution time!
3054 AC_SUBST(WINBIND_TARGETS)
3055 AC_SUBST(WINBIND_STARGETS)
3056 AC_SUBST(WINBIND_LTARGETS)
3057 AC_SUBST(WINBIND_PAM_TARGETS)
3058 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
3059 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
3061 # Solaris has some extra fields in struct passwd that need to be
3062 # initialised otherwise nscd crashes.  Unfortunately autoconf < 2.50
3063 # doesn't have the AC_CHECK_MEMBER macro which would be handy for checking
3064 # this.
3066 #AC_CHECK_MEMBER(struct passwd.pw_comment,
3067 #               AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),
3068 #               [#include <pwd.h>])
3070 AC_CACHE_CHECK([whether struct passwd has pw_comment],samba_cv_passwd_pw_comment, [
3071         AC_TRY_COMPILE([#include <pwd.h>],[struct passwd p; p.pw_comment;],
3072         samba_cv_passwd_pw_comment=yes,samba_cv_passwd_pw_comment=no)])
3073 if test x"$samba_cv_passwd_pw_comment" = x"yes"; then
3074         AC_DEFINE(HAVE_PASSWD_PW_COMMENT)
3077 #AC_CHECK_MEMBER(struct passwd.pw_age,
3078 #               AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),
3079 #               [#include <pwd.h>])
3081 AC_CACHE_CHECK([whether struct passwd has pw_age],samba_cv_passwd_pw_age, [
3082         AC_TRY_COMPILE([#include <pwd.h>],[struct passwd p; p.pw_age;],
3083         samba_cv_passwd_pw_age=yes,samba_cv_passwd_pw_age=no)])
3084 if test x"$samba_cv_passwd_pw_age" = x"yes"; then
3085         AC_DEFINE(HAVE_PASSWD_PW_AGE)
3088 #################################################
3089 # Check to see if we should use the included popt
3091 AC_ARG_WITH(included-popt,
3092 [  --with-included-popt    use bundled popt library, not from system],
3094   case "$withval" in
3095         yes)
3096                 INCLUDED_POPT=yes
3097                 ;;
3098         no)
3099                 INCLUDED_POPT=no
3100                 ;;
3101   esac ],
3103 if test x"$INCLUDED_POPT" != x"yes"; then
3104     AC_CHECK_LIB(popt, poptGetContext,
3105                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
3108 AC_MSG_CHECKING(whether to use included popt)
3109 if test x"$INCLUDED_POPT" = x"yes"; then
3110     AC_MSG_RESULT($srcdir/popt)
3111     BUILD_POPT='$(POPT_OBJS)'
3112     FLAGS1="-I$srcdir/popt"
3113 else
3114     AC_MSG_RESULT(no)
3115     LIBS="$LIBS -lpopt"
3117 AC_SUBST(BUILD_POPT)
3118 AC_SUBST(FLAGS1)
3120 #################################################
3121 # final configure stuff
3122 AC_MSG_CHECKING([configure summary])
3123 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
3124         AC_MSG_RESULT(yes),
3125         AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
3126         AC_MSG_WARN([cannot run when cross-compiling]))
3128 builddir=`pwd`
3129 AC_SUBST(builddir)
3131 AC_OUTPUT(include/stamp-h Makefile script/findsmb)