r18638: This is an attempt to fix the AIX build. Jeremy, as you are busy talking
[jra/samba/.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 rootsbindir="\${SBINDIR}"
26 lockdir="\${VARDIR}/locks"
27 piddir="\${VARDIR}/locks"
28 test "${mandir}" || mandir="\${prefix}/man"
29 logfilebase="\${VARDIR}"
30 privatedir="\${prefix}/private"
31 test "${libdir}" || libdir="\${prefix}/lib"
32 pammodulesdir="\${LIBDIR}/security"
33 configdir="\${LIBDIR}"
34 swatdir="\${prefix}/swat"
35
36 AC_ARG_WITH(fhs, 
37 [  --with-fhs              Use FHS-compliant paths (default=no)],
38 [ case "$withval" in
39   yes)
40     lockdir="\${VARDIR}/lib/samba"
41     piddir="\${VARDIR}/run"
42     mandir="\${prefix}/share/man"
43     logfilebase="\${VARDIR}/log/samba"
44     privatedir="\${CONFIGDIR}/private"
45     libdir="\${prefix}/lib/samba"
46     configdir="${sysconfdir}/samba"
47     swatdir="\${DATADIR}/samba/swat"
48     ;;
49   esac])
50
51 #################################################
52 # set private directory location
53 AC_ARG_WITH(privatedir,
54 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
55 [ case "$withval" in
56   yes|no)
57   #
58   # Just in case anybody calls it without argument
59   #
60     AC_MSG_WARN([--with-privatedir called without argument - will use default])
61   ;;
62   * )
63     privatedir="$withval"
64     ;;
65   esac])
66
67 #################################################
68 # set root sbin directory location
69 AC_ARG_WITH(rootsbindir,
70 [  --with-rootsbindir=DIR  Which directory to use for root sbin ($ac_default_prefix/sbin)],
71 [ case "$withval" in
72   yes|no)
73   #
74   # Just in case anybody calls it without argument
75   #
76     AC_MSG_WARN([--with-rootsbindir called without argument - will use default])
77   ;;
78   * )
79     rootsbindir="$withval"
80     ;;
81   esac])
82
83 #################################################
84 # set lock directory location
85 AC_ARG_WITH(lockdir,
86 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
87 [ case "$withval" in
88   yes|no)
89   #
90   # Just in case anybody calls it without argument
91   #
92     AC_MSG_WARN([--with-lockdir called without argument - will use default])
93   ;;
94   * )
95     lockdir="$withval"
96     ;;
97   esac])
98
99 #################################################
100 # set pid directory location
101 AC_ARG_WITH(piddir,
102 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
103 [ case "$withval" in
104   yes|no)
105   #
106   # Just in case anybody calls it without argument
107   #
108     AC_MSG_WARN([--with-piddir called without argument - will use default])
109   ;;
110   * )
111     piddir="$withval"
112     ;;
113   esac])
114
115 #################################################
116 # set SWAT directory location
117 AC_ARG_WITH(swatdir,
118 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
119 [ case "$withval" in
120   yes|no)
121   #
122   # Just in case anybody does it
123   #
124     AC_MSG_WARN([--with-swatdir called without argument - will use default])
125   ;;
126   * )
127     swatdir="$withval"
128     ;;
129   esac])
130
131 #################################################
132 # set configuration directory location
133 AC_ARG_WITH(configdir,
134 [  --with-configdir=DIR    Where to put configuration files ($libdir)],
135 [ case "$withval" in
136   yes|no)
137   #
138   # Just in case anybody does it
139   #
140     AC_MSG_WARN([--with-configdir called without argument - will use default])
141   ;;
142   * )
143     configdir="$withval"
144     ;;
145   esac])
146
147 #################################################
148 # set log directory location
149 AC_ARG_WITH(logfilebase,
150 [  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
151 [ case "$withval" in
152   yes|no)
153   #
154   # Just in case anybody does it
155   #
156     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
157   ;;
158   * )
159     logfilebase="$withval"
160     ;;
161   esac])
162
163 #################################################
164 # set lib directory location
165 AC_ARG_WITH(libdir,
166 [  --with-libdir=DIR       Where to put libdir ($libdir)],
167 [ case "$withval" in
168   yes|no)
169   #
170   # Just in case anybody does it
171   #
172     AC_MSG_WARN([--with-libdir without argument - will use default])
173   ;;
174   * )
175     libdir="$withval"
176     ;;
177   esac])
178
179 #################################################
180 # set PAM modules directory location
181 AC_ARG_WITH(pammodulesdir,
182 [  --with-pammodulesdir=DIR  Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)],
183 [ case "$withval" in
184   yes|no)
185   #
186   # Just in case anybody calls it without argument
187   #
188     AC_MSG_WARN([--with-pammodulesdir called without argument - will use default])
189   ;;
190   * )
191     pammodulesdir="$withval"
192     ;;
193   esac])
194
195 #################################################
196 # set man directory location
197 AC_ARG_WITH(mandir,
198 [  --with-mandir=DIR       Where to put man pages ($mandir)],
199 [ case "$withval" in
200   yes|no)
201   #
202   # Just in case anybody does it
203   #
204     AC_MSG_WARN([--with-mandir without argument - will use default])
205   ;;
206   * )
207     mandir="$withval"
208     ;;
209   esac])
210
211 AC_ARG_WITH(cfenc,
212 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
213                           for optimization (Mac OS X/Darwin only)],
214 [
215 # May be in source $withval/CoreFoundation/StringEncodings.subproj.
216 # Should have been in framework $withval/CoreFoundation.framework/Headers.
217 for d in \
218     $withval/CoreFoundation/StringEncodings.subproj \
219     $withval/StringEncodings.subproj \
220     $withval/CoreFoundation.framework/Headers \
221     $withval/Headers \
222     $withval
223 do
224     if test -r $d/CFStringEncodingConverter.h; then
225         ln -sfh $d include/CoreFoundation
226     fi
227 done
228 ])
229
230 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
231 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/tdb/include"
232 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
233 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
234
235 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/popt"
236
237 AC_SUBST(configdir)
238 AC_SUBST(lockdir)
239 AC_SUBST(piddir)
240 AC_SUBST(logfilebase)
241 AC_SUBST(privatedir)
242 AC_SUBST(swatdir)
243 AC_SUBST(bindir)
244 AC_SUBST(sbindir)
245 AC_SUBST(rootsbindir)
246 AC_SUBST(pammodulesdir)
247
248 dnl Unique-to-Samba variables we'll be playing with.
249 AC_SUBST(SAMBA_CPPFLAGS)
250 AC_SUBST(SHELL)
251 AC_SUBST(LDSHFLAGS)
252 AC_SUBST(SONAMEFLAG)
253 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
254 AC_SUBST(SHLD)
255 AC_SUBST(HOST_OS)
256 AC_SUBST(PICFLAGS)
257 AC_SUBST(PICSUFFIX)
258 AC_SUBST(libc_cv_fpie)
259 AC_SUBST(PIE_CFLAGS)
260 AC_SUBST(PIE_LDFLAGS)
261 AC_SUBST(SHLIBEXT)
262 AC_SUBST(INSTALLLIBCMD_SH)
263 AC_SUBST(INSTALLLIBCMD_A)
264 AC_SUBST(UNINSTALLLIBCMD_SH)
265 AC_SUBST(UNINSTALLLIBCMD_A)
266 AC_SUBST(INSTALL_LIBMSRPC)
267 AC_SUBST(UNINSTALL_LIBMSRPC)
268 AC_SUBST(LIBMSRPC_SHARED)
269 AC_SUBST(LIBMSRPC)
270 AC_SUBST(INSTALL_LIBADDNS)
271 AC_SUBST(UNINSTALL_LIBADDNS)
272 AC_SUBST(LIBADDNS_SHARED)
273 AC_SUBST(LIBADDNS)
274 AC_SUBST(INSTALL_LIBSMBCLIENT)
275 AC_SUBST(UNINSTALL_LIBSMBCLIENT)
276 AC_SUBST(LIBSMBCLIENT_SHARED)
277 AC_SUBST(LIBSMBCLIENT)
278 AC_SUBST(INSTALL_LIBSMBSHAREMODES)
279 AC_SUBST(UNINSTALL_LIBSMBSHAREMODES)
280 AC_SUBST(LIBSMBSHAREMODES_SHARED)
281 AC_SUBST(LIBSMBSHAREMODES)
282 AC_SUBST(PRINT_LIBS)
283 AC_SUBST(AUTH_LIBS)
284 AC_SUBST(ACL_LIBS)
285 AC_SUBST(PASSDB_LIBS)
286 AC_SUBST(IDMAP_LIBS)
287 AC_SUBST(KRB5_LIBS)
288 AC_SUBST(UUID_LIBS)
289 AC_SUBST(LDAP_LIBS)
290 AC_SUBST(SHLIB_PROGS)
291 AC_SUBST(PAM_MODULES)
292 AC_SUBST(INSTALL_PAM_MODULES)
293 AC_SUBST(UNINSTALL_PAM_MODULES)
294 AC_SUBST(SMBWRAPPER)
295 AC_SUBST(SMBWRAP_OBJS)
296 AC_SUBST(SMBWRAP_INC)
297 AC_SUBST(EXTRA_BIN_PROGS)
298 AC_SUBST(CIFSMOUNT_PROGS)
299 AC_SUBST(INSTALL_CIFSMOUNT)
300 AC_SUBST(UNINSTALL_CIFSMOUNT)
301 AC_SUBST(EXTRA_SBIN_PROGS)
302 AC_SUBST(EXTRA_ALL_TARGETS)
303 AC_SUBST(CONFIG_LIBS)
304 AC_SUBST(NSCD_LIBS)
305
306 # Set defaults
307 PIE_CFLAGS=""
308 PIE_LDFLAGS=""
309 AC_ARG_ENABLE(pie, [  --enable-pie            Turn on pie support if available (default=yes)])
310
311 if test "x$enable_pie" != xno
312 then
313         AC_CACHE_CHECK(for -fPIE, libc_cv_fpie, [dnl
314                 cat > conftest.c <<EOF
315 int foo;
316 main () { return 0;}
317 EOF
318                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
319                 then
320                         libc_cv_fpie=yes
321                         PIE_CFLAGS="-fPIE"
322                         PIE_LDFLAGS="-pie"
323                 fi
324                 rm -f conftest*])
325 fi
326 if test "x$PIE_CFLAGS" = x
327 then
328         libc_cv_fpie=no
329 fi
330
331 AC_ARG_ENABLE(debug, 
332 [  --enable-debug          Turn on compiler debugging information (default=no)],
333     [if eval "test x$enable_debug = xyes"; then
334         CFLAGS="${CFLAGS} -g"
335     fi])
336
337 AC_SUBST(SOCKWRAP)
338 AC_ARG_ENABLE(socket-wrapper, 
339 [  --enable-socket-wrapper         Turn on socket wrapper library (default=no)],
340     [if eval "test x$enable_socket_wrapper = xyes"; then
341         AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
342         SOCKWRAP="\$(SOCKET_WRAPPER_OBJ)"
343     fi])
344
345 #################################################
346 # set prefix for 'make test'
347 selftest_prefix="./"
348 AC_SUBST(selftest_prefix)
349 AC_ARG_WITH(selftest-prefix,
350 [  --with-selftest-prefix=DIR    The prefix where make test will be runned ($selftest_prefix)],
351 [ case "$withval" in
352   yes|no)
353     AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
354   ;;
355   * )
356     selftest_prefix="$withval"
357     ;;
358   esac
359 ])
360
361 #################################################
362 # set path of samba4's smbtorture
363 smbtorture4_path=""
364 AC_SUBST(smbtorture4_path)
365 AC_ARG_WITH(smbtorture4_path,
366 [  --with-smbtorture4-path=PATH    The path to a samba4 smbtorture for make test (none)],
367 [ case "$withval" in
368   yes|no)
369     AC_MSG_ERROR([--with-smbtorture4-path should take a path])
370   ;;
371   * )
372     smbtorture4_path="$withval"
373     if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
374         AC_MSG_ERROR(['$smbtorture_path' does not  exist!]) 
375     fi
376   ;;
377  esac
378 ])
379
380 # compile with optimization and without debugging by default, but
381 # allow people to set their own preference.
382 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
383 # if it has no value.  This prevent *very* large debug binaries from occurring
384 # by default.
385 if test "x$CFLAGS" = x; then
386   CFLAGS="-O"
387 fi
388
389 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
390
391 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
392     [if eval "test x$enable_developer = xyes"; then
393         developer=yes
394         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
395         # Add -Wdeclaration-after-statement if compiler supports it
396         AC_CACHE_CHECK(
397           [that the C compiler understands -Wdeclaration-after-statement],
398           samba_cv_HAVE_Wdeclaration_after_statement, [
399           AC_TRY_RUN_STRICT([
400             int main(void)
401             {
402                 return 0;
403             }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
404             samba_cv_HAVE_Wdeclaration_after_statement=yes,
405             samba_cv_HAVE_Wdeclaration_after_statement=no,
406             samba_cv_HAVE_Wdeclaration_after_statement=cross)
407        ])
408        if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
409             CFLAGS="${CFLAGS} -Wdeclaration-after-statement"
410        fi
411     fi])
412
413 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
414     [if eval "test x$enable_krb5developer = xyes"; then
415         developer=yes
416         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
417     fi])
418
419 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
420
421 if test "x$enable_dmalloc" = xyes
422 then
423         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
424         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
425                   [Define to check invariants around some common functions])
426         LIBS="$LIBS -ldmalloc"  
427 fi
428
429 #################################################
430 # check for a shared memory profiling support
431 AC_MSG_CHECKING(whether to use profiling)
432 AC_ARG_WITH(profiling-data,
433 [  --with-profiling-data   Include gathering source code profile information (default=no)],
434 [ case "$withval" in
435   yes)
436     AC_MSG_RESULT(yes)
437     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
438     samba_cv_WITH_PROFILE=yes
439     ;;
440   *)
441     AC_MSG_RESULT(no)
442     samba_cv_WITH_PROFILE=no
443     ;;
444   esac ],
445   AC_MSG_RESULT(no)
446 )
447
448 dnl Checks for programs.
449
450 ##
451 ## for some reason this macro resets the CFLAGS
452 ## so save and restore
453 ##
454 OLD_CFLAGS=${CFLAGS}
455 AC_PROG_CC
456 CFLAGS=${OLD_CFLAGS}
457
458 OLD_CFLAGS=${CFLAGS}
459 AC_PROG_CPP
460 CFLAGS=${OLD_CFLAGS}
461
462 AC_PROG_INSTALL
463 AC_PROG_AWK
464 AC_PATH_PROG(PERL, perl)
465
466 AC_CHECK_TOOL(AR, ar)
467
468 dnl Check if we use GNU ld
469 LD=ld
470 AC_PROG_LD_GNU
471
472 dnl Certain versions of GNU ld the default is not to have the 
473 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
474 dnl warnings when building modules.
475 if test "$ac_cv_prog_gnu_ld" = "yes"; then
476         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
477         AC_MSG_CHECKING(GNU ld release date)
478         changequote(,)dnl
479         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'`
480         changequote([,])dnl
481         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
482         if test -n "$ac_cv_gnu_ld_date"; then
483         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
484                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
485         fi
486         else
487            AC_MSG_CHECKING(GNU ld release version)
488            changequote(,)dnl
489            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
490            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
491            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
492            changequote([,])dnl
493            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
494            AC_MSG_CHECKING(GNU ld release version major)
495            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
496            AC_MSG_CHECKING(GNU ld release version minor)
497            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
498            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
499              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
500            fi
501         fi
502 fi
503
504 dnl needed before AC_TRY_COMPILE
505 AC_ISC_POSIX
506
507 dnl look for executable suffix
508 AC_EXEEXT
509
510 dnl Check if C compiler understands -c and -o at the same time
511 AC_PROG_CC_C_O
512 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
513       BROKEN_CC=
514 else
515       BROKEN_CC=#
516 fi
517 AC_SUBST(BROKEN_CC)
518
519 dnl Check if the C compiler understands -Werror
520 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
521  AC_TRY_RUN_STRICT([
522   int main(void)
523   {
524         return 0;
525   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
526   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
527 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
528    Werror_FLAGS="-Werror"
529 else 
530 dnl Check if the C compiler understands -w2
531 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
532  AC_TRY_RUN_STRICT([
533   int main(void)
534   {
535         return 0;
536   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
537   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
538 if test x"$samba_cv_HAVE_w2" = x"yes"; then
539    Werror_FLAGS="-w2"
540 fi
541 fi
542
543 dnl Check if the C compiler understands volatile (it should, being ANSI).
544 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
545     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
546         samba_cv_volatile=yes,samba_cv_volatile=no)])
547 if test x"$samba_cv_volatile" = x"yes"; then
548    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
549 fi
550
551 dnl Figure out the flags to support named structure initializers
552
553 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])])
554
555 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
556 AC_MSG_CHECKING(uname -s)
557 AC_MSG_RESULT(${UNAME_S})
558
559 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
560 AC_MSG_CHECKING(uname -r)
561 AC_MSG_RESULT(${UNAME_R})
562
563 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
564 AC_MSG_CHECKING(uname -m)
565 AC_MSG_RESULT(${UNAME_M})
566
567 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
568 AC_MSG_CHECKING(uname -p)
569 AC_MSG_RESULT(${UNAME_P})
570
571 AC_CANONICAL_SYSTEM
572
573 dnl Add #include for broken IRIX header files
574   case "$host_os" in
575         *irix6*)
576                 AC_ADD_INCLUDE(<standards.h>)
577                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
578                         dnl Fix sensible defaults for MIPSPro compilers. The
579                         dnl error numbers are valid for the 7.3 compilers,
580                         dnl hopefully also valid for the 7.4 series.
581                         dnl
582                         dnl Bugzilla 3801. Force an error on warning 1035
583                         dnl so we don't incorrectly detect stdint.h. This
584                         dnl warning is emitted for #error directives.
585                         CFLAGS="$CFLAGS -diag_error 1035"
586                         dnl 1209: Controlling expression is constant
587                         dnl 1174: Function foo declared but never referenced
588                         dnl 3201: Parameter foo was never referenced
589                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
590                 fi
591         ;;
592 esac
593
594 AC_VALIDATE_CACHE_SYSTEM_TYPE
595
596 DYNEXP=
597
598 dnl Add modules that have to be built by default here
599 dnl These have to be built static:
600 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default"
601
602 dnl These are preferably build shared, and static if dlopen() is not available
603 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 auth_script"
604
605 if test "x$developer" = xyes; then
606    default_static_modules="$default_static_modules rpc_rpcecho"
607    default_shared_modules="$default_shared_modules charset_weird"
608 fi
609
610 #
611 # Config CPPFLAG settings for strange OS's that must be set
612 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
613 # case statement; its first reference must be unconditional.
614 #
615 case "$host_os" in
616 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
617     *hpux*)
618     
619       AC_PROG_CC_FLAG(Ae)
620       # mmap on HPUX is completely broken...
621       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
622       if test $ac_cv_prog_cc_Ae = yes; then
623         CPPFLAGS="$CPPFLAGS -Ae"
624       fi
625 #
626 # Defines needed for HPUX support.
627 # HPUX has bigcrypt but (sometimes?) doesn't use it for
628 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
629 #
630       case `uname -r` in
631                         *9*|*10*)
632                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
633                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
634                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
635                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
636                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
637                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
638                                 ;;
639                         *11*)
640                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
641                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
642                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
643                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
644                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
645                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
646                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
647                                 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Unix 98 sources -- needed for socklen_t in getsockopt on HP/UX 11])
648                                 ;;
649       esac
650       ;;
651
652 #
653 # CRAY Unicos has broken const handling
654        *unicos*)
655           AC_MSG_RESULT([disabling const])
656           CPPFLAGS="$CPPFLAGS -Dconst="
657           ;;
658         
659 #
660 # AIX4.x doesn't even admit to having large
661 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
662 #
663     *aix4*)
664           AC_MSG_RESULT([enabling large file support])
665       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
666           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
667       ;;    
668 #
669 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
670 # to the existance of large files..
671 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
672 # recommendations on large file support, however it makes the
673 # compile work using gcc 2.7 and 2.8, whereas using the Sun
674 # recommendation makes the compile fail on gcc2.7. JRA.
675 #
676 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
677 #
678         *solaris*)
679                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
680                 case `uname -r` in
681                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
682                                 AC_MSG_RESULT([no large file support])
683                                 ;;
684                         5.*)
685                         AC_MSG_RESULT([enabling large file support])
686                         if test "$ac_cv_prog_gcc" = yes; then
687                                 ${CC-cc} -v >conftest.c 2>&1
688                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
689                                 rm -fr conftest.c
690                                 case "$ac_cv_gcc_compiler_version_number" in
691                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
692                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
693                                                 LDFLAGS="$LDFLAGS -lthread"
694                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
695                                                 ;;
696                                         *)
697                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
698                                                 LDFLAGS="$LDFLAGS -lthread"
699                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
700                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
701                                                 ;;
702                                 esac
703                         else
704                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
705                                 LDFLAGS="$LDFLAGS -lthread"
706                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
707                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
708                         fi
709                         ;;
710                 esac
711                 ;;
712 #
713 # IRIX uses SYSV printing.  Make sure to set that here
714 #
715         *irix*)
716                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
717                 ;;
718         *freebsd*|*dragonfly*)
719                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
720                 ;;
721 #
722 # VOS may need to have POSIX support and System V compatibility enabled.
723 #
724     *vos*)
725     case "$CPPFLAGS" in
726           *-D_POSIX_C_SOURCE*)
727                 ;;
728           *)
729                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
730                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
731                 ;;
732     esac
733     case "$CPPFLAGS" in
734           *-D_SYSV*|*-D_SVID_SOURCE*)
735                 ;;
736           *)
737                 CPPFLAGS="$CPPFLAGS -D_SYSV"
738                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
739     esac
740     ;;
741 #
742 # Tests needed for SINIX large file support.
743 #
744     *sysv4*)
745       if test $host = mips-sni-sysv4 ; then
746         AC_MSG_CHECKING([for LFS support])
747         old_CPPFLAGS="$CPPFLAGS"
748         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
749         AC_TRY_RUN([
750 #include <unistd.h>
751 main () {
752 #if _LFS64_LARGEFILE == 1
753 exit(0);
754 #else
755 exit(1);
756 #endif
757 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
758         CPPFLAGS="$old_CPPFLAGS"
759         if test x$SINIX_LFS_SUPPORT = xyes ; then
760           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
761                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
762           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
763           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
764           LIBS="`getconf LFS64_LIBS` $LIBS"
765         fi
766       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
767       fi
768     ;;
769
770 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
771 #
772     *linux*)
773         AC_MSG_CHECKING([for LFS support])
774         old_CPPFLAGS="$CPPFLAGS"
775         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
776        AC_TRY_RUN([
777 #include <unistd.h>
778 #include <sys/utsname.h>
779 #include <string.h>
780 #include <stdlib.h>
781 main() {
782 #if _LFS64_LARGEFILE == 1
783        struct utsname uts;
784        char *release;
785        int major, minor;
786
787        /* Ensure this is glibc 2.2 or higher */
788 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
789        int libc_major = __GLIBC__;
790        int libc_minor = __GLIBC_MINOR__;
791
792        if (libc_major < 2)
793               exit(1);
794        if (libc_minor < 2)
795               exit(1);
796 #endif
797
798        /* Ensure this is kernel 2.4 or higher */
799
800        uname(&uts);
801        release = strdup(uts.release);
802        major = atoi(strsep(&release, "."));
803        minor = atoi(strsep(&release, "."));
804
805        if (major > 2 || (major == 2 && minor > 3))
806                exit(0);
807        exit(1);
808 #else
809        exit(1);
810 #endif
811 }
812 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
813         CPPFLAGS="$old_CPPFLAGS"
814         if test x$LINUX_LFS_SUPPORT = xyes ; then
815                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
816                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
817                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
818                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
819         fi
820         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
821         ;;
822
823 #
824 # MacOS X is the *only* system that uses compose character in utf8. This
825 # is so horribly broken....
826 #
827     *darwin*)
828         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
829 # Add Fink directories for various packages, like dlcompat.
830 # Note: iconv does that explicitly below, but other packages
831 # don't.
832         CPPFLAGS="$CPPFLAGS -I/sw/include"
833         LDFLAGS="$LDFLAGS -L/sw/lib"
834
835 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
836 # use that instead of plain dlsym.
837
838         AC_CHECK_LIB(dl,dlopen)
839         AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
840
841 # Add a system specific charset module.
842
843         default_shared_modules="$default_shared_modules charset_macosxfs"
844         ;;
845     *hurd*)
846         AC_MSG_CHECKING([for LFS support])
847         old_CPPFLAGS="$CPPFLAGS"
848         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
849         AC_TRY_RUN([
850 #include <unistd.h>
851 main () {
852 #if _LFS64_LARGEFILE == 1
853 exit(0);
854 #else
855 exit(1);
856 #endif
857 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
858         CPPFLAGS="$old_CPPFLAGS"
859         if test x$GLIBC_LFS_SUPPORT = xyes ; then
860           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
861                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
862           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
863         fi
864       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
865     ;;
866
867 esac
868
869 AC_INLINE
870 AC_HEADER_STDC
871 AC_HEADER_DIRENT
872 AC_HEADER_TIME
873 AC_HEADER_SYS_WAIT
874 AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
875 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
876 AC_CHECK_HEADERS(limits.h float.h)
877 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
878 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
879 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
880 AC_CHECK_HEADERS(sys/un.h)
881 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
882 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
883 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
884 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
885 AC_CHECK_HEADERS(langinfo.h locale.h)
886 AC_CHECK_HEADERS(xfs/libxfs.h)
887 AC_CHECK_HEADERS(security/pam_ext.h)
888
889 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
890 #if HAVE_RPC_RPC_H
891 #include <rpc/rpc.h>
892 #endif
893 ]])
894
895 ## These fail to compile on IRIX so just check for their presence
896 AC_CHECK_HEADERS(sys/mode.h,,,)
897
898 # Look for Darwin headers
899 old_CPPFLAGS="$CPPFLAGS"
900 CPPFLAGS="-Iinclude $CPPFLAGS"
901 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
902 CPPFLAGS="$old_CPPFLAGS"
903
904 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
905 # subdirectory of headers.
906 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
907
908 # check for linux on amd64 since valgrind is not quite there yet
909 case "$host_os" in
910         *linux*)
911                 case "$UNAME_P" in
912                         *x86_64*)
913                                 AC_DEFINE(HAVE_64BIT_LINUX,1,[Whether we are running on 64bit linux])
914                                 ;;
915                 esac
916                 ;;
917 esac
918
919
920 #
921 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
922 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
923 #
924 case "$host_os" in
925     *hpux*)
926                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
927                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
928                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
929                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
930                 fi
931         ;;
932 esac
933 AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
934 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
935 AC_CHECK_HEADERS(stropts.h poll.h)
936 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
937
938 AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
939 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
940
941 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
942
943 AC_CHECK_HEADERS(netinet/ip.h,,,[[
944 #include <sys/types.h>
945 #if HAVE_SYS_SOCKET_H
946 #include <sys/socket.h>
947 #endif
948 #include <netinet/in.h>
949 #if HAVE_NETINET_IN_SYSTM_H
950 #include <netinet/in_systm.h>
951 #endif
952 ]])
953
954 AC_CHECK_HEADERS(net/if.h,,,[[
955 #include <sys/types.h>
956 #if HAVE_SYS_SOCKET_H
957 #include <sys/socket.h>
958 #endif
959 ]])
960
961 AC_CHECK_HEADERS(security/pam_modules.h,,,[[
962 #if HAVE_SECURITY_PAM_APPL_H
963 #include <security/pam_appl.h>
964 #endif
965 ]])
966
967 # For experimental utmp support (lastlog on some BSD-like systems)
968 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
969  
970 AC_CHECK_SIZEOF(int,cross)
971 AC_CHECK_SIZEOF(long,cross)
972 AC_CHECK_SIZEOF(long long,cross)
973 AC_CHECK_SIZEOF(short,cross)
974
975 AC_C_CONST
976 AC_C_INLINE
977 AC_C_BIGENDIAN
978 AC_C_CHAR_UNSIGNED
979
980 AC_TYPE_SIGNAL
981 AC_TYPE_UID_T
982 AC_TYPE_MODE_T
983 AC_TYPE_OFF_T
984 AC_TYPE_SIZE_T
985 AC_TYPE_PID_T
986 AC_STRUCT_ST_RDEV
987 AC_DIRENT_D_OFF
988 AC_CHECK_TYPE(ino_t,unsigned)
989 AC_CHECK_TYPE(loff_t,off_t)
990 AC_CHECK_TYPE(offset_t,loff_t)
991 AC_CHECK_TYPE(ssize_t, int)
992 AC_CHECK_TYPE(wchar_t, unsigned short)
993 AC_CHECK_TYPE(comparison_fn_t, 
994 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
995
996 ############################################
997 # for cups support we need libcups, and a handful of header files
998
999 AC_ARG_ENABLE(cups,
1000 [  --enable-cups           Turn on CUPS support (default=auto)])
1001
1002 if test x$enable_cups != xno; then
1003         AC_PATH_PROG(CUPS_CONFIG, cups-config)
1004
1005         if test "x$CUPS_CONFIG" != x; then
1006                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
1007                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
1008                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
1009                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
1010         elif test x"$enable_cups" = x"yes"; then
1011                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
1012         fi
1013 fi
1014
1015 AC_ARG_ENABLE(iprint,
1016 [  --enable-iprint         Turn on iPrint support (default=yes if cups is yes)])
1017
1018 if test x$enable_iprint != xno; then
1019         if test "x$CUPS_CONFIG" != x; then
1020                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
1021         elif test x"$enable_iprint" = x"yes"; then
1022                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
1023         fi
1024 fi
1025
1026 ############################################
1027 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
1028 AC_SEARCH_LIBS(dlopen, [dl])
1029 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
1030
1031 ############################################
1032 # check if the compiler can do immediate structures
1033 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
1034     AC_TRY_COMPILE([
1035 #include <stdio.h>],
1036 [
1037    typedef struct {unsigned x;} FOOBAR;
1038    #define X_FOOBAR(x) ((FOOBAR) { x })
1039    #define FOO_ONE X_FOOBAR(1)
1040    FOOBAR f = FOO_ONE;   
1041    static struct {
1042         FOOBAR y; 
1043         } f2[] = {
1044                 {FOO_ONE}
1045         };   
1046 ],
1047         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
1048 if test x"$samba_cv_immediate_structures" = x"yes"; then
1049    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
1050 fi
1051
1052 ############################################
1053 # check if the compiler can do immediate structures
1054 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
1055     AC_TRY_LINK([
1056 #include <stdio.h>],
1057 [
1058                 if (0) {
1059                    this_function_does_not_exist();
1060                 } else {
1061                   return 1;
1062                 }
1063
1064 ],
1065         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
1066 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
1067    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
1068 fi
1069
1070 ############################################
1071 # check for unix domain sockets
1072 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
1073     AC_TRY_COMPILE([
1074 #include <sys/types.h>
1075 #include <stdlib.h>
1076 #include <stddef.h>
1077 #include <sys/socket.h>
1078 #include <sys/un.h>],
1079 [
1080   struct sockaddr_un sunaddr; 
1081   sunaddr.sun_family = AF_UNIX;
1082 ],
1083         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
1084 if test x"$samba_cv_unixsocket" = x"yes"; then
1085    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
1086 fi
1087
1088
1089 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
1090     AC_TRY_COMPILE([
1091 #include <sys/types.h>
1092 #if STDC_HEADERS
1093 #include <stdlib.h>
1094 #include <stddef.h>
1095 #endif
1096 #include <sys/socket.h>],[socklen_t i = 0],
1097         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
1098 if test x"$samba_cv_socklen_t" = x"yes"; then
1099    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
1100 fi
1101
1102 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
1103     AC_TRY_COMPILE([
1104 #include <sys/types.h>
1105 #if STDC_HEADERS
1106 #include <stdlib.h>
1107 #include <stddef.h>
1108 #endif
1109 #include <signal.h>],[sig_atomic_t i = 0],
1110         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
1111 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
1112    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
1113 fi
1114
1115 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
1116     AC_TRY_COMPILE([
1117 #include <sys/types.h>
1118 #if STDC_HEADERS
1119 #include <stdlib.h>
1120 #include <stddef.h>
1121 #endif
1122 #if TIME_WITH_SYS_TIME
1123 # include <sys/time.h>
1124 # include <time.h>
1125 #else
1126 # if HAVE_SYS_TIME_H
1127 #  include <sys/time.h>
1128 # else
1129 #  include <time.h>
1130 # endif
1131 #endif
1132 ],[struct timespec ts;],
1133         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
1134 if test x"$samba_cv_struct_timespec" = x"yes"; then
1135    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
1136 fi
1137
1138 # stupid headers have the functions but no declaration. grrrr.
1139 AC_HAVE_DECL(errno, [#include <errno.h>])
1140 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
1141 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
1142 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
1143 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
1144 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
1145 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
1146
1147 # and glibc has setresuid under linux but the function does
1148 # nothing until kernel 2.1.44! very dumb.
1149 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
1150     AC_TRY_RUN([#include <errno.h>
1151 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
1152         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
1153 if test x"$samba_cv_have_setresuid" = x"yes"; then
1154     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
1155 fi
1156
1157 # Do the same check for setresguid...
1158 #
1159 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
1160     AC_TRY_RUN([#include <unistd.h>
1161 #include <errno.h>
1162 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
1163         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
1164 if test x"$samba_cv_have_setresgid" = x"yes"; then
1165     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
1166 fi
1167
1168 AC_FUNC_MEMCMP
1169
1170 ###############################################
1171 # Readline included by default unless explicitly asked not to
1172 test "${with_readline+set}" != "set" && with_readline=yes
1173
1174 # test for where we get readline() from
1175 AC_MSG_CHECKING(whether to use readline)
1176 AC_ARG_WITH(readline,
1177 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
1178 [  case "$with_readline" in
1179   yes)
1180     AC_MSG_RESULT(yes)
1181
1182     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1183     AC_CHECK_HEADERS(readline/history.h)
1184
1185     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1186       for termlib in ncurses curses termcap terminfo termlib tinfo; do
1187        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1188       done
1189       AC_CHECK_LIB(readline, rl_callback_handler_install,
1190        [TERMLIBS="-lreadline $TERMLIBS"
1191        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1192        break], [TERMLIBS=], $TERMLIBS)])
1193     ;;
1194   no)
1195     AC_MSG_RESULT(no)
1196     ;;
1197   *)
1198     AC_MSG_RESULT(yes)
1199
1200     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1201     # alternate readline path
1202     _ldflags=${LDFLAGS}
1203     _cppflags=${CPPFLAGS}
1204
1205     # Add additional search path
1206     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1207     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1208
1209     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1210     AC_CHECK_HEADERS(readline/history.h)
1211
1212     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1213       for termlib in ncurses curses termcap terminfo termlib; do
1214        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1215       done
1216       AC_CHECK_LIB(readline, rl_callback_handler_install,
1217        [TERMLDFLAGS="-L$with_readline/lib"
1218        TERMCPPFLAGS="-I$with_readline/include"
1219        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1220        TERMLIBS="-lreadline $TERMLIBS"
1221        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1222        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1223
1224     LDFLAGS=$_ldflags
1225     ;;
1226   esac],
1227   AC_MSG_RESULT(no)
1228 )
1229 AC_SUBST(TERMLIBS)
1230 AC_SUBST(TERMLDFLAGS)
1231
1232 # The readline API changed slightly from readline3 to readline4, so
1233 # code will generate warnings on one of them unless we have a few
1234 # special cases.
1235 AC_CHECK_LIB(readline, rl_completion_matches,
1236              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
1237                         [Do we have rl_completion_matches?])],
1238              [],
1239              [$TERMLIBS])
1240
1241 # The following test taken from the cvs sources
1242 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
1243 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
1244 # libsocket.so which has a bad implementation of gethostbyname (it
1245 # only looks in /etc/hosts), so we only look for -lsocket if we need
1246 # it.
1247 AC_CHECK_FUNCS(connect)
1248 if test x"$ac_cv_func_connect" = x"no"; then
1249     case "$LIBS" in
1250     *-lnsl*) ;;
1251     *) AC_CHECK_LIB(nsl_s, connect) ;;
1252     esac
1253     case "$LIBS" in
1254     *-lnsl*) ;;
1255     *) AC_CHECK_LIB(nsl, connect) ;;
1256     esac
1257     case "$LIBS" in
1258     *-lsocket*) ;;
1259     *) AC_CHECK_LIB(socket, connect) ;;
1260     esac
1261     case "$LIBS" in
1262     *-linet*) ;;
1263     *) AC_CHECK_LIB(inet, connect) ;;
1264     esac
1265     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
1266     dnl has been cached.
1267     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
1268        test x"$ac_cv_lib_inet_connect" = x"yes"; then
1269         # ac_cv_func_connect=yes
1270         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
1271         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
1272     fi
1273 fi
1274
1275 ###############################################
1276 # test for where we get yp_get_default_domain() from
1277 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1278 AC_CHECK_FUNCS(yp_get_default_domain)
1279
1280 # Check if we have execl, if not we need to compile smbrun.
1281 AC_CHECK_FUNCS(execl)
1282 if test x"$ac_cv_func_execl" = x"no"; then
1283     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1284 fi
1285
1286 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strerror chown fchown chmod fchmod chroot link mknod mknod64)
1287 AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
1288 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
1289 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
1290 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1291 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1292 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
1293 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
1294 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1295 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1296 AC_CHECK_FUNCS(getdents getdents64)
1297 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1298 AC_CHECK_FUNCS(syslog vsyslog timegm)
1299 AC_CHECK_FUNCS(setlocale nl_langinfo)
1300 AC_CHECK_FUNCS(nanosleep)
1301 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1302 AC_CHECK_HEADERS(sys/mman.h)
1303 # setbuffer, shmget, shm_open are needed for smbtorture
1304 AC_CHECK_FUNCS(setbuffer shmget shm_open)
1305
1306 # Find a method of generating a stack trace
1307 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1308 AC_CHECK_FUNCS(backtrace_symbols)
1309 AC_CHECK_LIB(exc, trace_back_stack)
1310
1311 # Note that all the libunwind symbols in the API are defined to internal
1312 # platform-specific version, so we must include libunwind.h before checking
1313 # any of them.
1314 AC_MSG_CHECKING([for libunwind])
1315 save_LIBS=$LIBS
1316 if test x"$UNAME_P" = xunknown ; then
1317     # This probably won't link without the platform-specific libunwind.
1318     LIBS="$LIBS -lunwind"
1319 else
1320     # Add the platform-specific libunwind module. uname -p seems the most
1321     # plausible option and works for ia64, where libunwind is most useful.
1322     LIBS="$LIBS -lunwind -lunwind-$UNAME_P"
1323 fi
1324
1325 AC_TRY_LINK(
1326     [
1327 #ifdef HAVE_LIBUNWIND_H
1328 #include <libunwind.h>
1329 #endif
1330     ],
1331     [
1332         unw_context_t ctx; unw_cursor_t cur;
1333         char buf[256]; unw_word_t off; 
1334         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1335         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1336     ],
1337     [
1338         AC_MSG_RESULT(yes)
1339         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1340
1341         # If we have libunwind, test whether we also have libunwind-ptrace
1342         # which would let us unwind arbitrary processes.
1343         save_LIBS=$LIBS
1344         AC_CHECK_HEADERS(libunwind-ptrace.h)
1345         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1346             [
1347                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1348                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1349                     [Whether libunwind-ptrace.a is available.])
1350             ],
1351             [ LIBUNWIND_PTRACE="" ])
1352
1353         LIBS=$save_LIBS
1354     ],
1355     [
1356         AC_MSG_RESULT(no)
1357         LIBS=$save_LIBS
1358     ])
1359
1360 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1361 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1362     AC_CHECK_HEADERS(sys/ptrace.h)
1363     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1364     AC_TRY_LINK(
1365             [
1366 #if HAVE_SYS_TYPES_H
1367 #include <sys/types.h>
1368 #endif
1369 #if HAVE_SYS_PTRACE_H
1370 #include <sys/ptrace.h>
1371 #endif
1372             ],
1373             [
1374                 int main(int argc, const char ** argv)
1375                 {
1376                         pid_t me = (pid_t)-1;
1377                         ptrace(PTRACE_ATTACH, me, 0, 0);
1378                         ptrace(PTRACE_DETACH, me, 0, 0);
1379                         return 0;
1380                 }
1381             ],
1382             [
1383                 AC_MSG_RESULT(yes)
1384                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1385                     [Whether the Linux ptrace(2) interface is available.])
1386             ],
1387             [
1388                 AC_MSG_RESULT(no)
1389                 LIBUNWIND_PTRACE=""
1390             ])
1391 fi
1392
1393 AC_SUBST(LIBUNWIND_PTRACE)
1394
1395 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1396 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1397 AC_CHECK_FUNCS(__getcwd _getcwd)
1398 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1399 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1400 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1401 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1402 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1403 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1404 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1405 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1406 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1407 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1408 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1409 AC_CHECK_FUNCS(prctl)
1410
1411 AC_TRY_COMPILE([
1412 #ifdef HAVE_SYS_PRCTL_H
1413 #include <sys/prctl.h>
1414 #endif
1415 ],
1416 [int i; i = prtcl(0); ],
1417 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1418
1419 #
1420
1421 #
1422 case "$host_os" in
1423     *linux*)
1424        # glibc <= 2.3.2 has a broken getgrouplist
1425        AC_TRY_RUN([
1426 #include <unistd.h>
1427 #include <sys/utsname.h>
1428 main() {
1429        /* glibc up to 2.3 has a broken getgrouplist */
1430 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1431        int libc_major = __GLIBC__;
1432        int libc_minor = __GLIBC_MINOR__;
1433
1434        if (libc_major < 2)
1435               exit(1);
1436        if ((libc_major == 2) && (libc_minor <= 3))
1437               exit(1);
1438 #endif
1439        exit(0);
1440 }
1441 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1442        if test x"$linux_getgrouplist_ok" = x"yes"; then
1443           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1444        fi
1445        ;;
1446     *)
1447        AC_CHECK_FUNCS(getgrouplist)
1448        ;;
1449 esac
1450
1451 #
1452 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1453 #
1454
1455 if test x$ac_cv_func_stat64 = xno ; then
1456   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1457   AC_TRY_LINK([
1458 #if defined(HAVE_UNISTD_H)
1459 #include <unistd.h>
1460 #endif
1461 #include <sys/stat.h>
1462 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1463   AC_MSG_RESULT([$ac_cv_func_stat64])
1464   if test x$ac_cv_func_stat64 = xyes ; then
1465     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1466   fi
1467 fi
1468
1469 if test x$ac_cv_func_lstat64 = xno ; then
1470   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1471   AC_TRY_LINK([
1472 #if defined(HAVE_UNISTD_H)
1473 #include <unistd.h>
1474 #endif
1475 #include <sys/stat.h>
1476 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1477   AC_MSG_RESULT([$ac_cv_func_lstat64])
1478   if test x$ac_cv_func_lstat64 = xyes ; then
1479     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1480   fi
1481 fi
1482
1483 if test x$ac_cv_func_fstat64 = xno ; then
1484   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1485   AC_TRY_LINK([
1486 #if defined(HAVE_UNISTD_H)
1487 #include <unistd.h>
1488 #endif
1489 #include <sys/stat.h>
1490 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1491   AC_MSG_RESULT([$ac_cv_func_fstat64])
1492   if test x$ac_cv_func_fstat64 = xyes ; then
1493     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1494   fi
1495 fi
1496
1497 #################################################
1498 # Check whether struct stat has timestamps with sub-second resolution.
1499 # At least IRIX and Solaris have these.
1500 #
1501 # We check that 
1502 #       all of st_mtim, st_atim and st_ctim exist
1503 #       all of the members are in fact of type struct timespec
1504 #
1505 # There is some conflicting standards weirdness about whether we should use
1506 # "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we
1507 # prefer struct timespec.
1508
1509 AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_stat_hires,
1510     [
1511         AC_TRY_COMPILE(
1512             [
1513 #if TIME_WITH_SYS_TIME
1514 # include <sys/time.h>
1515 # include <time.h>
1516 #else
1517 # if HAVE_SYS_TIME_H
1518 #  include <sys/time.h>
1519 # else
1520 #  include <time.h>
1521 # endif
1522 #endif
1523 #ifdef HAVE_SYS_STAT_H
1524 #include <sys/stat.h>
1525 #endif
1526             ],
1527             [
1528                 struct timespec t;
1529                 struct stat s = {0};
1530                 t.tv_sec = s.st_mtim.tv_sec;
1531                 t.tv_nsec = s.st_mtim.tv_nsec;
1532                 t.tv_sec = s.st_ctim.tv_sec;
1533                 t.tv_nsec = s.st_ctim.tv_nsec;
1534                 t.tv_sec = s.st_atim.tv_sec;
1535                 t.tv_nsec = s.st_atim.tv_nsec;
1536             ],
1537             samba_stat_hires=yes, samba_stat_hires=no)
1538     ])
1539
1540 if test x"$samba_stat_hires" = x"yes" ; then
1541     AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim])
1542     AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim])
1543     AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim])
1544     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1545             [whether struct stat has sub-second timestamps])
1546 fi
1547
1548 AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_stat_hires_notimespec,
1549     [
1550         AC_TRY_COMPILE(
1551             [
1552 #if TIME_WITH_SYS_TIME
1553 # include <sys/time.h>
1554 # include <time.h>
1555 #else
1556 # if HAVE_SYS_TIME_H
1557 #  include <sys/time.h>
1558 # else
1559 #  include <time.h>
1560 # endif
1561 #endif
1562 #ifdef HAVE_SYS_STAT_H
1563 #include <sys/stat.h>
1564 #endif
1565             ],
1566             [
1567                 struct timespec t;
1568                 struct stat s = {0};
1569                 t.tv_sec = s.st_mtime;
1570                 t.tv_nsec = s.st_mtimensec;
1571                 t.tv_sec = s.st_ctime;
1572                 t.tv_nsec = s.st_ctimensec;
1573                 t.tv_sec = s.st_atime;
1574                 t.tv_nsec = s.st_atimensec;
1575             ],
1576             samba_stat_hires=yes, samba_stat_hires=no)
1577     ])
1578
1579 if test x"$samba_stat_hires_notimespec" = x"yes" ; then
1580     AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
1581     AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
1582     AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
1583     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1584             [whether struct stat has sub-second timestamps without struct timespec])
1585 fi
1586
1587 #####################################
1588 # needed for SRV lookups
1589 AC_CHECK_LIB(resolv, dn_expand)
1590 AC_CHECK_LIB(resolv, _dn_expand)
1591 AC_CHECK_LIB(resolv, __dn_expand)
1592
1593 #
1594 # Check for the functions putprpwnam, set_auth_parameters,
1595 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1596 # Needed for OSF1 and HPUX.
1597 #
1598
1599 AC_LIBTESTFUNC(security, putprpwnam)
1600 AC_LIBTESTFUNC(sec, putprpwnam)
1601
1602 AC_LIBTESTFUNC(security, set_auth_parameters)
1603 AC_LIBTESTFUNC(sec, set_auth_parameters)
1604
1605 # UnixWare 7.x has its getspnam in -lgen
1606 AC_LIBTESTFUNC(gen, getspnam)
1607
1608 AC_LIBTESTFUNC(security, getspnam)
1609 AC_LIBTESTFUNC(sec, getspnam)
1610
1611 AC_LIBTESTFUNC(security, bigcrypt)
1612 AC_LIBTESTFUNC(sec, bigcrypt)
1613
1614 AC_LIBTESTFUNC(security, getprpwnam)
1615 AC_LIBTESTFUNC(sec, getprpwnam)
1616
1617 AC_CHECK_FUNCS(strsignal)
1618
1619 ############################################
1620 # Check if we have libattr
1621 case "$host_os" in
1622   *osf*)
1623         AC_SEARCH_LIBS(getproplist, [proplist])
1624         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1625         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1626         AC_CHECK_FUNCS(sizeof_proplist_entry)
1627   ;;
1628   *)
1629         AC_SEARCH_LIBS(getxattr, [attr])
1630         AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1631         AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
1632         AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
1633         AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1634         AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1635         AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1636         AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1637   ;;
1638 esac
1639
1640 # Check if we have extattr
1641 case "$host_os" in
1642   *freebsd4* | *dragonfly* )
1643     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1644     ;;
1645   *)
1646     AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
1647     AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
1648     AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
1649     AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
1650     ;;
1651 esac
1652
1653 # Assume non-shared by default and override below
1654 BLDSHARED="false"
1655
1656 # these are the defaults, good for lots of systems
1657 HOST_OS="$host_os"
1658 LDSHFLAGS="-shared"
1659 SONAMEFLAG="#"
1660 NSSSONAMEVERSIONSUFFIX=""
1661 SHLD="\${CC} \${CFLAGS}"
1662 PICFLAGS=""
1663 PICSUFFIX="po"
1664 SHLIBEXT="so"
1665
1666 if test "$enable_shared" = "yes"; then
1667   # this bit needs to be modified for each OS that supports share libs
1668   # You need to specify how to create a shared library and
1669   # how to compile C code to produce PIC object files
1670
1671   AC_MSG_CHECKING([ability to build shared libraries])
1672
1673   # and these are for particular systems
1674   case "$host_os" in
1675                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1676                         BLDSHARED="true"
1677                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1678                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
1679                         else
1680                                 LDSHFLAGS="-shared -Wl,-Bsymbolic" 
1681                         fi
1682                         DYNEXP="-Wl,--export-dynamic"
1683                         PICFLAGS="-fPIC"
1684                         SONAMEFLAG="-Wl,-soname="
1685                         NSSSONAMEVERSIONSUFFIX=".2"
1686                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1687                         ;;
1688                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1689                         BLDSHARED="true"
1690                         LDSHFLAGS="-G"
1691                         SONAMEFLAG="-h "
1692                         if test "${GCC}" = "yes"; then
1693                                 PICFLAGS="-fPIC"
1694                                 SONAMEFLAG="-Wl,-soname="
1695                                 NSSSONAMEVERSIONSUFFIX=".1"
1696                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1697                                         DYNEXP="-Wl,-E"
1698                                 fi
1699                         else
1700                                 PICFLAGS="-KPIC"
1701                                 ## ${CFLAGS} added for building 64-bit shared 
1702                                 ## libs using Sun's Compiler
1703                                 LDSHFLAGS="-G \${CFLAGS}"
1704                                 PICSUFFIX="po.o"
1705                         fi
1706                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1707                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1708                         ;;
1709                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1710                         BLDSHARED="true"
1711                         LDSHFLAGS="-G"
1712                         SONAMEFLAG="-Wl,-h,"
1713                         PICFLAGS="-KPIC"   # Is this correct for SunOS
1714                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1715                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1716                         ;;
1717                 *netbsd* | *freebsd* | *dragonfly* )  
1718                         BLDSHARED="true"
1719                         LDSHFLAGS="-shared"
1720                         DYNEXP="-Wl,--export-dynamic"
1721                         SONAMEFLAG="-Wl,-soname,"
1722                         PICFLAGS="-fPIC -DPIC"
1723                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1724                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1725                         ;;
1726                 *openbsd*)  BLDSHARED="true"
1727                         LDSHFLAGS="-shared"
1728                         DYNEXP="-Wl,-Bdynamic"
1729                         SONAMEFLAG="-Wl,-soname,"
1730                         PICFLAGS="-fPIC"
1731                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1732                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1733                         ;;
1734                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1735                         case "$host_os" in
1736                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1737                         ;;
1738                         esac
1739                         BLDSHARED="true"
1740                         LDSHFLAGS="-set_version sgi1.0 -shared"
1741                         SONAMEFLAG="-soname "
1742                         SHLD="\${LD}"
1743                         if test "${GCC}" = "yes"; then
1744                                 PICFLAGS="-fPIC"
1745                         else 
1746                                 PICFLAGS="-KPIC"
1747                         fi
1748                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1749                         ;;
1750                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1751                         BLDSHARED="true"
1752                         LDSHFLAGS="-Wl,-G,-bexpall"
1753                         DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
1754                         PICFLAGS="-O2"
1755                         # as AIX code is always position independent...
1756                         # .po will just create compile warnings, use po.o:
1757                         PICSUFFIX="po.o"
1758                         if test "${GCC}" != "yes"; then
1759                                 ## for funky AIX compiler using strncpy()
1760                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1761                         fi
1762
1763                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1764                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1765                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1766                         ;;
1767                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1768                         # Use special PIC flags for the native HP-UX compiler.
1769                         if test $ac_cv_prog_cc_Ae = yes; then
1770                                 BLDSHARED="true"
1771                                 SHLD="cc"
1772                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1773                                 SONAMEFLAG="-Wl,+h "
1774                                 PICFLAGS="+z"
1775                         elif test "${GCC}" = "yes"; then
1776                                 PICFLAGS="-fPIC"
1777                         fi
1778                         if test "$host_cpu" = "ia64"; then
1779                                 SHLIBEXT="so"
1780                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
1781                         else
1782                                 SHLIBEXT="sl"
1783                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1784                         fi
1785                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1786                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1787                         ;;
1788                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1789                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1790                         ;;
1791                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1792                         BLDSHARED="true"
1793                         LDSHFLAGS="-shared"
1794                         SONAMEFLAG="-Wl,-soname,"
1795                         PICFLAGS="-fPIC"
1796                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1797                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1798                         ;;
1799                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1800                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1801                         ;;
1802                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1803                         BLDSHARED="true"
1804                         LDSHFLAGS="-shared"
1805                         SONAMEFLAG="-Wl,-soname,"
1806                         PICFLAGS="-KPIC"
1807                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1808                         ;;
1809                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1810                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1811                         ;;
1812                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1813                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1814                         ;;
1815                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1816                         case "$host" in
1817                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1818                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1819                                         fi
1820                                         LDSHFLAGS="-G"
1821                                         DYNEXP="-Bexport"
1822                                 ;;
1823                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1824                         esac
1825                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1826                         ;;
1827
1828                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1829                         if [ test "$GCC" != yes ]; then
1830                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1831                         fi
1832                         LDSHFLAGS="-G"
1833                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1834                         ;;
1835                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1836                         BLDSHARED="false"
1837                         LDSHFLAGS=""
1838                         ;;
1839
1840                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1841                         BLDSHARED="true"
1842                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1843                         SHLIBEXT="dylib"
1844                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1845                         ;;
1846
1847                 *)
1848                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1849                         ;;
1850   esac
1851   AC_SUBST(DYNEXP)
1852   AC_MSG_RESULT($BLDSHARED)
1853   AC_MSG_CHECKING([linker flags for shared libraries])
1854   AC_MSG_RESULT([$LDSHFLAGS])
1855   AC_MSG_CHECKING([compiler flags for position-independent code])
1856   AC_MSG_RESULT([$PICFLAGS])
1857 fi
1858
1859 #######################################################
1860 # test whether building a shared library actually works
1861 if test $BLDSHARED = true; then
1862 AC_CACHE_CHECK([whether building shared libraries actually works], 
1863                [ac_cv_shlib_works],[
1864    # try building a trivial shared library
1865    ac_cv_shlib_works=no
1866    # The $SHLD and $LDSHFLAGS variables may contain references to other
1867    # variables so they need to be eval'ed.
1868    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
1869         shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
1870    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1871         shlib.$PICSUFFIX && ac_cv_shlib_works=yes
1872    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
1873 ])
1874 if test $ac_cv_shlib_works = no; then
1875    BLDSHARED=false
1876 fi
1877 fi
1878
1879 ################
1880
1881 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1882 AC_TRY_RUN([#include <stdio.h>
1883 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1884 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1885 if test x"$samba_cv_have_longlong" = x"yes"; then
1886     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1887     AC_CHECK_TYPE(intptr_t, unsigned long long)
1888 else
1889     AC_CHECK_TYPE(intptr_t, unsigned long)
1890 fi
1891
1892 #
1893 # Check if the compiler supports the LL prefix on long long integers.
1894 # AIX needs this.
1895
1896 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1897     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1898         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1899 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1900    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1901 fi
1902
1903   
1904 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1905 AC_TRY_RUN([#include <stdio.h>
1906 #include <sys/stat.h>
1907 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1908 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1909 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1910     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1911 fi
1912
1913 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1914 AC_TRY_RUN([
1915 #if defined(HAVE_UNISTD_H)
1916 #include <unistd.h>
1917 #endif
1918 #include <stdio.h>
1919 #include <sys/stat.h>
1920 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1921 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1922 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1923     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1924 fi
1925
1926 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1927 AC_TRY_RUN([
1928 #if defined(HAVE_UNISTD_H)
1929 #include <unistd.h>
1930 #endif
1931 #include <stdio.h>
1932 #include <sys/stat.h>
1933 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1934 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1935 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1936     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1937 fi
1938
1939 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1940 AC_TRY_RUN([
1941 #if defined(HAVE_UNISTD_H)
1942 #include <unistd.h>
1943 #endif
1944 #include <stdio.h>
1945 #include <sys/stat.h>
1946 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1947 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1948 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1949     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1950 fi
1951
1952 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
1953 AC_TRY_RUN([
1954 #if defined(HAVE_UNISTD_H)
1955 #include <unistd.h>
1956 #endif
1957 #include <stdio.h>
1958 #include <sys/stat.h>
1959 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
1960 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
1961 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
1962     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
1963 fi
1964
1965 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1966 AC_TRY_RUN([
1967 #if defined(HAVE_UNISTD_H)
1968 #include <unistd.h>
1969 #endif
1970 #include <stdio.h>
1971 #include <sys/stat.h>
1972 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1973 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1974 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1975     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1976 fi
1977
1978 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
1979 AC_TRY_COMPILE([
1980 #if defined(HAVE_UNISTD_H)
1981 #include <unistd.h>
1982 #endif
1983 #include <sys/types.h>
1984 #include <dirent.h>],
1985 [DIR64 de;],
1986 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
1987 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1988     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
1989 fi
1990
1991 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1992 AC_TRY_COMPILE([
1993 #if defined(HAVE_UNISTD_H)
1994 #include <unistd.h>
1995 #endif
1996 #include <sys/types.h>
1997 #include <dirent.h>],
1998 [struct dirent64 de;],
1999 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
2000 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2001     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
2002 fi
2003
2004 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
2005 AC_TRY_RUN([
2006 #if defined(HAVE_UNISTD_H)
2007 #include <unistd.h>
2008 #endif
2009 #include <sys/types.h>
2010 main() { dev_t dev; int i = major(dev); return 0; }],
2011 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
2012 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
2013     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
2014 fi
2015
2016 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
2017 AC_TRY_RUN([
2018 #if defined(HAVE_UNISTD_H)
2019 #include <unistd.h>
2020 #endif
2021 #include <sys/types.h>
2022 main() { dev_t dev; int i = minor(dev); return 0; }],
2023 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
2024 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
2025     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
2026 fi
2027
2028 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
2029 AC_TRY_RUN([
2030 #if defined(HAVE_UNISTD_H)
2031 #include <unistd.h>
2032 #endif
2033 #include <sys/types.h>
2034 main() { dev_t dev = makedev(1,2); return 0; }],
2035 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
2036 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
2037     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
2038 fi
2039
2040 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
2041 AC_TRY_RUN([#include <stdio.h>
2042 main() { char c; c=250; exit((c > 0)?0:1); }],
2043 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
2044 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
2045     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
2046 fi
2047
2048 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
2049 AC_TRY_COMPILE([#include <sys/types.h>
2050 #include <sys/socket.h>
2051 #include <netinet/in.h>],
2052 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
2053 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
2054 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
2055     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
2056 fi
2057
2058 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
2059 AC_TRY_COMPILE([#include <sys/types.h>
2060 #include <dirent.h>
2061 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2062 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2063 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2064     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2065 fi
2066
2067 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2068 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2069 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2070 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2071     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2072 fi
2073
2074 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
2075 AC_TRY_RUN([
2076 #include <sys/time.h>
2077 #include <unistd.h>
2078 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
2079            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
2080 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
2081     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
2082 fi
2083
2084 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
2085
2086     # On some systems (eg. Linux) librt can pull in libpthread. We
2087     # don't want this to happen because libpthreads changes signal delivery
2088     # semantics in ways we are not prepared for. This breaks Linux oplocks
2089     # which rely on signals.
2090
2091     AC_LIBTESTFUNC(rt, clock_gettime,
2092             [
2093                 AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
2094                     [Whether clock_gettime is available])
2095                 SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
2096                 SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
2097                 SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
2098             ])
2099
2100 fi
2101
2102 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
2103 AC_TRY_LINK([#include <stdarg.h>
2104 va_list ap1,ap2;], [va_copy(ap1,ap2);],
2105 samba_cv_HAVE_VA_COPY=yes,
2106 samba_cv_HAVE_VA_COPY=no)])
2107 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
2108     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
2109 else
2110     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
2111     AC_TRY_LINK([#include <stdarg.h>
2112     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
2113     samba_cv_HAVE___VA_COPY=yes,
2114     samba_cv_HAVE___VA_COPY=no)])
2115     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
2116         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
2117     fi
2118 fi
2119
2120 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
2121 AC_TRY_RUN([
2122 #include <sys/types.h>
2123 #include <stdarg.h>
2124 void foo(const char *format, ...) { 
2125        va_list ap;
2126        int len;
2127        char buf[5];
2128
2129        va_start(ap, format);
2130        len = vsnprintf(buf, 0, format, ap);
2131        va_end(ap);
2132        if (len != 5) exit(1);
2133
2134        va_start(ap, format);
2135        len = vsnprintf(0, 0, format, ap);
2136        va_end(ap);
2137        if (len != 5) exit(1);
2138
2139        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
2140
2141        exit(0);
2142 }
2143 main() { foo("hello"); }
2144 ],
2145 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
2146 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
2147     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
2148 fi
2149
2150 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2151 AC_TRY_RUN([#include <sys/types.h>
2152 #include <dirent.h>
2153 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2154 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2155 di->d_name[0] == 0) exit(0); exit(1);} ],
2156 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2157 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2158     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2159 fi
2160
2161 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2162 AC_TRY_COMPILE([#include <sys/types.h>
2163 #include <utime.h>],
2164 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2165 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2166 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2167     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2168 fi
2169
2170 ##############
2171 # Check utmp details, but only if our OS offers utmp.h
2172 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2173 dnl  utmp and utmpx come in many flavours
2174 dnl  We need to check for many of them
2175 dnl  But we don't need to do each and every one, because our code uses
2176 dnl  mostly just the utmp (not utmpx) fields.
2177
2178 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
2179
2180 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2181 AC_TRY_COMPILE([#include <sys/types.h>
2182 #include <utmp.h>],
2183 [struct utmp ut;  ut.ut_name[0] = 'a';],
2184 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2185 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2186     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2187 fi 
2188
2189 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2190 AC_TRY_COMPILE([#include <sys/types.h>
2191 #include <utmp.h>],
2192 [struct utmp ut;  ut.ut_user[0] = 'a';],
2193 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2194 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2195     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2196 fi 
2197
2198 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2199 AC_TRY_COMPILE([#include <sys/types.h>
2200 #include <utmp.h>],
2201 [struct utmp ut;  ut.ut_id[0] = 'a';],
2202 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2203 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2204     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2205 fi 
2206
2207 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2208 AC_TRY_COMPILE([#include <sys/types.h>
2209 #include <utmp.h>],
2210 [struct utmp ut;  ut.ut_host[0] = 'a';],
2211 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2212 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2213     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2214 fi 
2215
2216 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2217 AC_TRY_COMPILE([#include <sys/types.h>
2218 #include <utmp.h>],
2219 [struct utmp ut;  time_t t; ut.ut_time = t;],
2220 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2221 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2222     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2223 fi 
2224
2225 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2226 AC_TRY_COMPILE([#include <sys/types.h>
2227 #include <utmp.h>],
2228 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2229 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2230 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2231     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2232 fi 
2233
2234 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2235 AC_TRY_COMPILE([#include <sys/types.h>
2236 #include <utmp.h>],
2237 [struct utmp ut;  ut.ut_type = 0;],
2238 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2239 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2240     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2241 fi 
2242
2243 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2244 AC_TRY_COMPILE([#include <sys/types.h>
2245 #include <utmp.h>],
2246 [struct utmp ut;  ut.ut_pid = 0;],
2247 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2248 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2249     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2250 fi 
2251
2252 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2253 AC_TRY_COMPILE([#include <sys/types.h>
2254 #include <utmp.h>],
2255 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2256 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2257 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2258     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2259 fi 
2260
2261 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2262 AC_TRY_COMPILE([#include <sys/types.h>
2263 #include <utmp.h>],
2264 [struct utmp ut;  ut.ut_addr = 0;],
2265 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2266 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2267     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2268 fi 
2269
2270 if test x$ac_cv_func_pututline = xyes ; then
2271   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2272   AC_TRY_COMPILE([#include <sys/types.h>
2273 #include <utmp.h>],
2274   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2275   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2276   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2277       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2278   fi
2279 fi
2280
2281 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2282 AC_TRY_COMPILE([#include <sys/types.h>
2283 #include <utmpx.h>],
2284 [struct utmpx ux;  ux.ut_syslen = 0;],
2285 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2286 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2287     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2288 fi 
2289
2290 fi
2291 # end utmp details
2292
2293
2294 ICONV_LOCATION=standard
2295 LOOK_DIRS="/usr /usr/local /sw /opt"
2296 AC_ARG_WITH(libiconv,
2297 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
2298 [
2299   if test "$withval" = "no" ; then
2300     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2301   else
2302      if test "$withval" != "yes" ; then
2303         ICONV_PATH_SPEC=yes
2304         LOOK_DIRS="$withval"
2305      fi
2306   fi
2307 ])
2308
2309 for i in $LOOK_DIRS ; do
2310     save_LIBS=$LIBS
2311     save_LDFLAGS=$LDFLAGS
2312     save_CPPFLAGS=$CPPFLAGS
2313     ICONV_FOUND="no"
2314     unset libext
2315     CPPFLAGS="$CPPFLAGS -I$i/include"
2316 dnl This is here to handle -withval stuff for --with-libiconv
2317 dnl Perhaps we should always add a -L
2318
2319 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
2320 dnl installation paths. This gets a little tricky since we might have iconv
2321 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
2322 dnl succeed when the header is found. To counter this, make sure the 
2323 dnl library directory is there and check the ABI directory first (which
2324 dnl should be harmless on other systems.
2325 dnl For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2326     for l in "lib32" "lib" "lib/hpux32"; do
2327         if test -d "$i/$l" ; then
2328                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2329         LIBS=
2330         export LDFLAGS LIBS CPPFLAGS
2331 dnl Try to find iconv(3)
2332                 jm_ICONV($i/$l)
2333                 if test x"$ICONV_FOUND" = "xyes" ; then
2334             libext="$l"
2335             break;
2336         fi
2337         fi
2338     done
2339
2340     if test x"$ICONV_FOUND" = "xyes" ; then
2341         LDFLAGS=$save_LDFLAGS
2342         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
2343         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
2344         LIBS="$save_LIBS"
2345         ICONV_LOCATION=$i
2346         export LDFLAGS LIBS CPPFLAGS
2347 dnl Now, check for a working iconv ... we want to do it here because
2348 dnl there might be a working iconv further down the list of LOOK_DIRS
2349
2350         ############
2351         # check for iconv in libc
2352         ic_save_LIBS="$LIBS"
2353         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
2354            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
2355         fi
2356         if test x"$jm_cv_lib_iconv" != x; then
2357            LIBS="$LIBS -l$jm_cv_lib_iconv"
2358         fi
2359 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
2360         default_dos_charset=no
2361         default_display_charset=no
2362         default_unix_charset=no
2363
2364         # check for default dos charset name
2365         for j in CP850 IBM850 ; do
2366             rjs_CHARSET($j)
2367             if test x"$ICONV_CHARSET" = x"$j"; then
2368                 default_dos_charset="\"$j\""
2369                 break
2370             fi
2371         done
2372         # check for default display charset name
2373         for j in ASCII 646 ; do
2374             rjs_CHARSET($j)
2375             if test x"$ICONV_CHARSET" = x"$j"; then
2376                 default_display_charset="\"$j\""
2377                 break
2378             fi
2379         done
2380         # check for default unix charset name
2381         for j in UTF-8 UTF8 ; do
2382             rjs_CHARSET($j)
2383             if test x"$ICONV_CHARSET" = x"$j"; then
2384                 default_unix_charset="\"$j\""
2385                 break
2386             fi
2387         done
2388         
2389         if test "$default_dos_charset" != "no" -a \
2390                 "$default_dos_charset" != "cross" -a \
2391                 "$default_display_charset" != "no" -a \ 
2392                 "$default_display_charset" != "cross" -a \
2393                 "$default_unix_charset" != "no" -a \
2394                 "$default_unix_charset" != "cross"
2395         then
2396                 samba_cv_HAVE_NATIVE_ICONV=yes
2397         else if test "$default_dos_charset" = "cross" -o \
2398                      "$default_display_charset" = "cross" -o \
2399                      "$default_unix_charset" = "cross"
2400         then
2401                 samba_cv_HAVE_NATIVE_ICONV=cross
2402         else
2403                 samba_cv_HAVE_NATIVE_ICONV=no
2404         fi
2405         fi
2406 dnl ])
2407
2408         LIBS="$ic_save_LIBS"
2409         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
2410            CPPFLAGS=$save_CPPFLAGS
2411            LDFLAGS=$save_LDFLAGS
2412            LIBS=$save_LIBS
2413            if test x"$jm_cv_lib_iconv" != x; then
2414               LIBS="$LIBS -l$jm_cv_lib_iconv"
2415            fi
2416            dnl Add the flags we need to CPPFLAGS and LDFLAGS
2417            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
2418            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
2419            export CPPFLAGS
2420            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2421            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2422            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2423            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2424            break
2425         fi
2426 dnl We didn't find a working iconv, so keep going
2427     fi
2428 dnl We only need to clean these up here for the next pass through the loop
2429     CPPFLAGS=$save_CPPFLAGS
2430     LDFLAGS=$save_LDFLAGS
2431     LIBS=$save_LIBS
2432     export LDFLAGS LIBS CPPFLAGS
2433 done
2434 unset libext
2435
2436
2437 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2438     AC_MSG_WARN([Sufficient support for iconv function was not found. 
2439     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2440    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2441    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2442    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2443 fi
2444
2445
2446 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2447 AC_TRY_RUN([
2448 #include <sys/types.h>
2449 #include <fcntl.h>
2450 #ifndef F_GETLEASE
2451 #define F_GETLEASE      1025
2452 #endif
2453 main() {
2454        int fd = open("/dev/null", O_RDONLY);
2455        return fcntl(fd, F_GETLEASE, 0) == -1;
2456 }
2457 ],
2458 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2459 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2460     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2461 fi
2462
2463 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2464 AC_TRY_RUN([
2465 #include <sys/types.h>
2466 #include <fcntl.h>
2467 #include <signal.h>
2468 #ifndef F_NOTIFY
2469 #define F_NOTIFY 1026
2470 #endif
2471 main() {
2472         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2473 }
2474 ],
2475 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2476 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2477     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2478 fi
2479
2480 #################################################
2481 # Check if FAM notifications are available. For FAM info, see
2482 #       http://oss.sgi.com/projects/fam/
2483 #       http://savannah.nongnu.org/projects/fam/
2484
2485 AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2486 if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2487     # On IRIX, libfam requires libC, but other FAM implementations might not
2488     # need it.
2489     AC_CHECK_LIB(fam, FAMOpen2,
2490             [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam"],
2491             [samba_cv_HAVE_LIBFAM=no])
2492
2493     if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2494         samba_fam_xtra=-lC
2495         AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2496                 [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam -lC"],
2497                 [samba_cv_HAVE_LIBFAM=no])
2498         unset samba_fam_xtra
2499     fi
2500 fi
2501
2502 if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2503     AC_DEFINE(HAVE_FAM_CHANGE_NOTIFY, 1,
2504             [Whether FAM is file notifications are available])
2505     AC_TRY_COMPILE([#include <fam.h>],
2506                 [FAMCodes code = FAMChanged;],
2507                 AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2508                     [Whether fam.h contains a typedef for enum FAMCodes]),
2509                 [])
2510 fi
2511
2512 #################################################
2513 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2514
2515 SMB_CHECK_DMAPI([], AC_MSG_NOTICE(DMAPI support not present) )
2516
2517 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2518 AC_TRY_RUN([
2519 #include <sys/types.h>
2520 #include <fcntl.h>
2521 #include <signal.h>
2522 #include <sys/file.h>
2523 #ifndef LOCK_MAND
2524 #define LOCK_MAND       32
2525 #define LOCK_READ       64
2526 #endif
2527 main() {
2528         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2529 }
2530 ],
2531 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2532 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2533     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2534 fi
2535
2536
2537 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2538 AC_TRY_COMPILE([#include <sys/types.h>
2539 #include <fcntl.h>],
2540 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2541 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2542 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2543     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2544 fi
2545
2546 #################################################
2547 # Check for POSIX capability support
2548
2549 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2550     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2551     [], [])
2552
2553 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2554
2555     ac_save_LIBS=$LIBS
2556     AC_LIBTESTFUNC(cap, cap_get_proc)
2557
2558     AC_CACHE_CHECK([for POSIX capabilities],
2559             samba_cv_HAVE_POSIX_CAPABILITIES,
2560             [
2561                 AC_TRY_RUN([
2562 #include <sys/types.h>
2563 #include <sys/capability.h>
2564 main() {
2565  cap_t cap;
2566  cap_value_t vals[1];
2567  if (!(cap = cap_get_proc()))
2568    exit(1);
2569  vals[0] = CAP_CHOWN;
2570  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2571  cap_set_proc(cap);
2572  exit(0);
2573 }],
2574                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2575                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2576                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2577             ])
2578
2579 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2580     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2581             [Whether POSIX capabilities are available])
2582 else
2583     LIBS=$ac_save_LIBS
2584 fi
2585
2586 fi
2587
2588 #
2589 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2590 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2591 #
2592
2593 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2594 AC_TRY_COMPILE([#include <sys/types.h>
2595 #if defined(HAVE_RPC_RPC_H)
2596 #include <rpc/rpc.h>
2597 #endif],
2598 [int16 testvar;],
2599 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2600 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2601     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2602 fi
2603
2604 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2605 AC_TRY_COMPILE([#include <sys/types.h>
2606 #if defined(HAVE_RPC_RPC_H)
2607 #include <rpc/rpc.h>
2608 #endif],
2609 [uint16 testvar;],
2610 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2611 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2612     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2613 fi
2614
2615 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2616 AC_TRY_COMPILE([#include <sys/types.h>
2617 #if defined(HAVE_RPC_RPC_H)
2618 #include <rpc/rpc.h>
2619 #endif],
2620 [int32 testvar;],
2621 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2622 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2623     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2624 fi
2625
2626 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2627 AC_TRY_COMPILE([#include <sys/types.h>
2628 #if defined(HAVE_RPC_RPC_H)
2629 #include <rpc/rpc.h>
2630 #endif],
2631 [uint32 testvar;],
2632 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2633 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2634     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2635 fi
2636
2637 dnl
2638 dnl Some systems (SCO) have a problem including
2639 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2640 dnl as a #define in <prot.h> and as part of an enum
2641 dnl in <rpc/rpc.h>.
2642 dnl
2643
2644 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2645 AC_TRY_COMPILE([#include <sys/types.h>
2646 #ifdef HAVE_SYS_SECURITY_H
2647 #include <sys/security.h>
2648 #include <prot.h>
2649 #endif  /* HAVE_SYS_SECURITY_H */
2650 #if defined(HAVE_RPC_RPC_H)
2651 #include <rpc/rpc.h>
2652 #endif],
2653 [int testvar;],
2654 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2655 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2656     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2657 fi
2658
2659 AC_MSG_CHECKING([for test routines])
2660 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2661            AC_MSG_RESULT(yes),
2662            AC_MSG_ERROR([cant find test code. Aborting config]),
2663            AC_MSG_WARN([cannot run when cross-compiling]))
2664
2665 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2666 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2667            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2668 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2669     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2670 fi
2671
2672 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2673 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2674            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2675            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2676            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2677 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2678 then
2679     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2680 fi
2681
2682 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2683 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2684            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2685 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2686     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2687 fi
2688
2689 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
2690 SAVE_CPPFLAGS="$CPPFLAGS"
2691 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
2692 AC_TRY_COMPILE([
2693 #define REPLACE_GETPASS 1
2694 #define NO_PROTO_H 1
2695 #define NO_CONFIG_H 1
2696 #define main dont_declare_main
2697 #include "${srcdir-.}/lib/getsmbpass.c"
2698 #undef main
2699 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
2700 CPPFLAGS="$SAVE_CPPFLAGS"
2701 ])
2702 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
2703         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
2704 fi
2705
2706 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
2707 AC_TRY_RUN([
2708 #include <stdio.h>
2709 #include <sys/types.h>
2710 #include <netinet/in.h>
2711 #ifdef HAVE_ARPA_INET_H
2712 #include <arpa/inet.h>
2713 #endif
2714 main() { struct in_addr ip; ip.s_addr = 0x12345678;
2715 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2716     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
2717 exit(1);}],
2718            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
2719 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
2720     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
2721 fi
2722
2723 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2724 AC_TRY_RUN([#include <stdlib.h>
2725 #include <sys/types.h>
2726 #include <sys/stat.h>
2727 #include <unistd.h>
2728 main() { 
2729   struct stat st;
2730   char tpl[20]="/tmp/test.XXXXXX"; 
2731   int fd = mkstemp(tpl); 
2732   if (fd == -1) exit(1);
2733   unlink(tpl);
2734   if (fstat(fd, &st) != 0) exit(1);
2735   if ((st.st_mode & 0777) != 0600) exit(1);
2736   exit(0);
2737 }],
2738 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2739 samba_cv_HAVE_SECURE_MKSTEMP=no,
2740 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2741 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2742     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2743 fi
2744
2745 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
2746         AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
2747                 [samba_cv_HAVE_BROKEN_READDIR=no],
2748                         [samba_cv_HAVE_BROKEN_READDIR=yes],
2749                         [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
2750
2751 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
2752 AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
2753         AC_TRY_RUN([
2754 #include "${srcdir-.}/lib/repdir.c"
2755 #include "${srcdir-.}/tests/os2_delete.c"],
2756         samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
2757 fi
2758
2759 if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then
2760         AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
2761 fi
2762
2763 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2764 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2765 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2766 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2767 AC_CHECK_FUNCS(getpagesize)
2768
2769 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
2770 AC_TRY_RUN([main() { exit(getuid() != 0); }],
2771            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
2772 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
2773     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
2774 else
2775     AC_MSG_WARN(running as non-root will disable some tests)
2776 fi
2777
2778 ##################
2779 # look for a method of finding the list of network interfaces
2780 iface=no;
2781 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2782 AC_TRY_RUN([
2783 #define HAVE_IFACE_AIX 1
2784 #define AUTOCONF_TEST 1
2785 #include "confdefs.h"
2786 #include "${srcdir-.}/lib/interfaces.c"],
2787            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2788 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2789     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2790 fi
2791
2792 if test $iface = no; then
2793 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2794 AC_TRY_RUN([
2795 #define HAVE_IFACE_IFCONF 1
2796 #define AUTOCONF_TEST 1
2797 #include "confdefs.h"
2798 #include "${srcdir-.}/lib/interfaces.c"],
2799            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2800 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2801     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2802 fi
2803 fi
2804
2805 if test $iface = no; then
2806 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2807 AC_TRY_RUN([
2808 #define HAVE_IFACE_IFREQ 1
2809 #define AUTOCONF_TEST 1
2810 #include "confdefs.h"
2811 #include "${srcdir-.}/lib/interfaces.c"],
2812            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2813 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2814     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2815 fi
2816 fi
2817
2818
2819 ################################################
2820 # look for a method of setting the effective uid
2821 seteuid=no;
2822 if test $seteuid = no; then
2823 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2824 AC_TRY_RUN([
2825 #define AUTOCONF_TEST 1
2826 #define USE_SETRESUID 1
2827 #include "confdefs.h"
2828 #include "${srcdir-.}/lib/util_sec.c"],
2829            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2830 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2831     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2832 fi
2833 fi
2834
2835
2836 if test $seteuid = no; then
2837 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2838 AC_TRY_RUN([
2839 #define AUTOCONF_TEST 1
2840 #define USE_SETREUID 1
2841 #include "confdefs.h"
2842 #include "${srcdir-.}/lib/util_sec.c"],
2843            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2844 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2845     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2846 fi
2847 fi
2848
2849 if test $seteuid = no; then
2850 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2851 AC_TRY_RUN([
2852 #define AUTOCONF_TEST 1
2853 #define USE_SETEUID 1
2854 #include "confdefs.h"
2855 #include "${srcdir-.}/lib/util_sec.c"],
2856            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2857 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2858     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2859 fi
2860 fi
2861
2862 if test $seteuid = no; then
2863 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2864 AC_TRY_RUN([
2865 #define AUTOCONF_TEST 1
2866 #define USE_SETUIDX 1
2867 #include "confdefs.h"
2868 #include "${srcdir-.}/lib/util_sec.c"],
2869            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2870 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2871     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2872 fi
2873 fi
2874
2875
2876 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
2877 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
2878            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
2879 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
2880     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
2881 fi
2882
2883 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2884 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2885            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2886 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2887     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2888 fi
2889
2890 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2891 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2892            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2893 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2894     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2895
2896 else
2897
2898 dnl
2899 dnl Don't check for 64 bit fcntl locking if we know that the
2900 dnl glibc2.1 broken check has succeeded.
2901 dnl 
2902
2903   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2904   AC_TRY_RUN([
2905 #if defined(HAVE_UNISTD_H)
2906 #include <unistd.h>
2907 #endif
2908 #include <stdio.h>
2909 #include <stdlib.h>
2910
2911 #ifdef HAVE_FCNTL_H
2912 #include <fcntl.h>
2913 #endif
2914
2915 #ifdef HAVE_SYS_FCNTL_H
2916 #include <sys/fcntl.h>
2917 #endif
2918 main() { struct flock64 fl64;
2919 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2920 exit(0);
2921 #else
2922 exit(1);
2923 #endif
2924 }],
2925        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2926
2927   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2928       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2929   fi
2930 fi
2931
2932 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2933 AC_TRY_COMPILE([#include <sys/types.h>
2934 #include <sys/stat.h>
2935 #include <unistd.h>],
2936 [struct stat st;  st.st_blocks = 0;],
2937 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2938 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2939     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2940 fi 
2941
2942 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2943 AC_TRY_COMPILE([#include <sys/types.h>
2944 #include <sys/stat.h>
2945 #include <unistd.h>],
2946 [struct stat st;  st.st_blksize = 0;],
2947 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2948 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2949     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2950 fi
2951
2952 case "$host_os" in
2953 *linux*)
2954 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
2955 AC_TRY_COMPILE([
2956 #ifdef HAVE_SYS_VFS_H
2957 #include <sys/vfs.h>
2958 #endif
2959 #ifdef HAVE_SYS_CAPABILITY_H
2960 #include <sys/capability.h>
2961 #endif
2962 ],[int i;],
2963    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2964 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2965    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2966 fi
2967 ;;
2968 esac
2969
2970 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2971 AC_TRY_COMPILE([
2972 #include <sys/types.h>
2973 #include <sys/acl.h>
2974 #if defined(HAVE_RPCSVC_NIS_H)
2975 #include <rpcsvc/nis.h>
2976 #endif],
2977 [int i;],
2978 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2979 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2980         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2981 fi
2982
2983 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2984 AC_TRY_RUN([
2985 #include <stdio.h>
2986 #include <limits.h>
2987 main() {
2988         char *newpath = realpath("/tmp", NULL);
2989         exit ((newpath != NULL) ? 0 : 1);
2990 }
2991 ],
2992 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2993 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2994     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2995 fi
2996
2997 #################################################
2998 # check for AFS clear-text auth support
2999 samba_cv_WITH_AFS=no
3000 AC_MSG_CHECKING(whether to use AFS clear-text auth)
3001 AC_ARG_WITH(afs,
3002 [  --with-afs              Include AFS clear-text auth support (default=no) ],
3003 [ case "$withval" in
3004   yes|auto)
3005     AC_MSG_RESULT($withval)
3006     samba_cv_WITH_AFS=$withval
3007     ;;
3008   *)
3009     AC_MSG_RESULT(no)
3010     ;;
3011   esac ],
3012   AC_MSG_RESULT(no)
3013 )
3014
3015 ####################################################
3016 # check for Linux-specific AFS fake-kaserver support
3017 samba_cv_WITH_FAKE_KASERVER=no
3018 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3019 AC_ARG_WITH(fake-kaserver,
3020 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
3021 [ case "$withval" in
3022   yes|auto)
3023     AC_MSG_RESULT($withval)
3024     samba_cv_WITH_FAKE_KASERVER=$withval
3025     ;;
3026   *)
3027     AC_MSG_RESULT(no)
3028     ;;
3029   esac ],
3030   AC_MSG_RESULT(no)
3031 )
3032
3033 #################################################
3034 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3035 if test x"$samba_cv_WITH_AFS" != x"no" ||
3036    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3037
3038     # see if this box has the afs-headers in /usr/include/afs
3039     AC_MSG_CHECKING(for /usr/include/afs)
3040     if test -d /usr/include/afs; then
3041           CFLAGS="$CFLAGS -I/usr/include/afs"
3042           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
3043           AC_MSG_RESULT(yes)
3044     else
3045       AC_MSG_RESULT(no)
3046     fi
3047    
3048     # check for afs.h
3049     have_afs_headers=no
3050     AC_CHECK_HEADERS(afs.h afs/afs.h)
3051     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3052         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3053            test x"$samba_cv_WITH_AFS" = x"auto"; then
3054                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3055         else
3056                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3057         fi
3058     else
3059         have_afs_headers=yes
3060     fi
3061 fi
3062
3063 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3064     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3065 fi
3066
3067 #################################################
3068 # check whether to compile AFS/NT ACL mapping module
3069 samba_cv_WITH_VFS_AFSACL=no
3070 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
3071 AC_ARG_WITH(vfs-afsacl,
3072 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
3073 [ case "$withval" in
3074   yes|auto)
3075     AC_MSG_RESULT($withval)
3076     samba_cv_WITH_VFS_AFSACL=yes
3077     ;;
3078   *)
3079     AC_MSG_RESULT(no)
3080     ;;
3081   esac ],
3082   AC_MSG_RESULT(no)
3083 )
3084
3085 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3086    default_shared_modules="$default_shared_modules vfs_afsacl"
3087 fi
3088         
3089 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3090     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3091 fi
3092
3093 #################################################
3094 # check for the DFS clear-text auth system
3095 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3096 AC_ARG_WITH(dfs,
3097 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
3098 [ case "$withval" in
3099   yes)
3100     AC_MSG_RESULT(yes)
3101     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3102     ;;
3103   *)
3104     AC_MSG_RESULT(no)
3105     ;;
3106   esac ],
3107   AC_MSG_RESULT(no)
3108 )
3109
3110 ########################################################
3111 # Compile with LDAP support?
3112
3113 with_ldap_support=auto
3114 AC_MSG_CHECKING([for LDAP support])
3115
3116 AC_ARG_WITH(ldap,
3117 [  --with-ldap             LDAP support (default yes)],
3118 [ case "$withval" in
3119     yes|no)
3120         with_ldap_support=$withval
3121         ;;
3122   esac ])
3123
3124 AC_MSG_RESULT($with_ldap_support)
3125
3126 SMBLDAP=""
3127 AC_SUBST(SMBLDAP)
3128 SMBLDAPUTIL=""
3129 AC_SUBST(SMBLDAPUTIL)
3130 if test x"$with_ldap_support" != x"no"; then
3131
3132   ##################################################################
3133   # first test for ldap.h and lber.h
3134   # (ldap.h is required for this test)
3135   AC_CHECK_HEADERS(ldap.h lber.h)
3136   
3137   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3138         if test x"$with_ldap_support" = x"yes"; then
3139          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3140         else
3141          AC_MSG_WARN(ldap.h is needed for LDAP support)
3142         fi
3143         
3144         with_ldap_support=no
3145   fi
3146
3147   ##################################################################
3148   # HP/UX does not have ber_tag_t, disable LDAP there
3149   AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3150   if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3151         if test x"$with_ldap_support" = x"yes"; then
3152          AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3153         else
3154          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3155         fi
3156         with_ldap_support=no
3157   fi
3158 fi
3159
3160 if test x"$with_ldap_support" != x"no"; then
3161   ac_save_LIBS=$LIBS
3162
3163   ##################################################################
3164   # we might need the lber lib on some systems. To avoid link errors
3165   # this test must be before the libldap test
3166   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3167
3168   ########################################################
3169   # now see if we can find the ldap libs in standard paths
3170   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3171
3172   ########################################################
3173   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3174   # Check found in pam_ldap 145.
3175   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3176
3177   LIBS="$LIBS $LDAP_LIBS"
3178   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3179     AC_TRY_COMPILE([
3180         #include <lber.h>
3181         #include <ldap.h>], 
3182         [ldap_set_rebind_proc(0, 0, 0);], 
3183         [smb_ldap_cv_ldap_set_rebind_proc=3], 
3184         [smb_ldap_cv_ldap_set_rebind_proc=2]
3185     ) 
3186   ])
3187   
3188   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3189
3190   AC_CHECK_FUNC_EXT(ldap_dn2ad_canonical,$LDAP_LIBS)    
3191   
3192   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3193     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3194     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3195     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3196     default_shared_modules="$default_shared_modules";
3197     SMBLDAP="lib/smbldap.o"
3198     SMBLDAPUTIL="lib/smbldap_util.o"
3199     with_ldap_support=yes
3200     AC_MSG_CHECKING(whether LDAP support is used)
3201     AC_MSG_RESULT(yes)
3202   else
3203     if test x"$with_ldap_support" = x"yes"; then
3204         AC_MSG_ERROR(libldap is needed for LDAP support)
3205     else
3206         AC_MSG_WARN(libldap is needed for LDAP support)
3207     fi
3208     
3209     LDAP_LIBS=""
3210     with_ldap_support=no
3211   fi
3212   LIBS=$ac_save_LIBS
3213 fi
3214
3215
3216 #################################################
3217 # active directory support
3218
3219 with_ads_support=auto
3220 AC_MSG_CHECKING([for Active Directory and krb5 support])
3221
3222 AC_ARG_WITH(ads,
3223 [  --with-ads              Active Directory support (default auto)],
3224 [ case "$withval" in
3225     yes|no)
3226         with_ads_support="$withval"
3227         ;;
3228   esac ])
3229
3230 AC_MSG_RESULT($with_ads_support)
3231
3232 FOUND_KRB5=no
3233 KRB5_LIBS=""
3234
3235 if test x"$with_ldap_support" != x"yes"; then
3236
3237     if test x"$with_ads_support" = x"yes"; then
3238         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3239     elif test x"$with_ads_support" = x"auto"; then
3240         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3241         with_ads_support=no
3242     fi
3243
3244 else
3245
3246     # Check to see whether there is enough LDAP functionality to be able
3247     # to build AD support.
3248
3249     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3250
3251     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3252         if test x"$with_ads_support" = x"yes"; then
3253             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3254         elif test x"$with_ads_support" = x"auto"; then
3255             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3256             with_ads_support=no
3257         fi
3258     fi
3259
3260     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3261
3262     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3263         if test x"$with_ads_support" = x"yes"; then
3264             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3265         elif test x"$with_ads_support" = x"auto"; then
3266             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3267             with_ads_support=no
3268         fi
3269     fi
3270
3271 fi
3272
3273 if test x"$with_ads_support" != x"no"; then
3274
3275   # Do no harm to the values of CFLAGS and LIBS while testing for
3276   # Kerberos support.
3277  
3278   if test x$FOUND_KRB5 = x"no"; then
3279     #################################################
3280     # check for location of Kerberos 5 install
3281     AC_MSG_CHECKING(for kerberos 5 install path)
3282     AC_ARG_WITH(krb5,
3283     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
3284     [ case "$withval" in
3285       no)
3286         AC_MSG_RESULT(no krb5-path given)
3287         ;;
3288       yes)
3289         AC_MSG_RESULT(/usr)
3290         FOUND_KRB5=yes
3291         ;;
3292       *)
3293         AC_MSG_RESULT($withval)
3294         KRB5_CFLAGS="-I$withval/include"
3295         KRB5_CPPFLAGS="-I$withval/include"
3296         KRB5_LDFLAGS="-L$withval/lib"
3297         FOUND_KRB5=yes
3298         if test -x "$withval/bin/krb5-config"; then
3299                 KRB5CONFIG=$withval/bin/krb5-config
3300         fi
3301         ;;
3302       esac ],
3303       AC_MSG_RESULT(no krb5-path given)
3304     )
3305   fi
3306
3307   #################################################
3308   # check for krb5-config from recent MIT and Heimdal kerberos 5
3309   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3310   AC_MSG_CHECKING(for working krb5-config)
3311   if test -x "$KRB5CONFIG"; then
3312     ac_save_CFLAGS=$CFLAGS
3313     CFLAGS="";export CFLAGS
3314     ac_save_LDFLAGS=$LDFLAGS
3315     LDFLAGS="";export LDFLAGS
3316     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3317     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3318     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
3319     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3320     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3321     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3322     FOUND_KRB5=yes
3323     AC_MSG_RESULT(yes)
3324   else
3325     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3326   fi
3327  
3328   if test x$FOUND_KRB5 = x"no"; then
3329     #################################################
3330     # see if this box has the SuSE location for the heimdal krb implementation
3331     AC_MSG_CHECKING(for /usr/include/heimdal)
3332     if test -d /usr/include/heimdal; then
3333       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3334           KRB5_CFLAGS="-I/usr/include/heimdal"
3335           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3336           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3337           AC_MSG_RESULT(yes)
3338       else
3339           KRB5_CFLAGS="-I/usr/include/heimdal"
3340           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3341           AC_MSG_RESULT(yes)
3342       fi
3343     else
3344       AC_MSG_RESULT(no)
3345     fi
3346   fi
3347
3348   if test x$FOUND_KRB5 = x"no"; then
3349     #################################################
3350     # see if this box has the RedHat location for kerberos
3351     AC_MSG_CHECKING(for /usr/kerberos)
3352     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3353       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3354       KRB5_CFLAGS="-I/usr/kerberos/include"
3355       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3356       AC_MSG_RESULT(yes)
3357     else
3358       AC_MSG_RESULT(no)
3359     fi
3360   fi
3361
3362   ac_save_CFLAGS=$CFLAGS
3363   ac_save_CPPFLAGS=$CPPFLAGS
3364   ac_save_LDFLAGS=$LDFLAGS
3365
3366   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3367   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3368   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3369
3370   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3371
3372   # now check for krb5.h. Some systems have the libraries without the headers!
3373   # note that this check is done here to allow for different kerberos
3374   # include paths
3375   AC_CHECK_HEADERS(krb5.h)
3376
3377   if test x"$ac_cv_header_krb5_h" = x"no"; then
3378
3379     # Give a warning if AD support was not explicitly requested,
3380     # i.e with_ads_support = auto, otherwise die with an error.
3381
3382     if test x"$with_ads_support" = x"yes"; then
3383       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3384     else
3385       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3386     fi
3387
3388     # Turn off AD support and restore CFLAGS and LIBS variables
3389
3390     with_ads_support="no"
3391     
3392     CFLAGS=$ac_save_CFLAGS
3393     CPPFLAGS=$ac_save_CPPFLAGS
3394     LDFLAGS=$ac_save_LDFLAGS
3395   fi
3396 fi
3397
3398 # Now we have determined whether we really want ADS support
3399
3400 if test x"$with_ads_support" != x"no"; then
3401   ac_save_LIBS=$LIBS
3402
3403   # now check for gssapi headers.  This is also done here to allow for
3404   # different kerberos include paths
3405   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3406
3407   ##################################################################
3408   # we might need the k5crypto and com_err libraries on some systems
3409   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3410   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3411
3412   # Heimdal checks.
3413   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3414   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3415   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3416
3417   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3418   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
3419                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
3420
3421   ########################################################
3422   # now see if we can find the krb5 libs in standard paths
3423   # or as specified above
3424   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3425   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3426
3427   ########################################################
3428   # now see if we can find the gssapi libs in standard paths
3429   AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
3430             AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
3431
3432   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3433   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3434   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3435   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3436   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3437   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
3438   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3439   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
3440   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3441   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
3442   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3443   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
3444   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
3445   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
3446   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3447   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3448   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3449   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3450   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3451   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3452   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3453   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3454   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3455   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3456   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3457   AC_CHECK_FUNC_EXT(decode_krb5_ap_req, $KRB5_LIBS)
3458   AC_CHECK_FUNC_EXT(krb5_free_ap_req, $KRB5_LIBS)
3459   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3460   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3461   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3462   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3463   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3464   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3465   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3466   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3467   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3468
3469   LIBS="$KRB5_LIBS $LIBS"
3470
3471   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
3472     AC_TRY_COMPILE([
3473         #include <krb5.h>], 
3474         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);], 
3475         [smb_krb5_verify_checksum=7], 
3476         [smb_krb5_verify_checksum=6], 
3477     ) 
3478   ])
3479   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_verify_checksum, [Number of arguments to krb5_verify_checksum])
3480
3481   AC_CACHE_CHECK([for checksum in krb5_checksum],
3482                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3483     AC_TRY_COMPILE([#include <krb5.h>],
3484       [krb5_checksum cksum; cksum.checksum.length = 0;],
3485       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3486       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3487
3488   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3489     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3490                [Whether the krb5_checksum struct has a checksum property])
3491   fi
3492
3493   AC_CACHE_CHECK([for etype in EncryptedData],
3494                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3495     AC_TRY_COMPILE([#include <krb5.h>],
3496       [EncryptedData edata; edata.etype = 0;],
3497       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3498       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3499
3500   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3501     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3502                [Whether the EncryptedData struct has a etype property])
3503   fi
3504
3505   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3506                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3507     AC_TRY_COMPILE([#include <krb5.h>],
3508       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3509       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3510       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3511
3512   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3513     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3514                [Whether the krb5_ap_req struct has a ticket pointer])
3515   fi
3516
3517   AC_CACHE_CHECK([for e_data pointer in krb5_error],
3518                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
3519     AC_TRY_COMPILE([#include <krb5.h>],
3520       [krb5_error err; err.e_data = NULL;],
3521       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
3522       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
3523
3524   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
3525     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
3526                [Whether the krb5_error struct has a e_data pointer])
3527   fi
3528
3529   AC_CACHE_CHECK([for krb5_crypto type],
3530                 samba_cv_HAVE_KRB5_CRYPTO,[
3531     AC_TRY_COMPILE([#include <krb5.h>],
3532       [krb5_crypto crypto;],
3533       samba_cv_HAVE_KRB5_CRYPTO=yes,
3534       samba_cv_HAVE_KRB5_CRYPTO=no)])
3535
3536   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3537     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3538                [Whether the type krb5_crypto exists])
3539   fi
3540
3541   AC_CACHE_CHECK([for krb5_encrypt_block type],
3542                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3543     AC_TRY_COMPILE([#include <krb5.h>],
3544       [krb5_encrypt_block block;],
3545       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3546       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3547
3548   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3549     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3550                [Whether the type krb5_encrypt_block exists])
3551   fi
3552
3553   AC_CACHE_CHECK([for addrtype in krb5_address],
3554                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3555     AC_TRY_COMPILE([#include <krb5.h>],
3556       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3557       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3558       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3559
3560   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3561     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3562                [Whether the krb5_address struct has a addrtype property])
3563   fi
3564
3565   AC_CACHE_CHECK([for addr_type in krb5_address],
3566                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3567     AC_TRY_COMPILE([#include <krb5.h>],
3568       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3569       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3570       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3571
3572   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3573     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3574               [Whether the krb5_address struct has a addr_type property])
3575   fi
3576
3577   AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
3578                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3579                  [AC_TRY_COMPILE([#include <krb5.h>],
3580     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3581     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3582
3583   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3584     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3585               [Whether the krb5_ticket struct has a enc_part2 property])
3586   fi
3587
3588   AC_CACHE_CHECK([for keyblock in krb5_creds],
3589                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3590     AC_TRY_COMPILE([#include <krb5.h>],
3591       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3592       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3593       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
3594
3595   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
3596     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
3597               [Whether the krb5_creds struct has a keyblock property])
3598   fi
3599
3600   AC_CACHE_CHECK([for session in krb5_creds],
3601                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
3602     AC_TRY_COMPILE([#include <krb5.h>],
3603       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
3604       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
3605       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
3606
3607   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
3608     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
3609               [Whether the krb5_creds struct has a session property])
3610   fi
3611
3612   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
3613                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
3614     AC_TRY_COMPILE([#include <krb5.h>],
3615       [krb5_keyblock key; key.keyvalue.data = NULL;],
3616       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
3617       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
3618
3619   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
3620     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
3621               [Whether the krb5_keyblock struct has a keyvalue property])
3622   fi
3623
3624   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
3625                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
3626     AC_TRY_COMPILE([#include <krb5.h>],
3627       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
3628       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
3629       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
3630   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
3631                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
3632     AC_TRY_COMPILE([#include <krb5.h>],
3633       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
3634       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
3635       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
3636 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
3637 # w.r.t. arcfour and windows, so we must not enable it here
3638   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
3639           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
3640     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
3641               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
3642   fi
3643
3644   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
3645                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
3646     AC_TRY_COMPILE([#include <krb5.h>],
3647       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
3648       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
3649       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
3650
3651   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
3652     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
3653               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
3654   fi
3655
3656   AC_CACHE_CHECK([for KV5M_KEYTAB],
3657                  samba_cv_HAVE_KV5M_KEYTAB,[
3658     AC_TRY_COMPILE([#include <krb5.h>],
3659       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
3660       samba_cv_HAVE_KV5M_KEYTAB=yes,
3661       samba_cv_HAVE_KV5M_KEYTAB=no)])
3662
3663   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
3664       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
3665              [Whether the KV5M_KEYTAB option is available])
3666   fi
3667
3668   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
3669                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
3670     AC_TRY_COMPILE([#include <krb5.h>],
3671       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
3672       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
3673       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
3674
3675   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
3676     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
3677               [Whether KRB5_KU_OTHER_CKSUM is available])
3678   fi
3679   
3680   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
3681                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
3682     AC_TRY_COMPILE([#include <krb5.h>],
3683       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
3684       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
3685       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
3686
3687   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
3688     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
3689               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
3690   fi
3691
3692   AC_CACHE_CHECK([for the krb5_princ_component macro],
3693                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
3694     AC_TRY_LINK([#include <krb5.h>],
3695       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
3696       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
3697       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
3698
3699   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
3700     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
3701                [Whether krb5_princ_component is available])
3702   fi
3703
3704   AC_CACHE_CHECK([for key in krb5_keytab_entry],
3705                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
3706     AC_TRY_COMPILE([#include <krb5.h>],
3707       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
3708       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
3709       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
3710
3711   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
3712     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
3713               [Whether krb5_keytab_entry has key member])
3714   fi
3715
3716   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
3717                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
3718     AC_TRY_COMPILE([#include <krb5.h>],
3719       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
3720       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
3721       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
3722
3723   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
3724     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
3725               [Whether krb5_keytab_entry has keyblock member])
3726   fi
3727
3728   AC_CACHE_CHECK([for magic in krb5_address],
3729                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
3730     AC_TRY_COMPILE([#include <krb5.h>],
3731       [krb5_address addr; addr.magic = 0;],
3732       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
3733       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
3734
3735   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
3736     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
3737               [Whether the krb5_address struct has a magic property])
3738   fi
3739
3740   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
3741     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
3742     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
3743     AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
3744     AC_MSG_RESULT(yes)
3745   else
3746     if test x"$with_ads_support" = x"yes"; then
3747         AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
3748     else
3749         AC_MSG_WARN(libkrb5 is needed for Active Directory support)
3750     fi
3751     KRB5_LIBS=""
3752     with_ads_support=no 
3753   fi
3754
3755   AC_CACHE_CHECK([for WRFILE: keytab support],
3756                 samba_cv_HAVE_WRFILE_KEYTAB,[
3757     AC_TRY_RUN([
3758 #include<krb5.h>
3759   main()
3760   {
3761     krb5_context context;
3762     krb5_keytab keytab;
3763
3764     krb5_init_context(&context);
3765     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
3766   }],
3767   samba_cv_HAVE_WRFILE_KEYTAB=yes,
3768   samba_cv_HAVE_WRFILE_KEYTAB=no)])
3769
3770   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
3771       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
3772                [Whether the WRFILE:-keytab is supported])
3773   fi
3774
3775   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
3776                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3777     AC_TRY_COMPILE([#include <krb5.h>],
3778     [
3779     krb5_context context;
3780     krb5_principal principal;
3781     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3782     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3783     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3784
3785   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3786     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3787               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3788   fi
3789
3790   AC_CACHE_CHECK([for krb5_addresses type],
3791                 samba_cv_HAVE_KRB5_ADDRESSES,[
3792     AC_TRY_COMPILE([#include <krb5.h>],
3793       [krb5_addresses addr;],
3794       samba_cv_HAVE_KRB5_ADDRESSES=yes,
3795       samba_cv_HAVE_KRB5_ADDRESSES=no)])
3796
3797   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
3798     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
3799                [Whether the type krb5_addresses type exists])
3800   fi
3801
3802 LIBS="$ac_save_LIBS"
3803 fi
3804
3805 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
3806
3807
3808 ########################################################
3809 # Compile with DNS Updates support?
3810
3811 with_dnsupdate_support=no
3812 AC_MSG_CHECKING([whether to enable DNS Updates support])
3813
3814 AC_ARG_WITH(dnsupdate,
3815 [  --with-dnsupdate        Enable DNS Updates support (default no)],
3816 [ case "$withval" in
3817     yes|no)
3818         with_dnsupdate_support=$withval
3819         ;;
3820   esac ])
3821
3822 AC_MSG_RESULT($with_dnsupdate_support)
3823
3824 if test x"$with_dnsupdate_support" != x"no"; then
3825
3826   ################################################################
3827   # first test for Active Directory support being enabled
3828   #if test x"$with_ads_support" = x"no"; then
3829   #             AC_MSG_ERROR(Active Directory support is required to enable DNS Update support)
3830   #             with_dnsupdate_support=no
3831   #fi           
3832   ##################################################################
3833   # then test for uuid.h (necessary to generate unique DNS keynames
3834   # (uuid.h is required for this test)
3835   AC_CHECK_HEADERS(uuid/uuid.h)
3836   
3837   if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
3838         if test x"$with_dnsupdate_support" = x"yes"; then
3839          AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
3840         else
3841          AC_MSG_WARN(uuid.h is needed to enable DNS Updates support)
3842         fi
3843         with_dnsupdate_support=no
3844   fi
3845 fi
3846
3847 if test x"$with_dnsupdate_support" != x"no"; then
3848   ac_save_LIBS=$LIBS
3849
3850   ########################################################
3851   # now see if we can find the uuid libs in standard paths
3852   AC_CHECK_LIB_EXT(uuid, UUID_LIBS, uuid_generate)
3853
3854   LIBS="$LIBS $UUID_LIBS"
3855   
3856   if test x"$ac_cv_lib_ext_uuid_uuid_generate" = x"yes"; then
3857     with_dnsupdate_support=yes
3858     AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
3859     AC_MSG_CHECKING(whether UUID support is used)
3860     AC_MSG_RESULT(yes)
3861   else
3862     if test x"$with_dnsupdate_support" = x"yes"; then
3863         AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
3864     else
3865         AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
3866     fi
3867     UUID_LIBS=""
3868     with_dnsupdate_support=no
3869   fi
3870   LIBS=$ac_save_LIBS
3871 fi
3872
3873 #################################################
3874 # check for automount support
3875 AC_MSG_CHECKING(whether to use automount)
3876 AC_ARG_WITH(automount,
3877 [  --with-automount        Include automount support (default=no)],
3878 [ case "$withval" in
3879   yes)
3880     AC_MSG_RESULT(yes)
3881     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3882     ;;
3883   *)
3884     AC_MSG_RESULT(no)
3885     ;;
3886   esac ],
3887   AC_MSG_RESULT(no)
3888 )
3889
3890 #################################################
3891 # check for smbmount support
3892 AC_MSG_CHECKING(whether to use smbmount)
3893 AC_ARG_WITH(smbmount,
3894 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
3895 [ case "$withval" in
3896   yes)
3897         case "$host_os" in
3898         *linux*)
3899                 AC_MSG_RESULT(yes)
3900                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
3901                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
3902                 ;;
3903         *)
3904                 AC_MSG_ERROR(not on a linux system!)
3905                 ;;
3906         esac
3907     ;;
3908   *)
3909     AC_MSG_RESULT(no)
3910     ;;
3911   esac ],
3912   AC_MSG_RESULT(no)
3913 )
3914
3915 #################################################
3916 # check for mount- and umount.cifs support
3917 CIFSMOUNT_PROGS=""
3918 INSTALL_CIFSMOUNT=""
3919 UNINSTALL_CIFSMOUNT=""
3920 AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
3921 AC_ARG_WITH(cifsmount,
3922 [  --with-cifsmount        Include mount.cifs and umount.cifs (Linux only) support (default=yes)],
3923 [ case "$withval" in
3924   no)
3925         AC_MSG_RESULT(no)
3926         ;;
3927   *)
3928         case "$host_os" in
3929         *linux*)
3930                 AC_MSG_RESULT(yes)
3931                 AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
3932                 CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
3933                 INSTALL_CIFSMOUNT="installcifsmount"
3934                 UNINSTALL_CIFSMOUNT="uninstallcifsmount"
3935                 ;;
3936         *)
3937                 AC_MSG_ERROR(not on a linux system!)
3938                 ;;
3939         esac
3940     ;;
3941   esac ],
3942 [ case "$host_os" in
3943   *linux*)
3944         AC_MSG_RESULT(yes)
3945         AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
3946         CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
3947         INSTALL_CIFSMOUNT="installcifsmount"
3948         UNINSTALL_CIFSMOUNT="uninstallcifsmount"
3949         ;;
3950   *)
3951         AC_MSG_RESULT(no)
3952         ;;
3953   esac ]
3954 )
3955
3956
3957 #################################################
3958 # check for a PAM clear-text auth, accounts, password and session support
3959 with_pam_for_crypt=no
3960 AC_MSG_CHECKING(whether to use PAM)
3961 AC_ARG_WITH(pam,
3962 [  --with-pam              Include PAM support (default=no)],
3963 [ case "$withval" in
3964   yes)
3965     AC_MSG_RESULT(yes)
3966     if test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3967        if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
3968           if test x"$ac_cv_header_security__pam_macros_h" = x"no"; then
3969              AC_MSG_ERROR(--with-pam specified but no PAM headers found)
3970           fi
3971        fi
3972     fi
3973     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
3974     AUTH_LIBS="$AUTH_LIBS -lpam"
3975     with_pam_for_crypt=yes
3976     ;;
3977   *)
3978     AC_MSG_RESULT(no)
3979     ;;
3980   esac ],
3981   AC_MSG_RESULT(no)
3982 )
3983
3984 # we can't build a pam module if we don't have pam.
3985 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
3986 AC_CHECK_LIB(pam, pam_vsyslog, [AC_DEFINE(HAVE_PAM_VSYSLOG,1,[Whether pam_vsyslog is available])])
3987
3988 #################################################
3989 # check for pam_smbpass support
3990 PAM_MODULES=""
3991 INSTALL_PAM_MODULES=""
3992 UNINSTALL_PAM_MODULES=""
3993 AC_MSG_CHECKING(whether to use pam_smbpass)
3994 AC_ARG_WITH(pam_smbpass,
3995 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
3996 [ case "$withval" in
3997   yes)
3998     AC_MSG_RESULT(yes)
3999
4000        # Conditions under which pam_smbpass should not be built.
4001
4002        if test x"$PICFLAGS" = x; then
4003           AC_MSG_ERROR([No support for PIC code])
4004        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
4005           AC_MSG_ERROR([No security/pam_appl.h found])
4006        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
4007           AC_MSG_ERROR([No libpam found])
4008        else
4009           AUTH_LIBS="$AUTH_LIBS -lpam"
4010           PAM_MODULES="pam_smbpass"
4011           INSTALL_PAM_MODULES="installpammodules"
4012           UNINSTALL_PAM_MODULES="uninstallpammodules"
4013        fi
4014     ;;
4015   *)
4016     AC_MSG_RESULT(no)
4017     ;;
4018   esac ],
4019   AC_MSG_RESULT(no)
4020 )
4021
4022
4023 ###############################################
4024 # test for where we get crypt() from
4025 AC_SEARCH_LIBS(crypt, [crypt],
4026   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
4027   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
4028
4029 ##
4030 ## moved after the check for -lcrypt in order to
4031 ## ensure that the necessary libraries are included
4032 ## check checking for truncated salt.  Wrapped by the
4033 ## $with_pam_for_crypt variable as above   --jerry
4034 ##
4035 if test $with_pam_for_crypt = no; then
4036 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
4037 crypt_LIBS="$LIBS"
4038 LIBS="$AUTH_LIBS $LIBS"
4039 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
4040         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
4041 LIBS="$crypt_LIBS"])
4042 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
4043         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
4044 fi
4045 fi
4046
4047 #################################################
4048 # check for a NISPLUS_HOME support 
4049 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
4050 AC_ARG_WITH(nisplus-home,
4051 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
4052 [ case "$withval" in
4053   yes)
4054     AC_MSG_RESULT(yes)
4055     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
4056     ;;
4057   *)
4058     AC_MSG_RESULT(no)
4059     ;;
4060   esac ],
4061   AC_MSG_RESULT(no)
4062 )
4063
4064 #################################################
4065 # check for syslog logging
4066 AC_MSG_CHECKING(whether to use syslog logging)
4067 AC_ARG_WITH(syslog,
4068 [  --with-syslog           Include experimental SYSLOG support (default=no)],
4069 [ case "$withval" in
4070   yes)
4071     AC_MSG_RESULT(yes)
4072     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
4073     ;;
4074   *)
4075     AC_MSG_RESULT(no)
4076     ;;
4077   esac ],
4078   AC_MSG_RESULT(no)
4079 )
4080
4081 #################################################
4082 # check for experimental disk-quotas support
4083
4084 samba_cv_WITH_QUOTAS=auto
4085 samba_cv_TRY_QUOTAS=no
4086 samba_cv_RUN_QUOTA_TESTS=auto
4087 samba_cv_WITH_SYS_QUOTAS=auto
4088 samba_cv_TRY_SYS_QUOTAS=auto
4089 samba_cv_SYSQUOTA_FOUND=no
4090
4091 AC_MSG_CHECKING(whether to try disk-quotas support)
4092 AC_ARG_WITH(quotas,
4093 [  --with-quotas           Include disk-quota support (default=no)],
4094 [ case "$withval" in
4095   yes)
4096     AC_MSG_RESULT(yes)
4097     samba_cv_WITH_QUOTAS=yes
4098     samba_cv_TRY_QUOTAS=yes
4099     samba_cv_RUN_QUOTA_TESTS=yes
4100     #set sys quotas to auto in this case
4101     samba_cv_TRY_SYS_QUOTAS=auto
4102     ;;
4103   auto)
4104     AC_MSG_RESULT(auto)
4105     samba_cv_WITH_QUOTAS=auto
4106     samba_cv_TRY_QUOTAS=auto
4107     samba_cv_RUN_QUOTA_TESTS=auto
4108     #set sys quotas to auto in this case
4109     samba_cv_TRY_SYS_QUOTAS=auto
4110     ;;
4111   no)
4112     AC_MSG_RESULT(no)
4113     samba_cv_WITH_QUOTAS=no
4114     samba_cv_TRY_QUOTAS=no
4115     samba_cv_RUN_QUOTA_TESTS=no
4116     ;;
4117   *)
4118     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4119     ;;
4120   esac ],
4121   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4122 )
4123
4124 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4125 AC_ARG_WITH(sys-quotas,
4126 [  --with-sys-quotas       Include lib/sysquotas.c support (default=auto)],
4127 [ case "$withval" in
4128   yes)
4129     AC_MSG_RESULT(yes)
4130     samba_cv_WITH_SYS_QUOTAS=yes
4131     samba_cv_TRY_SYS_QUOTAS=yes
4132     samba_cv_RUN_QUOTA_TESTS=yes
4133     ;;
4134   auto)
4135     AC_MSG_RESULT(auto)
4136     samba_cv_WITH_SYS_QUOTAS=auto
4137     samba_cv_TRY_SYS_QUOTAS=auto
4138     samba_cv_RUN_QUOTA_TESTS=auto
4139     ;;
4140   no)
4141     AC_MSG_RESULT(no)
4142     samba_cv_WITH_SYS_QUOTAS=no
4143     samba_cv_TRY_SYS_QUOTAS=no
4144     ;;
4145   *)
4146     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4147     ;;
4148   esac ],
4149   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4150 )
4151
4152 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4153 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4154   case "$host_os" in
4155         *linux*)
4156             AC_MSG_RESULT(yes)
4157             samba_cv_TRY_SYS_QUOTAS=yes
4158             samba_cv_RUN_QUOTA_TESTS=yes
4159             ;;
4160         *)
4161             AC_MSG_RESULT(no)
4162             samba_cv_TRY_SYS_QUOTAS=no
4163             ;;
4164   esac
4165 fi
4166
4167 #############################################
4168 # only check for quota stuff if --with-quotas
4169 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4170
4171 case "$host_os" in
4172         # on linux we didn't need to test we have builtin support
4173         *linux*)
4174             samba_cv_SYSQUOTA_FOUND=yes
4175             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4176             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4177             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4178             AC_MSG_RESULT(yes)
4179
4180             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4181             samba_cv_found_xfs_header=yes
4182             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4183             AC_MSG_RESULT(yes)
4184             ;;
4185         *solaris*)
4186             # need to set this define when using static linking (BUG 1473)
4187             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4188             ;;
4189         *)
4190             ;;
4191 esac
4192
4193 # some broken header files need this
4194 AC_CHECK_HEADER(asm/types.h,[
4195             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4196             AC_ADD_INCLUDE(<asm/types.h>)
4197             ])
4198
4199 # For quotas on Veritas VxFS filesystems
4200 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4201
4202 # For sys/quota.h and linux/quota.h
4203 AC_CHECK_HEADERS(sys/quota.h)
4204
4205 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4206 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4207 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4208 AC_TRY_COMPILE([
4209 #include "confdefs.h"
4210 #ifdef HAVE_SYS_TYPES_H
4211 #include <sys/types.h>
4212 #endif
4213 #ifdef HAVE_ASM_TYPES_H
4214 #include <asm/types.h>
4215 #endif
4216 #include <sys/quota.h>
4217 ],[int i = Q_XGETQUOTA;],
4218 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4219 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4220         samba_cv_found_xfs_header=yes
4221 fi
4222 fi
4223
4224 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
4225 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4226 AC_TRY_COMPILE([
4227 #include "confdefs.h"
4228 #ifdef HAVE_SYS_QUOTA_H
4229 #include <sys/quota.h>
4230 #endif
4231 ],[
4232 struct dqblk D;
4233 D.dqb_fsoftlimit = 0;],
4234 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4235 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4236         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
4237 fi
4238
4239 ##################
4240 # look for a working quota system
4241
4242 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4243 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
4244 AC_TRY_RUN_STRICT([
4245 #define HAVE_QUOTACTL_4A 1
4246 #define AUTOCONF_TEST 1
4247 #include "confdefs.h"
4248 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4249            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
4250 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
4251     samba_cv_SYSQUOTA_FOUND=yes;
4252     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
4253     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
4254 fi
4255 fi
4256
4257 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4258 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
4259 AC_TRY_RUN_STRICT([
4260 #define HAVE_QUOTACTL_4B 1
4261 #define AUTOCONF_TEST 1
4262 #include "confdefs.h"
4263 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4264            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
4265 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
4266     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
4267     samba_cv_SYSQUOTA_FOUND=yes;
4268     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
4269     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
4270 fi
4271 fi
4272
4273 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4274 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
4275 AC_TRY_RUN_STRICT([
4276 #define HAVE_QUOTACTL_3 1
4277 #define AUTOCONF_TEST 1
4278 #include "confdefs.h"
4279 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4280            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
4281 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
4282     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
4283     samba_cv_SYSQUOTA_FOUND=yes;
4284     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
4285     samba_cv_sysquotas_file="lib/sysquotas_3.c"
4286 fi
4287 fi
4288
4289 #################################################
4290 # check for mntent.h and struct mntent
4291 AC_CHECK_HEADERS(mntent.h)
4292 #################################################
4293 # check for setmntent,getmntent,endmntent
4294 AC_CHECK_FUNCS(setmntent getmntent endmntent)
4295
4296 #################################################
4297 # check for devnm.h and struct mntent
4298 AC_CHECK_HEADERS(devnm.h)
4299 #################################################
4300 # check for devnm
4301 AC_CHECK_FUNCS(devnm)
4302
4303 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
4304     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4305         # if --with-sys-quotas=yes then build it 
4306         # you have can use the get/set quota command smb.conf
4307         # options then
4308         samba_cv_SYSQUOTA_FOUND=auto
4309     fi
4310     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
4311         # if --with-sys-quotas=yes then build it 
4312         # you have can use the get/set quota command smb.conf
4313         # options then
4314         samba_cv_TRY_SYS_QUOTAS=auto
4315     fi
4316 fi
4317
4318 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
4319 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
4320 SAVE_CPPFLAGS="$CPPFLAGS"
4321 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4322 AC_TRY_COMPILE([
4323 #include "confdefs.h"
4324 #define NO_PROTO_H 1
4325 #define NO_CONFIG_H 1
4326 #define HAVE_SYS_QUOTAS 1
4327 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
4328 #include "${srcdir-.}/lib/sysquotas.c"
4329 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
4330 CPPFLAGS="$SAVE_CPPFLAGS"
4331 ])
4332 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
4333 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
4334     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
4335         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4336         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
4337         samba_cv_WE_USE_SYS_QUOTAS=yes
4338         AC_MSG_RESULT(yes)
4339     else
4340         AC_MSG_RESULT(no)
4341     fi
4342 fi
4343 fi
4344
4345 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
4346 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
4347 SAVE_CPPFLAGS="$CPPFLAGS"
4348 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4349 AC_TRY_COMPILE([
4350 #include "confdefs.h"
4351 #define NO_PROTO_H 1
4352 #define NO_CONFIG_H 1
4353 #define HAVE_SYS_QUOTAS 1
4354 #define HAVE_XFS_QUOTAS 1
4355 #include "${srcdir-.}/lib/sysquotas_xfs.c"
4356 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
4357 CPPFLAGS="$SAVE_CPPFLAGS"
4358 ])
4359 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
4360     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
4361         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
4362     fi
4363 fi
4364 fi
4365
4366 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
4367 SAVE_CPPFLAGS="$CPPFLAGS"
4368 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4369 AC_TRY_COMPILE([
4370 #include "confdefs.h"
4371 #define NO_PROTO_H 1
4372 #define NO_CONFIG_H 1
4373 #include "${srcdir-.}/smbd/quotas.c"
4374 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
4375 CPPFLAGS="$SAVE_CPPFLAGS"
4376 ])
4377 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
4378 AC_MSG_CHECKING(whether to use the old quota support)
4379     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
4380       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
4381         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4382         AC_MSG_RESULT(yes)
4383       else
4384         AC_MSG_RESULT(no)
4385       fi
4386     else
4387       AC_MSG_RESULT(no)
4388     fi
4389 fi
4390
4391 ####################
4392 # End of quota check samba_cv_RUN_QUOTA_TESTS
4393 fi
4394
4395 #################################################
4396 # check for experimental utmp accounting
4397
4398 AC_MSG_CHECKING(whether to support utmp accounting)
4399 WITH_UTMP=yes
4400 AC_ARG_WITH(utmp,
4401 [  --with-utmp             Include utmp accounting (default, if supported by OS)],
4402 [ case "$withval" in
4403   no)
4404                 WITH_UTMP=no
4405                 ;;
4406   *)
4407                 WITH_UTMP=yes
4408                 ;;
4409   esac ],
4410 )
4411
4412 # utmp requires utmp.h
4413 # Note similar check earlier, when checking utmp details.
4414
4415 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
4416         utmp_no_reason=", no utmp.h on $host_os"
4417         WITH_UTMP=no
4418 fi
4419
4420 # Display test results
4421
4422 if test x"$WITH_UTMP" = x"yes"; then
4423         AC_MSG_RESULT(yes)
4424         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
4425 else
4426         AC_MSG_RESULT(no$utmp_no_reason)
4427 fi
4428
4429 INSTALLLIBCMD_SH=:
4430 INSTALLLIBCMD_A=:
4431 UNINSTALLLIBCMD_SH=:
4432 UNINSTALLLIBCMD_A=:
4433
4434 if test $BLDSHARED = true; then
4435         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
4436         UNINSTALLLIBCMD_SH="rm -f"
4437 fi
4438 if test $enable_static = yes; then
4439         INSTALLLIBCMD_A="\$(INSTALLCMD)"
4440         UNINSTALLLIBCMD_A="rm -f"
4441 fi
4442
4443 #################################################
4444 # should we build libmsrpc?
4445 INSTALL_LIBMSRPC=
4446 UNINSTALL_LIBMSRPC=
4447 LIBMSRPC_SHARED=
4448 LIBMSRPC=
4449 AC_MSG_CHECKING(whether to build the libmsrpc shared library)
4450 AC_ARG_WITH(libmsrpc,
4451 [  --with-libmsrpc         Build the libmsrpc shared library (default=yes if shared libs supported)],
4452 [ case "$withval" in
4453   no) 
4454      AC_MSG_RESULT(no)
4455      ;;
4456   *)
4457      if test $BLDSHARED = true; then
4458         LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
4459         LIBMSRPC=libmsrpc
4460         AC_MSG_RESULT(yes)
4461      else
4462         enable_static=yes
4463         AC_MSG_RESULT(no shared library support -- will supply static library)
4464      fi
4465      if test $enable_static = yes; then
4466         LIBMSRPC=libmsrpc
4467      fi
4468      INSTALL_LIBMSRPC=installlibmsrpc
4469      UNINSTALL_LIBMSRPC=uninstalllibmsrpc
4470      ;;
4471   esac ],
4472 [
4473 # if unspecified, default is to built it if possible.
4474   if test $BLDSHARED = true; then
4475      LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
4476      LIBMSRPC=libmsrpc
4477      AC_MSG_RESULT(yes)
4478    else
4479      enable_static=yes
4480      AC_MSG_RESULT(no shared library support -- will supply static library)
4481    fi
4482    if test $enable_static = yes; then
4483      LIBMSRPC=libmsrpc
4484   fi]
4485   INSTALL_LIBMSRPC=installlibmsrpc
4486   UNINSTALL_LIBMSRPC=uninstalllibmsrpc
4487 )
4488
4489
4490 #################################################
4491 # should we build libaddns?
4492 INSTALL_LIBADDNS=
4493 UNINSTALL_LIBADDNS=
4494 LIBADDNS_SHARED=
4495 LIBADDNS=
4496 AC_MSG_CHECKING(whether to build the libaddns shared library)
4497 AC_ARG_WITH(libaddns,
4498 [  --with-libaddns         Build the libaddns shared library (default=yes if shared libs supported)],
4499 [ case "$withval" in
4500   no) 
4501      AC_MSG_RESULT(no)
4502      ;;
4503   *)
4504      if test $BLDSHARED = true; then
4505         LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
4506         LIBADDNS=libaddns
4507         AC_MSG_RESULT(yes)
4508      else
4509         enable_static=yes
4510         AC_MSG_RESULT(no shared library support -- will supply static library)
4511      fi
4512      if test $enable_static = yes; then
4513         LIBADDNS=libaddns
4514      fi
4515      INSTALL_LIBADDNS=installlibaddns
4516      UNINSTALL_LIBADDNS=uninstalllibaddns
4517      ;;
4518   esac ],
4519 [
4520 # if unspecified, default is to built it if possible.
4521   if test $BLDSHARED = true; then
4522      LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
4523      LIBADDNS=libaddns
4524      AC_MSG_RESULT(yes)
4525    else
4526      enable_static=yes
4527      AC_MSG_RESULT(no shared library support -- will supply static library)
4528    fi
4529    if test $enable_static = yes; then
4530      LIBADDNS=libaddns
4531   fi]
4532   INSTALL_LIBADDNS=installlibaddns
4533   UNINSTALL_LIBADDNS=uninstalllibaddns
4534 )
4535
4536 #################################################
4537 # should we build libsmbclient?
4538 INSTALL_LIBSMBCLIENT=
4539 UNINSTALL_LIBSMBCLIENT=
4540 LIBSMBCLIENT_SHARED=
4541 LIBSMBCLIENT=
4542 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
4543 AC_ARG_WITH(libsmbclient,
4544 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
4545 [ case "$withval" in
4546   no) 
4547      AC_MSG_RESULT(no)
4548      ;;
4549   *)
4550      if test $BLDSHARED = true; then
4551         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4552         LIBSMBCLIENT=libsmbclient
4553         AC_MSG_RESULT(yes)
4554      else
4555         enable_static=yes
4556         AC_MSG_RESULT(no shared library support -- will supply static library)
4557      fi
4558      if test $enable_static = yes; then
4559         LIBSMBCLIENT=libsmbclient
4560      fi
4561      INSTALL_LIBSMBCLIENT=installclientlib
4562      UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4563      ;;
4564   esac ],
4565 [
4566 # if unspecified, default is to built it if possible.
4567   if test $BLDSHARED = true; then
4568      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4569      LIBSMBCLIENT=libsmbclient
4570      AC_MSG_RESULT(yes)
4571    else
4572      enable_static=yes
4573      AC_MSG_RESULT(no shared library support -- will supply static library)
4574    fi
4575    if test $enable_static = yes; then
4576      LIBSMBCLIENT=libsmbclient
4577   fi]
4578   INSTALL_LIBSMBCLIENT=installclientlib
4579   UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4580 )
4581
4582 INSTALL_LIBSMBSHAREMODES=
4583 LIBSMBSHAREMODES_SHARED=
4584 LIBSMBSHAREMODES=
4585 AC_MSG_CHECKING(whether to build the libsmbsharemodes shared library)
4586 AC_ARG_WITH(libsmbsharemodes,
4587 [  --with-libsmbsharemodes     Build the libsmbsharemodes shared library (default=yes if shared libs supported)],
4588 [ case "$withval" in
4589   no)
4590      AC_MSG_RESULT(no)
4591      ;;
4592   *)
4593      if test $BLDSHARED = true; then
4594         LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4595         LIBSMBSHAREMODES=libsmbsharemodes
4596         AC_MSG_RESULT(yes)
4597      else
4598         enable_static=yes
4599         AC_MSG_RESULT(no shared library support -- will supply static library)
4600      fi
4601      if test $enable_static = yes; then
4602         LIBSMBSHAREMODES=libsmbsharemodes
4603      fi
4604      INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4605      UNINSTALL_LIBSMBSHAREMODES=uninstalllibsmbsharemodes
4606      ;;
4607   esac ],
4608 [
4609 # if unspecified, default is to built it if possible.
4610   if test $BLDSHARED = true; then
4611      LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4612      LIBSMBSHAREMODES=libsmbsharemodes
4613      AC_MSG_RESULT(yes)
4614    else
4615      enable_static=yes
4616      AC_MSG_RESULT(no shared library support -- will supply static library)
4617    fi
4618    if test $enable_static = yes; then
4619      LIBSMBSHAREMODES=libsmbsharemodes
4620   fi]
4621   INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4622 )
4623
4624 #################################################
4625 # these tests are taken from the GNU fileutils package
4626 AC_CHECKING(how to get filesystem space usage)
4627 space=no
4628
4629 # Test for statvfs64.
4630 if test $space = no; then
4631   # SVR4
4632   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
4633   [AC_TRY_RUN([
4634 #if defined(HAVE_UNISTD_H)
4635 #include <unistd.h>
4636 #endif
4637 #include <sys/types.h>
4638 #include <sys/statvfs.h>
4639   main ()
4640   {
4641     struct statvfs64 fsd;
4642     exit (statvfs64 (".", &fsd));
4643   }],
4644   fu_cv_sys_stat_statvfs64=yes,
4645   fu_cv_sys_stat_statvfs64=no,
4646   fu_cv_sys_stat_statvfs64=cross)])
4647   if test $fu_cv_sys_stat_statvfs64 = yes; then
4648     space=yes
4649     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
4650   fi
4651 fi
4652
4653 # Perform only the link test since it seems there are no variants of the
4654 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
4655 # because that got a false positive on SCO OSR5.  Adding the declaration
4656 # of a `struct statvfs' causes this test to fail (as it should) on such
4657 # systems.  That system is reported to work fine with STAT_STATFS4 which
4658 # is what it gets when this test fails.
4659 if test $space = no; then
4660   # SVR4
4661   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
4662                  [AC_TRY_LINK([#include <sys/types.h>
4663 #include <sys/statvfs.h>],
4664                               [struct statvfs fsd; statvfs (0, &fsd);],
4665                               fu_cv_sys_stat_statvfs=yes,
4666                               fu_cv_sys_stat_statvfs=no)])
4667   if test $fu_cv_sys_stat_statvfs = yes; then
4668     space=yes
4669     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
4670   fi
4671 fi
4672
4673 # smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
4674 # This is not the case on ancient Linux systems.
4675
4676 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
4677     AC_TRY_COMPILE([#include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
4678         samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
4679 if test x"$samba_cv_fsid_int" = x"yes"; then
4680     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
4681 fi
4682
4683 if test $space = no; then
4684   # DEC Alpha running OSF/1
4685   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
4686   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
4687   [AC_TRY_RUN([
4688 #include <sys/param.h>
4689 #include <sys/types.h>
4690 #include <sys/mount.h>
4691   main ()
4692   {
4693     struct statfs fsd;
4694     fsd.f_fsize = 0;
4695     exit (statfs (".", &fsd, sizeof (struct statfs)));
4696   }],
4697   fu_cv_sys_stat_statfs3_osf1=yes,
4698   fu_cv_sys_stat_statfs3_osf1=no,
4699   fu_cv_sys_stat_statfs3_osf1=no)])
4700   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
4701   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
4702     space=yes
4703     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
4704   fi
4705 fi
4706
4707 if test $space = no; then
4708 # AIX
4709   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
4710 member (AIX, 4.3BSD)])
4711   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
4712   [AC_TRY_RUN([
4713 #ifdef HAVE_SYS_PARAM_H
4714 #include <sys/param.h>
4715 #endif
4716 #ifdef HAVE_SYS_MOUNT_H
4717 #include <sys/mount.h>
4718 #endif
4719 #ifdef HAVE_SYS_VFS_H
4720 #include <sys/vfs.h>
4721 #endif
4722   main ()
4723   {
4724   struct statfs fsd;
4725   fsd.f_bsize = 0;
4726   exit (statfs (".", &fsd));
4727   }],
4728   fu_cv_sys_stat_statfs2_bsize=yes,
4729   fu_cv_sys_stat_statfs2_bsize=no,
4730   fu_cv_sys_stat_statfs2_bsize=no)])
4731   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
4732   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
4733     space=yes
4734     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
4735   fi
4736 fi
4737
4738 if test $space = no; then
4739 # SVR3
4740   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
4741   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
4742   [AC_TRY_RUN([#include <sys/types.h>
4743 #include <sys/statfs.h>
4744   main ()
4745   {
4746   struct statfs fsd;
4747   exit (statfs (".", &fsd, sizeof fsd, 0));
4748   }],
4749     fu_cv_sys_stat_statfs4=yes,
4750     fu_cv_sys_stat_statfs4=no,
4751     fu_cv_sys_stat_statfs4=no)])
4752   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
4753   if test $fu_cv_sys_stat_statfs4 = yes; then
4754     space=yes
4755     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
4756   fi
4757 fi
4758
4759 if test $space = no; then
4760 # 4.4BSD and NetBSD
4761   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
4762 member (4.4BSD and NetBSD)])
4763   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
4764   [AC_TRY_RUN([#include <sys/types.h>
4765 #ifdef HAVE_SYS_PARAM_H
4766 #include <sys/param.h>
4767 #endif
4768 #ifdef HAVE_SYS_MOUNT_H
4769 #include <sys/mount.h>
4770 #endif
4771   main ()
4772   {
4773   struct statfs fsd;
4774   fsd.f_fsize = 0;
4775   exit (statfs (".", &fsd));
4776   }],
4777   fu_cv_sys_stat_statfs2_fsize=yes,
4778   fu_cv_sys_stat_statfs2_fsize=no,
4779   fu_cv_sys_stat_statfs2_fsize=no)])
4780   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
4781   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
4782     space=yes
4783         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
4784   fi
4785 fi
4786
4787 if test $space = no; then
4788   # Ultrix
4789   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
4790   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
4791   [AC_TRY_RUN([#include <sys/types.h>
4792 #ifdef HAVE_SYS_PARAM_H
4793 #include <sys/param.h>
4794 #endif
4795 #ifdef HAVE_SYS_MOUNT_H
4796 #include <sys/mount.h>
4797 #endif
4798 #ifdef HAVE_SYS_FS_TYPES_H
4799 #include <sys/fs_types.h>
4800 #endif
4801   main ()
4802   {
4803   struct fs_data fsd;
4804   /* Ultrix's statfs returns 1 for success,
4805      0 for not mounted, -1 for failure.  */
4806   exit (statfs (".", &fsd) != 1);
4807   }],
4808   fu_cv_sys_stat_fs_data=yes,
4809   fu_cv_sys_stat_fs_data=no,
4810   fu_cv_sys_stat_fs_data=no)])
4811   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
4812   if test $fu_cv_sys_stat_fs_data = yes; then
4813     space=yes
4814     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
4815   fi
4816 fi
4817
4818 #
4819 # As a gating factor for large file support, in order to
4820 # use <4GB files we must have the following minimal support
4821 # available.
4822 # long long, and a 64 bit off_t or off64_t.
4823 # If we don't have all of these then disable large
4824 # file support.
4825 #
4826 AC_MSG_CHECKING([if large file support can be enabled])
4827 AC_TRY_COMPILE([
4828 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
4829 #include <sys/types.h>
4830 #else
4831 __COMPILE_ERROR_
4832 #endif
4833 ],
4834 [int i],
4835 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
4836 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
4837         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
4838 fi
4839 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
4840
4841 AC_ARG_WITH(spinlocks, 
4842 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
4843 if test "x$with_spinlocks" = "xyes"; then
4844     AC_DEFINE(USE_SPINLOCKS,1,[Whether to use spin locks instead of fcntl locks])
4845
4846     case "$host_cpu" in
4847         sparc)
4848             AC_DEFINE(SPARC_SPINLOCKS,1,[Whether to use sparc spinlocks])
4849             ;;
4850
4851         i386|i486|i586|i686)
4852             AC_DEFINE(INTEL_SPINLOCKS,1,[Whether to use intel spinlocks])
4853             ;;
4854
4855         mips)
4856             AC_DEFINE(MIPS_SPINLOCKS,1,[Whether to use mips spinlocks])
4857             ;;
4858
4859         powerpc)
4860             AC_DEFINE(POWERPC_SPINLOCKS,1,[Whether to use powerpc spinlocks])
4861             ;;
4862     esac
4863 fi
4864
4865 #################################################
4866 # check for cluster extensions
4867
4868 AC_MSG_CHECKING(whether to include cluster support)
4869 AC_ARG_WITH(cluster-support, 
4870 [  --with-cluster-support  Enable cluster extensions (default=no)])
4871 if test "x$with_cluster_support" = "xyes"; then
4872     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
4873     AC_MSG_RESULT(yes)
4874 else
4875     AC_MSG_RESULT(no)
4876 fi
4877
4878
4879 #################################################
4880 # check for ACL support
4881
4882 AC_MSG_CHECKING(whether to support ACLs)
4883 AC_ARG_WITH(acl-support,
4884 [  --with-acl-support      Include ACL support (default=no)],
4885 [ case "$withval" in
4886   yes)
4887
4888         case "$host_os" in
4889         *sysv5*)
4890                 AC_MSG_RESULT(Using UnixWare ACLs)
4891                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
4892                 default_static_modules="$default_static_modules vfs_solarisacl"
4893                 ;;
4894         *solaris*)
4895                 AC_MSG_RESULT(Using solaris ACLs)
4896                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
4897                 ACL_LIBS="$ACL_LIBS -lsec"
4898                 default_static_modules="$default_static_modules vfs_solarisacl"
4899                 ;;
4900         *hpux*)
4901                 AC_MSG_RESULT(Using HPUX ACLs)
4902                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
4903                 default_static_modules="$default_static_modules vfs_hpuxacl"
4904                 ;;
4905         *irix*)
4906                 AC_MSG_RESULT(Using IRIX ACLs)
4907                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
4908                 default_static_modules="$default_static_modules vfs_irixacl"
4909                 ;;
4910         *aix*)
4911                 AC_MSG_RESULT(Using AIX ACLs)
4912                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
4913                 default_static_modules="$default_static_modules vfs_aixacl"
4914                 ;;
4915         *osf*)
4916                 AC_MSG_RESULT(Using Tru64 ACLs)
4917                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
4918                 ACL_LIBS="$ACL_LIBS -lpacl"
4919                 default_static_modules="$default_static_modules vfs_tru64acl"
4920                 ;;
4921         *freebsd[[5-9]]*)
4922                 AC_MSG_RESULT(Using FreeBSD posix ACLs)
4923                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
4924                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4925                 ;;
4926         *linux*)
4927                 AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
4928                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
4929                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
4930                 acl_LIBS=$LIBS
4931                 LIBS="$LIBS -lacl"
4932                 AC_TRY_LINK([#include <sys/types.h>
4933 #include <sys/acl.h>],
4934 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
4935 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
4936                 LIBS=$acl_LIBS])
4937                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4938                                 AC_MSG_RESULT(Using posix ACLs)
4939                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4940                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4941                                 acl_LIBS=$LIBS
4942                                 LIBS="$LIBS -lacl"
4943                                 AC_TRY_LINK([#include <sys/types.h>
4944 #include <sys/acl.h>],
4945 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4946 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4947                                 LIBS=$acl_LIBS])
4948                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4949                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4950                                 fi
4951                         fi
4952             ;;
4953          *)
4954                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
4955                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
4956                 acl_LIBS=$LIBS
4957                 LIBS="$LIBS -lacl"
4958                 AC_TRY_LINK([#include <sys/types.h>
4959 #include <sys/acl.h>],
4960 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
4961 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
4962                 LIBS=$acl_LIBS])
4963                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4964                                 AC_MSG_RESULT(Using posix ACLs)
4965                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4966                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4967                                 acl_LIBS=$LIBS
4968                                 LIBS="$LIBS -lacl"
4969                                 AC_TRY_LINK([#include <sys/types.h>
4970 #include <sys/acl.h>],
4971 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4972 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4973                                 LIBS=$acl_LIBS])
4974                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4975                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4976                                 fi
4977                         fi
4978             ;;
4979         esac
4980         ;;
4981   *)
4982     AC_MSG_RESULT(no)
4983     AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
4984     ;;
4985   esac ],
4986   AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
4987   AC_MSG_RESULT(no)
4988 )
4989
4990 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4991    default_static_modules="$default_static_modules vfs_posixacl"
4992 fi
4993
4994 #################################################
4995 # check for AIO support
4996
4997 AC_MSG_CHECKING(whether to support asynchronous io)
4998 AC_ARG_WITH(aio-support,
4999 [  --with-aio-support      Include asynchronous io support (default=no)],
5000 [ case "$withval" in
5001   yes)
5002
5003         AC_MSG_RESULT(yes)
5004         case "$host_os" in
5005         *)
5006                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
5007                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
5008                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
5009                 aio_LIBS=$LIBS
5010                 LIBS=$AIO_LIBS
5011                 AC_TRY_LINK([#include <sys/types.h>
5012 #include <aio.h>],
5013 [ struct aiocb a; return aio_read(&a);],
5014 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
5015                 LIBS=$aio_LIBS])
5016                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
5017                 aio_LIBS=$LIBS
5018                 LIBS=$AIO_LIBS
5019                 AC_TRY_LINK([#include <sys/types.h>
5020 #include <aio.h>],
5021 [ struct aiocb64 a; return aio_read64(&a);],
5022 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
5023                 LIBS=$aio_LIBS])
5024                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5025                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
5026                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5027                         LIBS=$AIO_LIBS
5028                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
5029                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5030                         LIBS=$AIO_LIBS
5031                 fi
5032
5033                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5034                         AC_MSG_CHECKING(for aio_read)
5035                         AC_LINK_IFELSE([#include <aio.h>
5036 int main() { struct aiocb a; return aio_read(&a); }],
5037 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
5038 [AC_MSG_RESULT(no)])
5039
5040                         AC_MSG_CHECKING(for aio_write)
5041                         AC_LINK_IFELSE([#include <aio.h>
5042 int main() { struct aiocb a; return aio_write(&a); }],
5043 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
5044 [AC_MSG_RESULT(no)])
5045
5046                         AC_MSG_CHECKING(for aio_fsync)
5047                         AC_LINK_IFELSE([#include <aio.h>
5048 int main() { struct aiocb a; return aio_fsync(1, &a); }],
5049 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
5050 [AC_MSG_RESULT(no)])
5051
5052                         AC_MSG_CHECKING(for aio_return)
5053                         AC_LINK_IFELSE([#include <aio.h>
5054 int main() { struct aiocb a; return aio_return(&a); }],
5055 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
5056 [AC_MSG_RESULT(no)])
5057
5058                         AC_MSG_CHECKING(for aio_error)
5059                         AC_LINK_IFELSE([#include <aio.h>
5060 int main() { struct aiocb a; return aio_error(&a); }],
5061 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
5062 [AC_MSG_RESULT(no)])
5063
5064                         AC_MSG_CHECKING(for aio_cancel)
5065                         AC_LINK_IFELSE([#include <aio.h>
5066 int main() { struct aiocb a; return aio_cancel(1, &a); }],
5067 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
5068 [AC_MSG_RESULT(no)])
5069
5070                         AC_MSG_CHECKING(for aio_suspend)
5071                         AC_LINK_IFELSE([#include <aio.h>
5072 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
5073 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
5074 [AC_MSG_RESULT(no)])
5075                 fi
5076
5077                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5078                         AC_MSG_CHECKING(for aio_read64)
5079                         AC_LINK_IFELSE([#include <aio.h>
5080 int main() { struct aiocb a; return aio_read64(&a); }],
5081 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
5082 [AC_MSG_RESULT(no)])
5083
5084                         AC_MSG_CHECKING(for aio_write64)
5085                         AC_LINK_IFELSE([#include <aio.h>
5086 int main() { struct aiocb a; return aio_write64(&a); }],
5087 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
5088 [AC_MSG_RESULT(no)])
5089
5090                         AC_MSG_CHECKING(for aio_fsync64)
5091                         AC_LINK_IFELSE([#include <aio.h>
5092 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
5093 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
5094 [AC_MSG_RESULT(no)])
5095
5096                         AC_MSG_CHECKING(for aio_return64)
5097                         AC_LINK_IFELSE([#include <aio.h>
5098 int main() { struct aiocb a; return aio_return64(&a); }],
5099 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
5100 [AC_MSG_RESULT(no)])
5101
5102                         AC_MSG_CHECKING(for aio_error64)
5103                         AC_LINK_IFELSE([#include <aio.h>
5104 int main() { struct aiocb a; return aio_error64(&a); }],
5105 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
5106 [AC_MSG_RESULT(no)])
5107
5108                         AC_MSG_CHECKING(for aio_cancel64)
5109                         AC_LINK_IFELSE([#include <aio.h>
5110 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
5111 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
5112 [AC_MSG_RESULT(no)])
5113
5114                         AC_MSG_CHECKING(for aio_suspend64)
5115                         AC_LINK_IFELSE([#include <aio.h>
5116 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
5117 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
5118 [AC_MSG_RESULT(no)])
5119                 fi
5120             ;;
5121         esac
5122         ;;
5123   *)
5124     AC_MSG_RESULT(no)
5125     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
5126     ;;
5127   esac ],
5128   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
5129   AC_MSG_RESULT(no)
5130 )
5131
5132 #################################################
5133 # check for sendfile support
5134
5135 with_sendfile_support=yes
5136 AC_MSG_CHECKING(whether to check to support sendfile)
5137 AC_ARG_WITH(sendfile-support,
5138 [  --with-sendfile-support Check for sendfile support (default=yes)],
5139 [ case "$withval" in
5140   yes)
5141
5142         AC_MSG_RESULT(yes);
5143
5144         case "$host_os" in
5145         *linux*)
5146                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5147                 AC_TRY_LINK([#include <sys/sendfile.h>],
5148 [\
5149 int tofd, fromfd;
5150 off64_t offset;
5151 size_t total;
5152 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
5153 ],
5154 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5155
5156                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
5157                 AC_TRY_LINK([#include <sys/sendfile.h>],
5158 [\
5159 int tofd, fromfd;
5160 off_t offset;
5161 size_t total;
5162 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5163 ],
5164 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5165
5166 # Try and cope with broken Linux sendfile....
5167                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
5168                 AC_TRY_LINK([\
5169 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5170 #undef _FILE_OFFSET_BITS
5171 #endif
5172 #include <sys/sendfile.h>],
5173 [\
5174 int tofd, fromfd;
5175 off_t offset;
5176 size_t total;
5177 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5178 ],
5179 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5180
5181         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5182                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5183                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5184                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5185         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5186                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5187                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5188                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5189         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5190                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5191                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5192         else
5193                 AC_MSG_RESULT(no);
5194         fi
5195
5196         ;;
5197         *freebsd* | *dragonfly* )
5198                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5199                 AC_TRY_LINK([\
5200 #include <sys/types.h>
5201 #include <unistd.h>
5202 #include <sys/socket.h>
5203 #include <sys/uio.h>],
5204 [\
5205         int fromfd, tofd, ret, total=0;
5206         off_t offset, nwritten;
5207         struct sf_hdtr hdr;
5208         struct iovec hdtrl;
5209         hdr.headers = &hdtrl;
5210         hdr.hdr_cnt = 1;
5211         hdr.trailers = NULL;
5212         hdr.trl_cnt = 0;
5213         hdtrl.iov_base = NULL;
5214         hdtrl.iov_len = 0;
5215         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
5216 ],
5217 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5218
5219         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5220                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
5221                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
5222                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5223         else
5224                 AC_MSG_RESULT(no);
5225         fi
5226         ;;
5227
5228         *hpux*)
5229                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5230                 AC_TRY_LINK([\
5231 #include <sys/socket.h>
5232 #include <sys/uio.h>],
5233 [\
5234         int fromfd, tofd;
5235         size_t total=0;
5236         struct iovec hdtrl[2];
5237         ssize_t nwritten;
5238         off64_t offset;
5239
5240         hdtrl[0].iov_base = 0;
5241         hdtrl[0].iov_len = 0;
5242
5243         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
5244 ],
5245 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5246         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5247                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
5248                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5249                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5250         else
5251                 AC_MSG_RESULT(no);
5252         fi
5253
5254                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
5255                 AC_TRY_LINK([\
5256 #include <sys/socket.h>
5257 #include <sys/uio.h>],
5258 [\
5259         int fromfd, tofd;
5260         size_t total=0;
5261         struct iovec hdtrl[2];
5262         ssize_t nwritten;
5263         off_t offset;
5264
5265         hdtrl[0].iov_base = 0;
5266         hdtrl[0].iov_len = 0;
5267
5268         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
5269 ],
5270 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5271         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5272                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5273                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5274                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5275         else
5276                 AC_MSG_RESULT(no);
5277         fi
5278         ;;
5279
5280         *solaris*)
5281                 AC_CHECK_LIB(sendfile,sendfilev)
5282                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
5283                 AC_TRY_LINK([\
5284 #include <sys/sendfile.h>],
5285 [\
5286         int sfvcnt;
5287         size_t xferred;
5288         struct sendfilevec vec[2];
5289         ssize_t nwritten;
5290         int tofd;
5291
5292         sfvcnt = 2;
5293
5294         vec[0].sfv_fd = SFV_FD_SELF;
5295         vec[0].sfv_flag = 0;
5296         vec[0].sfv_off = 0;
5297         vec[0].sfv_len = 0;
5298
5299         vec[1].sfv_fd = 0;
5300         vec[1].sfv_flag = 0;
5301         vec[1].sfv_off = 0;
5302         vec[1].sfv_len = 0;
5303         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
5304 ],
5305 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
5306
5307         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
5308                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
5309                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
5310                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5311         else
5312                 AC_MSG_RESULT(no);
5313         fi
5314
5315                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
5316                 AC_TRY_LINK([\
5317 #include <sys/sendfile.h>],
5318 [\
5319         int sfvcnt;
5320         size_t xferred;
5321         struct sendfilevec vec[2];
5322         ssize_t nwritten;
5323         int tofd;
5324
5325         sfvcnt = 2;
5326
5327         vec[0].sfv_fd = SFV_FD_SELF;
5328         vec[0].sfv_flag = 0;
5329         vec[0].sfv_off = 0;
5330         vec[0].sfv_len = 0;
5331
5332         vec[1].sfv_fd = 0;
5333         vec[1].sfv_flag = 0;
5334         vec[1].sfv_off = 0;
5335         vec[1].sfv_len = 0;
5336         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
5337 ],
5338 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
5339
5340         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
5341                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
5342                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
5343                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5344         else
5345                 AC_MSG_RESULT(no);
5346         fi
5347         ;;
5348         *aix*)
5349                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
5350                 AC_TRY_LINK([\
5351 #include <sys/socket.h>],
5352 [\
5353         int fromfd, tofd;
5354         size_t total=0;
5355         struct sf_parms hdtrl;
5356         ssize_t nwritten;
5357         off64_t offset;
5358
5359         hdtrl.header_data = 0;
5360         hdtrl.header_length = 0;
5361         hdtrl.file_descriptor = fromfd;
5362         hdtrl.file_offset = 0;
5363         hdtrl.file_bytes = 0;
5364         hdtrl.trailer_data = 0;
5365         hdtrl.trailer_length = 0;
5366
5367         nwritten = send_file(&tofd, &hdtrl, 0);
5368 ],
5369 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5370         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5371                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5372                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
5373                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5374         else
5375                 AC_MSG_RESULT(no);
5376         fi
5377         ;;
5378         *)
5379         ;;
5380         esac
5381         ;;
5382   *)
5383     AC_MSG_RESULT(no)
5384     ;;
5385   esac ],
5386   AC_MSG_RESULT(yes)
5387 )
5388
5389
5390 #################################################
5391 # Check whether winbind is supported on this platform.  If so we need to
5392 # build and install client programs, sbin programs and shared libraries
5393
5394 AC_MSG_CHECKING(whether to build winbind)
5395
5396 # Initially, the value of $host_os decides whether winbind is supported
5397
5398 HAVE_WINBIND=yes
5399
5400 # Define the winbind shared library name and any specific linker flags
5401 # it needs to be built with.
5402
5403 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
5404 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
5405 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
5406
5407 case "$host_os" in
5408         *linux*)
5409                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
5410                 ;;
5411         *freebsd[[5-9]]*)
5412                 # FreeBSD winbind client is implemented as a wrapper around
5413                 # the Linux version.
5414                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
5415                     nsswitch/winbind_nss_linux.o"
5416                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
5417                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
5418                 ;;
5419         *irix*)
5420                 # IRIX has differently named shared libraries
5421                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
5422                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
5423                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
5424                 ;;
5425         *solaris*)
5426                 # Solaris winbind client is implemented as a wrapper around
5427                 # the Linux version.
5428                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
5429                     nsswitch/winbind_nss_linux.o"
5430                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
5431                 ;;
5432         *hpux11*)
5433                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
5434                 ;;
5435         *aix*)
5436                 # AIX has even differently named shared libraries.  No
5437                 # WINS support has been implemented yet.
5438                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
5439                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
5440                 WINBIND_NSS="nsswitch/WINBIND"
5441                 WINBIND_WINS_NSS=""
5442                 ;;
5443         *)
5444                 HAVE_WINBIND=no
5445                 winbind_no_reason=", unsupported on $host_os"
5446                 ;;
5447 esac
5448
5449 AC_SUBST(WINBIND_NSS)
5450 AC_SUBST(WINBIND_WINS_NSS)
5451 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
5452 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
5453 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
5454
5455 # Check the setting of --with-winbind
5456
5457 AC_ARG_WITH(winbind,
5458 [  --with-winbind          Build winbind (default, if supported by OS)],
5459
5460   case "$withval" in
5461         yes)
5462                 HAVE_WINBIND=yes
5463                 ;;
5464         no)
5465                 HAVE_WINBIND=no
5466                 winbind_reason=""
5467                 ;;
5468   esac ],
5469 )
5470
5471 # We need unix domain sockets for winbind
5472
5473 if test x"$HAVE_WINBIND" = x"yes"; then
5474         if test x"$samba_cv_unixsocket" = x"no"; then
5475                 winbind_no_reason=", no unix domain socket support on $host_os"
5476                 HAVE_WINBIND=no
5477         fi
5478 fi
5479
5480 # Display test results
5481
5482 if test x"$HAVE_WINBIND" = x"yes"; then
5483         AC_MSG_RESULT(yes)
5484         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
5485
5486         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
5487         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
5488         if test $BLDSHARED = true; then
5489                 SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
5490
5491                 if test x"$with_pam" = x"yes"; then
5492                         PAM_MODULES="$PAM_MODULES pam_winbind"
5493                         INSTALL_PAM_MODULES="installpammodules"
5494                         UNINSTALL_PAM_MODULES="uninstallpammodules"
5495                 fi
5496         fi
5497 else
5498         AC_MSG_RESULT(no$winbind_no_reason)
5499 fi
5500
5501 # Solaris 10 does have new member in nss_XbyY_key
5502 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
5503                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
5504                 [#include <nss_dbdefs.h>])
5505
5506 # Solaris has some extra fields in struct passwd that need to be
5507 # initialised otherwise nscd crashes.  
5508  
5509 AC_CHECK_MEMBER(struct passwd.pw_comment,
5510                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
5511                 [#include <pwd.h>])
5512
5513 AC_CHECK_MEMBER(struct passwd.pw_age,
5514                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
5515                 [#include <pwd.h>])
5516
5517 # AIX 4.3.x and 5.1 do not have as many members in
5518 # struct secmethod_table as AIX 5.2
5519 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
5520        [#include <usersec.h>])
5521 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
5522        [#include <usersec.h>])
5523
5524 AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
5525 AC_TRY_COMPILE([#include <sys/types.h>
5526 #include <sys/socket.h>],
5527 [struct ucred cred;
5528  socklen_t cred_len;
5529  int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
5530 ],
5531 samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
5532 if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
5533     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
5534 fi
5535
5536
5537 #################################################
5538 # Check to see if we should use the included popt 
5539
5540 AC_ARG_WITH(included-popt,
5541 [  --with-included-popt    use bundled popt library, not from system],
5542
5543   case "$withval" in
5544         yes)
5545                 INCLUDED_POPT=yes
5546                 ;;
5547         no)
5548                 INCLUDED_POPT=no
5549                 ;;
5550   esac ],
5551 )
5552 if test x"$INCLUDED_POPT" != x"yes"; then
5553     AC_CHECK_LIB(popt, poptGetContext,
5554                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
5555 fi
5556
5557 AC_MSG_CHECKING(whether to use included popt)
5558 if test x"$INCLUDED_POPT" = x"yes"; then
5559     AC_MSG_RESULT(yes)
5560     BUILD_POPT='$(POPT_OBJS)'
5561         POPTLIBS='$(POPT_OBJS)'
5562     FLAGS1="-I\$(srcdir)/popt"
5563 else
5564     AC_MSG_RESULT(no)
5565         BUILD_POPT=""
5566     POPTLIBS="-lpopt"
5567 fi
5568 AC_SUBST(BUILD_POPT)
5569 AC_SUBST(POPTLIBS)
5570 AC_SUBST(FLAGS1)
5571
5572 #################################################
5573 # Check to see if we should use the included iniparser 
5574
5575 AC_ARG_WITH(included-iniparser,
5576 [  --with-included-iniparser    use bundled iniparser library, not from system],
5577
5578   case "$withval" in
5579         yes)
5580                 INCLUDED_INIPARSER=yes
5581                 ;;
5582         no)
5583                 INCLUDED_INIPARSER=no
5584                 ;;
5585   esac ],
5586 )
5587 if test x"$INCLUDED_INIPARSER" != x"yes"; then
5588     AC_CHECK_LIB(iniparser, iniparser_load,
5589                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
5590 fi
5591
5592 AC_MSG_CHECKING(whether to use included iniparser)
5593 if test x"$INCLUDED_INIPARSER" = x"yes"; then
5594     AC_MSG_RESULT(yes)
5595     BUILD_INIPARSER='$(INIPARSER_OBJ)'
5596         INIPARSERLIBS=""
5597     FLAGS1="$FLAGS1 -I\$(srcdir)/iniparser/src"
5598 else
5599     AC_MSG_RESULT(no)
5600         BUILD_INIPARSER=""
5601     INIPARSERLIBS="-liniparser"
5602 fi
5603 AC_SUBST(BUILD_INIPARSER)
5604 AC_SUBST(INIPARSERLIBS)
5605 AC_SUBST(FLAGS1)
5606
5607
5608
5609 #################################################
5610 # Check if the user wants Python
5611
5612 # At the moment, you can use this to set which Python binary to link
5613 # against.  (Libraries built for Python2.2 can't be used by 2.1,
5614 # though they can coexist in different directories.)  In the future
5615 # this might make the Python stuff be built by default.
5616
5617 # Defaulting python breaks the clean target if python isn't installed
5618
5619 PYTHON=
5620
5621 AC_ARG_WITH(python,
5622 [  --with-python=PYTHONNAME  build Python libraries],
5623 [ case "${withval-python}" in
5624   yes)
5625         PYTHON=python
5626         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
5627         ;;
5628   no)
5629         PYTHON=
5630         ;;
5631   *)
5632         PYTHON=${withval-python}
5633         ;;
5634   esac ])
5635 AC_SUBST(PYTHON)
5636
5637 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
5638 do
5639         eval MODULE_DEFAULT_$i=STATIC
5640 done
5641
5642 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
5643 do
5644         dnl Fall back to static if we cannot build shared libraries
5645         eval MODULE_DEFAULT_$i=STATIC
5646
5647         if test $BLDSHARED = true; then
5648                 eval MODULE_DEFAULT_$i=SHARED
5649         fi
5650 done
5651
5652 dnl Always built these modules static
5653 MODULE_rpc_spoolss=STATIC
5654 MODULE_rpc_srv=STATIC
5655 MODULE_idmap_tdb=STATIC
5656
5657 AC_ARG_WITH(static-modules,
5658 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
5659 [ if test $withval; then
5660         for i in `echo $withval | sed -e 's/,/ /g'`
5661         do
5662                 eval MODULE_$i=STATIC
5663         done
5664 fi ])
5665
5666 AC_ARG_WITH(shared-modules,
5667 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
5668 [ if test $withval; then
5669         for i in `echo $withval | sed -e 's/,/ /g'`
5670         do
5671                         eval MODULE_$i=SHARED
5672         done
5673 fi ])
5674
5675 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB, 
5676                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
5677 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
5678 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
5679 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
5680
5681
5682 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
5683 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
5684 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
5685 SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
5686 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
5687 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
5688 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
5689 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
5690 SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
5691 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
5692 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
5693 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
5694 SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
5695 SMB_MODULE(rpc_unixinfo, \$(RPC_UNIXINFO_OBJ), "bin/librpc_unixinfo.$SHLIBEXT", RPC)
5696 SMB_SUBSYSTEM(RPC,smbd/server.o)
5697
5698 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
5699 SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
5700 SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
5701 SMB_MODULE(idmap_ad, sam/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
5702 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
5703
5704 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
5705 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
5706 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
5707 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
5708 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
5709
5710 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
5711 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
5712 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
5713 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
5714 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
5715 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
5716 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
5717 SMB_SUBSYSTEM(AUTH,auth/auth.o)
5718
5719 SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
5720 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
5721 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
5722 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
5723 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
5724 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
5725 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
5726 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
5727 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
5728 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
5729 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
5730 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
5731 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
5732 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
5733 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
5734 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
5735 SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
5736 SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
5737 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
5738 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
5739 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
5740 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
5741 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
5742 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
5743
5744 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
5745
5746 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
5747
5748 #################################################
5749 # do extra things if we are running insure
5750
5751 if test "${ac_cv_prog_CC}" = "insure"; then
5752         CPPFLAGS="$CPPFLAGS -D__INSURE__"
5753 fi
5754
5755 #################################################
5756 # If run from the build farm, enable NASTY hacks
5757 #################################################
5758 AC_MSG_CHECKING(whether to enable build farm hacks)
5759 if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
5760         AC_MSG_RESULT(yes)
5761         AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
5762 else
5763         AC_MSG_RESULT(no)
5764 fi
5765
5766 #################################################
5767 # check for bad librt/libpthread interactions
5768
5769 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
5770     x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
5771     x"$samba_cv_HAVE_AIO64" = x"yes" -o \
5772     x"$samba_cv_HAVE_AIO" = x"yes" ; then
5773
5774 SMB_IF_RTSIGNAL_BUG(
5775         [
5776             # Have RT_SIGNAL bug, need to check whether the problem will
5777             # affect anything we have configured.
5778
5779             rt_do_error=no
5780             if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
5781                 if test x"$rt_signal_lease_ok" = x"no" ; then
5782                     rt_do_error=yes
5783                 fi
5784             fi
5785
5786             if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
5787                 if test x"$rt_signal_notify_ok" = x"no" ; then
5788                     rt_do_error=yes
5789                 fi
5790             fi
5791
5792             if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
5793                     x"$samba_cv_HAVE_AIO" = x"yes" ; then
5794                 if test x"$rt_signal_aio_ok" = x"no" ; then
5795                     rt_do_error=yes
5796                 fi
5797             fi
5798
5799             if test x"$rt_do_error" = x"yes" ; then
5800                 SMB_IS_LIBPTHREAD_LINKED(
5801                     [
5802                         cat<<MSG
5803
5804 *** On this platforms, linking Samba against pthreads causes problems
5805 *** with the oplock and change notification mechanisms. You may be
5806 *** using pthreads as a side-effect of using the --with-aio-support
5807 *** or --with-profiling-data options. Please remove these and try again.
5808
5809 MSG
5810                     ],
5811                     [
5812                         cat<<MSG
5813
5814 *** On this platform, the oplock and change notification mechanisms do not
5815 *** appear to work. Please report this problem to samba-technical@samba.org
5816 *** and attach the config.log file from this directory.
5817
5818 MSG
5819                     ])
5820                 AC_MSG_ERROR(unable to use realtime signals on this platform)
5821             fi
5822         ],
5823         [
5824             # no RT_SIGNAL bug, we are golden
5825             SMB_IS_LIBPTHREAD_LINKED(
5826                 [
5827                     AC_MSG_WARN(using libpthreads - this may degrade performance)
5828                 ])
5829
5830         ],
5831         [
5832             # cross compiling, I hope you know what you are doing
5833             true
5834         ])
5835
5836 fi
5837
5838 #################################################
5839 # Display summary of libraries detected
5840
5841 AC_MSG_RESULT([Using libraries:])
5842 AC_MSG_RESULT([    LIBS = $LIBS])
5843 if test x"$with_ads_support" != x"no"; then
5844    AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
5845 fi
5846 if test x"$with_ldap_support" != x"no"; then
5847    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
5848 fi
5849 if test x"$with_dnsupdate_support" != x"no"; then
5850         AC_MSG_RESULT([   UUID_LIBS = $UUID_LIBS])
5851 fi
5852 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
5853
5854 #################################################
5855 # final configure stuff
5856
5857 AC_MSG_CHECKING([configure summary])
5858 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
5859            AC_MSG_RESULT(yes),
5860            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
5861            AC_MSG_WARN([cannot run when cross-compiling]))
5862
5863 builddir=`pwd`
5864 AC_SUBST(builddir)
5865
5866 # Stuff the smbd-only libraries at the end of the smbd link
5867 # path (if we have them).
5868 SMBD_LIBS="$samba_fam_libs $samba_dmapi_libs"
5869 AC_SUBST(SMBD_LIBS)
5870
5871 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
5872 LIB_REMOVE_USR_LIB(LDFLAGS)
5873 LIB_REMOVE_USR_LIB(LIBS)
5874
5875 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
5876 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
5877 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
5878
5879 AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)
5880
5881 #################################################
5882 # Print very concise instructions on building/use
5883 if test "x$enable_dmalloc" = xyes
5884 then
5885         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
5886         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
5887 fi