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