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