r22731: - Fix bug #4594.
[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 AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
8
9 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
10 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
11
12 SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
13 if test -n "${SAMBA_VERSION_SVN_REVISION}";then
14         echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
15 fi
16
17 AC_LIBREPLACE_LOCATION_CHECKS
18
19 AC_DISABLE_STATIC
20 AC_ENABLE_SHARED
21
22 #################################################
23 # Directory handling stuff to support both the
24 # legacy SAMBA directories and FHS compliant
25 # ones...
26 AC_PREFIX_DEFAULT(/usr/local/samba)
27
28 rootsbindir="\${SBINDIR}"
29 lockdir="\${VARDIR}/locks"
30 piddir="\${VARDIR}/locks"
31 test "${mandir}" || mandir="\${prefix}/man"
32 logfilebase="\${VARDIR}"
33 privatedir="\${prefix}/private"
34 test "${libdir}" || libdir="\${prefix}/lib"
35 pammodulesdir="\${LIBDIR}/security"
36 configdir="\${LIBDIR}"
37 swatdir="\${prefix}/swat"
38
39 AC_ARG_WITH(fhs,
40 [  --with-fhs              Use FHS-compliant paths (default=no)],
41 [ case "$withval" in
42   yes)
43     lockdir="\${VARDIR}/lib/samba"
44     piddir="\${VARDIR}/run"
45     mandir="\${prefix}/share/man"
46     logfilebase="\${VARDIR}/log/samba"
47     privatedir="\${CONFIGDIR}/private"
48     libdir="\${prefix}/lib/samba"
49     configdir="\${sysconfdir}/samba"
50     swatdir="\${DATADIR}/samba/swat"
51     ;;
52   esac])
53
54 #################################################
55 # set private directory location
56 AC_ARG_WITH(privatedir,
57 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
58 [ case "$withval" in
59   yes|no)
60   #
61   # Just in case anybody calls it without argument
62   #
63     AC_MSG_WARN([--with-privatedir called without argument - will use default])
64   ;;
65   * )
66     privatedir="$withval"
67     ;;
68   esac])
69
70 #################################################
71 # set root sbin directory location
72 AC_ARG_WITH(rootsbindir,
73 [  --with-rootsbindir=DIR  Which directory to use for root sbin ($ac_default_prefix/sbin)],
74 [ case "$withval" in
75   yes|no)
76   #
77   # Just in case anybody calls it without argument
78   #
79     AC_MSG_WARN([--with-rootsbindir called without argument - will use default])
80   ;;
81   * )
82     rootsbindir="$withval"
83     ;;
84   esac])
85
86 #################################################
87 # set lock directory location
88 AC_ARG_WITH(lockdir,
89 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
90 [ case "$withval" in
91   yes|no)
92   #
93   # Just in case anybody calls it without argument
94   #
95     AC_MSG_WARN([--with-lockdir called without argument - will use default])
96   ;;
97   * )
98     lockdir="$withval"
99     ;;
100   esac])
101
102 #################################################
103 # set pid directory location
104 AC_ARG_WITH(piddir,
105 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
106 [ case "$withval" in
107   yes|no)
108   #
109   # Just in case anybody calls it without argument
110   #
111     AC_MSG_WARN([--with-piddir called without argument - will use default])
112   ;;
113   * )
114     piddir="$withval"
115     ;;
116   esac])
117
118 #################################################
119 # set SWAT directory location
120 AC_ARG_WITH(swatdir,
121 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
122 [ case "$withval" in
123   yes|no)
124   #
125   # Just in case anybody does it
126   #
127     AC_MSG_WARN([--with-swatdir called without argument - will use default])
128   ;;
129   * )
130     swatdir="$withval"
131     ;;
132   esac])
133
134 #################################################
135 # set configuration directory location
136 AC_ARG_WITH(configdir,
137 [  --with-configdir=DIR    Where to put configuration files ($libdir)],
138 [ case "$withval" in
139   yes|no)
140   #
141   # Just in case anybody does it
142   #
143     AC_MSG_WARN([--with-configdir called without argument - will use default])
144   ;;
145   * )
146     configdir="$withval"
147     ;;
148   esac])
149
150 #################################################
151 # set log directory location
152 AC_ARG_WITH(logfilebase,
153 [  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
154 [ case "$withval" in
155   yes|no)
156   #
157   # Just in case anybody does it
158   #
159     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
160   ;;
161   * )
162     logfilebase="$withval"
163     ;;
164   esac])
165
166 #################################################
167 # set lib directory location
168 AC_ARG_WITH(libdir,
169 [  --with-libdir=DIR       Where to put libdir ($libdir)],
170 [ case "$withval" in
171   yes|no)
172   #
173   # Just in case anybody does it
174   #
175     AC_MSG_WARN([--with-libdir without argument - will use default])
176   ;;
177   * )
178     libdir="$withval"
179     ;;
180   esac])
181
182 #################################################
183 # set PAM modules directory location
184 AC_ARG_WITH(pammodulesdir,
185 [  --with-pammodulesdir=DIR  Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)],
186 [ case "$withval" in
187   yes|no)
188   #
189   # Just in case anybody calls it without argument
190   #
191     AC_MSG_WARN([--with-pammodulesdir called without argument - will use default])
192   ;;
193   * )
194     pammodulesdir="$withval"
195     ;;
196   esac])
197
198 #################################################
199 # set man directory location
200 AC_ARG_WITH(mandir,
201 [  --with-mandir=DIR       Where to put man pages ($mandir)],
202 [ case "$withval" in
203   yes|no)
204   #
205   # Just in case anybody does it
206   #
207     AC_MSG_WARN([--with-mandir without argument - will use default])
208   ;;
209   * )
210     mandir="$withval"
211     ;;
212   esac])
213
214 AC_ARG_WITH(cfenc,
215 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
216                           for optimization (Mac OS X/Darwin only)],
217 [
218 # May be in source $withval/CoreFoundation/StringEncodings.subproj.
219 # Should have been in framework $withval/CoreFoundation.framework/Headers.
220 for d in \
221     $withval/CoreFoundation/StringEncodings.subproj \
222     $withval/StringEncodings.subproj \
223     $withval/CoreFoundation.framework/Headers \
224     $withval/Headers \
225     $withval
226 do
227     if test -r $d/CFStringEncodingConverter.h; then
228         ln -sfh $d include/CoreFoundation
229     fi
230 done
231 ])
232
233 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
234 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace"
235 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/talloc"
236 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/tdb/include"
237 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
238 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
239
240 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/popt"
241
242 ## cleanup the $(srcdir) in the Makefile if we are outside of the tree
243 if test "x${srcdir-.}" != "x."; then
244         SAMBA_CPPFLAGS=`echo ${SAMBA_CPPFLAGS} | sed -e "s;${srcdir};\$\(srcdir\);g"`
245 fi
246
247 AC_SUBST(configdir)
248 AC_SUBST(lockdir)
249 AC_SUBST(piddir)
250 AC_SUBST(logfilebase)
251 AC_SUBST(privatedir)
252 AC_SUBST(swatdir)
253 AC_SUBST(bindir)
254 AC_SUBST(sbindir)
255 AC_SUBST(rootsbindir)
256 AC_SUBST(pammodulesdir)
257
258 dnl Unique-to-Samba variables we'll be playing with.
259 AC_SUBST(SAMBA_CPPFLAGS)
260 AC_SUBST(SHELL)
261 AC_SUBST(LDSHFLAGS)
262 AC_SUBST(MODULE_EXPORTS)
263 AC_SUBST(SONAMEFLAG)
264 AC_SUBST(SHLD)
265 AC_SUBST(HOST_OS)
266 AC_SUBST(PICFLAG)
267 AC_SUBST(PIE_CFLAGS)
268 AC_SUBST(PIE_LDFLAGS)
269 AC_SUBST(SHLIBEXT)
270 AC_SUBST(INSTALLLIBCMD_SH)
271 AC_SUBST(INSTALLLIBCMD_A)
272 AC_SUBST(UNINSTALLLIBCMD_SH)
273 AC_SUBST(UNINSTALLLIBCMD_A)
274 AC_SUBST(INSTALL_LIBMSRPC)
275 AC_SUBST(UNINSTALL_LIBMSRPC)
276 AC_SUBST(LIBMSRPC_SHARED)
277 AC_SUBST(LIBMSRPC)
278 AC_SUBST(INSTALL_LIBADDNS)
279 AC_SUBST(UNINSTALL_LIBADDNS)
280 AC_SUBST(LIBADDNS_SHARED)
281 AC_SUBST(LIBADDNS)
282 AC_SUBST(INSTALL_LIBSMBCLIENT)
283 AC_SUBST(UNINSTALL_LIBSMBCLIENT)
284 AC_SUBST(LIBSMBCLIENT_SHARED)
285 AC_SUBST(LIBSMBCLIENT)
286 AC_SUBST(INSTALL_LIBSMBSHAREMODES)
287 AC_SUBST(UNINSTALL_LIBSMBSHAREMODES)
288 AC_SUBST(LIBSMBSHAREMODES_SHARED)
289 AC_SUBST(LIBSMBSHAREMODES)
290 AC_SUBST(PRINT_LIBS)
291 AC_SUBST(AUTH_LIBS)
292 AC_SUBST(ACL_LIBS)
293 AC_SUBST(PASSDB_LIBS)
294 AC_SUBST(IDMAP_LIBS)
295 AC_SUBST(KRB5_LIBS)
296 AC_SUBST(UUID_LIBS)
297 AC_SUBST(LDAP_LIBS)
298 AC_SUBST(PAM_MODULES)
299 AC_SUBST(INSTALL_PAM_MODULES)
300 AC_SUBST(UNINSTALL_PAM_MODULES)
301 AC_SUBST(NSS_MODULES)
302 AC_SUBST(EXTRA_BIN_PROGS)
303 AC_SUBST(SMBMOUNT_PROGS)
304 AC_SUBST(CIFSMOUNT_PROGS)
305 AC_SUBST(INSTALL_CIFSMOUNT)
306 AC_SUBST(UNINSTALL_CIFSMOUNT)
307 AC_SUBST(EXTRA_SBIN_PROGS)
308 AC_SUBST(EXTRA_ALL_TARGETS)
309 AC_SUBST(CONFIG_LIBS)
310 AC_SUBST(NSCD_LIBS)
311
312 ## check for --enable-debug first before checking CFLAGS before
313 ## so that we don't mix -O and -g
314 AC_ARG_ENABLE(debug,
315 [  --enable-debug          Turn on compiler debugging information (default=no)],
316     [if eval "test x$enable_debug = xyes"; then
317         CFLAGS="${CFLAGS} -g"
318     fi])
319
320 # compile with optimization and without debugging by default, but
321 # allow people to set their own preference.
322 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
323 # if it has no value.  This prevent *very* large debug binaries from occurring
324 # by default.
325 if test "x$CFLAGS" = x; then
326   CFLAGS="-O"
327 fi
328
329 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
330
331 AC_LIBREPLACE_CC_CHECKS
332
333 m4_include(lib/socket_wrapper/config.m4)
334
335 #################################################
336 # set prefix for 'make test'
337 selftest_prefix="./"
338 AC_SUBST(selftest_prefix)
339 AC_ARG_WITH(selftest-prefix,
340 [  --with-selftest-prefix=DIR    The prefix where make test will be runned ($selftest_prefix)],
341 [ case "$withval" in
342   yes|no)
343     AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
344   ;;
345   * )
346     selftest_prefix="$withval"
347     ;;
348   esac
349 ])
350
351 AC_ARG_ENABLE(launchd,
352 [  --enable-launchd        Support running under launchd (default=auto)])
353
354 if test x"$enable_launchd" != x"no" ; then
355     AC_CACHE_CHECK([whether to include launchd support],
356         samba_cv_launchd_support,
357         [
358             AC_TRY_COMPILE(
359             [
360 #include <launch.h>
361             ],
362             [
363                 launchd_msg(NULL);
364                 launchd_data_get_fd(NULL);
365             ],
366             samba_cv_launchd_support=yes,
367             samba_cv_launchd_support=no)
368         ])
369
370     if test x"$samba_cv_launchd_support" = x"yes" ; then
371         AC_DEFINE(WITH_LAUNCHD_SUPPORT, 1,
372                     [Whether launchd support should be enabled])
373     else
374         if test x"$enable_launchd" = x"yes" ; then
375             AC_ERROR(launchd support is not available)
376         fi
377     fi
378 fi
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         DEVELOPER_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        ])
417        if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
418             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
419        fi
420         # here
421         #-Werror-implicit-function-declaration
422         AC_CACHE_CHECK(
423           [that the C compiler understands -Werror-implicit-function-declaration],
424           samba_cv_HAVE_Werror_implicit_function_declaration, [
425           AC_TRY_RUN_STRICT([
426             int main(void)
427             {
428                 return 0;
429             }],[-Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
430             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
431             samba_cv_HAVE_Werror_implicit_function_declaration=no,
432             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
433        ])
434        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
435             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
436        fi
437     fi])
438
439 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
440     [if eval "test x$enable_krb5developer = xyes"; then
441         developer=yes
442         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
443     fi])
444
445 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
446
447 if test "x$enable_dmalloc" = xyes
448 then
449         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
450         AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
451                   [Define to check invariants around some common functions])
452         LIBS="$LIBS -ldmalloc"  
453 fi
454
455 #################################################
456 # check for a shared memory profiling support
457 AC_MSG_CHECKING(whether to use profiling)
458 AC_ARG_WITH(profiling-data,
459 [  --with-profiling-data   Include gathering source code profile information (default=no)],
460 [ case "$withval" in
461   yes)
462     AC_MSG_RESULT(yes)
463     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
464     samba_cv_WITH_PROFILE=yes
465     ;;
466   *)
467     AC_MSG_RESULT(no)
468     samba_cv_WITH_PROFILE=no
469     ;;
470   esac ],
471   AC_MSG_RESULT(no)
472 )
473
474 dnl Checks for programs.
475
476 AC_PROG_INSTALL
477 AC_PROG_AWK
478 AC_PATH_PROG(PERL, perl)
479
480 AC_CHECK_TOOL(AR, ar)
481
482 dnl Check if we use GNU ld
483 LD=ld
484 AC_PROG_LD_GNU
485
486 dnl Certain versions of GNU ld the default is not to have the
487 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
488 dnl warnings when building modules.
489 if test "$ac_cv_prog_gnu_ld" = "yes"; then
490         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
491         AC_MSG_CHECKING(GNU ld release date)
492         changequote(,)dnl
493         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'`
494         changequote([,])dnl
495         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
496         if test -n "$ac_cv_gnu_ld_date"; then
497         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
498                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
499         fi
500         else
501            AC_MSG_CHECKING(GNU ld release version)
502            changequote(,)dnl
503            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
504            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
505            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
506            changequote([,])dnl
507            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
508            AC_MSG_CHECKING(GNU ld release version major)
509            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
510            AC_MSG_CHECKING(GNU ld release version minor)
511            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
512            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
513              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
514            fi
515         fi
516 fi
517
518 dnl look for executable suffix
519 AC_EXEEXT
520
521 dnl Check if C compiler understands -c and -o at the same time
522 AC_PROG_CC_C_O
523 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
524       BROKEN_CC=
525 else
526       BROKEN_CC=#
527 fi
528 AC_SUBST(BROKEN_CC)
529
530 dnl Check if the C compiler understands -Werror
531 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
532  AC_TRY_RUN_STRICT([
533   int main(void)
534   {
535         return 0;
536   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
537   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
538 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
539    Werror_FLAGS="-Werror"
540 else
541 dnl Check if the C compiler understands -w2
542 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
543  AC_TRY_RUN_STRICT([
544   int main(void)
545   {
546         return 0;
547   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
548   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
549 if test x"$samba_cv_HAVE_w2" = x"yes"; then
550    Werror_FLAGS="-w2"
551 fi
552 fi
553
554 dnl Check if the C compiler understands volatile (it should, being ANSI).
555 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
556     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
557         samba_cv_volatile=yes,samba_cv_volatile=no)])
558 if test x"$samba_cv_volatile" = x"yes"; then
559    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
560 fi
561
562 ############################################
563 # check if the compiler can handle negative enum values
564 # and don't truncate the values to INT_MAX
565 # a runtime test is needed here
566 AC_SUBST(PIDL_ARGS)
567 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
568     AC_TRY_RUN(
569 [
570         #include <stdio.h>
571         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
572         int main(void) {
573                 enum negative_values v1 = NEGATIVE_VALUE;
574                 unsigned v2 = NEGATIVE_VALUE;
575
576                 if (v1 != 0xFFFFFFFF) {
577                         printf("%u != 0xFFFFFFFF\n", v1);
578                         return 1;
579                 }
580                 if (v2 != 0xFFFFFFFF) {
581                         printf("%u != 0xFFFFFFFF\n", v2);
582                         return 1;
583                 }
584
585                 return 0;
586         }
587 ],
588         SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
589 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
590         AC_MSG_WARN([using --unit-enums for pidl])
591         PIDL_ARGS="$PIDL_ARGS --uint-enums"
592 fi
593
594 ############################################
595 # Check whether we can do automatic dependency tracking
596
597 m4_include(m4/substnot.m4)
598 m4_include(m4/cond.m4)
599 m4_include(m4/make.m4)
600 m4_include(m4/depout.m4)
601 m4_include(m4/lead-dot.m4)
602 m4_include(m4/check_gnu_make.m4)
603 m4_include(m4/depend.m4)
604
605 # Using the dependency files requires GNU make until someone adds support
606 # for Makefile includes for other make implementations. Note that
607 # CHECK_GNU_MAKE() can find a non-default make.
608 CHECK_GNU_MAKE()
609 if test "x$_cv_gnu_make_command" != "x" -a \
610     x`which make` = x`which "$_cv_gnu_make_command"` ; then
611     AC_SUBST(MAKE, $_cv_gnu_make_command)
612 else
613     # If GNU make is not the default, don't enable GNU-isms because we can't
614     # guarantee that GNU make will actually be the make that is invoked.
615     ifGNUmake='#'
616 fi
617
618 AM_DEP_TRACK()
619 _AM_DEPENDENCIES(CC)
620
621 ############################################
622 # Figure out the flags to support named structure initializers
623
624 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
625
626 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
627 AC_MSG_CHECKING(uname -s)
628 AC_MSG_RESULT(${UNAME_S})
629
630 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
631 AC_MSG_CHECKING(uname -r)
632 AC_MSG_RESULT(${UNAME_R})
633
634 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
635 AC_MSG_CHECKING(uname -m)
636 AC_MSG_RESULT(${UNAME_M})
637
638 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
639 AC_MSG_CHECKING(uname -p)
640 AC_MSG_RESULT(${UNAME_P})
641
642 dnl Add #include for broken IRIX header files
643   case "$host_os" in
644         *irix6*)
645                 #TODO add to libreplace
646                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
647                         dnl Fix sensible defaults for MIPSPro compilers. The
648                         dnl error numbers are valid for the 7.3 compilers,
649                         dnl hopefully also valid for the 7.4 series.
650                         dnl
651                         dnl Bugzilla 3801. Force an error on warning 1035
652                         dnl so we don't incorrectly detect stdint.h. This
653                         dnl warning is emitted for #error directives.
654                         CFLAGS="$CFLAGS -diag_error 1035"
655                         dnl 1209: Controlling expression is constant
656                         dnl 1174: Function foo declared but never referenced
657                         dnl 3201: Parameter foo was never referenced
658                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
659                 fi
660         ;;
661 esac
662
663 DYNEXP=
664 AC_SUBST(DYNEXP)
665
666 dnl Add modules that have to be built by default here
667 dnl These have to be built static:
668 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 rpc_epmapper auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
669
670 dnl These are preferably build shared, and static if dlopen() is not available
671 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 vfs_readahead"
672
673 if test "x$developer" = xyes; then
674    default_static_modules="$default_static_modules rpc_rpcecho"
675    default_shared_modules="$default_shared_modules charset_weird"
676 fi
677
678 #
679 # Config CPPFLAG settings for strange OS's that must be set
680 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
681 # case statement; its first reference must be unconditional.
682 #
683 case "$host_os" in
684     *hpux*)
685 #
686 # Defines needed for HPUX support.
687 # HPUX has bigcrypt but (sometimes?) doesn't use it for
688 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
689 #
690       case `uname -r` in
691                         *9*|*10*)
692                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
693                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
694                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
695                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
696                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
697                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
698                                 ;;
699                         *11*)
700                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
701                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
702                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
703                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
704                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
705                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
706                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
707                                 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Unix 98 sources -- needed for socklen_t in getsockopt on HP/UX 11])
708                                 ;;
709       esac
710       ;;
711
712 #
713 # CRAY Unicos has broken const handling
714        *unicos*)
715           AC_MSG_RESULT([disabling const])
716           CPPFLAGS="$CPPFLAGS -Dconst="
717           ;;
718         
719 #
720 # AIX4.x doesn't even admit to having large
721 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
722 #
723     *aix4*)
724           AC_MSG_RESULT([enabling large file support])
725       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
726           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
727       ;;
728 #
729 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
730 # to the existance of large files..
731 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
732 # recommendations on large file support, however it makes the
733 # compile work using gcc 2.7 and 2.8, whereas using the Sun
734 # recommendation makes the compile fail on gcc2.7. JRA.
735 #
736 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
737 #
738         *solaris*)
739                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
740                 case `uname -r` in
741                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
742                                 AC_MSG_RESULT([no large file support])
743                                 ;;
744                         5.*)
745                         AC_MSG_RESULT([enabling large file support])
746                         if test "$ac_cv_prog_gcc" = yes; then
747                                 ${CC-cc} -v >conftest.c 2>&1
748                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
749                                 rm -fr conftest.c
750                                 case "$ac_cv_gcc_compiler_version_number" in
751                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
752                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
753                                                 LDFLAGS="$LDFLAGS -lthread"
754                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
755                                                 ;;
756                                         *)
757                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
758                                                 LDFLAGS="$LDFLAGS -lthread"
759                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
760                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
761                                                 ;;
762                                 esac
763                         else
764                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
765                                 LDFLAGS="$LDFLAGS -lthread"
766                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
767                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
768                         fi
769                         ;;
770                 esac
771                 ;;
772 #
773 # IRIX uses SYSV printing.  Make sure to set that here
774 #
775         *irix*)
776                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
777                 ;;
778         *freebsd*|*dragonfly*)
779                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
780                 ;;
781 #
782 # VOS may need to have POSIX support and System V compatibility enabled.
783 #
784     *vos*)
785     case "$CPPFLAGS" in
786           *-D_POSIX_C_SOURCE*)
787                 ;;
788           *)
789                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
790                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
791                 ;;
792     esac
793     case "$CPPFLAGS" in
794           *-D_SYSV*|*-D_SVID_SOURCE*)
795                 ;;
796           *)
797                 CPPFLAGS="$CPPFLAGS -D_SYSV"
798                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
799     esac
800     ;;
801 #
802 # Tests needed for SINIX large file support.
803 #
804     *sysv4*)
805       if test $host = mips-sni-sysv4 ; then
806         AC_MSG_CHECKING([for LFS support])
807         old_CPPFLAGS="$CPPFLAGS"
808         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
809         AC_TRY_RUN([
810 #include <unistd.h>
811 int main () {
812 #if _LFS64_LARGEFILE == 1
813 return 0;
814 #else
815 return 1;
816 #endif
817 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
818         CPPFLAGS="$old_CPPFLAGS"
819         if test x$SINIX_LFS_SUPPORT = xyes ; then
820           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
821                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
822           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
823           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
824           LIBS="`getconf LFS64_LIBS` $LIBS"
825         fi
826       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
827       fi
828     ;;
829
830 # Systems with LFS support.
831 #
832     gnu* | k*bsd*-gnu)
833         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
834         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
835         AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
836         AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
837         ;;
838
839 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
840 #
841     *linux*)
842         AC_MSG_CHECKING([for LFS support])
843         old_CPPFLAGS="$CPPFLAGS"
844         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
845        AC_TRY_RUN([
846 #include <unistd.h>
847 #include <sys/utsname.h>
848 #include <string.h>
849 #include <stdlib.h>
850 int main() {
851 #if _LFS64_LARGEFILE == 1
852        struct utsname uts;
853        char *release;
854        int major, minor;
855
856        /* Ensure this is glibc 2.2 or higher */
857 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
858        int libc_major = __GLIBC__;
859        int libc_minor = __GLIBC_MINOR__;
860
861        if (libc_major < 2)
862               return 1;
863        if (libc_minor < 2)
864               return 1;
865 #endif
866
867        /* Ensure this is kernel 2.4 or higher */
868
869        uname(&uts);
870        release = strdup(uts.release);
871        major = atoi(strsep(&release, "."));
872        minor = atoi(strsep(&release, "."));
873
874        if (major > 2 || (major == 2 && minor > 3))
875                return 0;
876        return 1;
877 #else
878        return 1;
879 #endif
880 }
881 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
882         CPPFLAGS="$old_CPPFLAGS"
883         if test x$LINUX_LFS_SUPPORT = xyes ; then
884                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
885                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
886                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
887                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
888         fi
889         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
890         ;;
891
892 #
893 # MacOS X is the *only* system that uses compose character in utf8. This
894 # is so horribly broken....
895 #
896     *darwin*)
897         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
898
899         # Add a system specific charset module.
900         default_shared_modules="$default_shared_modules charset_macosxfs"
901
902         ;;
903     *hurd*)
904         AC_MSG_CHECKING([for LFS support])
905         old_CPPFLAGS="$CPPFLAGS"
906         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
907         AC_TRY_RUN([
908 #include <unistd.h>
909 main () {
910 #if _LFS64_LARGEFILE == 1
911 return 0;
912 #else
913 return 1;
914 #endif
915 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
916         CPPFLAGS="$old_CPPFLAGS"
917         if test x$GLIBC_LFS_SUPPORT = xyes ; then
918           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
919                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
920           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
921         fi
922       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
923     ;;
924
925 esac
926
927 AC_LIBREPLACE_BROKEN_CHECKS
928
929 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
930
931 LIBREPLACE_OBJS=""
932 for obj in ${LIBREPLACEOBJ}; do
933         LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
934 done
935 AC_SUBST(LIBREPLACE_OBJS)
936
937 # add -ldl to the global LIBS
938 LIBS="${LIBS} ${LIBDL}"
939
940 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)
941 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
942 AC_CHECK_HEADERS(limits.h float.h)
943 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
944 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
945 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
946 AC_CHECK_HEADERS(sys/un.h)
947 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
948 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
949 AC_CHECK_HEADERS(sys/sysmacros.h)
950 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
951 AC_CHECK_HEADERS(langinfo.h locale.h)
952 AC_CHECK_HEADERS(xfs/libxfs.h)
953
954 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
955 #if HAVE_RPC_RPC_H
956 #include <rpc/rpc.h>
957 #endif
958 ]])
959
960 ## These fail to compile on IRIX so just check for their presence
961 AC_CHECK_HEADERS(sys/mode.h,,,)
962
963 # Look for Darwin headers
964 old_CPPFLAGS="$CPPFLAGS"
965 CPPFLAGS="-Iinclude $CPPFLAGS"
966 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
967 CPPFLAGS="$old_CPPFLAGS"
968
969 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
970 # subdirectory of headers.
971 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
972
973 # check for linux on amd64 since valgrind is not quite there yet
974 case "$host_os" in
975         *linux*)
976                 case "$UNAME_P" in
977                         *x86_64*)
978                                 AC_DEFINE(HAVE_64BIT_LINUX,1,[Whether we are running on 64bit linux])
979                                 ;;
980                 esac
981                 ;;
982 esac
983
984
985 #
986 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
987 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
988 #
989 case "$host_os" in
990     *hpux*)
991                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
992                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
993                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
994                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
995                 fi
996         ;;
997 esac
998 AC_CHECK_HEADERS(shadow.h)
999 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
1000 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
1001
1002 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
1003 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
1004
1005 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
1006
1007 # For experimental utmp support (lastlog on some BSD-like systems)
1008 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
1009
1010 AC_CHECK_SIZEOF(int,cross)
1011 AC_CHECK_SIZEOF(long,cross)
1012 AC_CHECK_SIZEOF(long long,cross)
1013 AC_CHECK_SIZEOF(short,cross)
1014
1015 AC_C_CONST
1016 AC_C_INLINE
1017 AC_C_BIGENDIAN
1018 AC_C_CHAR_UNSIGNED
1019
1020 AC_TYPE_SIGNAL
1021 AC_TYPE_UID_T
1022 AC_TYPE_MODE_T
1023 AC_TYPE_OFF_T
1024 AC_TYPE_SIZE_T
1025 AC_TYPE_PID_T
1026 AC_STRUCT_ST_RDEV
1027 AC_DIRENT_D_OFF
1028 AC_CHECK_TYPE(ino_t,unsigned)
1029 AC_CHECK_TYPE(loff_t,off_t)
1030 AC_CHECK_TYPE(offset_t,loff_t)
1031 AC_CHECK_TYPE(ssize_t, int)
1032 AC_CHECK_TYPE(wchar_t, unsigned short)
1033 AC_CHECK_TYPE(comparison_fn_t,
1034 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
1035
1036 ############################################
1037 # for cups support we need libcups, and a handful of header files
1038
1039 AC_ARG_ENABLE(cups,
1040 [  --enable-cups           Turn on CUPS support (default=auto)])
1041
1042 if test x$enable_cups != xno; then
1043         AC_PATH_PROG(CUPS_CONFIG, cups-config)
1044
1045         if test "x$CUPS_CONFIG" != x; then
1046                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
1047                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
1048                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
1049                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
1050         elif test x"$enable_cups" = x"yes"; then
1051                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
1052         fi
1053 fi
1054
1055 AC_ARG_ENABLE(iprint,
1056 [  --enable-iprint         Turn on iPrint support (default=yes if cups is yes)])
1057
1058 if test x$enable_iprint != xno; then
1059         if test "x$CUPS_CONFIG" != x; then
1060                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
1061         elif test x"$enable_iprint" = x"yes"; then
1062                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
1063         fi
1064 fi
1065
1066 ############################################
1067 # check if the compiler will optimize out function calls
1068 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
1069     AC_TRY_LINK([
1070 #include <stdio.h>],
1071 [
1072                 if (0) {
1073                    this_function_does_not_exist();
1074                 } else {
1075                   return 1;
1076                 }
1077
1078 ],
1079         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
1080 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
1081    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
1082 fi
1083
1084 ############################################
1085 # check for unix domain sockets
1086 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
1087     AC_TRY_COMPILE([
1088 #include <sys/types.h>
1089 #include <stdlib.h>
1090 #include <stddef.h>
1091 #include <sys/socket.h>
1092 #include <sys/un.h>],
1093 [
1094   struct sockaddr_un sunaddr;
1095   sunaddr.sun_family = AF_UNIX;
1096 ],
1097         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
1098 if test x"$samba_cv_unixsocket" = x"yes"; then
1099    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
1100 fi
1101
1102
1103 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
1104     AC_TRY_COMPILE([
1105 #include <sys/types.h>
1106 #if STDC_HEADERS
1107 #include <stdlib.h>
1108 #include <stddef.h>
1109 #endif
1110 #include <sys/socket.h>],[socklen_t i = 0],
1111         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
1112 if test x"$samba_cv_socklen_t" = x"yes"; then
1113    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
1114 fi
1115
1116 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
1117     AC_TRY_COMPILE([
1118 #include <sys/types.h>
1119 #if STDC_HEADERS
1120 #include <stdlib.h>
1121 #include <stddef.h>
1122 #endif
1123 #include <signal.h>],[sig_atomic_t i = 0],
1124         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
1125 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
1126    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
1127 fi
1128
1129 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
1130     AC_TRY_COMPILE([
1131 #include <sys/types.h>
1132 #if STDC_HEADERS
1133 #include <stdlib.h>
1134 #include <stddef.h>
1135 #endif
1136 #if TIME_WITH_SYS_TIME
1137 # include <sys/time.h>
1138 # include <time.h>
1139 #else
1140 # if HAVE_SYS_TIME_H
1141 #  include <sys/time.h>
1142 # else
1143 #  include <time.h>
1144 # endif
1145 #endif
1146 ],[struct timespec ts;],
1147         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
1148 if test x"$samba_cv_struct_timespec" = x"yes"; then
1149    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
1150 fi
1151
1152 # stupid headers have the functions but no declaration. grrrr.
1153 AC_HAVE_DECL(errno, [#include <errno.h>])
1154 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
1155 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
1156 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
1157 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
1158 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
1159 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
1160
1161 # and glibc has setresuid under linux but the function does
1162 # nothing until kernel 2.1.44! very dumb.
1163 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
1164     AC_TRY_RUN([#include <errno.h>
1165 int main() { setresuid(1,1,1); setresuid(2,2,2); return errno==EPERM?0:1;}],
1166         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
1167 if test x"$samba_cv_have_setresuid" = x"yes"; then
1168     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
1169 fi
1170
1171 # Do the same check for setresguid...
1172 #
1173 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
1174     AC_TRY_RUN([#include <unistd.h>
1175 #include <errno.h>
1176 int main() { errno = 0; setresgid(1,1,1); return errno != 0 ? (errno==EPERM ? 0 : 1) : 0;}],
1177         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
1178 if test x"$samba_cv_have_setresgid" = x"yes"; then
1179     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
1180 fi
1181
1182 AC_FUNC_MEMCMP
1183
1184 ###############################################
1185 # Readline included by default unless explicitly asked not to
1186 test "${with_readline+set}" != "set" && with_readline=yes
1187
1188 # test for where we get readline() from
1189 AC_MSG_CHECKING(whether to use readline)
1190 AC_ARG_WITH(readline,
1191 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
1192 [  case "$with_readline" in
1193   yes)
1194     AC_MSG_RESULT(yes)
1195
1196     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1197     AC_CHECK_HEADERS(readline/history.h)
1198
1199     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1200       for termlib in ncurses curses termcap terminfo termlib tinfo; do
1201        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1202       done
1203       AC_CHECK_LIB(readline, rl_callback_handler_install,
1204        [TERMLIBS="-lreadline $TERMLIBS"
1205        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1206        break], [TERMLIBS=], $TERMLIBS)])
1207     ;;
1208   no)
1209     AC_MSG_RESULT(no)
1210     ;;
1211   *)
1212     AC_MSG_RESULT(yes)
1213
1214     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1215     # alternate readline path
1216     _ldflags=${LDFLAGS}
1217     _cppflags=${CPPFLAGS}
1218
1219     # Add additional search path
1220     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1221     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1222
1223     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1224     AC_CHECK_HEADERS(readline/history.h)
1225
1226     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1227       for termlib in ncurses curses termcap terminfo termlib; do
1228        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1229       done
1230       AC_CHECK_LIB(readline, rl_callback_handler_install,
1231        [TERMLDFLAGS="-L$with_readline/lib"
1232        TERMCPPFLAGS="-I$with_readline/include"
1233        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1234        TERMLIBS="-lreadline $TERMLIBS"
1235        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1236        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1237
1238     LDFLAGS=$_ldflags
1239     ;;
1240   esac],
1241   AC_MSG_RESULT(no)
1242 )
1243 AC_SUBST(TERMLIBS)
1244 AC_SUBST(TERMLDFLAGS)
1245
1246 # The readline API changed slightly from readline3 to readline4, so
1247 # code will generate warnings on one of them unless we have a few
1248 # special cases.
1249 AC_CHECK_LIB(readline, rl_completion_matches,
1250              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
1251                         [Do we have rl_completion_matches?])],
1252              [],
1253              [$TERMLIBS])
1254
1255 # not all readline libs have rl_event_hook or history_list
1256 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
1257 AC_CHECK_LIB(readline, history_list,
1258              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
1259              [],
1260              [$TERMLIBS])
1261
1262 # The following test taken from the cvs sources
1263 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
1264 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
1265 # libsocket.so which has a bad implementation of gethostbyname (it
1266 # only looks in /etc/hosts), so we only look for -lsocket if we need
1267 # it.
1268 AC_CHECK_FUNCS(connect)
1269 if test x"$ac_cv_func_connect" = x"no"; then
1270     case "$LIBS" in
1271     *-lnsl*) ;;
1272     *) AC_CHECK_LIB(nsl_s, connect) ;;
1273     esac
1274     case "$LIBS" in
1275     *-lnsl*) ;;
1276     *) AC_CHECK_LIB(nsl, connect) ;;
1277     esac
1278     case "$LIBS" in
1279     *-lsocket*) ;;
1280     *) AC_CHECK_LIB(socket, connect) ;;
1281     esac
1282     case "$LIBS" in
1283     *-linet*) ;;
1284     *) AC_CHECK_LIB(inet, connect) ;;
1285     esac
1286     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
1287     dnl has been cached.
1288     if test x"$ac_cv_lib_socket_connect" = x"yes" ||
1289        test x"$ac_cv_lib_inet_connect" = x"yes"; then
1290         # ac_cv_func_connect=yes
1291         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
1292         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
1293     fi
1294 fi
1295
1296 ###############################################
1297 # test for where we get yp_get_default_domain() from
1298 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1299 AC_CHECK_FUNCS(yp_get_default_domain)
1300
1301 # Check if we have execl, if not we need to compile smbrun.
1302 AC_CHECK_FUNCS(execl)
1303 if test x"$ac_cv_func_execl" = x"no"; then
1304     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1305 fi
1306
1307 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror chown fchown chmod fchmod chroot link mknod mknod64)
1308 AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
1309 AC_CHECK_FUNCS(fstat strchr utime utimes chflags)
1310 AC_CHECK_FUNCS(getrlimit fsync memset strlcpy strlcat setpgid)
1311 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
1312 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1313 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1314 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
1315 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
1316 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1317 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1318 AC_CHECK_FUNCS(getpwent_r)
1319 AC_CHECK_FUNCS(getdents getdents64)
1320 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1321 AC_CHECK_FUNCS(syslog vsyslog timegm)
1322 AC_CHECK_FUNCS(setlocale nl_langinfo)
1323 AC_CHECK_FUNCS(nanosleep)
1324 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1325 AC_CHECK_FUNCS(memalign posix_memalign)
1326 AC_CHECK_HEADERS(sys/mman.h)
1327 # setbuffer, shmget, shm_open are needed for smbtorture
1328 AC_CHECK_FUNCS(setbuffer shmget shm_open)
1329 AC_CHECK_FUNCS(makecontext getcontext setcontext swapcontext)
1330
1331 # Find a method of generating a stack trace
1332 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1333 AC_CHECK_FUNCS(backtrace_symbols)
1334 AC_CHECK_LIB(exc, trace_back_stack)
1335
1336 # Save the original CFLAGS for a few tests that we want to allow
1337 # implicit declaration warnings without failing the test (in developer mode)
1338 ac_no_error_on_warning_CFLAGS="${CFLAGS}"
1339
1340 # Since --enable-developer causes warnings to be treated as errors during
1341 # compilation, we should avoid using features that will fail to compile.
1342 #
1343 # We don't want to enable this earlier because the built-in functions such as
1344 # memset fail to configure properly.
1345
1346 if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes" -a \
1347         x"$developer" = xyes; then
1348   CFLAGS="${CFLAGS} -Werror-implicit-function-declaration"
1349   ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
1350   ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
1351 fi
1352
1353 echo -n "checking for GPFS GPL libs... "
1354 save_LIBS="$LIBS"
1355 LIBS="$LIBS -lgpfs_gpl"
1356 AC_TRY_LINK([#include <gpfs_gpl.h>],
1357           [gpfs_set_share(0,GPFS_SHARE_READ,GPFS_DENY_NONE)],
1358           samba_cv_HAVE_GPFS=yes,
1359           samba_cv_HAVE_GPFS=no)
1360 echo $samba_cv_HAVE_GPFS
1361 if test x"$samba_cv_HAVE_GPFS" = x"yes"; then
1362     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL libs are available])
1363     default_shared_modules="$default_shared_modules vfs_gpfs"
1364 fi
1365 LIBS="$save_LIBS"
1366
1367 # Note that all the libunwind symbols in the API are defined to internal
1368 # platform-specific version, so we must include libunwind.h before checking
1369 # any of them.
1370 AC_MSG_CHECKING([for libunwind])
1371 save_LIBS=$LIBS
1372 if test x"$UNAME_P" = xunknown ; then
1373     # This probably won't link without the platform-specific libunwind.
1374     LIBS="$LIBS -lunwind"
1375 else
1376     # Add the platform-specific libunwind module. uname -p seems the most
1377     # plausible option and works for ia64, where libunwind is most useful.
1378     LIBS="$LIBS -lunwind -lunwind-$UNAME_P"
1379 fi
1380
1381 AC_TRY_LINK(
1382     [
1383 #ifdef HAVE_LIBUNWIND_H
1384 #include <libunwind.h>
1385 #endif
1386     ],
1387     [
1388         unw_context_t ctx; unw_cursor_t cur;
1389         char buf[256]; unw_word_t off;
1390         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1391         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1392     ],
1393     [
1394         AC_MSG_RESULT(yes)
1395         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1396
1397         # If we have libunwind, test whether we also have libunwind-ptrace
1398         # which would let us unwind arbitrary processes.
1399         save_LIBS=$LIBS
1400         AC_CHECK_HEADERS(libunwind-ptrace.h)
1401         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1402             [
1403                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1404                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1405                     [Whether libunwind-ptrace.a is available.])
1406             ],
1407             [ LIBUNWIND_PTRACE="" ])
1408
1409         LIBS=$save_LIBS
1410     ],
1411     [
1412         AC_MSG_RESULT(no)
1413         LIBS=$save_LIBS
1414     ])
1415
1416 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1417 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1418     AC_CHECK_HEADERS(sys/ptrace.h)
1419     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1420     AC_TRY_LINK(
1421             [
1422 #if HAVE_SYS_TYPES_H
1423 #include <sys/types.h>
1424 #endif
1425 #if HAVE_SYS_PTRACE_H
1426 #include <sys/ptrace.h>
1427 #endif
1428             ],
1429             [
1430                 int main(int argc, const char ** argv)
1431                 {
1432                         pid_t me = (pid_t)-1;
1433                         ptrace(PTRACE_ATTACH, me, 0, 0);
1434                         ptrace(PTRACE_DETACH, me, 0, 0);
1435                         return 0;
1436                 }
1437             ],
1438             [
1439                 AC_MSG_RESULT(yes)
1440                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1441                     [Whether the Linux ptrace(2) interface is available.])
1442             ],
1443             [
1444                 AC_MSG_RESULT(no)
1445                 LIBUNWIND_PTRACE=""
1446             ])
1447 fi
1448
1449 AC_SUBST(LIBUNWIND_PTRACE)
1450
1451 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1452 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1453 AC_CHECK_FUNCS(__getcwd _getcwd)
1454 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1455 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1456 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1457 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1458 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1459 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1460 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1461 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1462 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1463 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1464 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1465 AC_CHECK_FUNCS(prctl)
1466
1467 AC_TRY_COMPILE([
1468 #ifdef HAVE_SYS_PRCTL_H
1469 #include <sys/prctl.h>
1470 #endif
1471 ],
1472 [int i; i = prtcl(0); ],
1473 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1474
1475 #
1476 #
1477 #
1478 case "$host_os" in
1479     linux*-gnu* | gnu* | k*bsd*-gnu)
1480        # glibc <= 2.3.2 has a broken getgrouplist
1481     AC_CACHE_CHECK([for a broken Linux getgrouplist API],
1482             linux_getgrouplist_ok,
1483             [
1484                 AC_TRY_RUN([
1485 #include <unistd.h>
1486 #include <sys/utsname.h>
1487
1488                     int main() {
1489                            /* glibc up to 2.3 has a broken getgrouplist */
1490 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1491                            int libc_major = __GLIBC__;
1492                            int libc_minor = __GLIBC_MINOR__;
1493
1494                            if (libc_major < 2)
1495                                   return 1;
1496                            if ((libc_major == 2) && (libc_minor <= 3))
1497                                   return 1;
1498 #endif
1499                            return 0;
1500                     }
1501
1502                 ],
1503                 [linux_getgrouplist_ok=yes],
1504                 [linux_getgrouplist_ok=no],
1505                 [linux_getgrouplist_ok=cross])
1506        ])
1507
1508        if test x"$linux_getgrouplist_ok" = x"yes"; then
1509           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1510        fi
1511        ;;
1512     *)
1513        AC_CHECK_FUNCS(getgrouplist)
1514        ;;
1515 esac
1516
1517 #
1518 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1519 #
1520
1521 if test x$ac_cv_func_stat64 = xno ; then
1522   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1523   AC_TRY_LINK([
1524 #if defined(HAVE_UNISTD_H)
1525 #include <unistd.h>
1526 #endif
1527 #include <sys/stat.h>
1528 ], [struct stat64 st64; return stat64(".",&st64);], [ac_cv_func_stat64=yes])
1529   AC_MSG_RESULT([$ac_cv_func_stat64])
1530   if test x$ac_cv_func_stat64 = xyes ; then
1531     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1532   fi
1533 fi
1534
1535 if test x$ac_cv_func_lstat64 = xno ; then
1536   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1537   AC_TRY_LINK([
1538 #if defined(HAVE_UNISTD_H)
1539 #include <unistd.h>
1540 #endif
1541 #include <sys/stat.h>
1542 ], [struct stat64 st64; return lstat64(".",&st64);], [ac_cv_func_lstat64=yes])
1543   AC_MSG_RESULT([$ac_cv_func_lstat64])
1544   if test x$ac_cv_func_lstat64 = xyes ; then
1545     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1546   fi
1547 fi
1548
1549 if test x$ac_cv_func_fstat64 = xno ; then
1550   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1551   AC_TRY_LINK([
1552 #if defined(HAVE_UNISTD_H)
1553 #include <unistd.h>
1554 #endif
1555 #include <sys/stat.h>
1556 ], [struct stat64 st64; return fstat64(0,&st64);], [ac_cv_func_fstat64=yes])
1557   AC_MSG_RESULT([$ac_cv_func_fstat64])
1558   if test x$ac_cv_func_fstat64 = xyes ; then
1559     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1560   fi
1561 fi
1562
1563 #################################################
1564 # Check whether struct stat has timestamps with sub-second resolution.
1565 # At least IRIX and Solaris have these.
1566 #
1567 # We check that
1568 #       all of st_mtim, st_atim and st_ctim exist
1569 #       all of the members are in fact of type struct timespec
1570 #
1571 # There is some conflicting standards weirdness about whether we should use
1572 # "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we
1573 # prefer struct timespec.
1574
1575 AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_stat_hires,
1576     [
1577         AC_TRY_COMPILE(
1578             [
1579 #if TIME_WITH_SYS_TIME
1580 # include <sys/time.h>
1581 # include <time.h>
1582 #else
1583 # if HAVE_SYS_TIME_H
1584 #  include <sys/time.h>
1585 # else
1586 #  include <time.h>
1587 # endif
1588 #endif
1589 #ifdef HAVE_SYS_STAT_H
1590 #include <sys/stat.h>
1591 #endif
1592             ],
1593             [
1594                 struct timespec t;
1595                 struct stat s = {0};
1596                 t.tv_sec = s.st_mtim.tv_sec;
1597                 t.tv_nsec = s.st_mtim.tv_nsec;
1598                 t.tv_sec = s.st_ctim.tv_sec;
1599                 t.tv_nsec = s.st_ctim.tv_nsec;
1600                 t.tv_sec = s.st_atim.tv_sec;
1601                 t.tv_nsec = s.st_atim.tv_nsec;
1602             ],
1603             samba_stat_hires=yes, samba_stat_hires=no)
1604     ])
1605
1606 if test x"$samba_stat_hires" = x"yes" ; then
1607     AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim])
1608     AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim])
1609     AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim])
1610     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1611             [whether struct stat has sub-second timestamps])
1612 fi
1613
1614 AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_stat_hires_notimespec,
1615     [
1616         AC_TRY_COMPILE(
1617             [
1618 #if TIME_WITH_SYS_TIME
1619 # include <sys/time.h>
1620 # include <time.h>
1621 #else
1622 # if HAVE_SYS_TIME_H
1623 #  include <sys/time.h>
1624 # else
1625 #  include <time.h>
1626 # endif
1627 #endif
1628 #ifdef HAVE_SYS_STAT_H
1629 #include <sys/stat.h>
1630 #endif
1631             ],
1632             [
1633                 struct timespec t;
1634                 struct stat s = {0};
1635                 t.tv_sec = s.st_mtime;
1636                 t.tv_nsec = s.st_mtimensec;
1637                 t.tv_sec = s.st_ctime;
1638                 t.tv_nsec = s.st_ctimensec;
1639                 t.tv_sec = s.st_atime;
1640                 t.tv_nsec = s.st_atimensec;
1641             ],
1642             samba_stat_hires=yes, samba_stat_hires=no)
1643     ])
1644
1645 if test x"$samba_stat_hires_notimespec" = x"yes" ; then
1646     AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
1647     AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
1648     AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
1649     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1650             [whether struct stat has sub-second timestamps without struct timespec])
1651 fi
1652
1653 #####################################
1654 # needed for SRV lookups
1655 AC_CHECK_LIB(resolv, dn_expand)
1656 AC_CHECK_LIB(resolv, _dn_expand)
1657 AC_CHECK_LIB(resolv, __dn_expand)
1658
1659 #
1660 # Check for the functions putprpwnam, set_auth_parameters,
1661 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1662 # Needed for OSF1 and HPUX.
1663 #
1664
1665 AC_LIBTESTFUNC(security, putprpwnam)
1666 AC_LIBTESTFUNC(sec, putprpwnam)
1667
1668 AC_LIBTESTFUNC(security, set_auth_parameters)
1669 AC_LIBTESTFUNC(sec, set_auth_parameters)
1670
1671 # UnixWare 7.x has its getspnam in -lgen
1672 AC_LIBTESTFUNC(gen, getspnam)
1673
1674 AC_LIBTESTFUNC(security, getspnam)
1675 AC_LIBTESTFUNC(sec, getspnam)
1676
1677 AC_LIBTESTFUNC(security, bigcrypt)
1678 AC_LIBTESTFUNC(sec, bigcrypt)
1679
1680 AC_LIBTESTFUNC(security, getprpwnam)
1681 AC_LIBTESTFUNC(sec, getprpwnam)
1682
1683 AC_CHECK_FUNCS(strsignal)
1684
1685 ############################################
1686 # Check if we have libattr
1687 case "$host_os" in
1688   *osf*)
1689         AC_SEARCH_LIBS(getproplist, [proplist])
1690         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1691         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1692         AC_CHECK_FUNCS(sizeof_proplist_entry)
1693   ;;
1694   *)
1695         AC_SEARCH_LIBS(getxattr, [attr])
1696         AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1697         AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
1698         AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
1699         AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1700         AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1701         AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1702         AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1703   ;;
1704 esac
1705
1706 ########################################################
1707 # Do xattr functions take additional options like on Darwin?
1708 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1709         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1710                 old_LIBS=$LIBS
1711                 LIBS="$LIBS $ACL_LIBS"
1712                 AC_TRY_COMPILE([
1713                         #include <sys/types.h>
1714                         #if HAVE_ATTR_XATTR_H
1715                         #include <attr/xattr.h>
1716                         #elif HAVE_SYS_XATTR_H
1717                         #include <sys/xattr.h>
1718                         #endif
1719                 ],[
1720                         getxattr(0, 0, 0, 0, 0, 0);
1721                 ],
1722                 [smb_attr_cv_xattr_add_opt=yes],
1723                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1724         ])
1725         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1726                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1727         fi
1728 fi
1729
1730 # Check if we have extattr
1731 case "$host_os" in
1732   *freebsd4* | *dragonfly* )
1733     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1734     ;;
1735   *)
1736     AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
1737     AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
1738     AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
1739     AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
1740     ;;
1741 esac
1742
1743 # Set defaults
1744 PIE_CFLAGS=""
1745 PIE_LDFLAGS=""
1746 AC_ARG_ENABLE(pie, [  --enable-pie            Turn on pie support if available (default=yes)])
1747
1748 if test "x$enable_pie" != xno
1749 then
1750         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1751         [
1752                 cat > conftest.c <<EOF
1753 int foo;
1754 main () { return 0;}
1755 EOF
1756                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1757                 then
1758                         samba_cv_fpie=yes
1759                 else
1760                         samba_cv_fpie=no
1761                 fi
1762                 rm -f conftest*
1763         ])
1764         if test x"${samba_cv_fpie}" = x"yes"
1765         then
1766                 PIE_CFLAGS="-fPIE"
1767                 PIE_LDFLAGS="-pie"
1768         fi
1769 fi
1770
1771 # Assume non-shared by default and override below
1772 BLDSHARED="false"
1773
1774 # these are the defaults, good for lots of systems
1775 HOST_OS="$host_os"
1776 LDSHFLAGS="-shared"
1777 MODULE_EXPORTS=""
1778 SONAMEFLAG="#"
1779 SHLD="\${CC} \${CFLAGS}"
1780 PICFLAG="${PIE_CFLAGS}"
1781 SHLIBEXT="so"
1782
1783
1784 # this bit needs to be modified for each OS that supports share libs
1785 # You need to specify how to create a shared library and
1786 # how to compile C code to produce PIC object files
1787
1788 AC_MSG_CHECKING([ability to build shared libraries])
1789
1790 # and these are for particular systems
1791 case "$host_os" in
1792                 linux*-gnu* | gnu* | k*bsd*-gnu)
1793                         case "$host_os" in 
1794                                 linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
1795                         esac
1796                         BLDSHARED="true"
1797                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1798                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
1799                         else
1800                                 LDSHFLAGS="-shared -Wl,-Bsymbolic"
1801                         fi
1802                         DYNEXP="-Wl,--export-dynamic"
1803                         PICFLAG="-fPIC"
1804                         SONAMEFLAG="-Wl,-soname="
1805                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1806                         ;;
1807                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1808                         BLDSHARED="true"
1809                         LDSHFLAGS="-G"
1810                         SONAMEFLAG="-h "
1811                         if test "${GCC}" = "yes"; then
1812                                 PICFLAG="-fPIC"
1813                                 SONAMEFLAG="-Wl,-soname="
1814                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1815                                         DYNEXP="-Wl,-E"
1816                                 fi
1817                         else
1818                                 PICFLAG="-KPIC"
1819                                 ## ${CFLAGS} added for building 64-bit shared
1820                                 ## libs using Sun's Compiler
1821                                 LDSHFLAGS="-G \${CFLAGS}"
1822                         fi
1823                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1824                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1825                         ;;
1826                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1827                         BLDSHARED="true"
1828                         LDSHFLAGS="-G"
1829                         SONAMEFLAG="-Wl,-h,"
1830                         PICFLAG="-KPIC"   # Is this correct for SunOS
1831                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1832                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1833                         ;;
1834                 *netbsd* | *freebsd* | *dragonfly* )
1835                         BLDSHARED="true"
1836                         LDSHFLAGS="-shared"
1837                         DYNEXP="-Wl,--export-dynamic"
1838                         SONAMEFLAG="-Wl,-soname,"
1839                         PICFLAG="-fPIC -DPIC"
1840                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1841                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1842                         ;;
1843                 *openbsd*)  BLDSHARED="true"
1844                         LDSHFLAGS="-shared"
1845                         DYNEXP="-Wl,-Bdynamic"
1846                         SONAMEFLAG="-Wl,-soname,"
1847                         PICFLAG="-fPIC"
1848                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1849                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1850                         ;;
1851                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1852                         case "$host_os" in
1853                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1854                         ;;
1855                         esac
1856                         BLDSHARED="true"
1857                         LDSHFLAGS="-set_version sgi1.0 -shared"
1858                         SONAMEFLAG="-soname "
1859                         SHLD="\${LD}"
1860                         if test "${GCC}" = "yes"; then
1861                                 PICFLAG="-fPIC"
1862                         else
1863                                 PICFLAG="-KPIC"
1864                         fi
1865                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1866                         ;;
1867                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1868                         BLDSHARED="true"
1869                         LDSHFLAGS="-Wl,-G,-bexpall,-bbigtoc"
1870                         DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
1871                         PICFLAG="-O2"
1872                         # as AIX code is always position independent...
1873                         # .po will just create compile warnings, use po.o:
1874                         if test "${GCC}" != "yes"; then
1875                                 ## for funky AIX compiler using strncpy()
1876                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1877                         fi
1878
1879                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1880                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1881                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1882                         ;;
1883                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1884                         # Use special PIC flags for the native HP-UX compiler.
1885                                 BLDSHARED="true"
1886                                 SHLD="cc"
1887                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1888                                 SONAMEFLAG="-Wl,+h "
1889                                 PICFLAG="+z"
1890                         if test "${GCC}" = "yes"; then
1891                                 PICFLAG="-fPIC"
1892                         else
1893                                 PICFLAG="+z"
1894                         fi
1895                         if test "$host_cpu" = "ia64"; then
1896                                 SHLIBEXT="so"
1897                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
1898                         else
1899                                 SHLIBEXT="sl"
1900                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1901                         fi
1902                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1903                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1904                         ;;
1905                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1906                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1907                         ;;
1908                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1909                         BLDSHARED="true"
1910                         LDSHFLAGS="-shared"
1911                         SONAMEFLAG="-Wl,-soname,"
1912                         PICFLAG="-fPIC"
1913                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1914                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1915                         ;;
1916                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1917                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1918                         ;;
1919                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1920                         BLDSHARED="true"
1921                         LDSHFLAGS="-shared"
1922                         SONAMEFLAG="-Wl,-soname,"
1923                         PICFLAG="-KPIC"
1924                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1925                         ;;
1926                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1927                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1928                         ;;
1929                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1930                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1931                         ;;
1932                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1933                         case "$host" in
1934                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1935                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1936                                         fi
1937                                         LDSHFLAGS="-G"
1938                                         DYNEXP="-Bexport"
1939                                 ;;
1940                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1941                         esac
1942                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1943                         ;;
1944
1945                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1946                         if [ test "$GCC" != yes ]; then
1947                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1948                         fi
1949                         LDSHFLAGS="-G"
1950                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1951                         ;;
1952                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1953                         BLDSHARED="false"
1954                         LDSHFLAGS=""
1955                         ;;
1956
1957                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1958                         BLDSHARED="true"
1959                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1960                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/modules/exports.darwin"
1961                         SHLIBEXT="dylib"
1962                         # Since gcc doesn't fail on unrecognised options, the
1963                         # PIE test incorrectly succeeds. Darwin gcc does not
1964                         # actually support the PIE stuff.
1965                         PIE_LDFLAGS=
1966                         PIE_CFLAGS=
1967                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1968                         ;;
1969
1970                 *)
1971                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1972                         ;;
1973 esac
1974
1975 if test "$enable_shared" != "yes"; then
1976         BLDSHARED=false
1977 fi
1978
1979 AC_MSG_RESULT($BLDSHARED)
1980
1981 AC_MSG_CHECKING([LDFLAGS])
1982 AC_MSG_RESULT([$LDFLAGS])
1983 AC_MSG_CHECKING([DYNEXP])
1984 AC_MSG_RESULT([$DYNEXP])
1985
1986 #######################################################
1987 # test whether building a shared library actually works
1988 if test $BLDSHARED = true; then
1989
1990 AC_MSG_CHECKING([SHLD])
1991 AC_MSG_RESULT([$SHLD])
1992 AC_MSG_CHECKING([LDSHFLAGS])
1993 AC_MSG_RESULT([$LDSHFLAGS])
1994
1995 AC_MSG_CHECKING([SHLIBEXT])
1996 AC_MSG_RESULT([$SHLIBEXT])
1997 AC_MSG_CHECKING([SONAMEFLAG])
1998 AC_MSG_RESULT([$SONAMEFLAG])
1999
2000 AC_MSG_CHECKING([PICFLAG])
2001 AC_MSG_RESULT([$PICFLAG])
2002
2003 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
2004 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
2005
2006 AC_CACHE_CHECK([whether building shared libraries actually works],
2007                [ac_cv_shlib_works],[
2008    # try building a trivial shared library
2009    ac_cv_shlib_works=no
2010    # The $SHLD and $LDSHFLAGS variables may contain references to other
2011    # variables so they need to be eval'ed.
2012    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o \
2013         shlib.o ${srcdir-.}/tests/shlib.c && \
2014    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
2015         shlib.o && ac_cv_shlib_works=yes
2016    rm -f "shlib.$SHLIBEXT" shlib.o
2017
2018 ])
2019 if test $ac_cv_shlib_works = no; then
2020    BLDSHARED=false
2021 fi
2022 fi
2023
2024 if test x"$BLDSHARED" != x"true"; then
2025         LDSHFLAGS="shared-libraries-disabled"
2026         SONAMEFLAG="shared-libraries-disabled"
2027         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
2028         SHLD="shared-libraries-disabled"
2029         PICFLAG="${PIE_CFLAGS}"
2030         SHLIBEXT="shared_libraries_disabled"
2031 fi
2032
2033 AC_MSG_CHECKING([used PICFLAG])
2034 AC_MSG_RESULT([$PICFLAG])
2035
2036 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
2037
2038 ################
2039
2040 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
2041 AC_TRY_RUN([#include <stdio.h>
2042 int main() { long long x = 1000000; x *= x; return ((x/1000000) == 1000000)? 0: 1; }],
2043 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
2044 if test x"$samba_cv_have_longlong" = x"yes"; then
2045     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
2046     AC_CHECK_TYPE(intptr_t, unsigned long long)
2047 else
2048     AC_CHECK_TYPE(intptr_t, unsigned long)
2049 fi
2050
2051 #
2052 # Check if the compiler supports the LL prefix on long long integers.
2053 # AIX needs this.
2054
2055 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
2056     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
2057         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
2058 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
2059    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
2060 fi
2061
2062
2063 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
2064 AC_TRY_RUN([#include <stdio.h>
2065 #include <sys/stat.h>
2066 int main() { return (sizeof(off_t) == 8) ? 0 : 1; }],
2067 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
2068 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
2069     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
2070 fi
2071
2072 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
2073 AC_TRY_RUN([
2074 #if defined(HAVE_UNISTD_H)
2075 #include <unistd.h>
2076 #endif
2077 #include <stdio.h>
2078 #include <sys/stat.h>
2079 int main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
2080 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
2081 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
2082     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
2083 fi
2084
2085 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
2086 AC_TRY_RUN([
2087 #if defined(HAVE_UNISTD_H)
2088 #include <unistd.h>
2089 #endif
2090 #include <stdio.h>
2091 #include <sys/stat.h>
2092 int main() { return (sizeof(ino_t) == 8) ? 0 : 1; }],
2093 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
2094 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
2095     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
2096 fi
2097
2098 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
2099 AC_TRY_RUN([
2100 #if defined(HAVE_UNISTD_H)
2101 #include <unistd.h>
2102 #endif
2103 #include <stdio.h>
2104 #include <sys/stat.h>
2105 int main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
2106 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
2107 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
2108     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
2109 fi
2110
2111 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
2112 AC_TRY_RUN([
2113 #if defined(HAVE_UNISTD_H)
2114 #include <unistd.h>
2115 #endif
2116 #include <stdio.h>
2117 #include <sys/stat.h>
2118 int main() { return (sizeof(dev_t) == 8) ? 0 : 1; }],
2119 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
2120 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
2121     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
2122 fi
2123
2124 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
2125 AC_TRY_RUN([
2126 #if defined(HAVE_UNISTD_H)
2127 #include <unistd.h>
2128 #endif
2129 #include <stdio.h>
2130 #include <sys/stat.h>
2131 int main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
2132 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
2133 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
2134     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
2135 fi
2136
2137 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
2138 AC_TRY_COMPILE([
2139 #if defined(HAVE_UNISTD_H)
2140 #include <unistd.h>
2141 #endif
2142 #include <sys/types.h>
2143 #include <dirent.h>],
2144 [DIR64 de;],
2145 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
2146 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2147     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
2148 fi
2149
2150 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
2151 AC_TRY_COMPILE([
2152 #if defined(HAVE_UNISTD_H)
2153 #include <unistd.h>
2154 #endif
2155 #include <sys/types.h>
2156 #include <dirent.h>],
2157 [struct dirent64 de;],
2158 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
2159 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2160     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
2161 fi
2162
2163 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
2164 AC_TRY_RUN([
2165 #if defined(HAVE_UNISTD_H)
2166 #include <unistd.h>
2167 #endif
2168 #include <sys/types.h>
2169 int main() { dev_t dev; int i = major(dev); return 0; }],
2170 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
2171 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
2172     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
2173 fi
2174
2175 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
2176 AC_TRY_RUN([
2177 #if defined(HAVE_UNISTD_H)
2178 #include <unistd.h>
2179 #endif
2180 #include <sys/types.h>
2181 int main() { dev_t dev; int i = minor(dev); return 0; }],
2182 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
2183 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
2184     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
2185 fi
2186
2187 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
2188 AC_TRY_RUN([
2189 #if defined(HAVE_UNISTD_H)
2190 #include <unistd.h>
2191 #endif
2192 #include <sys/types.h>
2193 int main() { dev_t dev = makedev(1,2); return 0; }],
2194 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
2195 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
2196     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
2197 fi
2198
2199 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
2200 AC_TRY_RUN([#include <stdio.h>
2201 int main() { char c; c=250; return (c > 0)?0:1; }],
2202 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
2203 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
2204     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
2205 fi
2206
2207 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
2208 AC_TRY_COMPILE([#include <sys/types.h>
2209 #include <sys/socket.h>
2210 #include <netinet/in.h>],
2211 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
2212 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
2213 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
2214     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
2215 fi
2216
2217 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
2218 AC_TRY_COMPILE([#include <sys/types.h>
2219 #include <dirent.h>
2220 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2221 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2222 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2223     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2224 fi
2225
2226 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2227 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2228 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2229 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2230     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2231 fi
2232
2233 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
2234 AC_TRY_RUN([
2235 #include <sys/time.h>
2236 #include <unistd.h>
2237 int main() { struct timeval tv; return gettimeofday(&tv, NULL);}],
2238            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
2239 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
2240     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
2241 fi
2242
2243 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
2244
2245     # On some systems (eg. Linux) librt can pull in libpthread. We
2246     # don't want this to happen because libpthreads changes signal delivery
2247     # semantics in ways we are not prepared for. This breaks Linux oplocks
2248     # which rely on signals.
2249
2250     AC_LIBTESTFUNC(rt, clock_gettime,
2251             [
2252                 AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
2253                     [Whether clock_gettime is available])
2254                 SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
2255                 SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
2256                 SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
2257             ])
2258
2259 fi
2260
2261 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
2262 AC_TRY_LINK([#include <stdarg.h>
2263 va_list ap1,ap2;], [va_copy(ap1,ap2);],
2264 samba_cv_HAVE_VA_COPY=yes,
2265 samba_cv_HAVE_VA_COPY=no)])
2266 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
2267     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
2268 else
2269     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
2270     AC_TRY_LINK([#include <stdarg.h>
2271     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
2272     samba_cv_HAVE___VA_COPY=yes,
2273     samba_cv_HAVE___VA_COPY=no)])
2274     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
2275         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
2276     fi
2277 fi
2278
2279 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
2280 AC_TRY_RUN([
2281 #include <sys/types.h>
2282 #include <stdarg.h>
2283 void foo(const char *format, ...) {
2284        va_list ap;
2285        int len;
2286        char buf[5];
2287
2288        va_start(ap, format);
2289        len = vsnprintf(buf, 0, format, ap);
2290        va_end(ap);
2291        if (len != 5) return 1;
2292
2293        va_start(ap, format);
2294        len = vsnprintf(0, 0, format, ap);
2295        va_end(ap);
2296        if (len != 5) return 1;
2297
2298        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return 1;
2299
2300        return 0;
2301 }
2302 int main() { foo("hello"); }
2303 ],
2304 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
2305 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
2306     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
2307 fi
2308
2309 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2310 AC_TRY_RUN([#include <sys/types.h>
2311 #include <dirent.h>
2312 int main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2313 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2314 di->d_name[0] == 0) return 0; return 1;} ],
2315 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2316 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2317     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2318 fi
2319
2320 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2321 AC_TRY_COMPILE([#include <sys/types.h>
2322 #include <utime.h>],
2323 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
2324 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2325 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2326     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2327 fi
2328
2329 ##############
2330 # Check utmp details, but only if our OS offers utmp.h
2331 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2332 dnl  utmp and utmpx come in many flavours
2333 dnl  We need to check for many of them
2334 dnl  But we don't need to do each and every one, because our code uses
2335 dnl  mostly just the utmp (not utmpx) fields.
2336
2337 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
2338
2339 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2340 AC_TRY_COMPILE([#include <sys/types.h>
2341 #include <utmp.h>],
2342 [struct utmp ut;  ut.ut_name[0] = 'a';],
2343 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2344 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2345     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2346 fi
2347
2348 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2349 AC_TRY_COMPILE([#include <sys/types.h>
2350 #include <utmp.h>],
2351 [struct utmp ut;  ut.ut_user[0] = 'a';],
2352 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2353 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2354     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2355 fi
2356
2357 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2358 AC_TRY_COMPILE([#include <sys/types.h>
2359 #include <utmp.h>],
2360 [struct utmp ut;  ut.ut_id[0] = 'a';],
2361 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2362 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2363     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2364 fi
2365
2366 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2367 AC_TRY_COMPILE([#include <sys/types.h>
2368 #include <utmp.h>],
2369 [struct utmp ut;  ut.ut_host[0] = 'a';],
2370 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2371 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2372     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2373 fi
2374
2375 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2376 AC_TRY_COMPILE([#include <sys/types.h>
2377 #include <utmp.h>],
2378 [struct utmp ut;  time_t t; ut.ut_time = t;],
2379 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2380 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2381     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2382 fi
2383
2384 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2385 AC_TRY_COMPILE([#include <sys/types.h>
2386 #include <utmp.h>],
2387 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2388 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2389 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2390     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2391 fi
2392
2393 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2394 AC_TRY_COMPILE([#include <sys/types.h>
2395 #include <utmp.h>],
2396 [struct utmp ut;  ut.ut_type = 0;],
2397 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2398 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2399     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2400 fi
2401
2402 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2403 AC_TRY_COMPILE([#include <sys/types.h>
2404 #include <utmp.h>],
2405 [struct utmp ut;  ut.ut_pid = 0;],
2406 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2407 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2408     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2409 fi
2410
2411 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2412 AC_TRY_COMPILE([#include <sys/types.h>
2413 #include <utmp.h>],
2414 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2415 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2416 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2417     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2418 fi
2419
2420 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2421 AC_TRY_COMPILE([#include <sys/types.h>
2422 #include <utmp.h>],
2423 [struct utmp ut;  ut.ut_addr = 0;],
2424 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2425 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2426     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2427 fi
2428
2429 if test x$ac_cv_func_pututline = xyes ; then
2430   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2431   AC_TRY_COMPILE([#include <sys/types.h>
2432 #include <utmp.h>],
2433   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2434   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2435   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2436       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2437   fi
2438 fi
2439
2440 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2441 AC_TRY_COMPILE([#include <sys/types.h>
2442 #include <utmpx.h>],
2443 [struct utmpx ux;  ux.ut_syslen = 0;],
2444 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2445 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2446     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2447 fi
2448
2449 fi
2450 # end utmp details
2451
2452
2453 ICONV_LOCATION=standard
2454 LOOK_DIRS="/usr /usr/local /sw /opt"
2455 AC_ARG_WITH(libiconv,
2456 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
2457 [
2458   if test "$withval" = "no" ; then
2459     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2460   else
2461      if test "$withval" != "yes" ; then
2462         ICONV_PATH_SPEC=yes
2463         LOOK_DIRS="$withval"
2464      fi
2465   fi
2466 ])
2467
2468 for i in $LOOK_DIRS ; do
2469     save_LIBS=$LIBS
2470     save_LDFLAGS=$LDFLAGS
2471     save_CPPFLAGS=$CPPFLAGS
2472     ICONV_FOUND="no"
2473     unset libext
2474     CPPFLAGS="$CPPFLAGS -I$i/include"
2475 dnl This is here to handle -withval stuff for --with-libiconv
2476 dnl Perhaps we should always add a -L
2477
2478 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
2479 dnl installation paths. This gets a little tricky since we might have iconv
2480 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
2481 dnl succeed when the header is found. To counter this, make sure the
2482 dnl library directory is there and check the ABI directory first (which
2483 dnl should be harmless on other systems.
2484 dnl For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2485     for l in "lib32" "lib" "lib/hpux32"; do
2486         if test -d "$i/$l" ; then
2487                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2488         LIBS=
2489         export LDFLAGS LIBS CPPFLAGS
2490 dnl Try to find iconv(3)
2491                 jm_ICONV($i/$l)
2492                 if test x"$ICONV_FOUND" = "xyes" ; then
2493             libext="$l"
2494             break;
2495         fi
2496         fi
2497     done
2498
2499     if test x"$ICONV_FOUND" = "xyes" ; then
2500         LDFLAGS=$save_LDFLAGS
2501         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
2502         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
2503         LIBS="$save_LIBS"
2504         ICONV_LOCATION=$i
2505         export LDFLAGS LIBS CPPFLAGS
2506 dnl Now, check for a working iconv ... we want to do it here because
2507 dnl there might be a working iconv further down the list of LOOK_DIRS
2508
2509         ############
2510         # check for iconv in libc
2511         ic_save_LIBS="$LIBS"
2512         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
2513            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
2514         fi
2515         if test x"$jm_cv_lib_iconv" != x; then
2516            LIBS="$LIBS -l$jm_cv_lib_iconv"
2517         fi
2518 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
2519         default_dos_charset=no
2520         default_display_charset=no
2521         default_unix_charset=no
2522
2523         # check for default dos charset name
2524         for j in CP850 IBM850 ; do
2525             rjs_CHARSET($j)
2526             if test x"$ICONV_CHARSET" = x"$j"; then
2527                 default_dos_charset="\"$j\""
2528                 break
2529             fi
2530         done
2531         # check for default display charset name
2532         for j in ASCII 646 ; do
2533             rjs_CHARSET($j)
2534             if test x"$ICONV_CHARSET" = x"$j"; then
2535                 default_display_charset="\"$j\""
2536                 break
2537             fi
2538         done
2539         # check for default unix charset name
2540         for j in UTF-8 UTF8 ; do
2541             rjs_CHARSET($j)
2542             if test x"$ICONV_CHARSET" = x"$j"; then
2543                 default_unix_charset="\"$j\""
2544                 break
2545             fi
2546         done
2547         
2548         if test "$default_dos_charset" != "no" -a \
2549                 "$default_dos_charset" != "cross" -a \
2550                 "$default_display_charset" != "no" -a \
2551                 "$default_display_charset" != "cross" -a \
2552                 "$default_unix_charset" != "no" -a \
2553                 "$default_unix_charset" != "cross"
2554         then
2555                 samba_cv_HAVE_NATIVE_ICONV=yes
2556         else if test "$default_dos_charset" = "cross" -o \
2557                      "$default_display_charset" = "cross" -o \
2558                      "$default_unix_charset" = "cross"
2559         then
2560                 samba_cv_HAVE_NATIVE_ICONV=cross
2561         else
2562                 samba_cv_HAVE_NATIVE_ICONV=no
2563         fi
2564         fi
2565 dnl ])
2566
2567         LIBS="$ic_save_LIBS"
2568         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
2569            CPPFLAGS=$save_CPPFLAGS
2570            LDFLAGS=$save_LDFLAGS
2571            LIBS=$save_LIBS
2572            if test x"$jm_cv_lib_iconv" != x; then
2573               LIBS="$LIBS -l$jm_cv_lib_iconv"
2574            fi
2575            dnl Add the flags we need to CPPFLAGS and LDFLAGS
2576            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
2577            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
2578            export CPPFLAGS
2579            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2580            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2581            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2582            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2583            break
2584         fi
2585 dnl We didn't find a working iconv, so keep going
2586     fi
2587 dnl We only need to clean these up here for the next pass through the loop
2588     CPPFLAGS=$save_CPPFLAGS
2589     LDFLAGS=$save_LDFLAGS
2590     LIBS=$save_LIBS
2591     export LDFLAGS LIBS CPPFLAGS
2592 done
2593 unset libext
2594
2595
2596 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2597     AC_MSG_WARN([Sufficient support for iconv function was not found.
2598     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2599    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2600    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2601    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2602 fi
2603
2604
2605 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2606 AC_TRY_RUN([
2607 #include <sys/types.h>
2608 #include <fcntl.h>
2609 #ifndef F_GETLEASE
2610 #define F_GETLEASE      1025
2611 #endif
2612 int main() {
2613        int fd = open("/dev/null", O_RDONLY);
2614        return fcntl(fd, F_GETLEASE, 0) == -1;
2615 }
2616 ],
2617 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2618 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2619     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2620 fi
2621
2622 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2623 AC_TRY_RUN([
2624 #include <sys/types.h>
2625 #include <fcntl.h>
2626 #include <signal.h>
2627 #ifndef F_NOTIFY
2628 #define F_NOTIFY 1026
2629 #endif
2630 int main() {
2631         return fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0;
2632 }
2633 ],
2634 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2635 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2636     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2637 fi
2638
2639 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2640 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h)
2641 AC_CHECK_FUNC(inotify_init)
2642 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2643 ],
2644 samba_cv_HAVE_INOTIFY=yes,
2645 samba_cv_HAVE_INOTIFY=no,
2646 samba_cv_HAVE_INOTIFY=cross)
2647
2648 if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2649     AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
2650 fi
2651
2652 #################################################
2653 # Check if FAM notifications are available. For FAM info, see
2654 #       http://oss.sgi.com/projects/fam/
2655 #       http://savannah.nongnu.org/projects/fam/
2656 AC_ARG_ENABLE(fam,
2657 [  --enable-fam            Turn on FAM support (default=auto)])
2658
2659 if test x$enable_fam != xno; then
2660     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2661     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2662         # On IRIX, libfam requires libC, but other FAM implementations
2663         # might not need it.
2664         AC_CHECK_LIB(fam, FAMOpen2,
2665             [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam"],
2666             [samba_cv_HAVE_LIBFAM=no])
2667
2668         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2669             samba_fam_xtra=-lC
2670             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2671                 [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam -lC"],
2672                 [samba_cv_HAVE_LIBFAM=no])
2673             unset samba_fam_xtra
2674         fi
2675     fi
2676
2677     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2678         default_shared_modules="$default_shared_modules vfs_notify_fam"
2679         AC_TRY_COMPILE([#include <fam.h>],
2680                     [FAMCodes code = FAMChanged;],
2681                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2682                         [Whether fam.h contains a typedef for enum FAMCodes]),
2683                     [])
2684     fi
2685
2686     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2687         AC_MSG_ERROR(FAM support requested but FAM library not available )
2688     fi
2689 fi
2690
2691 #################################################
2692 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2693
2694 SMB_CHECK_DMAPI([], AC_MSG_NOTICE(DMAPI support not present) )
2695
2696 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2697 AC_TRY_RUN([
2698 #include <sys/types.h>
2699 #include <fcntl.h>
2700 #include <signal.h>
2701 #include <sys/file.h>
2702 #ifndef LOCK_MAND
2703 #define LOCK_MAND       32
2704 #define LOCK_READ       64
2705 #endif
2706 int main() {
2707         return flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0;
2708 }
2709 ],
2710 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2711 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2712     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2713 fi
2714
2715
2716 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2717 AC_TRY_COMPILE([#include <sys/types.h>
2718 #include <fcntl.h>],
2719 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2720 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2721 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2722     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2723 fi
2724
2725 #################################################
2726 # Check for POSIX capability support
2727
2728 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2729     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2730     [], [])
2731
2732 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2733
2734     ac_save_LIBS=$LIBS
2735     AC_LIBTESTFUNC(cap, cap_get_proc)
2736
2737     AC_CACHE_CHECK([for POSIX capabilities],
2738             samba_cv_HAVE_POSIX_CAPABILITIES,
2739             [
2740                 AC_TRY_RUN([
2741 #include <sys/types.h>
2742 #include <sys/capability.h>
2743 int main() {
2744  cap_t cap;
2745  cap_value_t vals[1];
2746  if (!(cap = cap_get_proc()))
2747    return 1;
2748  vals[0] = CAP_CHOWN;
2749  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2750  cap_set_proc(cap);
2751  return 0;
2752 }],
2753                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2754                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2755                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2756             ])
2757
2758 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2759     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2760             [Whether POSIX capabilities are available])
2761 else
2762     LIBS=$ac_save_LIBS
2763 fi
2764
2765 fi
2766
2767 #
2768 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2769 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2770 #
2771
2772 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2773 AC_TRY_COMPILE([#include <sys/types.h>
2774 #if defined(HAVE_RPC_RPC_H)
2775 #include <rpc/rpc.h>
2776 #endif],
2777 [int16 testvar;],
2778 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2779 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2780     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2781 fi
2782
2783 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2784 AC_TRY_COMPILE([#include <sys/types.h>
2785 #if defined(HAVE_RPC_RPC_H)
2786 #include <rpc/rpc.h>
2787 #endif],
2788 [uint16 testvar;],
2789 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2790 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2791     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2792 fi
2793
2794 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2795 AC_TRY_COMPILE([#include <sys/types.h>
2796 #if defined(HAVE_RPC_RPC_H)
2797 #include <rpc/rpc.h>
2798 #endif],
2799 [int32 testvar;],
2800 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2801 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2802     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2803 fi
2804
2805 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2806 AC_TRY_COMPILE([#include <sys/types.h>
2807 #if defined(HAVE_RPC_RPC_H)
2808 #include <rpc/rpc.h>
2809 #endif],
2810 [uint32 testvar;],
2811 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2812 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2813     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2814 fi
2815
2816 dnl
2817 dnl Some systems (SCO) have a problem including
2818 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2819 dnl as a #define in <prot.h> and as part of an enum
2820 dnl in <rpc/rpc.h>.
2821 dnl
2822
2823 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2824 AC_TRY_COMPILE([#include <sys/types.h>
2825 #ifdef HAVE_SYS_SECURITY_H
2826 #include <sys/security.h>
2827 #include <prot.h>
2828 #endif  /* HAVE_SYS_SECURITY_H */
2829 #if defined(HAVE_RPC_RPC_H)
2830 #include <rpc/rpc.h>
2831 #endif],
2832 [int testvar;],
2833 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2834 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2835     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2836 fi
2837
2838 AC_MSG_CHECKING([for test routines])
2839 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2840            AC_MSG_RESULT(yes),
2841            AC_MSG_ERROR([cant find test code. Aborting config]),
2842            AC_MSG_WARN([cannot run when cross-compiling]))
2843
2844 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2845 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2846            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2847 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2848     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2849 fi
2850
2851 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2852 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2853            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2854            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2855            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2856 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2857 then
2858     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2859 fi
2860
2861 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2862 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2863            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2864 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2865     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2866 fi
2867
2868 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2869 AC_TRY_RUN([#include <stdlib.h>
2870 #include <sys/types.h>
2871 #include <sys/stat.h>
2872 #include <unistd.h>
2873 int main() {
2874   struct stat st;
2875   char tpl[20]="/tmp/test.XXXXXX";
2876   int fd = mkstemp(tpl);
2877   if (fd == -1) return 1;
2878   unlink(tpl);
2879   if (fstat(fd, &st) != 0) return 1;
2880   if ((st.st_mode & 0777) != 0600) return 1;
2881   return 0;
2882 }],
2883 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2884 samba_cv_HAVE_SECURE_MKSTEMP=no,
2885 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2886 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2887     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2888 fi
2889
2890 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
2891         AC_TRY_RUN([
2892 #include "${srcdir-.}/lib/replace/test/os2_delete.c"
2893 int main(void) {
2894     return test_readdir_os2_delete();
2895 }
2896 ],
2897                 [samba_cv_HAVE_BROKEN_READDIR=no],
2898                         [samba_cv_HAVE_BROKEN_READDIR=yes],
2899                         [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
2900
2901 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
2902 AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
2903         AC_TRY_RUN([
2904 #include "${srcdir-.}/lib/repdir.c"
2905 #include "${srcdir-.}/lib/replace/test/os2_delete.c"
2906 int main(void) {
2907     return test_readdir_os2_delete();
2908 ],
2909         samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
2910 fi
2911
2912 if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then
2913         AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
2914 fi
2915
2916 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2917 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2918 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2919 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2920 AC_CHECK_FUNCS(getpagesize)
2921
2922 ##################
2923 # look for a method of finding the list of network interfaces
2924 iface=no;
2925 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2926 SAVE_CPPFLAGS="$CPPFLAGS"
2927 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
2928 AC_TRY_RUN([
2929 #define HAVE_IFACE_AIX 1
2930 #define AUTOCONF_TEST 1
2931 #undef _XOPEN_SOURCE_EXTENDED
2932 #include "${srcdir-.}/lib/interfaces.c"],
2933            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2934 CPPFLAGS="$SAVE_CPPFLAGS"
2935 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2936     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2937 fi
2938
2939 if test $iface = no; then
2940 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2941 SAVE_CPPFLAGS="$CPPFLAGS"
2942 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
2943 AC_TRY_RUN([
2944 #define HAVE_IFACE_IFCONF 1
2945 #define AUTOCONF_TEST 1
2946 #include "${srcdir-.}/lib/interfaces.c"],
2947            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2948 CPPFLAGS="$SAVE_CPPFLAGS"
2949 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2950     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2951 fi
2952 fi
2953
2954 if test $iface = no; then
2955 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2956 SAVE_CPPFLAGS="$CPPFLAGS"
2957 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
2958 AC_TRY_RUN([
2959 #define HAVE_IFACE_IFREQ 1
2960 #define AUTOCONF_TEST 1
2961 #include "${srcdir-.}/lib/interfaces.c"],
2962            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2963 CPPFLAGS="$SAVE_CPPFLAGS"
2964 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2965     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2966 fi
2967 fi
2968
2969
2970 ################################################
2971 # look for a method of setting the effective uid
2972 seteuid=no;
2973 if test $seteuid = no; then
2974 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2975 AC_TRY_RUN([
2976 #define AUTOCONF_TEST 1
2977 #define USE_SETRESUID 1
2978 #include "confdefs.h"
2979 #include "${srcdir-.}/lib/util_sec.c"],
2980            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2981 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2982     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2983 fi
2984 fi
2985
2986
2987 if test $seteuid = no; then
2988 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2989 AC_TRY_RUN([
2990 #define AUTOCONF_TEST 1
2991 #define USE_SETREUID 1
2992 #include "confdefs.h"
2993 #include "${srcdir-.}/lib/util_sec.c"],
2994            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2995 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2996     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2997 fi
2998 fi
2999
3000 if test $seteuid = no; then
3001 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
3002 AC_TRY_RUN([
3003 #define AUTOCONF_TEST 1
3004 #define USE_SETEUID 1
3005 #include "confdefs.h"
3006 #include "${srcdir-.}/lib/util_sec.c"],
3007            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
3008 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
3009     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
3010 fi
3011 fi
3012
3013 if test $seteuid = no; then
3014 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
3015 AC_TRY_RUN([
3016 #define AUTOCONF_TEST 1
3017 #define USE_SETUIDX 1
3018 #include "confdefs.h"
3019 #include "${srcdir-.}/lib/util_sec.c"],
3020            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
3021 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
3022     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
3023 fi
3024 fi
3025
3026
3027 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
3028 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
3029            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
3030 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
3031     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
3032 fi
3033
3034 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
3035 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
3036            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
3037 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
3038     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
3039 fi
3040
3041 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
3042 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
3043            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
3044 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
3045     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
3046
3047 else
3048
3049 dnl
3050 dnl Don't check for 64 bit fcntl locking if we know that the
3051 dnl glibc2.1 broken check has succeeded.
3052 dnl
3053
3054   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
3055   AC_TRY_RUN([
3056 #if defined(HAVE_UNISTD_H)
3057 #include <unistd.h>
3058 #endif
3059 #include <stdio.h>
3060 #include <stdlib.h>
3061
3062 #ifdef HAVE_FCNTL_H
3063 #include <fcntl.h>
3064 #endif
3065
3066 #ifdef HAVE_SYS_FCNTL_H
3067 #include <sys/fcntl.h>
3068 #endif
3069 int main() { struct flock64 fl64;
3070 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
3071 return 0;
3072 #else
3073 return 1;
3074 #endif
3075 }],
3076        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
3077
3078   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
3079       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
3080   fi
3081 fi
3082
3083 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
3084 AC_TRY_COMPILE([#include <sys/types.h>
3085 #include <sys/stat.h>
3086 #include <unistd.h>],
3087 [struct stat st;  st.st_blocks = 0;],
3088 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
3089 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
3090     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
3091 fi
3092
3093 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
3094 AC_TRY_COMPILE([#include <sys/types.h>
3095 #include <sys/stat.h>
3096 #include <unistd.h>],
3097 [struct stat st;  st.st_blksize = 0;],
3098 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
3099 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
3100     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
3101 fi
3102
3103 AC_CACHE_CHECK([for st_flags in struct stat],
3104         samba_cv_HAVE_STAT_ST_FLAGS,
3105         [
3106             AC_TRY_COMPILE([#include <sys/types.h>
3107 #include <sys/stat.h>
3108 #include <unistd.h>],
3109             [struct stat st;  st.st_flags = 0;],
3110             samba_cv_HAVE_STAT_ST_FLAGS=yes,
3111             samba_cv_HAVE_STAT_ST_FLAGS=no,
3112             samba_cv_HAVE_STAT_ST_FLAGS=cross)
3113         ])
3114
3115 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
3116     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
3117                 [Whether the stat struct has a st_flags member])
3118 fi
3119
3120 case "$host_os" in
3121 *linux*)
3122 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
3123 AC_TRY_COMPILE([
3124 #ifdef HAVE_SYS_VFS_H
3125 #include <sys/vfs.h>
3126 #endif
3127 #ifdef HAVE_SYS_CAPABILITY_H
3128 #include <sys/capability.h>
3129 #endif
3130 ],[int i;],
3131    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
3132 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
3133    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
3134 fi
3135 ;;
3136 esac
3137
3138 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
3139 AC_TRY_COMPILE([
3140 #include <sys/types.h>
3141 #include <sys/acl.h>
3142 #if defined(HAVE_RPCSVC_NIS_H)
3143 #include <rpcsvc/nis.h>
3144 #endif],
3145 [int i;],
3146 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
3147 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
3148         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
3149 fi
3150
3151 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
3152 AC_TRY_RUN([
3153 #include <stdio.h>
3154 #include <stdlib.h>
3155 #include <limits.h>
3156 int main() {
3157         char *newpath = realpath("/tmp", NULL);
3158         return (newpath != NULL) ? 0 : 1;
3159 }
3160 ],
3161 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
3162 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
3163     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
3164 fi
3165
3166 #################################################
3167 # check for AFS clear-text auth support
3168 samba_cv_WITH_AFS=no
3169 AC_MSG_CHECKING(whether to use AFS clear-text auth)
3170 AC_ARG_WITH(afs,
3171 [  --with-afs              Include AFS clear-text auth support (default=no) ],
3172 [ case "$withval" in
3173   yes|auto)
3174     AC_MSG_RESULT($withval)
3175     samba_cv_WITH_AFS=$withval
3176     ;;
3177   *)
3178     AC_MSG_RESULT(no)
3179     ;;
3180   esac ],
3181   AC_MSG_RESULT(no)
3182 )
3183
3184 ####################################################
3185 # check for Linux-specific AFS fake-kaserver support
3186 samba_cv_WITH_FAKE_KASERVER=no
3187 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3188 AC_ARG_WITH(fake-kaserver,
3189 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
3190 [ case "$withval" in
3191   yes|auto)
3192     AC_MSG_RESULT($withval)
3193     samba_cv_WITH_FAKE_KASERVER=$withval
3194     ;;
3195   *)
3196     AC_MSG_RESULT(no)
3197     ;;
3198   esac ],
3199   AC_MSG_RESULT(no)
3200 )
3201
3202 #################################################
3203 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3204 if test x"$samba_cv_WITH_AFS" != x"no" ||
3205    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3206
3207     # see if this box has the afs-headers in /usr/include/afs
3208     AC_MSG_CHECKING(for /usr/include/afs)
3209     if test -d /usr/include/afs; then
3210           CFLAGS="$CFLAGS -I/usr/include/afs"
3211           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
3212           AC_MSG_RESULT(yes)
3213     else
3214       AC_MSG_RESULT(no)
3215     fi
3216
3217     # check for afs.h
3218     have_afs_headers=no
3219     AC_CHECK_HEADERS(afs.h afs/afs.h)
3220     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3221         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3222            test x"$samba_cv_WITH_AFS" = x"auto"; then
3223                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3224         else
3225                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3226         fi
3227     else
3228         have_afs_headers=yes
3229     fi
3230 fi
3231
3232 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3233     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3234 fi
3235
3236 #################################################
3237 # check whether to compile AFS/NT ACL mapping module
3238 samba_cv_WITH_VFS_AFSACL=no
3239 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
3240 AC_ARG_WITH(vfs-afsacl,
3241 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
3242 [ case "$withval" in
3243   yes|auto)
3244     AC_MSG_RESULT($withval)
3245     samba_cv_WITH_VFS_AFSACL=yes
3246     ;;
3247   *)
3248     AC_MSG_RESULT(no)
3249     ;;
3250   esac ],
3251   AC_MSG_RESULT(no)
3252 )
3253
3254 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3255    default_shared_modules="$default_shared_modules vfs_afsacl"
3256 fi
3257         
3258 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3259     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3260 fi
3261
3262 #################################################
3263 # check for the DFS clear-text auth system
3264 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3265 AC_ARG_WITH(dfs,
3266 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
3267 [ case "$withval" in
3268   yes)
3269     AC_MSG_RESULT(yes)
3270     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3271     ;;
3272   *)
3273     AC_MSG_RESULT(no)
3274     ;;
3275   esac ],
3276   AC_MSG_RESULT(no)
3277 )
3278
3279 ########################################################
3280 # Compile with LDAP support?
3281
3282 with_ldap_support=auto
3283 AC_MSG_CHECKING([for LDAP support])
3284
3285 AC_ARG_WITH(ldap,
3286 [  --with-ldap             LDAP support (default yes)],
3287 [ case "$withval" in
3288     yes|no)
3289         with_ldap_support=$withval
3290         ;;
3291   esac ])
3292
3293 AC_MSG_RESULT($with_ldap_support)
3294
3295 SMBLDAP=""
3296 AC_SUBST(SMBLDAP)
3297 SMBLDAPUTIL=""
3298 AC_SUBST(SMBLDAPUTIL)
3299 LDBLDAP=""
3300 AC_SUBST(LDBLDAP)
3301
3302 if test x"$with_ldap_support" != x"no"; then
3303
3304   ##################################################################
3305   # first test for ldap.h and lber.h
3306   # (ldap.h is required for this test)
3307   AC_CHECK_HEADERS(ldap.h lber.h)
3308
3309   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3310         if test x"$with_ldap_support" = x"yes"; then
3311          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3312         else
3313          AC_MSG_WARN(ldap.h is needed for LDAP support)
3314         fi
3315         
3316         with_ldap_support=no
3317   fi
3318
3319   ##################################################################
3320   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
3321   # unsigned int in include/includes.h
3322   case $host_os in
3323         *hpux*)
3324          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3325          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
3326         with_ldap_support=yes
3327         ;;
3328         *)
3329         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3330         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3331                 if test x"$with_ldap_support" = x"yes"; then
3332                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3333                 else
3334                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3335                 fi
3336                 with_ldap_support=no
3337         fi
3338         ;;
3339   esac
3340 fi
3341
3342 if test x"$with_ldap_support" != x"no"; then
3343   ac_save_LIBS=$LIBS
3344
3345   ##################################################################
3346   # we might need the lber lib on some systems. To avoid link errors
3347   # this test must be before the libldap test
3348   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3349
3350   ########################################################
3351   # now see if we can find the ldap libs in standard paths
3352   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3353
3354   ########################################################
3355   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3356   # Check found in pam_ldap 145.
3357   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3358
3359   LIBS="$LIBS $LDAP_LIBS"
3360   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3361     AC_TRY_COMPILE([
3362         #include <lber.h>
3363         #include <ldap.h>],
3364         [ldap_set_rebind_proc(0, 0, 0);],
3365         [smb_ldap_cv_ldap_set_rebind_proc=3],
3366         [smb_ldap_cv_ldap_set_rebind_proc=2]
3367     )
3368   ])
3369
3370   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3371
3372   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3373
3374   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3375     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3376     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3377     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3378     default_shared_modules="$default_shared_modules";
3379     SMBLDAP="lib/smbldap.o"
3380     SMBLDAPUTIL="lib/smbldap_util.o"
3381     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3382       AC_MSG_WARN(Disabling ldb_ldap support (requires ldap_initialize))
3383     else
3384       AC_DEFINE(HAVE_LDB_LDAP,1,[Whether ldb_ldap is available])
3385       LDBLDAP="lib/ldb/ldb_ldap/ldb_ldap.o"
3386     fi
3387     with_ldap_support=yes
3388     AC_MSG_CHECKING(whether LDAP support is used)
3389     AC_MSG_RESULT(yes)
3390   else
3391     if test x"$with_ldap_support" = x"yes"; then
3392         AC_MSG_ERROR(libldap is needed for LDAP support)
3393     else
3394         AC_MSG_WARN(libldap is needed for LDAP support)
3395     fi
3396
3397     LDAP_LIBS=""
3398     with_ldap_support=no
3399   fi
3400   LIBS=$ac_save_LIBS
3401 fi
3402
3403
3404 #################################################
3405 # active directory support
3406
3407 with_ads_support=auto
3408 AC_MSG_CHECKING([for Active Directory and krb5 support])
3409
3410 AC_ARG_WITH(ads,
3411 [  --with-ads              Active Directory support (default auto)],
3412 [ case "$withval" in
3413     yes|no)
3414         with_ads_support="$withval"
3415         ;;
3416   esac ])
3417
3418 AC_MSG_RESULT($with_ads_support)
3419
3420 FOUND_KRB5=no
3421 KRB5_LIBS=""
3422
3423 if test x"$with_ldap_support" != x"yes"; then
3424
3425     if test x"$with_ads_support" = x"yes"; then
3426         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3427     elif test x"$with_ads_support" = x"auto"; then
3428         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3429         with_ads_support=no
3430     fi
3431
3432 else
3433
3434     # Check to see whether there is enough LDAP functionality to be able
3435     # to build AD support.
3436
3437 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3438 case "$host_os" in
3439         *hpux*)
3440     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3441
3442     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3443         if test x"$with_ads_support" = x"yes"; then
3444             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3445         elif test x"$with_ads_support" = x"auto"; then
3446             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3447             with_ads_support=no
3448         fi
3449     fi
3450     ;;
3451         *)
3452     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3453
3454     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3455         if test x"$with_ads_support" = x"yes"; then
3456             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3457         elif test x"$with_ads_support" = x"auto"; then
3458             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3459             with_ads_support=no
3460         fi
3461     fi
3462     ;;
3463 esac
3464
3465
3466     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3467
3468     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3469         if test x"$with_ads_support" = x"yes"; then
3470             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3471         elif test x"$with_ads_support" = x"auto"; then
3472             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3473             with_ads_support=no
3474         fi
3475     fi
3476
3477 fi
3478
3479 if test x"$with_ads_support" != x"no"; then
3480
3481   # Do no harm to the values of CFLAGS and LIBS while testing for
3482   # Kerberos support.
3483
3484   if test x$FOUND_KRB5 = x"no"; then
3485     #################################################
3486     # check for location of Kerberos 5 install
3487     AC_MSG_CHECKING(for kerberos 5 install path)
3488     AC_ARG_WITH(krb5,
3489     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
3490     [ case "$withval" in
3491       no)
3492         AC_MSG_RESULT(no krb5-path given)
3493         ;;
3494       yes)
3495         AC_MSG_RESULT(/usr)
3496         FOUND_KRB5=yes
3497         ;;
3498       *)
3499         AC_MSG_RESULT($withval)
3500         KRB5_CFLAGS="-I$withval/include"
3501         KRB5_CPPFLAGS="-I$withval/include"
3502         KRB5_LDFLAGS="-L$withval/lib"
3503         FOUND_KRB5=yes
3504         if test -x "$withval/bin/krb5-config"; then
3505                 KRB5CONFIG=$withval/bin/krb5-config
3506         fi
3507         ;;
3508       esac ],
3509       AC_MSG_RESULT(no krb5-path given)
3510     )
3511   fi
3512
3513   #################################################
3514   # check for krb5-config from recent MIT and Heimdal kerberos 5
3515   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3516   AC_MSG_CHECKING(for working krb5-config)
3517   if test -x "$KRB5CONFIG"; then
3518     ac_save_CFLAGS=$CFLAGS
3519     CFLAGS="";export CFLAGS
3520     ac_save_LDFLAGS=$LDFLAGS
3521     LDFLAGS="";export LDFLAGS
3522     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3523     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3524     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3525     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3526     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3527     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3528     FOUND_KRB5=yes
3529     AC_MSG_RESULT(yes)
3530   else
3531     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3532   fi
3533
3534   if test x$FOUND_KRB5 = x"no"; then
3535     #################################################
3536     # see if this box has the SuSE location for the heimdal krb implementation
3537     AC_MSG_CHECKING(for /usr/include/heimdal)
3538     if test -d /usr/include/heimdal; then
3539       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3540           KRB5_CFLAGS="-I/usr/include/heimdal"
3541           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3542           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3543           AC_MSG_RESULT(yes)
3544       else
3545           KRB5_CFLAGS="-I/usr/include/heimdal"
3546           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3547           AC_MSG_RESULT(yes)
3548       fi
3549     else
3550       AC_MSG_RESULT(no)
3551     fi
3552   fi
3553
3554   if test x$FOUND_KRB5 = x"no"; then
3555     #################################################
3556     # see if this box has the RedHat location for kerberos
3557     AC_MSG_CHECKING(for /usr/kerberos)
3558     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3559       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3560       KRB5_CFLAGS="-I/usr/kerberos/include"
3561       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3562       AC_MSG_RESULT(yes)
3563     else
3564       AC_MSG_RESULT(no)
3565     fi
3566   fi
3567
3568   ac_save_CFLAGS=$CFLAGS
3569   ac_save_CPPFLAGS=$CPPFLAGS
3570   ac_save_LDFLAGS=$LDFLAGS
3571
3572   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3573   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3574   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3575
3576   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3577
3578   # now check for krb5.h. Some systems have the libraries without the headers!
3579   # note that this check is done here to allow for different kerberos
3580   # include paths
3581   AC_CHECK_HEADERS(krb5.h)
3582
3583   if test x"$ac_cv_header_krb5_h" = x"no"; then
3584
3585     # Give a warning if AD support was not explicitly requested,
3586     # i.e with_ads_support = auto, otherwise die with an error.
3587
3588     if test x"$with_ads_support" = x"yes"; then
3589       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3590     else
3591       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3592     fi
3593
3594     # Turn off AD support and restore CFLAGS and LIBS variables
3595
3596     with_ads_support="no"
3597
3598     CFLAGS=$ac_save_CFLAGS
3599     CPPFLAGS=$ac_save_CPPFLAGS
3600     LDFLAGS=$ac_save_LDFLAGS
3601   fi
3602   AC_CHECK_HEADERS(krb5/locate_plugin.h)
3603 fi
3604
3605 # Now we have determined whether we really want ADS support
3606 use_ads=no
3607 if test x"$with_ads_support" != x"no"; then
3608   use_ads=yes
3609   have_gssapi=no
3610   ac_save_LIBS=$LIBS
3611
3612   # now check for gssapi headers.  This is also done here to allow for
3613   # different kerberos include paths
3614   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3615
3616   ##################################################################
3617   # we might need the k5crypto and com_err libraries on some systems
3618   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3619   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3620
3621   # Heimdal checks.
3622   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3623   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3624   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3625
3626   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3627   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3628
3629   ########################################################
3630   # now see if we can find the krb5 libs in standard paths
3631   # or as specified above
3632   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3633   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3634
3635   ########################################################
3636   # now see if we can find the gssapi libs in standard paths
3637   if test x"$have_gssapi" != x"yes"; then
3638      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3639   fi
3640
3641   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3642   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3643   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3644   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3645   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3646   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3647   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3648   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3649   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3650   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3651   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3652   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3653   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3654   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3655   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3656   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3657   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3658   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3659   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3660   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3661   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3662   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3663   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3664   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3665   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3666   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3667   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3668   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3669   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3670   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3671   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3672   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3673   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3674   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3675   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3676   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3677   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3678   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3679   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3680   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3681   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3682
3683   LIBS="$KRB5_LIBS $LIBS"
3684
3685   AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
3686         smb_krb5_ticket_has_keyinfo,
3687         [
3688             AC_TRY_COMPILE(
3689             [
3690                 #include <krb5.h>
3691             ],
3692             [
3693                 krb5_ticket ticket;
3694                 krb5_kvno kvno;
3695                 krb5_enctype enctype;
3696
3697                 enctype = ticket.enc_part.enctype;
3698                 kvno = ticket.enc_part.kvno;
3699             ],
3700             [ smb_krb5_ticket_has_keyinfo=yes ],
3701             [ smb_krb5_ticket_has_keyinfo=no ])
3702         ])
3703
3704   if test x"$smb_krb5_ticket_has_keyinfo" = x"yes" ; then
3705         AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
3706             [Whether the krb5_ticket structure contains the kvno and enctype])
3707   fi
3708
3709   AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
3710           smb_krb5_creds_opt_free_context,
3711           [
3712                 AC_TRY_COMPILE([
3713                     #include <krb5.h>],
3714                     [
3715                         krb5_context ctx;
3716                         krb5_get_init_creds_opt *opt = NULL;
3717                         krb5_get_init_creds_opt_free(ctx, opt);
3718                     ],
3719                     [smb_krb5_creds_opt_free_context=yes],
3720                     [smb_krb5_creds_opt_free_context=no]
3721                 )
3722           ])
3723
3724   if test x"$smb_krb5_creds_opt_free_context" = x"yes" ; then
3725         AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
3726             [Whether krb5_get_init_creds_opt_free takes a context argument])
3727   fi
3728
3729   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
3730     AC_TRY_COMPILE([
3731         #include <krb5.h>],
3732         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
3733         [smb_krb5_verify_checksum=7],
3734         [smb_krb5_verify_checksum=6],
3735     )
3736   ])
3737   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_verify_checksum, [Number of arguments to krb5_verify_checksum])
3738
3739   AC_CACHE_CHECK([for checksum in krb5_checksum],
3740                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3741     AC_TRY_COMPILE([#include <krb5.h>],
3742       [krb5_checksum cksum; cksum.checksum.length = 0;],
3743       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3744       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3745
3746   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3747     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3748                [Whether the krb5_checksum struct has a checksum property])
3749   fi
3750
3751   AC_CACHE_CHECK([for etype in EncryptedData],
3752                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3753     AC_TRY_COMPILE([#include <krb5.h>],
3754       [EncryptedData edata; edata.etype = 0;],
3755       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3756       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3757
3758   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3759     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3760                [Whether the EncryptedData struct has a etype property])
3761   fi
3762
3763   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3764                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3765     AC_TRY_COMPILE([#include <krb5.h>],
3766       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3767       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3768       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3769
3770   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3771     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3772                [Whether the krb5_ap_req struct has a ticket pointer])
3773   fi
3774
3775   AC_CACHE_CHECK([for e_data pointer in krb5_error],
3776                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
3777     AC_TRY_COMPILE([#include <krb5.h>],
3778       [krb5_error err; err.e_data = NULL;],
3779       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
3780       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
3781
3782   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
3783     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
3784                [Whether the krb5_error struct has a e_data pointer])
3785   fi
3786
3787   AC_CACHE_CHECK([for krb5_crypto type],
3788                 samba_cv_HAVE_KRB5_CRYPTO,[
3789     AC_TRY_COMPILE([#include <krb5.h>],
3790       [krb5_crypto crypto;],
3791       samba_cv_HAVE_KRB5_CRYPTO=yes,
3792       samba_cv_HAVE_KRB5_CRYPTO=no)])
3793
3794   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3795     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3796                [Whether the type krb5_crypto exists])
3797   fi
3798
3799   AC_CACHE_CHECK([for krb5_encrypt_block type],
3800                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3801     AC_TRY_COMPILE([#include <krb5.h>],
3802       [krb5_encrypt_block block;],
3803       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3804       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3805
3806   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3807     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3808                [Whether the type krb5_encrypt_block exists])
3809   fi
3810
3811   AC_CACHE_CHECK([for addrtype in krb5_address],
3812                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3813     AC_TRY_COMPILE([#include <krb5.h>],
3814       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3815       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3816       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3817
3818   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3819     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3820                [Whether the krb5_address struct has a addrtype property])
3821   fi
3822
3823   AC_CACHE_CHECK([for addr_type in krb5_address],
3824                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3825     AC_TRY_COMPILE([#include <krb5.h>],
3826       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3827       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3828       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3829
3830   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3831     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3832               [Whether the krb5_address struct has a addr_type property])
3833   fi
3834
3835   AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
3836                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3837                  [AC_TRY_COMPILE([#include <krb5.h>],
3838     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3839     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3840
3841   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3842     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3843               [Whether the krb5_ticket struct has a enc_part2 property])
3844   fi
3845
3846   AC_CACHE_CHECK([for keyblock in krb5_creds],
3847                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3848     AC_TRY_COMPILE([#include <krb5.h>],
3849       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3850       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3851       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
3852
3853   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
3854     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
3855               [Whether the krb5_creds struct has a keyblock property])
3856   fi
3857
3858   AC_CACHE_CHECK([for session in krb5_creds],
3859                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
3860     AC_TRY_COMPILE([#include <krb5.h>],
3861       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
3862       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
3863       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
3864
3865   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
3866     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
3867               [Whether the krb5_creds struct has a session property])
3868   fi
3869
3870   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
3871                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
3872     AC_TRY_COMPILE([#include <krb5.h>],
3873       [krb5_keyblock key; key.keyvalue.data = NULL;],
3874       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
3875       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
3876
3877   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
3878     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
3879               [Whether the krb5_keyblock struct has a keyvalue property])
3880   fi
3881
3882   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
3883                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
3884     AC_TRY_COMPILE([#include <krb5.h>],
3885       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
3886       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
3887       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
3888   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
3889                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
3890     AC_TRY_COMPILE([#include <krb5.h>],
3891       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
3892       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
3893       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
3894 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
3895 # w.r.t. arcfour and windows, so we must not enable it here
3896   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
3897           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
3898     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
3899               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
3900   fi
3901
3902   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
3903                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
3904     AC_TRY_COMPILE([#include <krb5.h>],
3905       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
3906       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
3907       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
3908
3909   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
3910     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
3911               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
3912   fi
3913
3914   AC_CACHE_CHECK([for KV5M_KEYTAB],
3915                  samba_cv_HAVE_KV5M_KEYTAB,[
3916     AC_TRY_COMPILE([#include <krb5.h>],
3917       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
3918       samba_cv_HAVE_KV5M_KEYTAB=yes,
3919       samba_cv_HAVE_KV5M_KEYTAB=no)])
3920
3921   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
3922       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
3923              [Whether the KV5M_KEYTAB option is available])
3924   fi
3925
3926   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
3927                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
3928     AC_TRY_COMPILE([#include <krb5.h>],
3929       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
3930       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
3931       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
3932
3933   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
3934     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
3935               [Whether KRB5_KU_OTHER_CKSUM is available])
3936   fi
3937
3938   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
3939                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
3940     AC_TRY_COMPILE([#include <krb5.h>],
3941       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
3942       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
3943       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
3944
3945   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
3946     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
3947               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
3948   fi
3949
3950   AC_CACHE_CHECK([for the krb5_princ_component macro],
3951                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
3952     AC_TRY_LINK([#include <krb5.h>],
3953       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
3954       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
3955       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])