registry cachehook: revert logic to make fast path more obvious and reduce indent.
[Samba/gbeck.git] / source / configure.in
blob7d6b1899e17b45f8cf3f4a06ab4b121c64662b2a
1 dnl Process this file with autoconf to produce a configure script.
3 dnl We must use autotools 2.53 or above
4 AC_PREREQ(2.53)
6 AC_INIT([Samba],[3],[samba-technical@samba.org])
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])
12 case "$PATH" in
13     */usr/ucb*)
14         AC_MSG_WARN([\$PATH contains /usr/ucb - build errors may follow])
15         ;;
16 esac 
18 builddir=`pwd`
19 AC_SUBST(builddir)
21 m4_include(m4/samba_version.m4)
22 m4_include(m4/check_path.m4)
24 AC_LIBREPLACE_CC_CHECKS
26 m4_include(lib/talloc/libtalloc.m4)
28 TALLOC_OBJS=""
29 for obj in ${TALLOC_OBJ}; do
30         TALLOC_OBJS="${TALLOC_OBJS} ${tallocdir}/${obj}"
31 done
32 AC_SUBST(TALLOC_OBJS)
34 # TODO: These should come from m4_include(lib/tdb/libtdb.m4)
35 # but currently this fails: things have to get merged from s4.
36 tdbdir="${srcdir-.}/lib/tdb"
37 AC_SUBST(tdbdir)
38 TDB_CFLAGS="-I$tdbdir/include"
39 AC_SUBST(TDB_CFLAGS)
40 TDB_OBJ="common/tdb.o common/dump.o common/transaction.o common/error.o common/traverse.o"
41 TDB_OBJ="$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o common/lock.o common/open.o"
42 AC_SUBST(TDB_OBJ)
44 TDB_OBJS=""
45 for obj in ${TDB_OBJ}; do
46         TDB_OBJS="${TDB_OBJS} ${tdbdir}/${obj}"
47 done
48 AC_SUBST(TDB_OBJS)
50 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
51 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace"
52 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
53 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
54 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
55 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
57 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/popt"
59 ## cleanup the $(srcdir) in the Makefile if we are outside of the tree
60 if test "x${srcdir-.}" != "x."; then
61         SAMBA_CPPFLAGS=`echo ${SAMBA_CPPFLAGS} | sed -e "s;${srcdir};\$\(srcdir\);g"`
64 dnl Unique-to-Samba variables we'll be playing with.
65 AC_SUBST(SAMBA_CPPFLAGS)
66 AC_SUBST(SHELL)
67 AC_SUBST(LDSHFLAGS)
68 AC_SUBST(SONAMEFLAG)
69 AC_SUBST(SHLD)
70 AC_SUBST(MODULE_EXPORTS)
71 AC_SUBST(DSO_EXPORTS)
72 AC_SUBST(HOST_OS)
73 AC_SUBST(PICFLAG)
74 AC_SUBST(PIE_CFLAGS)
75 AC_SUBST(PIE_LDFLAGS)
76 AC_SUBST(SHLIBEXT)
77 AC_SUBST(INSTALLLIBCMD_SH)
78 AC_SUBST(INSTALLLIBCMD_A)
79 AC_SUBST(UNINSTALLLIBCMD_SH)
80 AC_SUBST(UNINSTALLLIBCMD_A)
81 AC_SUBST(INSTALL_LIBADDNS)
82 AC_SUBST(UNINSTALL_LIBADDNS)
83 AC_SUBST(LIBADDNS_SHARED)
84 AC_SUBST(LIBADDNS)
86 AC_SUBST(INSTALL_LIBWBCLIENT)
87 AC_SUBST(UNINSTALL_LIBWBCLIENT)
88 AC_SUBST(LIBWBCLIENT_SHARED)
89 AC_SUBST(LIBWBCLIENT_STATIC)
90 AC_SUBST(LIBWBCLIENT)
91 AC_SUBST(WINBIND_LIBS)
93 AC_SUBST(LIBSAMBAUTIL_SHARED)
95 AC_SUBST(INSTALL_LIBSMBCLIENT)
96 AC_SUBST(UNINSTALL_LIBSMBCLIENT)
97 AC_SUBST(LIBSMBCLIENT_SHARED)
98 AC_SUBST(LIBSMBCLIENT)
99 AC_SUBST(INSTALL_LIBSMBSHAREMODES)
100 AC_SUBST(UNINSTALL_LIBSMBSHAREMODES)
101 AC_SUBST(LIBSMBSHAREMODES_SHARED)
102 AC_SUBST(LIBSMBSHAREMODES)
104 AC_SUBST(PRINT_LIBS)
105 AC_SUBST(AUTH_LIBS)
106 AC_SUBST(ACL_LIBS)
107 AC_SUBST(PASSDB_LIBS)
108 AC_SUBST(IDMAP_LIBS)
109 AC_SUBST(KRB5_LIBS)
110 AC_SUBST(UUID_LIBS)
111 AC_SUBST(LDAP_LIBS)
112 AC_SUBST(PAM_MODULES)
113 AC_SUBST(INSTALL_PAM_MODULES)
114 AC_SUBST(UNINSTALL_PAM_MODULES)
115 AC_SUBST(NSS_MODULES)
116 AC_SUBST(EXTRA_BIN_PROGS)
117 AC_SUBST(CIFSMOUNT_PROGS)
118 AC_SUBST(INSTALL_CIFSMOUNT)
119 AC_SUBST(UNINSTALL_CIFSMOUNT)
120 AC_SUBST(CIFSSPNEGO_PROGS)
121 AC_SUBST(INSTALL_CIFSSPNEGO)
122 AC_SUBST(UNINSTALL_CIFSSPNEGO)
123 AC_SUBST(EXTRA_SBIN_PROGS)
124 AC_SUBST(EXTRA_ALL_TARGETS)
125 AC_SUBST(CONFIG_LIBS)
126 AC_SUBST(NSCD_LIBS)
128 # compile with optimization and without debugging by default, but
129 # allow people to set their own preference.
130 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
131 # if it has no value.  This prevent *very* large debug binaries from occurring
132 # by default.
133 if test "x$CFLAGS" = x; then
134   CFLAGS="-O"
136 if test "x$debug" = "xyes" ; then
137         CFLAGS="${CFLAGS} -g"
138 else
139         CFLAGS="-O"
142 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
144 m4_include(lib/socket_wrapper/config.m4)
145 m4_include(lib/nss_wrapper/config.m4)
147 m4_include(m4/swat.m4)
149 # Probe the gcc version for extra CFLAGS. We always stash these in
150 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
151 # Makefile edit, avoiding the need to re-run configure.
152 if test x"$ac_cv_prog_gcc" = x"yes" ; then
153         DEVELOPER_CFLAGS="-g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
154         # Add -Wdeclaration-after-statement if compiler supports it
155         AC_CACHE_CHECK(
156           [that the C compiler understands -Wdeclaration-after-statement],
157           samba_cv_HAVE_Wdeclaration_after_statement, [
158           AC_TRY_RUN_STRICT([
159             int main(void)
160             {
161                 return 0;
162             }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
163             samba_cv_HAVE_Wdeclaration_after_statement=yes,
164             samba_cv_HAVE_Wdeclaration_after_statement=no,
165             samba_cv_HAVE_Wdeclaration_after_statement=cross)
166        ])
168         if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
169             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
170         fi
172         #-Werror-implicit-function-declaration
173         AC_CACHE_CHECK(
174           [that the C compiler understands -Werror-implicit-function-declaration],
175           samba_cv_HAVE_Werror_implicit_function_declaration, [
176           AC_TRY_RUN_STRICT([
177             int main(void)
178             {
179                 return 0;
180             }],[-Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
181             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
182             samba_cv_HAVE_Werror_implicit_function_declaration=no,
183             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
184        ])
185        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
186             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
187        fi
189         # krb5developer is like developer, except we don't get
190         # -Wstrict-prototypes.
191        if test x"$krb5_developer" != x"$yes" ; then
192             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
193        fi
196 AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
198 if test "x$enable_dmalloc" = xyes
199 then
200         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
201         AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
202                   [Define to check invariants around some common functions])
203         LIBS="$LIBS -ldmalloc"  
206 #################################################
207 # check for a shared memory profiling support
208 AC_MSG_CHECKING(whether to use profiling)
209 AC_ARG_WITH(profiling-data,
210 [AS_HELP_STRING([--with-profiling-data], [Include gathering source code profile information (default=no)])],
211 [ case "$withval" in
212   yes)
213     AC_MSG_RESULT(yes)
214     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
215     samba_cv_WITH_PROFILE=yes
216     ;;
217   *)
218     AC_MSG_RESULT(no)
219     samba_cv_WITH_PROFILE=no
220     ;;
221   esac ],
222   AC_MSG_RESULT(no)
225 dnl Checks for programs.
227 AC_PROG_INSTALL
228 AC_PROG_AWK
229 AC_PATH_PROG(PERL, perl)
231 AC_CHECK_TOOL(AR, ar)
233 dnl Check if we use GNU ld
234 LD=ld
235 AC_PROG_LD_GNU
237 dnl Certain versions of GNU ld the default is not to have the
238 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
239 dnl warnings when building modules.
240 if test "$ac_cv_prog_gnu_ld" = "yes"; then
241         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
242         AC_MSG_CHECKING(GNU ld release date)
243         changequote(,)dnl
244         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'`
245         changequote([,])dnl
246         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
247         if test -n "$ac_cv_gnu_ld_date"; then
248         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
249                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
250         fi
251         if test "$ac_cv_gnu_ld_date" -gt 20030101; then
252                 ac_cv_gnu_ld_version_script=yes
253         fi
254         else
255            AC_MSG_CHECKING(GNU ld release version)
256            changequote(,)dnl
257            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
258            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
259            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
260            changequote([,])dnl
261            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
262            AC_MSG_CHECKING(GNU ld release version major)
263            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
264            AC_MSG_CHECKING(GNU ld release version minor)
265            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
266            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
267              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
268            fi
269            if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_l= d_vernr_major"=2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
270              ac_cv_gnu_ld_version_script=yes
271            fi
272         fi
275 dnl look for executable suffix
276 AC_EXEEXT
278 dnl Check if C compiler understands -c and -o at the same time
279 AC_PROG_CC_C_O
280 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
281       BROKEN_CC=
282 else
283       BROKEN_CC=#
285 AC_SUBST(BROKEN_CC)
287 dnl Check if the C compiler understands -Werror
288 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
289  AC_TRY_RUN_STRICT([
290   int main(void)
291   {
292         return 0;
293   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
294   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
295 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
296    Werror_FLAGS="-Werror"
297 else
298 dnl Check if the C compiler understands -w2
299 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
300  AC_TRY_RUN_STRICT([
301   int main(void)
302   {
303         return 0;
304   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
305   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
306 if test x"$samba_cv_HAVE_w2" = x"yes"; then
307    Werror_FLAGS="-w2"
308 else
309 dnl Check if the C compiler understands -errwarn
310 AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
311   AC_TRY_RUN_STRICT([
312    int main(void)
313    {
314         return 0;
315    }],[-errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
316    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
317 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
318    Werror_FLAGS="-errwarn=%all"
323 dnl Check if the C compiler understands volatile (it should, being ANSI).
324 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
325     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
326         samba_cv_volatile=yes,samba_cv_volatile=no)])
327 if test x"$samba_cv_volatile" = x"yes"; then
328    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
331 ############################################
332 # check if the compiler can handle negative enum values
333 # and don't truncate the values to INT_MAX
334 # a runtime test is needed here
335 AC_SUBST(PIDL_ARGS)
336 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
337     AC_TRY_RUN(
339         #include <stdio.h>
340         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
341         int main(void) {
342                 enum negative_values v1 = NEGATIVE_VALUE;
343                 unsigned v2 = NEGATIVE_VALUE;
345                 if (v1 != 0xFFFFFFFF) {
346                         printf("%u != 0xFFFFFFFF\n", v1);
347                         return 1;
348                 }
349                 if (v2 != 0xFFFFFFFF) {
350                         printf("%u != 0xFFFFFFFF\n", v2);
351                         return 1;
352                 }
354                 return 0;
355         }
357         SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
358 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
359         AC_MSG_WARN([using --unit-enums for pidl])
360         PIDL_ARGS="$PIDL_ARGS --uint-enums"
363 dnl Figure out the flags to support named structure initializers
365 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
367 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
368 AC_MSG_CHECKING(uname -s)
369 AC_MSG_RESULT(${UNAME_S})
371 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
372 AC_MSG_CHECKING(uname -r)
373 AC_MSG_RESULT(${UNAME_R})
375 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
376 AC_MSG_CHECKING(uname -m)
377 AC_MSG_RESULT(${UNAME_M})
379 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
380 AC_MSG_CHECKING(uname -p)
381 AC_MSG_RESULT(${UNAME_P})
383 UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
384 AC_MSG_CHECKING(uname -i)
385 AC_MSG_RESULT(${UNAME_I})
387 dnl Add #include for broken IRIX header files
388   case "$host_os" in
389         *irix6*)
390                 #TODO add to libreplace
391                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
392                         dnl Fix sensible defaults for MIPSPro compilers. The
393                         dnl error numbers are valid for the 7.3 compilers,
394                         dnl hopefully also valid for the 7.4 series.
395                         dnl
396                         dnl Bugzilla 3801. Force an error on warning 1035
397                         dnl so we don't incorrectly detect stdint.h. This
398                         dnl warning is emitted for #error directives.
399                         CFLAGS="$CFLAGS -diag_error 1035"
400                         dnl 1209: Controlling expression is constant
401                         dnl 1174: Function foo declared but never referenced
402                         dnl 3201: Parameter foo was never referenced
403                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
404                 fi
405         ;;
406 esac
408 DYNEXP=
409 AC_SUBST(DYNEXP)
411 dnl Add modules that have to be built by default here
412 dnl These have to be built static:
413 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs2 rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
415 dnl These are preferably build shared, and static if dlopen() is not available
416 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"
418 if test "x$developer" = xyes; then
419    default_static_modules="$default_static_modules rpc_rpcecho"
420    default_shared_modules="$default_shared_modules charset_weird"
424 # Config CPPFLAG settings for strange OS's that must be set
425 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
426 # case statement; its first reference must be unconditional.
428 case "$host_os" in
429     *hpux*)
431 # Defines needed for HPUX support.
432 # HPUX has bigcrypt but (sometimes?) doesn't use it for
433 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
435       case `uname -r` in
436                 *9*|*10*|*11)
437                         AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
438                 ;;
439       esac
440       ;;
443 # CRAY Unicos has broken const handling
444        *unicos*)
445           AC_MSG_RESULT([disabling const])
446           CPPFLAGS="$CPPFLAGS -Dconst="
447           ;;
448         
450 # AIX4.x doesn't even admit to having large
451 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
453     *aix4*)
454           AC_MSG_RESULT([enabling large file support])
455       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
456           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
457       ;;
459 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
460 # to the existance of large files..
461 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
462 # recommendations on large file support, however it makes the
463 # compile work using gcc 2.7 and 2.8, whereas using the Sun
464 # recommendation makes the compile fail on gcc2.7. JRA.
466 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
468         *solaris*)
469                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
470                 case `uname -r` in
471                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
472                                 AC_MSG_RESULT([no large file support])
473                                 ;;
474                         5.*)
475                         AC_MSG_RESULT([enabling large file support])
476                         if test "$ac_cv_prog_gcc" = yes; then
477                                 ${CC-cc} -v >conftest.c 2>&1
478                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
479                                 rm -fr conftest.c
480                                 case "$ac_cv_gcc_compiler_version_number" in
481                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
482                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
483                                                 LDFLAGS="$LDFLAGS -lthread"
484                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
485                                                 ;;
486                                         *)
487                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
488                                                 LDFLAGS="$LDFLAGS -lthread"
489                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
490                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
491                                                 ;;
492                                 esac
493                         else
494                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
495                                 LDFLAGS="$LDFLAGS -lthread"
496                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
497                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
498                         fi
499                         ;;
500                 esac
501                 ;;
503 # IRIX uses SYSV printing.  Make sure to set that here
505         *irix*)
506                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
507                 ;;
508         *freebsd*|*dragonfly*)
509                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
510                 ;;
512 # VOS may need to have POSIX support and System V compatibility enabled.
514     *vos*)
515     case "$CPPFLAGS" in
516           *-D_POSIX_C_SOURCE*)
517                 ;;
518           *)
519                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
520                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
521                 ;;
522     esac
523     case "$CPPFLAGS" in
524           *-D_SYSV*|*-D_SVID_SOURCE*)
525                 ;;
526           *)
527                 CPPFLAGS="$CPPFLAGS -D_SYSV"
528                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
529     esac
530     ;;
532 # Tests needed for SINIX large file support.
534     *sysv4*)
535       if test $host = mips-sni-sysv4 ; then
536         AC_MSG_CHECKING([for LFS support])
537         old_CPPFLAGS="$CPPFLAGS"
538         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
539         AC_TRY_RUN([
540 #include <unistd.h>
541 main () {
542 #if _LFS64_LARGEFILE == 1
543 exit(0);
544 #else
545 exit(1);
546 #endif
547 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
548         CPPFLAGS="$old_CPPFLAGS"
549         if test x$SINIX_LFS_SUPPORT = xyes ; then
550           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
551                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
552           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
553           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
554           LIBS="`getconf LFS64_LIBS` $LIBS"
555         fi
556       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
557       fi
558     ;;
560 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
562     *linux*)
563         AC_MSG_CHECKING([for LFS support])
564         old_CPPFLAGS="$CPPFLAGS"
565         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
566        AC_TRY_RUN([
567 #include <unistd.h>
568 #include <sys/utsname.h>
569 #include <string.h>
570 #include <stdlib.h>
571 main() {
572 #if _LFS64_LARGEFILE == 1
573        struct utsname uts;
574        char *release;
575        int major, minor;
577        /* Ensure this is glibc 2.2 or higher */
578 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
579        int libc_major = __GLIBC__;
580        int libc_minor = __GLIBC_MINOR__;
582        if (libc_major < 2)
583               exit(1);
584        if (libc_minor < 2)
585               exit(1);
586 #endif
588        /* Ensure this is kernel 2.4 or higher */
590        uname(&uts);
591        release = strdup(uts.release);
592        major = atoi(strsep(&release, "."));
593        minor = atoi(strsep(&release, "."));
595        if (major > 2 || (major == 2 && minor > 3))
596                exit(0);
597        exit(1);
598 #else
599        exit(1);
600 #endif
602 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
603         CPPFLAGS="$old_CPPFLAGS"
604         if test x$LINUX_LFS_SUPPORT = xyes ; then
605                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
606                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
607                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
608                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
609         fi
610         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
611         ;;
614 # MacOS X is the *only* system that uses compose character in utf8. This
615 # is so horribly broken....
617     *darwin*)
618         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
620 # Add a system specific charset module.
621         default_shared_modules="$default_shared_modules charset_macosxfs"
623         ;;
624     *hurd*)
625         AC_MSG_CHECKING([for LFS support])
626         old_CPPFLAGS="$CPPFLAGS"
627         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
628         AC_TRY_RUN([
629 #include <unistd.h>
630 main () {
631 #if _LFS64_LARGEFILE == 1
632 exit(0);
633 #else
634 exit(1);
635 #endif
636 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
637         CPPFLAGS="$old_CPPFLAGS"
638         if test x$GLIBC_LFS_SUPPORT = xyes ; then
639           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
640                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
641           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
642         fi
643       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
644     ;;
646 esac
648 SAVE_CPPFLAGS="${CPPFLAGS}"
649 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
651 AC_LIBREPLACE_BROKEN_CHECKS
653 CPPFLAGS="${SAVE_CPPFLAGS}"
655 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
657 LIBREPLACE_OBJS=""
658 for obj in ${LIBREPLACEOBJ}; do
659         LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
660 done
661 AC_SUBST(LIBREPLACE_OBJS)
663 # add -ldl to the global LIBS
664 LIBS="${LIBS} ${LIBDL}"
666 AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
667 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
668 AC_CHECK_HEADERS(limits.h float.h pthread.h)
669 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
670 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
671 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
672 AC_CHECK_HEADERS(sys/un.h ifaddrs.h)
673 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
674 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
675 AC_CHECK_HEADERS(sys/sysmacros.h)
676 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
677 AC_CHECK_HEADERS(langinfo.h locale.h)
678 AC_CHECK_HEADERS(xfs/libxfs.h)
679 AC_CHECK_HEADERS(netgroup.h)
681 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
682 #if HAVE_RPC_RPC_H
683 #include <rpc/rpc.h>
684 #endif
687 ## These fail to compile on IRIX so just check for their presence
688 AC_CHECK_HEADERS(sys/mode.h,,,)
690 # Look for Darwin headers
691 old_CPPFLAGS="$CPPFLAGS"
692 CPPFLAGS="-Iinclude $CPPFLAGS"
693 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
694 CPPFLAGS="$old_CPPFLAGS"
696 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
697 # subdirectory of headers.
698 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
700 # check for linux on amd64 since valgrind is not quite there yet
701 case "$host_os" in
702         *linux*)
703                 case "$UNAME_P" in
704                         *x86_64*)
705                                 AC_DEFINE(HAVE_64BIT_LINUX,1,[Whether we are running on 64bit linux])
706                                 ;;
707                 esac
708                 ;;
709 esac
713 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
714 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
716 case "$host_os" in
717     *hpux*)
718                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
719                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
720                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
721                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
722                 fi
723         ;;
724 esac
725 AC_CHECK_HEADERS(shadow.h)
726 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
727 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
729 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
730 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
732 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
734 # For experimental utmp support (lastlog on some BSD-like systems)
735 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
737 AC_CHECK_SIZEOF(int,cross)
738 AC_CHECK_SIZEOF(long,cross)
739 AC_CHECK_SIZEOF(long long,cross)
740 AC_CHECK_SIZEOF(short,cross)
742 AC_C_CONST
743 AC_C_INLINE
744 AC_C_BIGENDIAN
745 AC_C_CHAR_UNSIGNED
747 AC_TYPE_SIGNAL
748 AC_TYPE_UID_T
749 AC_TYPE_MODE_T
750 AC_TYPE_OFF_T
751 AC_TYPE_SIZE_T
752 AC_TYPE_PID_T
753 AC_STRUCT_ST_RDEV
754 AC_DIRENT_D_OFF
755 AC_CHECK_TYPE(ssize_t, int)
756 AC_CHECK_TYPE(wchar_t, unsigned short)
758 ############################################
759 # for cups support we need libcups, and a handful of header files
761 AC_ARG_ENABLE(cups,
762 [AS_HELP_STRING([--enable-cups], [Turn on CUPS support (default=auto)])])
764 if test x$enable_cups != xno; then
765         AC_PATH_PROG(CUPS_CONFIG, cups-config)
767         if test "x$CUPS_CONFIG" != x; then
768                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
769                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
770                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
771                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
772         elif test x"$enable_cups" = x"yes"; then
773                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
774         fi
777 AC_ARG_ENABLE(iprint,
778 [AS_HELP_STRING([--enable-iprint], [Turn on iPrint support (default=yes if cups is yes)])])
780 if test x$enable_iprint != xno; then
781         if test "x$CUPS_CONFIG" != x; then
782                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
783         elif test x"$enable_iprint" = x"yes"; then
784                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
785         fi
788 ############################################
789 # check if the compiler will optimize out function calls
790 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
791     AC_TRY_LINK([
792 #include <stdio.h>],
794                 if (0) {
795                    this_function_does_not_exist();
796                 } else {
797                   return 1;
798                 }
801         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
802 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
803    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
806 ############################################
807 # check for unix domain sockets
808 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
809     AC_TRY_COMPILE([
810 #include <sys/types.h>
811 #include <stdlib.h>
812 #include <stddef.h>
813 #include <sys/socket.h>
814 #include <sys/un.h>],
816   struct sockaddr_un sunaddr;
817   sunaddr.sun_family = AF_UNIX;
819         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
820 if test x"$samba_cv_unixsocket" = x"yes"; then
821    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixsocket support])
824 #############################################
825 # check for fd passing struct via msg_control
826 AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [
827     AC_TRY_COMPILE([
828 #include <sys/types.h>
829 #include <stdlib.h>
830 #include <stddef.h>
831 #include <sys/socket.h>
832 #include <sys/un.h>],
834         struct msghdr msg;
835         union {
836               struct cmsghdr cm;
837               char control[CMSG_SPACE(sizeof(int))];
838         } control_un;
839         msg.msg_control = control_un.control;
840         msg.msg_controllen = sizeof(control_un.control);
842         samba_cv_msghdr_msg_control=yes,samba_cv_msghdr_msg_control=no)])
843 if test x"$samba_cv_msghdr_msg_control" = x"yes"; then
844    AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1,
845              [If we can use msg_control for passing file descriptors])
848 #############################################
849 # check for fd passing struct via msg_acctrights
850 AC_CACHE_CHECK([for fd passing via msg_acctrights],
851                 samba_cv_msghdr_msg_acctrights, [
852     AC_TRY_COMPILE([
853 #include <sys/types.h>
854 #include <stdlib.h>
855 #include <stddef.h>
856 #include <sys/socket.h>
857 #include <sys/un.h>],
859         struct msghdr msg;
860         int fd;
861         msg.msg_acctrights = (caddr_t) &fd;
862         msg.msg_acctrightslen = sizeof(fd);
864         samba_cv_msghdr_msg_acctrights=yes,samba_cv_msghdr_msg_acctrights=no)])
865 if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then
866    AC_DEFINE(HAVE_MSGHDR_MSG_ACCTRIGHTS,1,
867              [If we can use msg_acctrights for passing file descriptors])
870 AC_CHECK_FUNCS(dirfd)
871 if test x"$ac_cv_func_dirfd" = x"yes"; then
872         default_shared_modules="$default_shared_modules vfs_syncops"
875 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
876     AC_TRY_COMPILE([
877 #include <sys/types.h>
878 #if STDC_HEADERS
879 #include <stdlib.h>
880 #include <stddef.h>
881 #endif
882 #include <signal.h>],[sig_atomic_t i = 0],
883         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
884 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
885    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
888 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
889     AC_TRY_COMPILE([
890 #include <sys/types.h>
891 #if STDC_HEADERS
892 #include <stdlib.h>
893 #include <stddef.h>
894 #endif
895 #if TIME_WITH_SYS_TIME
896 # include <sys/time.h>
897 # include <time.h>
898 #else
899 # if HAVE_SYS_TIME_H
900 #  include <sys/time.h>
901 # else
902 #  include <time.h>
903 # endif
904 #endif
905 ],[struct timespec ts;],
906         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
907 if test x"$samba_cv_struct_timespec" = x"yes"; then
908    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
911 # stupid headers have the functions but no declaration. grrrr.
912 AC_HAVE_DECL(errno, [#include <errno.h>])
913 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
914 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
916 # and glibc has setresuid under linux but the function does
917 # nothing until kernel 2.1.44! very dumb.
918 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
919     AC_TRY_RUN([#include <errno.h>
920 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
921         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
922 if test x"$samba_cv_have_setresuid" = x"yes"; then
923     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
926 # Do the same check for setresguid...
928 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
929     AC_TRY_RUN([#include <unistd.h>
930 #include <errno.h>
931 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
932         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
933 if test x"$samba_cv_have_setresgid" = x"yes"; then
934     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
937 AC_FUNC_MEMCMP
939 ###############################################
940 # Readline included by default unless explicitly asked not to
941 test "${with_readline+set}" != "set" && with_readline=yes
943 # test for where we get readline() from
944 AC_MSG_CHECKING(whether to use readline)
945 AC_ARG_WITH(readline,
946 [AS_HELP_STRING([--with-readline[=DIR]], [Look for readline include/libs in DIR (default=auto)])],
947 [  case "$with_readline" in
948   yes)
949     AC_MSG_RESULT(yes)
951     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
952     AC_CHECK_HEADERS(readline/history.h)
954     AC_CHECK_HEADERS(readline.h readline/readline.h,[
955       for termlib in ncurses curses termcap terminfo termlib tinfo; do
956        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
957       done
958       AC_CHECK_LIB(readline, rl_callback_handler_install,
959        [TERMLIBS="-lreadline $TERMLIBS"
960        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
961        break], [TERMLIBS=], $TERMLIBS)])
962     ;;
963   no)
964     AC_MSG_RESULT(no)
965     ;;
966   *)
967     AC_MSG_RESULT(yes)
969     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
970     # alternate readline path
971     _ldflags=${LDFLAGS}
972     _cppflags=${CPPFLAGS}
974     # Add additional search path
975     LDFLAGS="-L$with_readline/lib $LDFLAGS"
976     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
978     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
979     AC_CHECK_HEADERS(readline/history.h)
981     AC_CHECK_HEADERS(readline.h readline/readline.h,[
982       for termlib in ncurses curses termcap terminfo termlib; do
983        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
984       done
985       AC_CHECK_LIB(readline, rl_callback_handler_install,
986        [TERMLDFLAGS="-L$with_readline/lib"
987        TERMCPPFLAGS="-I$with_readline/include"
988        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
989        TERMLIBS="-lreadline $TERMLIBS"
990        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
991        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
993     LDFLAGS=$_ldflags
994     ;;
995   esac],
996   AC_MSG_RESULT(no)
998 AC_SUBST(TERMLIBS)
999 AC_SUBST(TERMLDFLAGS)
1001 # The readline API changed slightly from readline3 to readline4, so
1002 # code will generate warnings on one of them unless we have a few
1003 # special cases.
1004 AC_CHECK_LIB(readline, rl_completion_matches,
1005              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
1006                         [Do we have rl_completion_matches?])],
1007              [],
1008              [$TERMLIBS])
1010 # not all readline libs have rl_event_hook or history_list
1011 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
1012 AC_CHECK_LIB(readline, history_list,
1013              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
1014              [],
1015              [$TERMLIBS])
1017 # The following test taken from the cvs sources
1018 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
1019 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
1020 # libsocket.so which has a bad implementation of gethostbyname (it
1021 # only looks in /etc/hosts), so we only look for -lsocket if we need
1022 # it.
1023 AC_CHECK_FUNCS(connect)
1024 if test x"$ac_cv_func_connect" = x"no"; then
1025     case "$LIBS" in
1026     *-lnsl*) ;;
1027     *) AC_CHECK_LIB(nsl_s, connect) ;;
1028     esac
1029     case "$LIBS" in
1030     *-lnsl*) ;;
1031     *) AC_CHECK_LIB(nsl, connect) ;;
1032     esac
1033     case "$LIBS" in
1034     *-lsocket*) ;;
1035     *) AC_CHECK_LIB(socket, connect) ;;
1036     esac
1037     case "$LIBS" in
1038     *-linet*) ;;
1039     *) AC_CHECK_LIB(inet, connect) ;;
1040     esac
1041     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
1042     dnl has been cached.
1043     if test x"$ac_cv_lib_socket_connect" = x"yes" ||
1044        test x"$ac_cv_lib_inet_connect" = x"yes"; then
1045         # ac_cv_func_connect=yes
1046         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
1047         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
1048     fi
1051 ###############################################
1052 # test for where we get yp_get_default_domain() from
1053 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1054 AC_CHECK_FUNCS(yp_get_default_domain)
1056 # Check if we have execl, if not we need to compile smbrun.
1057 AC_CHECK_FUNCS(execl)
1058 if test x"$ac_cv_func_execl" = x"no"; then
1059     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1062 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror chown fchown lchown chmod fchmod chroot link mknod mknod64)
1063 AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
1064 AC_CHECK_FUNCS(fstat strchr utime utimes chflags)
1065 AC_CHECK_FUNCS(getrlimit fsync fdatasync memset strlcpy strlcat setpgid)
1066 AC_CHECK_FUNCS(memmove setsid glob strpbrk pipe crypt16 getauthuid)
1067 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1068 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1069 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
1070 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
1071 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1072 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1073 AC_CHECK_FUNCS(getpwent_r)
1074 AC_CHECK_FUNCS(getdents getdents64)
1075 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1076 AC_CHECK_FUNCS(syslog vsyslog timegm)
1077 AC_CHECK_FUNCS(setlocale nl_langinfo)
1078 AC_CHECK_FUNCS(nanosleep)
1079 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1080 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
1081 AC_CHECK_HEADERS(sys/mman.h)
1082 # setbuffer, shmget, shm_open are needed for smbtorture
1083 AC_CHECK_FUNCS(setbuffer shmget shm_open)
1085 # Find a method of generating a stack trace
1086 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1087 AC_CHECK_FUNCS(backtrace_symbols)
1088 AC_CHECK_LIB(exc, trace_back_stack)
1090 printf "%s" "checking for GPFS GPL libs... "
1091 save_LIBS="$LIBS"
1092 LIBS="$LIBS -lgpfs_gpl"
1093 AC_TRY_LINK([#include <gpfs_gpl.h>],
1094           [gpfs_set_share(0,GPFS_SHARE_READ,GPFS_DENY_NONE)],
1095           samba_cv_HAVE_GPFS=yes,
1096           samba_cv_HAVE_GPFS=no)
1097 echo $samba_cv_HAVE_GPFS
1098 if test x"$samba_cv_HAVE_GPFS" = x"yes"; then
1099     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL libs are available])
1100     default_shared_modules="$default_shared_modules vfs_gpfs"
1102 LIBS="$save_LIBS"
1104 # Note that all the libunwind symbols in the API are defined to internal
1105 # platform-specific version, so we must include libunwind.h before checking
1106 # any of them.
1107 AC_MSG_CHECKING([for libunwind])
1108 save_LIBS=$LIBS
1110 UNWIND_ARCH="unknown"
1111 if test x"$UNAME_I" != x"unknown"; then
1112         UNWIND_ARCH="$UNAME_I"
1113 elif test x"$UNAME_M" != x"unknown"; then
1114         UNWIND_ARCH="$UNAME_M"
1115 elif test x"$UNAME_P" != x"unknown"; then
1116         UNWIND_ARCH="$UNAME_P"
1119 case "$UNWIND_ARCH" in
1120         unknown)
1121                 # This probably won't link without
1122                 # the platform-specific libunwind.
1123                 LIBS="$LIBS -lunwind"
1124                 ;;
1125         i386|i586|i686)
1126                 # Add the platform-specific libunwind module.
1127                 LIBS="$LIBS -lunwind -lunwind-x86"
1128                 ;;
1129         *)
1130                 # Add the platform-specific libunwind module.
1131                 # based on uname -i, uname -m or uname -p
1132                 LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
1133                 ;;
1134 esac
1136 AC_TRY_LINK(
1137     [
1138 #ifdef HAVE_LIBUNWIND_H
1139 #include <libunwind.h>
1140 #endif
1141     ],
1142     [
1143         unw_context_t ctx; unw_cursor_t cur;
1144         char buf[256]; unw_word_t off;
1145         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1146         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1147     ],
1148     [
1149         AC_MSG_RESULT(yes)
1150         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1152         # If we have libunwind, test whether we also have libunwind-ptrace
1153         # which would let us unwind arbitrary processes.
1154         save_LIBS=$LIBS
1155         AC_CHECK_HEADERS(libunwind-ptrace.h)
1156         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1157             [
1158                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1159                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1160                     [Whether libunwind-ptrace.a is available.])
1161             ],
1162             [ LIBUNWIND_PTRACE="" ])
1164         LIBS=$save_LIBS
1165     ],
1166     [
1167         AC_MSG_RESULT(no)
1168         LIBS=$save_LIBS
1169     ])
1171 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1172 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1173     AC_CHECK_HEADERS(sys/ptrace.h)
1174     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1175     AC_TRY_LINK(
1176             [
1177 #if HAVE_SYS_TYPES_H
1178 #include <sys/types.h>
1179 #endif
1180 #if HAVE_SYS_PTRACE_H
1181 #include <sys/ptrace.h>
1182 #endif
1183             ],
1184             [
1185                 int main(int argc, const char ** argv)
1186                 {
1187                         pid_t me = (pid_t)-1;
1188                         ptrace(PTRACE_ATTACH, me, 0, 0);
1189                         ptrace(PTRACE_DETACH, me, 0, 0);
1190                         return 0;
1191                 }
1192             ],
1193             [
1194                 AC_MSG_RESULT(yes)
1195                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1196                     [Whether the Linux ptrace(2) interface is available.])
1197             ],
1198             [
1199                 AC_MSG_RESULT(no)
1200                 LIBUNWIND_PTRACE=""
1201             ])
1204 AC_SUBST(LIBUNWIND_PTRACE)
1206 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1207 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1208 AC_CHECK_FUNCS(__getcwd _getcwd)
1209 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1210 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1211 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1212 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1213 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1214 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1215 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1216 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1217 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1218 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1219 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1220 AC_CHECK_FUNCS(prctl)
1222 AC_TRY_COMPILE([
1223 #ifdef HAVE_SYS_PRCTL_H
1224 #include <sys/prctl.h>
1225 #endif
1227 [int i; i = prtcl(0); ],
1228 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1233 case "$host_os" in
1234     *linux*)
1235        # glibc <= 2.3.2 has a broken getgrouplist
1236        AC_TRY_RUN([
1237 #include <unistd.h>
1238 #include <sys/utsname.h>
1239 main() {
1240        /* glibc up to 2.3 has a broken getgrouplist */
1241 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1242        int libc_major = __GLIBC__;
1243        int libc_minor = __GLIBC_MINOR__;
1245        if (libc_major < 2)
1246               exit(1);
1247        if ((libc_major == 2) && (libc_minor <= 3))
1248               exit(1);
1249 #endif
1250        exit(0);
1252 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1253        if test x"$linux_getgrouplist_ok" = x"yes"; then
1254           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1255        fi
1256        ;;
1257     *)
1258        AC_CHECK_FUNCS(getgrouplist)
1259        ;;
1260 esac
1263 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1266 if test x$ac_cv_func_stat64 = xno ; then
1267   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1268   AC_TRY_LINK([
1269 #if defined(HAVE_UNISTD_H)
1270 #include <unistd.h>
1271 #endif
1272 #include <sys/stat.h>
1273 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1274   AC_MSG_RESULT([$ac_cv_func_stat64])
1275   if test x$ac_cv_func_stat64 = xyes ; then
1276     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1277   fi
1280 if test x$ac_cv_func_lstat64 = xno ; then
1281   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1282   AC_TRY_LINK([
1283 #if defined(HAVE_UNISTD_H)
1284 #include <unistd.h>
1285 #endif
1286 #include <sys/stat.h>
1287 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1288   AC_MSG_RESULT([$ac_cv_func_lstat64])
1289   if test x$ac_cv_func_lstat64 = xyes ; then
1290     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1291   fi
1294 if test x$ac_cv_func_fstat64 = xno ; then
1295   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1296   AC_TRY_LINK([
1297 #if defined(HAVE_UNISTD_H)
1298 #include <unistd.h>
1299 #endif
1300 #include <sys/stat.h>
1301 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1302   AC_MSG_RESULT([$ac_cv_func_fstat64])
1303   if test x$ac_cv_func_fstat64 = xyes ; then
1304     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1305   fi
1308 #################################################
1309 # Check whether struct stat has timestamps with sub-second resolution.
1310 # At least IRIX and Solaris have these.
1312 # We check that
1313 #       all of st_mtim, st_atim and st_ctim exist
1314 #       all of the members are in fact of type struct timespec
1316 # There is some conflicting standards weirdness about whether we should use
1317 # "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we
1318 # prefer struct timespec.
1320 AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_stat_hires,
1321     [
1322         AC_TRY_COMPILE(
1323             [
1324 #if TIME_WITH_SYS_TIME
1325 # include <sys/time.h>
1326 # include <time.h>
1327 #else
1328 # if HAVE_SYS_TIME_H
1329 #  include <sys/time.h>
1330 # else
1331 #  include <time.h>
1332 # endif
1333 #endif
1334 #ifdef HAVE_SYS_STAT_H
1335 #include <sys/stat.h>
1336 #endif
1337             ],
1338             [
1339                 struct timespec t;
1340                 struct stat s = {0};
1341                 t.tv_sec = s.st_mtim.tv_sec;
1342                 t.tv_nsec = s.st_mtim.tv_nsec;
1343                 t.tv_sec = s.st_ctim.tv_sec;
1344                 t.tv_nsec = s.st_ctim.tv_nsec;
1345                 t.tv_sec = s.st_atim.tv_sec;
1346                 t.tv_nsec = s.st_atim.tv_nsec;
1347             ],
1348             samba_stat_hires=yes, samba_stat_hires=no)
1349     ])
1351 if test x"$samba_stat_hires" = x"yes" ; then
1352     AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim])
1353     AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim])
1354     AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim])
1355     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1356             [whether struct stat has sub-second timestamps])
1359 AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_stat_hires_notimespec,
1360     [
1361         AC_TRY_COMPILE(
1362             [
1363 #if TIME_WITH_SYS_TIME
1364 # include <sys/time.h>
1365 # include <time.h>
1366 #else
1367 # if HAVE_SYS_TIME_H
1368 #  include <sys/time.h>
1369 # else
1370 #  include <time.h>
1371 # endif
1372 #endif
1373 #ifdef HAVE_SYS_STAT_H
1374 #include <sys/stat.h>
1375 #endif
1376             ],
1377             [
1378                 struct timespec t;
1379                 struct stat s = {0};
1380                 t.tv_sec = s.st_mtime;
1381                 t.tv_nsec = s.st_mtimensec;
1382                 t.tv_sec = s.st_ctime;
1383                 t.tv_nsec = s.st_ctimensec;
1384                 t.tv_sec = s.st_atime;
1385                 t.tv_nsec = s.st_atimensec;
1386             ],
1387             samba_stat_hires=yes, samba_stat_hires=no)
1388     ])
1390 if test x"$samba_stat_hires_notimespec" = x"yes" ; then
1391     AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
1392     AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
1393     AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
1394     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1395             [whether struct stat has sub-second timestamps without struct timespec])
1398 #####################################
1399 # needed for SRV lookups
1400 AC_CHECK_LIB(resolv, dn_expand)
1401 AC_CHECK_LIB(resolv, _dn_expand)
1402 AC_CHECK_LIB(resolv, __dn_expand)
1405 # Check for the functions putprpwnam, set_auth_parameters,
1406 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1407 # Needed for OSF1 and HPUX.
1410 AC_LIBTESTFUNC(security, putprpwnam)
1411 AC_LIBTESTFUNC(sec, putprpwnam)
1413 AC_LIBTESTFUNC(security, set_auth_parameters)
1414 AC_LIBTESTFUNC(sec, set_auth_parameters)
1416 # UnixWare 7.x has its getspnam in -lgen
1417 AC_LIBTESTFUNC(gen, getspnam)
1419 AC_LIBTESTFUNC(security, getspnam)
1420 AC_LIBTESTFUNC(sec, getspnam)
1422 AC_LIBTESTFUNC(security, bigcrypt)
1423 AC_LIBTESTFUNC(sec, bigcrypt)
1425 AC_LIBTESTFUNC(security, getprpwnam)
1426 AC_LIBTESTFUNC(sec, getprpwnam)
1428 AC_CHECK_FUNCS(strsignal)
1430 ############################################
1431 # Check if we have libattr
1432 case "$host_os" in
1433   *osf*)
1434         AC_SEARCH_LIBS(getproplist, [proplist])
1435         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1436         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1437         AC_CHECK_FUNCS(sizeof_proplist_entry)
1438   ;;
1439   *)
1440         AC_SEARCH_LIBS(getxattr, [attr])
1441         AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1442         AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
1443         AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
1444         AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1445         AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1446         AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1447         AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1448   ;;
1449 esac
1451 ########################################################
1452 # Check if attropen() is present if this is Solaris
1453 case "$host_os" in
1454   *solaris*)
1455         AC_CHECK_FUNCS(attropen)
1456   ;;
1457 esac
1459 ########################################################
1460 # Do xattr functions take additional options like on Darwin?
1461 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1462         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1463                 old_LIBS=$LIBS
1464                 LIBS="$LIBS $ACL_LIBS"
1465                 AC_TRY_COMPILE([
1466                         #include <sys/types.h>
1467                         #if HAVE_ATTR_XATTR_H
1468                         #include <attr/xattr.h>
1469                         #elif HAVE_SYS_XATTR_H
1470                         #include <sys/xattr.h>
1471                         #endif
1472                 ],[
1473                         getxattr(0, 0, 0, 0, 0, 0);
1474                 ],
1475                 [smb_attr_cv_xattr_add_opt=yes],
1476                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1477         ])
1478         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1479                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1480         fi
1483 # Check if we have extattr
1484 case "$host_os" in
1485   *freebsd4* | *dragonfly* )
1486     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1487     ;;
1488   *)
1489     AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
1490     AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
1491     AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
1492     AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
1493     ;;
1494 esac
1496 AC_DISABLE_STATIC
1497 AC_ENABLE_SHARED
1499 # Set defaults
1500 PIE_CFLAGS=""
1501 PIE_LDFLAGS=""
1502 AC_ARG_ENABLE(pie, [AS_HELP_STRING([--enable-pie], [Turn on pie support if available (default=yes)])])
1504 if test "x$enable_pie" != xno
1505 then
1506         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1507         [
1508                 cat > conftest.c <<EOF
1509 int foo;
1510 main () { return 0;}
1512                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1513                 then
1514                         samba_cv_fpie=yes
1515                 else
1516                         samba_cv_fpie=no
1517                 fi
1518                 rm -f conftest*
1519         ])
1520         if test x"${samba_cv_fpie}" = x"yes"
1521         then
1522                 PIE_CFLAGS="-fPIE"
1523                 PIE_LDFLAGS="-pie"
1524         fi
1527 # Assume non-shared by default and override below
1528 BLDSHARED="false"
1530 # these are the defaults, good for lots of systems
1531 HOST_OS="$host_os"
1532 LDSHFLAGS="-shared"
1533 MODULE_EXPORTS=""
1534 SONAMEFLAG="#"
1535 SHLD="\${CC} \${CFLAGS}"
1536 PICFLAG="${PIE_CFLAGS}"
1537 SHLIBEXT="so"
1538 DSO_EXPORTS=""
1540 # this bit needs to be modified for each OS that supports share libs
1541 # You need to specify how to create a shared library and
1542   # how to compile C code to produce PIC object files
1544   AC_MSG_CHECKING([ability to build shared libraries])
1546   # and these are for particular systems
1547   case "$host_os" in
1548                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1549                         BLDSHARED="true"
1550                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1551                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
1552                         else
1553                                 LDSHFLAGS="-shared -Wl,-Bsymbolic"
1554                         fi
1555                         DYNEXP="-Wl,--export-dynamic"
1556                         PICFLAG="-fPIC"
1557                         SONAMEFLAG="-Wl,-soname="
1558                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1559                         ;;
1560                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1561                         BLDSHARED="true"
1562                         LDSHFLAGS="-G"
1563                         SONAMEFLAG="-h "
1564                         if test "${GCC}" = "yes"; then
1565                                 PICFLAG="-fPIC"
1566                                 SONAMEFLAG="-Wl,-soname="
1567                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1568                                         DYNEXP="-Wl,-E"
1569                                 fi
1570                         else
1571                                 PICFLAG="-KPIC"
1572                                 ## ${CFLAGS} added for building 64-bit shared
1573                                 ## libs using Sun's Compiler
1574                                 LDSHFLAGS="-G \${CFLAGS}"
1575                         fi
1576                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1577                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1578                         ;;
1579                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1580                         BLDSHARED="true"
1581                         LDSHFLAGS="-G"
1582                         SONAMEFLAG="-Wl,-h,"
1583                         PICFLAG="-KPIC"   # Is this correct for SunOS
1584                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1585                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1586                         ;;
1587                 *netbsd* | *freebsd* | *dragonfly* )
1588                         BLDSHARED="true"
1589                         LDSHFLAGS="-shared"
1590                         DYNEXP="-Wl,--export-dynamic"
1591                         SONAMEFLAG="-Wl,-soname,"
1592                         PICFLAG="-fPIC -DPIC"
1593                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1594                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1595                         ;;
1596                 *openbsd*)  BLDSHARED="true"
1597                         LDSHFLAGS="-shared"
1598                         DYNEXP="-Wl,-Bdynamic"
1599                         SONAMEFLAG="-Wl,-soname,"
1600                         PICFLAG="-fPIC"
1601                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1602                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1603                         ;;
1604                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1605                         case "$host_os" in
1606                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1607                         ;;
1608                         esac
1609                         BLDSHARED="true"
1610                         LDSHFLAGS="-set_version sgi1.0 -shared"
1611                         SONAMEFLAG="-soname "
1612                         SHLD="\${LD}"
1613                         if test "${GCC}" = "yes"; then
1614                                 PICFLAG="-fPIC"
1615                         else
1616                                 PICFLAG="-KPIC"
1617                         fi
1618                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1619                         ;;
1620                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1621                         BLDSHARED="true"
1622                         LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc"
1623                         DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
1624                         PICFLAG="-O2"
1625                         # as AIX code is always position independent...
1626                         # .po will just create compile warnings, use po.o:
1627                         if test "${GCC}" != "yes"; then
1628                                 ## for funky AIX compiler using strncpy()
1629                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1630                         fi
1632                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1633                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1634                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1635                         ;;
1636                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1637                         # Use special PIC flags for the native HP-UX compiler.
1638                                 BLDSHARED="true"
1639                                 SHLD="cc"
1640                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1641                                 SONAMEFLAG="-Wl,+h "
1642                                 PICFLAG="+z"
1643                         if test "${GCC}" = "yes"; then
1644                                 PICFLAG="-fPIC"
1645                         else
1646                                 PICFLAG="+z +ESnolit"
1647                         fi
1648                         if test "$host_cpu" = "ia64"; then
1649                                 SHLIBEXT="so"
1650                               PICFLAG="+z"
1651                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
1652                         else
1653                                 SHLIBEXT="sl"
1654                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1655                         fi
1656                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1657                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1658                         ;;
1659                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1660                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1661                         ;;
1662                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1663                         BLDSHARED="true"
1664                         LDSHFLAGS="-shared"
1665                         SONAMEFLAG="-Wl,-soname,"
1666                         PICFLAG="-fPIC"
1667                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1668                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1669                         ;;
1670                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1671                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1672                         ;;
1673                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1674                         BLDSHARED="true"
1675                         LDSHFLAGS="-shared"
1676                         SONAMEFLAG="-Wl,-soname,"
1677                         PICFLAG="-KPIC"
1678                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1679                         ;;
1680                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1681                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1682                         ;;
1683                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1684                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1685                         ;;
1686                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1687                         case "$host" in
1688                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1689                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1690                                         fi
1691                                         LDSHFLAGS="-G"
1692                                         DYNEXP="-Bexport"
1693                                 ;;
1694                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1695                         esac
1696                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1697                         ;;
1699                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1700                         if [ test "$GCC" != yes ]; then
1701                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1702                         fi
1703                         LDSHFLAGS="-G"
1704                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1705                         ;;
1706                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1707                         BLDSHARED="false"
1708                         LDSHFLAGS=""
1709                         ;;
1711                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1712                         BLDSHARED="true"
1713                         LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress"
1714                         CFLAGS="$CFLAGS -fno-common"
1715                         SHLD="\${CC}"
1716                         SHLIBEXT="dylib"
1717                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
1718                         SHLIBEXT="dylib"
1719                         # Since gcc doesn't fail on unrecognised options, the
1720                         # PIE test incorrectly succeeds. Darwin gcc does not
1721                         # actually support the PIE stuff.
1722                         PIE_LDFLAGS=
1723                         PIE_CFLAGS=
1724                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1725                         ;;
1727                 *)
1728                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1729                         ;;
1730   esac
1732 if test "$enable_shared" != "yes"; then
1733         BLDSHARED=false
1736 if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
1737         DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
1740 if test x"$BLDSHARED" = x"true" ; then
1741         LDFLAGS="$LDFLAGS -L./bin"
1744 AC_MSG_RESULT($BLDSHARED)
1746 AC_MSG_CHECKING([LDFLAGS])
1747 AC_MSG_RESULT([$LDFLAGS])
1748 AC_MSG_CHECKING([DYNEXP])
1749 AC_MSG_RESULT([$DYNEXP])
1751 #######################################################
1752 # test whether building a shared library actually works
1753 if test $BLDSHARED = true; then
1755 AC_MSG_CHECKING([SHLD])
1756 AC_MSG_RESULT([$SHLD])
1757 AC_MSG_CHECKING([LDSHFLAGS])
1758 AC_MSG_RESULT([$LDSHFLAGS])
1760 AC_MSG_CHECKING([SHLIBEXT])
1761 AC_MSG_RESULT([$SHLIBEXT])
1762 AC_MSG_CHECKING([SONAMEFLAG])
1763 AC_MSG_RESULT([$SONAMEFLAG])
1765 AC_MSG_CHECKING([PICFLAG])
1766 AC_MSG_RESULT([$PICFLAG])
1768 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
1769 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
1771 AC_CACHE_CHECK([whether building shared libraries actually works],
1772                [ac_cv_shlib_works],[
1773    # try building a trivial shared library
1774    ac_cv_shlib_works=no
1775    # The $SHLD and $LDSHFLAGS variables may contain references to other
1776    # variables so they need to be eval'ed.
1777    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o \
1778         shlib.o ${srcdir-.}/tests/shlib.c && \
1779    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1780         shlib.o && ac_cv_shlib_works=yes
1781    rm -f "shlib.$SHLIBEXT" shlib.o
1784 if test $ac_cv_shlib_works = no; then
1785    BLDSHARED=false
1789 if test x"$BLDSHARED" != x"true"; then
1790         LDSHFLAGS="shared-libraries-disabled"
1791         SONAMEFLAG="shared-libraries-disabled"
1792         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
1793         SHLD="shared-libraries-disabled"
1794         PICFLAG="${PIE_CFLAGS}"
1795         SHLIBEXT="shared_libraries_disabled"
1798 AC_MSG_CHECKING([used PICFLAG])
1799 AC_MSG_RESULT([$PICFLAG])
1801 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
1803 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
1805 ################
1807 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1808 AC_TRY_RUN([#include <stdio.h>
1809 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1810 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1811 if test x"$samba_cv_have_longlong" = x"yes"; then
1812     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1813     AC_CHECK_TYPE(intptr_t, unsigned long long)
1814 else
1815     AC_CHECK_TYPE(intptr_t, unsigned long)
1819 # Check if the compiler supports the LL prefix on long long integers.
1820 # AIX needs this.
1822 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1823     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1824         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1825 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1826    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1830 AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
1831 AC_TRY_RUN([#include <time.h>
1832 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
1833 samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
1834 if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
1835     AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
1838 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1839 AC_TRY_RUN([#include <stdio.h>
1840 #include <sys/stat.h>
1841 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1842 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1843 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1844     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1847 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_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() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1855 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1856 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1857     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1860 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_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() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1868 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1869 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1870     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1873 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1874 AC_TRY_RUN([
1875 #if defined(HAVE_UNISTD_H)
1876 #include <unistd.h>
1877 #endif
1878 #include <stdio.h>
1879 #include <sys/stat.h>
1880 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1881 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1882 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1883     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1886 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
1887 AC_TRY_RUN([
1888 #if defined(HAVE_UNISTD_H)
1889 #include <unistd.h>
1890 #endif
1891 #include <stdio.h>
1892 #include <sys/stat.h>
1893 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
1894 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
1895 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
1896     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
1899 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1900 AC_TRY_RUN([
1901 #if defined(HAVE_UNISTD_H)
1902 #include <unistd.h>
1903 #endif
1904 #include <stdio.h>
1905 #include <sys/stat.h>
1906 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1907 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1908 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1909     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1912 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
1913 AC_TRY_COMPILE([
1914 #if defined(HAVE_UNISTD_H)
1915 #include <unistd.h>
1916 #endif
1917 #include <sys/types.h>
1918 #include <dirent.h>],
1919 [DIR64 de;],
1920 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
1921 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1922     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
1925 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1926 AC_TRY_COMPILE([
1927 #if defined(HAVE_UNISTD_H)
1928 #include <unistd.h>
1929 #endif
1930 #include <sys/types.h>
1931 #include <dirent.h>],
1932 [struct dirent64 de;],
1933 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1934 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1935     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1938 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1939 AC_TRY_RUN([
1940 #if defined(HAVE_UNISTD_H)
1941 #include <unistd.h>
1942 #endif
1943 #include <sys/types.h>
1944 main() { dev_t dev; int i = major(dev); return 0; }],
1945 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1946 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1947     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1950 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1951 AC_TRY_RUN([
1952 #if defined(HAVE_UNISTD_H)
1953 #include <unistd.h>
1954 #endif
1955 #include <sys/types.h>
1956 main() { dev_t dev; int i = minor(dev); return 0; }],
1957 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1958 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1959     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1962 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1963 AC_TRY_RUN([
1964 #if defined(HAVE_UNISTD_H)
1965 #include <unistd.h>
1966 #endif
1967 #include <sys/types.h>
1968 main() { dev_t dev = makedev(1,2); return 0; }],
1969 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1970 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1971     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1974 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1975 AC_TRY_RUN([#include <stdio.h>
1976 main() { char c; c=250; exit((c > 0)?0:1); }],
1977 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1978 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1979     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1982 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1983 AC_TRY_COMPILE([#include <sys/types.h>
1984 #include <sys/socket.h>
1985 #include <netinet/in.h>],
1986 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1987 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1988 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1989     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1992 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1993 AC_TRY_COMPILE([#include <sys/types.h>
1994 #include <dirent.h>
1995 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1996 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1997 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1998     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2001 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2002 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2003 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2004 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2005     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2008 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
2009 AC_TRY_LINK([
2010 #include <sys/time.h>
2011 #include <unistd.h>], [struct timeval tv; return gettimeofday(&tv, NULL);],
2012            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,
2013            samba_cv_HAVE_GETTIMEOFDAY_TZ=no)])
2014 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
2015     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday takes a tz argument])
2018 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
2020     # On some systems (eg. Linux) librt can pull in libpthread. We
2021     # don't want this to happen because libpthreads changes signal delivery
2022     # semantics in ways we are not prepared for. This breaks Linux oplocks
2023     # which rely on signals.
2025     AC_LIBTESTFUNC(rt, clock_gettime,
2026             [
2027                             AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
2028                                 [Whether clock_gettime is available])
2029                             SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
2030                             SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
2031                             SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
2032                         ])
2036 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2037 AC_TRY_RUN([#include <sys/types.h>
2038 #include <dirent.h>
2039 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2040 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2041 di->d_name[0] == 0) exit(0); exit(1);} ],
2042 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2043 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2044     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2047 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2048 AC_TRY_COMPILE([#include <sys/types.h>
2049 #include <utime.h>],
2050 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2051 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2052 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2053     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2056 ##############
2057 # Check utmp details, but only if our OS offers utmp.h
2058 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2059 dnl  utmp and utmpx come in many flavours
2060 dnl  We need to check for many of them
2061 dnl  But we don't need to do each and every one, because our code uses
2062 dnl  mostly just the utmp (not utmpx) fields.
2064 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
2066 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2067 AC_TRY_COMPILE([#include <sys/types.h>
2068 #include <utmp.h>],
2069 [struct utmp ut;  ut.ut_name[0] = 'a';],
2070 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2071 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2072     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2075 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2076 AC_TRY_COMPILE([#include <sys/types.h>
2077 #include <utmp.h>],
2078 [struct utmp ut;  ut.ut_user[0] = 'a';],
2079 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2080 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2081     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2084 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2085 AC_TRY_COMPILE([#include <sys/types.h>
2086 #include <utmp.h>],
2087 [struct utmp ut;  ut.ut_id[0] = 'a';],
2088 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2089 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2090     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2093 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2094 AC_TRY_COMPILE([#include <sys/types.h>
2095 #include <utmp.h>],
2096 [struct utmp ut;  ut.ut_host[0] = 'a';],
2097 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2098 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2099     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2102 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2103 AC_TRY_COMPILE([#include <sys/types.h>
2104 #include <utmp.h>],
2105 [struct utmp ut;  time_t t; ut.ut_time = t;],
2106 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2107 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2108     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2111 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2112 AC_TRY_COMPILE([#include <sys/types.h>
2113 #include <utmp.h>],
2114 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2115 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2116 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2117     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2120 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2121 AC_TRY_COMPILE([#include <sys/types.h>
2122 #include <utmp.h>],
2123 [struct utmp ut;  ut.ut_type = 0;],
2124 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2125 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2126     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2129 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2130 AC_TRY_COMPILE([#include <sys/types.h>
2131 #include <utmp.h>],
2132 [struct utmp ut;  ut.ut_pid = 0;],
2133 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2134 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2135     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2138 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2139 AC_TRY_COMPILE([#include <sys/types.h>
2140 #include <utmp.h>],
2141 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2142 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2143 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2144     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2147 dnl Look for the IPv6 varient by preference. Many systems have both.
2148 AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
2149 AC_TRY_COMPILE([#include <sys/types.h>
2150 #include <utmp.h>],
2151 [struct utmp ut;  ut.ut_addr_v6[0] = 0;],
2152 samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
2153 if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
2154     AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
2157 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2158 AC_TRY_COMPILE([#include <sys/types.h>
2159 #include <utmp.h>],
2160 [struct utmp ut;  ut.ut_addr = 0;],
2161 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2162 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2163     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2166 if test x$ac_cv_func_pututline = xyes ; then
2167   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2168   AC_TRY_COMPILE([#include <sys/types.h>
2169 #include <utmp.h>],
2170   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2171   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2172   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2173       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2174   fi
2177 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2178 AC_TRY_COMPILE([#include <sys/types.h>
2179 #include <utmpx.h>],
2180 [struct utmpx ux;  ux.ut_syslen = 0;],
2181 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2182 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2183     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2187 # end utmp details
2190 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
2191 AC_ARG_WITH(libiconv,
2192 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
2194   if test "$withval" = "no" ; then
2195     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2196   else
2197      if test "$withval" != "yes" ; then
2198         ICONV_PATH_SPEC=yes
2199         ICONV_LOOK_DIRS="$withval"
2200      fi
2201   fi
2204 for i in $ICONV_LOOK_DIRS ; do
2206     save_LIBS="$LIBS"
2207     save_LDFLAGS="$LDFLAGS"
2208     save_CPPFLAGS="$CPPFLAGS"
2210     iconv_current_LIBS=""
2211     iconv_current_LDFLAGS=""
2212     iconv_current_CPPFLAGS=""
2214     ICONV_FOUND="no"
2215     unset libext
2217     #  This is here to handle -withval stuff for --with-libiconv
2218     #  Perhaps we should always add a -L
2219     CPPFLAGS="$save_CPPFLAGS -I$i/include"
2221     # Check lib and lib32 library variants to cater for IRIX ABI-specific
2222     # installation paths. This gets a little tricky since we might have iconv
2223     # in both libiconv and in libc. In this case the jm_ICONV test will always
2224     # succeed when the header is found. To counter this, make sure the
2225     # library directory is there and check the ABI directory first (which
2226     # should be harmless on other systems.
2227     # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2228     for l in "lib32" "lib" "lib/hpux32"; do
2229         if test -d "$i/$l" ; then
2230                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2231                 LIBS=
2232                 export LDFLAGS LIBS CPPFLAGS
2233                 # Try to find iconv(3)
2234                 jm_ICONV($i/$l)
2235                 if test x"$ICONV_FOUND" = "xyes" ; then
2236                     libext="$l"
2237                     break
2238                 fi
2239         fi
2240     done
2242     if test x"$ICONV_FOUND" = "xyes" ; then
2243         iconv_current_LDFLAGS="-L$i/$libext"
2244         iconv_current_CPPFLAGS="-I$i/include"
2246         if test x"$jm_cv_lib_iconv" != x; then
2247             iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
2248         else
2249             # We found iconv in libc.
2250             iconv_current_LIBS=""
2251         fi
2253     fi
2255     if test x"$ICONV_FOUND" = "xyes" ; then
2257         LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
2258         CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
2259         LIBS="$save_LIBS $iconv_current_LIBS"
2260         export LDFLAGS LIBS CPPFLAGS
2262         default_dos_charset=no
2263         default_display_charset=no
2264         default_unix_charset=no
2266         # check for default dos charset name
2267         for j in CP850 IBM850 ; do
2268             rjs_CHARSET($j)
2269             default_dos_charset="$ICONV_CHARSET"
2270             if test x"$default_dos_charset" = x"$j"; then
2271                 break
2272             fi
2273         done
2275         # check for default display charset name
2276         for j in ASCII 646 ; do
2277             rjs_CHARSET($j)
2278             default_display_charset="$ICONV_CHARSET"
2279             if test x"$default_display_charset" = x"$j"; then
2280                 break
2281             fi
2282         done
2284         # check for default unix charset name
2285         for j in UTF-8 UTF8 ; do
2286             rjs_CHARSET($j)
2287             default_unix_charset="$ICONV_CHARSET"
2288             if test x"$default_unix_charset" = x"$j"; then
2289                 break
2290             fi
2291         done
2293         if test "$default_dos_charset" != "no" -a \
2294                 "$default_dos_charset" != "cross" -a \
2295                 "$default_display_charset" != "no" -a \
2296                 "$default_display_charset" != "cross" -a \
2297                 "$default_unix_charset" != "no" -a \
2298                 "$default_unix_charset" != "cross"
2299         then
2300                 samba_cv_HAVE_NATIVE_ICONV=yes
2301         else
2302             if test "$default_dos_charset" = "cross" -o \
2303                      "$default_display_charset" = "cross" -o \
2304                      "$default_unix_charset" = "cross"
2305             then
2306                     samba_cv_HAVE_NATIVE_ICONV=cross
2307             else
2308                     samba_cv_HAVE_NATIVE_ICONV=no
2309             fi
2310         fi
2312         # At this point, we have a libiconv candidate. We know that
2313         # we have the right headers and libraries, but we don't know
2314         # whether it does the conversions we want. We can't test this
2315         # because we are cross-compiling. This is not necessarily a big
2316         # deal, since we can't guarantee that the results we get now will
2317         # match the results we get at runtime anyway.
2318         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
2319             default_dos_charset="CP850"
2320             default_display_charset="ASCII"
2321             default_unix_charset="UTF-8"
2322             samba_cv_HAVE_NATIVE_ICONV=yes
2323             AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
2324             AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
2325         fi
2327         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
2329             CPPFLAGS=$save_CPPFLAGS
2330             LDFLAGS=$save_LDFLAGS
2331             LIBS=$save_LIBS
2333             if test x"$iconv_current_LIBS" != x; then
2334                 LIBS="$LIBS $iconv_current_LIBS"
2335             fi
2337             # Add the flags we need to CPPFLAGS and LDFLAGS
2338             CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
2339             LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
2341             # Turn the #defines into string literals
2342             default_dos_charset="\"$default_dos_charset\""
2343             default_display_charset="\"$default_display_charset\""
2344             default_unix_charset="\"$default_unix_charset\""
2346             AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2347             AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2348             AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2349             AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2351            break
2352         fi
2354     # We didn't find a working iconv, so keep going
2355     fi
2357     #  We only need to clean these up here for the next pass through the loop
2358     CPPFLAGS=$save_CPPFLAGS
2359     LDFLAGS=$save_LDFLAGS
2360     LIBS=$save_LIBS
2361     export LDFLAGS LIBS CPPFLAGS
2362 done
2363 unset libext
2366 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2367     AC_MSG_WARN([Sufficient support for iconv function was not found.
2368     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2369    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2370    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2371    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2375 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2376 AC_TRY_RUN([
2377 #include <sys/types.h>
2378 #include <fcntl.h>
2379 #ifndef F_GETLEASE
2380 #define F_GETLEASE      1025
2381 #endif
2382 main() {
2383        int fd = open("/dev/null", O_RDONLY);
2384        return fcntl(fd, F_GETLEASE, 0) == -1;
2387 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2388 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2389     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2392 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2393 AC_TRY_RUN([
2394 #include <sys/types.h>
2395 #include <fcntl.h>
2396 #include <signal.h>
2397 #ifndef F_NOTIFY
2398 #define F_NOTIFY 1026
2399 #endif
2400 main() {
2401         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2404 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2405 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2406     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2409 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2410 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h)
2411 AC_CHECK_FUNCS(inotify_init)
2412 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2414 samba_cv_HAVE_INOTIFY=yes,
2415 samba_cv_HAVE_INOTIFY=no,
2416 samba_cv_HAVE_INOTIFY=cross)
2418 if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2419     AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
2422 #################################################
2423 # Check if FAM notifications are available. For FAM info, see
2424 #       http://oss.sgi.com/projects/fam/
2425 #       http://savannah.nongnu.org/projects/fam/
2426 AC_ARG_ENABLE(fam,
2427 [AS_HELP_STRING([--enable-fam], [Turn on FAM support (default=auto)])])
2429 if test x$enable_fam != xno; then
2430     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2431     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2432         # On IRIX, libfam requires libC, but other FAM implementations
2433         # might not need it.
2434         AC_CHECK_LIB(fam, FAMOpen2,
2435             [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam"],
2436             [samba_cv_HAVE_LIBFAM=no])
2438         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2439             samba_fam_xtra=-lC
2440             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2441                 [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC"],
2442                 [samba_cv_HAVE_LIBFAM=no])
2443             unset samba_fam_xtra
2444         fi
2445     fi
2447     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2448         default_shared_modules="$default_shared_modules vfs_notify_fam"
2449         AC_TRY_COMPILE([#include <fam.h>],
2450                     [FAMCodes code = FAMChanged;],
2451                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2452                         [Whether fam.h contains a typedef for enum FAMCodes]),
2453                     [])
2454     fi
2456     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2457         AC_MSG_ERROR(FAM support requested but FAM library not available )
2458     fi
2461 AC_SUBST(SMB_FAM_LIBS)
2463 #################################################
2464 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2466 SMB_CHECK_DMAPI([], AC_MSG_NOTICE(DMAPI support not present) )
2468 # Add TSM SM VFS module only if there are both GPFS and DMAPI support
2469 # Theoretically it should work with AIX JFS2 too but this needs testing
2470 if test x"$samba_cv_HAVE_GPFS" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
2471     default_shared_modules="$default_shared_modules vfs_tsmsm"
2474 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2475 AC_TRY_RUN([
2476 #include <sys/types.h>
2477 #include <fcntl.h>
2478 #include <signal.h>
2479 #include <sys/file.h>
2480 #ifndef LOCK_MAND
2481 #define LOCK_MAND       32
2482 #define LOCK_READ       64
2483 #endif
2484 main() {
2485         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2488 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2489 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2490     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2494 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2495 AC_TRY_COMPILE([#include <sys/types.h>
2496 #include <fcntl.h>],
2497 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2498 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2499 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2500     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2503 #################################################
2504 # Check for POSIX capability support
2506 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2507     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2508     [], [])
2510 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2512     ac_save_LIBS=$LIBS
2513     AC_LIBTESTFUNC(cap, cap_get_proc)
2515     AC_CACHE_CHECK([for POSIX capabilities],
2516             samba_cv_HAVE_POSIX_CAPABILITIES,
2517             [
2518                 AC_TRY_RUN([
2519 #include <sys/types.h>
2520 #include <sys/capability.h>
2521 main() {
2522  cap_t cap;
2523  cap_value_t vals[1];
2524  if (!(cap = cap_get_proc()))
2525    exit(1);
2526  vals[0] = CAP_CHOWN;
2527  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2528  cap_set_proc(cap);
2529  exit(0);
2531                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2532                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2533                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2534             ])
2536 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2537     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2538             [Whether POSIX capabilities are available])
2539 else
2540     LIBS=$ac_save_LIBS
2546 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2547 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2550 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2551 AC_TRY_COMPILE([#include <sys/types.h>
2552 #if defined(HAVE_RPC_RPC_H)
2553 #include <rpc/rpc.h>
2554 #endif],
2555 [int16 testvar;],
2556 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2557 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2558     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2561 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2562 AC_TRY_COMPILE([#include <sys/types.h>
2563 #if defined(HAVE_RPC_RPC_H)
2564 #include <rpc/rpc.h>
2565 #endif],
2566 [uint16 testvar;],
2567 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2568 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2569     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2572 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2573 AC_TRY_COMPILE([#include <sys/types.h>
2574 #if defined(HAVE_RPC_RPC_H)
2575 #include <rpc/rpc.h>
2576 #endif],
2577 [int32 testvar;],
2578 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2579 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2580     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2583 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2584 AC_TRY_COMPILE([#include <sys/types.h>
2585 #if defined(HAVE_RPC_RPC_H)
2586 #include <rpc/rpc.h>
2587 #endif],
2588 [uint32 testvar;],
2589 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2590 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2591     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2595 dnl Some systems (SCO) have a problem including
2596 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2597 dnl as a #define in <prot.h> and as part of an enum
2598 dnl in <rpc/rpc.h>.
2601 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2602 AC_TRY_COMPILE([#include <sys/types.h>
2603 #ifdef HAVE_SYS_SECURITY_H
2604 #include <sys/security.h>
2605 #include <prot.h>
2606 #endif  /* HAVE_SYS_SECURITY_H */
2607 #if defined(HAVE_RPC_RPC_H)
2608 #include <rpc/rpc.h>
2609 #endif],
2610 [int testvar;],
2611 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2612 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2613     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2616 AC_MSG_CHECKING([for test routines])
2617 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2618            AC_MSG_RESULT(yes),
2619            AC_MSG_ERROR([cant find test code. Aborting config]),
2620            AC_MSG_WARN([cannot run when cross-compiling]))
2622 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2623 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2624            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2625 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2626     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2629 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2630 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2631            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2632            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2633            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2634 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2635 then
2636     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2639 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2640 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2641            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2642 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2643     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2646 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2647 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2648 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2649 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2650 AC_CHECK_FUNCS(getpagesize)
2652 dnl test for ipv6
2653 AC_CACHE_CHECK([for ipv6 support],samba_cv_HAVE_IPV6,[
2654 AC_TRY_COMPILE([
2655 #include <stdlib.h> /* for NULL */
2656 #include <sys/socket.h>
2657 #include <sys/types.h>
2658 #include <netdb.h>],
2660 struct sockaddr_storage sa_store;
2661 struct addrinfo *ai = NULL;
2662 struct in6_addr in6addr;
2663 int s = socket(AF_INET6, SOCK_STREAM, 0);
2664 int ret = getaddrinfo(NULL, NULL, NULL, &ai);
2665 if (ret != 0) {
2666         const char *es = gai_strerror(ret);
2668 freeaddrinfo(ai);
2670 samba_cv_HAVE_IPV6=yes,samba_cv_HAVE_IPV6=no)])
2671 if test x"$samba_cv_HAVE_IPV6" = x"yes"; then
2672     AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support])
2675 ################################################
2676 # look for a method of setting the effective uid
2677 seteuid=no;
2678 if test $seteuid = no; then
2679 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2680 AC_TRY_RUN([
2681 #define AUTOCONF_TEST 1
2682 #define USE_SETRESUID 1
2683 #include "confdefs.h"
2684 #include "${srcdir-.}/lib/util_sec.c"],
2685            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2686 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2687     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2692 if test $seteuid = no; then
2693 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2694 AC_TRY_RUN([
2695 #define AUTOCONF_TEST 1
2696 #define USE_SETREUID 1
2697 #include "confdefs.h"
2698 #include "${srcdir-.}/lib/util_sec.c"],
2699            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2700 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2701     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2705 if test $seteuid = no; then
2706 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2707 AC_TRY_RUN([
2708 #define AUTOCONF_TEST 1
2709 #define USE_SETEUID 1
2710 #include "confdefs.h"
2711 #include "${srcdir-.}/lib/util_sec.c"],
2712            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2713 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2714     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2718 if test $seteuid = no; then
2719 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2720 AC_TRY_RUN([
2721 #define AUTOCONF_TEST 1
2722 #define USE_SETUIDX 1
2723 #include "confdefs.h"
2724 #include "${srcdir-.}/lib/util_sec.c"],
2725            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2726 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2727     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2731 AC_CACHE_CHECK([for the Darwin initgroups system call],
2732         samba_cv_DARWIN_INITGROUPS,
2733         AC_TRY_LINK([
2734 #include <sys/syscall.h>
2735 #include <unistd.h>
2736         ],
2737         [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
2738         samba_cv_DARWIN_INITGROUPS=yes,
2739         samba_cv_DARWIN_INITGROUPS=no)
2742 if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
2743     AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
2744         [Whether to use the Darwin-specific initgroups system call])
2747 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2748 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2749            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2750 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2751     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2754 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2755 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2756            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2757 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2758     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2760 else
2763 dnl Don't check for 64 bit fcntl locking if we know that the
2764 dnl glibc2.1 broken check has succeeded.
2767   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2768   AC_TRY_RUN([
2769 #if defined(HAVE_UNISTD_H)
2770 #include <unistd.h>
2771 #endif
2772 #include <stdio.h>
2773 #include <stdlib.h>
2775 #ifdef HAVE_FCNTL_H
2776 #include <fcntl.h>
2777 #endif
2779 #ifdef HAVE_SYS_FCNTL_H
2780 #include <sys/fcntl.h>
2781 #endif
2782 main() { struct flock64 fl64;
2783 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2784 exit(0);
2785 #else
2786 exit(1);
2787 #endif
2789        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2791   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2792       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2793   fi
2796 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2797 AC_TRY_COMPILE([#include <sys/types.h>
2798 #include <sys/stat.h>
2799 #include <unistd.h>],
2800 [struct stat st;  st.st_blocks = 0;],
2801 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2802 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2803     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2806 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2807 AC_TRY_COMPILE([#include <sys/types.h>
2808 #include <sys/stat.h>
2809 #include <unistd.h>],
2810 [struct stat st;  st.st_blksize = 0;],
2811 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2812 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2813     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2816 AC_CACHE_CHECK([for st_flags in struct stat],
2817         samba_cv_HAVE_STAT_ST_FLAGS,
2818         [
2819             AC_TRY_COMPILE([#include <sys/types.h>
2820 #include <sys/stat.h>
2821 #include <unistd.h>],
2822             [struct stat st;  st.st_flags = 0;],
2823             samba_cv_HAVE_STAT_ST_FLAGS=yes,
2824             samba_cv_HAVE_STAT_ST_FLAGS=no,
2825             samba_cv_HAVE_STAT_ST_FLAGS=cross)
2826         ])
2828 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
2829     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
2830                 [Whether the stat struct has a st_flags member])
2833 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2834 AC_TRY_COMPILE([
2835 #include <sys/types.h>
2836 #include <sys/acl.h>
2837 #if defined(HAVE_RPCSVC_NIS_H)
2838 #include <rpcsvc/nis.h>
2839 #endif],
2840 [int i;],
2841 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2842 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2843         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2846 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2847 AC_TRY_RUN([
2848 #include <stdio.h>
2849 #include <limits.h>
2850 main() {
2851         char *newpath = realpath("/tmp", NULL);
2852         exit ((newpath != NULL) ? 0 : 1);
2855 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2856 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2857     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2860 #################################################
2861 # check for AFS clear-text auth support
2862 samba_cv_WITH_AFS=no
2863 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2864 AC_ARG_WITH(afs,
2865 [AS_HELP_STRING([--with-afs], [Include AFS clear-text auth support (default=no)])],
2866 [ case "$withval" in
2867   yes|auto)
2868     AC_MSG_RESULT($withval)
2869     samba_cv_WITH_AFS=$withval
2870     ;;
2871   *)
2872     AC_MSG_RESULT(no)
2873     ;;
2874   esac ],
2875   AC_MSG_RESULT(no)
2878 ####################################################
2879 # check for Linux-specific AFS fake-kaserver support
2880 samba_cv_WITH_FAKE_KASERVER=no
2881 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2882 AC_ARG_WITH(fake-kaserver,
2883 [AS_HELP_STRING([--with-fake-kaserver], [Include AFS fake-kaserver support (default=no)])],
2884 [ case "$withval" in
2885   yes|auto)
2886     AC_MSG_RESULT($withval)
2887     samba_cv_WITH_FAKE_KASERVER=$withval
2888     ;;
2889   *)
2890     AC_MSG_RESULT(no)
2891     ;;
2892   esac ],
2893   AC_MSG_RESULT(no)
2896 #################################################
2897 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
2898 if test x"$samba_cv_WITH_AFS" != x"no" ||
2899    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
2901     # see if this box has the afs-headers in /usr/include/afs
2902     AC_MSG_CHECKING(for /usr/include/afs)
2903     if test -d /usr/include/afs; then
2904           CFLAGS="$CFLAGS -I/usr/include/afs"
2905           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
2906           AC_MSG_RESULT(yes)
2907     else
2908       AC_MSG_RESULT(no)
2909     fi
2911     # check for afs.h
2912     have_afs_headers=no
2913     AC_CHECK_HEADERS(afs.h afs/afs.h)
2914     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
2915         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
2916            test x"$samba_cv_WITH_AFS" = x"auto"; then
2917                 AC_MSG_WARN([AFS cannot be supported without afs.h])
2918         else
2919                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
2920         fi
2921     else
2922         have_afs_headers=yes
2923     fi
2926 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
2927     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
2930 #################################################
2931 # check whether to compile AFS/NT ACL mapping module
2932 samba_cv_WITH_VFS_AFSACL=no
2933 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
2934 AC_ARG_WITH(vfs-afsacl,
2935 [AS_HELP_STRING([--with-vfs-afsacl], [Include AFS to NT ACL mapping module (default=no)])],
2936 [ case "$withval" in
2937   yes|auto)
2938     AC_MSG_RESULT($withval)
2939     samba_cv_WITH_VFS_AFSACL=yes
2940     ;;
2941   *)
2942     AC_MSG_RESULT(no)
2943     ;;
2944   esac ],
2945   AC_MSG_RESULT(no)
2948 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
2949    default_shared_modules="$default_shared_modules vfs_afsacl"
2951         
2952 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
2953     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2956 #################################################
2957 # check for the DFS clear-text auth system
2958 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2959 AC_ARG_WITH(dfs,
2960 [AS_HELP_STRING([--with-dce-dfs], [Include DCE/DFS clear-text auth support (default=no)])],
2961 [ case "$withval" in
2962   yes)
2963     AC_MSG_RESULT(yes)
2964     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2965     ;;
2966   *)
2967     AC_MSG_RESULT(no)
2968     ;;
2969   esac ],
2970   AC_MSG_RESULT(no)
2973 ########################################################
2974 # Compile with LDAP support?
2976 with_ldap_support=auto
2977 AC_MSG_CHECKING([for LDAP support])
2979 AC_ARG_WITH(ldap,
2980 [AS_HELP_STRING([--with-ldap], [LDAP support (default yes)])],
2981 [ case "$withval" in
2982     yes|no)
2983         with_ldap_support=$withval
2984         ;;
2985   esac ])
2987 AC_MSG_RESULT($with_ldap_support)
2989 SMBLDAP=""
2990 AC_SUBST(SMBLDAP)
2991 SMBLDAPUTIL=""
2992 AC_SUBST(SMBLDAPUTIL)
2993 LDBLDAP=""
2994 AC_SUBST(LDBLDAP)
2996 if test x"$with_ldap_support" != x"no"; then
2998   ##################################################################
2999   # first test for ldap.h and lber.h
3000   # (ldap.h is required for this test)
3001   AC_CHECK_HEADERS(ldap.h lber.h)
3003   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3004         if test x"$with_ldap_support" = x"yes"; then
3005          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3006         else
3007          AC_MSG_WARN(ldap.h is needed for LDAP support)
3008         fi
3009         
3010         with_ldap_support=no
3011   fi
3013   ##################################################################
3014   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
3015   # unsigned int in include/includes.h
3016   case $host_os in
3017         *hpux*)
3018          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3019          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
3020         with_ldap_support=yes
3021         ;;
3022         *)
3023         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3024         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3025                 if test x"$with_ldap_support" = x"yes"; then
3026                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3027                 else
3028                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3029                 fi
3030                 with_ldap_support=no
3031         fi
3032         ;;
3033   esac
3036 if test x"$with_ldap_support" != x"no"; then
3037   ac_save_LIBS=$LIBS
3039   ##################################################################
3040   # we might need the lber lib on some systems. To avoid link errors
3041   # this test must be before the libldap test
3042   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3044   ########################################################
3045   # If ber_sockbuf_add_io() is available we can add
3046   # SASL wrapping hooks
3047   AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
3049   AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
3050                  AC_TRY_COMPILE([#include <ldap.h>],
3051                                 [int val = LDAP_OPT_SOCKBUF;],
3052                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
3053                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
3055   if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
3056           x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
3057         AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
3058   fi
3060   #######################################################
3061   # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
3062   # ldap logging and print it out in the samba logs
3063   AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
3064                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
3065                  [AC_TRY_COMPILE([#include <lber.h>],
3066                                  [int val = LBER_OPT_LOG_PRINT_FN;],
3067                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
3068                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
3070   if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
3071         AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
3072                   [Support for LDAP/LBER logging interception])
3073   fi
3075   ########################################################
3076   # now see if we can find the ldap libs in standard paths
3077   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3079   ########################################################
3080   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3081   # Check found in pam_ldap 145.
3082   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3084   LIBS="$LIBS $LDAP_LIBS"
3085   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3086     AC_TRY_COMPILE([
3087         #include <lber.h>
3088         #include <ldap.h>],
3089         [ldap_set_rebind_proc(0, 0, 0);],
3090         [smb_ldap_cv_ldap_set_rebind_proc=3],
3091         [smb_ldap_cv_ldap_set_rebind_proc=2]
3092     )
3093   ])
3095   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3097   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3099   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3100     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3101     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3102     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3103     default_shared_modules="$default_shared_modules";
3104     SMBLDAP="lib/smbldap.o"
3105     SMBLDAPUTIL="lib/smbldap_util.o"
3106     with_ldap_support=yes
3107     AC_MSG_CHECKING(whether LDAP support is used)
3108     AC_MSG_RESULT(yes)
3109   else
3110     if test x"$with_ldap_support" = x"yes"; then
3111         AC_MSG_ERROR(libldap is needed for LDAP support)
3112     else
3113         AC_MSG_WARN(libldap is needed for LDAP support)
3114     fi
3116     LDAP_LIBS=""
3117     with_ldap_support=no
3118   fi
3119   LIBS=$ac_save_LIBS
3123 #################################################
3124 # active directory support
3126 with_ads_support=auto
3127 AC_MSG_CHECKING([for Active Directory and krb5 support])
3129 AC_ARG_WITH(ads,
3130 [AS_HELP_STRING([--with-ads], [Active Directory support (default auto)])],
3131 [ case "$withval" in
3132     yes|no)
3133         with_ads_support="$withval"
3134         ;;
3135   esac ])
3137 AC_MSG_RESULT($with_ads_support)
3139 FOUND_KRB5=no
3140 KRB5_LIBS=""
3142 if test x"$with_ldap_support" != x"yes"; then
3144     if test x"$with_ads_support" = x"yes"; then
3145         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3146     elif test x"$with_ads_support" = x"auto"; then
3147         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3148         with_ads_support=no
3149     fi
3151 else
3153     # Check to see whether there is enough LDAP functionality to be able
3154     # to build AD support.
3156 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3157 case "$host_os" in
3158         *hpux*)
3159     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3161     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3162         if test x"$with_ads_support" = x"yes"; then
3163             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3164         elif test x"$with_ads_support" = x"auto"; then
3165             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3166             with_ads_support=no
3167         fi
3168     fi
3169     ;;
3170         *)
3171     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3173     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3174         if test x"$with_ads_support" = x"yes"; then
3175             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3176         elif test x"$with_ads_support" = x"auto"; then
3177             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3178             with_ads_support=no
3179         fi
3180     fi
3181     ;;
3182 esac
3185     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3187     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3188         if test x"$with_ads_support" = x"yes"; then
3189             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3190         elif test x"$with_ads_support" = x"auto"; then
3191             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3192             with_ads_support=no
3193         fi
3194     fi
3198 if test x"$with_ads_support" != x"no"; then
3200   # Do no harm to the values of CFLAGS and LIBS while testing for
3201   # Kerberos support.
3203   if test x$FOUND_KRB5 = x"no"; then
3204     #################################################
3205     # check for location of Kerberos 5 install
3206     AC_MSG_CHECKING(for kerberos 5 install path)
3207     AC_ARG_WITH(krb5,
3208     [AS_HELP_STRING([--with-krb5=base-dir], [Locate Kerberos 5 support (default=/usr)])],
3209     [ case "$withval" in
3210       no)
3211         AC_MSG_RESULT(no krb5-path given)
3212         ;;
3213       yes)
3214         AC_MSG_RESULT(/usr)
3215         FOUND_KRB5=yes
3216         ;;
3217       *)
3218         AC_MSG_RESULT($withval)
3219         KRB5_CFLAGS="-I$withval/include"
3220         KRB5_CPPFLAGS="-I$withval/include"
3221         KRB5_LDFLAGS="-L$withval/lib"
3222         FOUND_KRB5=yes
3223         if test -x "$withval/bin/krb5-config"; then
3224                 KRB5CONFIG=$withval/bin/krb5-config
3225         fi
3226         ;;
3227       esac ],
3228       AC_MSG_RESULT(no krb5-path given)
3229     )
3230   fi
3232   #################################################
3233   # check for krb5-config from recent MIT and Heimdal kerberos 5
3234   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3235   AC_MSG_CHECKING(for working krb5-config)
3236   if test -x "$KRB5CONFIG"; then
3237     ac_save_CFLAGS=$CFLAGS
3238     CFLAGS="";export CFLAGS
3239     ac_save_LDFLAGS=$LDFLAGS
3240     LDFLAGS="";export LDFLAGS
3241     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3242     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3243     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3244     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3245     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3246     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3247     FOUND_KRB5=yes
3248     AC_MSG_RESULT(yes)
3249   else
3250     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3251   fi
3253   if test x$FOUND_KRB5 = x"no"; then
3254     #################################################
3255     # see if this box has the SuSE location for the heimdal krb implementation
3256     AC_MSG_CHECKING(for /usr/include/heimdal)
3257     if test -d /usr/include/heimdal; then
3258       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3259           KRB5_CFLAGS="-I/usr/include/heimdal"
3260           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3261           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3262           FOUND_KRB5=yes
3263           AC_MSG_RESULT(yes)
3264       else
3265           KRB5_CFLAGS="-I/usr/include/heimdal"
3266           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3267           FOUND_KRB5=yes
3268           AC_MSG_RESULT(yes)
3269       fi
3270     else
3271       AC_MSG_RESULT(no)
3272     fi
3273   fi
3275   if test x$FOUND_KRB5 = x"no"; then
3276     #################################################
3277     # see if this box has the RedHat location for kerberos
3278     AC_MSG_CHECKING(for /usr/kerberos)
3279     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3280       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3281       KRB5_CFLAGS="-I/usr/kerberos/include"
3282       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3283       FOUND_KRB5=yes
3284       AC_MSG_RESULT(yes)
3285     else
3286       AC_MSG_RESULT(no)
3287     fi
3288   fi
3290   if test x$FOUND_KRB5 = x"no"; then
3291     #################################################
3292     # see if this box has the OpenBSD location for heimdal krb5
3293     AC_MSG_CHECKING(for /usr/include/kerberosV)
3294     if test -d /usr/include/kerberosV; then
3295       KRB5_CPPFLAGS="-I/usr/include/kerberosV"
3296       KRB5_LIBS="-lcrypto"
3297       FOUND_KRB5=yes
3298       AC_MSG_RESULT(yes)
3299     else
3300       AC_MSG_RESULT(no)
3301     fi
3302   fi
3304   ac_save_CFLAGS=$CFLAGS
3305   ac_save_CPPFLAGS=$CPPFLAGS
3306   ac_save_LDFLAGS=$LDFLAGS
3308   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3309   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3310   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3312   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3314   # now check for krb5.h. Some systems have the libraries without the headers!
3315   # note that this check is done here to allow for different kerberos
3316   # include paths
3317   AC_CHECK_HEADERS(krb5.h)
3319   if test x"$ac_cv_header_krb5_h" = x"no"; then
3321     # Give a warning if AD support was not explicitly requested,
3322     # i.e with_ads_support = auto, otherwise die with an error.
3324     if test x"$with_ads_support" = x"yes"; then
3325       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3326     else
3327       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3328     fi
3330     # Turn off AD support and restore CFLAGS and LIBS variables
3332     with_ads_support="no"
3334     CFLAGS=$ac_save_CFLAGS
3335     CPPFLAGS=$ac_save_CPPFLAGS
3336     LDFLAGS=$ac_save_LDFLAGS
3337   fi
3338   AC_CHECK_HEADERS(krb5/locate_plugin.h)
3339   if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
3340         WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
3341         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
3342   fi
3345 # Now we have determined whether we really want ADS support
3346 use_ads=no
3347 if test x"$with_ads_support" != x"no"; then
3348   use_ads=yes
3349   have_gssapi=no
3350   ac_save_LIBS=$LIBS
3352   # now check for gssapi headers.  This is also done here to allow for
3353   # different kerberos include paths
3354   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3356   ##################################################################
3357   # we might need the k5crypto and com_err libraries on some systems
3358   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3359   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3361   # Heimdal checks.
3362   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3363   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3364   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3366   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3367   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3369   ########################################################
3370   # now see if we can find the krb5 libs in standard paths
3371   # or as specified above
3372   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3373   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3375   ########################################################
3376   # now see if we can find the gssapi libs in standard paths
3377   if test x"$have_gssapi" != x"yes"; then
3378      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3379   fi
3381   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3382   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3383   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3384   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3385   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3386   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3387   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3388   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3389   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3390   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3391   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3392   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3393   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3394   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3395   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3396   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3397   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3398   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3399   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3400   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3401   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3402   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3403   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3404   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3405   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3406   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3407   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3408   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3409   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3410   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3411   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3412   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3413   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3414   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3415   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3416   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3417   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3418   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3419   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3420   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3421   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3423   LIBS="$KRB5_LIBS $LIBS"
3425   AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
3426         smb_krb5_ticket_has_keyinfo,
3427         [
3428             AC_TRY_COMPILE(
3429             [
3430                 #include <krb5.h>
3431             ],
3432             [
3433                 krb5_ticket ticket;
3434                 krb5_kvno kvno;
3435                 krb5_enctype enctype;
3437                 enctype = ticket.enc_part.enctype;
3438                 kvno = ticket.enc_part.kvno;
3439             ],
3440             [ smb_krb5_ticket_has_keyinfo=yes ],
3441             [ smb_krb5_ticket_has_keyinfo=no ])
3442         ])
3444   if test x"$smb_krb5_ticket_has_keyinfo" = x"yes" ; then
3445         AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
3446             [Whether the krb5_ticket structure contains the kvno and enctype])
3447   fi
3449   AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
3450           smb_krb5_creds_opt_free_context,
3451           [
3452                 AC_TRY_COMPILE([
3453                     #include <krb5.h>],
3454                     [
3455                         krb5_context ctx;
3456                         krb5_get_init_creds_opt *opt = NULL;
3457                         krb5_get_init_creds_opt_free(ctx, opt);
3458                     ],
3459                     [smb_krb5_creds_opt_free_context=yes],
3460                     [smb_krb5_creds_opt_free_context=no]
3461                 )
3462           ])
3464   if test x"$smb_krb5_creds_opt_free_context" = x"yes" ; then
3465         AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
3466             [Whether krb5_get_init_creds_opt_free takes a context argument])
3467   fi
3469   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
3470     AC_TRY_COMPILE([
3471         #include <krb5.h>],
3472         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
3473         [smb_krb5_verify_checksum=7],
3474         [smb_krb5_verify_checksum=6],
3475     )
3476   ])
3477   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_verify_checksum, [Number of arguments to krb5_verify_checksum])
3479   AC_CACHE_CHECK([for checksum in krb5_checksum],
3480                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3481     AC_TRY_COMPILE([#include <krb5.h>],
3482       [krb5_checksum cksum; cksum.checksum.length = 0;],
3483       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3484       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3486   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3487     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3488                [Whether the krb5_checksum struct has a checksum property])
3489   fi
3491   AC_CACHE_CHECK([for etype in EncryptedData],
3492                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3493     AC_TRY_COMPILE([#include <krb5.h>],
3494       [EncryptedData edata; edata.etype = 0;],
3495       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3496       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3498   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3499     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3500                [Whether the EncryptedData struct has a etype property])
3501   fi
3503   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3504                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3505     AC_TRY_COMPILE([#include <krb5.h>],
3506       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3507       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3508       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3510   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3511     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3512                [Whether the krb5_ap_req struct has a ticket pointer])
3513   fi
3515   AC_CACHE_CHECK([for e_data pointer in krb5_error],
3516                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
3517     AC_TRY_COMPILE([#include <krb5.h>],
3518       [krb5_error err; err.e_data = NULL;],
3519       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
3520       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
3522   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
3523     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
3524                [Whether the krb5_error struct has a e_data pointer])
3525   fi
3527   AC_CACHE_CHECK([for krb5_crypto type],
3528                 samba_cv_HAVE_KRB5_CRYPTO,[
3529     AC_TRY_COMPILE([#include <krb5.h>],
3530       [krb5_crypto crypto;],
3531       samba_cv_HAVE_KRB5_CRYPTO=yes,
3532       samba_cv_HAVE_KRB5_CRYPTO=no)])
3534   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3535     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3536                [Whether the type krb5_crypto exists])
3537   fi
3539   AC_CACHE_CHECK([for krb5_encrypt_block type],
3540                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3541     AC_TRY_COMPILE([#include <krb5.h>],
3542       [krb5_encrypt_block block;],
3543       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3544       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3546   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3547     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3548                [Whether the type krb5_encrypt_block exists])
3549   fi
3551   AC_CACHE_CHECK([for addrtype in krb5_address],
3552                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3553     AC_TRY_COMPILE([#include <krb5.h>],
3554       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3555       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3556       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3558   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3559     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3560                [Whether the krb5_address struct has a addrtype property])
3561   fi
3563   AC_CACHE_CHECK([for addr_type in krb5_address],
3564                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3565     AC_TRY_COMPILE([#include <krb5.h>],
3566       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3567       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3568       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3570   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3571     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3572               [Whether the krb5_address struct has a addr_type property])
3573   fi
3575   AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
3576                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3577                  [AC_TRY_COMPILE([#include <krb5.h>],
3578     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3579     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3581   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3582     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3583               [Whether the krb5_ticket struct has a enc_part2 property])
3584   fi
3586   AC_CACHE_CHECK([for keyblock in krb5_creds],
3587                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3588     AC_TRY_COMPILE([#include <krb5.h>],
3589       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3590       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3591       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
3593   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
3594     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
3595               [Whether the krb5_creds struct has a keyblock property])
3596   fi
3598   AC_CACHE_CHECK([for session in krb5_creds],
3599                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
3600     AC_TRY_COMPILE([#include <krb5.h>],
3601       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
3602       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
3603       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
3605   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
3606     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
3607               [Whether the krb5_creds struct has a session property])
3608   fi
3610   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
3611                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
3612     AC_TRY_COMPILE([#include <krb5.h>],
3613       [krb5_keyblock key; key.keyvalue.data = NULL;],
3614       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
3615       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
3617   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
3618     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
3619               [Whether the krb5_keyblock struct has a keyvalue property])
3620   fi
3622   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
3623                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
3624     AC_TRY_COMPILE([#include <krb5.h>],
3625       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
3626       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
3627       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
3628   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
3629                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
3630     AC_TRY_COMPILE([#include <krb5.h>],
3631       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
3632       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
3633       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
3634 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
3635 # w.r.t. arcfour and windows, so we must not enable it here
3636   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
3637           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
3638     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
3639               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
3640   fi
3642   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
3643                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
3644     AC_TRY_COMPILE([#include <krb5.h>],
3645       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
3646       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
3647       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
3649   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
3650     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
3651               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
3652   fi
3654   AC_CACHE_CHECK([for KV5M_KEYTAB],
3655                  samba_cv_HAVE_KV5M_KEYTAB,[
3656     AC_TRY_COMPILE([#include <krb5.h>],
3657       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
3658       samba_cv_HAVE_KV5M_KEYTAB=yes,
3659       samba_cv_HAVE_KV5M_KEYTAB=no)])
3661   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
3662       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
3663              [Whether the KV5M_KEYTAB option is available])
3664   fi
3666   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
3667                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
3668     AC_TRY_COMPILE([#include <krb5.h>],
3669       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
3670       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
3671       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
3673   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
3674     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
3675               [Whether KRB5_KU_OTHER_CKSUM is available])
3676   fi
3678   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
3679                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
3680     AC_TRY_COMPILE([#include <krb5.h>],
3681       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
3682       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
3683       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
3685   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
3686     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
3687               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
3688   fi
3690   AC_CACHE_CHECK([for the krb5_princ_component macro],
3691                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
3692     AC_TRY_LINK([#include <krb5.h>],
3693       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
3694       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
3695       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
3697   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
3698     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
3699                [Whether krb5_princ_component is available])
3700   fi
3702   AC_CACHE_CHECK([for key in krb5_keytab_entry],
3703                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
3704     AC_TRY_COMPILE([#include <krb5.h>],
3705       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
3706       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
3707       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
3709   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
3710     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
3711               [Whether krb5_keytab_entry has key member])
3712   fi
3714   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
3715                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
3716     AC_TRY_COMPILE([#include <krb5.h>],
3717       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
3718       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
3719       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
3721   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
3722     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
3723               [Whether krb5_keytab_entry has keyblock member])
3724   fi
3726   AC_CACHE_CHECK([for magic in krb5_address],
3727                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
3728     AC_TRY_COMPILE([#include <krb5.h>],
3729       [krb5_address addr; addr.magic = 0;],
3730       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
3731       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
3733   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
3734     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
3735               [Whether the krb5_address struct has a magic property])
3736   fi
3738   AC_CACHE_CHECK([for WRFILE: keytab support],
3739                 samba_cv_HAVE_WRFILE_KEYTAB,[
3740     AC_TRY_RUN([
3741 #include<krb5.h>
3742   main()
3743   {
3744     krb5_context context;
3745     krb5_keytab keytab;
3747     krb5_init_context(&context);
3748     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
3749   }],
3750   samba_cv_HAVE_WRFILE_KEYTAB=yes,
3751   samba_cv_HAVE_WRFILE_KEYTAB=no)])
3753   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
3754       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
3755                [Whether the WRFILE:-keytab is supported])
3756   fi
3758   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
3759                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3760     AC_TRY_COMPILE([#include <krb5.h>],
3761     [
3762     krb5_context context;
3763     krb5_principal principal;
3764     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3765     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3766     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3768   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3769     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3770               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3771   fi
3773   AC_CACHE_CHECK([for krb5_addresses type],
3774                 samba_cv_HAVE_KRB5_ADDRESSES,[
3775     AC_TRY_COMPILE([#include <krb5.h>],
3776       [krb5_addresses addr;],
3777       samba_cv_HAVE_KRB5_ADDRESSES=yes,
3778       samba_cv_HAVE_KRB5_ADDRESSES=no)])
3780   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
3781     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
3782                [Whether the type krb5_addresses type exists])
3783   fi
3785   AC_CACHE_CHECK([whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal],
3786                 samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE, [
3787     AC_TRY_COMPILE([#include <krb5.h>],
3788     [
3789     krb5_mk_error(0,0,0);],
3790     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=yes,
3791     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=no)])
3793   if test x"$samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE" = x"yes"; then
3794     AC_DEFINE(HAVE_SHORT_KRB5_MK_ERROR_INTERFACE,1,
3795               [whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal])
3796   fi
3798   if test x"$ac_cv_func_ext_krb5_enctype_to_string" = x"yes"; then
3799     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_context context, krb5_enctype enctype, char **str)],
3800         smb_krb5_enctype_to_string_takes_krb5_context_arg,[
3801         AC_TRY_RUN_STRICT([
3802                 #include <krb5.h>
3803                 int main(void) {
3804                         krb5_context context = NULL;
3805                         char *str = NULL;
3806                         krb5_enctype_to_string(context, 1, &str);
3807                         if (str) free (str); 
3808                         return 0;
3809                 }
3810                 ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3811                 smb_krb5_enctype_to_string_takes_krb5_context_arg=yes,
3812                 smb_krb5_enctype_to_string_takes_krb5_context_arg=no)])
3814     if test x"$smb_krb5_enctype_to_string_takes_krb5_context_arg" = x"yes"; then
3815       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG,1,
3816                 [whether krb5_enctype_to_string takes krb5_context argument])
3817     fi
3819     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_enctype enctype, char *str, size_t len)],
3820         smb_krb5_enctype_to_string_takes_size_t_arg,[
3821         AC_TRY_RUN_STRICT([
3822                 #include <krb5.h>
3823                 int main(void) {
3824                         char buf[256];
3825                         krb5_enctype_to_string(1, buf, 256);
3826                         return 0;
3827                 }
3828                 ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3829                 smb_krb5_enctype_to_string_takes_size_t_arg=yes,
3830                 smb_krb5_enctype_to_string_takes_size_t_arg=no)])
3832     if test x"$smb_krb5_enctype_to_string_takes_size_t_arg" = x"yes"; then
3833       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG,1,
3834                 [whether krb5_enctype_to_string takes size_t argument])
3835     fi
3836   fi
3838   AC_CACHE_CHECK([for krb5_principal_get_realm],
3839                 samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
3840     AC_TRY_LINK([#include <krb5.h>],
3841       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
3842       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
3843       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
3845   if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
3846     AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
3847                [Whether the function krb5_principal_get_realm is defined])
3848   fi
3850   AC_CACHE_CHECK([for krb5_princ_realm],
3851                 samba_cv_HAVE_KRB5_PRINC_REALM,[
3852     AC_TRY_LINK([#include <krb5.h>],
3853       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
3854       samba_cv_HAVE_KRB5_PRINC_REALM=yes,
3855       samba_cv_HAVE_KRB5_PRINC_REALM=no)])
3857   if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
3858     AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
3859                [Whether the macro krb5_princ_realm is defined])
3860   fi
3862   #
3863   #
3864   # Now the decisions whether we can support krb5
3865   #
3866   # NOTE: all tests should be done before this block!
3867   #
3868   #
3869   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
3870     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
3871     use_ads=no
3872   fi
3874   if test x"$ac_cv_func_ext_krb5_principal2salt" != x"yes" -a \
3875           x"$ac_cv_func_ext_krb5_get_pw_salt" != x"yes"
3876   then
3877     AC_MSG_WARN(no CREATE_KEY_FUNCTIONS detected)
3878     use_ads=no
3879   fi
3881   if test x"$ac_cv_func_ext_krb5_get_permitted_enctypes" != x"yes" -a \
3882           x"$ac_cv_func_ext_krb5_get_default_in_tkt_etypes" != x"yes"
3883   then
3884     AC_MSG_WARN(no GET_ENCTYPES_FUNCTIONS detected)
3885     use_ads=no
3886   fi
3888   if test x"$ac_cv_func_ext_krb5_kt_free_entry" != x"yes" -a \
3889           x"$ac_cv_func_ext_krb5_free_keytab_entry_contents" != x"yes"
3890   then
3891     AC_MSG_WARN(no KT_FREE_FUNCTION detected)
3892     use_ads=no
3893   fi
3895   if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes" -a \
3896           x"$ac_cv_func_ext_krb5_verify_checksum" != x"yes"
3897   then
3898     AC_MSG_WARN(no KRB5_VERIFY_CHECKSUM_FUNCTION detected)
3899     use_ads=no
3900   fi
3902   if test x"$smb_krb5_ticket_has_keyinfo" != x"yes" ; then
3904       # We only need the following functions if we can't get the enctype
3905       # and kvno out of the ticket directly (ie. on Heimdal).
3907       if test x"$ac_cv_func_ext_free_AP_REQ" != x"yes"
3908       then
3909         AC_MSG_WARN(no KRB5_AP_REQ_FREE_FUNCTION detected)
3910         use_ads=no
3911       fi
3913       if test x"$ac_cv_func_ext_krb5_decode_ap_req" != x"yes"
3914       then
3915         AC_MSG_WARN(no KRB5_AP_REQ_DECODING_FUNCTION detected)
3916         use_ads=no
3917       fi
3919   fi
3921   if test x"$use_ads" = x"yes"; then
3922     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
3923     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
3924     if test x"$have_gssapi" = x"yes"; then
3925       AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
3926     fi
3927   else
3928     if test x"$with_ads_support" = x"yes"; then
3929         AC_MSG_ERROR(krb5 libs don't have all features required for Active Directory support)
3930     else
3931         AC_MSG_WARN(krb5 libs don't have all features required for Active Directory support)
3932     fi
3933     AC_REMOVE_DEFINE(HAVE_KRB5_H)
3934     AC_REMOVE_DEFINE(HAVE_GSSAPI_H)
3935     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H)
3936     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_H)
3937     KRB5_LIBS=""
3938     with_ads_support=no
3939   fi
3940   AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
3941   AC_MSG_RESULT([$use_ads])
3943 LIBS="$ac_save_LIBS"
3946 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
3947 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
3950 ########################################################
3951 # Compile with DNS Updates support?
3953 with_dnsupdate_support=no
3954 AC_MSG_CHECKING([whether to enable DNS Updates support])
3956 AC_ARG_WITH(dnsupdate,
3957 [AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default no)])],
3958 [ case "$withval" in
3959     yes|no)
3960         with_dnsupdate_support=$withval
3961         ;;
3962   esac ])
3964 AC_MSG_RESULT($with_dnsupdate_support)
3966 if test x"$with_dnsupdate_support" != x"no"; then
3968   ################################################################
3969   # first test for Active Directory support being enabled
3970   #if test x"$with_ads_support" = x"no"; then
3971   #             AC_MSG_ERROR(Active Directory support is required to enable DNS Update support)
3972   #             with_dnsupdate_support=no
3973   #fi           
3974   ##################################################################
3975   # then test for uuid.h (necessary to generate unique DNS keynames
3976   # (uuid.h is required for this test)
3977   AC_CHECK_HEADERS(uuid/uuid.h)
3979   if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
3980         if test x"$with_dnsupdate_support" = x"yes"; then
3981          AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
3982         else
3983          AC_MSG_WARN(uuid.h is needed to enable DNS Updates support)
3984         fi
3985         with_dnsupdate_support=no
3986   fi
3989 if test x"$with_dnsupdate_support" != x"no"; then
3991   ########################################################
3992   # Now see if we can find the uuid libs in standard paths
3993   # On some systems, the uuid API is in libc, so we have to
3994   # be careful not to insert a spurious -luuid.
3996   UUID_LIBS=""
3997   AC_LIBTESTFUNC(uuid, uuid_generate,
3998           [
3999             case " $LIBS " in
4000                 *\ -luuid\ *)
4001                 UUID_LIBS="-luuid"
4002                 SMB_REMOVE_LIB(uuid)
4003                 ;;
4004             esac
4006             with_dnsupdate_support=yes
4007             AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
4008         ],
4009         [
4010             if test x"$with_dnsupdate_support" = x"yes"; then
4011                 AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
4012             else
4013                 AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
4014             fi
4015             with_dnsupdate_support=no
4016         ])
4019 #################################################
4020 # check for automount support
4021 AC_MSG_CHECKING(whether to use automount)
4022 AC_ARG_WITH(automount,
4023 [AS_HELP_STRING([--with-automount], [Include automount support (default=no)])],
4024 [ case "$withval" in
4025   yes)
4026     AC_MSG_RESULT(yes)
4027     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
4028     ;;
4029   *)
4030     AC_MSG_RESULT(no)
4031     ;;
4032   esac ],
4033   AC_MSG_RESULT(no)
4036 #################################################
4037 # check for mount- and umount.cifs support
4038 CIFSMOUNT_PROGS=""
4039 INSTALL_CIFSMOUNT=""
4040 UNINSTALL_CIFSMOUNT=""
4041 AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
4042 AC_ARG_WITH(cifsmount,
4043 [AS_HELP_STRING([--with-cifsmount], [Include mount.cifs and umount.cifs (Linux only) support (default=yes)])],
4044 [ case "$withval" in
4045   no)
4046         AC_MSG_RESULT(no)
4047         ;;
4048   *)
4049         case "$host_os" in
4050         *linux*)
4051                 AC_MSG_RESULT(yes)
4052                 AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
4053                 CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
4054                 INSTALL_CIFSMOUNT="installcifsmount"
4055                 UNINSTALL_CIFSMOUNT="uninstallcifsmount"
4056                 ;;
4057         *)
4058                 AC_MSG_ERROR(not on a linux system!)
4059                 ;;
4060         esac
4061     ;;
4062   esac ],
4063 [ case "$host_os" in
4064   *linux*)
4065         AC_MSG_RESULT(yes)
4066         AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
4067         CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
4068         INSTALL_CIFSMOUNT="installcifsmount"
4069         UNINSTALL_CIFSMOUNT="uninstallcifsmount"
4070         ;;
4071   *)
4072         AC_MSG_RESULT(no)
4073         ;;
4074   esac ]
4077 #################################################
4078 # check for cifs.spnego support
4079 AC_CHECK_HEADERS([keyutils.h], [HAVE_KEYUTILS_H=1], [HAVE_KEYUTILS_H=0])
4080 CIFSSPNEGO_PROGS=""
4081 INSTALL_CIFSSPNEGO=""
4082 UNINSTALL_CIFSSPNEGO=""
4083 AC_MSG_CHECKING(whether to build cifs.spnego)
4084 AC_ARG_WITH(cifsspnego,
4085 [AS_HELP_STRING([--with-cifsspnego], [Include cifs.spnego (Linux only) support (default=no)])],
4086 [ case "$withval" in
4087   no)
4088         AC_MSG_RESULT(no)
4089         ;;
4090   *)
4091         case "$host_os" in
4092         *linux*)
4093                 if test x"$use_ads" != x"yes"; then
4094                         AC_MSG_ERROR(ADS support should be enabled for building cifs.spnego)
4095                 elif test x"$HAVE_KEYUTILS_H" != "x1"; then
4096                         AC_MSG_ERROR(keyutils package is required for cifs.spnego)
4097                 else
4098                         AC_MSG_RESULT(yes)
4099                         AC_DEFINE(WITH_CIFSSPNEGO,1,[whether to build cifs.spnego])
4100                         CIFSSPNEGO_PROGS="bin/cifs.spnego"
4101                         INSTALL_CIFSSPNEGO="installcifsspnego"
4102                         UNINSTALL_CIFSSPNEGO="uninstallcifsspnego"
4103                 fi
4104                 ;;
4105         *)
4106                 AC_MSG_ERROR(not on a linux system!)
4107                 ;;
4108         esac
4109     ;;
4110   esac ],
4112   AC_MSG_RESULT(no)
4113   ]
4117 #################################################
4118 # Check for a PAM clear-text auth, accounts, password
4119 # and session support. Most PAM implementations keep their
4120 # headers in /usr/include/security. Darwin keeps its in
4121 # /usr/include/pam.
4123 with_pam_for_crypt=no
4124 try_pam=no
4125 AC_MSG_CHECKING(whether to try PAM support)
4126 AC_ARG_WITH(pam,
4127 [AS_HELP_STRING([--with-pam], [Include PAM support (default=no)])],
4128 [ case "$withval" in
4129   yes|no)
4130     try_pam=$withval
4131     ;;
4132   esac
4134 AC_MSG_RESULT([$try_pam])
4136 use_pam=no
4137 create_pam_modules=no
4138 if test x"${try_pam}" != x"no";then
4139         use_pam=yes
4140         create_pam_modules=yes
4142         # Most systems have PAM headers in /usr/include/security, but Darwin
4143         # has them in /usr/include/pam.
4144         AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
4145         if test x"$ac_cv_header_security_pam_appl_h" != x"yes" -a \
4146                 x"$ac_cv_header_pam_pam_appl_h" != x"yes"; then
4147                 if test x"${try_pam}" = x"yes";then
4148                         AC_MSG_ERROR([--with-pam=yes but pam_appl.h not found])
4149                 fi
4150                 use_pam=no
4151                 create_pam_modules=no
4152         fi
4154         AC_CHECK_LIB_EXT(pam, PAM_LIBS, pam_get_data)
4155         if test x"$ac_cv_lib_ext_pam_pam_get_data" != x"yes"; then
4156                 if test x"${try_pam}" = x"yes";then
4157                         AC_MSG_ERROR([--with-pam=yes but libpam not found])
4158                 fi
4159                 use_pam=no
4160                 create_pam_modules=no
4161         fi
4163         AC_CHECK_HEADERS(security/pam_modules.h pam/pam_modules.h,,,[[
4164                 #if HAVE_SECURITY_PAM_APPL_H
4165                 #include <security/pam_appl.h>
4166                 #endif
4167                 #if HAVE_PAM_PAM_APPL_H
4168                 #include <pam/pam_appl.h>
4169                 #endif
4170         ]])
4171         if test x"$ac_cv_header_security_pam_modules_h" = x"no" -a \
4172                 x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
4173                 if test x"${try_pam}" = x"yes";then
4174                         AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
4175        fi
4176                 create_pam_modules=no
4177     fi
4179         if test x"$use_pam" = x"yes"; then
4180     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
4181                 AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
4182                 AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
4183     with_pam_for_crypt=yes
4185                 if test x"$create_pam_modules" = x"yes"; then
4186                         AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
4187                         # this checks are optional,
4188                         # we don't care about the results here
4189                         AC_CHECK_HEADERS(security/pam_ext.h security/_pam_macros.h)
4190                         AC_CHECK_HEADERS(pam/pam_ext.h pam/_pam_macros.h)
4191                         AC_CHECK_FUNC_EXT(pam_vsyslog,$PAM_LIBS)
4192                 else
4193                         AC_MSG_WARN([PAM support detected but PAM MODULES support is missing])          
4194                 fi
4195         fi
4196         AC_MSG_CHECKING(whether to use PAM support)
4197         AC_MSG_RESULT([$use_pam])
4199         AC_MSG_CHECKING(whether to have PAM MODULES support)
4200         AC_MSG_RESULT([$create_pam_modules])
4201 fi # try_pam != no
4203 #################################################
4204 # check for pam_smbpass support
4205 PAM_MODULES=""
4206 INSTALL_PAM_MODULES=""
4207 UNINSTALL_PAM_MODULES=""
4208 AC_MSG_CHECKING(whether to use pam_smbpass)
4209 AC_ARG_WITH(pam_smbpass,
4210 [AS_HELP_STRING([--with-pam_smbpass], [Build PAM module for authenticating against passdb backends (default=no)])],
4211 [ case "$withval" in
4212   yes)
4213     AC_MSG_RESULT(yes)
4215        # Conditions under which pam_smbpass should not be built.
4217        if test x"$BLDSHARED" != x"true"; then
4218           AC_MSG_ERROR([No support for shared modules])
4219        elif test x"$create_pam_modules" != x"yes"; then
4220           AC_MSG_ERROR([No support for PAM MODULES])
4221        else
4222           PAM_MODULES="pam_smbpass"
4223           INSTALL_PAM_MODULES="installpammodules"
4224           UNINSTALL_PAM_MODULES="uninstallpammodules"
4225        fi
4226     ;;
4227   *)
4228     AC_MSG_RESULT(no)
4229     ;;
4230   esac ],
4231   AC_MSG_RESULT(no)
4235 ###############################################
4236 # test for where we get crypt() from
4237 AC_SEARCH_LIBS(crypt, [crypt],
4238   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
4239   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
4242 ## moved after the check for -lcrypt in order to
4243 ## ensure that the necessary libraries are included
4244 ## check checking for truncated salt.  Wrapped by the
4245 ## $with_pam_for_crypt variable as above   --jerry
4247 if test $with_pam_for_crypt = no; then
4248 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
4249 crypt_LIBS="$LIBS"
4250 LIBS="$AUTH_LIBS $LIBS"
4251 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
4252         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
4253 LIBS="$crypt_LIBS"])
4254 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
4255         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
4259 #################################################
4260 # check for a NISPLUS_HOME support
4261 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
4262 AC_ARG_WITH(nisplus-home,
4263 [AS_HELP_STRING([--with-nisplus-home], [Include NISPLUS_HOME support (default=no)])],
4264 [ case "$withval" in
4265   yes)
4266     AC_MSG_RESULT(yes)
4267     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
4268     ;;
4269   *)
4270     AC_MSG_RESULT(no)
4271     ;;
4272   esac ],
4273   AC_MSG_RESULT(no)
4276 #################################################
4277 # check for syslog logging
4278 AC_MSG_CHECKING(whether to use syslog logging)
4279 AC_ARG_WITH(syslog,
4280 [AS_HELP_STRING([--with-syslog], [Include experimental SYSLOG support (default=no)])],
4281 [ case "$withval" in
4282   yes)
4283     AC_MSG_RESULT(yes)
4284     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
4285     ;;
4286   *)
4287     AC_MSG_RESULT(no)
4288     ;;
4289   esac ],
4290   AC_MSG_RESULT(no)
4293 #################################################
4294 # check for experimental disk-quotas support
4296 samba_cv_WITH_QUOTAS=auto
4297 samba_cv_TRY_QUOTAS=no
4298 samba_cv_RUN_QUOTA_TESTS=auto
4299 samba_cv_WITH_SYS_QUOTAS=auto
4300 samba_cv_TRY_SYS_QUOTAS=auto
4301 samba_cv_SYSQUOTA_FOUND=no
4303 AC_MSG_CHECKING(whether to try disk-quotas support)
4304 AC_ARG_WITH(quotas,
4305 [AS_HELP_STRING([--with-quotas], [Include disk-quota support (default=no)])],
4306 [ case "$withval" in
4307   yes)
4308     AC_MSG_RESULT(yes)
4309     samba_cv_WITH_QUOTAS=yes
4310     samba_cv_TRY_QUOTAS=yes
4311     samba_cv_RUN_QUOTA_TESTS=yes
4312     #set sys quotas to auto in this case
4313     samba_cv_TRY_SYS_QUOTAS=auto
4314     ;;
4315   auto)
4316     AC_MSG_RESULT(auto)
4317     samba_cv_WITH_QUOTAS=auto
4318     samba_cv_TRY_QUOTAS=auto
4319     samba_cv_RUN_QUOTA_TESTS=auto
4320     #set sys quotas to auto in this case
4321     samba_cv_TRY_SYS_QUOTAS=auto
4322     ;;
4323   no)
4324     AC_MSG_RESULT(no)
4325     samba_cv_WITH_QUOTAS=no
4326     samba_cv_TRY_QUOTAS=no
4327     samba_cv_RUN_QUOTA_TESTS=no
4328     ;;
4329   *)
4330     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4331     ;;
4332   esac ],
4333   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4336 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4337 AC_ARG_WITH(sys-quotas,
4338 [AS_HELP_STRING([--with-sys-quotas], [Include lib/sysquotas.c support (default=auto)])],
4339 [ case "$withval" in
4340   yes)
4341     AC_MSG_RESULT(yes)
4342     samba_cv_WITH_SYS_QUOTAS=yes
4343     samba_cv_TRY_SYS_QUOTAS=yes
4344     samba_cv_RUN_QUOTA_TESTS=yes
4345     ;;
4346   auto)
4347     AC_MSG_RESULT(auto)
4348     samba_cv_WITH_SYS_QUOTAS=auto
4349     samba_cv_TRY_SYS_QUOTAS=auto
4350     samba_cv_RUN_QUOTA_TESTS=auto
4351     ;;
4352   no)
4353     AC_MSG_RESULT(no)
4354     samba_cv_WITH_SYS_QUOTAS=no
4355     samba_cv_TRY_SYS_QUOTAS=no
4356     ;;
4357   *)
4358     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4359     ;;
4360   esac ],
4361   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4364 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4365 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4366   case "$host_os" in
4367         *linux*)
4368             AC_MSG_RESULT(yes)
4369             samba_cv_TRY_SYS_QUOTAS=yes
4370             samba_cv_RUN_QUOTA_TESTS=yes
4371             ;;
4372         *)
4373             AC_MSG_RESULT(no)
4374             samba_cv_TRY_SYS_QUOTAS=no
4375             ;;
4376   esac
4379 #############################################
4380 # only check for quota stuff if --with-quotas
4381 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4383 case "$host_os" in
4384         # on linux we didn't need to test we have builtin support
4385         *linux*)
4386             samba_cv_SYSQUOTA_FOUND=yes
4387             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4388             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4389             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4390             AC_MSG_RESULT(yes)
4392             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4393             samba_cv_found_xfs_header=yes
4394             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4395             AC_MSG_RESULT(yes)
4396             ;;
4397         *solaris*)
4398             # need to set this define when using static linking (BUG 1473)
4399             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4400             ;;
4401         *)
4402             ;;
4403 esac
4405 # some broken header files need this
4406 AC_CHECK_HEADER(asm/types.h,[
4407             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4408             AC_ADD_INCLUDE(<asm/types.h>)
4409             ])
4411 # For quotas on Veritas VxFS filesystems
4412 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4414 # For quotas on Linux XFS filesystems
4415 AC_CHECK_HEADERS(linux/dqblk_xfs.h)
4417 # For sys/quota.h and linux/quota.h
4418 AC_CHECK_HEADERS(sys/quota.h)
4420 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4421 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4422 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4423 AC_TRY_COMPILE([
4424 #include "confdefs.h"
4425 #ifdef HAVE_SYS_TYPES_H
4426 #include <sys/types.h>
4427 #endif
4428 #ifdef HAVE_ASM_TYPES_H
4429 #include <asm/types.h>
4430 #endif
4431 #include <sys/quota.h>
4432 ],[int i = Q_XGETQUOTA;],
4433 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4434 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4435         samba_cv_found_xfs_header=yes
4439 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX
4440 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4441 AC_TRY_COMPILE([
4442 #include "confdefs.h"
4443 #ifdef HAVE_SYS_QUOTA_H
4444 #include <sys/quota.h>
4445 #endif
4447 struct dqblk D;
4448 D.dqb_fsoftlimit = 0;],
4449 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4450 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4451         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
4454 ##################
4455 # look for a working quota system
4457 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4458 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
4459 AC_TRY_RUN_STRICT([
4460 #define HAVE_QUOTACTL_4A 1
4461 #define AUTOCONF_TEST 1
4462 #include "confdefs.h"
4463 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4464            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
4465 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
4466     samba_cv_SYSQUOTA_FOUND=yes;
4467     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
4468     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
4472 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4473 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
4474 AC_TRY_RUN_STRICT([
4475 #define HAVE_QUOTACTL_4B 1
4476 #define AUTOCONF_TEST 1
4477 #include "confdefs.h"
4478 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4479            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
4480 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
4481     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
4482     samba_cv_SYSQUOTA_FOUND=yes;
4483     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
4484     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
4488 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4489 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
4490 AC_TRY_RUN_STRICT([
4491 #define HAVE_QUOTACTL_3 1
4492 #define AUTOCONF_TEST 1
4493 #include "confdefs.h"
4494 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4495            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
4496 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
4497     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
4498     samba_cv_SYSQUOTA_FOUND=yes;
4499     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
4500     samba_cv_sysquotas_file="lib/sysquotas_3.c"
4504 #################################################
4505 # check for mntent.h and struct mntent
4506 AC_CHECK_HEADERS(mntent.h)
4507 #################################################
4508 # check for setmntent,getmntent,endmntent
4509 AC_CHECK_FUNCS(setmntent getmntent endmntent)
4511 #################################################
4512 # check for devnm.h and struct mntent
4513 AC_CHECK_HEADERS(devnm.h)
4514 #################################################
4515 # check for devnm
4516 AC_CHECK_FUNCS(devnm)
4518 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
4519     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4520         # if --with-sys-quotas=yes then build it
4521         # you have can use the get/set quota command smb.conf
4522         # options then
4523         samba_cv_SYSQUOTA_FOUND=auto
4524     fi
4525     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
4526         # if --with-sys-quotas=yes then build it
4527         # you have can use the get/set quota command smb.conf
4528         # options then
4529         samba_cv_TRY_SYS_QUOTAS=auto
4530     fi
4533 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
4534 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
4535 SAVE_CPPFLAGS="$CPPFLAGS"
4536 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4537 AC_TRY_COMPILE([
4538 #include "confdefs.h"
4539 #define NO_PROTO_H 1
4540 #define NO_CONFIG_H 1
4541 #define HAVE_SYS_QUOTAS 1
4542 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
4543 #include "${srcdir-.}/lib/sysquotas.c"
4544 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
4545 CPPFLAGS="$SAVE_CPPFLAGS"
4547 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
4548 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
4549     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
4550         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4551         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
4552         samba_cv_WE_USE_SYS_QUOTAS=yes
4553         AC_MSG_RESULT(yes)
4554     else
4555         AC_MSG_RESULT(no)
4556     fi
4560 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
4561 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
4562 SAVE_CPPFLAGS="$CPPFLAGS"
4563 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4564 AC_TRY_COMPILE([
4565 #include "confdefs.h"
4566 #define NO_PROTO_H 1
4567 #define NO_CONFIG_H 1
4568 #define HAVE_SYS_QUOTAS 1
4569 #define HAVE_XFS_QUOTAS 1
4570 #include "${srcdir-.}/lib/sysquotas_xfs.c"
4571 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
4572 CPPFLAGS="$SAVE_CPPFLAGS"
4574 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
4575     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
4576         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
4577     fi
4581 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
4582 SAVE_CPPFLAGS="$CPPFLAGS"
4583 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4584 AC_TRY_COMPILE([
4585 #include "confdefs.h"
4586 #define NO_PROTO_H 1
4587 #define NO_CONFIG_H 1
4588 #include "${srcdir-.}/smbd/quotas.c"
4589 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
4590 CPPFLAGS="$SAVE_CPPFLAGS"
4592 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
4593 AC_MSG_CHECKING(whether to use the old quota support)
4594     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
4595       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
4596         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4597         AC_MSG_RESULT(yes)
4598       else
4599         AC_MSG_RESULT(no)
4600       fi
4601     else
4602       AC_MSG_RESULT(no)
4603     fi
4606 ####################
4607 # End of quota check samba_cv_RUN_QUOTA_TESTS
4610 #################################################
4611 # check for experimental utmp accounting
4613 AC_MSG_CHECKING(whether to support utmp accounting)
4614 WITH_UTMP=yes
4615 AC_ARG_WITH(utmp,
4616 [AS_HELP_STRING([--with-utmp], [Include utmp accounting (default, if supported by OS)])],
4617 [ case "$withval" in
4618   no)
4619                 WITH_UTMP=no
4620                 ;;
4621   *)
4622                 WITH_UTMP=yes
4623                 ;;
4624   esac ],
4627 # utmp requires utmp.h
4628 # Note similar check earlier, when checking utmp details.
4630 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
4631         utmp_no_reason=", no utmp.h on $host_os"
4632         WITH_UTMP=no
4635 # Display test results
4637 if test x"$WITH_UTMP" = x"yes"; then
4638         AC_MSG_RESULT(yes)
4639         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
4640 else
4641         AC_MSG_RESULT(no$utmp_no_reason)
4644 INSTALLLIBCMD_SH=:
4645 INSTALLLIBCMD_A=:
4646 UNINSTALLLIBCMD_SH=:
4647 UNINSTALLLIBCMD_A=:
4649 if test $BLDSHARED = true; then
4650         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
4651         UNINSTALLLIBCMD_SH="rm -f"
4653 if test $enable_static = yes; then
4654         INSTALLLIBCMD_A="\$(INSTALLCMD)"
4655         UNINSTALLLIBCMD_A="rm -f"
4658 #################################################
4659 # --disable-shared-libs
4660 # can be used to disable the internal use of shared libs altogether
4661 # (this only has an effect when building shared libs is enabled)
4663 USESHARED=false
4664 AC_SUBST(USESHARED)
4666 AC_MSG_CHECKING(whether to use shared libraries internally)
4667 AC_ARG_ENABLE([shared-libs],
4668         AS_HELP_STRING([--enable-shared-libs],
4669                 [Use shared libraries internally (default=yes)]),
4670         [enable_shared_libs=$enableval],
4671         [enable_shared_libs=yes])
4673 if test x"$enable_shared_libs" != x"no" ; then
4674         USESHARED=$BLDSHARED
4677 AC_MSG_RESULT([$USESHARED])
4679 if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
4680         AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
4683 #################################################
4684 # --with-static-libs=LIBS:
4685 #   link (internal) libs dynamically or statically?
4687 # If a subsystem is built as a library then this controls whether they are
4688 # linked into Samba targets statically or dynamically:
4690 # * If we build the shared library at all, we link dynamically by default.
4692 # * We only link statically if we don't build shared or if the library
4693 #   appears in the --with-static-libs configure option.
4695 # Example:
4696 #   --with-static-libs=libtalloc makes use of libtalloc.a instead
4697 #   of linking the dynamic variant with -ltalloc.
4699 # NOTE: This option only affects libraries that we do not only build
4700 # but that samba also links against as libraries (as opposed to linking
4701 # the plain object files. - This has to be configured in Makefile.in.
4702 # So in particular it does not harm to give invalid or unknown names here.
4705 AC_ARG_WITH([static-libs],
4706         [AS_HELP_STRING([--with-static-libs=LIBS],
4707                 [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
4708         [AS_IF([test $withval],
4709                 [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
4710                         [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
4711                         eval LINK_$lib=STATIC
4712                 done], [])],
4713         [])
4716 # WORKAROUND:
4717 #   until we have organized other internal subsystems (as util, registrt
4718 #   and smbconf) into shared libraries, we CAN NOT link libnetapi
4719 #   dynamically to samba programs.
4721 LINK_LIBNETAPI=STATIC
4723 SMB_LIBRARY(talloc)
4724 SMB_LIBRARY(tdb)
4725 SMB_LIBRARY(netapi)
4728 #################################################
4729 # should we build libaddns?
4730 INSTALL_LIBADDNS=
4731 UNINSTALL_LIBADDNS=
4732 LIBADDNS_SHARED=
4733 LIBADDNS=
4734 AC_MSG_CHECKING(whether to build the libaddns shared library)
4735 AC_ARG_WITH(libaddns,
4736 [AS_HELP_STRING([--with-libaddns], [Build the libaddns shared library (default=no undefined API)])],
4737 [ case "$withval" in
4738   *)
4739      AC_MSG_RESULT(no)
4740      ;;
4741   yes)
4742      if test $BLDSHARED = true; then
4743         LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
4744         LIBADDNS=libaddns
4745         AC_MSG_RESULT(yes)
4746      else
4747         enable_static=yes
4748         AC_MSG_RESULT(no shared library support -- will supply static library)
4749      fi
4750      if test $enable_static = yes; then
4751         LIBADDNS=libaddns
4752      fi
4753      INSTALL_LIBADDNS=installlibaddns
4754      UNINSTALL_LIBADDNS=uninstalllibaddns
4755      ;;
4756   esac ],
4757 [AC_MSG_RESULT(no)]
4760 #################################################
4761 # should we build libsmbclient?
4763 INSTALL_LIBSMBCLIENT=
4764 UNINSTALL_LIBSMBCLIENT=
4765 LIBSMBCLIENT_SHARED=
4766 LIBSMBCLIENT=
4767 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
4768 AC_ARG_WITH(libsmbclient,
4769 [AS_HELP_STRING([--with-libsmbclient], [Build the libsmbclient shared library (default=yes if shared libs supported)])],
4770 [ case "$withval" in
4771   no)
4772      AC_MSG_RESULT(no)
4773      ;;
4774   *)
4775      if test $BLDSHARED = true; then
4776         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4777         LIBSMBCLIENT=libsmbclient
4778         AC_MSG_RESULT(yes)
4779      else
4780         enable_static=yes
4781         AC_MSG_RESULT(no shared library support -- will supply static library)
4782      fi
4783      if test $enable_static = yes; then
4784         LIBSMBCLIENT=libsmbclient
4785      fi
4786      INSTALL_LIBSMBCLIENT=installclientlib
4787      UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4788      ;;
4789   esac ],
4791 # if unspecified, default is to build it if possible.
4792   if test $BLDSHARED = true; then
4793      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4794      LIBSMBCLIENT=libsmbclient
4795      AC_MSG_RESULT(yes)
4796    else
4797      enable_static=yes
4798      AC_MSG_RESULT(no shared library support -- will supply static library)
4799    fi
4800    if test $enable_static = yes; then
4801      LIBSMBCLIENT=libsmbclient
4802   fi]
4803   INSTALL_LIBSMBCLIENT=installclientlib
4804   UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4807 INSTALL_LIBSMBSHAREMODES=
4808 LIBSMBSHAREMODES_SHARED=
4809 LIBSMBSHAREMODES=
4810 AC_MSG_CHECKING(whether to build the libsmbsharemodes shared library)
4811 AC_ARG_WITH(libsmbsharemodes,
4812 [AS_HELP_STRING([--with-libsmbsharemodes], [Build the libsmbsharemodes shared library (default=yes if shared libs supported)])],
4813 [ case "$withval" in
4814   no)
4815      AC_MSG_RESULT(no)
4816      ;;
4817   *)
4818      if test $BLDSHARED = true; then
4819         LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4820         LIBSMBSHAREMODES=libsmbsharemodes
4821         AC_MSG_RESULT(yes)
4822      else
4823         enable_static=yes
4824         AC_MSG_RESULT(no shared library support -- will supply static library)
4825      fi
4826      if test $enable_static = yes; then
4827         LIBSMBSHAREMODES=libsmbsharemodes
4828      fi
4829      INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4830      UNINSTALL_LIBSMBSHAREMODES=uninstalllibsmbsharemodes
4831      ;;
4832   esac ],
4834 # if unspecified, default is to build it if possible.
4835   if test $BLDSHARED = true; then
4836      LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4837      LIBSMBSHAREMODES=libsmbsharemodes
4838      AC_MSG_RESULT(yes)
4839    else
4840      enable_static=yes
4841      AC_MSG_RESULT(no shared library support -- will supply static library)
4842    fi
4843    if test $enable_static = yes; then
4844      LIBSMBSHAREMODES=libsmbsharemodes
4845   fi]
4846   INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4850 #################################################
4851 # these tests are taken from the GNU fileutils package
4852 AC_CHECKING(how to get filesystem space usage)
4853 space=no
4855 # Test for statvfs64.
4856 if test $space = no; then
4857   # SVR4
4858   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
4859   [AC_TRY_RUN([
4860 #if defined(HAVE_UNISTD_H)
4861 #include <unistd.h>
4862 #endif
4863 #include <sys/types.h>
4864 #include <sys/statvfs.h>
4865   main ()
4866   {
4867     struct statvfs64 fsd;
4868     exit (statvfs64 (".", &fsd));
4869   }],
4870   fu_cv_sys_stat_statvfs64=yes,
4871   fu_cv_sys_stat_statvfs64=no,
4872   fu_cv_sys_stat_statvfs64=cross)])
4873   if test $fu_cv_sys_stat_statvfs64 = yes; then
4874     space=yes
4875     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
4876   fi
4879 # Perform only the link test since it seems there are no variants of the
4880 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
4881 # because that got a false positive on SCO OSR5.  Adding the declaration
4882 # of a `struct statvfs' causes this test to fail (as it should) on such
4883 # systems.  That system is reported to work fine with STAT_STATFS4 which
4884 # is what it gets when this test fails.
4885 if test $space = no; then
4886   # SVR4
4887   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
4888                  [AC_TRY_LINK([#include <sys/types.h>
4889 #include <sys/statvfs.h>],
4890                               [struct statvfs fsd; statvfs (0, &fsd);],
4891                               fu_cv_sys_stat_statvfs=yes,
4892                               fu_cv_sys_stat_statvfs=no)])
4893   if test $fu_cv_sys_stat_statvfs = yes; then
4894     space=yes
4895     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
4896   fi
4899 # smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
4900 # This is not the case on ancient Linux systems.
4902 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
4903     AC_TRY_COMPILE([#include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
4904         samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
4905 if test x"$samba_cv_fsid_int" = x"yes"; then
4906     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
4909 if test $space = no; then
4910   # DEC Alpha running OSF/1
4911   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
4912   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
4913   [AC_TRY_RUN([
4914 #include <sys/param.h>
4915 #include <sys/types.h>
4916 #include <sys/mount.h>
4917   main ()
4918   {
4919     struct statfs fsd;
4920     fsd.f_fsize = 0;
4921     exit (statfs (".", &fsd, sizeof (struct statfs)));
4922   }],
4923   fu_cv_sys_stat_statfs3_osf1=yes,
4924   fu_cv_sys_stat_statfs3_osf1=no,
4925   fu_cv_sys_stat_statfs3_osf1=no)])
4926   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
4927   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
4928     space=yes
4929     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
4930   fi
4933 if test $space = no; then
4934 # AIX
4935   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
4936 member (AIX, 4.3BSD)])
4937   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
4938   [AC_TRY_RUN([
4939 #ifdef HAVE_SYS_PARAM_H
4940 #include <sys/param.h>
4941 #endif
4942 #ifdef HAVE_SYS_MOUNT_H
4943 #include <sys/mount.h>
4944 #endif
4945 #ifdef HAVE_SYS_VFS_H
4946 #include <sys/vfs.h>
4947 #endif
4948   main ()
4949   {
4950   struct statfs fsd;
4951   fsd.f_bsize = 0;
4952   exit (statfs (".", &fsd));
4953   }],
4954   fu_cv_sys_stat_statfs2_bsize=yes,
4955   fu_cv_sys_stat_statfs2_bsize=no,
4956   fu_cv_sys_stat_statfs2_bsize=no)])
4957   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
4958   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
4959     space=yes
4960     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
4961   fi
4964 if test $space = no; then
4965 # SVR3
4966   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
4967   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
4968   [AC_TRY_RUN([#include <sys/types.h>
4969 #include <sys/statfs.h>
4970   main ()
4971   {
4972   struct statfs fsd;
4973   exit (statfs (".", &fsd, sizeof fsd, 0));
4974   }],
4975     fu_cv_sys_stat_statfs4=yes,
4976     fu_cv_sys_stat_statfs4=no,
4977     fu_cv_sys_stat_statfs4=no)])
4978   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
4979   if test $fu_cv_sys_stat_statfs4 = yes; then
4980     space=yes
4981     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
4982   fi
4985 if test $space = no; then
4986 # 4.4BSD and NetBSD
4987   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
4988 member (4.4BSD and NetBSD)])
4989   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
4990   [AC_TRY_RUN([#include <sys/types.h>
4991 #ifdef HAVE_SYS_PARAM_H
4992 #include <sys/param.h>
4993 #endif
4994 #ifdef HAVE_SYS_MOUNT_H
4995 #include <sys/mount.h>
4996 #endif
4997   main ()
4998   {
4999   struct statfs fsd;
5000   fsd.f_fsize = 0;
5001   exit (statfs (".", &fsd));
5002   }],
5003   fu_cv_sys_stat_statfs2_fsize=yes,
5004   fu_cv_sys_stat_statfs2_fsize=no,
5005   fu_cv_sys_stat_statfs2_fsize=no)])
5006   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
5007   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
5008     space=yes
5009         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
5010   fi
5013 if test $space = no; then
5014   # Ultrix
5015   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
5016   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
5017   [AC_TRY_RUN([#include <sys/types.h>
5018 #ifdef HAVE_SYS_PARAM_H
5019 #include <sys/param.h>
5020 #endif
5021 #ifdef HAVE_SYS_MOUNT_H
5022 #include <sys/mount.h>
5023 #endif
5024 #ifdef HAVE_SYS_FS_TYPES_H
5025 #include <sys/fs_types.h>
5026 #endif
5027   main ()
5028   {
5029   struct fs_data fsd;
5030   /* Ultrix's statfs returns 1 for success,
5031      0 for not mounted, -1 for failure.  */
5032   exit (statfs (".", &fsd) != 1);
5033   }],
5034   fu_cv_sys_stat_fs_data=yes,
5035   fu_cv_sys_stat_fs_data=no,
5036   fu_cv_sys_stat_fs_data=no)])
5037   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
5038   if test $fu_cv_sys_stat_fs_data = yes; then
5039     space=yes
5040     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
5041   fi
5045 # As a gating factor for large file support, in order to
5046 # use <4GB files we must have the following minimal support
5047 # available.
5048 # long long, and a 64 bit off_t or off64_t.
5049 # If we don't have all of these then disable large
5050 # file support.
5052 AC_MSG_CHECKING([if large file support can be enabled])
5053 AC_TRY_COMPILE([
5054 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
5055 #include <sys/types.h>
5056 #else
5057 __COMPILE_ERROR_
5058 #endif
5060 [int i],
5061 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
5062 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
5063         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
5065 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
5067 #################################################
5068 # check for cluster extensions
5070 AC_MSG_CHECKING(whether to include cluster support)
5071 AC_ARG_WITH(cluster-support,
5072 [AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=no)])])
5073 if test "x$with_cluster_support" = "xyes"; then
5074     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
5075     AC_MSG_RESULT(yes)
5076 else
5077     AC_MSG_RESULT(no)
5081 #################################################
5082 # check for ACL support
5084 AC_MSG_CHECKING(whether to support ACLs)
5085 AC_ARG_WITH(acl-support,
5086 [AS_HELP_STRING([--with-acl-support], [Include ACL support (default=auto)])],
5087 [ case "$withval" in
5088         yes|no)
5089                 with_acl_support="$withval"
5090                 ;;
5091   esac ])
5093 if test x"$with_acl_support" = x ; then
5094         with_acl_support="auto"
5097 AC_MSG_RESULT($with_acl_support)
5099 if test x"$with_acl_support" = x"no"; then
5100         AC_MSG_RESULT(Disabling ACL support)
5101         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
5102 else
5103         AC_MSG_NOTICE(checking whether ACL support is available:)
5104         case "$host_os" in
5105         *sysv5*)
5106                 AC_MSG_NOTICE(Using UnixWare ACLs)
5107                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
5108                 default_static_modules="$default_static_modules vfs_solarisacl"
5109                 ;;
5110         *solaris*)
5111                 AC_MSG_NOTICE(Using solaris ACLs)
5112                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
5113                 ACL_LIBS="$ACL_LIBS -lsec"
5114                 default_static_modules="$default_static_modules vfs_solarisacl"
5115                 ;;
5116         *hpux*)
5117                 AC_MSG_NOTICE(Using HPUX ACLs)
5118                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
5119                 default_static_modules="$default_static_modules vfs_hpuxacl"
5120                 ;;
5121         *irix*)
5122                 AC_MSG_NOTICE(Using IRIX ACLs)
5123                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
5124                 default_static_modules="$default_static_modules vfs_irixacl"
5125                 ;;
5126         *aix*)
5127                 AC_MSG_NOTICE(Using AIX ACLs)
5128                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
5129                 default_static_modules="$default_static_modules vfs_aixacl"
5130                 ;;
5131         *osf*)
5132                 AC_MSG_NOTICE(Using Tru64 ACLs)
5133                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
5134                 ACL_LIBS="$ACL_LIBS -lpacl"
5135                 default_static_modules="$default_static_modules vfs_tru64acl"
5136                 ;;
5137         *darwin*)
5138                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
5139                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5140                 ;;
5141         *)
5142                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
5143                 case "$host_os" in
5144                 *linux*)
5145                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
5146                         ;;
5147                 esac
5148                 AC_CACHE_CHECK([for POSIX ACL support],samba_cv_HAVE_POSIX_ACLS,[
5149                         acl_LIBS=$LIBS
5150                         LIBS="$LIBS $ACL_LIBS"
5151                         AC_TRY_LINK([
5152                                 #include <sys/types.h>
5153                                 #include <sys/acl.h>
5154                         ],[
5155                                 acl_t acl;
5156                                 int entry_id;
5157                                 acl_entry_t *entry_p;
5158                                 return acl_get_entry(acl, entry_id, entry_p);
5159                         ],
5160                         [samba_cv_HAVE_POSIX_ACLS=yes],
5161                         [samba_cv_HAVE_POSIX_ACLS=no])
5162                         LIBS=$acl_LIBS
5163                 ])
5164                 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
5165                         AC_MSG_NOTICE(Using posix ACLs)
5166                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
5167                         AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
5168                                 acl_LIBS=$LIBS
5169                                 LIBS="$LIBS $ACL_LIBS"
5170                                 AC_TRY_LINK([
5171                                         #include <sys/types.h>
5172                                         #include <sys/acl.h>
5173                                 ],[
5174                                         acl_permset_t permset_d;
5175                                         acl_perm_t perm;
5176                                         return acl_get_perm_np(permset_d, perm);
5177                                 ],
5178                                 [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
5179                                 [samba_cv_HAVE_ACL_GET_PERM_NP=no])
5180                                 LIBS=$acl_LIBS
5181                         ])
5182                         if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
5183                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
5184                         fi
5185                         default_static_modules="$default_static_modules vfs_posixacl"
5186                 else
5187                         AC_MSG_NOTICE(ACL support is not avaliable)
5188                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5189                 fi
5190                 ;;
5191         esac
5192 fi # with_acl_support
5196 #################################################
5197 # check for AIO support
5199 AC_MSG_CHECKING(whether to support asynchronous io)
5200 AC_ARG_WITH(aio-support,
5201 [AS_HELP_STRING([--with-aio-support], [Include asynchronous io support (default=no)])],
5202 [ case "$withval" in
5203   yes)
5205         AC_MSG_RESULT(yes)
5206         case "$host_os" in
5207         *)
5208                 AIO_LIBS=$LIBS
5209                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
5210                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
5211                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
5212                 aio_LIBS=$LIBS
5213                 LIBS=$AIO_LIBS
5214                 AC_TRY_LINK([#include <sys/types.h>
5215 #include <aio.h>],
5216 [ struct aiocb a; return aio_read(&a);],
5217 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
5218                 LIBS=$aio_LIBS])
5219                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
5220                 aio_LIBS=$LIBS
5221                 LIBS=$AIO_LIBS
5222                 AC_TRY_LINK([#include <sys/types.h>
5223 #include <aio.h>],
5224 [ struct aiocb64 a; return aio_read64(&a);],
5225 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
5226                 LIBS=$aio_LIBS])
5227                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5228                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
5229                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5230                         LIBS=$AIO_LIBS
5231                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
5232                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5233                         LIBS=$AIO_LIBS
5234                 fi
5236                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5237                         AC_MSG_CHECKING(for aio_read)
5238                         AC_LINK_IFELSE([#include <aio.h>
5239 int main() { struct aiocb a; return aio_read(&a); }],
5240 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
5241 [AC_MSG_RESULT(no)])
5243                         AC_MSG_CHECKING(for aio_write)
5244                         AC_LINK_IFELSE([#include <aio.h>
5245 int main() { struct aiocb a; return aio_write(&a); }],
5246 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
5247 [AC_MSG_RESULT(no)])
5249                         AC_MSG_CHECKING(for aio_fsync)
5250                         AC_LINK_IFELSE([#include <aio.h>
5251 int main() { struct aiocb a; return aio_fsync(1, &a); }],
5252 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
5253 [AC_MSG_RESULT(no)])
5255                         AC_MSG_CHECKING(for aio_return)
5256                         AC_LINK_IFELSE([#include <aio.h>
5257 int main() { struct aiocb a; return aio_return(&a); }],
5258 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
5259 [AC_MSG_RESULT(no)])
5261                         AC_MSG_CHECKING(for aio_error)
5262                         AC_LINK_IFELSE([#include <aio.h>
5263 int main() { struct aiocb a; return aio_error(&a); }],
5264 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
5265 [AC_MSG_RESULT(no)])
5267                         AC_MSG_CHECKING(for aio_cancel)
5268                         AC_LINK_IFELSE([#include <aio.h>
5269 int main() { struct aiocb a; return aio_cancel(1, &a); }],
5270 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
5271 [AC_MSG_RESULT(no)])
5273                         AC_MSG_CHECKING(for aio_suspend)
5274                         AC_LINK_IFELSE([#include <aio.h>
5275 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
5276 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
5277 [AC_MSG_RESULT(no)])
5278                 fi
5280                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5281                         AC_MSG_CHECKING(for aio_read64)
5282                         AC_LINK_IFELSE([#include <aio.h>
5283 int main() { struct aiocb a; return aio_read64(&a); }],
5284 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
5285 [AC_MSG_RESULT(no)])
5287                         AC_MSG_CHECKING(for aio_write64)
5288                         AC_LINK_IFELSE([#include <aio.h>
5289 int main() { struct aiocb a; return aio_write64(&a); }],
5290 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
5291 [AC_MSG_RESULT(no)])
5293                         AC_MSG_CHECKING(for aio_fsync64)
5294                         AC_LINK_IFELSE([#include <aio.h>
5295 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
5296 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
5297 [AC_MSG_RESULT(no)])
5299                         AC_MSG_CHECKING(for aio_return64)
5300                         AC_LINK_IFELSE([#include <aio.h>
5301 int main() { struct aiocb a; return aio_return64(&a); }],
5302 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
5303 [AC_MSG_RESULT(no)])
5305                         AC_MSG_CHECKING(for aio_error64)
5306                         AC_LINK_IFELSE([#include <aio.h>
5307 int main() { struct aiocb a; return aio_error64(&a); }],
5308 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
5309 [AC_MSG_RESULT(no)])
5311                         AC_MSG_CHECKING(for aio_cancel64)
5312                         AC_LINK_IFELSE([#include <aio.h>
5313 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
5314 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
5315 [AC_MSG_RESULT(no)])
5317                         AC_MSG_CHECKING(for aio_suspend64)
5318                         AC_LINK_IFELSE([#include <aio.h>
5319 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
5320 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
5321 [AC_MSG_RESULT(no)])
5322                 fi
5323             ;;
5324         esac
5325         ;;
5326   *)
5327     AC_MSG_RESULT(no)
5328     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
5329     ;;
5330   esac ],
5331   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
5332   AC_MSG_RESULT(no)
5335 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5336         if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \
5337                 x"$samba_cv_msghdr_msg_acctright" = x"yes"; then
5338                 default_shared_modules="$default_shared_modules vfs_aio_fork"
5339         fi
5342 #################################################
5343 # check for sendfile support
5345 with_sendfile_support=yes
5346 AC_MSG_CHECKING(whether to check to support sendfile)
5347 AC_ARG_WITH(sendfile-support,
5348 [AS_HELP_STRING([--with-sendfile-support], [Check for sendfile support (default=yes)])],
5349 [ case "$withval" in
5350   yes)
5352         AC_MSG_RESULT(yes);
5354         case "$host_os" in
5355         *linux*)
5356                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5357                 AC_TRY_LINK([#include <sys/sendfile.h>],
5359 int tofd, fromfd;
5360 off64_t offset;
5361 size_t total;
5362 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
5364 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5366                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
5367                 AC_TRY_LINK([#include <sys/sendfile.h>],
5369 int tofd, fromfd;
5370 off_t offset;
5371 size_t total;
5372 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5374 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5376 # Try and cope with broken Linux sendfile....
5377                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
5378                 AC_TRY_LINK([\
5379 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5380 #undef _FILE_OFFSET_BITS
5381 #endif
5382 #include <sys/sendfile.h>],
5384 int tofd, fromfd;
5385 off_t offset;
5386 size_t total;
5387 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5389 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5391         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5392                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5393                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5394                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5395         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5396                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5397                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5398                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5399         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5400                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5401                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5402         else
5403                 AC_MSG_RESULT(no);
5404         fi
5406         ;;
5407         *freebsd* | *dragonfly* )
5408                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5409                 AC_TRY_LINK([\
5410 #include <sys/types.h>
5411 #include <unistd.h>
5412 #include <sys/socket.h>
5413 #include <sys/uio.h>],
5415         int fromfd, tofd, ret, total=0;
5416         off_t offset, nwritten;
5417         struct sf_hdtr hdr;
5418         struct iovec hdtrl;
5419         hdr.headers = &hdtrl;
5420         hdr.hdr_cnt = 1;
5421         hdr.trailers = NULL;
5422         hdr.trl_cnt = 0;
5423         hdtrl.iov_base = NULL;
5424         hdtrl.iov_len = 0;
5425         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
5427 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5429         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5430                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
5431                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
5432                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5433         else
5434                 AC_MSG_RESULT(no);
5435         fi
5436         ;;
5438         *hpux*)
5439                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5440                 AC_TRY_LINK([\
5441 #include <sys/socket.h>
5442 #include <sys/uio.h>],
5444         int fromfd, tofd;
5445         size_t total=0;
5446         struct iovec hdtrl[2];
5447         ssize_t nwritten;
5448         off64_t offset;
5450         hdtrl[0].iov_base = 0;
5451         hdtrl[0].iov_len = 0;
5453         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
5455 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5456         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5457                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
5458                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5459                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5460         else
5461                 AC_MSG_RESULT(no);
5462         fi
5464                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
5465                 AC_TRY_LINK([\
5466 #include <sys/socket.h>
5467 #include <sys/uio.h>],
5469         int fromfd, tofd;
5470         size_t total=0;
5471         struct iovec hdtrl[2];
5472         ssize_t nwritten;
5473         off_t offset;
5475         hdtrl[0].iov_base = 0;
5476         hdtrl[0].iov_len = 0;
5478         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
5480 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5481         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5482                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5483                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5484                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5485         else
5486                 AC_MSG_RESULT(no);
5487         fi
5488         ;;
5490         *solaris*)
5491                 AC_CHECK_LIB(sendfile,sendfilev)
5492                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
5493                 AC_TRY_LINK([\
5494 #include <sys/sendfile.h>],
5496         int sfvcnt;
5497         size_t xferred;
5498         struct sendfilevec vec[2];
5499         ssize_t nwritten;
5500         int tofd;
5502         sfvcnt = 2;
5504         vec[0].sfv_fd = SFV_FD_SELF;
5505         vec[0].sfv_flag = 0;
5506         vec[0].sfv_off = 0;
5507         vec[0].sfv_len = 0;
5509         vec[1].sfv_fd = 0;
5510         vec[1].sfv_flag = 0;
5511         vec[1].sfv_off = 0;
5512         vec[1].sfv_len = 0;
5513         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
5515 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
5517         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
5518                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
5519                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
5520                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5521         else
5522                 AC_MSG_RESULT(no);
5523         fi
5525                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
5526                 AC_TRY_LINK([\
5527 #include <sys/sendfile.h>],
5529         int sfvcnt;
5530         size_t xferred;
5531         struct sendfilevec vec[2];
5532         ssize_t nwritten;
5533         int tofd;
5535         sfvcnt = 2;
5537         vec[0].sfv_fd = SFV_FD_SELF;
5538         vec[0].sfv_flag = 0;
5539         vec[0].sfv_off = 0;
5540         vec[0].sfv_len = 0;
5542         vec[1].sfv_fd = 0;
5543         vec[1].sfv_flag = 0;
5544         vec[1].sfv_off = 0;
5545         vec[1].sfv_len = 0;
5546         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
5548 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
5550         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
5551                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
5552                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
5553                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5554         else
5555                 AC_MSG_RESULT(no);
5556         fi
5557         ;;
5558         *aix*)
5559                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
5560                 AC_TRY_LINK([\
5561 #include <sys/socket.h>],
5563         int fromfd, tofd;
5564         size_t total=0;
5565         struct sf_parms hdtrl;
5566         ssize_t nwritten;
5567         off64_t offset;
5569         hdtrl.header_data = 0;
5570         hdtrl.header_length = 0;
5571         hdtrl.file_descriptor = fromfd;
5572         hdtrl.file_offset = 0;
5573         hdtrl.file_bytes = 0;
5574         hdtrl.trailer_data = 0;
5575         hdtrl.trailer_length = 0;
5577         nwritten = send_file(&tofd, &hdtrl, 0);
5579 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5580         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5581                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5582                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
5583                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5584         else
5585                 AC_MSG_RESULT(no);
5586         fi
5587         ;;
5588         *)
5589         ;;
5590         esac
5591         ;;
5592   *)
5593     AC_MSG_RESULT(no)
5594     ;;
5595   esac ],
5596   AC_MSG_RESULT(yes)
5599 ############################################
5600 # See if we have the Linux readahead syscall.
5602 AC_CACHE_CHECK([for Linux readahead],
5603                 samba_cv_HAVE_LINUX_READAHEAD,[
5604     AC_TRY_LINK([
5605 #if defined(HAVE_UNISTD_H)
5606 #include <unistd.h>
5607 #endif
5608 #include <fcntl.h>],
5609     [ssize_t err = readahead(0,0,0x80000);],
5610     samba_cv_HAVE_LINUX_READAHEAD=yes,
5611     samba_cv_HAVE_LINUX_READAHEAD=no)])
5613 if test x"$samba_cv_HAVE_LINUX_READAHEAD" = x"yes"; then
5614   AC_DEFINE(HAVE_LINUX_READAHEAD,1,
5615              [Whether Linux readahead is available])
5618 AC_HAVE_DECL(readahead, [#include <fcntl.h>])
5620 ############################################
5621 # See if we have the posix_fadvise syscall.
5623 AC_CACHE_CHECK([for posix_fadvise],
5624                 samba_cv_HAVE_POSIX_FADVISE,[
5625     AC_TRY_LINK([
5626 #if defined(HAVE_UNISTD_H)
5627 #include <unistd.h>
5628 #endif
5629 #include <fcntl.h>],
5630     [ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);],
5631     samba_cv_HAVE_POSIX_FADVISE=yes,
5632     samba_cv_HAVE_POSIX_FADVISE=no)])
5634 if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
5635   AC_DEFINE(HAVE_POSIX_FADVISE,1,
5636              [Whether posix_fadvise is available])
5641 #################################################
5642 # Check whether winbind is supported on this platform.  If so we need to
5643 # build and install client programs, sbin programs and shared libraries
5645 AC_MSG_CHECKING(whether to build winbind)
5647 # Initially, the value of $host_os decides whether winbind is supported
5649 HAVE_WINBIND=yes
5651 # Define the winbind shared library name and any specific linker flags
5652 # it needs to be built with.
5654 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
5655 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
5656 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
5657 NSSSONAMEVERSIONSUFFIX=""
5658 WINBIND_NSS_PTHREAD=""
5660 case "$host_os" in
5661         *linux*)
5662                 NSSSONAMEVERSIONSUFFIX=".2"
5663                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
5664                 ;;
5665         *freebsd[[5-9]]*)
5666                 # FreeBSD winbind client is implemented as a wrapper around
5667                 # the Linux version.
5668                 NSSSONAMEVERSIONSUFFIX=".1"
5669                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
5670                     nsswitch/winbind_nss_linux.o"
5671                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
5672                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
5673                 ;;
5675         *netbsd*[[3-9]]*)
5676                 # NetBSD winbind client is implemented as a wrapper
5677                 # around the Linux version. It needs getpwent_r() to
5678                 # indicate libc's use of the correct nsdispatch API.
5679                 #
5680                 if test x"$ac_cv_func_getpwent_r" = x"yes"; then
5681                         WINBIND_NSS_EXTRA_OBJS="\
5682                             nsswitch/winbind_nss_netbsd.o \
5683                             nsswitch/winbind_nss_linux.o"
5684                         WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
5685                         WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
5686                 else
5687                         HAVE_WINBIND=no
5688                         winbind_no_reason=", getpwent_r is missing on $host_os so winbind is unsupported"
5689                 fi
5690                 ;;
5691         *irix*)
5692                 # IRIX has differently named shared libraries
5693                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
5694                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
5695                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
5696                 ;;
5697         *solaris*)
5698                 # Solaris winbind client is implemented as a wrapper around
5699                 # the Linux version.
5700                 NSSSONAMEVERSIONSUFFIX=".1"
5701                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
5702                     nsswitch/winbind_nss_linux.o"
5703                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
5704                 ;;
5705         *hpux11*)
5706                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
5707                 ;;
5708         *aix*)
5709                 # AIX has even differently named shared libraries.  No
5710                 # WINS support has been implemented yet.
5711                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
5712                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
5713                 WINBIND_NSS="nsswitch/WINBIND"
5714                 WINBIND_WINS_NSS=""
5715                 ;;
5716         *)
5717                 HAVE_WINBIND=no
5718                 winbind_no_reason=", unsupported on $host_os"
5719                 ;;
5720 esac
5722 # Check the setting of --with-winbind
5724 AC_ARG_WITH(winbind,
5725 [AS_HELP_STRING([--with-winbind], [Build winbind (default, if supported by OS)])],
5727   case "$withval" in
5728         yes)
5729                 HAVE_WINBIND=yes
5730                 ;;
5731         no)
5732                 HAVE_WINBIND=no
5733                 winbind_reason=""
5734                 ;;
5735   esac ],
5738 # We need unix domain sockets for winbind
5740 if test x"$HAVE_WINBIND" = x"yes"; then
5741         if test x"$samba_cv_unixsocket" = x"no"; then
5742                 winbind_no_reason=", no unix domain socket support on $host_os"
5743                 HAVE_WINBIND=no
5744         fi
5747 # Display test results
5749 if test x"$HAVE_WINBIND" = x"no"; then
5750         WINBIND_NSS=""
5751         WINBIND_WINS_NSS=""
5754 if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
5755         BUILD_LIBWBCLIENT_SHARED=no
5756 else
5757         BUILD_LIBWBCLIENT_SHARED=yes
5760 if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
5761         NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
5762         ## Only worry about libwbclient if we have shared library support
5763         ## and winbindd
5764         LIBWBCLIENT_SHARED=bin/libwbclient.$SHLIBEXT
5765         LIBWBCLIENT=libwbclient
5766         INSTALL_LIBWBCLIENT=installlibwbclient
5767         UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
5768         WINBIND_LIBS="-lwbclient"
5769 else
5770         LIBWBCLIENT_STATIC=bin/libwbclient.a
5773 if test x"$HAVE_WINBIND" = x"yes"; then
5774         AC_MSG_RESULT(yes)
5775         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
5777         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
5778         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
5779         if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
5780                 PAM_MODULES="$PAM_MODULES pam_winbind"
5781                 INSTALL_PAM_MODULES="installpammodules"
5782                 UNINSTALL_PAM_MODULES="uninstallpammodules"
5783         fi
5784 else
5785         AC_MSG_RESULT(no$winbind_no_reason)
5788 AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
5789                         AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])])
5791 AC_SUBST(WINBIND_NSS_PTHREAD)
5792 AC_SUBST(WINBIND_NSS)
5793 AC_SUBST(WINBIND_WINS_NSS)
5794 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
5795 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
5796 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
5797 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
5799 AC_SUBST(WINBIND_KRB5_LOCATOR)
5801 # Solaris 10 does have new member in nss_XbyY_key
5802 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
5803                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
5804                 [#include <nss_dbdefs.h>])
5806 # Solaris has some extra fields in struct passwd that need to be
5807 # initialised otherwise nscd crashes.
5809 AC_CHECK_MEMBER(struct passwd.pw_comment,
5810                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
5811                 [#include <pwd.h>])
5813 AC_CHECK_MEMBER(struct passwd.pw_age,
5814                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
5815                 [#include <pwd.h>])
5817 # AIX 4.3.x and 5.1 do not have as many members in
5818 # struct secmethod_table as AIX 5.2
5819 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
5820        [#include <usersec.h>])
5821 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
5822        [#include <usersec.h>])
5824 AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
5825 AC_TRY_COMPILE([#include <sys/types.h>
5826 #include <sys/socket.h>],
5827 [struct ucred cred;
5828  socklen_t cred_len;
5829  int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
5831 samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
5832 if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
5833     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
5837 #################################################
5838 # Check to see if we should use the included popt
5840 AC_ARG_WITH(included-popt,
5841 [AS_HELP_STRING([--with-included-popt], [use bundled popt library, not from system])],
5843   case "$withval" in
5844         yes)
5845                 INCLUDED_POPT=yes
5846                 ;;
5847         no)
5848                 INCLUDED_POPT=no
5849                 ;;
5850   esac ],
5852 if test x"$INCLUDED_POPT" != x"yes"; then
5853     AC_CHECK_LIB(popt, poptGetContext,
5854                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
5857 AC_MSG_CHECKING(whether to use included popt)
5858 if test x"$INCLUDED_POPT" = x"yes"; then
5859     AC_MSG_RESULT(yes)
5860     BUILD_POPT='$(POPT_OBJ)'
5861     POPTLIBS='$(POPT_OBJ)'
5862     FLAGS1="-I\$(srcdir)/popt"
5863 else
5864     AC_MSG_RESULT(no)
5865         BUILD_POPT=""
5866     POPTLIBS="-lpopt"
5868 AC_SUBST(BUILD_POPT)
5869 AC_SUBST(POPTLIBS)
5870 AC_SUBST(FLAGS1)
5872 #################################################
5873 # Check if user wants DNS service discovery support
5875 AC_ARG_ENABLE(dnssd,
5876 [AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=auto)])])
5878 AC_SUBST(DNSSD_LIBS)
5879 if test x"$enable_dnssd" != x"no"; then
5880     have_dnssd_support=yes
5882     AC_CHECK_HEADERS(dns_sd.h)
5883     if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
5884         have_dnssd_support=no
5885     fi
5887     # On Darwin the DNSSD API is in libc, but on other platforms it's
5888     # probably in -ldns_sd
5889     AC_CHECK_FUNCS(DNSServiceRegister)
5890     AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
5891     if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
5892             x"$ac_cv_lib_ext_DNSServiceRegister" != x"yes"; then
5893         have_dnssd_support=no
5894     fi
5896     if test x"$have_dnssd_support" = x"yes"; then
5897         AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
5898                 [Whether to enable DNS service discovery support])
5899     else
5900         if test x"$enable_dnssd" = x"yes"; then
5901             AC_MSG_ERROR(DNS service discovery support not available)
5902         fi
5903     fi
5907 #################################################
5908 # Check to see if we should use the included iniparser
5910 AC_ARG_WITH(included-iniparser,
5911 [AS_HELP_STRING([--with-included-iniparser], [use bundled iniparser library, not from system])],
5913   case "$withval" in
5914         yes)
5915                 INCLUDED_INIPARSER=yes
5916                 ;;
5917         no)
5918                 INCLUDED_INIPARSER=no
5919                 ;;
5920   esac ],
5922 if test x"$INCLUDED_INIPARSER" != x"yes"; then
5923     AC_CHECK_LIB(iniparser, iniparser_load,
5924                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
5927 AC_MSG_CHECKING(whether to use included iniparser)
5928 if test x"$INCLUDED_INIPARSER" = x"yes"; then
5929     AC_MSG_RESULT(yes)
5930     BUILD_INIPARSER='$(INIPARSER_OBJ)'
5931         INIPARSERLIBS=""
5932     FLAGS1="$FLAGS1 -I\$(srcdir)/iniparser/src"
5933 else
5934     AC_MSG_RESULT(no)
5935         BUILD_INIPARSER=""
5936     INIPARSERLIBS="-liniparser"
5938 AC_SUBST(BUILD_INIPARSER)
5939 AC_SUBST(INIPARSERLIBS)
5940 AC_SUBST(FLAGS1)
5944 # Checks for the vfs_fileid module
5945 # Start
5946 AC_CHECK_FUNC(getmntent)
5948 AC_CHECK_HEADERS(sys/statfs.h)
5950 AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
5951 AC_CACHE_VAL(vfsfileid_cv_statfs,[
5952              AC_TRY_RUN([
5953                 #include <sys/types.h>
5954                 #include <sys/statfs.h>
5955                 int main(void)
5956                 {
5957                         struct statfs fsd;
5958                         fsid_t fsid = fsd.f_fsid;
5959                         return statfs (".", &fsd);
5960                 }],
5961                 vfsfileid_cv_statfs=yes,
5962                 vfsfileid_cv_statfs=no,
5963                 vfsfileid_cv_statfs=cross)
5965 AC_MSG_RESULT($vfsfileid_cv_statfs)
5967 if test x"$ac_cv_func_getmntent" = x"yes" -a \
5968         x"$vfsfileid_cv_statfs" = x"yes"; then
5969         default_shared_modules="$default_shared_modules vfs_fileid"
5971 # End
5972 # Checks for the vfs_fileid module
5975 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
5977         eval MODULE_DEFAULT_$i=STATIC
5978 done
5980 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
5982         dnl Fall back to static if we cannot build shared libraries
5983         eval MODULE_DEFAULT_$i=STATIC
5985         if test $BLDSHARED = true; then
5986                 eval MODULE_DEFAULT_$i=SHARED
5987         fi
5988 done
5990 dnl Always build these modules static
5991 MODULE_rpc_spoolss=STATIC
5992 MODULE_rpc_srvsvc=STATIC
5993 MODULE_idmap_tdb=STATIC
5994 MODULE_idmap_passdb=STATIC
5995 MODULE_idmap_nss=STATIC
5997 MODULE_nss_info_template=STATIC
5999 AC_ARG_WITH(static-modules,
6000 [AS_HELP_STRING([--with-static-modules=MODULES], [Comma-separated list of names of modules to statically link in])],
6001 [ if test $withval; then
6002         for i in `echo $withval | sed -e 's/,/ /g'`
6003         do
6004                 eval MODULE_$i=STATIC
6005         done
6006 fi ])
6008 AC_ARG_WITH(shared-modules,
6009 [AS_HELP_STRING([--with-shared-modules=MODULES], [Comma-separated list of names of modules to build shared])],
6010 [ if test $withval; then
6011         for i in `echo $withval | sed -e 's/,/ /g'`
6012         do
6013                         eval MODULE_$i=SHARED
6014         done
6015 fi ])
6017 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB,
6018                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
6019 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
6020 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
6021 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
6024 SMB_MODULE(rpc_lsarpc, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
6025 SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
6026 SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
6027 SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC)
6028 SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
6029 SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC)
6030 SMB_MODULE(rpc_ntsvcs2, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs2.$SHLIBEXT", RPC)
6031 SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
6032 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
6033 SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc.$SHLIBEXT", RPC)
6034 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
6035 SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
6036 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
6037 SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
6038 SMB_SUBSYSTEM(RPC,smbd/server.o)
6040 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
6041 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
6042 SMB_MODULE(idmap_tdb2, winbindd/idmap_tdb2.o, "bin/tdb2.$SHLIBEXT", IDMAP)
6043 SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
6044 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
6045 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
6046 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
6047 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
6049 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
6050 SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
6052 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
6053 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
6054 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
6055 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
6056 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
6058 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
6059 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
6060 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
6061 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
6062 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
6063 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
6064 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
6065 SMB_SUBSYSTEM(AUTH,auth/auth.o)
6067 SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
6068 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
6069 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
6070 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
6071 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
6072 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
6073 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
6074 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
6075 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
6076 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
6077 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
6078 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
6079 SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
6080 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
6081 SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
6082 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
6083 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
6084 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
6085 SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
6086 SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
6087 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
6088 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
6089 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
6090 SMB_MODULE(vfs_streams_xattr, \$(VFS_STREAMS_XATTR_OBJ), "bin/streams_xattr.$SHLIBEXT", VFS)
6091 SMB_MODULE(vfs_streams_depot, \$(VFS_STREAMS_DEPOT_OBJ), "bin/streams_depot.$SHLIBEXT", VFS)
6092 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
6093 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
6094 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
6095 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
6096 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
6097 SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
6098 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
6099 SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS)
6100 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
6101 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
6102 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
6105 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
6107 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
6109 #################################################
6110 # do extra things if we are running insure
6112 if test "${ac_cv_prog_CC}" = "insure"; then
6113         CPPFLAGS="$CPPFLAGS -D__INSURE__"
6116 #################################################
6117 # If run from the build farm, enable NASTY hacks
6118 #################################################
6119 AC_MSG_CHECKING(whether to enable build farm hacks)
6120 if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
6121         AC_MSG_RESULT(yes)
6122         AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
6123 else
6124         AC_MSG_RESULT(no)
6127 #################################################
6128 # check for bad librt/libpthread interactions
6130 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
6131     x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
6132     x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6133     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6135 SMB_IF_RTSIGNAL_BUG(
6136         [
6137             # Have RT_SIGNAL bug, need to check whether the problem will
6138             # affect anything we have configured.
6140             rt_do_error=no
6141             if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
6142                 if test x"$rt_signal_lease_ok" = x"no" ; then
6143                     rt_do_error=yes
6144                 fi
6145             fi
6147             if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
6148                 if test x"$rt_signal_notify_ok" = x"no" ; then
6149                     rt_do_error=yes
6150                 fi
6151             fi
6153             if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6154                     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6155                 if test x"$rt_signal_aio_ok" = x"no" ; then
6156                     rt_do_error=yes
6157                 fi
6158             fi
6160             if test x"$rt_do_error" = x"yes" ; then
6161                 SMB_IS_LIBPTHREAD_LINKED(
6162                     [
6163                         cat<<MSG
6165 *** On this platforms, linking Samba against pthreads causes problems
6166 *** with the oplock and change notification mechanisms. You may be
6167 *** using pthreads as a side-effect of using the --with-aio-support
6168 *** or --with-profiling-data options. Please remove these and try again.
6171                     ],
6172                     [
6173                         cat<<MSG
6175 *** On this platform, the oplock and change notification mechanisms do not
6176 *** appear to work. Please report this problem to samba-technical@samba.org
6177 *** and attach the config.log file from this directory.
6180                     ])
6181                 AC_MSG_ERROR(unable to use realtime signals on this platform)
6182             fi
6183         ],
6184         [
6185             # no RT_SIGNAL bug, we are golden
6186             SMB_IS_LIBPTHREAD_LINKED(
6187                 [
6188                     AC_MSG_WARN(using libpthreads - this may degrade performance)
6189                 ])
6191         ],
6192         [
6193             # cross compiling, I hope you know what you are doing
6194             true
6195         ])
6199 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
6200 LIB_REMOVE_USR_LIB(LDFLAGS)
6201 LIB_REMOVE_USR_LIB(LIBS)
6202 LIB_REMOVE_USR_LIB(KRB5_LIBS)
6204 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
6205 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
6206 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
6208 #################################################
6209 # Display summary of libraries detected
6211 AC_MSG_RESULT([Using libraries:])
6212 AC_MSG_RESULT([    LIBS = $LIBS])
6213 if test x"$with_ads_support" != x"no"; then
6214     AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
6216 if test x"$with_ldap_support" != x"no"; then
6217     AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
6219 if test x"$with_dnsupdate_support" != x"no"; then
6220     AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
6222 if test x"$have_dnssd_support" != x"no"; then
6223     AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
6225 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
6227 #################################################
6228 # final configure stuff
6230 AC_MSG_CHECKING([configure summary])
6231 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
6232            AC_MSG_RESULT(yes),
6233            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
6234            AC_MSG_WARN([cannot run when cross-compiling]))
6236 dnl Merge in developer cflags from now on
6237 AC_SUBST(DEVELOPER_CFLAGS)
6238 if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes"; then
6239     CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
6242 # Stuff the smbd-only libraries at the end of the smbd link
6243 # path (if we have them).
6244 SMBD_LIBS="$samba_dmapi_libs"
6245 AC_SUBST(SMBD_LIBS)
6247 AC_OUTPUT(Makefile library-versions
6248           script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
6249           lib/netapi/examples/Makefile
6250           pkgconfig/smbclient.pc
6251           pkgconfig/wbclient.pc
6252           pkgconfig/netapi.pc
6253           pkgconfig/smbsharemodes.pc
6254           )
6256 #################################################
6257 # Print very concise instructions on building/use
6258 if test "x$enable_dmalloc" = xyes
6259 then
6260         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
6261         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])