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