WHATSNEW: Added Kai's commits.
[Samba/gebeck_regimport.git] / source3 / configure.in
blob4fadfd7ae0389454d1a07dce1e21f4a0244d8268
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="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(SMBMOUNT_PROGS)
118 AC_SUBST(CIFSMOUNT_PROGS)
119 AC_SUBST(INSTALL_CIFSMOUNT)
120 AC_SUBST(UNINSTALL_CIFSMOUNT)
121 AC_SUBST(CIFSSPNEGO_PROGS)
122 AC_SUBST(INSTALL_CIFSSPNEGO)
123 AC_SUBST(UNINSTALL_CIFSSPNEGO)
124 AC_SUBST(EXTRA_SBIN_PROGS)
125 AC_SUBST(EXTRA_ALL_TARGETS)
126 AC_SUBST(CONFIG_LIBS)
127 AC_SUBST(NSCD_LIBS)
129 # compile with optimization and without debugging by default, but
130 # allow people to set their own preference.
131 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
132 # if it has no value.  This prevent *very* large debug binaries from occurring
133 # by default.
134 if test "x$CFLAGS" = x; then
135   CFLAGS="-O"
137 if test "x$debug" = "xyes" ; then
138         CFLAGS="${CFLAGS} -g"
139 else
140         CFLAGS="-O"
143 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
145 m4_include(lib/socket_wrapper/config.m4)
146 m4_include(lib/nss_wrapper/config.m4)
148 m4_include(m4/swat.m4)
150 # Probe the gcc version for extra CFLAGS. We always stash these in
151 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
152 # Makefile edit, avoiding the need to re-run configure.
153 if test x"$ac_cv_prog_gcc" = x"yes" ; then
154         DEVELOPER_CFLAGS="-g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
155         # Add -Wdeclaration-after-statement if compiler supports it
156         AC_CACHE_CHECK(
157           [that the C compiler understands -Wdeclaration-after-statement],
158           samba_cv_HAVE_Wdeclaration_after_statement, [
159           AC_TRY_RUN_STRICT([
160             int main(void)
161             {
162                 return 0;
163             }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
164             samba_cv_HAVE_Wdeclaration_after_statement=yes,
165             samba_cv_HAVE_Wdeclaration_after_statement=no,
166             samba_cv_HAVE_Wdeclaration_after_statement=cross)
167        ])
169         if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
170             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
171         fi
173         #-Werror-implicit-function-declaration
174         AC_CACHE_CHECK(
175           [that the C compiler understands -Werror-implicit-function-declaration],
176           samba_cv_HAVE_Werror_implicit_function_declaration, [
177           AC_TRY_RUN_STRICT([
178             int main(void)
179             {
180                 return 0;
181             }],[-Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
182             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
183             samba_cv_HAVE_Werror_implicit_function_declaration=no,
184             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
185        ])
186        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
187             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
188        fi
190         # krb5developer is like developer, except we don't get
191         # -Wstrict-prototypes.
192        if test x"$krb5_developer" != x"$yes" ; then
193             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
194        fi
197 AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
199 if test "x$enable_dmalloc" = xyes
200 then
201         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
202         AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
203                   [Define to check invariants around some common functions])
204         LIBS="$LIBS -ldmalloc"  
207 #################################################
208 # check for a shared memory profiling support
209 AC_MSG_CHECKING(whether to use profiling)
210 AC_ARG_WITH(profiling-data,
211 [AS_HELP_STRING([--with-profiling-data], [Include gathering source code profile information (default=no)])],
212 [ case "$withval" in
213   yes)
214     AC_MSG_RESULT(yes)
215     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
216     samba_cv_WITH_PROFILE=yes
217     ;;
218   *)
219     AC_MSG_RESULT(no)
220     samba_cv_WITH_PROFILE=no
221     ;;
222   esac ],
223   AC_MSG_RESULT(no)
226 dnl Checks for programs.
228 AC_PROG_INSTALL
229 AC_PROG_AWK
230 AC_PATH_PROG(PERL, perl)
232 AC_CHECK_TOOL(AR, ar)
234 dnl Check if we use GNU ld
235 LD=ld
236 AC_PROG_LD_GNU
238 dnl Certain versions of GNU ld the default is not to have the
239 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
240 dnl warnings when building modules.
241 if test "$ac_cv_prog_gnu_ld" = "yes"; then
242         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
243         AC_MSG_CHECKING(GNU ld release date)
244         changequote(,)dnl
245         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'`
246         changequote([,])dnl
247         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
248         if test -n "$ac_cv_gnu_ld_date"; then
249         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
250                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
251         fi
252         if test "$ac_cv_gnu_ld_date" -gt 20030101; then
253                 ac_cv_gnu_ld_version_script=yes
254         fi
255         else
256            AC_MSG_CHECKING(GNU ld release version)
257            changequote(,)dnl
258            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
259            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
260            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
261            changequote([,])dnl
262            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
263            AC_MSG_CHECKING(GNU ld release version major)
264            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
265            AC_MSG_CHECKING(GNU ld release version minor)
266            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
267            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
268              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
269            fi
270            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
271              ac_cv_gnu_ld_version_script=yes
272            fi
273         fi
276 dnl look for executable suffix
277 AC_EXEEXT
279 dnl Check if C compiler understands -c and -o at the same time
280 AC_PROG_CC_C_O
281 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
282       BROKEN_CC=
283 else
284       BROKEN_CC=#
286 AC_SUBST(BROKEN_CC)
288 dnl Check if the C compiler understands -Werror
289 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
290  AC_TRY_RUN_STRICT([
291   int main(void)
292   {
293         return 0;
294   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
295   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
296 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
297    Werror_FLAGS="-Werror"
298 else
299 dnl Check if the C compiler understands -w2
300 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
301  AC_TRY_RUN_STRICT([
302   int main(void)
303   {
304         return 0;
305   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
306   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
307 if test x"$samba_cv_HAVE_w2" = x"yes"; then
308    Werror_FLAGS="-w2"
312 dnl Check if the C compiler understands volatile (it should, being ANSI).
313 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
314     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
315         samba_cv_volatile=yes,samba_cv_volatile=no)])
316 if test x"$samba_cv_volatile" = x"yes"; then
317    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
320 ############################################
321 # check if the compiler can handle negative enum values
322 # and don't truncate the values to INT_MAX
323 # a runtime test is needed here
324 AC_SUBST(PIDL_ARGS)
325 AC_CACHE_CHECK([that the C compiler understands negative enum values],SMB_BUILD_CC_NEGATIVE_ENUM_VALUES, [
326     AC_TRY_RUN(
328         #include <stdio.h>
329         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
330         int main(void) {
331                 enum negative_values v1 = NEGATIVE_VALUE;
332                 unsigned v2 = NEGATIVE_VALUE;
334                 if (v1 != 0xFFFFFFFF) {
335                         printf("%u != 0xFFFFFFFF\n", v1);
336                         return 1;
337                 }
338                 if (v2 != 0xFFFFFFFF) {
339                         printf("%u != 0xFFFFFFFF\n", v2);
340                         return 1;
341                 }
343                 return 0;
344         }
346         SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=yes,SMB_BUILD_CC_NEGATIVE_ENUM_VALUES=no)])
347 if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
348         AC_MSG_WARN([using --unit-enums for pidl])
349         PIDL_ARGS="$PIDL_ARGS --uint-enums"
352 dnl Figure out the flags to support named structure initializers
354 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
356 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
357 AC_MSG_CHECKING(uname -s)
358 AC_MSG_RESULT(${UNAME_S})
360 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
361 AC_MSG_CHECKING(uname -r)
362 AC_MSG_RESULT(${UNAME_R})
364 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
365 AC_MSG_CHECKING(uname -m)
366 AC_MSG_RESULT(${UNAME_M})
368 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
369 AC_MSG_CHECKING(uname -p)
370 AC_MSG_RESULT(${UNAME_P})
372 UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
373 AC_MSG_CHECKING(uname -i)
374 AC_MSG_RESULT(${UNAME_I})
376 dnl Add #include for broken IRIX header files
377   case "$host_os" in
378         *irix6*)
379                 #TODO add to libreplace
380                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
381                         dnl Fix sensible defaults for MIPSPro compilers. The
382                         dnl error numbers are valid for the 7.3 compilers,
383                         dnl hopefully also valid for the 7.4 series.
384                         dnl
385                         dnl Bugzilla 3801. Force an error on warning 1035
386                         dnl so we don't incorrectly detect stdint.h. This
387                         dnl warning is emitted for #error directives.
388                         CFLAGS="$CFLAGS -diag_error 1035"
389                         dnl 1209: Controlling expression is constant
390                         dnl 1174: Function foo declared but never referenced
391                         dnl 3201: Parameter foo was never referenced
392                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
393                 fi
394         ;;
395 esac
397 DYNEXP=
398 AC_SUBST(DYNEXP)
400 dnl Add modules that have to be built by default here
401 dnl These have to be built static:
402 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_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
404 dnl These are preferably build shared, and static if dlopen() is not available
405 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_syncops vfs_xattr_tdb vfs_streams_xattr"
407 if test "x$developer" = xyes; then
408    default_static_modules="$default_static_modules rpc_rpcecho"
409    default_shared_modules="$default_shared_modules charset_weird"
413 # Config CPPFLAG settings for strange OS's that must be set
414 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
415 # case statement; its first reference must be unconditional.
417 case "$host_os" in
418     *hpux*)
420 # Defines needed for HPUX support.
421 # HPUX has bigcrypt but (sometimes?) doesn't use it for
422 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
424       case `uname -r` in
425                 *9*|*10*|*11)
426                         AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
427                 ;;
428       esac
429       ;;
432 # CRAY Unicos has broken const handling
433        *unicos*)
434           AC_MSG_RESULT([disabling const])
435           CPPFLAGS="$CPPFLAGS -Dconst="
436           ;;
437         
439 # AIX4.x doesn't even admit to having large
440 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
442     *aix4*)
443           AC_MSG_RESULT([enabling large file support])
444       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
445           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
446       ;;
448 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
449 # to the existance of large files..
450 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
451 # recommendations on large file support, however it makes the
452 # compile work using gcc 2.7 and 2.8, whereas using the Sun
453 # recommendation makes the compile fail on gcc2.7. JRA.
455 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
457         *solaris*)
458                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
459                 case `uname -r` in
460                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
461                                 AC_MSG_RESULT([no large file support])
462                                 ;;
463                         5.*)
464                         AC_MSG_RESULT([enabling large file support])
465                         if test "$ac_cv_prog_gcc" = yes; then
466                                 ${CC-cc} -v >conftest.c 2>&1
467                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
468                                 rm -fr conftest.c
469                                 case "$ac_cv_gcc_compiler_version_number" in
470                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
471                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
472                                                 LDFLAGS="$LDFLAGS -lthread"
473                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
474                                                 ;;
475                                         *)
476                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
477                                                 LDFLAGS="$LDFLAGS -lthread"
478                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
479                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
480                                                 ;;
481                                 esac
482                         else
483                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
484                                 LDFLAGS="$LDFLAGS -lthread"
485                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
486                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
487                         fi
488                         ;;
489                 esac
490                 ;;
492 # IRIX uses SYSV printing.  Make sure to set that here
494         *irix*)
495                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
496                 ;;
497         *freebsd*|*dragonfly*)
498                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
499                 ;;
501 # VOS may need to have POSIX support and System V compatibility enabled.
503     *vos*)
504     case "$CPPFLAGS" in
505           *-D_POSIX_C_SOURCE*)
506                 ;;
507           *)
508                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
509                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
510                 ;;
511     esac
512     case "$CPPFLAGS" in
513           *-D_SYSV*|*-D_SVID_SOURCE*)
514                 ;;
515           *)
516                 CPPFLAGS="$CPPFLAGS -D_SYSV"
517                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
518     esac
519     ;;
521 # Tests needed for SINIX large file support.
523     *sysv4*)
524       if test $host = mips-sni-sysv4 ; then
525         AC_MSG_CHECKING([for LFS support])
526         old_CPPFLAGS="$CPPFLAGS"
527         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
528         AC_TRY_RUN([
529 #include <unistd.h>
530 main () {
531 #if _LFS64_LARGEFILE == 1
532 exit(0);
533 #else
534 exit(1);
535 #endif
536 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
537         CPPFLAGS="$old_CPPFLAGS"
538         if test x$SINIX_LFS_SUPPORT = xyes ; then
539           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
540                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
541           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
542           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
543           LIBS="`getconf LFS64_LIBS` $LIBS"
544         fi
545       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
546       fi
547     ;;
549 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
551     *linux*)
552         AC_MSG_CHECKING([for LFS support])
553         old_CPPFLAGS="$CPPFLAGS"
554         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
555        AC_TRY_RUN([
556 #include <unistd.h>
557 #include <sys/utsname.h>
558 #include <string.h>
559 #include <stdlib.h>
560 main() {
561 #if _LFS64_LARGEFILE == 1
562        struct utsname uts;
563        char *release;
564        int major, minor;
566        /* Ensure this is glibc 2.2 or higher */
567 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
568        int libc_major = __GLIBC__;
569        int libc_minor = __GLIBC_MINOR__;
571        if (libc_major < 2)
572               exit(1);
573        if (libc_minor < 2)
574               exit(1);
575 #endif
577        /* Ensure this is kernel 2.4 or higher */
579        uname(&uts);
580        release = strdup(uts.release);
581        major = atoi(strsep(&release, "."));
582        minor = atoi(strsep(&release, "."));
584        if (major > 2 || (major == 2 && minor > 3))
585                exit(0);
586        exit(1);
587 #else
588        exit(1);
589 #endif
591 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
592         CPPFLAGS="$old_CPPFLAGS"
593         if test x$LINUX_LFS_SUPPORT = xyes ; then
594                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
595                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
596                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
597                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
598         fi
599         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
600         ;;
603 # MacOS X is the *only* system that uses compose character in utf8. This
604 # is so horribly broken....
606     *darwin*)
607         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
609 # Add a system specific charset module.
610         default_shared_modules="$default_shared_modules charset_macosxfs"
612         ;;
613     *hurd*)
614         AC_MSG_CHECKING([for LFS support])
615         old_CPPFLAGS="$CPPFLAGS"
616         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
617         AC_TRY_RUN([
618 #include <unistd.h>
619 main () {
620 #if _LFS64_LARGEFILE == 1
621 exit(0);
622 #else
623 exit(1);
624 #endif
625 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
626         CPPFLAGS="$old_CPPFLAGS"
627         if test x$GLIBC_LFS_SUPPORT = xyes ; then
628           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
629                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
630           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
631         fi
632       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
633     ;;
635 esac
637 SAVE_CPPFLAGS="${CPPFLAGS}"
638 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
640 AC_LIBREPLACE_BROKEN_CHECKS
642 CPPFLAGS="${SAVE_CPPFLAGS}"
644 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
646 LIBREPLACE_OBJS=""
647 for obj in ${LIBREPLACEOBJ}; do
648         LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
649 done
650 AC_SUBST(LIBREPLACE_OBJS)
652 # add -ldl to the global LIBS
653 LIBS="${LIBS} ${LIBDL}"
655 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)
656 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
657 AC_CHECK_HEADERS(limits.h float.h pthread.h)
658 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
659 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
660 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
661 AC_CHECK_HEADERS(sys/un.h ifaddrs.h)
662 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
663 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
664 AC_CHECK_HEADERS(sys/sysmacros.h)
665 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
666 AC_CHECK_HEADERS(langinfo.h locale.h)
667 AC_CHECK_HEADERS(xfs/libxfs.h)
668 AC_CHECK_HEADERS(netgroup.h)
670 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
671 #if HAVE_RPC_RPC_H
672 #include <rpc/rpc.h>
673 #endif
676 ## These fail to compile on IRIX so just check for their presence
677 AC_CHECK_HEADERS(sys/mode.h,,,)
679 # Look for Darwin headers
680 old_CPPFLAGS="$CPPFLAGS"
681 CPPFLAGS="-Iinclude $CPPFLAGS"
682 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
683 CPPFLAGS="$old_CPPFLAGS"
685 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
686 # subdirectory of headers.
687 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
689 # check for linux on amd64 since valgrind is not quite there yet
690 case "$host_os" in
691         *linux*)
692                 case "$UNAME_P" in
693                         *x86_64*)
694                                 AC_DEFINE(HAVE_64BIT_LINUX,1,[Whether we are running on 64bit linux])
695                                 ;;
696                 esac
697                 ;;
698 esac
702 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
703 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
705 case "$host_os" in
706     *hpux*)
707                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
708                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
709                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
710                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
711                 fi
712         ;;
713 esac
714 AC_CHECK_HEADERS(shadow.h)
715 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
716 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
718 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
719 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
721 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
723 # For experimental utmp support (lastlog on some BSD-like systems)
724 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
726 AC_CHECK_SIZEOF(int,cross)
727 AC_CHECK_SIZEOF(long,cross)
728 AC_CHECK_SIZEOF(long long,cross)
729 AC_CHECK_SIZEOF(short,cross)
731 AC_C_CONST
732 AC_C_INLINE
733 AC_C_BIGENDIAN
734 AC_C_CHAR_UNSIGNED
736 AC_TYPE_SIGNAL
737 AC_TYPE_UID_T
738 AC_TYPE_MODE_T
739 AC_TYPE_OFF_T
740 AC_TYPE_SIZE_T
741 AC_TYPE_PID_T
742 AC_STRUCT_ST_RDEV
743 AC_DIRENT_D_OFF
744 AC_CHECK_TYPE(ssize_t, int)
745 AC_CHECK_TYPE(wchar_t, unsigned short)
747 ############################################
748 # for cups support we need libcups, and a handful of header files
750 AC_ARG_ENABLE(cups,
751 [AS_HELP_STRING([--enable-cups], [Turn on CUPS support (default=auto)])])
753 if test x$enable_cups != xno; then
754         AC_PATH_PROG(CUPS_CONFIG, cups-config)
756         if test "x$CUPS_CONFIG" != x; then
757                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
758                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
759                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
760                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
761         elif test x"$enable_cups" = x"yes"; then
762                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
763         fi
766 AC_ARG_ENABLE(iprint,
767 [AS_HELP_STRING([--enable-iprint], [Turn on iPrint support (default=yes if cups is yes)])])
769 if test x$enable_iprint != xno; then
770         if test "x$CUPS_CONFIG" != x; then
771                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
772         elif test x"$enable_iprint" = x"yes"; then
773                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
774         fi
777 ############################################
778 # check if the compiler will optimize out function calls
779 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
780     AC_TRY_LINK([
781 #include <stdio.h>],
783                 if (0) {
784                    this_function_does_not_exist();
785                 } else {
786                   return 1;
787                 }
790         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
791 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
792    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
795 ############################################
796 # check for unix domain sockets
797 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
798     AC_TRY_COMPILE([
799 #include <sys/types.h>
800 #include <stdlib.h>
801 #include <stddef.h>
802 #include <sys/socket.h>
803 #include <sys/un.h>],
805   struct sockaddr_un sunaddr;
806   sunaddr.sun_family = AF_UNIX;
808         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
809 if test x"$samba_cv_unixsocket" = x"yes"; then
810    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixsocket support])
814 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
815     AC_TRY_COMPILE([
816 #include <sys/types.h>
817 #if STDC_HEADERS
818 #include <stdlib.h>
819 #include <stddef.h>
820 #endif
821 #include <signal.h>],[sig_atomic_t i = 0],
822         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
823 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
824    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
827 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
828     AC_TRY_COMPILE([
829 #include <sys/types.h>
830 #if STDC_HEADERS
831 #include <stdlib.h>
832 #include <stddef.h>
833 #endif
834 #if TIME_WITH_SYS_TIME
835 # include <sys/time.h>
836 # include <time.h>
837 #else
838 # if HAVE_SYS_TIME_H
839 #  include <sys/time.h>
840 # else
841 #  include <time.h>
842 # endif
843 #endif
844 ],[struct timespec ts;],
845         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
846 if test x"$samba_cv_struct_timespec" = x"yes"; then
847    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
850 # stupid headers have the functions but no declaration. grrrr.
851 AC_HAVE_DECL(errno, [#include <errno.h>])
852 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
853 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
855 # and glibc has setresuid under linux but the function does
856 # nothing until kernel 2.1.44! very dumb.
857 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
858     AC_TRY_RUN([#include <errno.h>
859 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
860         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
861 if test x"$samba_cv_have_setresuid" = x"yes"; then
862     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
865 # Do the same check for setresguid...
867 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
868     AC_TRY_RUN([#include <unistd.h>
869 #include <errno.h>
870 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
871         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
872 if test x"$samba_cv_have_setresgid" = x"yes"; then
873     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
876 AC_FUNC_MEMCMP
878 ###############################################
879 # Readline included by default unless explicitly asked not to
880 test "${with_readline+set}" != "set" && with_readline=yes
882 # test for where we get readline() from
883 AC_MSG_CHECKING(whether to use readline)
884 AC_ARG_WITH(readline,
885 [AS_HELP_STRING([--with-readline[=DIR]], [Look for readline include/libs in DIR (default=auto)])],
886 [  case "$with_readline" in
887   yes)
888     AC_MSG_RESULT(yes)
890     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
891     AC_CHECK_HEADERS(readline/history.h)
893     AC_CHECK_HEADERS(readline.h readline/readline.h,[
894       for termlib in ncurses curses termcap terminfo termlib tinfo; do
895        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
896       done
897       AC_CHECK_LIB(readline, rl_callback_handler_install,
898        [TERMLIBS="-lreadline $TERMLIBS"
899        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
900        break], [TERMLIBS=], $TERMLIBS)])
901     ;;
902   no)
903     AC_MSG_RESULT(no)
904     ;;
905   *)
906     AC_MSG_RESULT(yes)
908     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
909     # alternate readline path
910     _ldflags=${LDFLAGS}
911     _cppflags=${CPPFLAGS}
913     # Add additional search path
914     LDFLAGS="-L$with_readline/lib $LDFLAGS"
915     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
917     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
918     AC_CHECK_HEADERS(readline/history.h)
920     AC_CHECK_HEADERS(readline.h readline/readline.h,[
921       for termlib in ncurses curses termcap terminfo termlib; do
922        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
923       done
924       AC_CHECK_LIB(readline, rl_callback_handler_install,
925        [TERMLDFLAGS="-L$with_readline/lib"
926        TERMCPPFLAGS="-I$with_readline/include"
927        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
928        TERMLIBS="-lreadline $TERMLIBS"
929        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
930        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
932     LDFLAGS=$_ldflags
933     ;;
934   esac],
935   AC_MSG_RESULT(no)
937 AC_SUBST(TERMLIBS)
938 AC_SUBST(TERMLDFLAGS)
940 # The readline API changed slightly from readline3 to readline4, so
941 # code will generate warnings on one of them unless we have a few
942 # special cases.
943 AC_CHECK_LIB(readline, rl_completion_matches,
944              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
945                         [Do we have rl_completion_matches?])],
946              [],
947              [$TERMLIBS])
949 # not all readline libs have rl_event_hook or history_list
950 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
951 AC_CHECK_LIB(readline, history_list,
952              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
953              [],
954              [$TERMLIBS])
956 # The following test taken from the cvs sources
957 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
958 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
959 # libsocket.so which has a bad implementation of gethostbyname (it
960 # only looks in /etc/hosts), so we only look for -lsocket if we need
961 # it.
962 AC_CHECK_FUNCS(connect)
963 if test x"$ac_cv_func_connect" = x"no"; then
964     case "$LIBS" in
965     *-lnsl*) ;;
966     *) AC_CHECK_LIB(nsl_s, connect) ;;
967     esac
968     case "$LIBS" in
969     *-lnsl*) ;;
970     *) AC_CHECK_LIB(nsl, connect) ;;
971     esac
972     case "$LIBS" in
973     *-lsocket*) ;;
974     *) AC_CHECK_LIB(socket, connect) ;;
975     esac
976     case "$LIBS" in
977     *-linet*) ;;
978     *) AC_CHECK_LIB(inet, connect) ;;
979     esac
980     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
981     dnl has been cached.
982     if test x"$ac_cv_lib_socket_connect" = x"yes" ||
983        test x"$ac_cv_lib_inet_connect" = x"yes"; then
984         # ac_cv_func_connect=yes
985         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
986         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
987     fi
990 ###############################################
991 # test for where we get yp_get_default_domain() from
992 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
993 AC_CHECK_FUNCS(yp_get_default_domain)
995 # Check if we have execl, if not we need to compile smbrun.
996 AC_CHECK_FUNCS(execl)
997 if test x"$ac_cv_func_execl" = x"no"; then
998     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1001 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror chown fchown lchown chmod fchmod chroot link mknod mknod64)
1002 AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
1003 AC_CHECK_FUNCS(fstat strchr utime utimes chflags)
1004 AC_CHECK_FUNCS(getrlimit fsync fdatasync memset strlcpy strlcat setpgid)
1005 AC_CHECK_FUNCS(memmove setsid glob strpbrk pipe crypt16 getauthuid)
1006 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1007 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1008 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
1009 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
1010 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1011 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1012 AC_CHECK_FUNCS(getpwent_r)
1013 AC_CHECK_FUNCS(getdents getdents64)
1014 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1015 AC_CHECK_FUNCS(syslog vsyslog timegm)
1016 AC_CHECK_FUNCS(setlocale nl_langinfo)
1017 AC_CHECK_FUNCS(nanosleep)
1018 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1019 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
1020 AC_CHECK_HEADERS(sys/mman.h)
1021 # setbuffer, shmget, shm_open are needed for smbtorture
1022 AC_CHECK_FUNCS(setbuffer shmget shm_open)
1024 # Find a method of generating a stack trace
1025 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1026 AC_CHECK_FUNCS(backtrace_symbols)
1027 AC_CHECK_LIB(exc, trace_back_stack)
1029 echo -n "checking for GPFS GPL libs... "
1030 save_LIBS="$LIBS"
1031 LIBS="$LIBS -lgpfs_gpl"
1032 AC_TRY_LINK([#include <gpfs_gpl.h>],
1033           [gpfs_set_share(0,GPFS_SHARE_READ,GPFS_DENY_NONE)],
1034           samba_cv_HAVE_GPFS=yes,
1035           samba_cv_HAVE_GPFS=no)
1036 echo $samba_cv_HAVE_GPFS
1037 if test x"$samba_cv_HAVE_GPFS" = x"yes"; then
1038     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL libs are available])
1039     default_shared_modules="$default_shared_modules vfs_gpfs"
1041 LIBS="$save_LIBS"
1043 # Note that all the libunwind symbols in the API are defined to internal
1044 # platform-specific version, so we must include libunwind.h before checking
1045 # any of them.
1046 AC_MSG_CHECKING([for libunwind])
1047 save_LIBS=$LIBS
1049 UNWIND_ARCH="unknown"
1050 if test x"$UNAME_I" != x"unknown"; then
1051         UNWIND_ARCH="$UNAME_I"
1052 elif test x"$UNAME_M" != x"unknown"; then
1053         UNWIND_ARCH="$UNAME_M"
1054 elif test x"$UNAME_P" != x"unknown"; then
1055         UNWIND_ARCH="$UNAME_P"
1058 case "$UNWIND_ARCH" in
1059         unknown)
1060                 # This probably won't link without
1061                 # the platform-specific libunwind.
1062                 LIBS="$LIBS -lunwind"
1063                 ;;
1064         i386|i586|i686)
1065                 # Add the platform-specific libunwind module.
1066                 LIBS="$LIBS -lunwind -lunwind-x86"
1067                 ;;
1068         *)
1069                 # Add the platform-specific libunwind module.
1070                 # based on uname -i, uname -m or uname -p
1071                 LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
1072                 ;;
1073 esac
1075 AC_TRY_LINK(
1076     [
1077 #ifdef HAVE_LIBUNWIND_H
1078 #include <libunwind.h>
1079 #endif
1080     ],
1081     [
1082         unw_context_t ctx; unw_cursor_t cur;
1083         char buf[256]; unw_word_t off;
1084         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1085         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1086     ],
1087     [
1088         AC_MSG_RESULT(yes)
1089         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1091         # If we have libunwind, test whether we also have libunwind-ptrace
1092         # which would let us unwind arbitrary processes.
1093         save_LIBS=$LIBS
1094         AC_CHECK_HEADERS(libunwind-ptrace.h)
1095         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1096             [
1097                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1098                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1099                     [Whether libunwind-ptrace.a is available.])
1100             ],
1101             [ LIBUNWIND_PTRACE="" ])
1103         LIBS=$save_LIBS
1104     ],
1105     [
1106         AC_MSG_RESULT(no)
1107         LIBS=$save_LIBS
1108     ])
1110 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1111 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1112     AC_CHECK_HEADERS(sys/ptrace.h)
1113     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1114     AC_TRY_LINK(
1115             [
1116 #if HAVE_SYS_TYPES_H
1117 #include <sys/types.h>
1118 #endif
1119 #if HAVE_SYS_PTRACE_H
1120 #include <sys/ptrace.h>
1121 #endif
1122             ],
1123             [
1124                 int main(int argc, const char ** argv)
1125                 {
1126                         pid_t me = (pid_t)-1;
1127                         ptrace(PTRACE_ATTACH, me, 0, 0);
1128                         ptrace(PTRACE_DETACH, me, 0, 0);
1129                         return 0;
1130                 }
1131             ],
1132             [
1133                 AC_MSG_RESULT(yes)
1134                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1135                     [Whether the Linux ptrace(2) interface is available.])
1136             ],
1137             [
1138                 AC_MSG_RESULT(no)
1139                 LIBUNWIND_PTRACE=""
1140             ])
1143 AC_SUBST(LIBUNWIND_PTRACE)
1145 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1146 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1147 AC_CHECK_FUNCS(__getcwd _getcwd)
1148 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1149 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1150 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1151 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1152 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1153 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1154 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1155 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1156 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1157 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1158 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1159 AC_CHECK_FUNCS(prctl)
1161 AC_TRY_COMPILE([
1162 #ifdef HAVE_SYS_PRCTL_H
1163 #include <sys/prctl.h>
1164 #endif
1166 [int i; i = prtcl(0); ],
1167 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1172 case "$host_os" in
1173     *linux*)
1174        # glibc <= 2.3.2 has a broken getgrouplist
1175        AC_TRY_RUN([
1176 #include <unistd.h>
1177 #include <sys/utsname.h>
1178 main() {
1179        /* glibc up to 2.3 has a broken getgrouplist */
1180 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1181        int libc_major = __GLIBC__;
1182        int libc_minor = __GLIBC_MINOR__;
1184        if (libc_major < 2)
1185               exit(1);
1186        if ((libc_major == 2) && (libc_minor <= 3))
1187               exit(1);
1188 #endif
1189        exit(0);
1191 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1192        if test x"$linux_getgrouplist_ok" = x"yes"; then
1193           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1194        fi
1195        ;;
1196     *)
1197        AC_CHECK_FUNCS(getgrouplist)
1198        ;;
1199 esac
1202 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1205 if test x$ac_cv_func_stat64 = xno ; then
1206   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1207   AC_TRY_LINK([
1208 #if defined(HAVE_UNISTD_H)
1209 #include <unistd.h>
1210 #endif
1211 #include <sys/stat.h>
1212 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1213   AC_MSG_RESULT([$ac_cv_func_stat64])
1214   if test x$ac_cv_func_stat64 = xyes ; then
1215     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1216   fi
1219 if test x$ac_cv_func_lstat64 = xno ; then
1220   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1221   AC_TRY_LINK([
1222 #if defined(HAVE_UNISTD_H)
1223 #include <unistd.h>
1224 #endif
1225 #include <sys/stat.h>
1226 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1227   AC_MSG_RESULT([$ac_cv_func_lstat64])
1228   if test x$ac_cv_func_lstat64 = xyes ; then
1229     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1230   fi
1233 if test x$ac_cv_func_fstat64 = xno ; then
1234   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1235   AC_TRY_LINK([
1236 #if defined(HAVE_UNISTD_H)
1237 #include <unistd.h>
1238 #endif
1239 #include <sys/stat.h>
1240 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1241   AC_MSG_RESULT([$ac_cv_func_fstat64])
1242   if test x$ac_cv_func_fstat64 = xyes ; then
1243     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1244   fi
1247 #################################################
1248 # Check whether struct stat has timestamps with sub-second resolution.
1249 # At least IRIX and Solaris have these.
1251 # We check that
1252 #       all of st_mtim, st_atim and st_ctim exist
1253 #       all of the members are in fact of type struct timespec
1255 # There is some conflicting standards weirdness about whether we should use
1256 # "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we
1257 # prefer struct timespec.
1259 AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_stat_hires,
1260     [
1261         AC_TRY_COMPILE(
1262             [
1263 #if TIME_WITH_SYS_TIME
1264 # include <sys/time.h>
1265 # include <time.h>
1266 #else
1267 # if HAVE_SYS_TIME_H
1268 #  include <sys/time.h>
1269 # else
1270 #  include <time.h>
1271 # endif
1272 #endif
1273 #ifdef HAVE_SYS_STAT_H
1274 #include <sys/stat.h>
1275 #endif
1276             ],
1277             [
1278                 struct timespec t;
1279                 struct stat s = {0};
1280                 t.tv_sec = s.st_mtim.tv_sec;
1281                 t.tv_nsec = s.st_mtim.tv_nsec;
1282                 t.tv_sec = s.st_ctim.tv_sec;
1283                 t.tv_nsec = s.st_ctim.tv_nsec;
1284                 t.tv_sec = s.st_atim.tv_sec;
1285                 t.tv_nsec = s.st_atim.tv_nsec;
1286             ],
1287             samba_stat_hires=yes, samba_stat_hires=no)
1288     ])
1290 if test x"$samba_stat_hires" = x"yes" ; then
1291     AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim])
1292     AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim])
1293     AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim])
1294     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1295             [whether struct stat has sub-second timestamps])
1298 AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_stat_hires_notimespec,
1299     [
1300         AC_TRY_COMPILE(
1301             [
1302 #if TIME_WITH_SYS_TIME
1303 # include <sys/time.h>
1304 # include <time.h>
1305 #else
1306 # if HAVE_SYS_TIME_H
1307 #  include <sys/time.h>
1308 # else
1309 #  include <time.h>
1310 # endif
1311 #endif
1312 #ifdef HAVE_SYS_STAT_H
1313 #include <sys/stat.h>
1314 #endif
1315             ],
1316             [
1317                 struct timespec t;
1318                 struct stat s = {0};
1319                 t.tv_sec = s.st_mtime;
1320                 t.tv_nsec = s.st_mtimensec;
1321                 t.tv_sec = s.st_ctime;
1322                 t.tv_nsec = s.st_ctimensec;
1323                 t.tv_sec = s.st_atime;
1324                 t.tv_nsec = s.st_atimensec;
1325             ],
1326             samba_stat_hires=yes, samba_stat_hires=no)
1327     ])
1329 if test x"$samba_stat_hires_notimespec" = x"yes" ; then
1330     AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
1331     AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
1332     AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
1333     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1334             [whether struct stat has sub-second timestamps without struct timespec])
1337 #####################################
1338 # needed for SRV lookups
1339 AC_CHECK_LIB(resolv, dn_expand)
1340 AC_CHECK_LIB(resolv, _dn_expand)
1341 AC_CHECK_LIB(resolv, __dn_expand)
1344 # Check for the functions putprpwnam, set_auth_parameters,
1345 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1346 # Needed for OSF1 and HPUX.
1349 AC_LIBTESTFUNC(security, putprpwnam)
1350 AC_LIBTESTFUNC(sec, putprpwnam)
1352 AC_LIBTESTFUNC(security, set_auth_parameters)
1353 AC_LIBTESTFUNC(sec, set_auth_parameters)
1355 # UnixWare 7.x has its getspnam in -lgen
1356 AC_LIBTESTFUNC(gen, getspnam)
1358 AC_LIBTESTFUNC(security, getspnam)
1359 AC_LIBTESTFUNC(sec, getspnam)
1361 AC_LIBTESTFUNC(security, bigcrypt)
1362 AC_LIBTESTFUNC(sec, bigcrypt)
1364 AC_LIBTESTFUNC(security, getprpwnam)
1365 AC_LIBTESTFUNC(sec, getprpwnam)
1367 AC_CHECK_FUNCS(strsignal)
1369 ############################################
1370 # Check if we have libattr
1371 case "$host_os" in
1372   *osf*)
1373         AC_SEARCH_LIBS(getproplist, [proplist])
1374         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1375         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1376         AC_CHECK_FUNCS(sizeof_proplist_entry)
1377   ;;
1378   *)
1379         AC_SEARCH_LIBS(getxattr, [attr])
1380         AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1381         AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
1382         AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
1383         AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1384         AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1385         AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1386         AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1387   ;;
1388 esac
1390 ########################################################
1391 # Check if attropen() is present if this is Solaris
1392 case "$host_os" in
1393   *solaris*)
1394         AC_CHECK_FUNCS(attropen)
1395   ;;
1396 esac
1398 ########################################################
1399 # Do xattr functions take additional options like on Darwin?
1400 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1401         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1402                 old_LIBS=$LIBS
1403                 LIBS="$LIBS $ACL_LIBS"
1404                 AC_TRY_COMPILE([
1405                         #include <sys/types.h>
1406                         #if HAVE_ATTR_XATTR_H
1407                         #include <attr/xattr.h>
1408                         #elif HAVE_SYS_XATTR_H
1409                         #include <sys/xattr.h>
1410                         #endif
1411                 ],[
1412                         getxattr(0, 0, 0, 0, 0, 0);
1413                 ],
1414                 [smb_attr_cv_xattr_add_opt=yes],
1415                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1416         ])
1417         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1418                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1419         fi
1422 # Check if we have extattr
1423 case "$host_os" in
1424   *freebsd4* | *dragonfly* )
1425     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1426     ;;
1427   *)
1428     AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
1429     AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
1430     AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
1431     AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
1432     ;;
1433 esac
1435 AC_DISABLE_STATIC
1436 AC_ENABLE_SHARED
1438 # Set defaults
1439 PIE_CFLAGS=""
1440 PIE_LDFLAGS=""
1441 AC_ARG_ENABLE(pie, [AS_HELP_STRING([--enable-pie], [Turn on pie support if available (default=yes)])])
1443 if test "x$enable_pie" != xno
1444 then
1445         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1446         [
1447                 cat > conftest.c <<EOF
1448 int foo;
1449 main () { return 0;}
1451                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1452                 then
1453                         samba_cv_fpie=yes
1454                 else
1455                         samba_cv_fpie=no
1456                 fi
1457                 rm -f conftest*
1458         ])
1459         if test x"${samba_cv_fpie}" = x"yes"
1460         then
1461                 PIE_CFLAGS="-fPIE"
1462                 PIE_LDFLAGS="-pie"
1463         fi
1466 # Assume non-shared by default and override below
1467 BLDSHARED="false"
1469 # these are the defaults, good for lots of systems
1470 HOST_OS="$host_os"
1471 LDSHFLAGS="-shared"
1472 MODULE_EXPORTS=""
1473 SONAMEFLAG="#"
1474 SHLD="\${CC} \${CFLAGS}"
1475 PICFLAG="${PIE_CFLAGS}"
1476 SHLIBEXT="so"
1477 DSO_EXPORTS=""
1479 # this bit needs to be modified for each OS that supports share libs
1480 # You need to specify how to create a shared library and
1481   # how to compile C code to produce PIC object files
1483   AC_MSG_CHECKING([ability to build shared libraries])
1485   # and these are for particular systems
1486   case "$host_os" in
1487                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1488                         BLDSHARED="true"
1489                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1490                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
1491                         else
1492                                 LDSHFLAGS="-shared -Wl,-Bsymbolic"
1493                         fi
1494                         DYNEXP="-Wl,--export-dynamic"
1495                         PICFLAG="-fPIC"
1496                         SONAMEFLAG="-Wl,-soname="
1497                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1498                         ;;
1499                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1500                         BLDSHARED="true"
1501                         LDSHFLAGS="-G"
1502                         SONAMEFLAG="-h "
1503                         if test "${GCC}" = "yes"; then
1504                                 PICFLAG="-fPIC"
1505                                 SONAMEFLAG="-Wl,-soname="
1506                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1507                                         DYNEXP="-Wl,-E"
1508                                 fi
1509                         else
1510                                 PICFLAG="-KPIC"
1511                                 ## ${CFLAGS} added for building 64-bit shared
1512                                 ## libs using Sun's Compiler
1513                                 LDSHFLAGS="-G \${CFLAGS}"
1514                         fi
1515                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1516                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1517                         ;;
1518                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1519                         BLDSHARED="true"
1520                         LDSHFLAGS="-G"
1521                         SONAMEFLAG="-Wl,-h,"
1522                         PICFLAG="-KPIC"   # Is this correct for SunOS
1523                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1524                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1525                         ;;
1526                 *netbsd* | *freebsd* | *dragonfly* )
1527                         BLDSHARED="true"
1528                         LDSHFLAGS="-shared"
1529                         DYNEXP="-Wl,--export-dynamic"
1530                         SONAMEFLAG="-Wl,-soname,"
1531                         PICFLAG="-fPIC -DPIC"
1532                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1533                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1534                         ;;
1535                 *openbsd*)  BLDSHARED="true"
1536                         LDSHFLAGS="-shared"
1537                         DYNEXP="-Wl,-Bdynamic"
1538                         SONAMEFLAG="-Wl,-soname,"
1539                         PICFLAG="-fPIC"
1540                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1541                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1542                         ;;
1543                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1544                         case "$host_os" in
1545                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1546                         ;;
1547                         esac
1548                         BLDSHARED="true"
1549                         LDSHFLAGS="-set_version sgi1.0 -shared"
1550                         SONAMEFLAG="-soname "
1551                         SHLD="\${LD}"
1552                         if test "${GCC}" = "yes"; then
1553                                 PICFLAG="-fPIC"
1554                         else
1555                                 PICFLAG="-KPIC"
1556                         fi
1557                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1558                         ;;
1559                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1560                         BLDSHARED="true"
1561                         LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc"
1562                         DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
1563                         PICFLAG="-O2"
1564                         # as AIX code is always position independent...
1565                         # .po will just create compile warnings, use po.o:
1566                         if test "${GCC}" != "yes"; then
1567                                 ## for funky AIX compiler using strncpy()
1568                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1569                         fi
1571                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1572                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1573                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1574                         ;;
1575                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1576                         # Use special PIC flags for the native HP-UX compiler.
1577                                 BLDSHARED="true"
1578                                 SHLD="cc"
1579                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1580                                 SONAMEFLAG="-Wl,+h "
1581                                 PICFLAG="+z"
1582                         if test "${GCC}" = "yes"; then
1583                                 PICFLAG="-fPIC"
1584                         else
1585                                 PICFLAG="+z +ESnolit"
1586                         fi
1587                         if test "$host_cpu" = "ia64"; then
1588                                 SHLIBEXT="so"
1589                               PICFLAG="+z"
1590                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
1591                         else
1592                                 SHLIBEXT="sl"
1593                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1594                         fi
1595                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1596                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1597                         ;;
1598                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1599                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1600                         ;;
1601                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1602                         BLDSHARED="true"
1603                         LDSHFLAGS="-shared"
1604                         SONAMEFLAG="-Wl,-soname,"
1605                         PICFLAG="-fPIC"
1606                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1607                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1608                         ;;
1609                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1610                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1611                         ;;
1612                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1613                         BLDSHARED="true"
1614                         LDSHFLAGS="-shared"
1615                         SONAMEFLAG="-Wl,-soname,"
1616                         PICFLAG="-KPIC"
1617                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1618                         ;;
1619                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1620                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1621                         ;;
1622                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1623                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1624                         ;;
1625                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1626                         case "$host" in
1627                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1628                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1629                                         fi
1630                                         LDSHFLAGS="-G"
1631                                         DYNEXP="-Bexport"
1632                                 ;;
1633                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1634                         esac
1635                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1636                         ;;
1638                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1639                         if [ test "$GCC" != yes ]; then
1640                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1641                         fi
1642                         LDSHFLAGS="-G"
1643                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1644                         ;;
1645                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1646                         BLDSHARED="false"
1647                         LDSHFLAGS=""
1648                         ;;
1650                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1651                         BLDSHARED="true"
1652                         LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress"
1653                         CFLAGS="$CFLAGS -fno-common"
1654                         SHLD="\${CC}"
1655                         SHLIBEXT="dylib"
1656                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
1657                         SHLIBEXT="dylib"
1658                         # Since gcc doesn't fail on unrecognised options, the
1659                         # PIE test incorrectly succeeds. Darwin gcc does not
1660                         # actually support the PIE stuff.
1661                         PIE_LDFLAGS=
1662                         PIE_CFLAGS=
1663                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1664                         ;;
1666                 *)
1667                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1668                         ;;
1669   esac
1671 if test "$enable_shared" != "yes"; then
1672         BLDSHARED=false
1675 if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
1676         DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
1679 if test x"$BLDSHARED" = x"true" ; then
1680         LDFLAGS="$LDFLAGS -L./bin"
1683 AC_MSG_RESULT($BLDSHARED)
1685 AC_MSG_CHECKING([LDFLAGS])
1686 AC_MSG_RESULT([$LDFLAGS])
1687 AC_MSG_CHECKING([DYNEXP])
1688 AC_MSG_RESULT([$DYNEXP])
1690 #######################################################
1691 # test whether building a shared library actually works
1692 if test $BLDSHARED = true; then
1694 AC_MSG_CHECKING([SHLD])
1695 AC_MSG_RESULT([$SHLD])
1696 AC_MSG_CHECKING([LDSHFLAGS])
1697 AC_MSG_RESULT([$LDSHFLAGS])
1699 AC_MSG_CHECKING([SHLIBEXT])
1700 AC_MSG_RESULT([$SHLIBEXT])
1701 AC_MSG_CHECKING([SONAMEFLAG])
1702 AC_MSG_RESULT([$SONAMEFLAG])
1704 AC_MSG_CHECKING([PICFLAG])
1705 AC_MSG_RESULT([$PICFLAG])
1707 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
1708 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
1710 AC_CACHE_CHECK([whether building shared libraries actually works],
1711                [ac_cv_shlib_works],[
1712    # try building a trivial shared library
1713    ac_cv_shlib_works=no
1714    # The $SHLD and $LDSHFLAGS variables may contain references to other
1715    # variables so they need to be eval'ed.
1716    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o \
1717         shlib.o ${srcdir-.}/tests/shlib.c && \
1718    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1719         shlib.o && ac_cv_shlib_works=yes
1720    rm -f "shlib.$SHLIBEXT" shlib.o
1723 if test $ac_cv_shlib_works = no; then
1724    BLDSHARED=false
1728 if test x"$BLDSHARED" != x"true"; then
1729         LDSHFLAGS="shared-libraries-disabled"
1730         SONAMEFLAG="shared-libraries-disabled"
1731         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
1732         SHLD="shared-libraries-disabled"
1733         PICFLAG="${PIE_CFLAGS}"
1734         SHLIBEXT="shared_libraries_disabled"
1737 AC_MSG_CHECKING([used PICFLAG])
1738 AC_MSG_RESULT([$PICFLAG])
1740 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
1742 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
1744 ################
1746 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1747 AC_TRY_RUN([#include <stdio.h>
1748 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1749 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1750 if test x"$samba_cv_have_longlong" = x"yes"; then
1751     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1752     AC_CHECK_TYPE(intptr_t, unsigned long long)
1753 else
1754     AC_CHECK_TYPE(intptr_t, unsigned long)
1758 # Check if the compiler supports the LL prefix on long long integers.
1759 # AIX needs this.
1761 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1762     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1763         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1764 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1765    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1769 AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
1770 AC_TRY_RUN([#include <time.h>
1771 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
1772 samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
1773 if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
1774     AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
1777 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1778 AC_TRY_RUN([#include <stdio.h>
1779 #include <sys/stat.h>
1780 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1781 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1782 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1783     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1786 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1787 AC_TRY_RUN([
1788 #if defined(HAVE_UNISTD_H)
1789 #include <unistd.h>
1790 #endif
1791 #include <stdio.h>
1792 #include <sys/stat.h>
1793 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1794 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1795 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1796     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1799 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1800 AC_TRY_RUN([
1801 #if defined(HAVE_UNISTD_H)
1802 #include <unistd.h>
1803 #endif
1804 #include <stdio.h>
1805 #include <sys/stat.h>
1806 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1807 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1808 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1809     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1812 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1813 AC_TRY_RUN([
1814 #if defined(HAVE_UNISTD_H)
1815 #include <unistd.h>
1816 #endif
1817 #include <stdio.h>
1818 #include <sys/stat.h>
1819 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1820 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1821 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1822     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1825 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
1826 AC_TRY_RUN([
1827 #if defined(HAVE_UNISTD_H)
1828 #include <unistd.h>
1829 #endif
1830 #include <stdio.h>
1831 #include <sys/stat.h>
1832 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
1833 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
1834 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
1835     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
1838 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1839 AC_TRY_RUN([
1840 #if defined(HAVE_UNISTD_H)
1841 #include <unistd.h>
1842 #endif
1843 #include <stdio.h>
1844 #include <sys/stat.h>
1845 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1846 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1847 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1848     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1851 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
1852 AC_TRY_COMPILE([
1853 #if defined(HAVE_UNISTD_H)
1854 #include <unistd.h>
1855 #endif
1856 #include <sys/types.h>
1857 #include <dirent.h>],
1858 [DIR64 de;],
1859 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
1860 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1861     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
1864 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1865 AC_TRY_COMPILE([
1866 #if defined(HAVE_UNISTD_H)
1867 #include <unistd.h>
1868 #endif
1869 #include <sys/types.h>
1870 #include <dirent.h>],
1871 [struct dirent64 de;],
1872 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1873 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1874     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1877 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1878 AC_TRY_RUN([
1879 #if defined(HAVE_UNISTD_H)
1880 #include <unistd.h>
1881 #endif
1882 #include <sys/types.h>
1883 main() { dev_t dev; int i = major(dev); return 0; }],
1884 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1885 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1886     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1889 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1890 AC_TRY_RUN([
1891 #if defined(HAVE_UNISTD_H)
1892 #include <unistd.h>
1893 #endif
1894 #include <sys/types.h>
1895 main() { dev_t dev; int i = minor(dev); return 0; }],
1896 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1897 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1898     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1901 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1902 AC_TRY_RUN([
1903 #if defined(HAVE_UNISTD_H)
1904 #include <unistd.h>
1905 #endif
1906 #include <sys/types.h>
1907 main() { dev_t dev = makedev(1,2); return 0; }],
1908 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1909 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1910     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1913 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1914 AC_TRY_RUN([#include <stdio.h>
1915 main() { char c; c=250; exit((c > 0)?0:1); }],
1916 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1917 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1918     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1921 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1922 AC_TRY_COMPILE([#include <sys/types.h>
1923 #include <sys/socket.h>
1924 #include <netinet/in.h>],
1925 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1926 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1927 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1928     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1931 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1932 AC_TRY_COMPILE([#include <sys/types.h>
1933 #include <dirent.h>
1934 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1935 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1936 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1937     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1940 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1941 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1942 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1943 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1944     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1947 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1948 AC_TRY_LINK([
1949 #include <sys/time.h>
1950 #include <unistd.h>], [struct timeval tv; return gettimeofday(&tv, NULL);],
1951            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,
1952            samba_cv_HAVE_GETTIMEOFDAY_TZ=no)])
1953 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1954     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday takes a tz argument])
1957 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
1959     # On some systems (eg. Linux) librt can pull in libpthread. We
1960     # don't want this to happen because libpthreads changes signal delivery
1961     # semantics in ways we are not prepared for. This breaks Linux oplocks
1962     # which rely on signals.
1964     AC_LIBTESTFUNC(rt, clock_gettime,
1965             [
1966                             AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
1967                                 [Whether clock_gettime is available])
1968                             SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
1969                             SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
1970                             SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
1971                         ])
1975 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
1976 AC_TRY_RUN([#include <sys/types.h>
1977 #include <dirent.h>
1978 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1979 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1980 di->d_name[0] == 0) exit(0); exit(1);} ],
1981 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
1982 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
1983     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
1986 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1987 AC_TRY_COMPILE([#include <sys/types.h>
1988 #include <utime.h>],
1989 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1990 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1991 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1992     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1995 ##############
1996 # Check utmp details, but only if our OS offers utmp.h
1997 if test x"$ac_cv_header_utmp_h" = x"yes"; then
1998 dnl  utmp and utmpx come in many flavours
1999 dnl  We need to check for many of them
2000 dnl  But we don't need to do each and every one, because our code uses
2001 dnl  mostly just the utmp (not utmpx) fields.
2003 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
2005 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2006 AC_TRY_COMPILE([#include <sys/types.h>
2007 #include <utmp.h>],
2008 [struct utmp ut;  ut.ut_name[0] = 'a';],
2009 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2010 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2011     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2014 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2015 AC_TRY_COMPILE([#include <sys/types.h>
2016 #include <utmp.h>],
2017 [struct utmp ut;  ut.ut_user[0] = 'a';],
2018 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2019 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2020     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2023 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2024 AC_TRY_COMPILE([#include <sys/types.h>
2025 #include <utmp.h>],
2026 [struct utmp ut;  ut.ut_id[0] = 'a';],
2027 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2028 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2029     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2032 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2033 AC_TRY_COMPILE([#include <sys/types.h>
2034 #include <utmp.h>],
2035 [struct utmp ut;  ut.ut_host[0] = 'a';],
2036 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2037 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2038     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2041 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2042 AC_TRY_COMPILE([#include <sys/types.h>
2043 #include <utmp.h>],
2044 [struct utmp ut;  time_t t; ut.ut_time = t;],
2045 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2046 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2047     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2050 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2051 AC_TRY_COMPILE([#include <sys/types.h>
2052 #include <utmp.h>],
2053 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2054 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2055 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2056     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2059 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2060 AC_TRY_COMPILE([#include <sys/types.h>
2061 #include <utmp.h>],
2062 [struct utmp ut;  ut.ut_type = 0;],
2063 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2064 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2065     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2068 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2069 AC_TRY_COMPILE([#include <sys/types.h>
2070 #include <utmp.h>],
2071 [struct utmp ut;  ut.ut_pid = 0;],
2072 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2073 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2074     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2077 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2078 AC_TRY_COMPILE([#include <sys/types.h>
2079 #include <utmp.h>],
2080 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2081 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2082 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2083     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2086 dnl Look for the IPv6 varient by preference. Many systems have both.
2087 AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
2088 AC_TRY_COMPILE([#include <sys/types.h>
2089 #include <utmp.h>],
2090 [struct utmp ut;  ut.ut_addr_v6[0] = 0;],
2091 samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
2092 if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
2093     AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
2096 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2097 AC_TRY_COMPILE([#include <sys/types.h>
2098 #include <utmp.h>],
2099 [struct utmp ut;  ut.ut_addr = 0;],
2100 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2101 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2102     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2105 if test x$ac_cv_func_pututline = xyes ; then
2106   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2107   AC_TRY_COMPILE([#include <sys/types.h>
2108 #include <utmp.h>],
2109   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2110   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2111   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2112       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2113   fi
2116 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2117 AC_TRY_COMPILE([#include <sys/types.h>
2118 #include <utmpx.h>],
2119 [struct utmpx ux;  ux.ut_syslen = 0;],
2120 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2121 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2122     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2126 # end utmp details
2129 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
2130 AC_ARG_WITH(libiconv,
2131 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
2133   if test "$withval" = "no" ; then
2134     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2135   else
2136      if test "$withval" != "yes" ; then
2137         ICONV_PATH_SPEC=yes
2138         ICONV_LOOK_DIRS="$withval"
2139      fi
2140   fi
2143 for i in $ICONV_LOOK_DIRS ; do
2145     save_LIBS="$LIBS"
2146     save_LDFLAGS="$LDFLAGS"
2147     save_CPPFLAGS="$CPPFLAGS"
2149     iconv_current_LIBS=""
2150     iconv_current_LDFLAGS=""
2151     iconv_current_CPPFLAGS=""
2153     ICONV_FOUND="no"
2154     unset libext
2156     #  This is here to handle -withval stuff for --with-libiconv
2157     #  Perhaps we should always add a -L
2158     CPPFLAGS="$save_CPPFLAGS -I$i/include"
2160     # Check lib and lib32 library variants to cater for IRIX ABI-specific
2161     # installation paths. This gets a little tricky since we might have iconv
2162     # in both libiconv and in libc. In this case the jm_ICONV test will always
2163     # succeed when the header is found. To counter this, make sure the
2164     # library directory is there and check the ABI directory first (which
2165     # should be harmless on other systems.
2166     # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2167     for l in "lib32" "lib" "lib/hpux32"; do
2168         if test -d "$i/$l" ; then
2169                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2170                 LIBS=
2171                 export LDFLAGS LIBS CPPFLAGS
2172                 # Try to find iconv(3)
2173                 jm_ICONV($i/$l)
2174                 if test x"$ICONV_FOUND" = "xyes" ; then
2175                     libext="$l"
2176                     break
2177                 fi
2178         fi
2179     done
2181     if test x"$ICONV_FOUND" = "xyes" ; then
2182         iconv_current_LDFLAGS="-L$i/$libext"
2183         iconv_current_CPPFLAGS="-I$i/include"
2185         if test x"$jm_cv_lib_iconv" != x; then
2186             iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
2187         else
2188             # We found iconv in libc.
2189             iconv_current_LIBS=""
2190         fi
2192     fi
2194     if test x"$ICONV_FOUND" = "xyes" ; then
2196         LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
2197         CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
2198         LIBS="$save_LIBS $iconv_current_LIBS"
2199         export LDFLAGS LIBS CPPFLAGS
2201         default_dos_charset=no
2202         default_display_charset=no
2203         default_unix_charset=no
2205         # check for default dos charset name
2206         for j in CP850 IBM850 ; do
2207             rjs_CHARSET($j)
2208             default_dos_charset="$ICONV_CHARSET"
2209             if test x"$default_dos_charset" = x"$j"; then
2210                 break
2211             fi
2212         done
2214         # check for default display charset name
2215         for j in ASCII 646 ; do
2216             rjs_CHARSET($j)
2217             default_display_charset="$ICONV_CHARSET"
2218             if test x"$default_display_charset" = x"$j"; then
2219                 break
2220             fi
2221         done
2223         # check for default unix charset name
2224         for j in UTF-8 UTF8 ; do
2225             rjs_CHARSET($j)
2226             default_unix_charset="$ICONV_CHARSET"
2227             if test x"$default_unix_charset" = x"$j"; then
2228                 break
2229             fi
2230         done
2232         if test "$default_dos_charset" != "no" -a \
2233                 "$default_dos_charset" != "cross" -a \
2234                 "$default_display_charset" != "no" -a \
2235                 "$default_display_charset" != "cross" -a \
2236                 "$default_unix_charset" != "no" -a \
2237                 "$default_unix_charset" != "cross"
2238         then
2239                 samba_cv_HAVE_NATIVE_ICONV=yes
2240         else
2241             if test "$default_dos_charset" = "cross" -o \
2242                      "$default_display_charset" = "cross" -o \
2243                      "$default_unix_charset" = "cross"
2244             then
2245                     samba_cv_HAVE_NATIVE_ICONV=cross
2246             else
2247                     samba_cv_HAVE_NATIVE_ICONV=no
2248             fi
2249         fi
2251         # At this point, we have a libiconv candidate. We know that
2252         # we have the right headers and libraries, but we don't know
2253         # whether it does the conversions we want. We can't test this
2254         # because we are cross-compiling. This is not necessarily a big
2255         # deal, since we can't guarantee that the results we get now will
2256         # match the results we get at runtime anyway.
2257         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
2258             default_dos_charset="CP850"
2259             default_display_charset="ASCII"
2260             default_unix_charset="UTF-8"
2261             samba_cv_HAVE_NATIVE_ICONV=yes
2262             AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
2263             AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
2264         fi
2266         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
2268             CPPFLAGS=$save_CPPFLAGS
2269             LDFLAGS=$save_LDFLAGS
2270             LIBS=$save_LIBS
2272             if test x"$iconv_current_LIBS" != x; then
2273                 LIBS="$LIBS $iconv_current_LIBS"
2274             fi
2276             # Add the flags we need to CPPFLAGS and LDFLAGS
2277             CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
2278             LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
2280             # Turn the #defines into string literals
2281             default_dos_charset="\"$default_dos_charset\""
2282             default_display_charset="\"$default_display_charset\""
2283             default_unix_charset="\"$default_unix_charset\""
2285             AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2286             AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2287             AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2288             AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2290            break
2291         fi
2293     # We didn't find a working iconv, so keep going
2294     fi
2296     #  We only need to clean these up here for the next pass through the loop
2297     CPPFLAGS=$save_CPPFLAGS
2298     LDFLAGS=$save_LDFLAGS
2299     LIBS=$save_LIBS
2300     export LDFLAGS LIBS CPPFLAGS
2301 done
2302 unset libext
2305 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2306     AC_MSG_WARN([Sufficient support for iconv function was not found.
2307     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2308    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2309    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2310    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2314 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2315 AC_TRY_RUN([
2316 #include <sys/types.h>
2317 #include <fcntl.h>
2318 #ifndef F_GETLEASE
2319 #define F_GETLEASE      1025
2320 #endif
2321 main() {
2322        int fd = open("/dev/null", O_RDONLY);
2323        return fcntl(fd, F_GETLEASE, 0) == -1;
2326 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2327 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2328     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2331 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2332 AC_TRY_RUN([
2333 #include <sys/types.h>
2334 #include <fcntl.h>
2335 #include <signal.h>
2336 #ifndef F_NOTIFY
2337 #define F_NOTIFY 1026
2338 #endif
2339 main() {
2340         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2343 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2344 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2345     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2348 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2349 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h)
2350 AC_CHECK_FUNCS(inotify_init)
2351 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2353 samba_cv_HAVE_INOTIFY=yes,
2354 samba_cv_HAVE_INOTIFY=no,
2355 samba_cv_HAVE_INOTIFY=cross)
2357 if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2358     AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
2361 #################################################
2362 # Check if FAM notifications are available. For FAM info, see
2363 #       http://oss.sgi.com/projects/fam/
2364 #       http://savannah.nongnu.org/projects/fam/
2365 AC_ARG_ENABLE(fam,
2366 [AS_HELP_STRING([--enable-fam], [Turn on FAM support (default=auto)])])
2368 if test x$enable_fam != xno; then
2369     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2370     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2371         # On IRIX, libfam requires libC, but other FAM implementations
2372         # might not need it.
2373         AC_CHECK_LIB(fam, FAMOpen2,
2374             [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam"],
2375             [samba_cv_HAVE_LIBFAM=no])
2377         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2378             samba_fam_xtra=-lC
2379             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2380                 [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC"],
2381                 [samba_cv_HAVE_LIBFAM=no])
2382             unset samba_fam_xtra
2383         fi
2384     fi
2386     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2387         default_shared_modules="$default_shared_modules vfs_notify_fam"
2388         AC_TRY_COMPILE([#include <fam.h>],
2389                     [FAMCodes code = FAMChanged;],
2390                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2391                         [Whether fam.h contains a typedef for enum FAMCodes]),
2392                     [])
2393     fi
2395     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2396         AC_MSG_ERROR(FAM support requested but FAM library not available )
2397     fi
2400 AC_SUBST(SMB_FAM_LIBS)
2402 #################################################
2403 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2405 SMB_CHECK_DMAPI([], AC_MSG_NOTICE(DMAPI support not present) )
2407 # Add TSM SM VFS module only if there are both GPFS and DMAPI support
2408 # Theoretically it should work with AIX JFS2 too but this needs testing
2409 if test x"$samba_cv_HAVE_GPFS" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
2410     default_shared_modules="$default_shared_modules vfs_tsmsm"
2413 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2414 AC_TRY_RUN([
2415 #include <sys/types.h>
2416 #include <fcntl.h>
2417 #include <signal.h>
2418 #include <sys/file.h>
2419 #ifndef LOCK_MAND
2420 #define LOCK_MAND       32
2421 #define LOCK_READ       64
2422 #endif
2423 main() {
2424         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2427 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2428 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2429     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2433 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2434 AC_TRY_COMPILE([#include <sys/types.h>
2435 #include <fcntl.h>],
2436 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2437 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2438 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2439     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2442 #################################################
2443 # Check for POSIX capability support
2445 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2446     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2447     [], [])
2449 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2451     ac_save_LIBS=$LIBS
2452     AC_LIBTESTFUNC(cap, cap_get_proc)
2454     AC_CACHE_CHECK([for POSIX capabilities],
2455             samba_cv_HAVE_POSIX_CAPABILITIES,
2456             [
2457                 AC_TRY_RUN([
2458 #include <sys/types.h>
2459 #include <sys/capability.h>
2460 main() {
2461  cap_t cap;
2462  cap_value_t vals[1];
2463  if (!(cap = cap_get_proc()))
2464    exit(1);
2465  vals[0] = CAP_CHOWN;
2466  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2467  cap_set_proc(cap);
2468  exit(0);
2470                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2471                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2472                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2473             ])
2475 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2476     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2477             [Whether POSIX capabilities are available])
2478 else
2479     LIBS=$ac_save_LIBS
2485 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2486 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2489 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2490 AC_TRY_COMPILE([#include <sys/types.h>
2491 #if defined(HAVE_RPC_RPC_H)
2492 #include <rpc/rpc.h>
2493 #endif],
2494 [int16 testvar;],
2495 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2496 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2497     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2500 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2501 AC_TRY_COMPILE([#include <sys/types.h>
2502 #if defined(HAVE_RPC_RPC_H)
2503 #include <rpc/rpc.h>
2504 #endif],
2505 [uint16 testvar;],
2506 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2507 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2508     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2511 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2512 AC_TRY_COMPILE([#include <sys/types.h>
2513 #if defined(HAVE_RPC_RPC_H)
2514 #include <rpc/rpc.h>
2515 #endif],
2516 [int32 testvar;],
2517 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2518 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2519     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2522 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2523 AC_TRY_COMPILE([#include <sys/types.h>
2524 #if defined(HAVE_RPC_RPC_H)
2525 #include <rpc/rpc.h>
2526 #endif],
2527 [uint32 testvar;],
2528 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2529 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2530     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2534 dnl Some systems (SCO) have a problem including
2535 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2536 dnl as a #define in <prot.h> and as part of an enum
2537 dnl in <rpc/rpc.h>.
2540 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2541 AC_TRY_COMPILE([#include <sys/types.h>
2542 #ifdef HAVE_SYS_SECURITY_H
2543 #include <sys/security.h>
2544 #include <prot.h>
2545 #endif  /* HAVE_SYS_SECURITY_H */
2546 #if defined(HAVE_RPC_RPC_H)
2547 #include <rpc/rpc.h>
2548 #endif],
2549 [int testvar;],
2550 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2551 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2552     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2555 AC_MSG_CHECKING([for test routines])
2556 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2557            AC_MSG_RESULT(yes),
2558            AC_MSG_ERROR([cant find test code. Aborting config]),
2559            AC_MSG_WARN([cannot run when cross-compiling]))
2561 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2562 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2563            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2564 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2565     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2568 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2569 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2570            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2571            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2572            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2573 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2574 then
2575     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2578 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2579 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2580            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2581 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2582     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2585 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
2586         AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
2587                 [samba_cv_HAVE_BROKEN_READDIR=no],
2588                         [samba_cv_HAVE_BROKEN_READDIR=yes],
2589                         [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
2591 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
2592 AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
2593         AC_TRY_RUN([
2594 #include "${srcdir-.}/lib/repdir.c"
2595 #include "${srcdir-.}/tests/os2_delete.c"],
2596         samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
2599 if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then
2600         AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
2603 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2604 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2605 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2606 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2607 AC_CHECK_FUNCS(getpagesize)
2609 dnl test for ipv6
2610 AC_CACHE_CHECK([for ipv6 support],samba_cv_HAVE_IPV6,[
2611 AC_TRY_COMPILE([
2612 #include <stdlib.h> /* for NULL */
2613 #include <sys/socket.h>
2614 #include <sys/types.h>
2615 #include <netdb.h>],
2617 struct sockaddr_storage sa_store;
2618 struct addrinfo *ai = NULL;
2619 struct in6_addr in6addr;
2620 int s = socket(AF_INET6, SOCK_STREAM, 0);
2621 int ret = getaddrinfo(NULL, NULL, NULL, &ai);
2622 if (ret != 0) {
2623         const char *es = gai_strerror(ret);
2625 freeaddrinfo(ai);
2627 samba_cv_HAVE_IPV6=yes,samba_cv_HAVE_IPV6=no)])
2628 if test x"$samba_cv_HAVE_IPV6" = x"yes"; then
2629     AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support])
2632 ################################################
2633 # look for a method of setting the effective uid
2634 seteuid=no;
2635 if test $seteuid = no; then
2636 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2637 AC_TRY_RUN([
2638 #define AUTOCONF_TEST 1
2639 #define USE_SETRESUID 1
2640 #include "confdefs.h"
2641 #include "${srcdir-.}/lib/util_sec.c"],
2642            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2643 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2644     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2649 if test $seteuid = no; then
2650 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2651 AC_TRY_RUN([
2652 #define AUTOCONF_TEST 1
2653 #define USE_SETREUID 1
2654 #include "confdefs.h"
2655 #include "${srcdir-.}/lib/util_sec.c"],
2656            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2657 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2658     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2662 if test $seteuid = no; then
2663 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2664 AC_TRY_RUN([
2665 #define AUTOCONF_TEST 1
2666 #define USE_SETEUID 1
2667 #include "confdefs.h"
2668 #include "${srcdir-.}/lib/util_sec.c"],
2669            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2670 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2671     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2675 if test $seteuid = no; then
2676 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2677 AC_TRY_RUN([
2678 #define AUTOCONF_TEST 1
2679 #define USE_SETUIDX 1
2680 #include "confdefs.h"
2681 #include "${srcdir-.}/lib/util_sec.c"],
2682            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2683 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2684     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2688 AC_CACHE_CHECK([for the Darwin initgroups system call],
2689         samba_cv_DARWIN_INITGROUPS,
2690         AC_TRY_LINK([
2691 #include <sys/syscall.h>
2692 #include <unistd.h>
2693         ],
2694         [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
2695         samba_cv_DARWIN_INITGROUPS=yes,
2696         samba_cv_DARWIN_INITGROUPS=no)
2699 if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
2700     AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
2701         [Whether to use the Darwin-specific initgroups system call])
2704 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2705 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2706            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2707 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2708     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2711 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2712 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2713            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2714 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2715     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2717 else
2720 dnl Don't check for 64 bit fcntl locking if we know that the
2721 dnl glibc2.1 broken check has succeeded.
2724   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2725   AC_TRY_RUN([
2726 #if defined(HAVE_UNISTD_H)
2727 #include <unistd.h>
2728 #endif
2729 #include <stdio.h>
2730 #include <stdlib.h>
2732 #ifdef HAVE_FCNTL_H
2733 #include <fcntl.h>
2734 #endif
2736 #ifdef HAVE_SYS_FCNTL_H
2737 #include <sys/fcntl.h>
2738 #endif
2739 main() { struct flock64 fl64;
2740 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2741 exit(0);
2742 #else
2743 exit(1);
2744 #endif
2746        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2748   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2749       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2750   fi
2753 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2754 AC_TRY_COMPILE([#include <sys/types.h>
2755 #include <sys/stat.h>
2756 #include <unistd.h>],
2757 [struct stat st;  st.st_blocks = 0;],
2758 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2759 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2760     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2763 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2764 AC_TRY_COMPILE([#include <sys/types.h>
2765 #include <sys/stat.h>
2766 #include <unistd.h>],
2767 [struct stat st;  st.st_blksize = 0;],
2768 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2769 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2770     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2773 AC_CACHE_CHECK([for st_flags in struct stat],
2774         samba_cv_HAVE_STAT_ST_FLAGS,
2775         [
2776             AC_TRY_COMPILE([#include <sys/types.h>
2777 #include <sys/stat.h>
2778 #include <unistd.h>],
2779             [struct stat st;  st.st_flags = 0;],
2780             samba_cv_HAVE_STAT_ST_FLAGS=yes,
2781             samba_cv_HAVE_STAT_ST_FLAGS=no,
2782             samba_cv_HAVE_STAT_ST_FLAGS=cross)
2783         ])
2785 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
2786     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
2787                 [Whether the stat struct has a st_flags member])
2790 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2791 AC_TRY_COMPILE([
2792 #include <sys/types.h>
2793 #include <sys/acl.h>
2794 #if defined(HAVE_RPCSVC_NIS_H)
2795 #include <rpcsvc/nis.h>
2796 #endif],
2797 [int i;],
2798 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2799 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2800         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2803 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2804 AC_TRY_RUN([
2805 #include <stdio.h>
2806 #include <limits.h>
2807 main() {
2808         char *newpath = realpath("/tmp", NULL);
2809         exit ((newpath != NULL) ? 0 : 1);
2812 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2813 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2814     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2817 #################################################
2818 # check for AFS clear-text auth support
2819 samba_cv_WITH_AFS=no
2820 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2821 AC_ARG_WITH(afs,
2822 [AS_HELP_STRING([--with-afs], [Include AFS clear-text auth support (default=no)])],
2823 [ case "$withval" in
2824   yes|auto)
2825     AC_MSG_RESULT($withval)
2826     samba_cv_WITH_AFS=$withval
2827     ;;
2828   *)
2829     AC_MSG_RESULT(no)
2830     ;;
2831   esac ],
2832   AC_MSG_RESULT(no)
2835 ####################################################
2836 # check for Linux-specific AFS fake-kaserver support
2837 samba_cv_WITH_FAKE_KASERVER=no
2838 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2839 AC_ARG_WITH(fake-kaserver,
2840 [AS_HELP_STRING([--with-fake-kaserver], [Include AFS fake-kaserver support (default=no)])],
2841 [ case "$withval" in
2842   yes|auto)
2843     AC_MSG_RESULT($withval)
2844     samba_cv_WITH_FAKE_KASERVER=$withval
2845     ;;
2846   *)
2847     AC_MSG_RESULT(no)
2848     ;;
2849   esac ],
2850   AC_MSG_RESULT(no)
2853 #################################################
2854 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
2855 if test x"$samba_cv_WITH_AFS" != x"no" ||
2856    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
2858     # see if this box has the afs-headers in /usr/include/afs
2859     AC_MSG_CHECKING(for /usr/include/afs)
2860     if test -d /usr/include/afs; then
2861           CFLAGS="$CFLAGS -I/usr/include/afs"
2862           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
2863           AC_MSG_RESULT(yes)
2864     else
2865       AC_MSG_RESULT(no)
2866     fi
2868     # check for afs.h
2869     have_afs_headers=no
2870     AC_CHECK_HEADERS(afs.h afs/afs.h)
2871     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
2872         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
2873            test x"$samba_cv_WITH_AFS" = x"auto"; then
2874                 AC_MSG_WARN([AFS cannot be supported without afs.h])
2875         else
2876                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
2877         fi
2878     else
2879         have_afs_headers=yes
2880     fi
2883 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
2884     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
2887 #################################################
2888 # check whether to compile AFS/NT ACL mapping module
2889 samba_cv_WITH_VFS_AFSACL=no
2890 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
2891 AC_ARG_WITH(vfs-afsacl,
2892 [AS_HELP_STRING([--with-vfs-afsacl], [Include AFS to NT ACL mapping module (default=no)])],
2893 [ case "$withval" in
2894   yes|auto)
2895     AC_MSG_RESULT($withval)
2896     samba_cv_WITH_VFS_AFSACL=yes
2897     ;;
2898   *)
2899     AC_MSG_RESULT(no)
2900     ;;
2901   esac ],
2902   AC_MSG_RESULT(no)
2905 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
2906    default_shared_modules="$default_shared_modules vfs_afsacl"
2908         
2909 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
2910     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2913 #################################################
2914 # check for the DFS clear-text auth system
2915 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2916 AC_ARG_WITH(dfs,
2917 [AS_HELP_STRING([--with-dce-dfs], [Include DCE/DFS clear-text auth support (default=no)])],
2918 [ case "$withval" in
2919   yes)
2920     AC_MSG_RESULT(yes)
2921     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2922     ;;
2923   *)
2924     AC_MSG_RESULT(no)
2925     ;;
2926   esac ],
2927   AC_MSG_RESULT(no)
2930 ########################################################
2931 # Compile with LDAP support?
2933 with_ldap_support=auto
2934 AC_MSG_CHECKING([for LDAP support])
2936 AC_ARG_WITH(ldap,
2937 [AS_HELP_STRING([--with-ldap], [LDAP support (default yes)])],
2938 [ case "$withval" in
2939     yes|no)
2940         with_ldap_support=$withval
2941         ;;
2942   esac ])
2944 AC_MSG_RESULT($with_ldap_support)
2946 SMBLDAP=""
2947 AC_SUBST(SMBLDAP)
2948 SMBLDAPUTIL=""
2949 AC_SUBST(SMBLDAPUTIL)
2950 LDBLDAP=""
2951 AC_SUBST(LDBLDAP)
2953 if test x"$with_ldap_support" != x"no"; then
2955   ##################################################################
2956   # first test for ldap.h and lber.h
2957   # (ldap.h is required for this test)
2958   AC_CHECK_HEADERS(ldap.h lber.h)
2960   if test x"$ac_cv_header_ldap_h" != x"yes"; then
2961         if test x"$with_ldap_support" = x"yes"; then
2962          AC_MSG_ERROR(ldap.h is needed for LDAP support)
2963         else
2964          AC_MSG_WARN(ldap.h is needed for LDAP support)
2965         fi
2966         
2967         with_ldap_support=no
2968   fi
2970   ##################################################################
2971   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
2972   # unsigned int in include/includes.h
2973   case $host_os in
2974         *hpux*)
2975          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
2976          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
2977         with_ldap_support=yes
2978         ;;
2979         *)
2980         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
2981         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
2982                 if test x"$with_ldap_support" = x"yes"; then
2983                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
2984                 else
2985                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
2986                 fi
2987                 with_ldap_support=no
2988         fi
2989         ;;
2990   esac
2993 if test x"$with_ldap_support" != x"no"; then
2994   ac_save_LIBS=$LIBS
2996   ##################################################################
2997   # we might need the lber lib on some systems. To avoid link errors
2998   # this test must be before the libldap test
2999   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3001   ########################################################
3002   # If ber_sockbuf_add_io() is available we can add
3003   # SASL wrapping hooks
3004   AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
3006   AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
3007                  AC_TRY_COMPILE([#include <ldap.h>],
3008                                 [int val = LDAP_OPT_SOCKBUF;],
3009                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
3010                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
3012   if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
3013           x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
3014         AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
3015   fi
3017   #######################################################
3018   # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
3019   # ldap logging and print it out in the samba logs
3020   AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
3021                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
3022                  [AC_TRY_COMPILE([#include <lber.h>],
3023                                  [int val = LBER_OPT_LOG_PRINT_FN;],
3024                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
3025                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
3027   if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
3028         AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
3029                   [Support for LDAP/LBER logging interception])
3030   fi
3032   ########################################################
3033   # now see if we can find the ldap libs in standard paths
3034   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3036   ########################################################
3037   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3038   # Check found in pam_ldap 145.
3039   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3041   LIBS="$LIBS $LDAP_LIBS"
3042   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3043     AC_TRY_COMPILE([
3044         #include <lber.h>
3045         #include <ldap.h>],
3046         [ldap_set_rebind_proc(0, 0, 0);],
3047         [smb_ldap_cv_ldap_set_rebind_proc=3],
3048         [smb_ldap_cv_ldap_set_rebind_proc=2]
3049     )
3050   ])
3052   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3054   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3056   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3057     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3058     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3059     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3060     default_shared_modules="$default_shared_modules";
3061     SMBLDAP="lib/smbldap.o"
3062     SMBLDAPUTIL="lib/smbldap_util.o"
3063     with_ldap_support=yes
3064     AC_MSG_CHECKING(whether LDAP support is used)
3065     AC_MSG_RESULT(yes)
3066   else
3067     if test x"$with_ldap_support" = x"yes"; then
3068         AC_MSG_ERROR(libldap is needed for LDAP support)
3069     else
3070         AC_MSG_WARN(libldap is needed for LDAP support)
3071     fi
3073     LDAP_LIBS=""
3074     with_ldap_support=no
3075   fi
3076   LIBS=$ac_save_LIBS
3080 #################################################
3081 # active directory support
3083 with_ads_support=auto
3084 AC_MSG_CHECKING([for Active Directory and krb5 support])
3086 AC_ARG_WITH(ads,
3087 [AS_HELP_STRING([--with-ads], [Active Directory support (default auto)])],
3088 [ case "$withval" in
3089     yes|no)
3090         with_ads_support="$withval"
3091         ;;
3092   esac ])
3094 AC_MSG_RESULT($with_ads_support)
3096 FOUND_KRB5=no
3097 KRB5_LIBS=""
3099 if test x"$with_ldap_support" != x"yes"; then
3101     if test x"$with_ads_support" = x"yes"; then
3102         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3103     elif test x"$with_ads_support" = x"auto"; then
3104         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3105         with_ads_support=no
3106     fi
3108 else
3110     # Check to see whether there is enough LDAP functionality to be able
3111     # to build AD support.
3113 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3114 case "$host_os" in
3115         *hpux*)
3116     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3118     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3119         if test x"$with_ads_support" = x"yes"; then
3120             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3121         elif test x"$with_ads_support" = x"auto"; then
3122             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3123             with_ads_support=no
3124         fi
3125     fi
3126     ;;
3127         *)
3128     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3130     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3131         if test x"$with_ads_support" = x"yes"; then
3132             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3133         elif test x"$with_ads_support" = x"auto"; then
3134             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3135             with_ads_support=no
3136         fi
3137     fi
3138     ;;
3139 esac
3142     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3144     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3145         if test x"$with_ads_support" = x"yes"; then
3146             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3147         elif test x"$with_ads_support" = x"auto"; then
3148             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3149             with_ads_support=no
3150         fi
3151     fi
3155 if test x"$with_ads_support" != x"no"; then
3157   # Do no harm to the values of CFLAGS and LIBS while testing for
3158   # Kerberos support.
3160   if test x$FOUND_KRB5 = x"no"; then
3161     #################################################
3162     # check for location of Kerberos 5 install
3163     AC_MSG_CHECKING(for kerberos 5 install path)
3164     AC_ARG_WITH(krb5,
3165     [AS_HELP_STRING([--with-krb5=base-dir], [Locate Kerberos 5 support (default=/usr)])],
3166     [ case "$withval" in
3167       no)
3168         AC_MSG_RESULT(no krb5-path given)
3169         ;;
3170       yes)
3171         AC_MSG_RESULT(/usr)
3172         FOUND_KRB5=yes
3173         ;;
3174       *)
3175         AC_MSG_RESULT($withval)
3176         KRB5_CFLAGS="-I$withval/include"
3177         KRB5_CPPFLAGS="-I$withval/include"
3178         KRB5_LDFLAGS="-L$withval/lib"
3179         FOUND_KRB5=yes
3180         if test -x "$withval/bin/krb5-config"; then
3181                 KRB5CONFIG=$withval/bin/krb5-config
3182         fi
3183         ;;
3184       esac ],
3185       AC_MSG_RESULT(no krb5-path given)
3186     )
3187   fi
3189   #################################################
3190   # check for krb5-config from recent MIT and Heimdal kerberos 5
3191   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3192   AC_MSG_CHECKING(for working krb5-config)
3193   if test -x "$KRB5CONFIG"; then
3194     ac_save_CFLAGS=$CFLAGS
3195     CFLAGS="";export CFLAGS
3196     ac_save_LDFLAGS=$LDFLAGS
3197     LDFLAGS="";export LDFLAGS
3198     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3199     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3200     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3201     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3202     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3203     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3204     FOUND_KRB5=yes
3205     AC_MSG_RESULT(yes)
3206   else
3207     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3208   fi
3210   if test x$FOUND_KRB5 = x"no"; then
3211     #################################################
3212     # see if this box has the SuSE location for the heimdal krb implementation
3213     AC_MSG_CHECKING(for /usr/include/heimdal)
3214     if test -d /usr/include/heimdal; then
3215       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3216           KRB5_CFLAGS="-I/usr/include/heimdal"
3217           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3218           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3219           FOUND_KRB5=yes
3220           AC_MSG_RESULT(yes)
3221       else
3222           KRB5_CFLAGS="-I/usr/include/heimdal"
3223           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3224           FOUND_KRB5=yes
3225           AC_MSG_RESULT(yes)
3226       fi
3227     else
3228       AC_MSG_RESULT(no)
3229     fi
3230   fi
3232   if test x$FOUND_KRB5 = x"no"; then
3233     #################################################
3234     # see if this box has the RedHat location for kerberos
3235     AC_MSG_CHECKING(for /usr/kerberos)
3236     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3237       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3238       KRB5_CFLAGS="-I/usr/kerberos/include"
3239       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3240       FOUND_KRB5=yes
3241       AC_MSG_RESULT(yes)
3242     else
3243       AC_MSG_RESULT(no)
3244     fi
3245   fi
3247   if test x$FOUND_KRB5 = x"no"; then
3248     #################################################
3249     # see if this box has the OpenBSD location for heimdal krb5
3250     AC_MSG_CHECKING(for /usr/include/kerberosV)
3251     if test -d /usr/include/kerberosV; then
3252       KRB5_CPPFLAGS="-I/usr/include/kerberosV"
3253       KRB5_LIBS="-lcrypto"
3254       FOUND_KRB5=yes
3255       AC_MSG_RESULT(yes)
3256     else
3257       AC_MSG_RESULT(no)
3258     fi
3259   fi
3261   ac_save_CFLAGS=$CFLAGS
3262   ac_save_CPPFLAGS=$CPPFLAGS
3263   ac_save_LDFLAGS=$LDFLAGS
3265   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3266   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3267   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3269   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3271   # now check for krb5.h. Some systems have the libraries without the headers!
3272   # note that this check is done here to allow for different kerberos
3273   # include paths
3274   AC_CHECK_HEADERS(krb5.h)
3276   if test x"$ac_cv_header_krb5_h" = x"no"; then
3278     # Give a warning if AD support was not explicitly requested,
3279     # i.e with_ads_support = auto, otherwise die with an error.
3281     if test x"$with_ads_support" = x"yes"; then
3282       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3283     else
3284       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3285     fi
3287     # Turn off AD support and restore CFLAGS and LIBS variables
3289     with_ads_support="no"
3291     CFLAGS=$ac_save_CFLAGS
3292     CPPFLAGS=$ac_save_CPPFLAGS
3293     LDFLAGS=$ac_save_LDFLAGS
3294   fi
3295   AC_CHECK_HEADERS(krb5/locate_plugin.h)
3296   if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
3297         WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
3298         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
3299   fi
3302 # Now we have determined whether we really want ADS support
3303 use_ads=no
3304 if test x"$with_ads_support" != x"no"; then
3305   use_ads=yes
3306   have_gssapi=no
3307   ac_save_LIBS=$LIBS
3309   # now check for gssapi headers.  This is also done here to allow for
3310   # different kerberos include paths
3311   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3313   ##################################################################
3314   # we might need the k5crypto and com_err libraries on some systems
3315   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3316   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3318   # Heimdal checks.
3319   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3320   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3321   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3323   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3324   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3326   ########################################################
3327   # now see if we can find the krb5 libs in standard paths
3328   # or as specified above
3329   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3330   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3332   ########################################################
3333   # now see if we can find the gssapi libs in standard paths
3334   if test x"$have_gssapi" != x"yes"; then
3335      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3336   fi
3338   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3339   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3340   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3341   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3342   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3343   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3344   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3345   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3346   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3347   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3348   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3349   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3350   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3351   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3352   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3353   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3354   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3355   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3356   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3357   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3358   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3359   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3360   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3361   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3362   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3363   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3364   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3365   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3366   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3367   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3368   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3369   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3370   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3371   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3372   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3373   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3374   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3375   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3376   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3377   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3378   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3380   LIBS="$KRB5_LIBS $LIBS"
3382   AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
3383         smb_krb5_ticket_has_keyinfo,
3384         [
3385             AC_TRY_COMPILE(
3386             [
3387                 #include <krb5.h>
3388             ],
3389             [
3390                 krb5_ticket ticket;
3391                 krb5_kvno kvno;
3392                 krb5_enctype enctype;
3394                 enctype = ticket.enc_part.enctype;
3395                 kvno = ticket.enc_part.kvno;
3396             ],
3397             [ smb_krb5_ticket_has_keyinfo=yes ],
3398             [ smb_krb5_ticket_has_keyinfo=no ])
3399         ])
3401   if test x"$smb_krb5_ticket_has_keyinfo" = x"yes" ; then
3402         AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
3403             [Whether the krb5_ticket structure contains the kvno and enctype])
3404   fi
3406   AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
3407           smb_krb5_creds_opt_free_context,
3408           [
3409                 AC_TRY_COMPILE([
3410                     #include <krb5.h>],
3411                     [
3412                         krb5_context ctx;
3413                         krb5_get_init_creds_opt *opt = NULL;
3414                         krb5_get_init_creds_opt_free(ctx, opt);
3415                     ],
3416                     [smb_krb5_creds_opt_free_context=yes],
3417                     [smb_krb5_creds_opt_free_context=no]
3418                 )
3419           ])
3421   if test x"$smb_krb5_creds_opt_free_context" = x"yes" ; then
3422         AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
3423             [Whether krb5_get_init_creds_opt_free takes a context argument])
3424   fi
3426   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
3427     AC_TRY_COMPILE([
3428         #include <krb5.h>],
3429         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
3430         [smb_krb5_verify_checksum=7],
3431         [smb_krb5_verify_checksum=6],
3432     )
3433   ])
3434   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_verify_checksum, [Number of arguments to krb5_verify_checksum])
3436   AC_CACHE_CHECK([for checksum in krb5_checksum],
3437                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3438     AC_TRY_COMPILE([#include <krb5.h>],
3439       [krb5_checksum cksum; cksum.checksum.length = 0;],
3440       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3441       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3443   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3444     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3445                [Whether the krb5_checksum struct has a checksum property])
3446   fi
3448   AC_CACHE_CHECK([for etype in EncryptedData],
3449                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3450     AC_TRY_COMPILE([#include <krb5.h>],
3451       [EncryptedData edata; edata.etype = 0;],
3452       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3453       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3455   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3456     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3457                [Whether the EncryptedData struct has a etype property])
3458   fi
3460   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3461                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3462     AC_TRY_COMPILE([#include <krb5.h>],
3463       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3464       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3465       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3467   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3468     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3469                [Whether the krb5_ap_req struct has a ticket pointer])
3470   fi
3472   AC_CACHE_CHECK([for e_data pointer in krb5_error],
3473                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
3474     AC_TRY_COMPILE([#include <krb5.h>],
3475       [krb5_error err; err.e_data = NULL;],
3476       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
3477       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
3479   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
3480     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
3481                [Whether the krb5_error struct has a e_data pointer])
3482   fi
3484   AC_CACHE_CHECK([for krb5_crypto type],
3485                 samba_cv_HAVE_KRB5_CRYPTO,[
3486     AC_TRY_COMPILE([#include <krb5.h>],
3487       [krb5_crypto crypto;],
3488       samba_cv_HAVE_KRB5_CRYPTO=yes,
3489       samba_cv_HAVE_KRB5_CRYPTO=no)])
3491   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3492     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3493                [Whether the type krb5_crypto exists])
3494   fi
3496   AC_CACHE_CHECK([for krb5_encrypt_block type],
3497                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3498     AC_TRY_COMPILE([#include <krb5.h>],
3499       [krb5_encrypt_block block;],
3500       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3501       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3503   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3504     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3505                [Whether the type krb5_encrypt_block exists])
3506   fi
3508   AC_CACHE_CHECK([for addrtype in krb5_address],
3509                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3510     AC_TRY_COMPILE([#include <krb5.h>],
3511       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3512       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3513       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3515   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3516     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3517                [Whether the krb5_address struct has a addrtype property])
3518   fi
3520   AC_CACHE_CHECK([for addr_type in krb5_address],
3521                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3522     AC_TRY_COMPILE([#include <krb5.h>],
3523       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3524       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3525       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3527   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3528     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3529               [Whether the krb5_address struct has a addr_type property])
3530   fi
3532   AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
3533                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3534                  [AC_TRY_COMPILE([#include <krb5.h>],
3535     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3536     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3538   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3539     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3540               [Whether the krb5_ticket struct has a enc_part2 property])
3541   fi
3543   AC_CACHE_CHECK([for keyblock in krb5_creds],
3544                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3545     AC_TRY_COMPILE([#include <krb5.h>],
3546       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3547       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3548       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
3550   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
3551     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
3552               [Whether the krb5_creds struct has a keyblock property])
3553   fi
3555   AC_CACHE_CHECK([for session in krb5_creds],
3556                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
3557     AC_TRY_COMPILE([#include <krb5.h>],
3558       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
3559       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
3560       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
3562   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
3563     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
3564               [Whether the krb5_creds struct has a session property])
3565   fi
3567   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
3568                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
3569     AC_TRY_COMPILE([#include <krb5.h>],
3570       [krb5_keyblock key; key.keyvalue.data = NULL;],
3571       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
3572       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
3574   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
3575     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
3576               [Whether the krb5_keyblock struct has a keyvalue property])
3577   fi
3579   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
3580                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
3581     AC_TRY_COMPILE([#include <krb5.h>],
3582       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
3583       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
3584       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
3585   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
3586                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
3587     AC_TRY_COMPILE([#include <krb5.h>],
3588       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
3589       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
3590       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
3591 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
3592 # w.r.t. arcfour and windows, so we must not enable it here
3593   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
3594           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
3595     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
3596               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
3597   fi
3599   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
3600                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
3601     AC_TRY_COMPILE([#include <krb5.h>],
3602       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
3603       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
3604       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
3606   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
3607     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
3608               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
3609   fi
3611   AC_CACHE_CHECK([for KV5M_KEYTAB],
3612                  samba_cv_HAVE_KV5M_KEYTAB,[
3613     AC_TRY_COMPILE([#include <krb5.h>],
3614       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
3615       samba_cv_HAVE_KV5M_KEYTAB=yes,
3616       samba_cv_HAVE_KV5M_KEYTAB=no)])
3618   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
3619       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
3620              [Whether the KV5M_KEYTAB option is available])
3621   fi
3623   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
3624                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
3625     AC_TRY_COMPILE([#include <krb5.h>],
3626       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
3627       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
3628       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
3630   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
3631     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
3632               [Whether KRB5_KU_OTHER_CKSUM is available])
3633   fi
3635   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
3636                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
3637     AC_TRY_COMPILE([#include <krb5.h>],
3638       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
3639       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
3640       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
3642   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
3643     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
3644               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
3645   fi
3647   AC_CACHE_CHECK([for the krb5_princ_component macro],
3648                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
3649     AC_TRY_LINK([#include <krb5.h>],
3650       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
3651       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
3652       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
3654   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
3655     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
3656                [Whether krb5_princ_component is available])
3657   fi
3659   AC_CACHE_CHECK([for key in krb5_keytab_entry],
3660                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
3661     AC_TRY_COMPILE([#include <krb5.h>],
3662       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
3663       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
3664       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
3666   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
3667     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
3668               [Whether krb5_keytab_entry has key member])
3669   fi
3671   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
3672                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
3673     AC_TRY_COMPILE([#include <krb5.h>],
3674       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
3675       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
3676       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
3678   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
3679     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
3680               [Whether krb5_keytab_entry has keyblock member])
3681   fi
3683   AC_CACHE_CHECK([for magic in krb5_address],
3684                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
3685     AC_TRY_COMPILE([#include <krb5.h>],
3686       [krb5_address addr; addr.magic = 0;],
3687       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
3688       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
3690   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
3691     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
3692               [Whether the krb5_address struct has a magic property])
3693   fi
3695   AC_CACHE_CHECK([for WRFILE: keytab support],
3696                 samba_cv_HAVE_WRFILE_KEYTAB,[
3697     AC_TRY_RUN([
3698 #include<krb5.h>
3699   main()
3700   {
3701     krb5_context context;
3702     krb5_keytab keytab;
3704     krb5_init_context(&context);
3705     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
3706   }],
3707   samba_cv_HAVE_WRFILE_KEYTAB=yes,
3708   samba_cv_HAVE_WRFILE_KEYTAB=no)])
3710   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
3711       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
3712                [Whether the WRFILE:-keytab is supported])
3713   fi
3715   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
3716                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3717     AC_TRY_COMPILE([#include <krb5.h>],
3718     [
3719     krb5_context context;
3720     krb5_principal principal;
3721     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3722     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3723     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3725   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3726     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3727               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3728   fi
3730   AC_CACHE_CHECK([for krb5_addresses type],
3731                 samba_cv_HAVE_KRB5_ADDRESSES,[
3732     AC_TRY_COMPILE([#include <krb5.h>],
3733       [krb5_addresses addr;],
3734       samba_cv_HAVE_KRB5_ADDRESSES=yes,
3735       samba_cv_HAVE_KRB5_ADDRESSES=no)])
3737   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
3738     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
3739                [Whether the type krb5_addresses type exists])
3740   fi
3742   AC_CACHE_CHECK([whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal],
3743                 samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE, [
3744     AC_TRY_COMPILE([#include <krb5.h>],
3745     [
3746     krb5_mk_error(0,0,0);],
3747     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=yes,
3748     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=no)])
3750   if test x"$samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE" = x"yes"; then
3751     AC_DEFINE(HAVE_SHORT_KRB5_MK_ERROR_INTERFACE,1,
3752               [whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal])
3753   fi
3755   if test x"$ac_cv_func_ext_krb5_enctype_to_string" = x"yes"; then
3756     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_context context, krb5_enctype enctype, char **str)],
3757         smb_krb5_enctype_to_string_takes_krb5_context_arg,[
3758         AC_TRY_RUN_STRICT([
3759                 #include <krb5.h>
3760                 int main(void) {
3761                         krb5_context context = NULL;
3762                         char *str = NULL;
3763                         krb5_enctype_to_string(context, 1, &str);
3764                         if (str) free (str); 
3765                         return 0;
3766                 }
3767                 ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3768                 smb_krb5_enctype_to_string_takes_krb5_context_arg=yes,
3769                 smb_krb5_enctype_to_string_takes_krb5_context_arg=no)])
3771     if test x"$smb_krb5_enctype_to_string_takes_krb5_context_arg" = x"yes"; then
3772       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG,1,
3773                 [whether krb5_enctype_to_string takes krb5_context argument])
3774     fi
3776     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_enctype enctype, char *str, size_t len)],
3777         smb_krb5_enctype_to_string_takes_size_t_arg,[
3778         AC_TRY_RUN_STRICT([
3779                 #include <krb5.h>
3780                 int main(void) {
3781                         char buf[256];
3782                         krb5_enctype_to_string(1, buf, 256);
3783                         return 0;
3784                 }
3785                 ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3786                 smb_krb5_enctype_to_string_takes_size_t_arg=yes,
3787                 smb_krb5_enctype_to_string_takes_size_t_arg=no)])
3789     if test x"$smb_krb5_enctype_to_string_takes_size_t_arg" = x"yes"; then
3790       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG,1,
3791                 [whether krb5_enctype_to_string takes size_t argument])
3792     fi
3793   fi
3795   AC_CACHE_CHECK([for krb5_principal_get_realm],
3796                 samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
3797     AC_TRY_LINK([#include <krb5.h>],
3798       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
3799       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
3800       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
3802   if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
3803     AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
3804                [Whether the function krb5_principal_get_realm is defined])
3805   fi
3807   AC_CACHE_CHECK([for krb5_princ_realm],
3808                 samba_cv_HAVE_KRB5_PRINC_REALM,[
3809     AC_TRY_LINK([#include <krb5.h>],
3810       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
3811       samba_cv_HAVE_KRB5_PRINC_REALM=yes,
3812       samba_cv_HAVE_KRB5_PRINC_REALM=no)])
3814   if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
3815     AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
3816                [Whether the macro krb5_princ_realm is defined])
3817   fi
3819   #
3820   #
3821   # Now the decisions whether we can support krb5
3822   #
3823   # NOTE: all tests should be done before this block!
3824   #
3825   #
3826   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
3827     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
3828     use_ads=no
3829   fi
3831   if test x"$ac_cv_func_ext_krb5_principal2salt" != x"yes" -a \
3832           x"$ac_cv_func_ext_krb5_get_pw_salt" != x"yes"
3833   then
3834     AC_MSG_WARN(no CREATE_KEY_FUNCTIONS detected)
3835     use_ads=no
3836   fi
3838   if test x"$ac_cv_func_ext_krb5_get_permitted_enctypes" != x"yes" -a \
3839           x"$ac_cv_func_ext_krb5_get_default_in_tkt_etypes" != x"yes"
3840   then
3841     AC_MSG_WARN(no GET_ENCTYPES_FUNCTIONS detected)
3842     use_ads=no
3843   fi
3845   if test x"$ac_cv_func_ext_krb5_kt_free_entry" != x"yes" -a \
3846           x"$ac_cv_func_ext_krb5_free_keytab_entry_contents" != x"yes"
3847   then
3848     AC_MSG_WARN(no KT_FREE_FUNCTION detected)
3849     use_ads=no
3850   fi
3852   if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes" -a \
3853           x"$ac_cv_func_ext_krb5_verify_checksum" != x"yes"
3854   then
3855     AC_MSG_WARN(no KRB5_VERIFY_CHECKSUM_FUNCTION detected)
3856     use_ads=no
3857   fi
3859   if test x"$smb_krb5_ticket_has_keyinfo" != x"yes" ; then
3861       # We only need the following functions if we can't get the enctype
3862       # and kvno out of the ticket directly (ie. on Heimdal).
3864       if test x"$ac_cv_func_ext_free_AP_REQ" != x"yes"
3865       then
3866         AC_MSG_WARN(no KRB5_AP_REQ_FREE_FUNCTION detected)
3867         use_ads=no
3868       fi
3870       if test x"$ac_cv_func_ext_krb5_decode_ap_req" != x"yes"
3871       then
3872         AC_MSG_WARN(no KRB5_AP_REQ_DECODING_FUNCTION detected)
3873         use_ads=no
3874       fi
3876   fi
3878   if test x"$use_ads" = x"yes"; then
3879     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
3880     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
3881     if test x"$have_gssapi" = x"yes"; then
3882       AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
3883     fi
3884   else
3885     if test x"$with_ads_support" = x"yes"; then
3886         AC_MSG_ERROR(krb5 libs don't have all features required for Active Directory support)
3887     else
3888         AC_MSG_WARN(krb5 libs don't have all features required for Active Directory support)
3889     fi
3890     AC_REMOVE_DEFINE(HAVE_KRB5_H)
3891     AC_REMOVE_DEFINE(HAVE_GSSAPI_H)
3892     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H)
3893     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_H)
3894     KRB5_LIBS=""
3895     with_ads_support=no
3896   fi
3897   AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
3898   AC_MSG_RESULT([$use_ads])
3900 LIBS="$ac_save_LIBS"
3903 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
3904 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
3907 ########################################################
3908 # Compile with DNS Updates support?
3910 with_dnsupdate_support=no
3911 AC_MSG_CHECKING([whether to enable DNS Updates support])
3913 AC_ARG_WITH(dnsupdate,
3914 [AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default no)])],
3915 [ case "$withval" in
3916     yes|no)
3917         with_dnsupdate_support=$withval
3918         ;;
3919   esac ])
3921 AC_MSG_RESULT($with_dnsupdate_support)
3923 if test x"$with_dnsupdate_support" != x"no"; then
3925   ################################################################
3926   # first test for Active Directory support being enabled
3927   #if test x"$with_ads_support" = x"no"; then
3928   #             AC_MSG_ERROR(Active Directory support is required to enable DNS Update support)
3929   #             with_dnsupdate_support=no
3930   #fi           
3931   ##################################################################
3932   # then test for uuid.h (necessary to generate unique DNS keynames
3933   # (uuid.h is required for this test)
3934   AC_CHECK_HEADERS(uuid/uuid.h)
3936   if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
3937         if test x"$with_dnsupdate_support" = x"yes"; then
3938          AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
3939         else
3940          AC_MSG_WARN(uuid.h is needed to enable DNS Updates support)
3941         fi
3942         with_dnsupdate_support=no
3943   fi
3946 if test x"$with_dnsupdate_support" != x"no"; then
3948   ########################################################
3949   # Now see if we can find the uuid libs in standard paths
3950   # On some systems, the uuid API is in libc, so we have to
3951   # be careful not to insert a spurious -luuid.
3953   UUID_LIBS=""
3954   AC_LIBTESTFUNC(uuid, uuid_generate,
3955           [
3956             case " $LIBS " in
3957                 *\ -luuid\ *)
3958                 UUID_LIBS="-luuid"
3959                 SMB_REMOVE_LIB(uuid)
3960                 ;;
3961             esac
3963             with_dnsupdate_support=yes
3964             AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
3965         ],
3966         [
3967             if test x"$with_dnsupdate_support" = x"yes"; then
3968                 AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
3969             else
3970                 AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
3971             fi
3972             with_dnsupdate_support=no
3973         ])
3976 #################################################
3977 # check for automount support
3978 AC_MSG_CHECKING(whether to use automount)
3979 AC_ARG_WITH(automount,
3980 [AS_HELP_STRING([--with-automount], [Include automount support (default=no)])],
3981 [ case "$withval" in
3982   yes)
3983     AC_MSG_RESULT(yes)
3984     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3985     ;;
3986   *)
3987     AC_MSG_RESULT(no)
3988     ;;
3989   esac ],
3990   AC_MSG_RESULT(no)
3993 #################################################
3994 # check for smbmount support
3995 AC_MSG_CHECKING(whether to use smbmount)
3996 AC_ARG_WITH(smbmount,
3997 [AS_HELP_STRING([--with-smbmount], [Include smbmount (Linux only) support (default=no)])],
3998 [ case "$withval" in
3999   yes)
4000         case "$host_os" in
4001         *linux*)
4002                 AC_MSG_RESULT(yes)
4003                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
4004                 SMBMOUNT_PROGS="bin/smbmount bin/smbmnt bin/smbumount"
4005                 ;;
4006         *)
4007                 AC_MSG_ERROR(not on a linux system!)
4008                 ;;
4009         esac
4010     ;;
4011   *)
4012     AC_MSG_RESULT(no)
4013     ;;
4014   esac ],
4015   AC_MSG_RESULT(no)
4018 #################################################
4019 # check for mount- and umount.cifs support
4020 CIFSMOUNT_PROGS=""
4021 INSTALL_CIFSMOUNT=""
4022 UNINSTALL_CIFSMOUNT=""
4023 AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
4024 AC_ARG_WITH(cifsmount,
4025 [AS_HELP_STRING([--with-cifsmount], [Include mount.cifs and umount.cifs (Linux only) support (default=yes)])],
4026 [ case "$withval" in
4027   no)
4028         AC_MSG_RESULT(no)
4029         ;;
4030   *)
4031         case "$host_os" in
4032         *linux*)
4033                 AC_MSG_RESULT(yes)
4034                 AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
4035                 CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
4036                 INSTALL_CIFSMOUNT="installcifsmount"
4037                 UNINSTALL_CIFSMOUNT="uninstallcifsmount"
4038                 ;;
4039         *)
4040                 AC_MSG_ERROR(not on a linux system!)
4041                 ;;
4042         esac
4043     ;;
4044   esac ],
4045 [ case "$host_os" in
4046   *linux*)
4047         AC_MSG_RESULT(yes)
4048         AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
4049         CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
4050         INSTALL_CIFSMOUNT="installcifsmount"
4051         UNINSTALL_CIFSMOUNT="uninstallcifsmount"
4052         ;;
4053   *)
4054         AC_MSG_RESULT(no)
4055         ;;
4056   esac ]
4059 #################################################
4060 # check for cifs.spnego support
4061 AC_CHECK_HEADERS([keyutils.h], [HAVE_KEYUTILS_H=1], [HAVE_KEYUTILS_H=0])
4062 CIFSSPNEGO_PROGS=""
4063 INSTALL_CIFSSPNEGO=""
4064 UNINSTALL_CIFSSPNEGO=""
4065 AC_MSG_CHECKING(whether to build cifs.spnego)
4066 AC_ARG_WITH(cifsspnego,
4067 [AS_HELP_STRING([--with-cifsspnego], [Include cifs.spnego (Linux only) support (default=no)])],
4068 [ case "$withval" in
4069   no)
4070         AC_MSG_RESULT(no)
4071         ;;
4072   *)
4073         case "$host_os" in
4074         *linux*)
4075                 if test x"$use_ads" != x"yes"; then
4076                         AC_MSG_ERROR(ADS support should be enabled for building cifs.spnego)
4077                 elif test x"$HAVE_KEYUTILS_H" != "x1"; then
4078                         AC_MSG_ERROR(keyutils package is required for cifs.spnego)
4079                 else
4080                         AC_MSG_RESULT(yes)
4081                         AC_DEFINE(WITH_CIFSSPNEGO,1,[whether to build cifs.spnego])
4082                         CIFSSPNEGO_PROGS="bin/cifs.spnego"
4083                         INSTALL_CIFSSPNEGO="installcifsspnego"
4084                         UNINSTALL_CIFSSPNEGO="uninstallcifsspnego"
4085                 fi
4086                 ;;
4087         *)
4088                 AC_MSG_ERROR(not on a linux system!)
4089                 ;;
4090         esac
4091     ;;
4092   esac ],
4094   AC_MSG_RESULT(no)
4095   ]
4099 #################################################
4100 # Check for a PAM clear-text auth, accounts, password
4101 # and session support. Most PAM implementations keep their
4102 # headers in /usr/include/security. Darwin keeps its in
4103 # /usr/include/pam.
4105 with_pam_for_crypt=no
4106 try_pam=no
4107 AC_MSG_CHECKING(whether to try PAM support)
4108 AC_ARG_WITH(pam,
4109 [AS_HELP_STRING([--with-pam], [Include PAM support (default=no)])],
4110 [ case "$withval" in
4111   yes|no)
4112     try_pam=$withval
4113     ;;
4114   esac
4116 AC_MSG_RESULT([$try_pam])
4118 use_pam=no
4119 create_pam_modules=no
4120 if test x"${try_pam}" != x"no";then
4121         use_pam=yes
4122         create_pam_modules=yes
4124         # Most systems have PAM headers in /usr/include/security, but Darwin
4125         # has them in /usr/include/pam.
4126         AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
4127         if test x"$ac_cv_header_security_pam_appl_h" != x"yes" -a \
4128                 x"$ac_cv_header_pam_pam_appl_h" != x"yes"; then
4129                 if test x"${try_pam}" = x"yes";then
4130                         AC_MSG_ERROR([--with-pam=yes but pam_appl.h not found])
4131                 fi
4132                 use_pam=no
4133                 create_pam_modules=no
4134         fi
4136         AC_CHECK_LIB_EXT(pam, PAM_LIBS, pam_get_data)
4137         if test x"$ac_cv_lib_ext_pam_pam_get_data" != x"yes"; then
4138                 if test x"${try_pam}" = x"yes";then
4139                         AC_MSG_ERROR([--with-pam=yes but libpam not found])
4140                 fi
4141                 use_pam=no
4142                 create_pam_modules=no
4143         fi
4145         AC_CHECK_HEADERS(security/pam_modules.h pam/pam_modules.h,,,[[
4146                 #if HAVE_SECURITY_PAM_APPL_H
4147                 #include <security/pam_appl.h>
4148                 #endif
4149                 #if HAVE_PAM_PAM_APPL_H
4150                 #include <pam/pam_appl.h>
4151                 #endif
4152         ]])
4153         if test x"$ac_cv_header_security_pam_modules_h" = x"no" -a \
4154                 x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
4155                 if test x"${try_pam}" = x"yes";then
4156                         AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
4157        fi
4158                 create_pam_modules=no
4159     fi
4161         if test x"$use_pam" = x"yes"; then
4162     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
4163                 AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
4164                 AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
4165     with_pam_for_crypt=yes
4167                 if test x"$create_pam_modules" = x"yes"; then
4168                         AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
4169                         # this checks are optional,
4170                         # we don't care about the results here
4171                         AC_CHECK_HEADERS(security/pam_ext.h security/_pam_macros.h)
4172                         AC_CHECK_HEADERS(pam/pam_ext.h pam/_pam_macros.h)
4173                         AC_CHECK_FUNC_EXT(pam_vsyslog,$PAM_LIBS)
4174                 else
4175                         AC_MSG_WARN([PAM support detected but PAM MODULES support is missing])          
4176                 fi
4177         fi
4178         AC_MSG_CHECKING(whether to use PAM support)
4179         AC_MSG_RESULT([$use_pam])
4181         AC_MSG_CHECKING(whether to have PAM MODULES support)
4182         AC_MSG_RESULT([$create_pam_modules])
4183 fi # try_pam != no
4185 #################################################
4186 # check for pam_smbpass support
4187 PAM_MODULES=""
4188 INSTALL_PAM_MODULES=""
4189 UNINSTALL_PAM_MODULES=""
4190 AC_MSG_CHECKING(whether to use pam_smbpass)
4191 AC_ARG_WITH(pam_smbpass,
4192 [AS_HELP_STRING([--with-pam_smbpass], [Build PAM module for authenticating against passdb backends (default=no)])],
4193 [ case "$withval" in
4194   yes)
4195     AC_MSG_RESULT(yes)
4197        # Conditions under which pam_smbpass should not be built.
4199        if test x"$BLDSHARED" != x"true"; then
4200           AC_MSG_ERROR([No support for shared modules])
4201        elif test x"$create_pam_modules" != x"yes"; then
4202           AC_MSG_ERROR([No support for PAM MODULES])
4203        else
4204           PAM_MODULES="pam_smbpass"
4205           INSTALL_PAM_MODULES="installpammodules"
4206           UNINSTALL_PAM_MODULES="uninstallpammodules"
4207        fi
4208     ;;
4209   *)
4210     AC_MSG_RESULT(no)
4211     ;;
4212   esac ],
4213   AC_MSG_RESULT(no)
4217 ###############################################
4218 # test for where we get crypt() from
4219 AC_SEARCH_LIBS(crypt, [crypt],
4220   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
4221   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
4224 ## moved after the check for -lcrypt in order to
4225 ## ensure that the necessary libraries are included
4226 ## check checking for truncated salt.  Wrapped by the
4227 ## $with_pam_for_crypt variable as above   --jerry
4229 if test $with_pam_for_crypt = no; then
4230 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
4231 crypt_LIBS="$LIBS"
4232 LIBS="$AUTH_LIBS $LIBS"
4233 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
4234         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
4235 LIBS="$crypt_LIBS"])
4236 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
4237         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
4241 #################################################
4242 # check for a NISPLUS_HOME support
4243 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
4244 AC_ARG_WITH(nisplus-home,
4245 [AS_HELP_STRING([--with-nisplus-home], [Include NISPLUS_HOME support (default=no)])],
4246 [ case "$withval" in
4247   yes)
4248     AC_MSG_RESULT(yes)
4249     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
4250     ;;
4251   *)
4252     AC_MSG_RESULT(no)
4253     ;;
4254   esac ],
4255   AC_MSG_RESULT(no)
4258 #################################################
4259 # check for syslog logging
4260 AC_MSG_CHECKING(whether to use syslog logging)
4261 AC_ARG_WITH(syslog,
4262 [AS_HELP_STRING([--with-syslog], [Include experimental SYSLOG support (default=no)])],
4263 [ case "$withval" in
4264   yes)
4265     AC_MSG_RESULT(yes)
4266     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
4267     ;;
4268   *)
4269     AC_MSG_RESULT(no)
4270     ;;
4271   esac ],
4272   AC_MSG_RESULT(no)
4275 #################################################
4276 # check for experimental disk-quotas support
4278 samba_cv_WITH_QUOTAS=auto
4279 samba_cv_TRY_QUOTAS=no
4280 samba_cv_RUN_QUOTA_TESTS=auto
4281 samba_cv_WITH_SYS_QUOTAS=auto
4282 samba_cv_TRY_SYS_QUOTAS=auto
4283 samba_cv_SYSQUOTA_FOUND=no
4285 AC_MSG_CHECKING(whether to try disk-quotas support)
4286 AC_ARG_WITH(quotas,
4287 [AS_HELP_STRING([--with-quotas], [Include disk-quota support (default=no)])],
4288 [ case "$withval" in
4289   yes)
4290     AC_MSG_RESULT(yes)
4291     samba_cv_WITH_QUOTAS=yes
4292     samba_cv_TRY_QUOTAS=yes
4293     samba_cv_RUN_QUOTA_TESTS=yes
4294     #set sys quotas to auto in this case
4295     samba_cv_TRY_SYS_QUOTAS=auto
4296     ;;
4297   auto)
4298     AC_MSG_RESULT(auto)
4299     samba_cv_WITH_QUOTAS=auto
4300     samba_cv_TRY_QUOTAS=auto
4301     samba_cv_RUN_QUOTA_TESTS=auto
4302     #set sys quotas to auto in this case
4303     samba_cv_TRY_SYS_QUOTAS=auto
4304     ;;
4305   no)
4306     AC_MSG_RESULT(no)
4307     samba_cv_WITH_QUOTAS=no
4308     samba_cv_TRY_QUOTAS=no
4309     samba_cv_RUN_QUOTA_TESTS=no
4310     ;;
4311   *)
4312     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4313     ;;
4314   esac ],
4315   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4318 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4319 AC_ARG_WITH(sys-quotas,
4320 [AS_HELP_STRING([--with-sys-quotas], [Include lib/sysquotas.c support (default=auto)])],
4321 [ case "$withval" in
4322   yes)
4323     AC_MSG_RESULT(yes)
4324     samba_cv_WITH_SYS_QUOTAS=yes
4325     samba_cv_TRY_SYS_QUOTAS=yes
4326     samba_cv_RUN_QUOTA_TESTS=yes
4327     ;;
4328   auto)
4329     AC_MSG_RESULT(auto)
4330     samba_cv_WITH_SYS_QUOTAS=auto
4331     samba_cv_TRY_SYS_QUOTAS=auto
4332     samba_cv_RUN_QUOTA_TESTS=auto
4333     ;;
4334   no)
4335     AC_MSG_RESULT(no)
4336     samba_cv_WITH_SYS_QUOTAS=no
4337     samba_cv_TRY_SYS_QUOTAS=no
4338     ;;
4339   *)
4340     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4341     ;;
4342   esac ],
4343   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4346 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4347 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4348   case "$host_os" in
4349         *linux*)
4350             AC_MSG_RESULT(yes)
4351             samba_cv_TRY_SYS_QUOTAS=yes
4352             samba_cv_RUN_QUOTA_TESTS=yes
4353             ;;
4354         *)
4355             AC_MSG_RESULT(no)
4356             samba_cv_TRY_SYS_QUOTAS=no
4357             ;;
4358   esac
4361 #############################################
4362 # only check for quota stuff if --with-quotas
4363 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4365 case "$host_os" in
4366         # on linux we didn't need to test we have builtin support
4367         *linux*)
4368             samba_cv_SYSQUOTA_FOUND=yes
4369             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4370             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4371             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4372             AC_MSG_RESULT(yes)
4374             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4375             samba_cv_found_xfs_header=yes
4376             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4377             AC_MSG_RESULT(yes)
4378             ;;
4379         *solaris*)
4380             # need to set this define when using static linking (BUG 1473)
4381             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4382             ;;
4383         *)
4384             ;;
4385 esac
4387 # some broken header files need this
4388 AC_CHECK_HEADER(asm/types.h,[
4389             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4390             AC_ADD_INCLUDE(<asm/types.h>)
4391             ])
4393 # For quotas on Veritas VxFS filesystems
4394 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4396 # For quotas on Linux XFS filesystems
4397 AC_CHECK_HEADERS(linux/dqblk_xfs.h)
4399 # For sys/quota.h and linux/quota.h
4400 AC_CHECK_HEADERS(sys/quota.h)
4402 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4403 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4404 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4405 AC_TRY_COMPILE([
4406 #include "confdefs.h"
4407 #ifdef HAVE_SYS_TYPES_H
4408 #include <sys/types.h>
4409 #endif
4410 #ifdef HAVE_ASM_TYPES_H
4411 #include <asm/types.h>
4412 #endif
4413 #include <sys/quota.h>
4414 ],[int i = Q_XGETQUOTA;],
4415 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4416 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4417         samba_cv_found_xfs_header=yes
4421 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX
4422 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4423 AC_TRY_COMPILE([
4424 #include "confdefs.h"
4425 #ifdef HAVE_SYS_QUOTA_H
4426 #include <sys/quota.h>
4427 #endif
4429 struct dqblk D;
4430 D.dqb_fsoftlimit = 0;],
4431 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4432 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4433         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
4436 ##################
4437 # look for a working quota system
4439 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4440 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
4441 AC_TRY_RUN_STRICT([
4442 #define HAVE_QUOTACTL_4A 1
4443 #define AUTOCONF_TEST 1
4444 #include "confdefs.h"
4445 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4446            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
4447 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
4448     samba_cv_SYSQUOTA_FOUND=yes;
4449     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
4450     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
4454 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4455 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
4456 AC_TRY_RUN_STRICT([
4457 #define HAVE_QUOTACTL_4B 1
4458 #define AUTOCONF_TEST 1
4459 #include "confdefs.h"
4460 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4461            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
4462 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
4463     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
4464     samba_cv_SYSQUOTA_FOUND=yes;
4465     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
4466     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
4470 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4471 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
4472 AC_TRY_RUN_STRICT([
4473 #define HAVE_QUOTACTL_3 1
4474 #define AUTOCONF_TEST 1
4475 #include "confdefs.h"
4476 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4477            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
4478 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
4479     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
4480     samba_cv_SYSQUOTA_FOUND=yes;
4481     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
4482     samba_cv_sysquotas_file="lib/sysquotas_3.c"
4486 #################################################
4487 # check for mntent.h and struct mntent
4488 AC_CHECK_HEADERS(mntent.h)
4489 #################################################
4490 # check for setmntent,getmntent,endmntent
4491 AC_CHECK_FUNCS(setmntent getmntent endmntent)
4493 #################################################
4494 # check for devnm.h and struct mntent
4495 AC_CHECK_HEADERS(devnm.h)
4496 #################################################
4497 # check for devnm
4498 AC_CHECK_FUNCS(devnm)
4500 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
4501     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4502         # if --with-sys-quotas=yes then build it
4503         # you have can use the get/set quota command smb.conf
4504         # options then
4505         samba_cv_SYSQUOTA_FOUND=auto
4506     fi
4507     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
4508         # if --with-sys-quotas=yes then build it
4509         # you have can use the get/set quota command smb.conf
4510         # options then
4511         samba_cv_TRY_SYS_QUOTAS=auto
4512     fi
4515 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
4516 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
4517 SAVE_CPPFLAGS="$CPPFLAGS"
4518 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4519 AC_TRY_COMPILE([
4520 #include "confdefs.h"
4521 #define NO_PROTO_H 1
4522 #define NO_CONFIG_H 1
4523 #define HAVE_SYS_QUOTAS 1
4524 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
4525 #include "${srcdir-.}/lib/sysquotas.c"
4526 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
4527 CPPFLAGS="$SAVE_CPPFLAGS"
4529 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
4530 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
4531     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
4532         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4533         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
4534         samba_cv_WE_USE_SYS_QUOTAS=yes
4535         AC_MSG_RESULT(yes)
4536     else
4537         AC_MSG_RESULT(no)
4538     fi
4542 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
4543 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
4544 SAVE_CPPFLAGS="$CPPFLAGS"
4545 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4546 AC_TRY_COMPILE([
4547 #include "confdefs.h"
4548 #define NO_PROTO_H 1
4549 #define NO_CONFIG_H 1
4550 #define HAVE_SYS_QUOTAS 1
4551 #define HAVE_XFS_QUOTAS 1
4552 #include "${srcdir-.}/lib/sysquotas_xfs.c"
4553 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
4554 CPPFLAGS="$SAVE_CPPFLAGS"
4556 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
4557     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
4558         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
4559     fi
4563 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
4564 SAVE_CPPFLAGS="$CPPFLAGS"
4565 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4566 AC_TRY_COMPILE([
4567 #include "confdefs.h"
4568 #define NO_PROTO_H 1
4569 #define NO_CONFIG_H 1
4570 #include "${srcdir-.}/smbd/quotas.c"
4571 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
4572 CPPFLAGS="$SAVE_CPPFLAGS"
4574 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
4575 AC_MSG_CHECKING(whether to use the old quota support)
4576     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
4577       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
4578         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4579         AC_MSG_RESULT(yes)
4580       else
4581         AC_MSG_RESULT(no)
4582       fi
4583     else
4584       AC_MSG_RESULT(no)
4585     fi
4588 ####################
4589 # End of quota check samba_cv_RUN_QUOTA_TESTS
4592 #################################################
4593 # check for experimental utmp accounting
4595 AC_MSG_CHECKING(whether to support utmp accounting)
4596 WITH_UTMP=yes
4597 AC_ARG_WITH(utmp,
4598 [AS_HELP_STRING([--with-utmp], [Include utmp accounting (default, if supported by OS)])],
4599 [ case "$withval" in
4600   no)
4601                 WITH_UTMP=no
4602                 ;;
4603   *)
4604                 WITH_UTMP=yes
4605                 ;;
4606   esac ],
4609 # utmp requires utmp.h
4610 # Note similar check earlier, when checking utmp details.
4612 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
4613         utmp_no_reason=", no utmp.h on $host_os"
4614         WITH_UTMP=no
4617 # Display test results
4619 if test x"$WITH_UTMP" = x"yes"; then
4620         AC_MSG_RESULT(yes)
4621         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
4622 else
4623         AC_MSG_RESULT(no$utmp_no_reason)
4626 INSTALLLIBCMD_SH=:
4627 INSTALLLIBCMD_A=:
4628 UNINSTALLLIBCMD_SH=:
4629 UNINSTALLLIBCMD_A=:
4631 if test $BLDSHARED = true; then
4632         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
4633         UNINSTALLLIBCMD_SH="rm -f"
4635 if test $enable_static = yes; then
4636         INSTALLLIBCMD_A="\$(INSTALLCMD)"
4637         UNINSTALLLIBCMD_A="rm -f"
4640 #################################################
4641 # --disable-shared-libs
4642 # can be used to disable the internal use of shared libs altogether
4643 # (this only has an effect when building shared libs is enabled)
4645 USESHARED=false
4646 AC_SUBST(USESHARED)
4648 AC_MSG_CHECKING(whether to use shared libraries internally)
4649 AC_ARG_ENABLE([shared-libs],
4650         AS_HELP_STRING([--enable-shared-libs],
4651                 [Use shared libraries internally (default=yes)]),
4652         [enable_shared_libs=$enableval],
4653         [enable_shared_libs=yes])
4655 if test x"$enable_shared_libs" != x"no" ; then
4656         USESHARED=$BLDSHARED
4659 AC_MSG_RESULT([$USESHARED])
4661 if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
4662         AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
4665 #################################################
4666 # --with-static-libs=LIBS:
4667 #   link (internal) libs dynamically or statically?
4669 # If a subsystem is built as a library then this controls whether they are
4670 # linked into Samba targets statically or dynamically:
4672 # * If we build the shared library at all, we link dynamically by default.
4674 # * We only link statically if we don't build shared or if the library
4675 #   appears in the --with-static-libs configure option.
4677 # Example:
4678 #   --with-static-libs=libtalloc makes use of libtalloc.a instead
4679 #   of linking the dynamic variant with -ltalloc.
4681 # NOTE: This option only affects libraries that we do not only build
4682 # but that samba also links against as libraries (as opposed to linking
4683 # the plain object files. - This has to be configured in Makefile.in.
4684 # So in particular it does not harm to give invalid or unknown names here.
4687 AC_ARG_WITH([static-libs],
4688         [AS_HELP_STRING([--with-static-libs=LIBS],
4689                 [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
4690         [AS_IF([test $withval],
4691                 [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
4692                         [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
4693                         eval LINK_$lib=STATIC
4694                 done], [])],
4695         [])
4698 SMB_LIBRARY(talloc)
4699 SMB_LIBRARY(tdb)
4700 SMB_LIBRARY(netapi)
4703 #################################################
4704 # should we build libaddns?
4705 INSTALL_LIBADDNS=
4706 UNINSTALL_LIBADDNS=
4707 LIBADDNS_SHARED=
4708 LIBADDNS=
4709 AC_MSG_CHECKING(whether to build the libaddns shared library)
4710 AC_ARG_WITH(libaddns,
4711 [AS_HELP_STRING([--with-libaddns], [Build the libaddns shared library (default=no undefined API)])],
4712 [ case "$withval" in
4713   *)
4714      AC_MSG_RESULT(no)
4715      ;;
4716   yes)
4717      if test $BLDSHARED = true; then
4718         LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
4719         LIBADDNS=libaddns
4720         AC_MSG_RESULT(yes)
4721      else
4722         enable_static=yes
4723         AC_MSG_RESULT(no shared library support -- will supply static library)
4724      fi
4725      if test $enable_static = yes; then
4726         LIBADDNS=libaddns
4727      fi
4728      INSTALL_LIBADDNS=installlibaddns
4729      UNINSTALL_LIBADDNS=uninstalllibaddns
4730      ;;
4731   esac ],
4732 [AC_MSG_RESULT(no)]
4735 #################################################
4736 # should we build libsmbclient?
4738 INSTALL_LIBSMBCLIENT=
4739 UNINSTALL_LIBSMBCLIENT=
4740 LIBSMBCLIENT_SHARED=
4741 LIBSMBCLIENT=
4742 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
4743 AC_ARG_WITH(libsmbclient,
4744 [AS_HELP_STRING([--with-libsmbclient], [Build the libsmbclient shared library (default=yes if shared libs supported)])],
4745 [ case "$withval" in
4746   no)
4747      AC_MSG_RESULT(no)
4748      ;;
4749   *)
4750      if test $BLDSHARED = true; then
4751         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4752         LIBSMBCLIENT=libsmbclient
4753         AC_MSG_RESULT(yes)
4754      else
4755         enable_static=yes
4756         AC_MSG_RESULT(no shared library support -- will supply static library)
4757      fi
4758      if test $enable_static = yes; then
4759         LIBSMBCLIENT=libsmbclient
4760      fi
4761      INSTALL_LIBSMBCLIENT=installclientlib
4762      UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4763      ;;
4764   esac ],
4766 # if unspecified, default is to build it if possible.
4767   if test $BLDSHARED = true; then
4768      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4769      LIBSMBCLIENT=libsmbclient
4770      AC_MSG_RESULT(yes)
4771    else
4772      enable_static=yes
4773      AC_MSG_RESULT(no shared library support -- will supply static library)
4774    fi
4775    if test $enable_static = yes; then
4776      LIBSMBCLIENT=libsmbclient
4777   fi]
4778   INSTALL_LIBSMBCLIENT=installclientlib
4779   UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4782 INSTALL_LIBSMBSHAREMODES=
4783 LIBSMBSHAREMODES_SHARED=
4784 LIBSMBSHAREMODES=
4785 AC_MSG_CHECKING(whether to build the libsmbsharemodes shared library)
4786 AC_ARG_WITH(libsmbsharemodes,
4787 [AS_HELP_STRING([--with-libsmbsharemodes], [Build the libsmbsharemodes shared library (default=yes if shared libs supported)])],
4788 [ case "$withval" in
4789   no)
4790      AC_MSG_RESULT(no)
4791      ;;
4792   *)
4793      if test $BLDSHARED = true; then
4794         LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4795         LIBSMBSHAREMODES=libsmbsharemodes
4796         AC_MSG_RESULT(yes)
4797      else
4798         enable_static=yes
4799         AC_MSG_RESULT(no shared library support -- will supply static library)
4800      fi
4801      if test $enable_static = yes; then
4802         LIBSMBSHAREMODES=libsmbsharemodes
4803      fi
4804      INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4805      UNINSTALL_LIBSMBSHAREMODES=uninstalllibsmbsharemodes
4806      ;;
4807   esac ],
4809 # if unspecified, default is to build it if possible.
4810   if test $BLDSHARED = true; then
4811      LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4812      LIBSMBSHAREMODES=libsmbsharemodes
4813      AC_MSG_RESULT(yes)
4814    else
4815      enable_static=yes
4816      AC_MSG_RESULT(no shared library support -- will supply static library)
4817    fi
4818    if test $enable_static = yes; then
4819      LIBSMBSHAREMODES=libsmbsharemodes
4820   fi]
4821   INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4825 #################################################
4826 # these tests are taken from the GNU fileutils package
4827 AC_CHECKING(how to get filesystem space usage)
4828 space=no
4830 # Test for statvfs64.
4831 if test $space = no; then
4832   # SVR4
4833   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
4834   [AC_TRY_RUN([
4835 #if defined(HAVE_UNISTD_H)
4836 #include <unistd.h>
4837 #endif
4838 #include <sys/types.h>
4839 #include <sys/statvfs.h>
4840   main ()
4841   {
4842     struct statvfs64 fsd;
4843     exit (statvfs64 (".", &fsd));
4844   }],
4845   fu_cv_sys_stat_statvfs64=yes,
4846   fu_cv_sys_stat_statvfs64=no,
4847   fu_cv_sys_stat_statvfs64=cross)])
4848   if test $fu_cv_sys_stat_statvfs64 = yes; then
4849     space=yes
4850     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
4851   fi
4854 # Perform only the link test since it seems there are no variants of the
4855 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
4856 # because that got a false positive on SCO OSR5.  Adding the declaration
4857 # of a `struct statvfs' causes this test to fail (as it should) on such
4858 # systems.  That system is reported to work fine with STAT_STATFS4 which
4859 # is what it gets when this test fails.
4860 if test $space = no; then
4861   # SVR4
4862   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
4863                  [AC_TRY_LINK([#include <sys/types.h>
4864 #include <sys/statvfs.h>],
4865                               [struct statvfs fsd; statvfs (0, &fsd);],
4866                               fu_cv_sys_stat_statvfs=yes,
4867                               fu_cv_sys_stat_statvfs=no)])
4868   if test $fu_cv_sys_stat_statvfs = yes; then
4869     space=yes
4870     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
4871   fi
4874 # smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
4875 # This is not the case on ancient Linux systems.
4877 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
4878     AC_TRY_COMPILE([#include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
4879         samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
4880 if test x"$samba_cv_fsid_int" = x"yes"; then
4881     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
4884 if test $space = no; then
4885   # DEC Alpha running OSF/1
4886   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
4887   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
4888   [AC_TRY_RUN([
4889 #include <sys/param.h>
4890 #include <sys/types.h>
4891 #include <sys/mount.h>
4892   main ()
4893   {
4894     struct statfs fsd;
4895     fsd.f_fsize = 0;
4896     exit (statfs (".", &fsd, sizeof (struct statfs)));
4897   }],
4898   fu_cv_sys_stat_statfs3_osf1=yes,
4899   fu_cv_sys_stat_statfs3_osf1=no,
4900   fu_cv_sys_stat_statfs3_osf1=no)])
4901   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
4902   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
4903     space=yes
4904     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
4905   fi
4908 if test $space = no; then
4909 # AIX
4910   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
4911 member (AIX, 4.3BSD)])
4912   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
4913   [AC_TRY_RUN([
4914 #ifdef HAVE_SYS_PARAM_H
4915 #include <sys/param.h>
4916 #endif
4917 #ifdef HAVE_SYS_MOUNT_H
4918 #include <sys/mount.h>
4919 #endif
4920 #ifdef HAVE_SYS_VFS_H
4921 #include <sys/vfs.h>
4922 #endif
4923   main ()
4924   {
4925   struct statfs fsd;
4926   fsd.f_bsize = 0;
4927   exit (statfs (".", &fsd));
4928   }],
4929   fu_cv_sys_stat_statfs2_bsize=yes,
4930   fu_cv_sys_stat_statfs2_bsize=no,
4931   fu_cv_sys_stat_statfs2_bsize=no)])
4932   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
4933   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
4934     space=yes
4935     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
4936   fi
4939 if test $space = no; then
4940 # SVR3
4941   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
4942   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
4943   [AC_TRY_RUN([#include <sys/types.h>
4944 #include <sys/statfs.h>
4945   main ()
4946   {
4947   struct statfs fsd;
4948   exit (statfs (".", &fsd, sizeof fsd, 0));
4949   }],
4950     fu_cv_sys_stat_statfs4=yes,
4951     fu_cv_sys_stat_statfs4=no,
4952     fu_cv_sys_stat_statfs4=no)])
4953   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
4954   if test $fu_cv_sys_stat_statfs4 = yes; then
4955     space=yes
4956     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
4957   fi
4960 if test $space = no; then
4961 # 4.4BSD and NetBSD
4962   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
4963 member (4.4BSD and NetBSD)])
4964   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
4965   [AC_TRY_RUN([#include <sys/types.h>
4966 #ifdef HAVE_SYS_PARAM_H
4967 #include <sys/param.h>
4968 #endif
4969 #ifdef HAVE_SYS_MOUNT_H
4970 #include <sys/mount.h>
4971 #endif
4972   main ()
4973   {
4974   struct statfs fsd;
4975   fsd.f_fsize = 0;
4976   exit (statfs (".", &fsd));
4977   }],
4978   fu_cv_sys_stat_statfs2_fsize=yes,
4979   fu_cv_sys_stat_statfs2_fsize=no,
4980   fu_cv_sys_stat_statfs2_fsize=no)])
4981   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
4982   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
4983     space=yes
4984         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
4985   fi
4988 if test $space = no; then
4989   # Ultrix
4990   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
4991   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
4992   [AC_TRY_RUN([#include <sys/types.h>
4993 #ifdef HAVE_SYS_PARAM_H
4994 #include <sys/param.h>
4995 #endif
4996 #ifdef HAVE_SYS_MOUNT_H
4997 #include <sys/mount.h>
4998 #endif
4999 #ifdef HAVE_SYS_FS_TYPES_H
5000 #include <sys/fs_types.h>
5001 #endif
5002   main ()
5003   {
5004   struct fs_data fsd;
5005   /* Ultrix's statfs returns 1 for success,
5006      0 for not mounted, -1 for failure.  */
5007   exit (statfs (".", &fsd) != 1);
5008   }],
5009   fu_cv_sys_stat_fs_data=yes,
5010   fu_cv_sys_stat_fs_data=no,
5011   fu_cv_sys_stat_fs_data=no)])
5012   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
5013   if test $fu_cv_sys_stat_fs_data = yes; then
5014     space=yes
5015     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
5016   fi
5020 # As a gating factor for large file support, in order to
5021 # use <4GB files we must have the following minimal support
5022 # available.
5023 # long long, and a 64 bit off_t or off64_t.
5024 # If we don't have all of these then disable large
5025 # file support.
5027 AC_MSG_CHECKING([if large file support can be enabled])
5028 AC_TRY_COMPILE([
5029 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
5030 #include <sys/types.h>
5031 #else
5032 __COMPILE_ERROR_
5033 #endif
5035 [int i],
5036 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
5037 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
5038         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
5040 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
5042 #################################################
5043 # check for cluster extensions
5045 AC_MSG_CHECKING(whether to include cluster support)
5046 AC_ARG_WITH(cluster-support,
5047 [AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=no)])])
5048 if test "x$with_cluster_support" = "xyes"; then
5049     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
5050     AC_MSG_RESULT(yes)
5051 else
5052     AC_MSG_RESULT(no)
5056 #################################################
5057 # check for ACL support
5059 AC_MSG_CHECKING(whether to support ACLs)
5060 AC_ARG_WITH(acl-support,
5061 [AS_HELP_STRING([--with-acl-support], [Include ACL support (default=auto)])],
5062 [ case "$withval" in
5063         yes|no)
5064                 with_acl_support="$withval"
5065                 ;;
5066   esac ])
5068 if test x"$with_acl_support" = x ; then
5069         with_acl_support="auto"
5072 AC_MSG_RESULT($with_acl_support)
5074 if test x"$with_acl_support" = x"no"; then
5075         AC_MSG_RESULT(Disabling ACL support)
5076         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
5077 else
5078         AC_MSG_NOTICE(checking whether ACL support is available:)
5079         case "$host_os" in
5080         *sysv5*)
5081                 AC_MSG_NOTICE(Using UnixWare ACLs)
5082                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
5083                 default_static_modules="$default_static_modules vfs_solarisacl"
5084                 ;;
5085         *solaris*)
5086                 AC_MSG_NOTICE(Using solaris ACLs)
5087                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
5088                 ACL_LIBS="$ACL_LIBS -lsec"
5089                 default_static_modules="$default_static_modules vfs_solarisacl"
5090                 ;;
5091         *hpux*)
5092                 AC_MSG_NOTICE(Using HPUX ACLs)
5093                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
5094                 default_static_modules="$default_static_modules vfs_hpuxacl"
5095                 ;;
5096         *irix*)
5097                 AC_MSG_NOTICE(Using IRIX ACLs)
5098                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
5099                 default_static_modules="$default_static_modules vfs_irixacl"
5100                 ;;
5101         *aix*)
5102                 AC_MSG_NOTICE(Using AIX ACLs)
5103                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
5104                 default_static_modules="$default_static_modules vfs_aixacl"
5105                 ;;
5106         *osf*)
5107                 AC_MSG_NOTICE(Using Tru64 ACLs)
5108                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
5109                 ACL_LIBS="$ACL_LIBS -lpacl"
5110                 default_static_modules="$default_static_modules vfs_tru64acl"
5111                 ;;
5112         *darwin*)
5113                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
5114                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5115                 ;;
5116         *)
5117                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
5118                 case "$host_os" in
5119                 *linux*)
5120                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
5121                         ;;
5122                 esac
5123                 AC_CACHE_CHECK([for POSIX ACL support],samba_cv_HAVE_POSIX_ACLS,[
5124                         acl_LIBS=$LIBS
5125                         LIBS="$LIBS $ACL_LIBS"
5126                         AC_TRY_LINK([
5127                                 #include <sys/types.h>
5128                                 #include <sys/acl.h>
5129                         ],[
5130                                 acl_t acl;
5131                                 int entry_id;
5132                                 acl_entry_t *entry_p;
5133                                 return acl_get_entry(acl, entry_id, entry_p);
5134                         ],
5135                         [samba_cv_HAVE_POSIX_ACLS=yes],
5136                         [samba_cv_HAVE_POSIX_ACLS=no])
5137                         LIBS=$acl_LIBS
5138                 ])
5139                 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
5140                         AC_MSG_NOTICE(Using posix ACLs)
5141                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
5142                         AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
5143                                 acl_LIBS=$LIBS
5144                                 LIBS="$LIBS $ACL_LIBS"
5145                                 AC_TRY_LINK([
5146                                         #include <sys/types.h>
5147                                         #include <sys/acl.h>
5148                                 ],[
5149                                         acl_permset_t permset_d;
5150                                         acl_perm_t perm;
5151                                         return acl_get_perm_np(permset_d, perm);
5152                                 ],
5153                                 [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
5154                                 [samba_cv_HAVE_ACL_GET_PERM_NP=no])
5155                                 LIBS=$acl_LIBS
5156                         ])
5157                         if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
5158                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
5159                         fi
5160                         default_static_modules="$default_static_modules vfs_posixacl"
5161                 else
5162                         AC_MSG_NOTICE(ACL support is not avaliable)
5163                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5164                 fi
5165                 ;;
5166         esac
5167 fi # with_acl_support
5171 #################################################
5172 # check for AIO support
5174 AC_MSG_CHECKING(whether to support asynchronous io)
5175 AC_ARG_WITH(aio-support,
5176 [AS_HELP_STRING([--with-aio-support], [Include asynchronous io support (default=no)])],
5177 [ case "$withval" in
5178   yes)
5180         AC_MSG_RESULT(yes)
5181         case "$host_os" in
5182         *)
5183                 AIO_LIBS=$LIBS
5184                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
5185                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
5186                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
5187                 aio_LIBS=$LIBS
5188                 LIBS=$AIO_LIBS
5189                 AC_TRY_LINK([#include <sys/types.h>
5190 #include <aio.h>],
5191 [ struct aiocb a; return aio_read(&a);],
5192 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
5193                 LIBS=$aio_LIBS])
5194                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
5195                 aio_LIBS=$LIBS
5196                 LIBS=$AIO_LIBS
5197                 AC_TRY_LINK([#include <sys/types.h>
5198 #include <aio.h>],
5199 [ struct aiocb64 a; return aio_read64(&a);],
5200 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
5201                 LIBS=$aio_LIBS])
5202                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5203                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
5204                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5205                         LIBS=$AIO_LIBS
5206                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
5207                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5208                         LIBS=$AIO_LIBS
5209                 fi
5211                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5212                         AC_MSG_CHECKING(for aio_read)
5213                         AC_LINK_IFELSE([#include <aio.h>
5214 int main() { struct aiocb a; return aio_read(&a); }],
5215 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
5216 [AC_MSG_RESULT(no)])
5218                         AC_MSG_CHECKING(for aio_write)
5219                         AC_LINK_IFELSE([#include <aio.h>
5220 int main() { struct aiocb a; return aio_write(&a); }],
5221 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
5222 [AC_MSG_RESULT(no)])
5224                         AC_MSG_CHECKING(for aio_fsync)
5225                         AC_LINK_IFELSE([#include <aio.h>
5226 int main() { struct aiocb a; return aio_fsync(1, &a); }],
5227 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
5228 [AC_MSG_RESULT(no)])
5230                         AC_MSG_CHECKING(for aio_return)
5231                         AC_LINK_IFELSE([#include <aio.h>
5232 int main() { struct aiocb a; return aio_return(&a); }],
5233 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
5234 [AC_MSG_RESULT(no)])
5236                         AC_MSG_CHECKING(for aio_error)
5237                         AC_LINK_IFELSE([#include <aio.h>
5238 int main() { struct aiocb a; return aio_error(&a); }],
5239 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
5240 [AC_MSG_RESULT(no)])
5242                         AC_MSG_CHECKING(for aio_cancel)
5243                         AC_LINK_IFELSE([#include <aio.h>
5244 int main() { struct aiocb a; return aio_cancel(1, &a); }],
5245 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
5246 [AC_MSG_RESULT(no)])
5248                         AC_MSG_CHECKING(for aio_suspend)
5249                         AC_LINK_IFELSE([#include <aio.h>
5250 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
5251 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
5252 [AC_MSG_RESULT(no)])
5253                 fi
5255                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5256                         AC_MSG_CHECKING(for aio_read64)
5257                         AC_LINK_IFELSE([#include <aio.h>
5258 int main() { struct aiocb a; return aio_read64(&a); }],
5259 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
5260 [AC_MSG_RESULT(no)])
5262                         AC_MSG_CHECKING(for aio_write64)
5263                         AC_LINK_IFELSE([#include <aio.h>
5264 int main() { struct aiocb a; return aio_write64(&a); }],
5265 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
5266 [AC_MSG_RESULT(no)])
5268                         AC_MSG_CHECKING(for aio_fsync64)
5269                         AC_LINK_IFELSE([#include <aio.h>
5270 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
5271 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
5272 [AC_MSG_RESULT(no)])
5274                         AC_MSG_CHECKING(for aio_return64)
5275                         AC_LINK_IFELSE([#include <aio.h>
5276 int main() { struct aiocb a; return aio_return64(&a); }],
5277 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
5278 [AC_MSG_RESULT(no)])
5280                         AC_MSG_CHECKING(for aio_error64)
5281                         AC_LINK_IFELSE([#include <aio.h>
5282 int main() { struct aiocb a; return aio_error64(&a); }],
5283 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
5284 [AC_MSG_RESULT(no)])
5286                         AC_MSG_CHECKING(for aio_cancel64)
5287                         AC_LINK_IFELSE([#include <aio.h>
5288 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
5289 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
5290 [AC_MSG_RESULT(no)])
5292                         AC_MSG_CHECKING(for aio_suspend64)
5293                         AC_LINK_IFELSE([#include <aio.h>
5294 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
5295 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
5296 [AC_MSG_RESULT(no)])
5297                 fi
5298             ;;
5299         esac
5300         ;;
5301   *)
5302     AC_MSG_RESULT(no)
5303     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
5304     ;;
5305   esac ],
5306   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
5307   AC_MSG_RESULT(no)
5310 #################################################
5311 # check for sendfile support
5313 with_sendfile_support=yes
5314 AC_MSG_CHECKING(whether to check to support sendfile)
5315 AC_ARG_WITH(sendfile-support,
5316 [AS_HELP_STRING([--with-sendfile-support], [Check for sendfile support (default=yes)])],
5317 [ case "$withval" in
5318   yes)
5320         AC_MSG_RESULT(yes);
5322         case "$host_os" in
5323         *linux*)
5324                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5325                 AC_TRY_LINK([#include <sys/sendfile.h>],
5327 int tofd, fromfd;
5328 off64_t offset;
5329 size_t total;
5330 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
5332 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5334                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
5335                 AC_TRY_LINK([#include <sys/sendfile.h>],
5337 int tofd, fromfd;
5338 off_t offset;
5339 size_t total;
5340 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5342 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5344 # Try and cope with broken Linux sendfile....
5345                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
5346                 AC_TRY_LINK([\
5347 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5348 #undef _FILE_OFFSET_BITS
5349 #endif
5350 #include <sys/sendfile.h>],
5352 int tofd, fromfd;
5353 off_t offset;
5354 size_t total;
5355 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5357 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5359         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5360                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5361                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5362                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5363         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5364                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5365                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5366                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5367         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5368                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5369                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5370         else
5371                 AC_MSG_RESULT(no);
5372         fi
5374         ;;
5375         *freebsd* | *dragonfly* )
5376                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5377                 AC_TRY_LINK([\
5378 #include <sys/types.h>
5379 #include <unistd.h>
5380 #include <sys/socket.h>
5381 #include <sys/uio.h>],
5383         int fromfd, tofd, ret, total=0;
5384         off_t offset, nwritten;
5385         struct sf_hdtr hdr;
5386         struct iovec hdtrl;
5387         hdr.headers = &hdtrl;
5388         hdr.hdr_cnt = 1;
5389         hdr.trailers = NULL;
5390         hdr.trl_cnt = 0;
5391         hdtrl.iov_base = NULL;
5392         hdtrl.iov_len = 0;
5393         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
5395 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5397         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5398                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
5399                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
5400                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5401         else
5402                 AC_MSG_RESULT(no);
5403         fi
5404         ;;
5406         *hpux*)
5407                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5408                 AC_TRY_LINK([\
5409 #include <sys/socket.h>
5410 #include <sys/uio.h>],
5412         int fromfd, tofd;
5413         size_t total=0;
5414         struct iovec hdtrl[2];
5415         ssize_t nwritten;
5416         off64_t offset;
5418         hdtrl[0].iov_base = 0;
5419         hdtrl[0].iov_len = 0;
5421         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
5423 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5424         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5425                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
5426                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5427                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5428         else
5429                 AC_MSG_RESULT(no);
5430         fi
5432                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
5433                 AC_TRY_LINK([\
5434 #include <sys/socket.h>
5435 #include <sys/uio.h>],
5437         int fromfd, tofd;
5438         size_t total=0;
5439         struct iovec hdtrl[2];
5440         ssize_t nwritten;
5441         off_t offset;
5443         hdtrl[0].iov_base = 0;
5444         hdtrl[0].iov_len = 0;
5446         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
5448 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5449         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5450                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5451                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5452                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5453         else
5454                 AC_MSG_RESULT(no);
5455         fi
5456         ;;
5458         *solaris*)
5459                 AC_CHECK_LIB(sendfile,sendfilev)
5460                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
5461                 AC_TRY_LINK([\
5462 #include <sys/sendfile.h>],
5464         int sfvcnt;
5465         size_t xferred;
5466         struct sendfilevec vec[2];
5467         ssize_t nwritten;
5468         int tofd;
5470         sfvcnt = 2;
5472         vec[0].sfv_fd = SFV_FD_SELF;
5473         vec[0].sfv_flag = 0;
5474         vec[0].sfv_off = 0;
5475         vec[0].sfv_len = 0;
5477         vec[1].sfv_fd = 0;
5478         vec[1].sfv_flag = 0;
5479         vec[1].sfv_off = 0;
5480         vec[1].sfv_len = 0;
5481         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
5483 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
5485         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
5486                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
5487                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
5488                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5489         else
5490                 AC_MSG_RESULT(no);
5491         fi
5493                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
5494                 AC_TRY_LINK([\
5495 #include <sys/sendfile.h>],
5497         int sfvcnt;
5498         size_t xferred;
5499         struct sendfilevec vec[2];
5500         ssize_t nwritten;
5501         int tofd;
5503         sfvcnt = 2;
5505         vec[0].sfv_fd = SFV_FD_SELF;
5506         vec[0].sfv_flag = 0;
5507         vec[0].sfv_off = 0;
5508         vec[0].sfv_len = 0;
5510         vec[1].sfv_fd = 0;
5511         vec[1].sfv_flag = 0;
5512         vec[1].sfv_off = 0;
5513         vec[1].sfv_len = 0;
5514         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
5516 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
5518         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
5519                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
5520                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
5521                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5522         else
5523                 AC_MSG_RESULT(no);
5524         fi
5525         ;;
5526         *aix*)
5527                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
5528                 AC_TRY_LINK([\
5529 #include <sys/socket.h>],
5531         int fromfd, tofd;
5532         size_t total=0;
5533         struct sf_parms hdtrl;
5534         ssize_t nwritten;
5535         off64_t offset;
5537         hdtrl.header_data = 0;
5538         hdtrl.header_length = 0;
5539         hdtrl.file_descriptor = fromfd;
5540         hdtrl.file_offset = 0;
5541         hdtrl.file_bytes = 0;
5542         hdtrl.trailer_data = 0;
5543         hdtrl.trailer_length = 0;
5545         nwritten = send_file(&tofd, &hdtrl, 0);
5547 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5548         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5549                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5550                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
5551                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5552         else
5553                 AC_MSG_RESULT(no);
5554         fi
5555         ;;
5556         *)
5557         ;;
5558         esac
5559         ;;
5560   *)
5561     AC_MSG_RESULT(no)
5562     ;;
5563   esac ],
5564   AC_MSG_RESULT(yes)
5567 ############################################
5568 # See if we have the Linux readahead syscall.
5570 AC_CACHE_CHECK([for Linux readahead],
5571                 samba_cv_HAVE_LINUX_READAHEAD,[
5572     AC_TRY_LINK([
5573 #if defined(HAVE_UNISTD_H)
5574 #include <unistd.h>
5575 #endif
5576 #include <fcntl.h>],
5577     [ssize_t err = readahead(0,0,0x80000);],
5578     samba_cv_HAVE_LINUX_READAHEAD=yes,
5579     samba_cv_HAVE_LINUX_READAHEAD=no)])
5581 if test x"$samba_cv_HAVE_LINUX_READAHEAD" = x"yes"; then
5582   AC_DEFINE(HAVE_LINUX_READAHEAD,1,
5583              [Whether Linux readahead is available])
5586 AC_HAVE_DECL(readahead, [#include <fcntl.h>])
5588 ############################################
5589 # See if we have the posix_fadvise syscall.
5591 AC_CACHE_CHECK([for posix_fadvise],
5592                 samba_cv_HAVE_POSIX_FADVISE,[
5593     AC_TRY_LINK([
5594 #if defined(HAVE_UNISTD_H)
5595 #include <unistd.h>
5596 #endif
5597 #include <fcntl.h>],
5598     [ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);],
5599     samba_cv_HAVE_POSIX_FADVISE=yes,
5600     samba_cv_HAVE_POSIX_FADVISE=no)])
5602 if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
5603   AC_DEFINE(HAVE_POSIX_FADVISE,1,
5604              [Whether posix_fadvise is available])
5609 #################################################
5610 # Check whether winbind is supported on this platform.  If so we need to
5611 # build and install client programs, sbin programs and shared libraries
5613 AC_MSG_CHECKING(whether to build winbind)
5615 # Initially, the value of $host_os decides whether winbind is supported
5617 HAVE_WINBIND=yes
5619 # Define the winbind shared library name and any specific linker flags
5620 # it needs to be built with.
5622 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
5623 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
5624 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
5625 NSSSONAMEVERSIONSUFFIX=""
5626 WINBIND_NSS_PTHREAD=""
5628 case "$host_os" in
5629         *linux*)
5630                 NSSSONAMEVERSIONSUFFIX=".2"
5631                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
5632                 ;;
5633         *freebsd[[5-9]]*)
5634                 # FreeBSD winbind client is implemented as a wrapper around
5635                 # the Linux version.
5636                 NSSSONAMEVERSIONSUFFIX=".1"
5637                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
5638                     nsswitch/winbind_nss_linux.o"
5639                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
5640                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
5641                 ;;
5643         *netbsd*[[3-9]]*)
5644                 # NetBSD winbind client is implemented as a wrapper
5645                 # around the Linux version. It needs getpwent_r() to
5646                 # indicate libc's use of the correct nsdispatch API.
5647                 #
5648                 if test x"$ac_cv_func_getpwent_r" = x"yes"; then
5649                         WINBIND_NSS_EXTRA_OBJS="\
5650                             nsswitch/winbind_nss_netbsd.o \
5651                             nsswitch/winbind_nss_linux.o"
5652                         WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
5653                         WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
5654                 else
5655                         HAVE_WINBIND=no
5656                         winbind_no_reason=", getpwent_r is missing on $host_os so winbind is unsupported"
5657                 fi
5658                 ;;
5659         *irix*)
5660                 # IRIX has differently named shared libraries
5661                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
5662                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
5663                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
5664                 ;;
5665         *solaris*)
5666                 # Solaris winbind client is implemented as a wrapper around
5667                 # the Linux version.
5668                 NSSSONAMEVERSIONSUFFIX=".1"
5669                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
5670                     nsswitch/winbind_nss_linux.o"
5671                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
5672                 ;;
5673         *hpux11*)
5674                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
5675                 ;;
5676         *aix*)
5677                 # AIX has even differently named shared libraries.  No
5678                 # WINS support has been implemented yet.
5679                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
5680                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
5681                 WINBIND_NSS="nsswitch/WINBIND"
5682                 WINBIND_WINS_NSS=""
5683                 ;;
5684         *)
5685                 HAVE_WINBIND=no
5686                 winbind_no_reason=", unsupported on $host_os"
5687                 ;;
5688 esac
5690 # Check the setting of --with-winbind
5692 AC_ARG_WITH(winbind,
5693 [AS_HELP_STRING([--with-winbind], [Build winbind (default, if supported by OS)])],
5695   case "$withval" in
5696         yes)
5697                 HAVE_WINBIND=yes
5698                 ;;
5699         no)
5700                 HAVE_WINBIND=no
5701                 winbind_reason=""
5702                 ;;
5703   esac ],
5706 # We need unix domain sockets for winbind
5708 if test x"$HAVE_WINBIND" = x"yes"; then
5709         if test x"$samba_cv_unixsocket" = x"no"; then
5710                 winbind_no_reason=", no unix domain socket support on $host_os"
5711                 HAVE_WINBIND=no
5712         fi
5715 # Display test results
5717 if test x"$HAVE_WINBIND" = x"no"; then
5718         WINBIND_NSS=""
5719         WINBIND_WINS_NSS=""
5722 if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
5723         BUILD_LIBWBCLIENT_SHARED=no
5724 else
5725         BUILD_LIBWBCLIENT_SHARED=yes
5728 if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
5729         NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
5730         ## Only worry about libwbclient if we have shared library support
5731         ## and winbindd
5732         LIBWBCLIENT_SHARED=bin/libwbclient.$SHLIBEXT
5733         LIBWBCLIENT=libwbclient
5734         INSTALL_LIBWBCLIENT=installlibwbclient
5735         UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
5736         WINBIND_LIBS="-lwbclient"
5737 else
5738         LIBWBCLIENT_STATIC=bin/libwbclient.a
5741 if test x"$HAVE_WINBIND" = x"yes"; then
5742         AC_MSG_RESULT(yes)
5743         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
5745         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
5746         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
5747         if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
5748                 PAM_MODULES="$PAM_MODULES pam_winbind"
5749                 INSTALL_PAM_MODULES="installpammodules"
5750                 UNINSTALL_PAM_MODULES="uninstallpammodules"
5751         fi
5752 else
5753         AC_MSG_RESULT(no$winbind_no_reason)
5756 AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
5757                         AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])])
5759 AC_SUBST(WINBIND_NSS_PTHREAD)
5760 AC_SUBST(WINBIND_NSS)
5761 AC_SUBST(WINBIND_WINS_NSS)
5762 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
5763 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
5764 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
5765 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
5767 AC_SUBST(WINBIND_KRB5_LOCATOR)
5769 # Solaris 10 does have new member in nss_XbyY_key
5770 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
5771                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
5772                 [#include <nss_dbdefs.h>])
5774 # Solaris has some extra fields in struct passwd that need to be
5775 # initialised otherwise nscd crashes.
5777 AC_CHECK_MEMBER(struct passwd.pw_comment,
5778                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
5779                 [#include <pwd.h>])
5781 AC_CHECK_MEMBER(struct passwd.pw_age,
5782                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
5783                 [#include <pwd.h>])
5785 # AIX 4.3.x and 5.1 do not have as many members in
5786 # struct secmethod_table as AIX 5.2
5787 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
5788        [#include <usersec.h>])
5789 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
5790        [#include <usersec.h>])
5792 AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
5793 AC_TRY_COMPILE([#include <sys/types.h>
5794 #include <sys/socket.h>],
5795 [struct ucred cred;
5796  socklen_t cred_len;
5797  int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
5799 samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
5800 if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
5801     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
5805 #################################################
5806 # Check to see if we should use the included popt
5808 AC_ARG_WITH(included-popt,
5809 [AS_HELP_STRING([--with-included-popt], [use bundled popt library, not from system])],
5811   case "$withval" in
5812         yes)
5813                 INCLUDED_POPT=yes
5814                 ;;
5815         no)
5816                 INCLUDED_POPT=no
5817                 ;;
5818   esac ],
5820 if test x"$INCLUDED_POPT" != x"yes"; then
5821     AC_CHECK_LIB(popt, poptGetContext,
5822                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
5825 AC_MSG_CHECKING(whether to use included popt)
5826 if test x"$INCLUDED_POPT" = x"yes"; then
5827     AC_MSG_RESULT(yes)
5828     BUILD_POPT='$(POPT_OBJ)'
5829     POPTLIBS='$(POPT_OBJ)'
5830     FLAGS1="-I\$(srcdir)/popt"
5831 else
5832     AC_MSG_RESULT(no)
5833         BUILD_POPT=""
5834     POPTLIBS="-lpopt"
5836 AC_SUBST(BUILD_POPT)
5837 AC_SUBST(POPTLIBS)
5838 AC_SUBST(FLAGS1)
5840 #################################################
5841 # Check if user wants DNS service discovery support
5843 AC_ARG_ENABLE(dnssd,
5844 [AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=auto)])])
5846 AC_SUBST(DNSSD_LIBS)
5847 if test x"$enable_dnssd" != x"no"; then
5848     have_dnssd_support=yes
5850     AC_CHECK_HEADERS(dns_sd.h)
5851     if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
5852         have_dnssd_support=no
5853     fi
5855     # On Darwin the DNSSD API is in libc, but on other platforms it's
5856     # probably in -ldns_sd
5857     AC_CHECK_FUNCS(DNSServiceRegister)
5858     AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
5859     if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
5860             x"$ac_cv_lib_ext_DNSServiceRegister" != x"yes"; then
5861         have_dnssd_support=no
5862     fi
5864     if test x"$have_dnssd_support" = x"yes"; then
5865         AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
5866                 [Whether to enable DNS service discovery support])
5867     else
5868         if test x"$enable_dnssd" = x"yes"; then
5869             AC_MSG_ERROR(DNS service discovery support not available)
5870         fi
5871     fi
5875 #################################################
5876 # Check to see if we should use the included iniparser
5878 AC_ARG_WITH(included-iniparser,
5879 [AS_HELP_STRING([--with-included-iniparser], [use bundled iniparser library, not from system])],
5881   case "$withval" in
5882         yes)
5883                 INCLUDED_INIPARSER=yes
5884                 ;;
5885         no)
5886                 INCLUDED_INIPARSER=no
5887                 ;;
5888   esac ],
5890 if test x"$INCLUDED_INIPARSER" != x"yes"; then
5891     AC_CHECK_LIB(iniparser, iniparser_load,
5892                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
5895 AC_MSG_CHECKING(whether to use included iniparser)
5896 if test x"$INCLUDED_INIPARSER" = x"yes"; then
5897     AC_MSG_RESULT(yes)
5898     BUILD_INIPARSER='$(INIPARSER_OBJ)'
5899         INIPARSERLIBS=""
5900     FLAGS1="$FLAGS1 -I\$(srcdir)/iniparser/src"
5901 else
5902     AC_MSG_RESULT(no)
5903         BUILD_INIPARSER=""
5904     INIPARSERLIBS="-liniparser"
5906 AC_SUBST(BUILD_INIPARSER)
5907 AC_SUBST(INIPARSERLIBS)
5908 AC_SUBST(FLAGS1)
5912 # Checks for the vfs_fileid module
5913 # Start
5914 AC_CHECK_FUNC(getmntent)
5916 AC_CHECK_HEADERS(sys/statfs.h)
5918 AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
5919 AC_CACHE_VAL(vfsfileid_cv_statfs,[
5920              AC_TRY_RUN([
5921                 #include <sys/types.h>
5922                 #include <sys/statfs.h>
5923                 int main(void)
5924                 {
5925                         struct statfs fsd;
5926                         fsid_t fsid = fsd.f_fsid;
5927                         return statfs (".", &fsd);
5928                 }],
5929                 vfsfileid_cv_statfs=yes,
5930                 vfsfileid_cv_statfs=no,
5931                 vfsfileid_cv_statfs=cross)
5933 AC_MSG_RESULT($vfsfileid_cv_statfs)
5935 if test x"$ac_cv_func_getmntent" = x"yes" -a \
5936         x"$vfsfileid_cv_statfs" = x"yes"; then
5937         default_shared_modules="$default_shared_modules vfs_fileid"
5939 # End
5940 # Checks for the vfs_fileid module
5943 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
5945         eval MODULE_DEFAULT_$i=STATIC
5946 done
5948 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
5950         dnl Fall back to static if we cannot build shared libraries
5951         eval MODULE_DEFAULT_$i=STATIC
5953         if test $BLDSHARED = true; then
5954                 eval MODULE_DEFAULT_$i=SHARED
5955         fi
5956 done
5958 dnl Always build these modules static
5959 MODULE_rpc_spoolss=STATIC
5960 MODULE_rpc_srvsvc2=STATIC
5961 MODULE_idmap_tdb=STATIC
5962 MODULE_idmap_passdb=STATIC
5963 MODULE_idmap_nss=STATIC
5965 MODULE_nss_info_template=STATIC
5967 AC_ARG_WITH(static-modules,
5968 [AS_HELP_STRING([--with-static-modules=MODULES], [Comma-separated list of names of modules to statically link in])],
5969 [ if test $withval; then
5970         for i in `echo $withval | sed -e 's/,/ /g'`
5971         do
5972                 eval MODULE_$i=STATIC
5973         done
5974 fi ])
5976 AC_ARG_WITH(shared-modules,
5977 [AS_HELP_STRING([--with-shared-modules=MODULES], [Comma-separated list of names of modules to build shared])],
5978 [ if test $withval; then
5979         for i in `echo $withval | sed -e 's/,/ /g'`
5980         do
5981                         eval MODULE_$i=SHARED
5982         done
5983 fi ])
5985 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB,
5986                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
5987 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
5988 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
5989 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
5992 SMB_MODULE(rpc_lsarpc, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
5993 SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
5994 SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
5995 SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC)
5996 SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
5997 SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC)
5998 SMB_MODULE(rpc_ntsvcs2, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs2.$SHLIBEXT", RPC)
5999 SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
6000 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
6001 SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$SHLIBEXT", RPC)
6002 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
6003 SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
6004 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
6005 SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
6006 SMB_SUBSYSTEM(RPC,smbd/server.o)
6008 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
6009 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
6010 SMB_MODULE(idmap_tdb2, winbindd/idmap_tdb2.o, "bin/tdb2.$SHLIBEXT", IDMAP)
6011 SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
6012 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
6013 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
6014 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
6015 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
6017 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
6018 SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
6020 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
6021 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
6022 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
6023 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
6024 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
6026 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
6027 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
6028 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
6029 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
6030 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
6031 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
6032 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
6033 SMB_SUBSYSTEM(AUTH,auth/auth.o)
6035 SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
6036 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
6037 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
6038 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
6039 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
6040 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
6041 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
6042 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
6043 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
6044 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
6045 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
6046 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
6047 SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
6048 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
6049 SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
6050 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
6051 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
6052 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
6053 SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
6054 SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
6055 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
6056 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
6057 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
6058 SMB_MODULE(vfs_streams_xattr, \$(VFS_STREAMS_XATTR_OBJ), "bin/streams_xattr.$SHLIBEXT", VFS)
6059 SMB_MODULE(vfs_streams_depot, \$(VFS_STREAMS_DEPOT_OBJ), "bin/streams_depot.$SHLIBEXT", VFS)
6060 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
6061 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
6062 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
6063 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
6064 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
6065 SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
6066 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
6067 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
6068 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
6069 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
6072 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
6074 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
6076 #################################################
6077 # do extra things if we are running insure
6079 if test "${ac_cv_prog_CC}" = "insure"; then
6080         CPPFLAGS="$CPPFLAGS -D__INSURE__"
6083 #################################################
6084 # If run from the build farm, enable NASTY hacks
6085 #################################################
6086 AC_MSG_CHECKING(whether to enable build farm hacks)
6087 if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
6088         AC_MSG_RESULT(yes)
6089         AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
6090 else
6091         AC_MSG_RESULT(no)
6094 #################################################
6095 # check for bad librt/libpthread interactions
6097 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
6098     x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
6099     x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6100     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6102 SMB_IF_RTSIGNAL_BUG(
6103         [
6104             # Have RT_SIGNAL bug, need to check whether the problem will
6105             # affect anything we have configured.
6107             rt_do_error=no
6108             if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
6109                 if test x"$rt_signal_lease_ok" = x"no" ; then
6110                     rt_do_error=yes
6111                 fi
6112             fi
6114             if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
6115                 if test x"$rt_signal_notify_ok" = x"no" ; then
6116                     rt_do_error=yes
6117                 fi
6118             fi
6120             if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6121                     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6122                 if test x"$rt_signal_aio_ok" = x"no" ; then
6123                     rt_do_error=yes
6124                 fi
6125             fi
6127             if test x"$rt_do_error" = x"yes" ; then
6128                 SMB_IS_LIBPTHREAD_LINKED(
6129                     [
6130                         cat<<MSG
6132 *** On this platforms, linking Samba against pthreads causes problems
6133 *** with the oplock and change notification mechanisms. You may be
6134 *** using pthreads as a side-effect of using the --with-aio-support
6135 *** or --with-profiling-data options. Please remove these and try again.
6138                     ],
6139                     [
6140                         cat<<MSG
6142 *** On this platform, the oplock and change notification mechanisms do not
6143 *** appear to work. Please report this problem to samba-technical@samba.org
6144 *** and attach the config.log file from this directory.
6147                     ])
6148                 AC_MSG_ERROR(unable to use realtime signals on this platform)
6149             fi
6150         ],
6151         [
6152             # no RT_SIGNAL bug, we are golden
6153             SMB_IS_LIBPTHREAD_LINKED(
6154                 [
6155                     AC_MSG_WARN(using libpthreads - this may degrade performance)
6156                 ])
6158         ],
6159         [
6160             # cross compiling, I hope you know what you are doing
6161             true
6162         ])
6166 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
6167 LIB_REMOVE_USR_LIB(LDFLAGS)
6168 LIB_REMOVE_USR_LIB(LIBS)
6169 LIB_REMOVE_USR_LIB(KRB5_LIBS)
6171 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
6172 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
6173 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
6175 #################################################
6176 # Display summary of libraries detected
6178 AC_MSG_RESULT([Using libraries:])
6179 AC_MSG_RESULT([    LIBS = $LIBS])
6180 if test x"$with_ads_support" != x"no"; then
6181     AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
6183 if test x"$with_ldap_support" != x"no"; then
6184     AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
6186 if test x"$with_dnsupdate_support" != x"no"; then
6187     AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
6189 if test x"$have_dnssd_support" != x"no"; then
6190     AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
6192 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
6194 #################################################
6195 # final configure stuff
6197 AC_MSG_CHECKING([configure summary])
6198 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
6199            AC_MSG_RESULT(yes),
6200            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
6201            AC_MSG_WARN([cannot run when cross-compiling]))
6203 dnl Merge in developer cflags from now on
6204 AC_SUBST(DEVELOPER_CFLAGS)
6205 if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes"; then
6206     CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
6209 # Stuff the smbd-only libraries at the end of the smbd link
6210 # path (if we have them).
6211 SMBD_LIBS="$samba_dmapi_libs"
6212 AC_SUBST(SMBD_LIBS)
6214 AC_OUTPUT(Makefile library-versions
6215           script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
6216           lib/netapi/examples/Makefile
6217           pkgconfig/smbclient.pc
6218           pkgconfig/wbclient.pc
6219           pkgconfig/netapi.pc
6220           pkgconfig/smbsharemodes.pc
6221           )
6223 #################################################
6224 # Print very concise instructions on building/use
6225 if test "x$enable_dmalloc" = xyes
6226 then
6227         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
6228         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])