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