r3538: Fix the build with the latest Heimdal code.
[ira/wip.git] / source3 / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl We must use autotools 2.53 or above
4 AC_PREREQ(2.53)
5 AC_INIT(include/includes.h)
6 AC_CONFIG_HEADER(include/config.h)
7
8 AC_DISABLE_STATIC
9 AC_ENABLE_SHARED
10
11 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
12 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
13
14 SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
15 if test -n "${SAMBA_VERSION_SVN_REVISION}";then
16         echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
17 fi
18
19 #################################################
20 # Directory handling stuff to support both the
21 # legacy SAMBA directories and FHS compliant
22 # ones...
23 AC_PREFIX_DEFAULT(/usr/local/samba)
24
25 lockdir="\${VARDIR}/locks"
26 piddir="\${VARDIR}/locks"
27 mandir="\${prefix}/man"
28 logfilebase="\${VARDIR}"
29 privatedir="\${prefix}/private"
30 libdir="\${prefix}/lib"
31 configdir="\${LIBDIR}"
32 swatdir="\${prefix}/swat"
33
34 AC_ARG_WITH(fhs, 
35 [  --with-fhs              Use FHS-compliant paths (default=no)],
36 [ case "$withval" in
37   yes)
38     lockdir="\${VARDIR}/lib/samba"
39     piddir="\${VARDIR}/run"
40     mandir="\${prefix}/share/man"
41     logfilebase="\${VARDIR}/log/samba"
42     privatedir="\${CONFIGDIR}/private"
43     libdir="\${prefix}/lib/samba"
44     configdir="${sysconfdir}/samba"
45     swatdir="\${DATADIR}/samba/swat"
46     ;;
47   esac])
48
49 #################################################
50 # set private directory location
51 AC_ARG_WITH(privatedir,
52 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
53 [ case "$withval" in
54   yes|no)
55   #
56   # Just in case anybody calls it without argument
57   #
58     AC_MSG_WARN([--with-privatedir called without argument - will use default])
59   ;;
60   * )
61     privatedir="$withval"
62     ;;
63   esac])
64
65 #################################################
66 # set lock directory location
67 AC_ARG_WITH(lockdir,
68 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
69 [ case "$withval" in
70   yes|no)
71   #
72   # Just in case anybody calls it without argument
73   #
74     AC_MSG_WARN([--with-lockdir called without argument - will use default])
75   ;;
76   * )
77     lockdir="$withval"
78     ;;
79   esac])
80
81 #################################################
82 # set pid directory location
83 AC_ARG_WITH(piddir,
84 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
85 [ case "$withval" in
86   yes|no)
87   #
88   # Just in case anybody calls it without argument
89   #
90     AC_MSG_WARN([--with-piddir called without argument - will use default])
91   ;;
92   * )
93     piddir="$withval"
94     ;;
95   esac])
96
97 #################################################
98 # set SWAT directory location
99 AC_ARG_WITH(swatdir,
100 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
101 [ case "$withval" in
102   yes|no)
103   #
104   # Just in case anybody does it
105   #
106     AC_MSG_WARN([--with-swatdir called without argument - will use default])
107   ;;
108   * )
109     swatdir="$withval"
110     ;;
111   esac])
112
113 #################################################
114 # set configuration directory location
115 AC_ARG_WITH(configdir,
116 [  --with-configdir=DIR    Where to put configuration files ($libdir)],
117 [ case "$withval" in
118   yes|no)
119   #
120   # Just in case anybody does it
121   #
122     AC_MSG_WARN([--with-configdir called without argument - will use default])
123   ;;
124   * )
125     configdir="$withval"
126     ;;
127   esac])
128
129 #################################################
130 # set log directory location
131 AC_ARG_WITH(logfilebase,
132 [  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
133 [ case "$withval" in
134   yes|no)
135   #
136   # Just in case anybody does it
137   #
138     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
139   ;;
140   * )
141     logfilebase="$withval"
142     ;;
143   esac])
144
145 #################################################
146 # set lib directory location
147 AC_ARG_WITH(libdir,
148 [  --with-libdir=DIR       Where to put libdir ($libdir)],
149 [ case "$withval" in
150   yes|no)
151   #
152   # Just in case anybody does it
153   #
154     AC_MSG_WARN([--with-libdir without argument - will use default])
155   ;;
156   * )
157     libdir="$withval"
158     ;;
159   esac])
160
161 #################################################
162 # set lib directory location
163 AC_ARG_WITH(mandir,
164 [  --with-mandir=DIR       Where to put man pages ($mandir)],
165 [ case "$withval" in
166   yes|no)
167   #
168   # Just in case anybody does it
169   #
170     AC_MSG_WARN([--with-mandir without argument - will use default])
171   ;;
172   * )
173     mandir="$withval"
174     ;;
175   esac])
176
177 AC_ARG_WITH(cfenc,
178 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
179                           for optimization (Mac OS X/Darwin only)],
180 [
181 # May be in source $withval/CoreFoundation/StringEncodings.subproj.
182 # Should have been in framework $withval/CoreFoundation.framework/Headers.
183 for d in \
184     $withval/CoreFoundation/StringEncodings.subproj \
185     $withval/StringEncodings.subproj \
186     $withval/CoreFoundation.framework/Headers \
187     $withval/Headers \
188     $withval
189 do
190     if test -r $d/CFStringEncodingConverter.h; then
191         ln -sfh $d include/CoreFoundation
192     fi
193 done
194 ])
195
196 AC_SUBST(configdir)
197 AC_SUBST(lockdir)
198 AC_SUBST(piddir)
199 AC_SUBST(logfilebase)
200 AC_SUBST(privatedir)
201 AC_SUBST(swatdir)
202 AC_SUBST(bindir)
203 AC_SUBST(sbindir)
204
205 dnl Unique-to-Samba variables we'll be playing with.
206 AC_SUBST(SHELL)
207 AC_SUBST(LDSHFLAGS)
208 AC_SUBST(SONAMEFLAG)
209 AC_SUBST(SHLD)
210 AC_SUBST(HOST_OS)
211 AC_SUBST(PICFLAGS)
212 AC_SUBST(PICSUFFIX)
213 AC_SUBST(SHLIBEXT)
214 AC_SUBST(INSTALLCLIENT)
215 AC_SUBST(INSTALLCLIENTCMD_SH)
216 AC_SUBST(INSTALLCLIENTCMD_A)
217 AC_SUBST(LIBSMBCLIENT_SHARED)
218 AC_SUBST(LIBSMBCLIENT)
219 AC_SUBST(PRINT_LIBS)
220 AC_SUBST(AUTH_LIBS)
221 AC_SUBST(ACL_LIBS)
222 AC_SUBST(PASSDB_LIBS)
223 AC_SUBST(IDMAP_LIBS)
224 AC_SUBST(KRB5_LIBS)
225 AC_SUBST(LDAP_LIBS)
226 AC_SUBST(SHLIB_PROGS)
227 AC_SUBST(SMBWRAPPER)
228 AC_SUBST(EXTRA_BIN_PROGS)
229 AC_SUBST(EXTRA_SBIN_PROGS)
230 AC_SUBST(EXTRA_ALL_TARGETS)
231
232 AC_ARG_ENABLE(debug, 
233 [  --enable-debug          Turn on compiler debugging information (default=no)],
234     [if eval "test x$enable_debug = xyes"; then
235         CFLAGS="${CFLAGS} -g"
236     fi])
237
238 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
239     [if eval "test x$enable_developer = xyes"; then
240         developer=yes
241         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
242     fi])
243
244 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
245     [if eval "test x$enable_krb5developer = xyes"; then
246         developer=yes
247         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
248     fi])
249
250 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
251
252 if test "x$enable_dmalloc" = xyes
253 then
254         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
255         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
256                   [Define to check invariants around some common functions])
257         LIBS="$LIBS -ldmalloc"  
258 fi
259
260 dnl Checks for programs.
261
262 ##
263 ## for some reason this macro resets the CFLAGS
264 ## so save and restore
265 ##
266 OLD_CFLAGS=${CFLAGS}
267 AC_PROG_CC
268 CFLAGS=${OLD_CFLAGS}
269
270 OLD_CFLAGS=${CFLAGS}
271 AC_PROG_CPP
272 CFLAGS=${OLD_CFLAGS}
273
274 AC_PROG_INSTALL
275 AC_PROG_AWK
276 AC_PATH_PROG(PERL, perl)
277
278 AC_CHECK_TOOL(AR, ar)
279
280 # compile with optimization and without debugging by default, but
281 # allow people to set their own preference.
282 if test "x$CFLAGS" = x
283 then
284   CFLAGS="-O ${CFLAGS}"
285 fi
286
287 dnl Check if we use GNU ld
288 LD=ld
289 AC_PROG_LD_GNU
290
291 dnl Certain versions of GNU ld the default is not to have the 
292 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
293 dnl warnings when building modules.
294 if test "$ac_cv_prog_gnu_ld" = "yes"; then
295         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
296         AC_MSG_CHECKING(GNU ld release date)
297         changequote(,)dnl
298         ac_cv_gnu_ld_date=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
299         changequote([,])dnl
300         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
301         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
302                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
303         fi
304 fi
305
306 dnl needed before AC_TRY_COMPILE
307 AC_ISC_POSIX
308
309 dnl look for executable suffix
310 AC_EXEEXT
311
312 dnl Check if C compiler understands -c and -o at the same time
313 AC_PROG_CC_C_O
314 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
315       BROKEN_CC=
316 else
317       BROKEN_CC=#
318 fi
319 AC_SUBST(BROKEN_CC)
320
321 dnl Check if the C compiler understands -Werror
322 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
323  AC_TRY_RUN_STRICT([
324   int main(void)
325   {
326         return 0;
327   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
328   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
329 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
330    Werror_FLAGS="-Werror"
331 else 
332 dnl Check if the C compiler understands -w2
333 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
334  AC_TRY_RUN_STRICT([
335   int main(void)
336   {
337         return 0;
338   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
339   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
340 if test x"$samba_cv_HAVE_w2" = x"yes"; then
341    Werror_FLAGS="-w2"
342 fi
343 fi
344
345 dnl Check if the C compiler understands volatile (it should, being ANSI).
346 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
347     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
348         samba_cv_volatile=yes,samba_cv_volatile=no)])
349 if test x"$samba_cv_volatile" = x"yes"; then
350    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
351 fi
352
353 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
354 AC_MSG_CHECKING(uname -s)
355 AC_MSG_RESULT(${UNAME_S})
356
357 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
358 AC_MSG_CHECKING(uname -r)
359 AC_MSG_RESULT(${UNAME_R})
360
361 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
362 AC_MSG_CHECKING(uname -m)
363 AC_MSG_RESULT(${UNAME_M})
364
365 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
366 AC_MSG_CHECKING(uname -p)
367 AC_MSG_RESULT(${UNAME_P})
368
369 AC_CANONICAL_SYSTEM
370
371 dnl Add #include for broken IRIX header files
372   case "$host_os" in
373         *irix6*) AC_ADD_INCLUDE(<standards.h>)
374         ;;
375 esac
376
377 AC_VALIDATE_CACHE_SYSTEM_TYPE
378
379 DYNEXP=
380
381 dnl Add modules that have to be built by default here
382 dnl These have to be built static:
383 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
384
385 dnl These are preferably build shared, and static if dlopen() is not available
386 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437"
387
388 if test "x$developer" = xyes; then
389    default_static_modules="$default_static_modules rpc_echo"
390    default_shared_modules="$default_shared_modules charset_weird"
391 fi
392
393 #
394 # Config CPPFLAG settings for strange OS's that must be set
395 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
396 # case statement; its first reference must be unconditional.
397 #
398 case "$host_os" in
399 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
400     *hpux*)
401     
402       AC_PROG_CC_FLAG(Ae)
403       # mmap on HPUX is completely broken...
404       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
405       if test $ac_cv_prog_cc_Ae = yes; then
406         CPPFLAGS="$CPPFLAGS -Ae"
407       fi
408 #
409 # Defines needed for HPUX support.
410 # HPUX has bigcrypt but (sometimes?) doesn't use it for
411 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
412 #
413       case `uname -r` in
414                         *9*|*10*)
415                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
416                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
417                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
418                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
419                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
420                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
421                                 ;;
422                         *11*)
423                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
424                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
425                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
426                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
427                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
428                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
429                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
430                                 ;;
431       esac
432       ;;
433
434 #
435 # CRAY Unicos has broken const handling
436        *unicos*)
437           AC_MSG_RESULT([disabling const])
438           CPPFLAGS="$CPPFLAGS -Dconst="
439           ;;
440         
441 #
442 # AIX4.x doesn't even admit to having large
443 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
444 #
445     *aix4*)
446           AC_MSG_RESULT([enabling large file support])
447       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
448           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
449       ;;    
450 #
451 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
452 # to the existance of large files..
453 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
454 # recommendations on large file support, however it makes the
455 # compile work using gcc 2.7 and 2.8, whereas using the Sun
456 # recommendation makes the compile fail on gcc2.7. JRA.
457 #
458 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
459 #
460         *solaris*)
461                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
462                 case `uname -r` in
463                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
464                                 AC_MSG_RESULT([no large file support])
465                                 ;;
466                         5.*)
467                         AC_MSG_RESULT([enabling large file support])
468                         if test "$ac_cv_prog_gcc" = yes; then
469                                 ${CC-cc} -v >conftest.c 2>&1
470                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
471                                 rm -fr conftest.c
472                                 case "$ac_cv_gcc_compiler_version_number" in
473                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
474                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
475                                                 LDFLAGS="$LDFLAGS -lthread"
476                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
477                                                 ;;
478                                         *)
479                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
480                                                 LDFLAGS="$LDFLAGS -lthread"
481                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
482                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
483                                                 ;;
484                                 esac
485                         else
486                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
487                                 LDFLAGS="$LDFLAGS -lthread"
488                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
489                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
490                         fi
491                         ;;
492                 esac
493                 ;;
494 #
495 # IRIX uses SYSV printing.  Make sure to set that here
496 #
497         *irix*)
498                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
499                 ;;
500         *freebsd*|*DragonFly*)
501                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
502                 ;;
503 #
504 # VOS may need to have POSIX support and System V compatibility enabled.
505 #
506     *vos*)
507     case "$CPPFLAGS" in
508           *-D_POSIX_C_SOURCE*)
509                 ;;
510           *)
511                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
512                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
513                 ;;
514     esac
515     case "$CPPFLAGS" in
516           *-D_SYSV*|*-D_SVID_SOURCE*)
517                 ;;
518           *)
519                 CPPFLAGS="$CPPFLAGS -D_SYSV"
520                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
521     esac
522     ;;
523 #
524 # Tests needed for SINIX large file support.
525 #
526     *sysv4*)
527       if test $host = mips-sni-sysv4 ; then
528         AC_MSG_CHECKING([for LFS support])
529         old_CPPFLAGS="$CPPFLAGS"
530         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
531         AC_TRY_RUN([
532 #include <unistd.h>
533 main () {
534 #if _LFS64_LARGEFILE == 1
535 exit(0);
536 #else
537 exit(1);
538 #endif
539 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
540         CPPFLAGS="$old_CPPFLAGS"
541         if test x$SINIX_LFS_SUPPORT = xyes ; then
542           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
543                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
544           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
545           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
546           LIBS="`getconf LFS64_LIBS` $LIBS"
547         fi
548       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
549       fi
550     ;;
551
552 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
553 #
554     *linux*)
555         AC_MSG_CHECKING([for LFS support])
556         old_CPPFLAGS="$CPPFLAGS"
557         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
558        AC_TRY_RUN([
559 #include <unistd.h>
560 #include <sys/utsname.h>
561 #include <string.h>
562 #include <stdlib.h>
563 main() {
564 #if _LFS64_LARGEFILE == 1
565        struct utsname uts;
566        char *release;
567        int major, minor;
568
569        /* Ensure this is glibc 2.2 or higher */
570 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
571        int libc_major = __GLIBC__;
572        int libc_minor = __GLIBC_MINOR__;
573
574        if (libc_major < 2)
575               exit(1);
576        if (libc_minor < 2)
577               exit(1);
578 #endif
579
580        /* Ensure this is kernel 2.4 or higher */
581
582        uname(&uts);
583        release = strdup(uts.release);
584        major = atoi(strsep(&release, "."));
585        minor = atoi(strsep(&release, "."));
586
587        if (major > 2 || (major == 2 && minor > 3))
588                exit(0);
589        exit(1);
590 #else
591        exit(1);
592 #endif
593 }
594 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
595         CPPFLAGS="$old_CPPFLAGS"
596         if test x$LINUX_LFS_SUPPORT = xyes ; then
597                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
598                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
599                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
600                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
601         fi
602         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
603         ;;
604
605 #
606 # MacOS X is the *only* system that uses compose character in utf8. This
607 # is so horribly broken....
608 #
609     *darwin*)
610         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
611 # Add Fink directories for various packages, like dlcompat.
612 # Note: iconv does that explicitly below, but other packages
613 # don't.
614         CPPFLAGS="$CPPFLAGS -I/sw/include"
615         LDFLAGS="$LDFLAGS -L/sw/lib"
616
617 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
618 # use that instead of plain dlsym.
619
620         AC_CHECK_LIB(dl,dlopen)
621         AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
622
623 # Add a system specific charset module.
624
625         default_shared_modules="$default_shared_modules charset_macosxfs"
626         ;;
627     *hurd*)
628         AC_MSG_CHECKING([for LFS support])
629         old_CPPFLAGS="$CPPFLAGS"
630         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
631         AC_TRY_RUN([
632 #include <unistd.h>
633 main () {
634 #if _LFS64_LARGEFILE == 1
635 exit(0);
636 #else
637 exit(1);
638 #endif
639 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
640         CPPFLAGS="$old_CPPFLAGS"
641         if test x$GLIBC_LFS_SUPPORT = xyes ; then
642           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
643                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
644           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
645         fi
646       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
647     ;;
648
649 esac
650
651 AC_INLINE
652 AC_HEADER_STDC
653 AC_HEADER_DIRENT
654 AC_HEADER_TIME
655 AC_HEADER_SYS_WAIT
656 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
657 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h)
658 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
659 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
660 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
661 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
662 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
663 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
664 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
665 AC_CHECK_HEADERS(langinfo.h locale.h)
666
667 # Look for Darwin headers
668 old_CPPFLAGS="$CPPFLAGS"
669 CPPFLAGS="-Iinclude $CPPFLAGS"
670 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
671 CPPFLAGS="$old_CPPFLAGS"
672
673 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
674 # subdirectory of headers.
675 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
676
677 #
678 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
679 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
680 #
681 case "$host_os" in
682     *hpux*)
683                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
684                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
685                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
686                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
687                 fi
688         ;;
689 esac
690 AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
691 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
692 AC_CHECK_HEADERS(stropts.h poll.h)
693 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
694 AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/cdefs.h glob.h)
695 # These faile to compile on Solaris so just check for their presence
696 AC_CHECK_HEADERS(security/pam_modules.h net/if.h netinet/ip.h, [], [], -)
697
698 # For experimental utmp support (lastlog on some BSD-like systems)
699 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
700  
701 AC_CHECK_SIZEOF(int,cross)
702 AC_CHECK_SIZEOF(long,cross)
703 AC_CHECK_SIZEOF(short,cross)
704
705 AC_C_CONST
706 AC_C_INLINE
707 AC_C_BIGENDIAN
708 AC_C_CHAR_UNSIGNED
709
710 AC_TYPE_SIGNAL
711 AC_TYPE_UID_T
712 AC_TYPE_MODE_T
713 AC_TYPE_OFF_T
714 AC_TYPE_SIZE_T
715 AC_TYPE_PID_T
716 AC_STRUCT_ST_RDEV
717 AC_DIRENT_D_OFF
718 AC_CHECK_TYPE(ino_t,unsigned)
719 AC_CHECK_TYPE(loff_t,off_t)
720 AC_CHECK_TYPE(offset_t,loff_t)
721 AC_CHECK_TYPE(ssize_t, int)
722 AC_CHECK_TYPE(wchar_t, unsigned short)
723
724 ############################################
725 # for cups support we need libcups, and a handful of header files
726
727 AC_ARG_ENABLE(cups,
728 [  --enable-cups           Turn on CUPS support (default=auto)])
729
730 if test x$enable_cups != xno; then
731         AC_PATH_PROG(CUPS_CONFIG, cups-config)
732
733         if test "x$CUPS_CONFIG" != x; then
734                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
735                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
736                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
737                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
738         elif test x"$enable_cups" = x"yes"; then
739                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
740         fi
741 fi
742
743 ############################################
744 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
745 AC_SEARCH_LIBS(dlopen, [dl])
746 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
747
748 ############################################
749 # check if the compiler can do immediate structures
750 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
751     AC_TRY_COMPILE([
752 #include <stdio.h>],
753 [
754    typedef struct {unsigned x;} FOOBAR;
755    #define X_FOOBAR(x) ((FOOBAR) { x })
756    #define FOO_ONE X_FOOBAR(1)
757    FOOBAR f = FOO_ONE;   
758    static struct {
759         FOOBAR y; 
760         } f2[] = {
761                 {FOO_ONE}
762         };   
763 ],
764         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
765 if test x"$samba_cv_immediate_structures" = x"yes"; then
766    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
767 fi
768
769 ############################################
770 # check if the compiler can do immediate structures
771 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
772     AC_TRY_LINK([
773 #include <stdio.h>],
774 [
775                 if (0) {
776                    this_function_does_not_exist();
777                 } else {
778                   return 1;
779                 }
780
781 ],
782         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
783 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
784    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
785 fi
786
787 ############################################
788 # check for unix domain sockets
789 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
790     AC_TRY_COMPILE([
791 #include <sys/types.h>
792 #include <stdlib.h>
793 #include <stddef.h>
794 #include <sys/socket.h>
795 #include <sys/un.h>],
796 [
797   struct sockaddr_un sunaddr; 
798   sunaddr.sun_family = AF_UNIX;
799 ],
800         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
801 if test x"$samba_cv_unixsocket" = x"yes"; then
802    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
803 fi
804
805
806 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
807     AC_TRY_COMPILE([
808 #include <sys/types.h>
809 #if STDC_HEADERS
810 #include <stdlib.h>
811 #include <stddef.h>
812 #endif
813 #include <sys/socket.h>],[socklen_t i = 0],
814         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
815 if test x"$samba_cv_socklen_t" = x"yes"; then
816    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
817 fi
818
819 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
820     AC_TRY_COMPILE([
821 #include <sys/types.h>
822 #if STDC_HEADERS
823 #include <stdlib.h>
824 #include <stddef.h>
825 #endif
826 #include <signal.h>],[sig_atomic_t i = 0],
827         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
828 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
829    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
830 fi
831
832 # stupid headers have the functions but no declaration. grrrr.
833 AC_HAVE_DECL(errno, [#include <errno.h>])
834 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
835 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
836 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
837 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
838 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
839 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
840
841 # and glibc has setresuid under linux but the function does
842 # nothing until kernel 2.1.44! very dumb.
843 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
844     AC_TRY_RUN([#include <errno.h>
845 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
846         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
847 if test x"$samba_cv_have_setresuid" = x"yes"; then
848     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
849 fi
850
851 # Do the same check for setresguid...
852 #
853 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
854     AC_TRY_RUN([#include <unistd.h>
855 #include <errno.h>
856 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
857         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
858 if test x"$samba_cv_have_setresgid" = x"yes"; then
859     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
860 fi
861
862 AC_FUNC_MEMCMP
863
864 ###############################################
865 # Readline included by default unless explicitly asked not to
866 test "${with_readline+set}" != "set" && with_readline=yes
867
868 # test for where we get readline() from
869 AC_MSG_CHECKING(whether to use readline)
870 AC_ARG_WITH(readline,
871 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
872 [  case "$with_readline" in
873   yes)
874     AC_MSG_RESULT(yes)
875
876     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
877     AC_CHECK_HEADERS(readline/history.h)
878
879     AC_CHECK_HEADERS(readline.h readline/readline.h,[
880       for termlib in ncurses curses termcap terminfo termlib tinfo; do
881        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
882       done
883       AC_CHECK_LIB(readline, rl_callback_handler_install,
884        [TERMLIBS="-lreadline $TERMLIBS"
885        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
886        break], [TERMLIBS=], $TERMLIBS)])
887     ;;
888   no)
889     AC_MSG_RESULT(no)
890     ;;
891   *)
892     AC_MSG_RESULT(yes)
893
894     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
895     # alternate readline path
896     _ldflags=${LDFLAGS}
897     _cppflags=${CPPFLAGS}
898
899     # Add additional search path
900     LDFLAGS="-L$with_readline/lib $LDFLAGS"
901     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
902
903     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
904     AC_CHECK_HEADERS(readline/history.h)
905
906     AC_CHECK_HEADERS(readline.h readline/readline.h,[
907       for termlib in ncurses curses termcap terminfo termlib; do
908        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
909       done
910       AC_CHECK_LIB(readline, rl_callback_handler_install,
911        [TERMLDFLAGS="-L$with_readline/lib"
912        TERMCPPFLAGS="-I$with_readline/include"
913        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
914        TERMLIBS="-lreadline $TERMLIBS"
915        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
916        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
917
918     LDFLAGS=$_ldflags
919     ;;
920   esac],
921   AC_MSG_RESULT(no)
922 )
923 AC_SUBST(TERMLIBS)
924 AC_SUBST(TERMLDFLAGS)
925
926 # The readline API changed slightly from readline3 to readline4, so
927 # code will generate warnings on one of them unless we have a few
928 # special cases.
929 AC_CHECK_LIB(readline, rl_completion_matches,
930              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
931                         [Do we have rl_completion_matches?])],
932              [],
933              [$TERMLIBS])
934
935 # The following test taken from the cvs sources
936 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
937 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
938 # libsocket.so which has a bad implementation of gethostbyname (it
939 # only looks in /etc/hosts), so we only look for -lsocket if we need
940 # it.
941 AC_CHECK_FUNCS(connect)
942 if test x"$ac_cv_func_connect" = x"no"; then
943     case "$LIBS" in
944     *-lnsl*) ;;
945     *) AC_CHECK_LIB(nsl_s, printf) ;;
946     esac
947     case "$LIBS" in
948     *-lnsl*) ;;
949     *) AC_CHECK_LIB(nsl, printf) ;;
950     esac
951     case "$LIBS" in
952     *-lsocket*) ;;
953     *) AC_CHECK_LIB(socket, connect) ;;
954     esac
955     case "$LIBS" in
956     *-linet*) ;;
957     *) AC_CHECK_LIB(inet, connect) ;;
958     esac
959     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
960     dnl has been cached.
961     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
962        test x"$ac_cv_lib_inet_connect" = x"yes"; then
963         # ac_cv_func_connect=yes
964         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
965         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
966     fi
967 fi
968
969 ###############################################
970 # test for where we get yp_get_default_domain() from
971 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
972 AC_CHECK_FUNCS(yp_get_default_domain)
973
974 # Check if we have execl, if not we need to compile smbrun.
975 AC_CHECK_FUNCS(execl)
976 if test x"$ac_cv_func_execl" = x"no"; then
977     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
978 fi
979
980 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
981 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
982 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
983 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
984 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
985 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
986 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
987 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
988 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
989 AC_CHECK_FUNCS(syslog vsyslog timegm)
990 AC_CHECK_FUNCS(setlocale nl_langinfo)
991 # setbuffer, shmget, shm_open are needed for smbtorture
992 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
993 AC_CHECK_HEADERS(libexc.h)
994 AC_CHECK_LIB(exc, trace_back_stack)
995
996 # syscall() is needed for smbwrapper.
997 AC_CHECK_FUNCS(syscall)
998
999 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1000 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1001 AC_CHECK_FUNCS(__getcwd _getcwd)
1002 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1003 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1004 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1005 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1006 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
1007 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1008 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1009 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1010 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1011 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1012 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1013
1014 #
1015
1016 #
1017 case "$host_os" in
1018     *linux*)
1019        # glibc <= 2.3.2 has a broken getgrouplist
1020        AC_TRY_RUN([
1021 #include <unistd.h>
1022 #include <sys/utsname.h>
1023 main() {
1024        /* glibc up to 2.3 has a broken getgrouplist */
1025 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1026        int libc_major = __GLIBC__;
1027        int libc_minor = __GLIBC_MINOR__;
1028
1029        if (libc_major < 2)
1030               exit(1);
1031        if ((libc_major == 2) && (libc_minor <= 3))
1032               exit(1);
1033 #endif
1034        exit(0);
1035 }
1036 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1037        if test x"$linux_getgrouplist_ok" = x"yes"; then
1038           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1039        fi
1040        ;;
1041     *)
1042        AC_CHECK_FUNCS(getgrouplist)
1043        ;;
1044 esac
1045
1046 #
1047 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1048 #
1049
1050 if test x$ac_cv_func_stat64 = xno ; then
1051   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1052   AC_TRY_LINK([
1053 #if defined(HAVE_UNISTD_H)
1054 #include <unistd.h>
1055 #endif
1056 #include <sys/stat.h>
1057 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1058   AC_MSG_RESULT([$ac_cv_func_stat64])
1059   if test x$ac_cv_func_stat64 = xyes ; then
1060     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1061   fi
1062 fi
1063
1064 if test x$ac_cv_func_lstat64 = xno ; then
1065   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1066   AC_TRY_LINK([
1067 #if defined(HAVE_UNISTD_H)
1068 #include <unistd.h>
1069 #endif
1070 #include <sys/stat.h>
1071 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1072   AC_MSG_RESULT([$ac_cv_func_lstat64])
1073   if test x$ac_cv_func_lstat64 = xyes ; then
1074     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1075   fi
1076 fi
1077
1078 if test x$ac_cv_func_fstat64 = xno ; then
1079   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1080   AC_TRY_LINK([
1081 #if defined(HAVE_UNISTD_H)
1082 #include <unistd.h>
1083 #endif
1084 #include <sys/stat.h>
1085 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1086   AC_MSG_RESULT([$ac_cv_func_fstat64])
1087   if test x$ac_cv_func_fstat64 = xyes ; then
1088     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1089   fi
1090 fi
1091
1092 #####################################
1093 # we might need the resolv library on some systems
1094 AC_CHECK_LIB(resolv, dn_expand)
1095
1096 #
1097 # Check for the functions putprpwnam, set_auth_parameters,
1098 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1099 # Needed for OSF1 and HPUX.
1100 #
1101
1102 AC_LIBTESTFUNC(security, putprpwnam)
1103 AC_LIBTESTFUNC(sec, putprpwnam)
1104
1105 AC_LIBTESTFUNC(security, set_auth_parameters)
1106 AC_LIBTESTFUNC(sec, set_auth_parameters)
1107
1108 # UnixWare 7.x has its getspnam in -lgen
1109 AC_LIBTESTFUNC(gen, getspnam)
1110
1111 AC_LIBTESTFUNC(security, getspnam)
1112 AC_LIBTESTFUNC(sec, getspnam)
1113
1114 AC_LIBTESTFUNC(security, bigcrypt)
1115 AC_LIBTESTFUNC(sec, bigcrypt)
1116
1117 AC_LIBTESTFUNC(security, getprpwnam)
1118 AC_LIBTESTFUNC(sec, getprpwnam)
1119
1120 ############################################
1121 # Check if we have libattr
1122 AC_SEARCH_LIBS(getxattr, [attr])
1123 AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1124 AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1125 AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1126 AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1127 AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1128
1129 # Assume non-shared by default and override below
1130 BLDSHARED="false"
1131
1132 # these are the defaults, good for lots of systems
1133 HOST_OS="$host_os"
1134 LDSHFLAGS="-shared"
1135 SONAMEFLAG="#"
1136 SHLD="\${CC} \${CFLAGS}"
1137 PICFLAGS=""
1138 PICSUFFIX="po"
1139 SHLIBEXT="so"
1140
1141 if test "$enable_shared" = "yes"; then
1142   # this bit needs to be modified for each OS that is suported by
1143   # smbwrapper. You need to specify how to created a shared library and
1144   # how to compile C code to produce PIC object files
1145
1146   AC_MSG_CHECKING([ability to build shared libraries])
1147
1148   # and these are for particular systems
1149   case "$host_os" in
1150                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1151                         BLDSHARED="true"
1152                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1153                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
1154                         else
1155                                 LDSHFLAGS="-shared -Wl,-Bsymbolic" 
1156                         fi
1157                         DYNEXP="-Wl,--export-dynamic"
1158                         PICFLAGS="-fPIC"
1159                         SONAMEFLAG="-Wl,-soname="
1160                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1161                         ;;
1162                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1163                         BLDSHARED="true"
1164                         LDSHFLAGS="-G"
1165                         SONAMEFLAG="-h "
1166                         if test "${GCC}" = "yes"; then
1167                                 PICFLAGS="-fPIC"
1168                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1169                                         DYNEXP="-Wl,-E"
1170                                 fi
1171                         else
1172                                 PICFLAGS="-KPIC"
1173                                 ## ${CFLAGS} added for building 64-bit shared 
1174                                 ## libs using Sun's Compiler
1175                                 LDSHFLAGS="-G \${CFLAGS}"
1176                                 PICSUFFIX="po.o"
1177                         fi
1178                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1179                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1180                         ;;
1181                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1182                         BLDSHARED="true"
1183                         LDSHFLAGS="-G"
1184                         SONAMEFLAG="-Wl,-h,"
1185                         PICFLAGS="-KPIC"   # Is this correct for SunOS
1186                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1187                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1188                         ;;
1189                 *netbsd* | *freebsd* | *DragonFly* )  
1190                         BLDSHARED="true"
1191                         LDSHFLAGS="-shared"
1192                         DYNEXP="-Wl,--export-dynamic"
1193                         SONAMEFLAG="-Wl,-soname,"
1194                         PICFLAGS="-fPIC -DPIC"
1195                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1196                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1197                         ;;
1198                 *openbsd*)  BLDSHARED="true"
1199                         LDSHFLAGS="-shared"
1200                         DYNEXP="-Wl,-Bdynamic"
1201                         SONAMEFLAG="-Wl,-soname,"
1202                         PICFLAGS="-fPIC"
1203                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1204                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1205                         ;;
1206                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1207                         case "$host_os" in
1208                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1209                         ;;
1210                         esac
1211                         BLDSHARED="true"
1212                         LDSHFLAGS="-set_version sgi1.0 -shared"
1213                         SONAMEFLAG="-soname "
1214                         SHLD="\${LD}"
1215                         if test "${GCC}" = "yes"; then
1216                                 PICFLAGS="-fPIC"
1217                         else 
1218                                 PICFLAGS="-KPIC"
1219                         fi
1220                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1221                         ;;
1222                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1223                         BLDSHARED="true"
1224                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
1225                         DYNEXP="-Wl,-brtl,-bexpall"
1226                         PICFLAGS="-O2"
1227                         if test "${GCC}" != "yes"; then
1228                                 ## for funky AIX compiler using strncpy()
1229                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1230                         fi
1231
1232                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1233                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1234                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1235                         ;;
1236                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1237                         SHLIBEXT="sl"
1238                         # Use special PIC flags for the native HP-UX compiler.
1239                         if test $ac_cv_prog_cc_Ae = yes; then
1240                                 BLDSHARED="true"
1241                                 SHLD="cc"
1242                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1243                                 SONAMEFLAG="-Wl,+h "
1244                                 PICFLAGS="+z"
1245                         elif test "${GCC}" = "yes"; then
1246                                 PICFLAGS="-fPIC"
1247                         fi
1248                         DYNEXP="-Wl,-E"
1249                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1250                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1251                         ;;
1252                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1253                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1254                         ;;
1255                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1256                         BLDSHARED="true"
1257                         LDSHFLAGS="-shared"
1258                         SONAMEFLAG="-Wl,-soname,"
1259                         PICFLAGS="-fPIC"
1260                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1261                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1262                         ;;
1263                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1264                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1265                         ;;
1266                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1267                         BLDSHARED="true"
1268                         LDSHFLAGS="-shared"
1269                         SONAMEFLAG="-Wl,-soname,"
1270                         PICFLAGS="-KPIC"
1271                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1272                         ;;
1273                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1274                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1275                         ;;
1276                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1277                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1278                         ;;
1279                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1280                         case "$host" in
1281                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1282                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1283                                         fi
1284                                         LDSHFLAGS="-G"
1285                                         DYNEXP="-Bexport"
1286                                 ;;
1287                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1288                         esac
1289                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1290                         ;;
1291
1292                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1293                         if [ test "$GCC" != yes ]; then
1294                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1295                         fi
1296                         LDSHFLAGS="-G"
1297                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1298                         ;;
1299                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1300                         BLDSHARED="false"
1301                         LDSHFLAGS=""
1302                         ;;
1303
1304                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1305                         BLDSHARED="true"
1306                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1307                         SHLIBEXT="dylib"
1308                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1309                         ;;
1310
1311                 *)
1312                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1313                         ;;
1314   esac
1315   AC_SUBST(DYNEXP)
1316   AC_MSG_RESULT($BLDSHARED)
1317   AC_MSG_CHECKING([linker flags for shared libraries])
1318   AC_MSG_RESULT([$LDSHFLAGS])
1319   AC_MSG_CHECKING([compiler flags for position-independent code])
1320   AC_MSG_RESULT([$PICFLAGS])
1321 fi
1322
1323 #######################################################
1324 # test whether building a shared library actually works
1325 if test $BLDSHARED = true; then
1326 AC_CACHE_CHECK([whether building shared libraries actually works], 
1327                [ac_cv_shlib_works],[
1328    # try building a trivial shared library
1329    ac_cv_shlib_works=no
1330    # The $SHLD and $LDSHFLAGS variables may contain references to other
1331    # variables so they need to be eval'ed.
1332    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
1333         shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
1334    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1335         shlib.$PICSUFFIX && ac_cv_shlib_works=yes
1336    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
1337 ])
1338 if test $ac_cv_shlib_works = no; then
1339    BLDSHARED=false
1340 fi
1341 fi
1342
1343 ################
1344
1345 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1346 AC_TRY_RUN([#include <stdio.h>
1347 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1348 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1349 if test x"$samba_cv_have_longlong" = x"yes"; then
1350     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1351 fi
1352
1353 #
1354 # Check if the compiler supports the LL prefix on long long integers.
1355 # AIX needs this.
1356
1357 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1358     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1359         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1360 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1361    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1362 fi
1363
1364   
1365 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1366 AC_TRY_RUN([#include <stdio.h>
1367 #include <sys/stat.h>
1368 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1369 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1370 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1371     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1372 fi
1373
1374 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1375 AC_TRY_RUN([
1376 #if defined(HAVE_UNISTD_H)
1377 #include <unistd.h>
1378 #endif
1379 #include <stdio.h>
1380 #include <sys/stat.h>
1381 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1382 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1383 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1384     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1385 fi
1386
1387 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1388 AC_TRY_RUN([#include <stdio.h>
1389 #include <sys/stat.h>
1390 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1391 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1392 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1393     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1394 fi
1395
1396 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1397 AC_TRY_RUN([
1398 #if defined(HAVE_UNISTD_H)
1399 #include <unistd.h>
1400 #endif
1401 #include <stdio.h>
1402 #include <sys/stat.h>
1403 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1404 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1405 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1406     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1407 fi
1408
1409 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1410 AC_TRY_RUN([
1411 #if defined(HAVE_UNISTD_H)
1412 #include <unistd.h>
1413 #endif
1414 #include <stdio.h>
1415 #include <sys/stat.h>
1416 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1417 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1418 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1419     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1420 fi
1421
1422 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1423 AC_TRY_COMPILE([
1424 #if defined(HAVE_UNISTD_H)
1425 #include <unistd.h>
1426 #endif
1427 #include <sys/types.h>
1428 #include <dirent.h>],
1429 [struct dirent64 de;],
1430 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1431 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1432     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1433 fi
1434
1435 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1436 AC_TRY_RUN([
1437 #if defined(HAVE_UNISTD_H)
1438 #include <unistd.h>
1439 #endif
1440 #include <sys/types.h>
1441 main() { dev_t dev; int i = major(dev); return 0; }],
1442 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1443 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1444     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1445 fi
1446
1447 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1448 AC_TRY_RUN([
1449 #if defined(HAVE_UNISTD_H)
1450 #include <unistd.h>
1451 #endif
1452 #include <sys/types.h>
1453 main() { dev_t dev; int i = minor(dev); return 0; }],
1454 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1455 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1456     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1457 fi
1458
1459 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1460 AC_TRY_RUN([
1461 #if defined(HAVE_UNISTD_H)
1462 #include <unistd.h>
1463 #endif
1464 #include <sys/types.h>
1465 main() { dev_t dev = makedev(1,2); return 0; }],
1466 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1467 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1468     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1469 fi
1470
1471 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1472 AC_TRY_RUN([#include <stdio.h>
1473 main() { char c; c=250; exit((c > 0)?0:1); }],
1474 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1475 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1476     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1477 fi
1478
1479 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1480 AC_TRY_COMPILE([#include <sys/types.h>
1481 #include <sys/socket.h>
1482 #include <netinet/in.h>],
1483 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1484 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1485 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1486     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1487 fi
1488
1489 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1490 AC_TRY_COMPILE([#include <sys/types.h>
1491 #include <dirent.h>
1492 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1493 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1494 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1495     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1496 fi
1497
1498 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1499 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1500 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1501 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1502     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1503 fi
1504
1505 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1506 AC_TRY_RUN([
1507 #include <sys/time.h>
1508 #include <unistd.h>
1509 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1510            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1511 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1512     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
1513 fi
1514
1515 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
1516 AC_TRY_LINK([#include <stdarg.h>
1517 va_list ap1,ap2;], [va_copy(ap1,ap2);],
1518 samba_cv_HAVE_VA_COPY=yes,
1519 samba_cv_HAVE_VA_COPY=no)])
1520 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1521     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
1522 else
1523     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
1524     AC_TRY_LINK([#include <stdarg.h>
1525     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1526     samba_cv_HAVE___VA_COPY=yes,
1527     samba_cv_HAVE___VA_COPY=no)])
1528     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
1529         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
1530     fi
1531 fi
1532
1533 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1534 AC_TRY_RUN([
1535 #include <sys/types.h>
1536 #include <stdarg.h>
1537 void foo(const char *format, ...) { 
1538        va_list ap;
1539        int len;
1540        char buf[5];
1541
1542        va_start(ap, format);
1543        len = vsnprintf(buf, 0, format, ap);
1544        va_end(ap);
1545        if (len != 5) exit(1);
1546
1547        va_start(ap, format);
1548        len = vsnprintf(0, 0, format, ap);
1549        va_end(ap);
1550        if (len != 5) exit(1);
1551
1552        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1553
1554        exit(0);
1555 }
1556 main() { foo("hello"); }
1557 ],
1558 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1559 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1560     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1561 fi
1562
1563 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1564 AC_TRY_RUN([#include <sys/types.h>
1565 #include <dirent.h>
1566 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1567 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1568 di->d_name[0] == 0) exit(0); exit(1);} ],
1569 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1570 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1571     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1572 fi
1573
1574 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1575 AC_TRY_COMPILE([#include <sys/types.h>
1576 #include <utime.h>],
1577 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1578 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1579 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1580     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1581 fi
1582
1583 ##############
1584 # Check utmp details, but only if our OS offers utmp.h
1585 if test x"$ac_cv_header_utmp_h" = x"yes"; then
1586 dnl  utmp and utmpx come in many flavours
1587 dnl  We need to check for many of them
1588 dnl  But we don't need to do each and every one, because our code uses
1589 dnl  mostly just the utmp (not utmpx) fields.
1590
1591 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1592
1593 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1594 AC_TRY_COMPILE([#include <sys/types.h>
1595 #include <utmp.h>],
1596 [struct utmp ut;  ut.ut_name[0] = 'a';],
1597 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1598 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1599     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
1600 fi 
1601
1602 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1603 AC_TRY_COMPILE([#include <sys/types.h>
1604 #include <utmp.h>],
1605 [struct utmp ut;  ut.ut_user[0] = 'a';],
1606 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1607 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1608     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
1609 fi 
1610
1611 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1612 AC_TRY_COMPILE([#include <sys/types.h>
1613 #include <utmp.h>],
1614 [struct utmp ut;  ut.ut_id[0] = 'a';],
1615 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1616 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1617     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
1618 fi 
1619
1620 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1621 AC_TRY_COMPILE([#include <sys/types.h>
1622 #include <utmp.h>],
1623 [struct utmp ut;  ut.ut_host[0] = 'a';],
1624 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1625 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1626     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
1627 fi 
1628
1629 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1630 AC_TRY_COMPILE([#include <sys/types.h>
1631 #include <utmp.h>],
1632 [struct utmp ut;  time_t t; ut.ut_time = t;],
1633 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1634 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1635     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
1636 fi 
1637
1638 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1639 AC_TRY_COMPILE([#include <sys/types.h>
1640 #include <utmp.h>],
1641 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1642 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1643 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1644     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
1645 fi 
1646
1647 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1648 AC_TRY_COMPILE([#include <sys/types.h>
1649 #include <utmp.h>],
1650 [struct utmp ut;  ut.ut_type = 0;],
1651 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1652 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1653     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
1654 fi 
1655
1656 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1657 AC_TRY_COMPILE([#include <sys/types.h>
1658 #include <utmp.h>],
1659 [struct utmp ut;  ut.ut_pid = 0;],
1660 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1661 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1662     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
1663 fi 
1664
1665 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1666 AC_TRY_COMPILE([#include <sys/types.h>
1667 #include <utmp.h>],
1668 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1669 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1670 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1671     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
1672 fi 
1673
1674 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1675 AC_TRY_COMPILE([#include <sys/types.h>
1676 #include <utmp.h>],
1677 [struct utmp ut;  ut.ut_addr = 0;],
1678 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1679 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1680     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
1681 fi 
1682
1683 if test x$ac_cv_func_pututline = xyes ; then
1684   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1685   AC_TRY_COMPILE([#include <sys/types.h>
1686 #include <utmp.h>],
1687   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1688   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1689   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1690       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
1691   fi
1692 fi
1693
1694 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1695 AC_TRY_COMPILE([#include <sys/types.h>
1696 #include <utmpx.h>],
1697 [struct utmpx ux;  ux.ut_syslen = 0;],
1698 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1699 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1700     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
1701 fi 
1702
1703 fi
1704 # end utmp details
1705
1706
1707 ICONV_LOCATION=standard
1708 LOOK_DIRS="/usr /usr/local /sw /opt"
1709 AC_ARG_WITH(libiconv,
1710 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1711 [
1712   if test "$withval" = "no" ; then
1713     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
1714   else
1715      if test "$withval" != "yes" ; then
1716         ICONV_PATH_SPEC=yes
1717         LOOK_DIRS="$withval"
1718      fi
1719   fi
1720 ])
1721
1722 for i in $LOOK_DIRS ; do
1723     save_LIBS=$LIBS
1724     save_LDFLAGS=$LDFLAGS
1725     save_CPPFLAGS=$CPPFLAGS
1726     ICONV_FOUND="no"
1727     unset libext
1728     CPPFLAGS="$CPPFLAGS -I$i/include"
1729 dnl This is here to handle -withval stuff for --with-libiconv
1730 dnl Perhaps we should always add a -L
1731
1732 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
1733 dnl installation paths. This gets a little tricky since we might have iconv
1734 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
1735 dnl succeed when the header is found. To counter this, make sure the 
1736 dnl library directory is there and check the ABI directory first (which
1737 dnl should be harmless on other systems.
1738     for l in "lib32" "lib" ; do
1739         if test -d "$i/$l" ; then
1740                 LDFLAGS="$save_LDFLAGS -L$i/$l"
1741                 LIBS=
1742                 export LDFLAGS LIBS CPPFLAGS
1743 dnl Try to find iconv(3)
1744                 jm_ICONV($i/$l)
1745                 if test x"$ICONV_FOUND" = "xyes" ; then
1746                     libext="$l"
1747                     break;
1748                 fi
1749         fi
1750     done
1751
1752     if test x"$ICONV_FOUND" = "xyes" ; then
1753         LDFLAGS=$save_LDFLAGS
1754         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1755         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1756         LIBS="$save_LIBS"
1757         ICONV_LOCATION=$i
1758         export LDFLAGS LIBS CPPFLAGS
1759 dnl Now, check for a working iconv ... we want to do it here because
1760 dnl there might be a working iconv further down the list of LOOK_DIRS
1761
1762         ############
1763         # check for iconv in libc
1764         ic_save_LIBS="$LIBS"
1765         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
1766            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
1767         fi
1768         if test x"$jm_cv_lib_iconv" != x; then
1769            LIBS="$LIBS -l$jm_cv_lib_iconv"
1770         fi
1771 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1772         default_dos_charset=no
1773         default_display_charset=no
1774         default_unix_charset=no
1775
1776         # check for default dos charset name
1777         for j in CP850 IBM850 ; do
1778             rjs_CHARSET($j)
1779             if test x"$ICONV_CHARSET" = x"$j"; then
1780                 default_dos_charset="\"$j\""
1781                 break
1782             fi
1783         done
1784         # check for default display charset name
1785         for j in ASCII 646 ; do
1786             rjs_CHARSET($j)
1787             if test x"$ICONV_CHARSET" = x"$j"; then
1788                 default_display_charset="\"$j\""
1789                 break
1790             fi
1791         done
1792         # check for default unix charset name
1793         for j in UTF-8 UTF8 ; do
1794             rjs_CHARSET($j)
1795             if test x"$ICONV_CHARSET" = x"$j"; then
1796                 default_unix_charset="\"$j\""
1797                 break
1798             fi
1799         done
1800         
1801         if test "$default_dos_charset" != "no" -a \
1802                 "$default_dos_charset" != "cross" -a \
1803                 "$default_display_charset" != "no" -a \ 
1804                 "$default_display_charset" != "cross" -a \
1805                 "$default_unix_charset" != "no" -a \
1806                 "$default_unix_charset" != "cross"
1807         then
1808                 samba_cv_HAVE_NATIVE_ICONV=yes
1809         else if test "$default_dos_charset" = "cross" -o \
1810                      "$default_display_charset" = "cross" -o \
1811                      "$default_unix_charset" = "cross"
1812         then
1813                 samba_cv_HAVE_NATIVE_ICONV=cross
1814         else
1815                 samba_cv_HAVE_NATIVE_ICONV=no
1816         fi
1817         fi
1818 dnl ])
1819
1820         LIBS="$ic_save_LIBS"
1821         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1822            CPPFLAGS=$save_CPPFLAGS
1823            LDFLAGS=$save_LDFLAGS
1824            LIBS=$save_LIBS
1825            if test x"$jm_cv_lib_iconv" != x; then
1826               LIBS="$LIBS -l$jm_cv_lib_iconv"
1827            fi
1828            dnl Add the flags we need to CPPFLAGS and LDFLAGS
1829            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1830            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1831            export CPPFLAGS
1832            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
1833            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
1834            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
1835            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
1836            break
1837         fi
1838 dnl We didn't find a working iconv, so keep going
1839     fi
1840 dnl We only need to clean these up here for the next pass through the loop
1841     CPPFLAGS=$save_CPPFLAGS
1842     LDFLAGS=$save_LDFLAGS
1843     LIBS=$save_LIBS
1844     export LDFLAGS LIBS CPPFLAGS
1845 done
1846 unset libext
1847
1848
1849 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
1850     AC_MSG_WARN([Sufficient support for iconv function was not found. 
1851     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
1852    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
1853    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
1854    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
1855 fi
1856
1857
1858 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1859 AC_TRY_RUN([
1860 #include <sys/types.h>
1861 #include <fcntl.h>
1862 #ifndef F_GETLEASE
1863 #define F_GETLEASE      1025
1864 #endif
1865 main() {
1866        int fd = open("/dev/null", O_RDONLY);
1867        return fcntl(fd, F_GETLEASE, 0) == -1;
1868 }
1869 ],
1870 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1871 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1872     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1873 fi
1874
1875 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1876 AC_TRY_RUN([
1877 #include <sys/types.h>
1878 #include <fcntl.h>
1879 #include <signal.h>
1880 #ifndef F_NOTIFY
1881 #define F_NOTIFY 1026
1882 #endif
1883 main() {
1884         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1885 }
1886 ],
1887 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1888 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1889     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1890 fi
1891
1892 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1893 AC_TRY_RUN([
1894 #include <sys/types.h>
1895 #include <fcntl.h>
1896 #include <signal.h>
1897 #include <sys/file.h>
1898 #ifndef LOCK_MAND
1899 #define LOCK_MAND       32
1900 #define LOCK_READ       64
1901 #endif
1902 main() {
1903         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1904 }
1905 ],
1906 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1907 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1908     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1909 fi
1910
1911
1912
1913
1914 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1915 AC_TRY_COMPILE([#include <sys/types.h>
1916 #include <fcntl.h>],
1917 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1918 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1919 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1920     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1921 fi
1922
1923 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1924 AC_TRY_RUN([#include <sys/types.h>
1925 #include <sys/capability.h>
1926 main() {
1927  cap_t cap;
1928  if ((cap = cap_get_proc()) == NULL)
1929    exit(1);
1930  cap->cap_effective |= CAP_NETWORK_MGT;
1931  cap->cap_inheritable |= CAP_NETWORK_MGT;
1932  cap_set_proc(cap);
1933  exit(0);
1934 }
1935 ],
1936 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1937 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1938     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1939 fi
1940
1941 #
1942 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1943 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1944 #
1945
1946 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1947 AC_TRY_COMPILE([#include <sys/types.h>
1948 #if defined(HAVE_RPC_RPC_H)
1949 #include <rpc/rpc.h>
1950 #endif],
1951 [int16 testvar;],
1952 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1953 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1954     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
1955 fi
1956
1957 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1958 AC_TRY_COMPILE([#include <sys/types.h>
1959 #if defined(HAVE_RPC_RPC_H)
1960 #include <rpc/rpc.h>
1961 #endif],
1962 [uint16 testvar;],
1963 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1964 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1965     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
1966 fi
1967
1968 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1969 AC_TRY_COMPILE([#include <sys/types.h>
1970 #if defined(HAVE_RPC_RPC_H)
1971 #include <rpc/rpc.h>
1972 #endif],
1973 [int32 testvar;],
1974 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1975 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1976     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
1977 fi
1978
1979 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1980 AC_TRY_COMPILE([#include <sys/types.h>
1981 #if defined(HAVE_RPC_RPC_H)
1982 #include <rpc/rpc.h>
1983 #endif],
1984 [uint32 testvar;],
1985 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1986 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1987     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
1988 fi
1989
1990 dnl
1991 dnl Some systems (SCO) have a problem including
1992 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1993 dnl as a #define in <prot.h> and as part of an enum
1994 dnl in <rpc/rpc.h>.
1995 dnl
1996
1997 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1998 AC_TRY_COMPILE([#include <sys/types.h>
1999 #ifdef HAVE_SYS_SECURITY_H
2000 #include <sys/security.h>
2001 #include <prot.h>
2002 #endif  /* HAVE_SYS_SECURITY_H */
2003 #if defined(HAVE_RPC_RPC_H)
2004 #include <rpc/rpc.h>
2005 #endif],
2006 [int testvar;],
2007 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2008 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2009     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2010 fi
2011
2012 AC_MSG_CHECKING([for test routines])
2013 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2014            AC_MSG_RESULT(yes),
2015            AC_MSG_ERROR([cant find test code. Aborting config]),
2016            AC_MSG_WARN([cannot run when cross-compiling]))
2017
2018 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2019 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2020            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2021 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2022     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2023 fi
2024
2025 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2026 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2027            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2028            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2029            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2030 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2031 then
2032     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2033 fi
2034
2035 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2036 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2037            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2038 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2039     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2040 fi
2041
2042 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
2043 SAVE_CPPFLAGS="$CPPFLAGS"
2044 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
2045 AC_TRY_COMPILE([
2046 #define REPLACE_GETPASS 1
2047 #define NO_PROTO_H 1
2048 #define NO_CONFIG_H 1
2049 #define main dont_declare_main
2050 #include "${srcdir-.}/lib/getsmbpass.c"
2051 #undef main
2052 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
2053 CPPFLAGS="$SAVE_CPPFLAGS"
2054 ])
2055 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
2056         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
2057 fi
2058
2059 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
2060 AC_TRY_RUN([
2061 #include <stdio.h>
2062 #include <sys/types.h>
2063 #include <netinet/in.h>
2064 #ifdef HAVE_ARPA_INET_H
2065 #include <arpa/inet.h>
2066 #endif
2067 main() { struct in_addr ip; ip.s_addr = 0x12345678;
2068 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2069     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
2070 exit(1);}],
2071            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
2072 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
2073     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
2074 fi
2075
2076 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2077 AC_TRY_RUN([#include <stdlib.h>
2078 #include <sys/types.h>
2079 #include <sys/stat.h>
2080 #include <unistd.h>
2081 main() { 
2082   struct stat st;
2083   char tpl[20]="/tmp/test.XXXXXX"; 
2084   int fd = mkstemp(tpl); 
2085   if (fd == -1) exit(1);
2086   unlink(tpl);
2087   if (fstat(fd, &st) != 0) exit(1);
2088   if ((st.st_mode & 0777) != 0600) exit(1);
2089   exit(0);
2090 }],
2091 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2092 samba_cv_HAVE_SECURE_MKSTEMP=no,
2093 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2094 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2095     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2096 fi
2097
2098 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
2099 AC_TRY_RUN([#include <unistd.h>
2100 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
2101 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
2102 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
2103     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
2104 fi
2105
2106 AC_CACHE_CHECK([for sysconf(_SC_NPROC_ONLN)],samba_cv_SYSCONF_SC_NPROC_ONLN,[
2107 AC_TRY_RUN([#include <unistd.h>
2108 main() { exit(sysconf(_SC_NPROC_ONLN) == -1 ? 1 : 0); }],
2109 samba_cv_SYSCONF_SC_NPROC_ONLN=yes,samba_cv_SYSCONF_SC_NPROC_ONLN=no,samba_cv_SYSCONF_SC_NPROC_ONLN=cross)])
2110 if test x"$samba_cv_SYSCONF_SC_NPROC_ONLN" = x"yes"; then
2111     AC_DEFINE(SYSCONF_SC_NPROC_ONLN,1,[Whether sysconf(_SC_NPROC_ONLN) is available])
2112 fi
2113
2114 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
2115 AC_TRY_RUN([main() { exit(getuid() != 0); }],
2116            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
2117 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
2118     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
2119 else
2120     AC_MSG_WARN(running as non-root will disable some tests)
2121 fi
2122
2123 ##################
2124 # look for a method of finding the list of network interfaces
2125 iface=no;
2126 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2127 AC_TRY_RUN([
2128 #define HAVE_IFACE_AIX 1
2129 #define AUTOCONF_TEST 1
2130 #include "confdefs.h"
2131 #include "${srcdir-.}/lib/interfaces.c"],
2132            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2133 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2134     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2135 fi
2136
2137 if test $iface = no; then
2138 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2139 AC_TRY_RUN([
2140 #define HAVE_IFACE_IFCONF 1
2141 #define AUTOCONF_TEST 1
2142 #include "confdefs.h"
2143 #include "${srcdir-.}/lib/interfaces.c"],
2144            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2145 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2146     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2147 fi
2148 fi
2149
2150 if test $iface = no; then
2151 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2152 AC_TRY_RUN([
2153 #define HAVE_IFACE_IFREQ 1
2154 #define AUTOCONF_TEST 1
2155 #include "confdefs.h"
2156 #include "${srcdir-.}/lib/interfaces.c"],
2157            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2158 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2159     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2160 fi
2161 fi
2162
2163
2164 ################################################
2165 # look for a method of setting the effective uid
2166 seteuid=no;
2167 if test $seteuid = no; then
2168 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2169 AC_TRY_RUN([
2170 #define AUTOCONF_TEST 1
2171 #define USE_SETRESUID 1
2172 #include "confdefs.h"
2173 #include "${srcdir-.}/lib/util_sec.c"],
2174            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2175 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2176     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2177 fi
2178 fi
2179
2180
2181 if test $seteuid = no; then
2182 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2183 AC_TRY_RUN([
2184 #define AUTOCONF_TEST 1
2185 #define USE_SETREUID 1
2186 #include "confdefs.h"
2187 #include "${srcdir-.}/lib/util_sec.c"],
2188            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2189 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2190     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2191 fi
2192 fi
2193
2194 if test $seteuid = no; then
2195 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2196 AC_TRY_RUN([
2197 #define AUTOCONF_TEST 1
2198 #define USE_SETEUID 1
2199 #include "confdefs.h"
2200 #include "${srcdir-.}/lib/util_sec.c"],
2201            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2202 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2203     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2204 fi
2205 fi
2206
2207 if test $seteuid = no; then
2208 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2209 AC_TRY_RUN([
2210 #define AUTOCONF_TEST 1
2211 #define USE_SETUIDX 1
2212 #include "confdefs.h"
2213 #include "${srcdir-.}/lib/util_sec.c"],
2214            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2215 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2216     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2217 fi
2218 fi
2219
2220
2221 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
2222 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
2223            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
2224 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
2225     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
2226 fi
2227
2228 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
2229 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
2230            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
2231 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
2232     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
2233 fi
2234
2235 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2236 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2237            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2238 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2239     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2240 fi
2241
2242 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2243 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2244            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2245 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2246     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2247
2248 else
2249
2250 dnl
2251 dnl Don't check for 64 bit fcntl locking if we know that the
2252 dnl glibc2.1 broken check has succeeded.
2253 dnl 
2254
2255   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2256   AC_TRY_RUN([
2257 #if defined(HAVE_UNISTD_H)
2258 #include <unistd.h>
2259 #endif
2260 #include <stdio.h>
2261 #include <stdlib.h>
2262
2263 #ifdef HAVE_FCNTL_H
2264 #include <fcntl.h>
2265 #endif
2266
2267 #ifdef HAVE_SYS_FCNTL_H
2268 #include <sys/fcntl.h>
2269 #endif
2270 main() { struct flock64 fl64;
2271 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2272 exit(0);
2273 #else
2274 exit(1);
2275 #endif
2276 }],
2277        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2278
2279   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2280       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2281   fi
2282 fi
2283
2284 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2285 AC_TRY_COMPILE([#include <sys/types.h>
2286 #include <sys/stat.h>
2287 #include <unistd.h>],
2288 [struct stat st;  st.st_blocks = 0;],
2289 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2290 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2291     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2292 fi 
2293
2294 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2295 AC_TRY_COMPILE([#include <sys/types.h>
2296 #include <sys/stat.h>
2297 #include <unistd.h>],
2298 [struct stat st;  st.st_blksize = 0;],
2299 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2300 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2301     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2302 fi
2303
2304 case "$host_os" in
2305 *linux*)
2306 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
2307 AC_TRY_COMPILE([
2308 #ifdef HAVE_SYS_VFS_H
2309 #include <sys/vfs.h>
2310 #endif
2311 #ifdef HAVE_SYS_CAPABILITY_H
2312 #include <sys/capability.h>
2313 #endif
2314 ],[int i;],
2315    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2316 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2317    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2318 fi
2319 ;;
2320 esac
2321
2322 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2323 AC_TRY_COMPILE([
2324 #include <sys/types.h>
2325 #include <sys/acl.h>
2326 #if defined(HAVE_RPCSVC_NIS_H)
2327 #include <rpcsvc/nis.h>
2328 #endif],
2329 [int i;],
2330 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2331 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2332         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2333 fi
2334
2335 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2336 AC_TRY_RUN([
2337 #include <stdio.h>
2338 #include <limits.h>
2339 main() {
2340         char *newpath = realpath("/tmp", NULL);
2341         exit ((newpath != NULL) ? 0 : 1);
2342 }
2343 ],
2344 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2345 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2346     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2347 fi
2348
2349 #################################################
2350 # check for smbwrapper support
2351 AC_MSG_CHECKING(whether to use smbwrapper)
2352 AC_ARG_WITH(smbwrapper,
2353 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
2354 [ case "$withval" in
2355   yes)
2356     AC_MSG_RESULT(yes)
2357     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
2358         WRAPPROG="bin/smbsh\$(EXEEXT)"
2359         WRAP="bin/smbwrapper.$SHLIBEXT"
2360
2361 # Conditions under which smbwrapper should not be built.
2362
2363         if test x$PICFLAGS = x; then
2364            echo No support for PIC code - disabling smbwrapper and smbsh
2365            WRAPPROG=""
2366            WRAP=""
2367         elif test x$ac_cv_func_syscall = xno; then
2368            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
2369            WRAPPROG=""
2370            WRAP=""
2371         fi
2372         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
2373         SMBWRAPPER="$WRAPPROG $WRAP"
2374     ;;
2375   *)
2376     AC_MSG_RESULT(no)
2377     ;;
2378   esac ],
2379   AC_MSG_RESULT(no)
2380 )
2381
2382 #################################################
2383 # check for AFS clear-text auth support
2384 samba_cv_WITH_AFS=no
2385 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2386 AC_ARG_WITH(afs,
2387 [  --with-afs              Include AFS clear-text auth support (default=no) ],
2388 [ case "$withval" in
2389   yes|auto)
2390     AC_MSG_RESULT($withval)
2391     samba_cv_WITH_AFS=$withval
2392     ;;
2393   *)
2394     AC_MSG_RESULT(no)
2395     ;;
2396   esac ],
2397   AC_MSG_RESULT(no)
2398 )
2399
2400 ####################################################
2401 # check for Linux-specific AFS fake-kaserver support
2402 samba_cv_WITH_FAKE_KASERVER=no
2403 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2404 AC_ARG_WITH(fake-kaserver,
2405 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
2406 [ case "$withval" in
2407   yes|auto)
2408     AC_MSG_RESULT($withval)
2409     samba_cv_WITH_FAKE_KASERVER=$withval
2410     ;;
2411   *)
2412     AC_MSG_RESULT(no)
2413     ;;
2414   esac ],
2415   AC_MSG_RESULT(no)
2416 )
2417
2418 #################################################
2419 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
2420 if test x"$samba_cv_WITH_AFS" != x"no" ||
2421    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
2422
2423     # see if this box has the afs-headers in /usr/include/afs
2424     AC_MSG_CHECKING(for /usr/include/afs)
2425     if test -d /usr/include/afs; then
2426           CFLAGS="$CFLAGS -I/usr/include/afs"
2427           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
2428           AC_MSG_RESULT(yes)
2429     else
2430       AC_MSG_RESULT(no)
2431     fi
2432    
2433     # check for afs.h
2434     have_afs_headers=no
2435     AC_CHECK_HEADERS(afs.h afs/afs.h)
2436     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
2437         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
2438            test x"$samba_cv_WITH_AFS" = x"auto"; then
2439                 AC_MSG_WARN([AFS cannot be supported without afs.h])
2440         else
2441                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
2442         fi
2443     else
2444         have_afs_headers=yes
2445     fi
2446 fi
2447
2448 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
2449     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
2450 fi
2451
2452 #################################################
2453 # check whether to compile AFS/NT ACL mapping module
2454 samba_cv_WITH_VFS_AFSACL=no
2455 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2456 AC_ARG_WITH(vfs-afsacl,
2457 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
2458 [ case "$withval" in
2459   yes|auto)
2460     AC_MSG_RESULT($withval)
2461     samba_cv_WITH_VFS_AFSACL=yes
2462     ;;
2463   *)
2464     AC_MSG_RESULT(no)
2465     ;;
2466   esac ],
2467   AC_MSG_RESULT(no)
2468 )
2469
2470 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
2471    default_shared_modules="$default_shared_modules vfs_afsacl"
2472 fi
2473         
2474 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
2475     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2476 fi
2477
2478 #################################################
2479 # check for the DFS clear-text auth system
2480 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2481 AC_ARG_WITH(dfs,
2482 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
2483 [ case "$withval" in
2484   yes)
2485     AC_MSG_RESULT(yes)
2486     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2487     ;;
2488   *)
2489     AC_MSG_RESULT(no)
2490     ;;
2491   esac ],
2492   AC_MSG_RESULT(no)
2493 )
2494
2495 ########################################################
2496 # Compile with LDAP support?
2497
2498 with_ldap_support=auto
2499 AC_MSG_CHECKING([for LDAP support])
2500
2501 AC_ARG_WITH(ldap,
2502 [  --with-ldap             LDAP support (default yes)],
2503 [ case "$withval" in
2504     yes|no)
2505         with_ldap_support=$withval
2506         ;;
2507   esac ])
2508
2509 AC_MSG_RESULT($with_ldap_support)
2510
2511 SMBLDAP=""
2512 AC_SUBST(SMBLDAP)
2513 if test x"$with_ldap_support" != x"no"; then
2514
2515   ##################################################################
2516   # first test for ldap.h and lber.h
2517   # (ldap.h is required for this test)
2518   AC_CHECK_HEADERS(ldap.h lber.h)
2519   
2520   if test x"$ac_cv_header_ldap_h" != x"yes"; then
2521         if test x"$with_ldap_support" = x"yes"; then
2522          AC_MSG_ERROR(ldap.h is needed for LDAP support)
2523         else
2524          AC_MSG_WARN(ldap.h is needed for LDAP support)
2525         fi
2526         
2527         with_ldap_support=no
2528   fi
2529 fi
2530
2531 if test x"$with_ldap_support" != x"no"; then
2532   ac_save_LIBS=$LIBS
2533
2534   ##################################################################
2535   # we might need the lber lib on some systems. To avoid link errors
2536   # this test must be before the libldap test
2537   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
2538
2539   ########################################################
2540   # now see if we can find the ldap libs in standard paths
2541   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
2542
2543   AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
2544   
2545   ########################################################
2546   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
2547   # Check found in pam_ldap 145.
2548   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
2549
2550   LIBS="$LIBS $LDAP_LIBS"
2551   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
2552     AC_TRY_COMPILE([
2553         #include <lber.h>
2554         #include <ldap.h>], 
2555         [ldap_set_rebind_proc(0, 0, 0);], 
2556         [smb_ldap_cv_ldap_set_rebind_proc=3], 
2557         [smb_ldap_cv_ldap_set_rebind_proc=2]
2558     ) 
2559   ])
2560   
2561   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
2562
2563   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS) 
2564   
2565   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
2566     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
2567     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
2568     SMBLDAP="lib/smbldap.o"
2569     with_ldap_support=yes
2570     AC_MSG_CHECKING(whether LDAP support is used)
2571     AC_MSG_RESULT(yes)
2572   else
2573     if test x"$with_ldap_support" = x"yes"; then
2574         AC_MSG_ERROR(libldap is needed for LDAP support)
2575     else
2576         AC_MSG_WARN(libldap is needed for LDAP support)
2577     fi
2578     
2579     LDAP_LIBS=""
2580     with_ldap_support=no
2581   fi
2582   LIBS=$ac_save_LIBS
2583 fi
2584
2585
2586 #################################################
2587 # active directory support
2588
2589 with_ads_support=auto
2590 AC_MSG_CHECKING([for Active Directory and krb5 support])
2591
2592 AC_ARG_WITH(ads,
2593 [  --with-ads              Active Directory support (default auto)],
2594 [ case "$withval" in
2595     yes|no)
2596         with_ads_support="$withval"
2597         ;;
2598   esac ])
2599
2600 AC_MSG_RESULT($with_ads_support)
2601
2602 FOUND_KRB5=no
2603 KRB5_LIBS=""
2604
2605 if test x"$with_ldap_support" != x"yes"; then
2606     if test x"$with_ads_support" = x"yes"; then
2607         AC_MSG_ERROR(Active Directory Support requires LDAP support)
2608     elif test x"$with_ads_support" != x"no"; then
2609         AC_MSG_WARN(Active Directory Support requires LDAP support)
2610     fi
2611     with_ads_support=no
2612 fi
2613
2614 if test x"$with_ads_support" != x"no"; then
2615
2616   # Do no harm to the values of CFLAGS and LIBS while testing for
2617   # Kerberos support.
2618  
2619   if test x$FOUND_KRB5 = x"no"; then
2620     #################################################
2621     # check for location of Kerberos 5 install
2622     AC_MSG_CHECKING(for kerberos 5 install path)
2623     AC_ARG_WITH(krb5,
2624     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
2625     [ case "$withval" in
2626       no)
2627         AC_MSG_RESULT(no krb5-path given)
2628         ;;
2629       yes)
2630         AC_MSG_RESULT(/usr)
2631         FOUND_KRB5=yes
2632         ;;
2633       *)
2634         AC_MSG_RESULT($withval)
2635         KRB5_CFLAGS="-I$withval/include"
2636         KRB5_CPPFLAGS="-I$withval/include"
2637         KRB5_LDFLAGS="-L$withval/lib"
2638         FOUND_KRB5=yes
2639         if test -x "$withval/bin/krb5-config"; then
2640                 KRB5_CONFIG=$withval/bin/krb5-config
2641         fi
2642         ;;
2643       esac ],
2644       AC_MSG_RESULT(no krb5-path given)
2645     )
2646   fi
2647
2648   #################################################
2649   # check for krb5-config from recent MIT and Heimdal kerberos 5
2650   AC_PATH_PROG(KRB5_CONFIG, krb5-config)
2651   AC_MSG_CHECKING(for working krb5-config)
2652   if test -x "$KRB5_CONFIG"; then
2653     ac_save_CFLAGS=$CFLAGS
2654     CFLAGS="";export CFLAGS
2655     ac_save_LDFLAGS=$LDFLAGS
2656     LDFLAGS="";export LDFLAGS
2657     KRB5_LIBS="`$KRB5_CONFIG --libs gssapi`"
2658     KRB5_LDFLAGS="`$KRB5_CONFIG --libs gssapi | sed s/-lgss.*//`"
2659     KRB5_CFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`" 
2660     KRB5_CPPFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`"
2661     CFLAGS=$ac_save_CFLAGS;export CFLAGS
2662     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
2663     FOUND_KRB5=yes
2664     AC_MSG_RESULT(yes)
2665   else
2666     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
2667   fi
2668  
2669   if test x$FOUND_KRB5 = x"no"; then
2670     #################################################
2671     # see if this box has the SuSE location for the heimdal krb implementation
2672     AC_MSG_CHECKING(for /usr/include/heimdal)
2673     if test -d /usr/include/heimdal; then
2674       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
2675           KRB5_CFLAGS="-I/usr/include/heimdal"
2676           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2677           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
2678           AC_MSG_RESULT(yes)
2679       else
2680           KRB5_CFLAGS="-I/usr/include/heimdal"
2681           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2682           AC_MSG_RESULT(yes)
2683       fi
2684     else
2685       AC_MSG_RESULT(no)
2686     fi
2687   fi
2688
2689   if test x$FOUND_KRB5 = x"no"; then
2690     #################################################
2691     # see if this box has the RedHat location for kerberos
2692     AC_MSG_CHECKING(for /usr/kerberos)
2693     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
2694       KRB5_LDFLAGS="-L/usr/kerberos/lib"
2695       KRB5_CFLAGS="-I/usr/kerberos/include"
2696       KRB5_CPPFLAGS="-I/usr/kerberos/include"
2697       AC_MSG_RESULT(yes)
2698     else
2699       AC_MSG_RESULT(no)
2700     fi
2701   fi
2702
2703   ac_save_CFLAGS=$CFLAGS
2704   ac_save_CPPFLAGS=$CPPFLAGS
2705   ac_save_LDFLAGS=$LDFLAGS
2706
2707   CFLAGS="$KRB5_CFLAGS $CFLAGS"
2708   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
2709   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
2710
2711   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
2712
2713   # now check for krb5.h. Some systems have the libraries without the headers!
2714   # note that this check is done here to allow for different kerberos
2715   # include paths
2716   AC_CHECK_HEADERS(krb5.h)
2717
2718   if test x"$ac_cv_header_krb5_h" = x"no"; then
2719
2720     # Give a warning if AD support was not explicitly requested,
2721     # i.e with_ads_support = auto, otherwise die with an error.
2722
2723     if test x"$with_ads_support" = x"yes"; then
2724       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
2725     else
2726       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
2727     fi
2728
2729     # Turn off AD support and restore CFLAGS and LIBS variables
2730
2731     with_ads_support="no"
2732     
2733     CFLAGS=$ac_save_CFLAGS
2734     CPPFLAGS=$ac_save_CPPFLAGS
2735     LDFLAGS=$ac_save_LDFLAGS
2736   fi
2737 fi
2738
2739 # Now we have determined whether we really want ADS support
2740
2741 if test x"$with_ads_support" != x"no"; then
2742   ac_save_LIBS=$LIBS
2743
2744   # now check for gssapi headers.  This is also done here to allow for
2745   # different kerberos include paths
2746   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
2747
2748   ##################################################################
2749   # we might need the k5crypto and com_err libraries on some systems
2750   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
2751   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
2752
2753   # Heimdal checks.
2754   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
2755   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
2756   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
2757
2758   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
2759   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
2760                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2761
2762   ########################################################
2763   # now see if we can find the krb5 libs in standard paths
2764   # or as specified above
2765   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
2766   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
2767
2768   ########################################################
2769   # now see if we can find the gssapi libs in standard paths
2770   AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
2771             AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2772
2773   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
2774   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
2775   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
2776   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
2777   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
2778   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
2779   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
2780   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
2781   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
2782   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
2783   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
2784   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
2785   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
2786   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
2787   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
2788   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
2789   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
2790   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
2791   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
2792   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
2793   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
2794   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
2795
2796   LIBS="$KRB5_LIBS $LIBS"
2797   
2798   AC_CACHE_CHECK([for krb5_encrypt_block type],
2799                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
2800     AC_TRY_COMPILE([#include <krb5.h>],
2801       [krb5_encrypt_block block;],
2802       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
2803       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
2804
2805   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
2806     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
2807                [Whether the type krb5_encrypt_block exists])
2808   fi
2809
2810   AC_CACHE_CHECK([for addrtype in krb5_address],
2811                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
2812     AC_TRY_COMPILE([#include <krb5.h>],
2813       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
2814       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
2815       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
2816
2817   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
2818     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
2819                [Whether the krb5_address struct has a addrtype property])
2820   fi
2821
2822   AC_CACHE_CHECK([for addr_type in krb5_address],
2823                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
2824     AC_TRY_COMPILE([#include <krb5.h>],
2825       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
2826       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
2827       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
2828
2829   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
2830     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
2831               [Whether the krb5_address struct has a addr_type property])
2832   fi
2833
2834   AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
2835                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
2836                  [AC_TRY_COMPILE([#include <krb5.h>],
2837     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
2838     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
2839
2840   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
2841     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
2842               [Whether the krb5_ticket struct has a enc_part2 property])
2843   fi
2844
2845   AC_CACHE_CHECK([for keyblock in krb5_creds],
2846                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
2847     AC_TRY_COMPILE([#include <krb5.h>],
2848       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
2849       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
2850       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
2851
2852   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
2853     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
2854               [Whether the krb5_creds struct has a keyblock property])
2855   fi
2856
2857   AC_CACHE_CHECK([for session in krb5_creds],
2858                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
2859     AC_TRY_COMPILE([#include <krb5.h>],
2860       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
2861       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
2862       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
2863
2864   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
2865     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
2866               [Whether the krb5_creds struct has a session property])
2867   fi
2868
2869   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
2870                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
2871     AC_TRY_COMPILE([#include <krb5.h>],
2872       [krb5_keyblock key; key.keyvalue.data = NULL;],
2873       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
2874       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
2875
2876   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
2877     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
2878               [Whether the krb5_keyblock struct has a keyvalue property])
2879   fi
2880
2881   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
2882                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
2883     AC_TRY_COMPILE([#include <krb5.h>],
2884       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
2885       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
2886       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
2887   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
2888                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
2889     AC_TRY_COMPILE([#include <krb5.h>],
2890       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
2891       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
2892       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
2893 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
2894 # w.r.t. arcfour and windows, so we must not enable it here
2895   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
2896           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
2897     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
2898               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
2899   fi
2900
2901   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
2902                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
2903     AC_TRY_COMPILE([#include <krb5.h>],
2904       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
2905       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
2906       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
2907
2908   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
2909     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
2910               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
2911   fi
2912
2913   AC_CACHE_CHECK([for KV5M_KEYTAB],
2914                  samba_cv_HAVE_KV5M_KEYTAB,[
2915     AC_TRY_COMPILE([#include <krb5.h>],
2916       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
2917       samba_cv_HAVE_KV5M_KEYTAB=yes,
2918       samba_cv_HAVE_KV5M_KEYTAB=no)])
2919
2920   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
2921       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
2922              [Whether the KV5M_KEYTAB option is available])
2923   fi
2924
2925   AC_CACHE_CHECK([for the krb5_princ_component macro],
2926                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
2927     AC_TRY_LINK([#include <krb5.h>],
2928       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
2929       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
2930       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
2931
2932   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
2933     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
2934                [Whether krb5_princ_component is available])
2935   fi
2936
2937   AC_CACHE_CHECK([for key in krb5_keytab_entry],
2938                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
2939     AC_TRY_COMPILE([#include <krb5.h>],
2940       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
2941       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
2942       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
2943
2944   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
2945     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
2946               [Whether krb5_keytab_entry has key member])
2947   fi
2948
2949   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
2950                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
2951     AC_TRY_COMPILE([#include <krb5.h>],
2952       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
2953       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
2954       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
2955
2956   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
2957     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
2958               [Whether krb5_keytab_entry has keyblock member])
2959   fi
2960
2961   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
2962     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
2963     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
2964     AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
2965     AC_MSG_RESULT(yes)
2966   else
2967     if test x"$with_ads_support" = x"yes"; then
2968         AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
2969     else
2970         AC_MSG_WARN(libkrb5 is needed for Active Directory support)
2971     fi
2972     KRB5_LIBS=""
2973     with_ads_support=no 
2974   fi
2975
2976   AC_CACHE_CHECK([for WRFILE: keytab support],
2977                 samba_cv_HAVE_WRFILE_KEYTAB,[
2978     AC_TRY_RUN([
2979 #include<krb5.h>
2980   main()
2981   {
2982     krb5_context context;
2983     krb5_keytab keytab;
2984
2985     krb5_init_context(&context);
2986     if (krb5_kt_resolve(context, "WRFILE:api", &keytab))
2987       exit(0);
2988     exit(1);
2989   }],
2990   samba_cv_HAVE_WRFILE_KEYTAB=no,
2991   samba_cv_HAVE_WRFILE_KEYTAB=yes)])
2992
2993   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
2994       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
2995                [Whether the WRFILE:-keytab is supported])
2996   fi
2997
2998   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
2999                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3000     AC_TRY_COMPILE([#include <krb5.h>],
3001     [
3002     krb5_context context;
3003     krb5_principal principal;
3004     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3005     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3006     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3007
3008   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3009     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3010               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3011   fi
3012
3013 LIBS="$ac_save_LIBS"
3014 fi
3015
3016 ########################################################
3017 # Compile experimental passdb backends?
3018 # (pdb_xml, pdb_mysql, pdb_pgsql)
3019 AC_MSG_CHECKING(whether to build experimental passdb libraries)
3020 AC_ARG_WITH(expsam,
3021 [  --with-expsam=<list>    Include experimental passdb libraries (default=no)]
3022 [                          Valid choices include (comma separated list): ]
3023 [                              xml, mysql & pgsql],
3024 [ expsam_pdb_modules=`echo "$withval" | sed 's/,/ /g'`
3025   if test "z$expsam_pdb_modules" = "zyes"; then
3026     expsam_pdb_modules="xml mysql pgsql"
3027   fi
3028   AC_MSG_RESULT($expsam_pdb_modules)
3029   for i in $expsam_pdb_modules
3030   do 
3031     case "$i" in
3032     xml|all|yes)
3033       ## pdb_xml
3034           AM_PATH_XML2([2.0.0],[default_shared_modules="$default_shared_modules pdb_xml"],[AC_MSG_ERROR([Can't find XML libraries while XML support is requested])])
3035       CFLAGS="$CFLAGS $XML_CFLAGS"
3036       ;;
3037     mysql|all|yes)
3038       ## pdb_mysql
3039           AM_PATH_MYSQL([default_shared_modules="$default_shared_modules pdb_mysql"],[AC_MSG_ERROR([Can't find MySQL libraries while MySQL support is requested])])
3040       CFLAGS="$CFLAGS $MYSQL_CFLAGS"
3041       ;;
3042      pgsql|all|yes)
3043       ## pdb_pgsql
3044       AM_PATH_PGSQL([default_shared_modules="$default_shared_modules pdb_pgsql"],[])
3045       CFLAGS="$CFLAGS $PGSQL_CFLAGS"
3046       ;;
3047     no)
3048       ;;
3049     *)
3050       echo "Unknown module name \"$i\"!  Exiting..."
3051       exit 1
3052       ;;
3053     esac
3054   done ],
3055   AC_MSG_RESULT(no)
3056 )
3057
3058 #################################################
3059 # check for automount support
3060 AC_MSG_CHECKING(whether to use automount)
3061 AC_ARG_WITH(automount,
3062 [  --with-automount        Include automount support (default=no)],
3063 [ case "$withval" in
3064   yes)
3065     AC_MSG_RESULT(yes)
3066     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3067     ;;
3068   *)
3069     AC_MSG_RESULT(no)
3070     ;;
3071   esac ],
3072   AC_MSG_RESULT(no)
3073 )
3074
3075 #################################################
3076 # check for smbmount support
3077 AC_MSG_CHECKING(whether to use smbmount)
3078 AC_ARG_WITH(smbmount,
3079 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
3080 [ case "$withval" in
3081   yes)
3082         case "$host_os" in
3083         *linux*)
3084                 AC_MSG_RESULT(yes)
3085                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
3086                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
3087                 ;;
3088         *)
3089                 AC_MSG_ERROR(not on a linux system!)
3090                 ;;
3091         esac
3092     ;;
3093   *)
3094     AC_MSG_RESULT(no)
3095     ;;
3096   esac ],
3097   AC_MSG_RESULT(no)
3098 )
3099
3100
3101
3102 #################################################
3103 # check for a PAM clear-text auth, accounts, password and session support
3104 with_pam_for_crypt=no
3105 AC_MSG_CHECKING(whether to use PAM)
3106 AC_ARG_WITH(pam,
3107 [  --with-pam              Include PAM support (default=no)],
3108 [ case "$withval" in
3109   yes)
3110     AC_MSG_RESULT(yes)
3111     if test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3112        if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
3113           if test x"$ac_cv_header_security__pam_macros_h" = x"no"; then
3114              AC_MSG_ERROR(--with-pam specified but no PAM headers found)
3115           fi
3116        fi
3117     fi
3118     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
3119     AUTH_LIBS="$AUTH_LIBS -lpam"
3120     with_pam_for_crypt=yes
3121     ;;
3122   *)
3123     AC_MSG_RESULT(no)
3124     ;;
3125   esac ],
3126   AC_MSG_RESULT(no)
3127 )
3128
3129 # we can't build a pam module if we don't have pam.
3130 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
3131
3132 #################################################
3133 # check for pam_smbpass support
3134 AC_MSG_CHECKING(whether to use pam_smbpass)
3135 AC_ARG_WITH(pam_smbpass,
3136 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
3137 [ case "$withval" in
3138   yes)
3139     AC_MSG_RESULT(yes)
3140
3141        # Conditions under which pam_smbpass should not be built.
3142
3143        if test x$PICFLAGS = x; then
3144           AC_MSG_ERROR([No support for PIC code])
3145        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3146           AC_MSG_ERROR([No security/pam_appl.h found])
3147        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
3148           AC_MSG_ERROR([No libpam found])
3149        else
3150           AUTH_LIBS="$AUTH_LIBS -lpam"
3151           SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.$SHLIBEXT"
3152        fi
3153     ;;
3154   *)
3155     AC_MSG_RESULT(no)
3156     ;;
3157   esac ],
3158   AC_MSG_RESULT(no)
3159 )
3160
3161
3162 ###############################################
3163 # test for where we get crypt() from
3164 AC_SEARCH_LIBS(crypt, [crypt],
3165   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
3166   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
3167
3168 ##
3169 ## moved after the check for -lcrypt in order to
3170 ## ensure that the necessary libraries are included
3171 ## check checking for truncated salt.  Wrapped by the
3172 ## $with_pam_for_crypt variable as above   --jerry
3173 ##
3174 if test $with_pam_for_crypt = no; then
3175 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
3176 crypt_LIBS="$LIBS"
3177 LIBS="$AUTH_LIBS $LIBS"
3178 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
3179         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
3180 LIBS="$crypt_LIBS"])
3181 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
3182         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
3183 fi
3184 fi
3185
3186
3187 ########################################################################################
3188 ##
3189 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
3190 ##
3191 ########################################################################################
3192
3193 #################################################
3194 # check for a LDAP password database configuration backwards compatibility
3195 AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration)
3196 AC_ARG_WITH(ldapsam,
3197 [  --with-ldapsam          Include LDAP SAM 2.2 compatible configuration (default=no)],
3198 [ case "$withval" in
3199   yes)
3200     AC_MSG_RESULT(yes)
3201     AC_DEFINE(WITH_LDAP_SAMCONFIG,1,[Whether to include 2.2 compatible LDAP SAM configuration])
3202     ;;
3203   *)
3204     AC_MSG_RESULT(no)
3205     ;;
3206   esac ],
3207   AC_MSG_RESULT(no)
3208 )
3209
3210 ########################################################################################
3211 ##
3212 ## END OF TESTS FOR SAM BACKENDS.  
3213 ##
3214 ########################################################################################
3215
3216 #################################################
3217 # check for a NISPLUS_HOME support 
3218 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
3219 AC_ARG_WITH(nisplus-home,
3220 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
3221 [ case "$withval" in
3222   yes)
3223     AC_MSG_RESULT(yes)
3224     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
3225     ;;
3226   *)
3227     AC_MSG_RESULT(no)
3228     ;;
3229   esac ],
3230   AC_MSG_RESULT(no)
3231 )
3232
3233 #################################################
3234 # check for syslog logging
3235 AC_MSG_CHECKING(whether to use syslog logging)
3236 AC_ARG_WITH(syslog,
3237 [  --with-syslog           Include experimental SYSLOG support (default=no)],
3238 [ case "$withval" in
3239   yes)
3240     AC_MSG_RESULT(yes)
3241     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
3242     ;;
3243   *)
3244     AC_MSG_RESULT(no)
3245     ;;
3246   esac ],
3247   AC_MSG_RESULT(no)
3248 )
3249
3250 #################################################
3251 # check for a shared memory profiling support
3252 AC_MSG_CHECKING(whether to use profiling)
3253 AC_ARG_WITH(profiling-data,
3254 [  --with-profiling-data   Include gathering source code profile information (default=no)],
3255 [ case "$withval" in
3256   yes)
3257     AC_MSG_RESULT(yes)
3258     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
3259     ;;
3260   *)
3261     AC_MSG_RESULT(no)
3262     ;;
3263   esac ],
3264   AC_MSG_RESULT(no)
3265 )
3266
3267
3268 #################################################
3269 # check for experimental disk-quotas support
3270
3271 samba_cv_WITH_QUOTAS=auto
3272 samba_cv_TRY_QUOTAS=no
3273 samba_cv_RUN_QUOTA_TESTS=auto
3274 samba_cv_WITH_SYS_QUOTAS=auto
3275 samba_cv_TRY_SYS_QUOTAS=no
3276 samba_cv_SYSQUOTA_FOUND=no;
3277
3278 AC_MSG_CHECKING(whether to try disk-quotas support)
3279 AC_ARG_WITH(quotas,
3280 [  --with-quotas           Include disk-quota support (default=no)],
3281 [ case "$withval" in
3282   yes)
3283     AC_MSG_RESULT(yes)
3284     samba_cv_WITH_QUOTAS=yes
3285     samba_cv_TRY_QUOTAS=yes
3286     samba_cv_RUN_QUOTA_TESTS=yes
3287     #set sys quotas to auto in this case
3288     samba_cv_TRY_SYS_QUOTAS=auto
3289     ;;
3290   auto)
3291     AC_MSG_RESULT(auto)
3292     samba_cv_WITH_QUOTAS=auto
3293     samba_cv_TRY_QUOTAS=auto
3294     samba_cv_RUN_QUOTA_TESTS=auto
3295     #set sys quotas to auto in this case
3296     samba_cv_TRY_SYS_QUOTAS=auto
3297     ;;
3298   no)
3299     AC_MSG_RESULT(no)
3300     samba_cv_WITH_QUOTAS=no
3301     samba_cv_TRY_QUOTAS=no
3302     samba_cv_RUN_QUOTA_TESTS=no
3303     ;;
3304   *)
3305     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3306     ;;
3307   esac ],
3308   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3309 )
3310
3311 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
3312 AC_ARG_WITH(sys-quotas,
3313 [  --with-sys-quotas       Include lib/sysquotas.c support (default=auto)],
3314 [ case "$withval" in
3315   yes)
3316     AC_MSG_RESULT(yes)
3317     samba_cv_WITH_SYS_QUOTAS=yes
3318     samba_cv_TRY_SYS_QUOTAS=yes
3319     samba_cv_RUN_QUOTA_TESTS=yes
3320     ;;
3321   auto)
3322     AC_MSG_RESULT(auto)
3323     samba_cv_WITH_SYS_QUOTAS=auto
3324     samba_cv_TRY_SYS_QUOTAS=auto
3325     samba_cv_RUN_QUOTA_TESTS=auto
3326     ;;
3327   no)
3328     AC_MSG_RESULT(no)
3329     samba_cv_WITH_SYS_QUOTAS=no
3330     samba_cv_TRY_SYS_QUOTAS=no
3331     ;;
3332   *)
3333     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3334     ;;
3335   esac ],
3336   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3337 )
3338
3339 if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
3340 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
3341   case "$host_os" in
3342         *linux*)
3343             AC_MSG_RESULT(yes)
3344             samba_cv_TRY_SYS_QUOTAS=yes
3345             samba_cv_RUN_QUOTA_TESTS=yes
3346             samba_cv_SYSQUOTA_FOUND=yes
3347             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
3348             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
3349             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
3350             samba_cv_found_xfs_header=yes
3351             ;;
3352         *)
3353             AC_MSG_RESULT(no)
3354             samba_cv_TRY_SYS_QUOTAS=no
3355             ;;
3356   esac
3357 fi
3358
3359 #############################################
3360 # only check for quota stuff if --with-quotas
3361 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
3362
3363 # some broken header files need this
3364 AC_CHECK_HEADER(asm/types.h,[
3365             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
3366             AC_ADD_INCLUDE(<asm/types.h>)
3367             ])
3368
3369 # For quotas on Veritas VxFS filesystems
3370 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
3371
3372 # For sys/quota.h and linux/quota.h
3373 AC_CHECK_HEADERS(sys/quota.h)
3374
3375 if test x"$samba_cv_found_xfs_header" != x"yes"; then
3376 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
3377 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
3378 AC_TRY_COMPILE([
3379 #include "confdefs.h"
3380 #ifdef HAVE_SYS_TYPES_H
3381 #include <sys/types.h>
3382 #endif
3383 #ifdef HAVE_ASM_TYPES_H
3384 #include <asm/types.h>
3385 #endif
3386 #include <sys/quota.h>
3387 ],[int i = Q_XGETQUOTA;],
3388 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
3389 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
3390         samba_cv_found_xfs_header=yes
3391 fi
3392 fi
3393
3394 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
3395 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
3396 AC_TRY_COMPILE([
3397 #include "confdefs.h"
3398 #ifdef HAVE_SYS_QUOTA_H
3399 #include <sys/quota.h>
3400 #endif
3401 ],[
3402 struct dqblk D;
3403 D.dqb_fsoftlimit = 0;],
3404 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
3405 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
3406         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
3407 fi
3408
3409 ##################
3410 # look for a working quota system
3411
3412 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3413 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
3414 AC_TRY_RUN_STRICT([
3415 #define HAVE_QUOTACTL_4A 1
3416 #define AUTOCONF_TEST 1
3417 #include "confdefs.h"
3418 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3419            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
3420 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
3421     samba_cv_SYSQUOTA_FOUND=yes;
3422     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
3423     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
3424 fi
3425 fi
3426
3427 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3428 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
3429 AC_TRY_RUN_STRICT([
3430 #define HAVE_QUOTACTL_4B 1
3431 #define AUTOCONF_TEST 1
3432 #include "confdefs.h"
3433 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3434            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
3435 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
3436     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
3437     samba_cv_SYSQUOTA_FOUND=yes;
3438     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
3439     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
3440 fi
3441 fi
3442
3443 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3444 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
3445 AC_TRY_RUN_STRICT([
3446 #define HAVE_QUOTACTL_3 1
3447 #define AUTOCONF_TEST 1
3448 #include "confdefs.h"
3449 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3450            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
3451 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
3452     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
3453     samba_cv_SYSQUOTA_FOUND=yes;
3454     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
3455     samba_cv_sysquotas_file="lib/sysquotas_3.c"
3456 fi
3457 fi
3458
3459 #################################################
3460 # check for mntent.h and struct mntent
3461 AC_CHECK_HEADERS(mntent.h)
3462 #################################################
3463 # check for setmntent,getmntent,endmntent
3464 AC_CHECK_FUNCS(setmntent getmntent endmntent)
3465
3466 #################################################
3467 # check for devnm.h and struct mntent
3468 AC_CHECK_HEADERS(devnm.h)
3469 #################################################
3470 # check for devnm
3471 AC_CHECK_FUNCS(devnm)
3472
3473 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
3474     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3475         # if --with-sys-quotas=yes then build it 
3476         # you have can use the get/set quota command smb.conf
3477         # options then
3478         samba_cv_SYSQUOTA_FOUND=auto
3479     fi
3480     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
3481         # if --with-sys-quotas=yes then build it 
3482         # you have can use the get/set quota command smb.conf
3483         # options then
3484         samba_cv_TRY_SYS_QUOTAS=auto
3485     fi
3486 fi
3487
3488 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
3489 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
3490 SAVE_CPPFLAGS="$CPPFLAGS"
3491 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3492 AC_TRY_COMPILE([
3493 #include "confdefs.h"
3494 #define NO_PROTO_H 1
3495 #define NO_CONFIG_H 1
3496 #define HAVE_SYS_QUOTAS 1
3497 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
3498 #include "${srcdir-.}/lib/sysquotas.c"
3499 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
3500 CPPFLAGS="$SAVE_CPPFLAGS"
3501 ])
3502 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
3503 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
3504     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
3505         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3506         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
3507         samba_cv_WE_USE_SYS_QUOTAS=yes
3508         AC_MSG_RESULT(yes)
3509     else
3510         AC_MSG_RESULT(no)
3511     fi
3512 fi
3513 fi
3514
3515 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
3516 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
3517 SAVE_CPPFLAGS="$CPPFLAGS"
3518 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3519 AC_TRY_COMPILE([
3520 #include "confdefs.h"
3521 #define NO_PROTO_H 1
3522 #define NO_CONFIG_H 1
3523 #define HAVE_SYS_QUOTAS 1
3524 #define HAVE_XFS_QUOTAS 1
3525 #include "${srcdir-.}/lib/sysquotas_xfs.c"
3526 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
3527 CPPFLAGS="$SAVE_CPPFLAGS"
3528 ])
3529 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
3530     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
3531         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
3532     fi
3533 fi
3534 fi
3535
3536 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
3537 SAVE_CPPFLAGS="$CPPFLAGS"
3538 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3539 AC_TRY_COMPILE([
3540 #include "confdefs.h"
3541 #define NO_PROTO_H 1
3542 #define NO_CONFIG_H 1
3543 #include "${srcdir-.}/smbd/quotas.c"
3544 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
3545 CPPFLAGS="$SAVE_CPPFLAGS"
3546 ])
3547 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
3548 AC_MSG_CHECKING(whether to use the old quota support)
3549     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
3550       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
3551         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3552         AC_MSG_RESULT(yes)
3553       else
3554         AC_MSG_RESULT(no)
3555       fi
3556     else
3557       AC_MSG_RESULT(no)
3558     fi
3559 fi
3560
3561 ####################
3562 # End of quota check samba_cv_RUN_QUOTA_TESTS
3563 fi
3564
3565 #################################################
3566 # check for experimental utmp accounting
3567
3568 AC_MSG_CHECKING(whether to support utmp accounting)
3569 WITH_UTMP=yes
3570 AC_ARG_WITH(utmp,
3571 [  --with-utmp             Include utmp accounting (default, if supported by OS)],
3572 [ case "$withval" in
3573   no)
3574                 WITH_UTMP=no
3575                 ;;
3576   *)
3577                 WITH_UTMP=yes
3578                 ;;
3579   esac ],
3580 )
3581
3582 # utmp requires utmp.h
3583 # Note similar check earlier, when checking utmp details.
3584
3585 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
3586         utmp_no_reason=", no utmp.h on $host_os"
3587         WITH_UTMP=no
3588 fi
3589
3590 # Display test results
3591
3592 if test x"$WITH_UTMP" = x"yes"; then
3593         AC_MSG_RESULT(yes)
3594         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
3595 else
3596         AC_MSG_RESULT(no$utmp_no_reason)
3597 fi
3598
3599 #################################################
3600 # choose native language(s) of man pages
3601 AC_MSG_CHECKING(chosen man pages' language(s))
3602 AC_ARG_WITH(manpages-langs,
3603 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
3604 [ case "$withval" in
3605   yes|no)
3606     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
3607     manlangs="en"
3608   ;;
3609   *)
3610     manlangs="$withval"
3611   ;;
3612   esac
3613
3614   AC_MSG_RESULT($manlangs)
3615   manlangs=`echo $manlangs | sed "s/,/ /g"`   # replacing commas with spaces to produce a list
3616   AC_SUBST(manlangs)],
3617
3618   [manlangs="en"
3619   AC_MSG_RESULT($manlangs)
3620   AC_SUBST(manlangs)]
3621 )
3622
3623 #################################################
3624 # should we build libsmbclient?
3625
3626 INSTALLCLIENTCMD_SH=:
3627 INSTALLCLIENTCMD_A=:
3628 INSTALLCLIENT=
3629 LIBSMBCLIENT_SHARED=
3630 LIBSMBCLIENT=
3631 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
3632 AC_ARG_WITH(libsmbclient,
3633 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
3634 [ case "$withval" in
3635   no) 
3636      AC_MSG_RESULT(no)
3637      ;;
3638   *)
3639      if test $BLDSHARED = true; then
3640         INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3641         ## build the static version of libsmbclient as well
3642         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3643         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3644         LIBSMBCLIENT=libsmbclient
3645         AC_MSG_RESULT(yes)
3646      else
3647         enable_static=yes
3648         AC_MSG_RESULT(no shared library support -- will supply static library)
3649      fi
3650      if test $enable_static = yes; then
3651         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3652         LIBSMBCLIENT=libsmbclient
3653      fi
3654      INSTALLCLIENT=installclientlib
3655      ;;
3656   esac ],
3657 [
3658 # if unspecified, default is to built it iff possible.
3659   if test $BLDSHARED = true; then
3660      INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3661      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3662      LIBSMBCLIENT=libsmbclient
3663      AC_MSG_RESULT(yes)
3664    else
3665      enable_static=yes
3666      AC_MSG_RESULT(no shared library support -- will supply static library)
3667    fi
3668    if test $enable_static = yes; then
3669      INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3670      LIBSMBCLIENT=libsmbclient
3671   fi]
3672   INSTALLCLIENT=installclientlib
3673 )
3674
3675
3676 #################################################
3677 # these tests are taken from the GNU fileutils package
3678 AC_CHECKING(how to get filesystem space usage)
3679 space=no
3680
3681 # Test for statvfs64.
3682 if test $space = no; then
3683   # SVR4
3684   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
3685   [AC_TRY_RUN([
3686 #if defined(HAVE_UNISTD_H)
3687 #include <unistd.h>
3688 #endif
3689 #include <sys/types.h>
3690 #include <sys/statvfs.h>
3691   main ()
3692   {
3693     struct statvfs64 fsd;
3694     exit (statvfs64 (".", &fsd));
3695   }],
3696   fu_cv_sys_stat_statvfs64=yes,
3697   fu_cv_sys_stat_statvfs64=no,
3698   fu_cv_sys_stat_statvfs64=cross)])
3699   if test $fu_cv_sys_stat_statvfs64 = yes; then
3700     space=yes
3701     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
3702   fi
3703 fi
3704
3705 # Perform only the link test since it seems there are no variants of the
3706 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
3707 # because that got a false positive on SCO OSR5.  Adding the declaration
3708 # of a `struct statvfs' causes this test to fail (as it should) on such
3709 # systems.  That system is reported to work fine with STAT_STATFS4 which
3710 # is what it gets when this test fails.
3711 if test $space = no; then
3712   # SVR4
3713   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
3714                  [AC_TRY_LINK([#include <sys/types.h>
3715 #include <sys/statvfs.h>],
3716                               [struct statvfs fsd; statvfs (0, &fsd);],
3717                               fu_cv_sys_stat_statvfs=yes,
3718                               fu_cv_sys_stat_statvfs=no)])
3719   if test $fu_cv_sys_stat_statvfs = yes; then
3720     space=yes
3721     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
3722   fi
3723 fi
3724
3725 if test $space = no; then
3726   # DEC Alpha running OSF/1
3727   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
3728   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
3729   [AC_TRY_RUN([
3730 #include <sys/param.h>
3731 #include <sys/types.h>
3732 #include <sys/mount.h>
3733   main ()
3734   {
3735     struct statfs fsd;
3736     fsd.f_fsize = 0;
3737     exit (statfs (".", &fsd, sizeof (struct statfs)));
3738   }],
3739   fu_cv_sys_stat_statfs3_osf1=yes,
3740   fu_cv_sys_stat_statfs3_osf1=no,
3741   fu_cv_sys_stat_statfs3_osf1=no)])
3742   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
3743   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
3744     space=yes
3745     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
3746   fi
3747 fi
3748
3749 if test $space = no; then
3750 # AIX
3751   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
3752 member (AIX, 4.3BSD)])
3753   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
3754   [AC_TRY_RUN([
3755 #ifdef HAVE_SYS_PARAM_H
3756 #include <sys/param.h>
3757 #endif
3758 #ifdef HAVE_SYS_MOUNT_H
3759 #include <sys/mount.h>
3760 #endif
3761 #ifdef HAVE_SYS_VFS_H
3762 #include <sys/vfs.h>
3763 #endif
3764   main ()
3765   {
3766   struct statfs fsd;
3767   fsd.f_bsize = 0;
3768   exit (statfs (".", &fsd));
3769   }],
3770   fu_cv_sys_stat_statfs2_bsize=yes,
3771   fu_cv_sys_stat_statfs2_bsize=no,
3772   fu_cv_sys_stat_statfs2_bsize=no)])
3773   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
3774   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
3775     space=yes
3776     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
3777   fi
3778 fi
3779
3780 if test $space = no; then
3781 # SVR3
3782   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
3783   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
3784   [AC_TRY_RUN([#include <sys/types.h>
3785 #include <sys/statfs.h>
3786   main ()
3787   {
3788   struct statfs fsd;
3789   exit (statfs (".", &fsd, sizeof fsd, 0));
3790   }],
3791     fu_cv_sys_stat_statfs4=yes,
3792     fu_cv_sys_stat_statfs4=no,
3793     fu_cv_sys_stat_statfs4=no)])
3794   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
3795   if test $fu_cv_sys_stat_statfs4 = yes; then
3796     space=yes
3797     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
3798   fi
3799 fi
3800
3801 if test $space = no; then
3802 # 4.4BSD and NetBSD
3803   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
3804 member (4.4BSD and NetBSD)])
3805   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
3806   [AC_TRY_RUN([#include <sys/types.h>
3807 #ifdef HAVE_SYS_PARAM_H
3808 #include <sys/param.h>
3809 #endif
3810 #ifdef HAVE_SYS_MOUNT_H
3811 #include <sys/mount.h>
3812 #endif
3813   main ()
3814   {
3815   struct statfs fsd;
3816   fsd.f_fsize = 0;
3817   exit (statfs (".", &fsd));
3818   }],
3819   fu_cv_sys_stat_statfs2_fsize=yes,
3820   fu_cv_sys_stat_statfs2_fsize=no,
3821   fu_cv_sys_stat_statfs2_fsize=no)])
3822   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
3823   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
3824     space=yes
3825         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
3826   fi
3827 fi
3828
3829 if test $space = no; then
3830   # Ultrix
3831   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
3832   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
3833   [AC_TRY_RUN([#include <sys/types.h>
3834 #ifdef HAVE_SYS_PARAM_H
3835 #include <sys/param.h>
3836 #endif
3837 #ifdef HAVE_SYS_MOUNT_H
3838 #include <sys/mount.h>
3839 #endif
3840 #ifdef HAVE_SYS_FS_TYPES_H
3841 #include <sys/fs_types.h>
3842 #endif
3843   main ()
3844   {
3845   struct fs_data fsd;
3846   /* Ultrix's statfs returns 1 for success,
3847      0 for not mounted, -1 for failure.  */
3848   exit (statfs (".", &fsd) != 1);
3849   }],
3850   fu_cv_sys_stat_fs_data=yes,
3851   fu_cv_sys_stat_fs_data=no,
3852   fu_cv_sys_stat_fs_data=no)])
3853   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
3854   if test $fu_cv_sys_stat_fs_data = yes; then
3855     space=yes
3856     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
3857   fi
3858 fi
3859
3860 #
3861 # As a gating factor for large file support, in order to
3862 # use <4GB files we must have the following minimal support
3863 # available.
3864 # long long, and a 64 bit off_t or off64_t.
3865 # If we don't have all of these then disable large
3866 # file support.
3867 #
3868 AC_MSG_CHECKING([if large file support can be enabled])
3869 AC_TRY_COMPILE([
3870 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
3871 #include <sys/types.h>
3872 #else
3873 __COMPILE_ERROR_
3874 #endif
3875 ],
3876 [int i],
3877 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
3878 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
3879         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
3880 fi
3881 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
3882
3883 AC_ARG_WITH(spinlocks, 
3884 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
3885 if test "x$with_spinlocks" = "xyes"; then
3886     AC_DEFINE(USE_SPINLOCKS,1,[Whether to use spin locks instead of fcntl locks])
3887
3888     case "$host_cpu" in
3889         sparc)
3890             AC_DEFINE(SPARC_SPINLOCKS,1,[Whether to use sparc spinlocks])
3891             ;;
3892
3893         i386|i486|i586|i686)
3894             AC_DEFINE(INTEL_SPINLOCKS,1,[Whether to use intel spinlocks])
3895             ;;
3896
3897         mips)
3898             AC_DEFINE(MIPS_SPINLOCKS,1,[Whether to use mips spinlocks])
3899             ;;
3900
3901         powerpc)
3902             AC_DEFINE(POWERPC_SPINLOCKS,1,[Whether to use powerpc spinlocks])
3903             ;;
3904     esac
3905 fi
3906
3907 #################################################
3908 # check for ACL support
3909
3910 AC_MSG_CHECKING(whether to support ACLs)
3911 AC_ARG_WITH(acl-support,
3912 [  --with-acl-support      Include ACL support (default=no)],
3913 [ case "$withval" in
3914   yes)
3915
3916         case "$host_os" in
3917         *sysv5*)
3918                 AC_MSG_RESULT(Using UnixWare ACLs)
3919                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
3920                 ;;
3921         *solaris*)
3922                 AC_MSG_RESULT(Using solaris ACLs)
3923                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
3924                 ;;
3925         *hpux*)
3926                 AC_MSG_RESULT(Using HPUX ACLs)
3927                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
3928                 ;;
3929         *irix*)
3930                 AC_MSG_RESULT(Using IRIX ACLs)
3931                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
3932                 ;;
3933         *aix*)
3934                 AC_MSG_RESULT(Using AIX ACLs)
3935                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
3936                 ;;
3937         *osf*)
3938                 AC_MSG_RESULT(Using Tru64 ACLs)
3939                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
3940                 ACL_LIBS="$ACL_LIBS -lpacl"
3941                 ;;
3942         *freebsd5*)
3943                 AC_MSG_RESULT(Using FreeBSD posix ACLs)
3944                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
3945                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
3946                 ;;
3947         *linux*)
3948                 AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
3949                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
3950                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
3951                 acl_LIBS=$LIBS
3952                 LIBS="$LIBS -lacl"
3953                 AC_TRY_LINK([#include <sys/types.h>
3954 #include <sys/acl.h>],
3955 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
3956 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
3957                 LIBS=$acl_LIBS])
3958                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
3959                                 AC_MSG_RESULT(Using posix ACLs)
3960                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
3961                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
3962                                 acl_LIBS=$LIBS
3963                                 LIBS="$LIBS -lacl"
3964                                 AC_TRY_LINK([#include <sys/types.h>
3965 #include <sys/acl.h>],
3966 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
3967 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
3968                                 LIBS=$acl_LIBS])
3969                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
3970                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
3971                                 fi
3972                         fi
3973             ;;
3974          *)
3975                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
3976                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
3977                 acl_LIBS=$LIBS
3978                 LIBS="$LIBS -lacl"
3979                 AC_TRY_LINK([#include <sys/types.h>
3980 #include <sys/acl.h>],
3981 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
3982 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
3983                 LIBS=$acl_LIBS])
3984                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
3985                                 AC_MSG_RESULT(Using posix ACLs)
3986                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
3987                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
3988                                 acl_LIBS=$LIBS
3989                                 LIBS="$LIBS -lacl"
3990                                 AC_TRY_LINK([#include <sys/types.h>
3991 #include <sys/acl.h>],
3992 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
3993 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
3994                                 LIBS=$acl_LIBS])
3995                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
3996                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
3997                                 fi
3998                         fi
3999             ;;
4000         esac
4001         ;;
4002   *)
4003     AC_MSG_RESULT(no)
4004     AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
4005     ;;
4006   esac ],
4007   AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
4008   AC_MSG_RESULT(no)
4009 )
4010
4011 #################################################
4012 # check for sendfile support
4013
4014 with_sendfile_support=yes
4015 AC_MSG_CHECKING(whether to check to support sendfile)
4016 AC_ARG_WITH(sendfile-support,
4017 [  --with-sendfile-support Check for sendfile support (default=yes)],
4018 [ case "$withval" in
4019   yes)
4020
4021         AC_MSG_RESULT(yes);
4022
4023         case "$host_os" in
4024         *linux*)
4025                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4026                 AC_TRY_LINK([#include <sys/sendfile.h>],
4027 [\
4028 int tofd, fromfd;
4029 off64_t offset;
4030 size_t total;
4031 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
4032 ],
4033 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4034
4035                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
4036                 AC_TRY_LINK([#include <sys/sendfile.h>],
4037 [\
4038 int tofd, fromfd;
4039 off_t offset;
4040 size_t total;
4041 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4042 ],
4043 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4044
4045 # Try and cope with broken Linux sendfile....
4046                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
4047                 AC_TRY_LINK([\
4048 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
4049 #undef _FILE_OFFSET_BITS
4050 #endif
4051 #include <sys/sendfile.h>],
4052 [\
4053 int tofd, fromfd;
4054 off_t offset;
4055 size_t total;
4056 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4057 ],
4058 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
4059
4060         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
4061                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
4062                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
4063                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
4064         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4065                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4066                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
4067                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
4068         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
4069                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
4070                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
4071         else
4072                 AC_MSG_RESULT(no);
4073         fi
4074
4075         ;;
4076         *freebsd* | *DragonFly* )
4077                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
4078                 AC_TRY_LINK([\
4079 #include <sys/types.h>
4080 #include <unistd.h>
4081 #include <sys/socket.h>
4082 #include <sys/uio.h>],
4083 [\
4084         int fromfd, tofd, ret, total=0;
4085         off_t offset, nwritten;
4086         struct sf_hdtr hdr;
4087         struct iovec hdtrl;
4088         hdr.headers = &hdtrl;
4089         hdr.hdr_cnt = 1;
4090         hdr.trailers = NULL;
4091         hdr.trl_cnt = 0;
4092         hdtrl.iov_base = NULL;
4093         hdtrl.iov_len = 0;
4094         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
4095 ],
4096 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4097
4098         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4099                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
4100                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
4101                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4102         else
4103                 AC_MSG_RESULT(no);
4104         fi
4105         ;;
4106
4107         *hpux*)
4108                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4109                 AC_TRY_LINK([\
4110 #include <sys/socket.h>
4111 #include <sys/uio.h>],
4112 [\
4113         int fromfd, tofd;
4114         size_t total=0;
4115         struct iovec hdtrl[2];
4116         ssize_t nwritten;
4117         off64_t offset;
4118
4119         hdtrl[0].iov_base = 0;
4120         hdtrl[0].iov_len = 0;
4121
4122         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
4123 ],
4124 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4125         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
4126                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
4127                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
4128                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4129         else
4130                 AC_MSG_RESULT(no);
4131         fi
4132
4133                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
4134                 AC_TRY_LINK([\
4135 #include <sys/socket.h>
4136 #include <sys/uio.h>],
4137 [\
4138         int fromfd, tofd;
4139         size_t total=0;
4140         struct iovec hdtrl[2];
4141         ssize_t nwritten;
4142         off_t offset;
4143
4144         hdtrl[0].iov_base = 0;
4145         hdtrl[0].iov_len = 0;
4146
4147         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
4148 ],
4149 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4150         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4151                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4152                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
4153                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4154         else
4155                 AC_MSG_RESULT(no);
4156         fi
4157         ;;
4158
4159         *solaris*)
4160                 AC_CHECK_LIB(sendfile,sendfilev)
4161                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
4162                 AC_TRY_LINK([\
4163 #include <sys/sendfile.h>],
4164 [\
4165         int sfvcnt;
4166         size_t xferred;
4167         struct sendfilevec vec[2];
4168         ssize_t nwritten;
4169         int tofd;
4170
4171         sfvcnt = 2;
4172
4173         vec[0].sfv_fd = SFV_FD_SELF;
4174         vec[0].sfv_flag = 0;
4175         vec[0].sfv_off = 0;
4176         vec[0].sfv_len = 0;
4177
4178         vec[1].sfv_fd = 0;
4179         vec[1].sfv_flag = 0;
4180         vec[1].sfv_off = 0;
4181         vec[1].sfv_len = 0;
4182         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
4183 ],
4184 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
4185
4186         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
4187                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
4188                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
4189                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4190         else
4191                 AC_MSG_RESULT(no);
4192         fi
4193
4194                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
4195                 AC_TRY_LINK([\
4196 #include <sys/sendfile.h>],
4197 [\
4198         int sfvcnt;
4199         size_t xferred;
4200         struct sendfilevec vec[2];
4201         ssize_t nwritten;
4202         int tofd;
4203
4204         sfvcnt = 2;
4205
4206         vec[0].sfv_fd = SFV_FD_SELF;
4207         vec[0].sfv_flag = 0;
4208         vec[0].sfv_off = 0;
4209         vec[0].sfv_len = 0;
4210
4211         vec[1].sfv_fd = 0;
4212         vec[1].sfv_flag = 0;
4213         vec[1].sfv_off = 0;
4214         vec[1].sfv_len = 0;
4215         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
4216 ],
4217 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
4218
4219         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
4220                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
4221                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
4222                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
4223         else
4224                 AC_MSG_RESULT(no);
4225         fi
4226         ;;
4227
4228         *)
4229         ;;
4230         esac
4231         ;;
4232   *)
4233     AC_MSG_RESULT(no)
4234     ;;
4235   esac ],
4236   AC_MSG_RESULT(yes)
4237 )
4238
4239
4240 #################################################
4241 # Check whether winbind is supported on this platform.  If so we need to
4242 # build and install client programs, sbin programs and shared libraries
4243
4244 AC_MSG_CHECKING(whether to build winbind)
4245
4246 # Initially, the value of $host_os decides whether winbind is supported
4247
4248 HAVE_WINBIND=yes
4249
4250 # Define the winbind shared library name and any specific linker flags
4251 # it needs to be built with.
4252
4253 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
4254 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
4255 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
4256
4257 case "$host_os" in
4258         *linux*)
4259                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
4260                 ;;
4261         *freebsd5*)
4262                 # FreeBSD winbind client is implemented as a wrapper around
4263                 # the Linux version.
4264                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
4265                     nsswitch/winbind_nss_linux.o"
4266                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
4267                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
4268                 ;;
4269         *irix*)
4270                 # IRIX has differently named shared libraries
4271                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
4272                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
4273                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
4274                 ;;
4275         *solaris*)
4276                 # Solaris winbind client is implemented as a wrapper around
4277                 # the Linux version.
4278                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
4279                     nsswitch/winbind_nss_linux.o"
4280                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
4281                 ;;
4282         *hpux11*)
4283                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
4284                 ;;
4285         *aix*)
4286                 # AIX has even differently named shared libraries.  No
4287                 # WINS support has been implemented yet.
4288                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
4289                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
4290                 WINBIND_NSS="nsswitch/WINBIND"
4291                 WINBIND_WINS_NSS=""
4292                 ;;
4293         *)
4294                 HAVE_WINBIND=no
4295                 winbind_no_reason=", unsupported on $host_os"
4296                 ;;
4297 esac
4298
4299 AC_SUBST(WINBIND_NSS)
4300 AC_SUBST(WINBIND_WINS_NSS)
4301 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
4302 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
4303 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
4304
4305 # Check the setting of --with-winbind
4306
4307 AC_ARG_WITH(winbind,
4308 [  --with-winbind          Build winbind (default, if supported by OS)],
4309
4310   case "$withval" in
4311         yes)
4312                 HAVE_WINBIND=yes
4313                 ;;
4314         no)
4315                 HAVE_WINBIND=no
4316                 winbind_reason=""
4317                 ;;
4318   esac ],
4319 )
4320
4321 # We need unix domain sockets for winbind
4322
4323 if test x"$HAVE_WINBIND" = x"yes"; then
4324         if test x"$samba_cv_unixsocket" = x"no"; then
4325                 winbind_no_reason=", no unix domain socket support on $host_os"
4326                 HAVE_WINBIND=no
4327         fi
4328 fi
4329
4330 # Display test results
4331
4332 if test x"$HAVE_WINBIND" = x"yes"; then
4333         AC_MSG_RESULT(yes)
4334         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
4335
4336         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
4337         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
4338         if test $BLDSHARED = true; then
4339                 SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
4340
4341                 if test x"$with_pam" = x"yes"; then
4342                         SHLIB_PROGS="$SHLIB_PROGS nsswitch/pam_winbind.$SHLIBEXT"
4343                 fi
4344         fi
4345 else
4346         AC_MSG_RESULT(no$winbind_no_reason)
4347 fi
4348
4349 # Solaris has some extra fields in struct passwd that need to be
4350 # initialised otherwise nscd crashes.  
4351  
4352 AC_CHECK_MEMBER(struct passwd.pw_comment,
4353                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
4354                 [#include <pwd.h>])
4355
4356 AC_CHECK_MEMBER(struct passwd.pw_age,
4357                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
4358                 [#include <pwd.h>])
4359
4360 # AIX 4.3.x and 5.1 do not have as many members in
4361 # struct secmethod_table as AIX 5.2
4362 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
4363        [#include <usersec.h>])
4364 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
4365        [#include <usersec.h>])
4366
4367
4368 #################################################
4369 # Check to see if we should use the included popt 
4370
4371 AC_ARG_WITH(included-popt,
4372 [  --with-included-popt    use bundled popt library, not from system],
4373
4374   case "$withval" in
4375         yes)
4376                 INCLUDED_POPT=yes
4377                 ;;
4378         no)
4379                 INCLUDED_POPT=no
4380                 ;;
4381   esac ],
4382 )
4383 if test x"$INCLUDED_POPT" != x"yes"; then
4384     AC_CHECK_LIB(popt, poptGetContext,
4385                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
4386 fi
4387
4388 AC_MSG_CHECKING(whether to use included popt)
4389 if test x"$INCLUDED_POPT" = x"yes"; then
4390     AC_MSG_RESULT(yes)
4391     BUILD_POPT='$(POPT_OBJS)'
4392         POPTLIBS='$(POPT_OBJS)'
4393     FLAGS1="-I$srcdir/popt"
4394 else
4395     AC_MSG_RESULT(no)
4396         BUILD_POPT=""
4397     POPTLIBS="-lpopt"
4398 fi
4399 AC_SUBST(BUILD_POPT)
4400 AC_SUBST(POPTLIBS)
4401 AC_SUBST(FLAGS1)
4402
4403 #################################################
4404 # Check if the user wants Python
4405
4406 # At the moment, you can use this to set which Python binary to link
4407 # against.  (Libraries built for Python2.2 can't be used by 2.1,
4408 # though they can coexist in different directories.)  In the future
4409 # this might make the Python stuff be built by default.
4410
4411 # Defaulting python breaks the clean target if python isn't installed
4412
4413 PYTHON=
4414
4415 AC_ARG_WITH(python,
4416 [  --with-python=PYTHONNAME  build Python libraries],
4417 [ case "${withval-python}" in
4418   yes)
4419         PYTHON=python
4420         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
4421         ;;
4422   no)
4423         PYTHON=
4424         ;;
4425   *)
4426         PYTHON=${withval-python}
4427         ;;
4428   esac ])
4429 AC_SUBST(PYTHON)
4430
4431 for i in `echo $default_static_modules | sed -e's/,/ /g'`
4432 do
4433         eval MODULE_DEFAULT_$i=STATIC
4434 done
4435
4436 for i in `echo $default_shared_modules | sed -e's/,/ /g'`
4437 do
4438         dnl Fall back to static if we cannot build shared libraries
4439         eval MODULE_DEFAULT_$i=STATIC
4440
4441         if test $BLDSHARED = true; then
4442                 eval MODULE_DEFAULT_$i=SHARED
4443         fi
4444 done
4445
4446 dnl Always built these modules static
4447 MODULE_pdb_guest=STATIC
4448 MODULE_rpc_spoolss=STATIC
4449 MODULE_rpc_srv=STATIC
4450 MODULE_idmap_tdb=STATIC
4451
4452 AC_ARG_WITH(static-modules,
4453 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
4454 [ if test $withval; then
4455         for i in `echo $withval | sed -e's/,/ /g'`
4456         do
4457                 eval MODULE_$i=STATIC
4458         done
4459 fi ])
4460
4461 AC_ARG_WITH(shared-modules,
4462 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
4463 [ if test $withval; then
4464         for i in `echo $withval | sed -e's/,/ /g'`
4465         do
4466                         eval MODULE_$i=SHARED
4467         done
4468 fi ])
4469
4470 ###########################################################################
4471 ## contributed pdb_modules
4472
4473 SMB_MODULE(pdb_xml, passdb/pdb_xml.o, "bin/xml.$SHLIBEXT", PDB,
4474                   [ PASSDB_LIBS="$PASSDB_LIBS $XML_LIBS" ] )
4475 SMB_MODULE(pdb_mysql, passdb/pdb_mysql.o, "bin/mysql.$SHLIBEXT", PDB, 
4476                    [ PASSDB_LIBS="$PASSDB_LIBS $MYSQL_LIBS" ]   )
4477 SMB_MODULE(pdb_pgsql, passdb/pdb_pgsql.o, "bin/pgsql.$SHLIBEXT", PDB, 
4478                    [ PASSDB_LIBS="$PASSDB_LIBS $PGSQL_LIBS" ]   )
4479
4480 ## end of contributed pdb_modules
4481 ###########################################################################
4482
4483 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o, "bin/ldapsam.$SHLIBEXT", PDB, 
4484                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
4485 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
4486 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
4487 SMB_MODULE(pdb_guest, passdb/pdb_guest.o, "bin/guest.$SHLIBEXT", PDB)
4488 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
4489
4490 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
4491 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
4492 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
4493 SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
4494 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
4495 SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
4496 SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
4497 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
4498 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
4499 SMB_MODULE(rpc_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
4500 SMB_SUBSYSTEM(RPC,smbd/server.o)
4501
4502 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/idmap_ldap.$SHLIBEXT", IDMAP)
4503 SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/idmap_tdb.$SHLIBEXT", IDMAP)
4504 SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/idmap_rid.$SHLIBEXT", IDMAP)
4505 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
4506
4507 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
4508 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
4509 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
4510 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
4511 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
4512
4513 SMB_MODULE(auth_rhosts, \$(AUTH_RHOSTS_OBJ), "bin/rhosts.$SHLIBEXT", AUTH)
4514 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
4515 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
4516 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
4517 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
4518 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
4519 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
4520 SMB_SUBSYSTEM(AUTH,auth/auth.o)
4521
4522 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
4523 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
4524 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
4525 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
4526 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
4527 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
4528 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
4529 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
4530 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
4531 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
4532 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
4533 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
4534 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
4535
4536 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
4537
4538 #################################################
4539 # do extra things if we are running insure
4540
4541 if test "${ac_cv_prog_CC}" = "insure"; then
4542         CPPFLAGS="$CPPFLAGS -D__INSURE__"
4543 fi
4544
4545 #################################################
4546 # Display summary of libraries detected
4547
4548 AC_MSG_RESULT([Using libraries:])
4549 AC_MSG_RESULT([    LIBS = $LIBS])
4550 if test x"$with_ads_support" != x"no"; then
4551    AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
4552 fi
4553 if test x"$with_ldap_support" != x"no"; then
4554    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
4555 fi
4556 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
4557
4558 #################################################
4559 # final configure stuff
4560
4561 AC_MSG_CHECKING([configure summary])
4562 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
4563            AC_MSG_RESULT(yes),
4564            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
4565            AC_MSG_WARN([cannot run when cross-compiling]))
4566
4567 builddir=`pwd`
4568 AC_SUBST(builddir)
4569
4570 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
4571 LIB_REMOVE_USR_LIB(LDFLAGS)
4572 LIB_REMOVE_USR_LIB(LIBS)
4573
4574 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
4575 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
4576 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
4577
4578 AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh)
4579
4580 #################################################
4581 # Print very concise instructions on building/use
4582 if test "x$enable_dmalloc" = xyes
4583 then
4584         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
4585         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
4586 fi