s3:winbind add timeouts to winbind cache
[Samba/wip.git] / source3 / configure.in
blobe67a26265079bad5c1756a80f2007caf1f1f0b96
1 dnl Process this file with autoconf to produce a configure script.
3 dnl We must use autotools 2.54 or above
4 AC_PREREQ(2.54)
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)
23 m4_include(pkg.m4)
25 AC_LIBREPLACE_CC_CHECKS
26 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
28 m4_include(../lib/tevent/libtevent.m4)
30 LIBTEVENT_OBJ0=""
31 for obj in ${TEVENT_OBJ}; do
32         LIBTEVENT_OBJ0="${LIBTEVENT_OBJ0} ${teventdir}/${obj}"
33 done
34 AC_SUBST(LIBTEVENT_OBJ0)
35 LIBS="${LIBS} ${TEVENT_LIBS}"
37 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
38 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
39 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
40 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
41 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
42 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
44 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt"
46 ## cleanup the $(srcdir) in the Makefile if we are outside of the tree
47 if test "x${srcdir-.}" != "x."; then
48         SAMBA_CPPFLAGS=`echo ${SAMBA_CPPFLAGS} | sed -e "s;${srcdir};\$\(srcdir\);g"`
51 dnl Unique-to-Samba variables we'll be playing with.
52 AC_SUBST(SAMBA_CPPFLAGS)
53 AC_SUBST(SHELL)
54 AC_SUBST(LDSHFLAGS)
55 AC_SUBST(SONAMEFLAG)
56 AC_SUBST(SHLD)
57 AC_SUBST(MODULE_EXPORTS)
58 AC_SUBST(DSO_EXPORTS)
59 AC_SUBST(HOST_OS)
60 AC_SUBST(PICFLAG)
61 AC_SUBST(PIE_CFLAGS)
62 AC_SUBST(PIE_LDFLAGS)
63 AC_SUBST(RELRO_LDFLAGS)
64 AC_SUBST(SHLIBEXT)
65 AC_SUBST(INSTALLLIBCMD_SH)
66 AC_SUBST(INSTALLLIBCMD_A)
67 AC_SUBST(UNINSTALLLIBCMD_SH)
68 AC_SUBST(UNINSTALLLIBCMD_A)
70 AC_SUBST(INSTALL_LIBWBCLIENT)
71 AC_SUBST(UNINSTALL_LIBWBCLIENT)
72 AC_SUBST(LIBWBCLIENT_SHARED_TARGET)
73 AC_SUBST(LIBWBCLIENT_SHARED)
74 AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
75 AC_SUBST(LIBWBCLIENT_STATIC)
76 AC_SUBST(LIBWBCLIENT_SOVER)
77 AC_SUBST(LIBWBCLIENT)
78 AC_SUBST(LIBWBCLIENT_LIBS)
80 AC_SUBST(LIBSAMBAUTIL_SHARED)
82 AC_SUBST(PRINT_LIBS)
83 AC_SUBST(AUTH_LIBS)
84 AC_SUBST(ACL_LIBS)
85 AC_SUBST(PASSDB_LIBS)
86 AC_SUBST(IDMAP_LIBS)
87 AC_SUBST(KRB5_LIBS)
88 AC_SUBST(UUID_LIBS)
89 AC_SUBST(LDAP_LIBS)
90 AC_SUBST(GPEXT_LIBS)
91 AC_SUBST(PAM_MODULES)
92 AC_SUBST(INSTALL_PAM_MODULES)
93 AC_SUBST(UNINSTALL_PAM_MODULES)
94 AC_SUBST(NSS_MODULES)
95 AC_SUBST(EXTRA_BIN_PROGS)
96 AC_SUBST(CIFSMOUNT_PROGS)
97 AC_SUBST(INSTALL_CIFSMOUNT)
98 AC_SUBST(UNINSTALL_CIFSMOUNT)
99 AC_SUBST(CIFSUMOUNT_PROGS)
100 AC_SUBST(INSTALL_CIFSUMOUNT)
101 AC_SUBST(UNINSTALL_CIFSUMOUNT)
102 AC_SUBST(CIFSUPCALL_PROGS)
103 AC_SUBST(INSTALL_CIFSUPCALL)
104 AC_SUBST(UNINSTALL_CIFSUPCALL)
105 AC_SUBST(EXTRA_SBIN_PROGS)
106 AC_SUBST(EXTRA_ALL_TARGETS)
107 AC_SUBST(CONFIG_LIBS)
108 AC_SUBST(NSCD_LIBS)
110 # compile with optimization and without debugging by default, but
111 # allow people to set their own preference.
112 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
113 # if it has no value.  This prevent *very* large debug binaries from occurring
114 # by default.
115 if test "x$debug" = "xyes" ; then
116         CFLAGS="${CFLAGS} -g"
118 if test "x$CFLAGS" = x; then
119   CFLAGS="-O"
122 m4_include(../lib/socket_wrapper/config.m4)
123 m4_include(../lib/nss_wrapper/config.m4)
125 m4_include(m4/swat.m4)
127 DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
129 # Probe the gcc version for extra CFLAGS. We always stash these in
130 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
131 # Makefile edit, avoiding the need to re-run configure.
132 if test x"$ac_cv_prog_gcc" = x"yes" ; then
133         DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings"
134         # Add -Wdeclaration-after-statement if compiler supports it
135         AC_CACHE_CHECK(
136           [that the C compiler understands -Wdeclaration-after-statement],
137           samba_cv_HAVE_Wdeclaration_after_statement, [
138           AC_TRY_RUN_STRICT([
139             int main(void)
140             {
141                 return 0;
142             }],[$CFLAGS -Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
143             samba_cv_HAVE_Wdeclaration_after_statement=yes,
144             samba_cv_HAVE_Wdeclaration_after_statement=no,
145             samba_cv_HAVE_Wdeclaration_after_statement=cross)
146        ])
148         if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
149             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
150         fi
152         #-Werror-implicit-function-declaration
153         AC_CACHE_CHECK(
154           [that the C compiler understands -Werror-implicit-function-declaration],
155           samba_cv_HAVE_Werror_implicit_function_declaration, [
156           AC_TRY_RUN_STRICT([
157             int main(void)
158             {
159                 return 0;
160             }],[$CFLAGS -Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
161             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
162             samba_cv_HAVE_Werror_implicit_function_declaration=no,
163             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
164        ])
165        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
166             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
167        fi
169         # krb5developer is like developer, except we don't get
170         # -Wstrict-prototypes.
171        if test x"$krb5_developer" != x"$yes" ; then
172             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
173        fi
175        if test x"$picky_developer" = x"yes"; then
176             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Werror"
177        fi
180 #################################################
181 # check for a shared memory profiling support
182 AC_MSG_CHECKING(whether to use profiling)
183 AC_ARG_WITH(profiling-data,
184 [AS_HELP_STRING([--with-profiling-data], [Include gathering source code profile information (default=no)])],
185 [ case "$withval" in
186   yes)
187     AC_MSG_RESULT(yes)
188     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
189     samba_cv_WITH_PROFILE=yes
190     ;;
191   *)
192     AC_MSG_RESULT(no)
193     samba_cv_WITH_PROFILE=no
194     ;;
195   esac ],
196   AC_MSG_RESULT(no)
199 dnl Checks for programs.
200 merged_build_possible=yes
202 AC_PROG_INSTALL
203 AC_PROG_AWK
204 # Check for GNU make
205 m4_include(../m4/check_make.m4)
206 AC_SAMBA_GNU_MAKE([true], [true])
208 # Check for perl
209 m4_include(../m4/check_perl.m4)
210 AC_SAMBA_PERL([true], [merged_build_possible=no])
212 # Check for python
213 m4_include(../m4/check_python.m4)
214 AC_SAMBA_PYTHON_DEVEL([true], [merged_build_possible=no])
216 AC_CHECK_TOOL(AR, ar)
218 dnl Check if we (actually our C compiler!) use GNU ld
219 AC_PROG_LD_GNU
221 dnl Certain versions of GNU ld the default is not to have the
222 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
223 dnl warnings when building modules.
224 if test "$ac_cv_prog_gnu_ld" = "yes"; then
225         ac_cv_gnu_ld_version=`$CC -Wl,-v /dev/null 2>/dev/null | head -1`
226         AC_MSG_CHECKING(GNU ld release date)
227         changequote(,)dnl
228         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'`
229         changequote([,])dnl
230         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
231         if test -n "$ac_cv_gnu_ld_date"; then
232         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
233                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
234         fi
235         if test "$ac_cv_gnu_ld_date" -gt 20030101; then
236                 ac_cv_gnu_ld_version_script=yes
237         fi
238         else
239            AC_MSG_CHECKING(GNU ld release version)
240            changequote(,)dnl
241            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | awk '{print $NF}' | sed -n 's,\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
242            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
243            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
244            changequote([,])dnl
245            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
246            AC_MSG_CHECKING(GNU ld release version major)
247            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
248            AC_MSG_CHECKING(GNU ld release version minor)
249            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
250            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
251              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
252            fi
253            if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major" = 2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
254              ac_cv_gnu_ld_version_script=yes
255            fi
256         fi
259 dnl look for executable suffix
260 AC_EXEEXT
262 dnl Check if C compiler understands -c and -o at the same time
263 AC_PROG_CC_C_O
264 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
265       BROKEN_CC=
266 else
267       BROKEN_CC=#
269 AC_SUBST(BROKEN_CC)
271 dnl Check if the C compiler understands -Werror (GNU)
272 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
273  AC_TRY_RUN_STRICT([
274   int main(void)
275   {
276         return 0;
277   }],[$CFLAGS -Werror],[$CPPFLAGS],[$LDFLAGS],
278   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
279 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
280    Werror_FLAGS="-Werror"
281 else
282 dnl Check if the C compiler understands -w2
283 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
284  AC_TRY_RUN_STRICT([
285   int main(void)
286   {
287         return 0;
288   }],[$CFLAGS -w2],[$CPPFLAGS],[$LDFLAGS],
289   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
290 if test x"$samba_cv_HAVE_w2" = x"yes"; then
291    Werror_FLAGS="-w2"
292 else
293 dnl Check if the C compiler understands -errwarn (Sun)
294 AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
295   AC_TRY_RUN_STRICT([
296    int main(void)
297    {
298         return 0;
299    }],[$CFLAGS -errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
300    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
301 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
302    Werror_FLAGS="-errwarn=%all"
303 else
304 dnl Check if the C compiler understands -qhalt (IBM)
305 AC_CACHE_CHECK([that the C compiler understands -qhalt],samba_cv_HAVE_qhalt, [
306   AC_TRY_RUN_STRICT([
307    int main(void)
308    {
309         return 0;
310    }],[$CFLAGS -qhalt=w],[$CPPFLAGS],[$LDFLAGS],
311    samba_cv_HAVE_qhalt=yes,samba_cv_HAVE_qhalt=no,samba_cv_HAVE_qhalt=cross)])
312 if test x"$samba_cv_HAVE_qhalt" = x"yes"; then
313    Werror_FLAGS="-qhalt=w"
319 ############################################
320 # check if the compiler can handle negative enum values
321 # and don't truncate the values to INT_MAX
322 # a runtime test is needed here
323 AC_SUBST(PIDL_ARGS)
324 AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
325     AC_TRY_RUN(
327         #include <stdio.h>
328         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
329         int main(void) {
330                 enum negative_values v1 = NEGATIVE_VALUE;
331                 unsigned v2 = NEGATIVE_VALUE;
333                 if (v1 != 0xFFFFFFFF) {
334                         printf("%u != 0xFFFFFFFF\n", v1);
335                         return 1;
336                 }
337                 if (v2 != 0xFFFFFFFF) {
338                         printf("%u != 0xFFFFFFFF\n", v2);
339                         return 1;
340                 }
342                 return 0;
343         }
345         samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv_CC_NEGATIVE_ENUM_VALUES=no)])
346 if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
347         AC_MSG_WARN([using --uint-enums for pidl])
348         PIDL_ARGS="$PIDL_ARGS --uint-enums"
351 dnl Figure out the flags to support named structure initializers
353 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
355 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
356 AC_MSG_CHECKING(uname -s)
357 AC_MSG_RESULT(${UNAME_S})
359 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
360 AC_MSG_CHECKING(uname -r)
361 AC_MSG_RESULT(${UNAME_R})
363 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
364 AC_MSG_CHECKING(uname -m)
365 AC_MSG_RESULT(${UNAME_M})
367 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
368 AC_MSG_CHECKING(uname -p)
369 AC_MSG_RESULT(${UNAME_P})
371 UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
372 AC_MSG_CHECKING(uname -i)
373 AC_MSG_RESULT(${UNAME_I})
375 dnl Add #include for broken IRIX header files
376   case "$host_os" in
377         *irix6*)
378                 #TODO add to libreplace
379                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
380                         dnl Fix sensible defaults for MIPSPro compilers. The
381                         dnl error numbers are valid for the 7.3 compilers,
382                         dnl hopefully also valid for the 7.4 series.
383                         dnl
384                         dnl Bugzilla 3801. Force an error on warning 1035
385                         dnl so we don't incorrectly detect stdint.h. This
386                         dnl warning is emitted for #error directives.
387                         CFLAGS="$CFLAGS -diag_error 1035"
388                         dnl 1209: Controlling expression is constant
389                         dnl 1174: Function foo declared but never referenced
390                         dnl 3201: Parameter foo was never referenced
391                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
392                 fi
393         ;;
394 esac
396 DYNEXP=
397 AC_SUBST(DYNEXP)
398 LDSHFLAGS_Z_DEFS=
399 AC_SUBST(LDSHFLAGS_Z_DEFS)
400 LDSHFLAGS_Z_NODEFS=
401 AC_SUBST(LDSHFLAGS_Z_NODEFS)
403 dnl Add modules that have to be built by default here
404 dnl These have to be built static:
405 default_static_modules=""
406 default_static_modules="$default_static_modules pdb_smbpasswd"
407 default_static_modules="$default_static_modules pdb_tdbsam"
408 default_static_modules="$default_static_modules pdb_wbc_sam"
409 default_static_modules="$default_static_modules rpc_lsarpc"
410 default_static_modules="$default_static_modules rpc_samr"
411 default_static_modules="$default_static_modules rpc_winreg"
412 default_static_modules="$default_static_modules rpc_initshutdown"
413 default_static_modules="$default_static_modules rpc_dssetup"
414 default_static_modules="$default_static_modules rpc_wkssvc"
415 default_static_modules="$default_static_modules rpc_svcctl"
416 default_static_modules="$default_static_modules rpc_ntsvcs"
417 default_static_modules="$default_static_modules rpc_netlogon"
418 default_static_modules="$default_static_modules rpc_netdfs"
419 default_static_modules="$default_static_modules rpc_srvsvc"
420 default_static_modules="$default_static_modules rpc_spoolss"
421 default_static_modules="$default_static_modules rpc_eventlog"
422 default_static_modules="$default_static_modules auth_sam"
423 default_static_modules="$default_static_modules auth_unix"
424 default_static_modules="$default_static_modules auth_winbind"
425 default_static_modules="$default_static_modules auth_wbc"
426 default_static_modules="$default_static_modules auth_server"
427 default_static_modules="$default_static_modules auth_domain"
428 default_static_modules="$default_static_modules auth_builtin"
429 default_static_modules="$default_static_modules auth_netlogond"
430 default_static_modules="$default_static_modules vfs_default"
431 default_static_modules="$default_static_modules nss_info_template"
433 dnl These are preferably build shared, and static if dlopen() is not available
434 default_shared_modules=""
435 default_shared_modules="$default_shared_modules vfs_recycle"
436 default_shared_modules="$default_shared_modules vfs_audit"
437 default_shared_modules="$default_shared_modules vfs_extd_audit"
438 default_shared_modules="$default_shared_modules vfs_full_audit"
439 default_shared_modules="$default_shared_modules vfs_netatalk"
440 default_shared_modules="$default_shared_modules vfs_fake_perms"
441 default_shared_modules="$default_shared_modules vfs_default_quota"
442 default_shared_modules="$default_shared_modules vfs_readonly"
443 default_shared_modules="$default_shared_modules vfs_cap"
444 default_shared_modules="$default_shared_modules vfs_expand_msdfs"
445 default_shared_modules="$default_shared_modules vfs_shadow_copy"
446 default_shared_modules="$default_shared_modules vfs_shadow_copy2"
447 default_shared_modules="$default_shared_modules charset_CP850"
448 default_shared_modules="$default_shared_modules charset_CP437"
449 default_shared_modules="$default_shared_modules auth_script"
450 default_shared_modules="$default_shared_modules vfs_readahead"
451 default_shared_modules="$default_shared_modules vfs_xattr_tdb"
452 default_shared_modules="$default_shared_modules vfs_streams_xattr"
453 default_shared_modules="$default_shared_modules vfs_streams_depot"
454 default_shared_modules="$default_shared_modules vfs_acl_xattr"
455 default_shared_modules="$default_shared_modules vfs_acl_tdb"
456 default_shared_modules="$default_shared_modules vfs_smb_traffic_analyzer"
457 default_shared_modules="$default_shared_modules vfs_preopen"
458 default_shared_modules="$default_shared_modules vfs_catia"
459 default_shared_modules="$default_shared_modules vfs_scannedonly"
460 default_shared_modules="$default_shared_modules vfs_crossrename"
461 default_shared_modules="$default_shared_modules vfs_linux_xfs_sgid"
462 default_shared_modules="$default_shared_modules vfs_time_audit"
464 if test "x$developer" = xyes; then
465    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
466    default_shared_modules="$default_shared_modules charset_weird perfcount_test"
470 # Config CPPFLAG settings for strange OS's that must be set
471 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
472 # case statement; its first reference must be unconditional.
474 case "$host_os" in
475     *hpux*)
477 # Defines needed for HPUX support.
478 # HPUX has bigcrypt but (sometimes?) doesn't use it for
479 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
481       case `uname -r` in
482                 *9*|*10*|*11)
483                         AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
484                 ;;
485       esac
486       ;;
489 # CRAY Unicos has broken const handling
490        *unicos*)
491           AC_MSG_RESULT([disabling const])
492           CPPFLAGS="$CPPFLAGS -Dconst="
493           ;;
494         
496 # AIX4.x doesn't even admit to having large
497 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
499     *aix4*)
500           AC_MSG_RESULT([enabling large file support])
501       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
502           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
503       ;;
505 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
506 # to the existance of large files..
507 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
508 # recommendations on large file support, however it makes the
509 # compile work using gcc 2.7 and 2.8, whereas using the Sun
510 # recommendation makes the compile fail on gcc2.7. JRA.
512 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
514         *solaris*)
515                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
516                 case `uname -r` in
517                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
518                                 AC_MSG_RESULT([no large file support])
519                                 ;;
520                         5.*)
521                         AC_MSG_RESULT([enabling large file support])
522                         if test "$ac_cv_prog_gcc" = yes; then
523                                 ${CC-cc} -v >conftest.c 2>&1
524                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
525                                 rm -fr conftest.c
526                                 case "$ac_cv_gcc_compiler_version_number" in
527                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
528                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
529                                                 LDFLAGS="$LDFLAGS -lthread"
530                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
531                                                 ;;
532                                         *)
533                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
534                                                 LDFLAGS="$LDFLAGS -lthread"
535                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
536                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
537                                                 ;;
538                                 esac
539                         else
540                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
541                                 LDFLAGS="$LDFLAGS -lthread"
542                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
543                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
544                         fi
545                         ;;
546                 esac
547                 ;;
549 # IRIX uses SYSV printing.  Make sure to set that here
551         *irix*)
552                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
553                 ;;
554         *freebsd*|*dragonfly*)
555                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
556                 ;;
558 # VOS may need to have POSIX support and System V compatibility enabled.
560     *vos*)
561     case "$CPPFLAGS" in
562           *-D_POSIX_C_SOURCE*)
563                 ;;
564           *)
565                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
566                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
567                 ;;
568     esac
569     case "$CPPFLAGS" in
570           *-D_SYSV*|*-D_SVID_SOURCE*)
571                 ;;
572           *)
573                 CPPFLAGS="$CPPFLAGS -D_SYSV"
574                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
575     esac
576     ;;
578 # Tests needed for SINIX large file support.
580     *sysv4*)
581       if test $host = mips-sni-sysv4 ; then
582         AC_MSG_CHECKING([for LFS support])
583         old_CPPFLAGS="$CPPFLAGS"
584         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
585         AC_TRY_RUN([
586 #include <unistd.h>
587 main () {
588 #if _LFS64_LARGEFILE == 1
589 exit(0);
590 #else
591 exit(1);
592 #endif
593 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
594         CPPFLAGS="$old_CPPFLAGS"
595         if test x$SINIX_LFS_SUPPORT = xyes ; then
596           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
597                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
598           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
599           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
600           LIBS="`getconf LFS64_LIBS` $LIBS"
601         fi
602       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
603       fi
604     ;;
606 # Systems with LFS support.
608     gnu* | k*bsd*-gnu | kopensolaris*-gnu)
609         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
610         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
611         AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
612         AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
613         ;;
615 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
617     *linux*)
618         AC_MSG_CHECKING([for LFS support])
619         old_CPPFLAGS="$CPPFLAGS"
620         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
621        AC_TRY_RUN([
622 #include <unistd.h>
623 #include <sys/utsname.h>
624 #include <string.h>
625 #include <stdlib.h>
626 main() {
627 #if _LFS64_LARGEFILE == 1
628        struct utsname uts;
629        char *release;
630        int major, minor;
632        /* Ensure this is glibc 2.2 or higher */
633 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
634        int libc_major = __GLIBC__;
635        int libc_minor = __GLIBC_MINOR__;
637        if (libc_major < 2)
638               exit(1);
639        if (libc_minor < 2)
640               exit(1);
641 #endif
643        /* Ensure this is kernel 2.4 or higher */
645        uname(&uts);
646        release = strdup(uts.release);
647        major = atoi(strsep(&release, "."));
648        minor = atoi(strsep(&release, "."));
650        if (major > 2 || (major == 2 && minor > 3))
651                exit(0);
652        exit(1);
653 #else
654        exit(1);
655 #endif
657 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
658         CPPFLAGS="$old_CPPFLAGS"
659         if test x$LINUX_LFS_SUPPORT = xyes ; then
660                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
661                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
662                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
663                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
664         fi
665         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
666         ;;
669 # MacOS X is the *only* system that uses compose character in utf8. This
670 # is so horribly broken....
672     *darwin*)
673         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
675 # Add a system specific charset module.
676         default_shared_modules="$default_shared_modules charset_macosxfs"
678         ;;
679     *hurd*)
680         AC_MSG_CHECKING([for LFS support])
681         old_CPPFLAGS="$CPPFLAGS"
682         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
683         AC_TRY_RUN([
684 #include <unistd.h>
685 main () {
686 #if _LFS64_LARGEFILE == 1
687 exit(0);
688 #else
689 exit(1);
690 #endif
691 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
692         CPPFLAGS="$old_CPPFLAGS"
693         if test x$GLIBC_LFS_SUPPORT = xyes ; then
694           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
695                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
696           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
697         fi
698       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
699     ;;
700     *qnx*)
701         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
702         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
703         ;;
705 esac
707 SAVE_CPPFLAGS="${CPPFLAGS}"
708 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
710 AC_LIBREPLACE_BROKEN_CHECKS
711 AC_CHECK_FUNCS([syslog],[],[AC_MSG_ERROR([Required function not found])])
712 AC_LIBREPLACE_NETWORK_CHECKS
714 CPPFLAGS="${SAVE_CPPFLAGS}"
716 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
718 LIBREPLACE_OBJS="${LIBREPLACEOBJ}"
719 AC_SUBST(LIBREPLACE_OBJS)
721 LIBREPLACE_LIBS="${LIBREPLACE_NETWORK_LIBS}"
722 AC_SUBST(LIBREPLACE_LIBS)
725 # add -ldl to the global LIBS
726 LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}"
727 AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
730 AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
731 AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h)
732 AC_CHECK_HEADERS(limits.h float.h libintl.h)
733 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
734 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h sys/sysctl.h)
735 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
736 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
737 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h)
738 AC_CHECK_HEADERS(sys/sysmacros.h)
739 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
740 AC_CHECK_HEADERS(langinfo.h locale.h)
741 AC_CHECK_HEADERS(xfs/libxfs.h)
742 AC_CHECK_HEADERS(netgroup.h)
744 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
745 #if HAVE_RPC_RPC_H
746 #include <rpc/rpc.h>
747 #endif
750 ## These fail to compile on IRIX so just check for their presence
751 AC_CHECK_HEADERS(sys/mode.h,,,)
753 # Look for Darwin headers
754 old_CPPFLAGS="$CPPFLAGS"
755 CPPFLAGS="-Iinclude $CPPFLAGS"
756 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
757 CPPFLAGS="$old_CPPFLAGS"
759 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
760 # subdirectory of headers.
761 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
763 if test x"$enable_developer" = x"yes" ; then
764    if test x"$ac_cv_header_valgrind_h" = xyes -o \
765            x"$ac_cv_header_valgrind_valgrind_h" = xyes ; then
766       AC_DEFINE(VALGRIND,1,[Whether we have valgrind headers])
767    fi
771 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
772 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
774 case "$host_os" in
775     *hpux*)
776                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
777                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
778                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
779                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
780                 fi
781         ;;
782 esac
783 AC_CHECK_HEADERS(shadow.h)
784 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
785 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
787 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
788 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
790 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
792 # For experimental utmp support (lastlog on some BSD-like systems)
793 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
795 AC_CHECK_SIZEOF(int,cross)
796 AC_CHECK_SIZEOF(long,cross)
797 AC_CHECK_SIZEOF(long long,cross)
798 AC_CHECK_SIZEOF(short,cross)
800 AC_C_CONST
801 AC_C_INLINE
802 AC_C_BIGENDIAN
803 AC_C_CHAR_UNSIGNED
805 AC_TYPE_SIGNAL
806 AC_TYPE_UID_T
807 AC_TYPE_MODE_T
808 AC_TYPE_OFF_T
809 AC_TYPE_SIZE_T
810 AC_TYPE_PID_T
811 AC_STRUCT_ST_RDEV
812 AC_DIRENT_D_OFF
813 AC_CHECK_TYPE(ssize_t, int)
814 AC_CHECK_TYPE(wchar_t, unsigned short)
816 ############################################
817 # for cups support we need libcups, and a handful of header files
819 AC_ARG_ENABLE(cups,
820 [AS_HELP_STRING([--enable-cups], [Turn on CUPS support (default=auto)])])
822 if test x$enable_cups != xno; then
823         AC_PATH_PROG(CUPS_CONFIG, cups-config)
825         if test "x$CUPS_CONFIG" != x; then
827                 ac_save_LDFLAGS=$LDFLAGS
828                 ac_save_PRINT_LIBS=$PRINT_LIBS
829                 AC_CHECK_HEADERS(cups/cups.h cups/language.h)
831                 if test x"$ac_cv_header_cups_cups_h" = xyes -a \
832                         x"$ac_cv_header_cups_language_h" = xyes; then
833                         # try linking with -lcups alone first. That should work unless libcups is
834                         # underlinked. With cups-config --libs we pull in unwanted and unneeded
835                         # dendencies including thread libraries - use cups-config only if really
836                         # required. 
837                         AC_CHECK_LIB_EXT(cups, ac_save_PRINT_LIBS , httpConnect,
838                                 [PRINT_LIBS"$ac_save_PRINT_LIBS -lcups"],
839                                 [AC_MSG_WARN([your cups library doesn't link with -lcups alone, it might be underlinked.]) ;
840                                  PRINT_LIBS="$ac_save_PRINT_LIBS `$CUPS_CONFIG --libs`"])
842                         AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
843                         samba_cv_HAVE_CUPS=yes
844                         AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
845                 else
846                         AC_MSG_WARN([cups-config around but cups-devel not installed])
847                         CFLAGS=$ac_save_CFLAGS
848                         LDFLAGS=$ac_save_LDFLAGS
849                         PRINT_LIBS=$ac_save_PRINT_LIBS
850                 fi
852         elif test x"$enable_cups" = x"yes"; then
853                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
854         fi
857 AC_ARG_ENABLE(iprint,
858 [AS_HELP_STRING([--enable-iprint], [Turn on iPrint support (default=yes if cups is yes)])])
860 if test x$enable_iprint != xno; then
861         if test x"$samba_cv_HAVE_CUPS" = xyes; then
862                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
863         elif test x"$enable_iprint" = x"yes"; then
864                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
865         fi
868 ############################################
869 # check if the compiler will optimize out function calls
870 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
871     AC_TRY_LINK([
872 #include <stdio.h>],
874                 if (0) {
875                    this_function_does_not_exist();
876                 } else {
877                   return 1;
878                 }
881         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
882 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
883    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
886 #############################################
887 # check for fd passing struct via msg_control
888 AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [
889     AC_TRY_COMPILE([
890 #include <sys/types.h>
891 #include <stdlib.h>
892 #include <stddef.h>
893 #include <sys/socket.h>
894 #include <sys/un.h>],
896         struct msghdr msg;
897         union {
898               struct cmsghdr cm;
899               char control[CMSG_SPACE(sizeof(int))];
900         } control_un;
901         msg.msg_control = control_un.control;
902         msg.msg_controllen = sizeof(control_un.control);
904         samba_cv_msghdr_msg_control=yes,samba_cv_msghdr_msg_control=no)])
905 if test x"$samba_cv_msghdr_msg_control" = x"yes"; then
906    AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1,
907              [If we can use msg_control for passing file descriptors])
910 #############################################
911 # check for fd passing struct via msg_acctrights
912 AC_CACHE_CHECK([for fd passing via msg_acctrights],
913                 samba_cv_msghdr_msg_acctrights, [
914     AC_TRY_COMPILE([
915 #include <sys/types.h>
916 #include <stdlib.h>
917 #include <stddef.h>
918 #include <sys/socket.h>
919 #include <sys/un.h>],
921         struct msghdr msg;
922         int fd;
923         msg.msg_acctrights = (caddr_t) &fd;
924         msg.msg_acctrightslen = sizeof(fd);
926         samba_cv_msghdr_msg_acctrights=yes,samba_cv_msghdr_msg_acctrights=no)])
927 if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then
928    AC_DEFINE(HAVE_MSGHDR_MSG_ACCTRIGHTS,1,
929              [If we can use msg_acctrights for passing file descriptors])
932 AC_CHECK_FUNCS(dirfd)
933 if test x"$ac_cv_func_dirfd" = x"yes"; then
934         default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort"
937 AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [
938     AC_TRY_COMPILE([
939 #include <sys/types.h>
940 #if STDC_HEADERS
941 #include <stdlib.h>
942 #include <stddef.h>
943 #endif
944 #include <signal.h>],[struct sigevent s;],
945         samba_cv_struct_sigevent=yes,samba_cv_struct_sigevent=no)])
946 if test x"$samba_cv_struct_sigevent" = x"yes"; then
947    AC_DEFINE(HAVE_STRUCT_SIGEVENT,1,[Whether we have the struct sigevent])
948    AC_CHECK_MEMBERS([struct sigevent.sigev_value.sival_ptr,struct sigevent.sigev_value.sigval_ptr], , ,
949         [#include <signal.h>])
952 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
953     AC_TRY_COMPILE([
954 #include <sys/types.h>
955 #if STDC_HEADERS
956 #include <stdlib.h>
957 #include <stddef.h>
958 #endif
959 #if TIME_WITH_SYS_TIME
960 # include <sys/time.h>
961 # include <time.h>
962 #else
963 # if HAVE_SYS_TIME_H
964 #  include <sys/time.h>
965 # else
966 #  include <time.h>
967 # endif
968 #endif
969 ],[struct timespec ts;],
970         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
971 if test x"$samba_cv_struct_timespec" = x"yes"; then
972    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
975 # and glibc has setresuid under linux but the function does
976 # nothing until kernel 2.1.44! very dumb.
977 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
978     AC_TRY_RUN([#include <errno.h>
979 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
980         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
981 if test x"$samba_cv_have_setresuid" = x"yes"; then
982     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
985 # Do the same check for setresguid...
987 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
988     AC_TRY_RUN([#include <unistd.h>
989 #include <errno.h>
990 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
991         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
992 if test x"$samba_cv_have_setresgid" = x"yes"; then
993     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
996 AC_FUNC_MEMCMP
998 ###############################################
999 # Readline included by default unless explicitly asked not to
1000 test "${with_readline+set}" != "set" && with_readline=yes
1002 # test for where we get readline() from
1003 AC_MSG_CHECKING(whether to use readline)
1004 AC_ARG_WITH(readline,
1005 [AS_HELP_STRING([--with-readline[=DIR]], [Look for readline include/libs in DIR (default=auto)])],
1006 [  case "$with_readline" in
1007   yes)
1008     AC_MSG_RESULT(yes)
1010     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1011     AC_CHECK_HEADERS(readline/history.h)
1013     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1014       for termlib in ncurses curses termcap terminfo termlib tinfo; do
1015        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1016       done
1017       AC_CHECK_LIB(readline, rl_callback_handler_install,
1018        [TERMLIBS="-lreadline $TERMLIBS"
1019        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1020        break], [TERMLIBS=], $TERMLIBS)])
1021     ;;
1022   no)
1023     AC_MSG_RESULT(no)
1024     ;;
1025   *)
1026     AC_MSG_RESULT(yes)
1028     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1029     # alternate readline path
1030     _ldflags=${LDFLAGS}
1031     _cppflags=${CPPFLAGS}
1033     # Add additional search path
1034     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1035     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1037     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1038     AC_CHECK_HEADERS(readline/history.h)
1040     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1041       for termlib in ncurses curses termcap terminfo termlib; do
1042        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1043       done
1044       AC_CHECK_LIB(readline, rl_callback_handler_install,
1045        [TERMLDFLAGS="-L$with_readline/lib"
1046        TERMCPPFLAGS="-I$with_readline/include"
1047        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1048        TERMLIBS="-lreadline $TERMLIBS"
1049        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1050        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1052     LDFLAGS=$_ldflags
1053     ;;
1054   esac],
1055   AC_MSG_RESULT(no)
1057 AC_SUBST(TERMLIBS)
1058 AC_SUBST(TERMLDFLAGS)
1060 # The readline API changed slightly from readline3 to readline4, so
1061 # code will generate warnings on one of them unless we have a few
1062 # special cases.
1063 AC_CHECK_LIB(readline, rl_completion_matches,
1064              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
1065                         [Do we have rl_completion_matches?])],
1066              [],
1067              [$TERMLIBS])
1069 # not all readline libs have rl_event_hook or history_list
1070 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
1071 AC_CHECK_LIB(readline, history_list,
1072              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
1073              [],
1074              [$TERMLIBS])
1076 ###############################################
1077 # test for where we get yp_get_default_domain() from
1078 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1079 AC_CHECK_FUNCS(yp_get_default_domain)
1081 # Check if we have execl, if not we need to compile smbrun.
1082 AC_CHECK_FUNCS(execl)
1083 if test x"$ac_cv_func_execl" = x"no"; then
1084     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1087 AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64)
1088 AC_CHECK_FUNCS(strtol)
1089 AC_CHECK_FUNCS(strchr chflags)
1090 AC_CHECK_FUNCS(getrlimit fsync setpgid)
1091 AC_CHECK_FUNCS(fdatasync,,[AC_CHECK_LIB_EXT(rt, LIBS, fdatasync)])
1092 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
1093 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1094 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
1095 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
1096 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
1097 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
1098 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1099 AC_CHECK_FUNCS(getpwent_r)
1100 AC_CHECK_FUNCS(getdents64)
1101 AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
1102 AC_CHECK_FUNCS(syslog vsyslog timegm)
1103 AC_CHECK_FUNCS(setlocale nl_langinfo)
1104 AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
1105 AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
1106 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1107 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
1108 AC_CHECK_HEADERS(sys/mman.h)
1109 # setbuffer, shmget, shm_open are needed for smbtorture
1110 AC_CHECK_FUNCS(shmget shm_open)
1111 AC_CHECK_FUNCS(gettext dgettext)
1112 AC_CHECK_FUNCS(bindtextdomain textdomain)
1113 AC_CHECK_FUNCS(strupr)
1115 # Find a method of generating a stack trace
1116 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1117 # libexecinfo provides backtrace_symbols on FreeBSD
1118 AC_SEARCH_LIBS(backtrace_symbols, [execinfo])
1119 AC_CHECK_FUNCS(backtrace_symbols)
1120 AC_CHECK_LIB(exc, trace_back_stack)
1122 # check for sysctlbyname for BSD systems
1123 AC_CHECK_FUNCS(sysctlbyname)
1125 #################################################
1126 # Check to see if core dump directory is defined in linux
1127 # with /proc/sys/kernel/core_pattern
1129 AC_CHECK_FILE([/proc/sys/kernel/core_pattern],
1130         AC_DEFINE(HAVE_SYS_KERNEL_PROC_CORE_PATTERN, 1,
1131         [Whether Linux kernel uses core_pattern for core files]),
1132          [])
1134 #############################
1135 # check if building with gpfs
1136 AC_CHECK_HEADERS(gpfs_gpl.h)
1137 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
1138     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
1139     default_shared_modules="$default_shared_modules vfs_gpfs"
1142 #############################################
1143 # check if building on Isilon OneFS
1144 printf "%s" "checking for Isilon OneFS... "
1145 save_LIBS="$LIBS"
1146 LIBS="$LIBS -lisi_version"
1147 AC_TRY_LINK([#include <isi_version/isi_version.h>],
1148           [get_isilon_copyright()],
1149           samba_cv_HAVE_ONEFS=yes,
1150           samba_cv_HAVE_ONEFS=no)
1151 echo $samba_cv_HAVE_ONEFS
1152 if test x"$samba_cv_HAVE_ONEFS" = x"yes"; then
1153     AC_DEFINE(HAVE_ONEFS,1,[Whether building on Isilon OneFS])
1154     default_shared_modules="$default_shared_modules vfs_onefs vfs_onefs_shadow_copy perfcount_onefs"
1155     default_static_modules="$default_static_modules"
1156     ONEFS_LIBS="-lisi_acl -lisi_ecs -lisi_event -lisi_util"
1157     # Need to also add general libs for oplocks support
1158     save_LIBS="$save_LIBS -lisi_ecs -lisi_event -lisi_util -ldevstat"
1160 AC_SUBST(ONEFS_LIBS)
1161 LIBS="$save_LIBS"
1163 # Note that all the libunwind symbols in the API are defined to internal
1164 # platform-specific version, so we must include libunwind.h before checking
1165 # any of them.
1166 AC_MSG_CHECKING([for libunwind])
1167 save_LIBS=$LIBS
1169 UNWIND_ARCH="unknown"
1170 if test x"$UNAME_I" != x"unknown"; then
1171         UNWIND_ARCH="$UNAME_I"
1172 elif test x"$UNAME_M" != x"unknown"; then
1173         UNWIND_ARCH="$UNAME_M"
1174 elif test x"$UNAME_P" != x"unknown"; then
1175         UNWIND_ARCH="$UNAME_P"
1178 case "$UNWIND_ARCH" in
1179         unknown)
1180                 # This probably won't link without
1181                 # the platform-specific libunwind.
1182                 LIBS="$LIBS -lunwind"
1183                 ;;
1184         i386|i586|i686)
1185                 # Add the platform-specific libunwind module.
1186                 LIBS="$LIBS -lunwind -lunwind-x86"
1187                 ;;
1188         *)
1189                 # Add the platform-specific libunwind module.
1190                 # based on uname -i, uname -m or uname -p
1191                 LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
1192                 ;;
1193 esac
1195 AC_TRY_LINK(
1196     [
1197 #ifdef HAVE_LIBUNWIND_H
1198 #include <libunwind.h>
1199 #endif
1200     ],
1201     [
1202         unw_context_t ctx; unw_cursor_t cur;
1203         char buf[256]; unw_word_t off;
1204         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1205         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1206     ],
1207     [
1208         AC_MSG_RESULT(yes)
1209         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1211         # If we have libunwind, test whether we also have libunwind-ptrace
1212         # which would let us unwind arbitrary processes.
1213         save_LIBS=$LIBS
1214         AC_CHECK_HEADERS(libunwind-ptrace.h)
1215         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1216             [
1217                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1218                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1219                     [Whether libunwind-ptrace.a is available.])
1220             ],
1221             [ LIBUNWIND_PTRACE="" ])
1223         LIBS=$save_LIBS
1224     ],
1225     [
1226         AC_MSG_RESULT(no)
1227         LIBS=$save_LIBS
1228     ])
1230 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1231 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1232     AC_CHECK_HEADERS(sys/ptrace.h)
1233     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1234     AC_TRY_LINK(
1235             [
1236 #if HAVE_SYS_TYPES_H
1237 #include <sys/types.h>
1238 #endif
1239 #if HAVE_SYS_PTRACE_H
1240 #include <sys/ptrace.h>
1241 #endif
1242             ],
1243             [
1244                 pid_t me = (pid_t)-1;
1245                 ptrace(PTRACE_ATTACH, me, 0, 0);
1246                 ptrace(PTRACE_DETACH, me, 0, 0);
1247                 return 0;
1248             ],
1249             [
1250                 AC_MSG_RESULT(yes)
1251                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1252                     [Whether the Linux ptrace(2) interface is available.])
1253             ],
1254             [
1255                 AC_MSG_RESULT(no)
1256                 LIBUNWIND_PTRACE=""
1257             ])
1260 AC_SUBST(LIBUNWIND_PTRACE)
1262 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1263 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1264 AC_CHECK_FUNCS(__getcwd _getcwd)
1265 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1266 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1267 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1268 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1269 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1270 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1271 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1272 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1273 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1274 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1275 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1276 AC_CHECK_FUNCS(prctl)
1278 AC_TRY_COMPILE([
1279 #ifdef HAVE_SYS_PRCTL_H
1280 #include <sys/prctl.h>
1281 #endif
1283 [int i; i = prtcl(0); ],
1284 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1289 case "$host_os" in
1290     *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
1291        # glibc <= 2.3.2 has a broken getgrouplist
1292        AC_CACHE_CHECK([for good getgrouplist],samba_cv_linux_getgrouplist_ok,[AC_TRY_RUN([
1293 #include <unistd.h>
1294 #include <sys/utsname.h>
1295 main() {
1296        /* glibc up to 2.3 has a broken getgrouplist */
1297 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1298        int libc_major = __GLIBC__;
1299        int libc_minor = __GLIBC_MINOR__;
1301        if (libc_major < 2)
1302               exit(1);
1303        if ((libc_major == 2) && (libc_minor <= 3))
1304               exit(1);
1305 #endif
1306        exit(0);
1308 ], [samba_cv_linux_getgrouplist_ok=yes],
1309    [samba_cv_linux_getgrouplist_ok=no],
1310    [samba_cv_linux_getgrouplist_ok=cross])])
1311        if test x"$samba_cv_linux_getgrouplist_ok" = x"yes"; then
1312           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1313        fi
1314        ;;
1315     *)
1316        AC_CHECK_FUNCS(getgrouplist)
1317        ;;
1318 esac
1321 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1324 if test x$ac_cv_func_stat64 = xno ; then
1325   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1326   AC_TRY_LINK([
1327 #if defined(HAVE_UNISTD_H)
1328 #include <unistd.h>
1329 #endif
1330 #include <sys/stat.h>
1331 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1332   AC_MSG_RESULT([$ac_cv_func_stat64])
1333   if test x$ac_cv_func_stat64 = xyes ; then
1334     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1335   fi
1338 if test x$ac_cv_func_lstat64 = xno ; then
1339   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1340   AC_TRY_LINK([
1341 #if defined(HAVE_UNISTD_H)
1342 #include <unistd.h>
1343 #endif
1344 #include <sys/stat.h>
1345 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1346   AC_MSG_RESULT([$ac_cv_func_lstat64])
1347   if test x$ac_cv_func_lstat64 = xyes ; then
1348     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1349   fi
1352 if test x$ac_cv_func_fstat64 = xno ; then
1353   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1354   AC_TRY_LINK([
1355 #if defined(HAVE_UNISTD_H)
1356 #include <unistd.h>
1357 #endif
1358 #include <sys/stat.h>
1359 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1360   AC_MSG_RESULT([$ac_cv_func_fstat64])
1361   if test x$ac_cv_func_fstat64 = xyes ; then
1362     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1363   fi
1366 #################################################
1367 # Check whether struct stat has timestamps with sub-second resolution.
1370 samba_cv_stat_hires=no
1371 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec], # Linux, Solaris
1372         [samba_cv_stat_hires=yes])
1373 AC_CHECK_MEMBERS([struct stat.st_mtimensec], # BSD, if defined _POSIX_SOURCE
1374         [samba_cv_stat_hires=yes])
1375 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec], # BSD, if not defined _POSIX_SOURCE
1376         [samba_cv_stat_hires=yes])
1377 AC_CHECK_MEMBERS([struct stat.st_mtime_n], # AIX
1378         [samba_cv_stat_hires=yes])
1379 AC_CHECK_MEMBERS([struct stat.st_umtime], # Tru64
1380         [samba_cv_stat_hires=yes])
1382 if test x"$samba_cv_stat_hires" = x"yes" ; then
1383     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1384             [whether struct stat has sub-second timestamps])
1387 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1388 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
1389 AC_CHECK_MEMBERS([struct stat.st_birthtime], AC_CHECK_MEMBERS([struct stat.st_birthtimensec]))
1392 AC_CACHE_CHECK([whether there is DOS flags support in the stat struct], samba_cv_stat_dos_flags,
1393     [
1394         AC_TRY_COMPILE(
1395             [#include <sys/stat.h>],
1396             [
1397                 int a = UF_DOS_ARCHIVE;
1398                 int h = UF_DOS_HIDDEN;
1399                 int r = UF_DOS_RO;
1400                 int s = UF_DOS_SYSTEM;
1401                 int i = UF_DOS_NOINDEX;
1402                 int f = UF_DOS_FLAGS;
1403             ],
1404             samba_cv_stat_dos_flags=yes, samba_cv_stat_dos_flags=no)
1405     ])
1407 if test x"$samba_cv_stat_dos_flags" = x"yes" ; then
1408     AC_DEFINE(HAVE_STAT_DOS_FLAGS, 1, [whether there is DOS flags support in the stat struct])
1411 AC_CACHE_CHECK([whether we can compile with __attribute__((destructor))],
1412                samba_cv_function_attribute_destructor,
1413                [
1414                  AC_COMPILE_IFELSE(
1415                         [
1416                                 __attribute__((destructor))
1417                                 static void cleanup(void) { }
1418                         ],
1419                         samba_cv_function_attribute_destructor=yes)
1420                 ])
1422 if test x"$samba_cv_function_attribute_destructor" = xyes ; then
1423    AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR, 1,
1424              [whether we can compile with __attribute__((destructor))])
1427 #####################################
1428 # needed for SRV lookups
1429 AC_CHECK_LIB(resolv, dn_expand)
1430 AC_CHECK_LIB(resolv, _dn_expand)
1431 AC_CHECK_LIB(resolv, __dn_expand)
1434 # Check for the functions putprpwnam, set_auth_parameters,
1435 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1436 # Needed for OSF1 and HPUX.
1439 AC_LIBTESTFUNC(security, putprpwnam)
1440 AC_LIBTESTFUNC(sec, putprpwnam)
1442 AC_LIBTESTFUNC(security, set_auth_parameters)
1443 AC_LIBTESTFUNC(sec, set_auth_parameters)
1445 # UnixWare 7.x has its getspnam in -lgen
1446 AC_LIBTESTFUNC(gen, getspnam)
1448 AC_LIBTESTFUNC(security, getspnam)
1449 AC_LIBTESTFUNC(sec, getspnam)
1451 AC_LIBTESTFUNC(security, bigcrypt)
1452 AC_LIBTESTFUNC(sec, bigcrypt)
1454 AC_LIBTESTFUNC(security, getprpwnam)
1455 AC_LIBTESTFUNC(sec, getprpwnam)
1457 AC_CHECK_FUNCS(strsignal)
1459 ############################################
1460 # Check for EA implementations
1461 case "$host_os" in
1462   *osf*)
1463         AC_SEARCH_LIBS(getproplist, [proplist])
1464         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1465         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1466         AC_CHECK_FUNCS(sizeof_proplist_entry)
1467   ;;
1468   *freebsd4* | *dragonfly* )
1469         AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1470   ;;
1471   *solaris*)
1472         AC_CHECK_FUNCS(attropen)
1473   ;;
1474   *)
1475         AC_SEARCH_LIBS(getxattr, [attr])
1476         AC_CHECK_FUNCS(getxattr,[
1477                 AC_CHECK_FUNCS(lgetxattr fgetxattr listxattr llistxattr flistxattr removexattr lremovexattr fremovexattr setxattr lsetxattr fsetxattr)
1478                 ])
1479         AC_CHECK_FUNCS(getea,[
1480                 AC_CHECK_FUNCS(fgetea lgetea listea flistea llistea removeea fremoveea lremoveea setea fsetea lsetea)
1481                 ])
1482         AC_CHECK_FUNCS(attr_get,[
1483                 AC_CHECK_FUNCS(attr_list attr_set attr_remove attr_getf attr_listf attr_setf attr_removef)
1484                 ])
1485         AC_CHECK_FUNCS(extattr_delete_file,[
1486                 AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file extattr_get_link extattr_list_fd extattr_list_file extattr_list_link extattr_set_fd extattr_set_file extattr_set_link)
1487                 ])
1488   ;;
1489 esac
1491 ########################################################
1492 # Do xattr functions take additional options like on Darwin?
1493 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1494         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1495                 old_LIBS=$LIBS
1496                 LIBS="$LIBS $ACL_LIBS"
1497                 AC_TRY_COMPILE([
1498                         #include <sys/types.h>
1499                         #if HAVE_ATTR_XATTR_H
1500                         #include <attr/xattr.h>
1501                         #elif HAVE_SYS_XATTR_H
1502                         #include <sys/xattr.h>
1503                         #endif
1504                 ],[
1505                         getxattr(0, 0, 0, 0, 0, 0);
1506                 ],
1507                 [smb_attr_cv_xattr_add_opt=yes],
1508                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1509         ])
1510         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1511                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1512         fi
1515 AC_DISABLE_STATIC
1516 AC_ENABLE_SHARED
1518 # Set defaults
1519 PIE_CFLAGS=""
1520 PIE_LDFLAGS=""
1521 AC_ARG_ENABLE(pie, [AS_HELP_STRING([--enable-pie], [Turn on pie support if available (default=yes)])])
1523 if test "x$enable_pie" != xno
1524 then
1525         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1526         [
1527                 cat > conftest.c <<EOF
1528 int foo;
1529 int main () { return 0;}
1531                 if AC_TRY_COMMAND_NO_STDERR([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c])
1532                 then
1533                         samba_cv_fpie=yes
1534                 else
1535                         samba_cv_fpie=no
1536                 fi
1537                 rm -f conftest*
1538         ])
1539         if test x"${samba_cv_fpie}" = x"yes"
1540         then
1541                 PIE_CFLAGS="-fPIE"
1542                 PIE_LDFLAGS="-pie"
1543         fi
1546 # Set defaults
1547 RELRO_LDFLAGS=""
1548 AC_ARG_ENABLE(relro, [AS_HELP_STRING([--enable-relro], [Turn on Relocations Read-Only (relro) support if available (default=yes)])])
1550 if test "x$enable_relro" != xno
1551 then
1552         AC_CACHE_CHECK([for -Wl,-z,relro], samba_cv_relro,
1553         [
1554                 cat > conftest.c <<EOF
1555 int foo;
1556 main () { return 0;}
1558                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1559                 then
1560                         samba_cv_relro=yes
1561                 else
1562                         samba_cv_relro=no
1563                 fi
1564                 rm -f conftest*
1565         ])
1566         if test x"${samba_cv_relro}" = x"yes"
1567         then
1568                 RELRO_LDFLAGS="-Wl,-z,relro"
1569         fi
1572 # Set defaults
1573 SYMSEXT="syms"
1574 AC_SUBST(SYMSEXT)
1576 # Assume non-shared by default and override below
1577 BLDSHARED="false"
1579 # these are the defaults, good for lots of systems
1580 HOST_OS="$host_os"
1581 LDSHFLAGS="-shared"
1582 MODULE_EXPORTS=""
1583 SONAMEFLAG="#"
1584 SHLD="\${CC} \${CFLAGS}"
1585 PICFLAG="${PIE_CFLAGS}"
1586 SHLIBEXT="so"
1587 DSO_EXPORTS=""
1589 # this bit needs to be modified for each OS that supports share libs
1590 # You need to specify how to create a shared library and
1591   # how to compile C code to produce PIC object files
1593   AC_MSG_CHECKING([ability to build shared libraries])
1595   # and these are for particular systems
1596   case "$host_os" in
1597                 *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
1598                         case "$host_os" in
1599                                 *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
1600                                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) ;;
1601                         esac
1602                         BLDSHARED="true"
1603                         LDSHFLAGS="-shared -Wl,-Bsymbolic"
1604                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1605                                 LDSHFLAGS_Z_NODEFS="-Wl,--allow-shlib-undefined"
1606                         fi
1607                         DYNEXP="-Wl,--export-dynamic"
1608                         PICFLAG="-fPIC"
1609                         SONAMEFLAG="-Wl,-soname="
1610                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1611                         ;;
1612                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1613                         BLDSHARED="true"
1614                         if test "${GCC}" = "yes"; then
1615                                 PICFLAG="-fPIC"
1616                                 SONAMEFLAG="-Wl,-soname="
1617                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1618                                         DYNEXP="-Wl,-E"
1619                                 fi
1620                                 LDSHFLAGS="-shared"
1621                         else
1622                                 PICFLAG="-KPIC"
1623                                 LDSHFLAGS="-G"
1624                         fi
1625                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1626                                 SONAMEFLAG="-Wl,-soname="
1627                         else
1628                                 SONAMEFLAG="-Wl,-h,"
1629                         fi
1630                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1631                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1632                         ;;
1633                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1634                         BLDSHARED="true"
1635                         LDSHFLAGS="-G"
1636                         SONAMEFLAG="-Wl,-h,"
1637                         PICFLAG="-KPIC"   # Is this correct for SunOS
1638                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1639                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1640                         ;;
1641                 *netbsd* | *freebsd* | *dragonfly* )
1642                         BLDSHARED="true"
1643                         LDSHFLAGS="-shared"
1644                         DYNEXP="-Wl,--export-dynamic"
1645                         SONAMEFLAG="-Wl,-soname,"
1646                         PICFLAG="-fPIC -DPIC"
1647                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1648                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1649                         ;;
1650                 *openbsd*)  BLDSHARED="true"
1651                         LDSHFLAGS="-shared"
1652                         DYNEXP="-Wl,-Bdynamic"
1653                         SONAMEFLAG="-Wl,-soname,"
1654                         PICFLAG="-fPIC"
1655                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1656                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1657                         ;;
1658                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1659                         case "$host_os" in
1660                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1661                         ;;
1662                         esac
1663                         BLDSHARED="true"
1664                         LDSHFLAGS="-Wl,-set_version,sgi1.0 -shared"
1665                         SONAMEFLAG="-Wl,-soname,"
1666                         if test "${GCC}" = "yes"; then
1667                                 PICFLAG="-fPIC"
1668                         else
1669                                 PICFLAG="-KPIC"
1670                         fi
1671                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1672                         ;;
1673                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1674                         BLDSHARED="true"
1675                         # use expfull to export underscored symbols
1676                         # add rtl to remove /lib/crt0.o warning
1677                         LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc,-brtl"
1678                         DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
1679                         PICFLAG="-O2"
1680                         # as AIX code is always position independent...
1681                         # .po will just create compile warnings, use po.o:
1682                         if test "${GCC}" != "yes"; then
1683                                 ## for funky AIX compiler using strncpy()
1684                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 -qhalt=e"
1685                         fi
1687                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1688                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1689                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1690                         ;;
1691                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1692                         # ia64: 64bit build using gcc with CFLAGS="-mpl64"
1693                         #       64bit build using HP's cc with CFLAGS="+DD64"
1694                         # hppa: 64bit build unsupported by gcc
1695                         #       64bit build using HP's cc with CFLAGS="+DA2.0w"
1696                         # HP-UX 11.00 ld needs PHSS_33034
1697                         BLDSHARED="true"
1698                         if test "${GCC}" = "yes"; then
1699                                 PICFLAG="-fPIC"
1700                                 LDSHFLAGS="-shared"
1701                         else
1702                                 PICFLAG="+z"
1703                                 LDSHFLAGS="-b"
1704                                 # "Uses depth-first symbol resolution"
1705                                 LDSHFLAGS="$LDSHFLAGS -Wl,-B,symbolic,-b"
1706                                 if test "$host_cpu" != "ia64"; then
1707                                         # "don't store literals in read-only memory" (?):
1708                                         PICFLAG="$PICFLAG +ESnolit"
1709                                 fi
1710                         fi
1711                         if test "$host_cpu" = "ia64"; then
1712                                 SHLIBEXT="so"
1713                                 # TODO: does the linker find the right 32/64 bit version of the libs? :
1714                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32:/usr/local/lib/hpux64:/usr/lib/hpux64"
1715                         else
1716                                 SHLIBEXT="sl"
1717                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1718                         fi
1719                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1720                                 SONAMEFLAG="-Wl,-soname="
1721                         else
1722                                 SONAMEFLAG="-Wl,+h,"
1723                         fi
1724                         # PIE/PIC flags at link time are required on HP-UX because
1725                         # linking requires a temporary source file, which is being
1726                         # compiled with the indicated flags - which need to contain
1727                         # PIC flags when we don't support PIE flags:
1728                         if test "$PIE_LDFLAGS" = "" ; then
1729                                 PIE_LDFLAGS=\${PICFLAG}
1730                         fi
1731                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1732                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1733                         ;;
1734                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1735                         BLDSHARED="true"
1736                         LDSHFLAGS="-shared"
1737                         SONAMEFLAG="-Wl,-soname,"
1738                         PICFLAG="-fPIC"
1739                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1740                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1741                         for flags in "-expect_unresolved '*'" "-Wl,-expect_unresolved,'*'" ; do
1742                                 saved_ldflags="$LDFLAGS"
1743                                 AC_MSG_CHECKING([if $flags works])
1744                                 LDFLAGS="$flags $saved_ldflags"
1745                                 AC_TRY_LINK([],[],
1746                                         [AC_MSG_RESULT([yes])
1747                                         LDSHFLAGS_Z_NODEFS=$flags],
1748                                         AC_MSG_RESULT([no]))
1749                                 LDFLAGS="$saved_ldflags"
1750                                 test x"$LDSHFLAGS_Z_NODEFS" != x && break
1751                         done
1752                         ;;
1753                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1754                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1755                         ;;
1756                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1757                         BLDSHARED="true"
1758                         LDSHFLAGS="-shared"
1759                         SONAMEFLAG="-Wl,-soname,"
1760                         PICFLAG="-KPIC"
1761                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1762                         ;;
1763                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1764                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1765                         ;;
1766                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1767                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1768                         ;;
1769                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1770                         case "$host" in
1771                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1772                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1773                                         fi
1774                                         LDSHFLAGS="-G"
1775                                         DYNEXP="-Bexport"
1776                                 ;;
1777                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1778                         esac
1779                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1780                         ;;
1782                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1783                         if [ test "$GCC" != yes ]; then
1784                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1785                         fi
1786                         LDSHFLAGS="-G"
1787                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1788                         ;;
1789                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1790                         BLDSHARED="false"
1791                         LDSHFLAGS=""
1792                         ;;
1794                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1795                         BLDSHARED="true"
1796                         LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress"
1797                         CFLAGS="$CFLAGS -fno-common"
1798                         SHLD="\${CC}"
1799                         SHLIBEXT="dylib"
1800                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
1801                         SHLIBEXT="dylib"
1802                         # Since gcc doesn't fail on unrecognised options, the
1803                         # PIE test incorrectly succeeds. Darwin gcc does not
1804                         # actually support the PIE stuff.
1805                         PIE_LDFLAGS=
1806                         PIE_CFLAGS=
1807                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1808                         ;;
1810                 *)
1811                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1812                         ;;
1813   esac
1815 if test "$enable_shared" != "yes"; then
1816         BLDSHARED=false
1819 if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
1820         DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
1823 if test x"$BLDSHARED" = x"true" ; then
1824         LDFLAGS="$LDFLAGS -L./bin"
1827 AC_MSG_RESULT($BLDSHARED)
1829 if test x"$enable_developer" = x"yes" ; then
1830         default_as_needed=auto
1831 else
1832         default_as_needed=no
1834 AC_ARG_ENABLE(as-needed,
1835         AS_HELP_STRING([--enable-as-needed],
1836         [Turn on as-needed support if available (default=no)]),
1837         [enable_as_needed=$enableval],
1838         [enable_as_needed=$default_as_needed])
1839 if test "x$enable_as_needed" != xno; then
1840     saved_before_as_needed_ldflags="$LDFLAGS"
1841     for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
1842         saved_ldflags="$LDFLAGS"
1843         AC_MSG_CHECKING([if $flags works])
1844         LDFLAGS="$flags $saved_ldflags"
1845         AC_TRY_LINK([],[],
1846                 [AC_MSG_RESULT([yes])
1847                 LD_AS_NEEDED_FLAG=$flags
1848                 ld_as_needed_flag_found=yes],
1849                 AC_MSG_RESULT([no]))
1850         LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
1851         test x"$ld_as_needed_flag_found" = xyes && break
1852     done
1855 if test x$ld_as_needed_flag_found = xyes -a x$enable_as_needed = xauto ; then
1856 # check if ld has bug described in https://bugzilla.samba.org/show_bug.cgi?id=7209#c17
1857         AC_MSG_CHECKING([if $LD_AS_NEEDED_FLAG has explicit external libs bug])
1858 cat > conftest_shb.c <<END
1859 void b() {}
1861 cat > conftest_sha.c <<END
1862 extern void b();
1863 void a() {
1864         b();
1867 cat > conftest.c <<END
1868 extern void a();
1869 int main() {
1870         a();
1871         return 0;
1875         rm -fr conftest
1876         AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o conftest_sha.o conftest_sha.c 1>&AS_MESSAGE_LOG_FD 2>&1])
1877         AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o conftest_shb.o conftest_shb.c 1>&AS_MESSAGE_LOG_FD 2>&1])
1878         TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
1879         AC_TRY_COMMAND([$TESTCMD -o libconftest_shb.$SHLIBEXT conftest_shb.o 1>&AS_MESSAGE_LOG_FD 2>&1])
1880         AC_TRY_COMMAND([$TESTCMD -o libconftest_sha.$SHLIBEXT conftest_sha.o 1>&AS_MESSAGE_LOG_FD 2>&1])
1881         AC_TRY_COMMAND([$CC -o conftest conftest.c $LDFLAGS -L. -lconftest_sha -lconftest_shb 1>&AS_MESSAGE_LOG_FD 2>&1])
1882         if AC_TRY_COMMAND([eval "$LIB_PATH_VAR=. ./conftest 1>&AS_MESSAGE_LOG_FD 2>&1"])
1883         then
1884                 AC_MSG_RESULT([no])
1885         else
1886                 ld_as_needed_flag_found=no
1887                 LDFLAGS="$saved_before_as_needed_ldflags"
1888                 AC_MSG_RESULT([yes])
1889         fi
1890         rm conftest* libconftest*
1893 # check if we have to disable LD_AS_NEEDED_FLAG:
1894 # On some systems for a veriety of reasons linking with
1895 # -Wl,--as-needed -lreadline -lncurses fails
1896 # we have to retest, if these combination is detected before.
1897 # Bugzilla #7209
1899 if test x$ac_cv_lib_readline_rl_callback_handler_install = xyes ; then
1900         if test x$ld_as_needed_flag_found = xyes ; then
1901                 AC_MSG_CHECKING([if $LD_AS_NEEDED_FLAG works with readline])
1902                 # try if check no fails
1903                 save_LIBS=$LIBS
1904                 LIBS="$LIBS $TERMLIBS"
1905                 AC_TRY_LINK([], [rl_callback_handler_install();], [AC_MSG_RESULT([yes])],[ AC_MSG_RESULT([no]); LDFLAGS="$saved_before_as_needed_ldflags"])
1906                 LIBS="$save_LIBS"
1907         fi
1912 # for historical reasons almost all linkers don't complain about unresolved
1913 # symbols in shared libs. Except for the internal samba modules we want to get
1914 # errors when we produce a shared lib with unresolved symbols. On some
1915 # platforms unresolved symbols might be intended, so we might have to add
1916 # platform specific exceptions here.
1918 for flags in "-Wl,-z,defs" "-error_unresolved" "-Wl,-error_unresolved" ; do
1919         saved_ldflags="$LDFLAGS"
1920         AC_MSG_CHECKING([if $flags works])
1921         LDFLAGS="$flags $saved_ldflags"
1922         AC_TRY_LINK([],[],
1923         [AC_MSG_RESULT([yes])
1924         LDSHFLAGS_Z_DEFS=$flags
1925         ldshflags_z_defs_found=yes],
1926         AC_MSG_RESULT([no]))
1927         LDFLAGS=$saved_ldflags
1928         test x"$ldshflags_z_defs_found" = xyes && break
1929 done
1931 AC_MSG_CHECKING([LDSHFLAGS_Z_DEFS])
1932 AC_MSG_RESULT([$LDSHFLAGS_Z_DEFS])
1933 AC_MSG_CHECKING([LDFLAGS])
1934 AC_MSG_RESULT([$LDFLAGS])
1935 AC_MSG_CHECKING([DYNEXP])
1936 AC_MSG_RESULT([$DYNEXP])
1938 #######################################################
1939 # test whether building a shared library actually works
1940 if test $BLDSHARED = true; then
1942 AC_MSG_CHECKING([SHLD])
1943 AC_MSG_RESULT([$SHLD])
1944 AC_MSG_CHECKING([LDSHFLAGS])
1945 AC_MSG_RESULT([$LDSHFLAGS])
1947 AC_MSG_CHECKING([SHLIBEXT])
1948 AC_MSG_RESULT([$SHLIBEXT])
1949 AC_MSG_CHECKING([SONAMEFLAG])
1950 AC_MSG_RESULT([$SONAMEFLAG])
1952 AC_MSG_CHECKING([PICFLAG])
1953 AC_MSG_RESULT([$PICFLAG])
1955 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
1956 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
1958 AC_CACHE_CHECK([whether building shared libraries actually works],
1959                [ac_cv_shlib_works],[
1960    # try building a trivial shared library
1961    ac_cv_shlib_works=no
1962    # The $SHLD and $LDSHFLAGS variables may contain references to other
1963    # variables so they need to be eval'ed.
1964    if AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.o ${srcdir-.}/../tests/shlib.c 1>&AS_MESSAGE_LOG_FD])
1965    then
1966      TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
1967      TESTCMD="$TESTCMD -o \"shlib.$SHLIBEXT\" shlib.o"
1968      if AC_TRY_COMMAND([eval $TESTCMD 1>&AS_MESSAGE_LOG_FD 2>&1])
1969      then
1970        ac_cv_shlib_works=yes
1971      fi
1972    fi
1973    rm -f "shlib.$SHLIBEXT" shlib.o
1976 if test $ac_cv_shlib_works = no; then
1977    BLDSHARED=false
1981 if test x"$BLDSHARED" != x"true"; then
1982         LDSHFLAGS="shared-libraries-disabled"
1983         SONAMEFLAG="shared-libraries-disabled"
1984         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
1985         SHLD="shared-libraries-disabled"
1986         PICFLAG="${PIE_CFLAGS}"
1987         SHLIBEXT="shared_libraries_disabled"
1988         merged_build_possible=no
1991 AC_MSG_CHECKING([used PICFLAG])
1992 AC_MSG_RESULT([$PICFLAG])
1994 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
1998 ###########################################################
2000 # Configuration of subsystems / libraries
2002 ###########################################################
2004 INSTALLLIBCMD_SH=:
2005 INSTALLLIBCMD_A=:
2006 UNINSTALLLIBCMD_SH=:
2007 UNINSTALLLIBCMD_A=:
2009 if test $BLDSHARED = true; then
2010         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
2011         UNINSTALLLIBCMD_SH="rm -f"
2013 if test $enable_static = yes; then
2014         INSTALLLIBCMD_A="\$(INSTALLCMD)"
2015         UNINSTALLLIBCMD_A="rm -f"
2018 #################################################
2019 # --disable-shared-libs
2020 # can be used to disable the internal use of shared libs altogether
2021 # (this only has an effect when building shared libs is enabled)
2023 USESHARED=false
2024 AC_SUBST(USESHARED)
2026 AC_MSG_CHECKING(whether to use shared libraries internally)
2027 AC_ARG_ENABLE([shared-libs],
2028         AS_HELP_STRING([--enable-shared-libs],
2029                 [Use shared libraries internally (default=yes)]),
2030         [enable_shared_libs=$enableval],
2031         [enable_shared_libs=yes])
2033 if test x"$enable_shared_libs" != x"no" ; then
2034         USESHARED=$BLDSHARED
2037 AC_MSG_RESULT([$USESHARED])
2039 if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
2040         AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
2043 #################################################
2044 # --with-static-libs=LIBS:
2045 #   link (internal) libs dynamically or statically?
2047 # If a subsystem is built as a library then this controls whether they are
2048 # linked into Samba targets statically or dynamically:
2050 # * If we build the shared library at all, we link dynamically by default.
2052 # * We only link statically if we don't build shared or if the library
2053 #   appears in the --with-static-libs configure option.
2055 # Example:
2056 #   --with-static-libs=libtalloc makes use of libtalloc.a instead
2057 #   of linking the dynamic variant with -ltalloc.
2059 # NOTE: This option only affects libraries that we do not only build
2060 # but that samba also links against as libraries (as opposed to linking
2061 # the plain object files. - This has to be configured in Makefile.in.
2062 # So in particular it does not harm to give invalid or unknown names here.
2065 AC_ARG_WITH([static-libs],
2066         [AS_HELP_STRING([--with-static-libs=LIBS],
2067                 [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
2068         [AS_IF([test $withval],
2069                 [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
2070                         [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
2071                         eval LINK_$lib=STATIC
2072                 done], [])],
2073         [])
2076 # WORKAROUND:
2077 #   until we have organized other internal subsystems (as util, registry
2078 #   and smbconf) into shared libraries, we CAN NOT link libnetapi
2079 #   dynamically to samba programs.
2081 LINK_LIBNETAPI=STATIC
2083 LINK_LIBSMBCLIENT=STATIC
2086 #  The library versions are hardcoded here
2087 #  and filled into the LIBFOO_SOVER variable.
2089 #  TODO: for talloc and tdb (at least), these should
2090 #  be extracted from their respective source directories
2092 AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
2093 [ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
2095 if test "x$enable_external_libtalloc" != xno
2096 then
2097         PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1,
2098                 [ enable_external_libtalloc=yes ],
2099                 [ if test x$enable_external_libtalloc = xyes; then
2100                         AC_MSG_ERROR([Unable to find libtalloc])
2101                   else
2102                         enable_external_libtalloc=no
2103                   fi
2104                 ])
2107 if test "x$enable_external_libtalloc" = xno
2108 then
2109         m4_include(../lib/talloc/libtalloc.m4)
2110         LINK_LIBTALLOC=STATIC
2111         SMB_LIBRARY(talloc, 2)
2112         LIBTALLOC_OBJ0=""
2113         for obj in ${TALLOC_OBJ}; do
2114                 LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
2115         done
2116         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
2117         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TALLOC_CFLAGS}"
2118         AC_SUBST(LIBTALLOC_OBJ0)
2120         TALLOCTORT="bin/talloctort\$(EXEEXT)"
2121         AC_SUBST(TALLOCTORT)
2125 AC_ARG_ENABLE(external_libtdb,
2126         [AS_HELP_STRING([--enable-external-libtdb],
2127                 [Enable external tdb [default=auto]])],
2128                 [ enable_external_libtalloc=$enableval ],
2129                 [ enable_external_libtalloc=auto ])
2131 if test "x$enable_external_libtdb" != xno
2132 then
2133         PKG_CHECK_MODULES(LIBTDB, tdb >= 1.2.6,
2134                 [ enable_external_libtdb=yes ],
2135                 [
2136                 if test x$enable_external_libtdb = xyes; then
2137                         AC_MSG_ERROR([Unable to find libtdb])
2138                 else
2139                         enable_external_libtdb=no
2140                 fi
2141                 ])
2144 AC_SUBST(LIBTDB_OBJ0)
2145 if test "x$enable_external_libtdb" = xno
2146 then
2147         m4_include(../lib/tdb/libtdb.m4)
2148         LINK_LIBTDB=STATIC
2149         SMB_LIBRARY(tdb, 1)
2150         LIBTDB_OBJ0=""
2151         LIBTDB_LIBS="$LIBTDB_LIBS $TDB_DEPS"
2152         for obj in ${TDB_OBJ}; do
2153                 LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
2154         done
2155         AC_SUBST(LIBTDB_OBJ0)
2156         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
2157         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TDB_CFLAGS}"
2159         TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
2160         AC_SUBST(TDBBACKUP)
2161         TDBDUMP="bin/tdbdump\$(EXEEXT)"
2162         AC_SUBST(TDBDUMP)
2163         TDBRESTORE="bin/tdbrestore\$(EXEEXT)"
2164         AC_SUBST(TDBRESTORE)
2165         TDBTOOL="bin/tdbtool\$(EXEEXT)"
2166         AC_SUBST(TDBTOOL)
2167         TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
2168         AC_SUBST(TDBTORTURE)
2169         ac_cv_have_tdb_err_nesting=yes
2170 else
2171         AC_TRY_COMPILE([#include "tdb.h"],
2172                        [enum TDB_ERROR err = TDB_ERR_NESTING],
2173                        ac_cv_have_tdb_err_nesting=yes,
2174                        ac_cv_have_tdb_err_nesting=no)
2177 if test x"$ac_cv_have_tdb_err_nesting" = xyes; then
2178    AC_DEFINE(HAVE_TDB_ERR_NESTING, 1, [Whether we have TDB_ERR_NESTING])
2181 SMB_LIBRARY(netapi, 0)
2182 SMB_LIBRARY(smbclient, 0)
2183 SMB_LIBRARY(smbsharemodes, 0)
2184 SMB_LIBRARY(addns, 0, no, [undefined API])
2188 ################
2190 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
2191 AC_TRY_RUN([#include <stdio.h>
2192 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
2193 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
2194 if test x"$samba_cv_have_longlong" = x"yes"; then
2195     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
2196     AC_CHECK_TYPE(intptr_t, unsigned long long)
2197 else
2198     AC_CHECK_TYPE(intptr_t, unsigned long)
2202 # Check if the compiler supports the LL prefix on long long integers.
2203 # AIX needs this.
2205 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
2206     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
2207         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
2208 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
2209    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
2213 AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
2214 AC_TRY_RUN([#include <time.h>
2215 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
2216 samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
2217 if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
2218     AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
2221 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
2222 AC_TRY_RUN([#include <stdio.h>
2223 #include <sys/stat.h>
2224 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
2225 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
2226 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
2227     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
2230 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
2231 AC_TRY_RUN([
2232 #if defined(HAVE_UNISTD_H)
2233 #include <unistd.h>
2234 #endif
2235 #include <stdio.h>
2236 #include <sys/stat.h>
2237 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2238 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
2239 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
2240     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
2243 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
2244 AC_TRY_RUN([
2245 #if defined(HAVE_UNISTD_H)
2246 #include <unistd.h>
2247 #endif
2248 #include <stdio.h>
2249 #include <sys/stat.h>
2250 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
2251 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
2252 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
2253     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
2256 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
2257 AC_TRY_RUN([
2258 #if defined(HAVE_UNISTD_H)
2259 #include <unistd.h>
2260 #endif
2261 #include <stdio.h>
2262 #include <sys/stat.h>
2263 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2264 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
2265 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
2266     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
2269 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
2270 AC_TRY_RUN([
2271 #if defined(HAVE_UNISTD_H)
2272 #include <unistd.h>
2273 #endif
2274 #include <stdio.h>
2275 #include <sys/stat.h>
2276 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
2277 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
2278 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
2279     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
2282 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
2283 AC_TRY_RUN([
2284 #if defined(HAVE_UNISTD_H)
2285 #include <unistd.h>
2286 #endif
2287 #include <stdio.h>
2288 #include <sys/stat.h>
2289 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2290 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
2291 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
2292     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
2295 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
2296 AC_TRY_COMPILE([
2297 #if defined(HAVE_UNISTD_H)
2298 #include <unistd.h>
2299 #endif
2300 #include <sys/types.h>
2301 #include <dirent.h>],
2302 [DIR64 de;],
2303 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
2304 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2305     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
2308 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
2309 AC_TRY_COMPILE([
2310 #if defined(HAVE_UNISTD_H)
2311 #include <unistd.h>
2312 #endif
2313 #include <sys/types.h>
2314 #include <dirent.h>],
2315 [struct dirent64 de;],
2316 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
2317 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2318     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
2321 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
2322 AC_TRY_RUN([
2323 #if defined(HAVE_UNISTD_H)
2324 #include <unistd.h>
2325 #endif
2326 #include <sys/types.h>
2327 main() { dev_t dev; int i = major(dev); return 0; }],
2328 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
2329 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
2330     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
2333 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
2334 AC_TRY_RUN([
2335 #if defined(HAVE_UNISTD_H)
2336 #include <unistd.h>
2337 #endif
2338 #include <sys/types.h>
2339 main() { dev_t dev; int i = minor(dev); return 0; }],
2340 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
2341 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
2342     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
2345 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
2346 AC_TRY_RUN([
2347 #if defined(HAVE_UNISTD_H)
2348 #include <unistd.h>
2349 #endif
2350 #include <sys/types.h>
2351 main() { dev_t dev = makedev(1,2); return 0; }],
2352 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
2353 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
2354     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
2357 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
2358 AC_TRY_RUN([#include <stdio.h>
2359 main() { char c; c=250; exit((c > 0)?0:1); }],
2360 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
2361 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
2362     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
2365 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
2366 AC_TRY_COMPILE([#include <sys/types.h>
2367 #include <dirent.h>
2368 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2369 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2370 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2371     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2374 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2375 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2376 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2377 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2378     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2381 if test x"$libreplace_cv_HAVE_CLOCK_GETTIME_IN_LIBRT" = xyes ; then
2382         LIBS="$LIBS -lrt"
2385 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2386 AC_TRY_RUN([#include <sys/types.h>
2387 #include <dirent.h>
2388 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2389 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2390 di->d_name[0] == 0) exit(0); exit(1);} ],
2391 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2392 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2393     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2396 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2397 AC_TRY_COMPILE([#include <sys/types.h>
2398 #include <utime.h>],
2399 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2400 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2401 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2402     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2405 ##############
2406 # Check utmp details, but only if our OS offers utmp.h
2407 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2408 dnl  utmp and utmpx come in many flavours
2409 dnl  We need to check for many of them
2410 dnl  But we don't need to do each and every one, because our code uses
2411 dnl  mostly just the utmp (not utmpx) fields.
2413 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx getutxent)
2415 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2416 AC_TRY_COMPILE([#include <sys/types.h>
2417 #include <utmp.h>],
2418 [struct utmp ut;  ut.ut_name[0] = 'a';],
2419 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2420 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2421     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2424 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2425 AC_TRY_COMPILE([#include <sys/types.h>
2426 #include <utmp.h>],
2427 [struct utmp ut;  ut.ut_user[0] = 'a';],
2428 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2429 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2430     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2433 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2434 AC_TRY_COMPILE([#include <sys/types.h>
2435 #include <utmp.h>],
2436 [struct utmp ut;  ut.ut_id[0] = 'a';],
2437 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2438 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2439     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2442 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2443 AC_TRY_COMPILE([#include <sys/types.h>
2444 #include <utmp.h>],
2445 [struct utmp ut;  ut.ut_host[0] = 'a';],
2446 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2447 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2448     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2451 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2452 AC_TRY_COMPILE([#include <sys/types.h>
2453 #include <utmp.h>],
2454 [struct utmp ut;  time_t t; ut.ut_time = t;],
2455 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2456 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2457     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2460 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2461 AC_TRY_COMPILE([#include <sys/types.h>
2462 #include <utmp.h>],
2463 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2464 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2465 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2466     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2469 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2470 AC_TRY_COMPILE([#include <sys/types.h>
2471 #include <utmp.h>],
2472 [struct utmp ut;  ut.ut_type = 0;],
2473 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2474 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2475     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2478 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2479 AC_TRY_COMPILE([#include <sys/types.h>
2480 #include <utmp.h>],
2481 [struct utmp ut;  ut.ut_pid = 0;],
2482 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2483 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2484     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2487 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2488 AC_TRY_COMPILE([#include <sys/types.h>
2489 #include <utmp.h>],
2490 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2491 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2492 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2493     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2496 dnl Look for the IPv6 varient by preference. Many systems have both.
2497 AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
2498 AC_TRY_COMPILE([#include <sys/types.h>
2499 #include <utmp.h>],
2500 [struct utmp ut;  ut.ut_addr_v6[0] = 0;],
2501 samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
2502 if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
2503     AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
2506 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2507 AC_TRY_COMPILE([#include <sys/types.h>
2508 #include <utmp.h>],
2509 [struct utmp ut;  ut.ut_addr = 0;],
2510 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2511 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2512     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2515 if test x$ac_cv_func_pututline = xyes ; then
2516   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2517   AC_TRY_COMPILE([#include <sys/types.h>
2518 #include <utmp.h>],
2519   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2520   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2521   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2522       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2523   fi
2526 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2527 AC_TRY_COMPILE([#include <sys/types.h>
2528 #include <utmpx.h>],
2529 [struct utmpx ux;  ux.ut_syslen = 0;],
2530 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2531 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2532     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2536 # end utmp details
2539 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
2540 AC_ARG_WITH(libiconv,
2541 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
2543   if test "$withval" = "no" ; then
2544     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2545   else
2546      if test "$withval" != "yes" ; then
2547         ICONV_PATH_SPEC=yes
2548         ICONV_LOOK_DIRS="$withval"
2549      fi
2550   fi
2553 for i in $ICONV_LOOK_DIRS ; do
2555     save_LIBS="$LIBS"
2556     save_LDFLAGS="$LDFLAGS"
2557     save_CPPFLAGS="$CPPFLAGS"
2559     iconv_current_LIBS=""
2560     iconv_current_LDFLAGS=""
2561     iconv_current_CPPFLAGS=""
2563     ICONV_FOUND="no"
2564     unset libext
2566     #  This is here to handle -withval stuff for --with-libiconv
2567     #  Perhaps we should always add a -L
2568     CPPFLAGS="$save_CPPFLAGS -I$i/include"
2570     # Check lib and lib32 library variants to cater for IRIX ABI-specific
2571     # installation paths. This gets a little tricky since we might have iconv
2572     # in both libiconv and in libc. In this case the jm_ICONV test will always
2573     # succeed when the header is found. To counter this, make sure the
2574     # library directory is there and check the ABI directory first (which
2575     # should be harmless on other systems, but causes tons of linker warnings on
2576     # 64bit Ubuntu systems).
2577     # As the build farm doesn't seem to have any IRIX machines with iconv.h
2578     # installed, I've decided to fix the linker warnings.
2579     # -- Kai
2580     # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2581     for l in "lib" "lib32" "lib/hpux32"; do
2582         if test -d "$i/$l" ; then
2583                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2584                 LIBS=
2585                 export LDFLAGS LIBS CPPFLAGS
2586                 # Try to find iconv(3)
2587                 jm_ICONV($i/$l)
2588                 if test x"$ICONV_FOUND" = "xyes" ; then
2589                     libext="$l"
2590                     break
2591                 fi
2592         fi
2593     done
2595     if test x"$ICONV_FOUND" = "xyes" ; then
2596         iconv_current_LDFLAGS="-L$i/$libext"
2597         iconv_current_CPPFLAGS="-I$i/include"
2599         if test x"$jm_cv_lib_iconv" != x; then
2600             iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
2601         else
2602             # We found iconv in libc.
2603             iconv_current_LIBS=""
2604         fi
2606     fi
2608     if test x"$ICONV_FOUND" = "xyes" ; then
2610         LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
2611         CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
2612         LIBS="$save_LIBS $iconv_current_LIBS"
2613         export LDFLAGS LIBS CPPFLAGS
2615         default_dos_charset=no
2616         default_display_charset=no
2617         default_unix_charset=no
2619         # check for default dos charset name
2620         for j in CP850 IBM850 ; do
2621             rjs_CHARSET($j)
2622             default_dos_charset="$ICONV_CHARSET"
2623             if test x"$default_dos_charset" = x"$j"; then
2624                 break
2625             fi
2626         done
2628         # check for default display charset name
2629         for j in ASCII 646 ; do
2630             rjs_CHARSET($j)
2631             default_display_charset="$ICONV_CHARSET"
2632             if test x"$default_display_charset" = x"$j"; then
2633                 break
2634             fi
2635         done
2637         # check for default unix charset name
2638         for j in UTF-8 UTF8 ; do
2639             rjs_CHARSET($j)
2640             default_unix_charset="$ICONV_CHARSET"
2641             if test x"$default_unix_charset" = x"$j"; then
2642                 break
2643             fi
2644         done
2646         if test "$default_dos_charset" != "no" -a \
2647                 "$default_dos_charset" != "cross" -a \
2648                 "$default_display_charset" != "no" -a \
2649                 "$default_display_charset" != "cross" -a \
2650                 "$default_unix_charset" != "no" -a \
2651                 "$default_unix_charset" != "cross"
2652         then
2653                 samba_cv_HAVE_NATIVE_ICONV=yes
2654         else
2655             if test "$default_dos_charset" = "cross" -o \
2656                      "$default_display_charset" = "cross" -o \
2657                      "$default_unix_charset" = "cross"
2658             then
2659                     samba_cv_HAVE_NATIVE_ICONV=cross
2660             else
2661                     samba_cv_HAVE_NATIVE_ICONV=no
2662             fi
2663         fi
2665         # At this point, we have a libiconv candidate. We know that
2666         # we have the right headers and libraries, but we don't know
2667         # whether it does the conversions we want. We can't test this
2668         # because we are cross-compiling. This is not necessarily a big
2669         # deal, since we can't guarantee that the results we get now will
2670         # match the results we get at runtime anyway.
2671         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
2672             default_dos_charset="CP850"
2673             default_display_charset="ASCII"
2674             default_unix_charset="UTF-8"
2675             samba_cv_HAVE_NATIVE_ICONV=yes
2676             AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
2677             AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
2678         fi
2680         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
2682             CPPFLAGS=$save_CPPFLAGS
2683             LDFLAGS=$save_LDFLAGS
2684             LIBS=$save_LIBS
2686             if test x"$iconv_current_LIBS" != x; then
2687                 LIBS="$LIBS $iconv_current_LIBS"
2688             fi
2690             # Add the flags we need to CPPFLAGS and LDFLAGS
2691             CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
2692             LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
2694             # Turn the #defines into string literals
2695             default_dos_charset="\"$default_dos_charset\""
2696             default_display_charset="\"$default_display_charset\""
2697             default_unix_charset="\"$default_unix_charset\""
2699             AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2700             AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2701             AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2702             AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2704            break
2705         fi
2707     # We didn't find a working iconv, so keep going
2708     fi
2710     #  We only need to clean these up here for the next pass through the loop
2711     CPPFLAGS=$save_CPPFLAGS
2712     LDFLAGS=$save_LDFLAGS
2713     LIBS=$save_LIBS
2714     export LDFLAGS LIBS CPPFLAGS
2715 done
2716 unset libext
2719 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2720     AC_MSG_WARN([Sufficient support for iconv function was not found.
2721     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2722    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2723    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2724    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2728 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2729 AC_TRY_RUN([
2730 #include <sys/types.h>
2731 #include <fcntl.h>
2732 #ifndef F_GETLEASE
2733 #define F_GETLEASE      1025
2734 #endif
2735 main() {
2736        int fd = open("/dev/null", O_RDONLY);
2737        return fcntl(fd, F_GETLEASE, 0) == -1;
2740 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2741 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2742     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2745 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2746 AC_TRY_RUN([
2747 #include <sys/types.h>
2748 #include <fcntl.h>
2749 #include <signal.h>
2750 #ifndef F_NOTIFY
2751 #define F_NOTIFY 1026
2752 #endif
2753 main() {
2754         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2757 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2758 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2759     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2762 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2763 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h sys/inotify.h)
2764 AC_CHECK_FUNCS(inotify_init)
2765 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2767 samba_cv_HAVE_INOTIFY=yes,
2768 samba_cv_HAVE_INOTIFY=no,
2769 samba_cv_HAVE_INOTIFY=cross)
2771 if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2772     AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
2775 #################################################
2776 # Check if FAM notifications are available. For FAM info, see
2777 #       http://oss.sgi.com/projects/fam/
2778 #       http://savannah.nongnu.org/projects/fam/
2779 AC_ARG_ENABLE(fam,
2780 [AS_HELP_STRING([--enable-fam], [Turn on FAM support (default=auto)])])
2782 if test x$enable_fam != xno; then
2783     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2784     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2785         # On IRIX, libfam requires libC, but other FAM implementations
2786         # might not need it.
2787         AC_CHECK_LIB(fam, FAMOpen2,
2788             [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam";
2789             AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2790             [samba_cv_HAVE_LIBFAM=no])
2792         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2793             samba_fam_xtra=-lC
2794             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2795                 [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC";
2796                 AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2797                 [samba_cv_HAVE_LIBFAM=no])
2798             unset samba_fam_xtra
2799         fi
2800     fi
2801     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2802         default_shared_modules="$default_shared_modules vfs_notify_fam"
2803         AC_TRY_COMPILE([#include <fam.h>],
2804                     [enum FAMCodes code = FAMChanged;],
2805                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2806                         [Whether fam.h contains a typedef for enum FAMCodes]),
2807                     [])
2808     fi
2810     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2811         AC_CHECK_LIB(fam, FAMNoExists,
2812             [AC_DEFINE(HAVE_FAMNOEXISTS, 1, Define to 1 if there is support for FAMNoExists)])
2813     fi
2815     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2816         AC_MSG_ERROR(FAM support requested but FAM library not available )
2817     fi
2820 AC_SUBST(SMB_FAM_LIBS)
2822 #################################################
2823 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2826 with_dmapi_support=auto
2827 AC_MSG_CHECKING(whether to use DMAPI support)
2828 AC_ARG_WITH(dmapi,
2829 [AS_HELP_STRING([--with-dmapi], [Include DMAPI/XDSM support (default=auto)])],
2830 [ case "$withval" in
2831   yes|no)
2832     with_dmapi_support=$withval
2833     ;;
2834   esac ]
2836 AC_MSG_RESULT([$with_dmapi_support])
2838 if test x"$with_dmapi_support" != xno ; then
2839         SMB_CHECK_DMAPI([], [
2840                 AC_MSG_NOTICE(DMAPI support not present)
2841                 if test x"$with_dmapi_support" = xyes ; then
2842                         AC_MSG_ERROR(no DMAPI support found but requested!)
2843                 fi
2844                 ]
2845         )
2848 # Add TSM SM VFS module only if there are both GPFS and DMAPI support
2849 # Theoretically it should work with AIX JFS2 too but this needs testing
2850 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
2851     default_shared_modules="$default_shared_modules vfs_tsmsm"
2854 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2855 AC_TRY_RUN([
2856 #include <sys/types.h>
2857 #include <fcntl.h>
2858 #include <signal.h>
2859 #include <sys/file.h>
2860 #ifndef LOCK_MAND
2861 #define LOCK_MAND       32
2862 #define LOCK_READ       64
2863 #endif
2864 main() {
2865         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2868 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2869 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2870     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2874 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2875 AC_TRY_COMPILE([#include <sys/types.h>
2876 #include <fcntl.h>],
2877 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2878 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2879 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2880     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2883 #################################################
2884 # Check for POSIX capability support
2886 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2887     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2888     [], [])
2890 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2892     ac_save_LIBS=$LIBS
2893     AC_LIBTESTFUNC(cap, cap_get_proc)
2895     AC_CACHE_CHECK([for POSIX capabilities],
2896             samba_cv_HAVE_POSIX_CAPABILITIES,
2897             [
2898                 AC_TRY_RUN([
2899 #include <sys/types.h>
2900 #include <sys/capability.h>
2901 main() {
2902  cap_t cap;
2903  cap_value_t vals[1];
2904  if (!(cap = cap_get_proc()))
2905    exit(1);
2906  vals[0] = CAP_CHOWN;
2907  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2908  cap_set_proc(cap);
2909  exit(0);
2911                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2912                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2913                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2914             ])
2916 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2917     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2918             [Whether POSIX capabilities are available])
2919 else
2920     LIBS=$ac_save_LIBS
2926 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2927 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2930 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2931 AC_TRY_COMPILE([#include <sys/types.h>
2932 #if defined(HAVE_RPC_RPC_H)
2933 #include <rpc/rpc.h>
2934 #endif],
2935 [int16 testvar;],
2936 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2937 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2938     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2941 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2942 AC_TRY_COMPILE([#include <sys/types.h>
2943 #if defined(HAVE_RPC_RPC_H)
2944 #include <rpc/rpc.h>
2945 #endif],
2946 [uint16 testvar;],
2947 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2948 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2949     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2952 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2953 AC_TRY_COMPILE([#include <sys/types.h>
2954 #if defined(HAVE_RPC_RPC_H)
2955 #include <rpc/rpc.h>
2956 #endif],
2957 [int32 testvar;],
2958 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2959 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2960     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2963 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2964 AC_TRY_COMPILE([#include <sys/types.h>
2965 #if defined(HAVE_RPC_RPC_H)
2966 #include <rpc/rpc.h>
2967 #endif],
2968 [uint32 testvar;],
2969 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2970 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2971     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2975 dnl Some systems (SCO) have a problem including
2976 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2977 dnl as a #define in <prot.h> and as part of an enum
2978 dnl in <rpc/rpc.h>.
2981 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2982 AC_TRY_COMPILE([#include <sys/types.h>
2983 #ifdef HAVE_SYS_SECURITY_H
2984 #include <sys/security.h>
2985 #include <prot.h>
2986 #endif  /* HAVE_SYS_SECURITY_H */
2987 #if defined(HAVE_RPC_RPC_H)
2988 #include <rpc/rpc.h>
2989 #endif],
2990 [int testvar;],
2991 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2992 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2993     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2996 AC_MSG_CHECKING([for test routines])
2997 AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
2998            AC_MSG_RESULT(yes),
2999            AC_MSG_ERROR([cant find test code. Aborting config]),
3000            AC_MSG_WARN([cannot run when cross-compiling]))
3002 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
3003 AC_TRY_RUN([#include "${srcdir-.}/../tests/ftruncate.c"],
3004            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
3005 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
3006     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
3009 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
3010 AC_TRY_RUN([#include "${srcdir-.}/../tests/getgroups.c"],
3011            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
3012 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
3013     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
3016 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
3017 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
3018 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
3019 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
3020 AC_CHECK_FUNCS(getpagesize)
3022 ################################################
3023 # look for a method of setting the effective uid
3024 seteuid=no;
3026 if test $seteuid = no; then
3027 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
3028 AC_TRY_RUN([
3029 #define AUTOCONF_TEST 1
3030 #define USE_SETREUID 1
3031 #include "confdefs.h"
3032 #include "${srcdir-.}/lib/util_sec.c"],
3033            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
3034 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
3035     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
3039 # we check for setresuid second as it conflicts with AIO on Linux. 
3040 # see http://samba.org/~tridge/junkcode/aio_uid.c
3041 if test $seteuid = no; then
3042 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
3043 AC_TRY_RUN([
3044 #define AUTOCONF_TEST 1
3045 #define USE_SETRESUID 1
3046 #include "confdefs.h"
3047 #include "${srcdir-.}/lib/util_sec.c"],
3048            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
3049 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
3050     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
3054 if test $seteuid = no; then
3055 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
3056 AC_TRY_RUN([
3057 #define AUTOCONF_TEST 1
3058 #define USE_SETEUID 1
3059 #include "confdefs.h"
3060 #include "${srcdir-.}/lib/util_sec.c"],
3061            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
3062 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
3063     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
3067 if test $seteuid = no; then
3068 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
3069 AC_TRY_RUN([
3070 #define AUTOCONF_TEST 1
3071 #define USE_SETUIDX 1
3072 #include "confdefs.h"
3073 #include "${srcdir-.}/lib/util_sec.c"],
3074            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
3075 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
3076     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
3080 AC_CACHE_CHECK([for the Darwin initgroups system call],
3081         samba_cv_DARWIN_INITGROUPS,
3082         AC_TRY_LINK([
3083 #include <sys/syscall.h>
3084 #include <unistd.h>
3085         ],
3086         [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
3087         samba_cv_DARWIN_INITGROUPS=yes,
3088         samba_cv_DARWIN_INITGROUPS=no)
3091 if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
3092     AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
3093         [Whether to use the Darwin-specific initgroups system call])
3096 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
3097 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock.c"],
3098            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
3099 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
3100     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
3103 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
3104 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock64.c"],
3105            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
3106 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
3107     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
3109 else
3112 dnl Don't check for 64 bit fcntl locking if we know that the
3113 dnl glibc2.1 broken check has succeeded.
3116   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
3117   AC_TRY_RUN([
3118 #if defined(HAVE_UNISTD_H)
3119 #include <unistd.h>
3120 #endif
3121 #include <stdio.h>
3122 #include <stdlib.h>
3124 #ifdef HAVE_FCNTL_H
3125 #include <fcntl.h>
3126 #endif
3128 #ifdef HAVE_SYS_FCNTL_H
3129 #include <sys/fcntl.h>
3130 #endif
3131 main() { struct flock64 fl64;
3132 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
3133 exit(0);
3134 #else
3135 exit(1);
3136 #endif
3138        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
3140   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
3141       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
3142   fi
3145 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
3146 AC_CACHE_CHECK([for broken posix_fallocate],samba_cv_HAVE_BROKEN_POSIX_FALLOCATE,[
3147 AC_TRY_COMPILE([
3148   #define _XOPEN_SOURCE 600
3149   #include <stdlib.h>
3150   #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
3151     probably broken posix_fallocate
3152   #endif
3153 ], [
3154 ], 
3155 samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=no,samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=yes)])
3156 if test x"$samba_cv_HAVE_BROKEN_POSIX_FALLOCATE" = xyes; then
3157         AC_DEFINE(HAVE_BROKEN_POSIX_FALLOCATE,, Whether we have a broken posix_fallocate)
3161 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
3162 AC_TRY_COMPILE([#include <sys/types.h>
3163 #include <sys/stat.h>
3164 #include <unistd.h>],
3165 [struct stat st;  st.st_blocks = 0;],
3166 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
3167 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
3168     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
3171 AC_CHECK_TYPES([blksize_t, blkcnt_t], [], [], [[#include <sys/stat.h>]])
3173 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
3174 AC_TRY_COMPILE([#include <sys/types.h>
3175 #include <sys/stat.h>
3176 #include <unistd.h>],
3177 [struct stat st;  st.st_blksize = 0;],
3178 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
3179 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
3180     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
3183 AC_CACHE_CHECK([for st_flags in struct stat],
3184         samba_cv_HAVE_STAT_ST_FLAGS,
3185         [
3186             AC_TRY_COMPILE([#include <sys/types.h>
3187 #include <sys/stat.h>
3188 #include <unistd.h>],
3189             [struct stat st;  st.st_flags = 0;],
3190             samba_cv_HAVE_STAT_ST_FLAGS=yes,
3191             samba_cv_HAVE_STAT_ST_FLAGS=no,
3192             samba_cv_HAVE_STAT_ST_FLAGS=cross)
3193         ])
3195 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
3196     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
3197                 [Whether the stat struct has a st_flags member])
3200 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
3201 AC_TRY_COMPILE([
3202 #include <sys/types.h>
3203 #include <sys/acl.h>
3204 #if defined(HAVE_RPCSVC_NIS_H)
3205 #include <rpcsvc/nis.h>
3206 #endif],
3207 [int i;],
3208 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
3209 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
3210         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
3213 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
3214 AC_TRY_RUN([
3215 #include <stdio.h>
3216 #include <limits.h>
3217 #include <signal.h>
3219 void exit_on_core(int ignored) {
3220         exit(1);
3223 main() {
3224         char *newpath;
3225         signal(SIGSEGV, exit_on_core);
3226         newpath = realpath("/tmp", NULL);
3227         exit((newpath != NULL) ? 0 : 1);
3230 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
3231 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
3232     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
3235 #################################################
3236 # check for AFS clear-text auth support
3237 samba_cv_WITH_AFS=no
3238 AC_MSG_CHECKING(whether to use AFS clear-text auth)
3239 AC_ARG_WITH(afs,
3240 [AS_HELP_STRING([--with-afs], [Include AFS clear-text auth support (default=no)])],
3241 [ case "$withval" in
3242   yes|auto)
3243     AC_MSG_RESULT($withval)
3244     samba_cv_WITH_AFS=$withval
3245     ;;
3246   *)
3247     AC_MSG_RESULT(no)
3248     ;;
3249   esac ],
3250   AC_MSG_RESULT(no)
3253 ####################################################
3254 # check for Linux-specific AFS fake-kaserver support
3255 samba_cv_WITH_FAKE_KASERVER=no
3256 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3257 AC_ARG_WITH(fake-kaserver,
3258 [AS_HELP_STRING([--with-fake-kaserver], [Include AFS fake-kaserver support (default=no)])],
3259 [ case "$withval" in
3260   yes|auto)
3261     AC_MSG_RESULT($withval)
3262     samba_cv_WITH_FAKE_KASERVER=$withval
3263     ;;
3264   *)
3265     AC_MSG_RESULT(no)
3266     ;;
3267   esac ],
3268   AC_MSG_RESULT(no)
3271 #################################################
3272 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3273 if test x"$samba_cv_WITH_AFS" != x"no" ||
3274    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3276     # see if this box has the OpenSSL DES libraries
3277     AC_CHECK_LIB( crypto, DES_pcbc_encrypt, LIBS="$LIBS -lcrypto" , [AC_ERROR(OpenSSL library: libcrypto ot found!)] )
3279     # see if this box has the afs-headers in /usr/include/afs
3280     AC_MSG_CHECKING(for /usr/include/afs)
3281     if test -d /usr/include/afs; then
3282           AC_MSG_RESULT(yes)
3283     else
3284       AC_MSG_RESULT(no)
3285     fi
3287     # check for afs.h
3288     have_afs_headers=no
3289     AC_CHECK_HEADERS(afs.h afs/afs.h)
3290     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3291         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3292            test x"$samba_cv_WITH_AFS" = x"auto"; then
3293                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3294         else
3295                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3296         fi
3297     else
3298         have_afs_headers=yes
3299     fi
3302 FAKE_KASERVER_OBJ=""
3303 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3304     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3305     FAKE_KASERVER_OBJ="utils/net_afs.o"
3307 AC_SUBST(FAKE_KASERVER_OBJ)
3309 #################################################
3310 # check whether to compile AFS/NT ACL mapping module
3311 samba_cv_WITH_VFS_AFSACL=no
3312 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
3313 AC_ARG_WITH(vfs-afsacl,
3314 [AS_HELP_STRING([--with-vfs-afsacl], [Include AFS to NT ACL mapping module (default=no)])],
3315 [ case "$withval" in
3316   yes|auto)
3317     AC_MSG_RESULT($withval)
3318     samba_cv_WITH_VFS_AFSACL=yes
3319     ;;
3320   *)
3321     AC_MSG_RESULT(no)
3322     ;;
3323   esac ],
3324   AC_MSG_RESULT(no)
3327 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3328    default_shared_modules="$default_shared_modules vfs_afsacl"
3330         
3331 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3332     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3335 #################################################
3336 # check for the DFS clear-text auth system
3337 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3338 AC_ARG_WITH(dfs,
3339 [AS_HELP_STRING([--with-dce-dfs], [Include DCE/DFS clear-text auth support (default=no)])],
3340 [ case "$withval" in
3341   yes)
3342     AC_MSG_RESULT(yes)
3343     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3344     ;;
3345   *)
3346     AC_MSG_RESULT(no)
3347     ;;
3348   esac ],
3349   AC_MSG_RESULT(no)
3352 ########################################################
3353 # Compile with LDAP support?
3355 with_ldap_support=auto
3356 AC_MSG_CHECKING([for LDAP support])
3358 AC_ARG_WITH(ldap,
3359 [AS_HELP_STRING([--with-ldap], [LDAP support (default=auto)])],
3360 [ case "$withval" in
3361     yes|no)
3362         with_ldap_support=$withval
3363         ;;
3364   esac ])
3366 AC_MSG_RESULT($with_ldap_support)
3368 SMBLDAP=""
3369 AC_SUBST(SMBLDAP)
3370 SMBLDAPUTIL=""
3371 AC_SUBST(SMBLDAPUTIL)
3373 if test x"$with_ldap_support" != x"no"; then
3375   ##################################################################
3376   # first test for ldap.h and lber.h
3377   # (ldap.h is required for this test)
3378   AC_CHECK_HEADERS(ldap.h lber.h)
3380   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3381         if test x"$with_ldap_support" = x"yes"; then
3382          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3383         else
3384          AC_MSG_WARN(ldap.h is needed for LDAP support)
3385         fi
3386         
3387         with_ldap_support=no
3388   fi
3390   ##################################################################
3391   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
3392   # unsigned int in include/includes.h
3393   case $host_os in
3394         *hpux*)
3395          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3396          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
3397         with_ldap_support=yes
3398         ;;
3399         *)
3400         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3401         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3402                 if test x"$with_ldap_support" = x"yes"; then
3403                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3404                 else
3405                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3406                 fi
3407                 with_ldap_support=no
3408         fi
3409         ;;
3410   esac
3413 if test x"$with_ldap_support" != x"no"; then
3414   ac_save_LIBS=$LIBS
3416   ##################################################################
3417   # we might need the lber lib on some systems. To avoid link errors
3418   # this test must be before the libldap test
3419   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3421   ########################################################
3422   # If ber_sockbuf_add_io() is available we can add
3423   # SASL wrapping hooks
3424   AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
3426   AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
3427                  AC_TRY_COMPILE([#include <ldap.h>],
3428                                 [int val = LDAP_OPT_SOCKBUF;],
3429                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
3430                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
3432   if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
3433           x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
3434         AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
3435   fi
3437   #######################################################
3438   # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
3439   # ldap logging and print it out in the samba logs
3440   AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
3441                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
3442                  [AC_TRY_COMPILE([#include <lber.h>],
3443                                  [int val = LBER_OPT_LOG_PRINT_FN;],
3444                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
3445                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
3447   if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
3448         AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
3449                   [Support for LDAP/LBER logging interception])
3450   fi
3452   ########################################################
3453   # now see if we can find the ldap libs in standard paths
3454   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3456   ########################################################
3457   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3458   # Check found in pam_ldap 145.
3459   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3461   LIBS="$LIBS $LDAP_LIBS"
3462   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3463     AC_TRY_COMPILE([
3464         #include <lber.h>
3465         #include <ldap.h>],
3466         [ldap_set_rebind_proc(0, 0, 0);],
3467         [smb_ldap_cv_ldap_set_rebind_proc=3],
3468         [smb_ldap_cv_ldap_set_rebind_proc=2]
3469     )
3470   ])
3472   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3474   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3476   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3477     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3478     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3479     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3480     default_shared_modules="$default_shared_modules";
3481     SMBLDAP="lib/smbldap.o"
3482     SMBLDAPUTIL="lib/smbldap_util.o"
3483     with_ldap_support=yes
3484     AC_MSG_CHECKING(whether LDAP support is used)
3485     AC_MSG_RESULT(yes)
3486   else
3487     if test x"$with_ldap_support" = x"yes"; then
3488         AC_MSG_ERROR(libldap is needed for LDAP support)
3489     else
3490         AC_MSG_WARN(libldap is needed for LDAP support)
3491     fi
3493     LDAP_LIBS=""
3494     with_ldap_support=no
3495   fi
3496   LIBS=$ac_save_LIBS
3500 #################################################
3501 # active directory support
3503 with_ads_support=auto
3504 AC_MSG_CHECKING([for Active Directory and krb5 support])
3506 AC_ARG_WITH(ads,
3507 [AS_HELP_STRING([--with-ads], [Active Directory support (default=auto)])],
3508 [ case "$withval" in
3509     yes|no)
3510         with_ads_support="$withval"
3511         ;;
3512   esac ])
3514 AC_MSG_RESULT($with_ads_support)
3516 FOUND_KRB5=no
3517 KRB5_LIBS=""
3519 if test x"$with_ldap_support" != x"yes"; then
3521     if test x"$with_ads_support" = x"yes"; then
3522         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3523     elif test x"$with_ads_support" = x"auto"; then
3524         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3525         with_ads_support=no
3526     fi
3528 else
3530     # Check to see whether there is enough LDAP functionality to be able
3531     # to build AD support.
3533 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3534 case "$host_os" in
3535         *hpux*)
3536     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3538     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3539         if test x"$with_ads_support" = x"yes"; then
3540             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3541         elif test x"$with_ads_support" = x"auto"; then
3542             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3543             with_ads_support=no
3544         fi
3545     fi
3546     ;;
3547         *)
3548     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3550     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3551         if test x"$with_ads_support" = x"yes"; then
3552             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3553         elif test x"$with_ads_support" = x"auto"; then
3554             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3555             with_ads_support=no
3556         fi
3557     fi
3558     ;;
3559 esac
3562     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3564     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3565         if test x"$with_ads_support" = x"yes"; then
3566             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3567         elif test x"$with_ads_support" = x"auto"; then
3568             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3569             with_ads_support=no
3570         fi
3571     fi
3575 if test x"$with_ads_support" != x"no"; then
3577   # Do no harm to the values of CFLAGS and LIBS while testing for
3578   # Kerberos support.
3580   if test x$FOUND_KRB5 = x"no"; then
3581     #################################################
3582     # check for location of Kerberos 5 install
3583     AC_MSG_CHECKING(for kerberos 5 install path)
3584     AC_ARG_WITH(krb5,
3585     [AS_HELP_STRING([--with-krb5=base-dir], [Locate Kerberos 5 support (default=/usr)])],
3586     [ case "$withval" in
3587       no)
3588         AC_MSG_RESULT(no krb5-path given)
3589         ;;
3590       yes)
3591         AC_MSG_RESULT(/usr)
3592         FOUND_KRB5=yes
3593         ;;
3594       *)
3595         AC_MSG_RESULT($withval)
3596         KRB5_CFLAGS="-I$withval/include"
3597         KRB5_CPPFLAGS="-I$withval/include"
3598         KRB5_LDFLAGS="-L$withval/lib"
3599         FOUND_KRB5=yes
3600         if test -x "$withval/bin/krb5-config"; then
3601                 KRB5CONFIG=$withval/bin/krb5-config
3602         fi
3603         ;;
3604       esac ],
3605       AC_MSG_RESULT(no krb5-path given)
3606     )
3607   fi
3609   #################################################
3610   # check for krb5-config from recent MIT and Heimdal kerberos 5
3611   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3612   AC_MSG_CHECKING(for working krb5-config)
3613   if test -x "$KRB5CONFIG" && $KRB5CONFIG --libs gssapi > /dev/null ; then
3614     ac_save_CFLAGS=$CFLAGS
3615     CFLAGS="";export CFLAGS
3616     ac_save_LDFLAGS=$LDFLAGS
3617     LDFLAGS="";export LDFLAGS
3618     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3619     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3620     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3621     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3622     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3623     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3624     FOUND_KRB5=yes
3625     AC_MSG_RESULT(yes)
3626   else
3627     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3628   fi
3630   if test x$FOUND_KRB5 = x"no"; then
3631     #################################################
3632     # see if this box has the SuSE location for the heimdal krb implementation
3633     AC_MSG_CHECKING(for /usr/include/heimdal)
3634     if test -d /usr/include/heimdal; then
3635       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3636           KRB5_CFLAGS="-I/usr/include/heimdal"
3637           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3638           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3639           FOUND_KRB5=yes
3640           AC_MSG_RESULT(yes)
3641       else
3642           KRB5_CFLAGS="-I/usr/include/heimdal"
3643           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3644           FOUND_KRB5=yes
3645           AC_MSG_RESULT(yes)
3646       fi
3647     else
3648       AC_MSG_RESULT(no)
3649     fi
3650   fi
3652   if test x$FOUND_KRB5 = x"no"; then
3653     #################################################
3654     # see if this box has the RedHat location for kerberos
3655     AC_MSG_CHECKING(for /usr/kerberos)
3656     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3657       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3658       KRB5_CFLAGS="-I/usr/kerberos/include"
3659       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3660       FOUND_KRB5=yes
3661       AC_MSG_RESULT(yes)
3662     else
3663       AC_MSG_RESULT(no)
3664     fi
3665   fi
3667   if test x$FOUND_KRB5 = x"no"; then
3668     #################################################
3669     # see if this box has the OpenBSD location for heimdal krb5
3670     AC_MSG_CHECKING(for /usr/include/kerberosV)
3671     if test -d /usr/include/kerberosV; then
3672       KRB5_CPPFLAGS="-I/usr/include/kerberosV"
3673       KRB5_LIBS="-lcrypto"
3674       FOUND_KRB5=yes
3675       AC_MSG_RESULT(yes)
3676     else
3677       AC_MSG_RESULT(no)
3678     fi
3679   fi
3681   ac_save_CFLAGS=$CFLAGS
3682   ac_save_CPPFLAGS=$CPPFLAGS
3683   ac_save_LDFLAGS=$LDFLAGS
3685   # remove needless evil rpath stuff as early as possible:
3686   LIB_REMOVE_USR_LIB(KRB5_LIBS)
3687   LIB_REMOVE_USR_LIB(KRB5_LDFLAGS)
3688   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3689   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3690   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3692   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3694   # now check for krb5.h. Some systems have the libraries without the headers!
3695   # note that this check is done here to allow for different kerberos
3696   # include paths
3697   AC_CHECK_HEADERS(krb5.h)
3699   if test x"$ac_cv_header_krb5_h" = x"no"; then
3701     # Give a warning if AD support was not explicitly requested,
3702     # i.e with_ads_support = auto, otherwise die with an error.
3704     if test x"$with_ads_support" = x"yes"; then
3705       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3706     else
3707       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3708     fi
3710     # Turn off AD support and restore CFLAGS and LIBS variables
3712     with_ads_support="no"
3714     CFLAGS=$ac_save_CFLAGS
3715     CPPFLAGS=$ac_save_CPPFLAGS
3716     LDFLAGS=$ac_save_LDFLAGS
3717   fi
3719   # check for new heimdal KRB5_DEPRECATED handling
3721   AC_CACHE_CHECK([for KRB5_DEPRECATED define taking an identifier],
3722                 samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER,[
3723     AC_TRY_COMPILE(
3724       [#define KRB5_DEPRECATED 1
3725       #include <krb5.h>],
3726       [],
3727       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=yes,
3728       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=no)])
3730   if test x"$samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER" = x"yes"; then
3731     AC_DEFINE(HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER, 1,
3732                [Whether to use deprecated krb5 interfaces])
3733   fi
3736 # Now we have determined whether we really want ADS support
3737 use_ads=no
3738 if test x"$with_ads_support" != x"no"; then
3739   use_ads=yes
3740   have_gssapi=no
3741   ac_save_LIBS=$LIBS
3743   # now check for gssapi headers.  This is also done here to allow for
3744   # different kerberos include paths
3745   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h)
3747   ##################################################################
3748   # we might need the k5crypto and com_err libraries on some systems
3749   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3750   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3752   # Heimdal checks.
3753   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3754   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3755   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3757   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3758   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3760   ########################################################
3761   # now see if we can find the krb5 libs in standard paths
3762   # or as specified above
3763   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3764   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3766   ########################################################
3767   # now see if we can find the gssapi libs in standard paths
3768   if test x"$have_gssapi" != x"yes"; then
3769      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3770      AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
3771   fi
3773   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3774   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3775   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3776   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3777   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3778   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3779   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3780   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3781   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3782   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3783   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3784   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3785   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3786   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3787   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3788   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3789   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3790   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3791   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3792   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3793   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3794   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3795   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3796   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3797   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3798   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3799   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3800   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3801   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3802   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3803   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3804   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3805   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3806   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3807   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3808   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3809   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3810   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3811   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3812   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3813   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3814   AC_CHECK_FUNC_EXT(krb5_fwd_tgt_creds, $KRB5_LIBS)
3815   AC_CHECK_FUNC_EXT(krb5_auth_con_set_req_cksumtype, $KRB5_LIBS)
3816   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_alloc, $KRB5_LIBS)
3817   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_set_impersonate, $KRB5_LIBS)
3818   AC_CHECK_FUNC_EXT(krb5_get_creds, $KRB5_LIBS)
3819   AC_CHECK_FUNC_EXT(krb5_get_credentials_for_user, $KRB5_LIBS)
3820   AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS)
3821   AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS)
3823   # MIT krb5 1.8 does not expose this call (yet)
3824   AC_CHECK_DECLS(krb5_get_credentials_for_user, [], [], [#include <krb5.h>])
3826   # MIT krb5 1.7beta3 (in Ubuntu Karmic) does not have this declaration
3827   # but does have the symbol
3828   AC_CHECK_DECLS(krb5_auth_con_set_req_cksumtype, [], [], [#include <krb5.h>])
3830   LIBS="$KRB5_LIBS $LIBS"
3832   AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
3833         smb_krb5_cv_ticket_has_keyinfo,
3834         [
3835             AC_TRY_COMPILE(
3836             [
3837                 #include <krb5.h>
3838             ],
3839             [
3840                 krb5_ticket ticket;
3841                 krb5_kvno kvno;
3842                 krb5_enctype enctype;
3844                 enctype = ticket.enc_part.enctype;
3845                 kvno = ticket.enc_part.kvno;
3846             ],
3847             [ smb_krb5_cv_ticket_has_keyinfo=yes ],
3848             [ smb_krb5_cv_ticket_has_keyinfo=no ])
3849         ])
3851   if test x"$smb_krb5_cv_ticket_has_keyinfo" = x"yes" ; then
3852         AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
3853             [Whether the krb5_ticket structure contains the kvno and enctype])
3854   fi
3856   AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
3857           smb_krb5_cv_creds_opt_free_context,
3858           [
3859                 AC_TRY_COMPILE([
3860                     #include <krb5.h>],
3861                     [
3862                         krb5_context ctx;
3863                         krb5_get_init_creds_opt *opt = NULL;
3864                         krb5_get_init_creds_opt_free(ctx, opt);
3865                     ],
3866                     [smb_krb5_cv_creds_opt_free_context=yes],
3867                     [smb_krb5_cv_creds_opt_free_context=no]
3868                 )
3869           ])
3871   if test x"$smb_krb5_cv_creds_opt_free_context" = x"yes" ; then
3872         AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
3873             [Whether krb5_get_init_creds_opt_free takes a context argument])
3874   fi
3876   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_cv_verify_checksum, [
3877     AC_TRY_COMPILE([
3878         #include <krb5.h>],
3879         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
3880         [smb_krb5_cv_verify_checksum=7],
3881         [smb_krb5_cv_verify_checksum=6],
3882     )
3883   ])
3884   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_cv_verify_checksum, [Number of arguments to krb5_verify_checksum])
3886   AC_CACHE_CHECK([for checksum in krb5_checksum],
3887                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3888     AC_TRY_COMPILE([#include <krb5.h>],
3889       [krb5_checksum cksum; cksum.checksum.length = 0;],
3890       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3891       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3893   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3894     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3895                [Whether the krb5_checksum struct has a checksum property])
3896   fi
3898   AC_CACHE_CHECK([for etype in EncryptedData],
3899                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3900     AC_TRY_COMPILE([#include <krb5.h>],
3901       [EncryptedData edata; edata.etype = 0;],
3902       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3903       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3905   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3906     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3907                [Whether the EncryptedData struct has a etype property])
3908   fi
3910   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3911                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3912     AC_TRY_COMPILE([#include <krb5.h>],
3913       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3914       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3915       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3917   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3918     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3919                [Whether the krb5_ap_req struct has a ticket pointer])
3920   fi
3922   AC_CACHE_CHECK([for e_data pointer in krb5_error],
3923                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
3924     AC_TRY_COMPILE([#include <krb5.h>],
3925       [krb5_error err; err.e_data = NULL;],
3926       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
3927       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
3929   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
3930     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
3931                [Whether the krb5_error struct has a e_data pointer])
3932   fi
3934   AC_CACHE_CHECK([for krb5_crypto type],
3935                 samba_cv_HAVE_KRB5_CRYPTO,[
3936     AC_TRY_COMPILE([#include <krb5.h>],
3937       [krb5_crypto crypto;],
3938       samba_cv_HAVE_KRB5_CRYPTO=yes,
3939       samba_cv_HAVE_KRB5_CRYPTO=no)])
3941   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3942     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3943                [Whether the type krb5_crypto exists])
3944   fi
3946   AC_CACHE_CHECK([for krb5_encrypt_block type],
3947                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3948     AC_TRY_COMPILE([#include <krb5.h>],
3949       [krb5_encrypt_block block;],
3950       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3951       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3953   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3954     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3955                [Whether the type krb5_encrypt_block exists])
3956   fi
3958   AC_CACHE_CHECK([for addrtype in krb5_address],
3959                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3960     AC_TRY_COMPILE([#include <krb5.h>],
3961       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3962       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3963       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3965   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3966     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3967                [Whether the krb5_address struct has a addrtype property])
3968   fi
3970   AC_CACHE_CHECK([for addr_type in krb5_address],
3971                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3972     AC_TRY_COMPILE([#include <krb5.h>],
3973       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3974       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3975       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3977   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3978     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3979               [Whether the krb5_address struct has a addr_type property])
3980   fi
3982   AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
3983                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3984                  [AC_TRY_COMPILE([#include <krb5.h>],
3985     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3986     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3988   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3989     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3990               [Whether the krb5_ticket struct has a enc_part2 property])
3991   fi
3993   AC_CACHE_CHECK([for keyblock in krb5_creds],
3994                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3995     AC_TRY_COMPILE([#include <krb5.h>],
3996       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3997       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3998       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
4000   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
4001     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
4002               [Whether the krb5_creds struct has a keyblock property])
4003   fi
4005   AC_CACHE_CHECK([for session in krb5_creds],
4006                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
4007     AC_TRY_COMPILE([#include <krb5.h>],
4008       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
4009       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
4010       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
4012   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
4013     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
4014               [Whether the krb5_creds struct has a session property])
4015   fi
4017   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
4018                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
4019     AC_TRY_COMPILE([#include <krb5.h>],
4020       [krb5_keyblock key; key.keyvalue.data = NULL;],
4021       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
4022       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
4024   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
4025     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
4026               [Whether the krb5_keyblock struct has a keyvalue property])
4027   fi
4029   found_arcfour_hmac=no
4030   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
4031                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
4032     AC_TRY_COMPILE([#include <krb5.h>],
4033       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
4034       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
4035       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
4036   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
4037                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
4038     AC_TRY_COMPILE([#include <krb5.h>],
4039       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
4040       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
4041       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
4042 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
4043 # w.r.t. arcfour and windows, so we must not enable it here
4044   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
4045           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
4046     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
4047               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available])
4048     found_arcfour_hmac=yes
4049   fi
4050   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC],
4051                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC,[
4052     AC_TRY_COMPILE([#include <krb5.h>],
4053       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC;],
4054       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC=yes,
4055       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC=no)])
4056   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC" = x"yes"; then
4057     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC,1,
4058               [Whether the ENCTYPE_ARCFOUR_HMAC key type definition is available])
4059     found_arcfour_hmac=yes
4060   fi
4062   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
4063                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
4064     AC_TRY_COMPILE([#include <krb5.h>],
4065       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
4066       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
4067       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
4069   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
4070     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
4071               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
4072   fi
4074   AC_CACHE_CHECK([for KV5M_KEYTAB],
4075                  samba_cv_HAVE_KV5M_KEYTAB,[
4076     AC_TRY_COMPILE([#include <krb5.h>],
4077       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
4078       samba_cv_HAVE_KV5M_KEYTAB=yes,
4079       samba_cv_HAVE_KV5M_KEYTAB=no)])
4081   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
4082       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
4083              [Whether the KV5M_KEYTAB option is available])
4084   fi
4086   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
4087                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
4088     AC_TRY_COMPILE([#include <krb5.h>],
4089       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
4090       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
4091       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
4093   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
4094     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
4095               [Whether KRB5_KU_OTHER_CKSUM is available])
4096   fi
4098   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
4099                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
4100     AC_TRY_COMPILE([#include <krb5.h>],
4101       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
4102       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
4103       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
4105   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
4106     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
4107               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
4108   fi
4110   AC_CACHE_CHECK([for the krb5_princ_component macro],
4111                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
4112     AC_TRY_LINK([#include <krb5.h>],
4113       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
4114       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
4115       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
4117   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
4118     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
4119                [Whether krb5_princ_component is available])
4120   fi
4122   AC_CACHE_CHECK([for key in krb5_keytab_entry],
4123                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
4124     AC_TRY_COMPILE([#include <krb5.h>],
4125       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
4126       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
4127       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
4129   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
4130     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
4131               [Whether krb5_keytab_entry has key member])
4132   fi
4134   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
4135                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
4136     AC_TRY_COMPILE([#include <krb5.h>],
4137       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
4138       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
4139       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
4141   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
4142     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
4143               [Whether krb5_keytab_entry has keyblock member])
4144   fi
4146   AC_CACHE_CHECK([for magic in krb5_address],
4147                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
4148     AC_TRY_COMPILE([#include <krb5.h>],
4149       [krb5_address addr; addr.magic = 0;],
4150       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
4151       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
4153   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
4154     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
4155               [Whether the krb5_address struct has a magic property])
4156   fi
4158   AC_CACHE_CHECK([for WRFILE: keytab support],
4159                 samba_cv_HAVE_WRFILE_KEYTAB,[
4160     AC_TRY_RUN([
4161 #include<krb5.h>
4162   main()
4163   {
4164     krb5_context context;
4165     krb5_keytab keytab;
4167     krb5_init_context(&context);
4168     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
4169   }],
4170   samba_cv_HAVE_WRFILE_KEYTAB=yes,
4171   samba_cv_HAVE_WRFILE_KEYTAB=no)])
4173   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
4174       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
4175                [Whether the WRFILE:-keytab is supported])
4176   fi
4178   AC_CACHE_CHECK([for krb5_realm type],
4179                 samba_cv_HAVE_KRB5_REALM_TYPE,[
4180     AC_TRY_COMPILE([#include <krb5.h>],
4181       [krb5_realm realm;],
4182       samba_cv_HAVE_KRB5_REALM_TYPE=yes,
4183       samba_cv_HAVE_KRB5_REALM_TYPE=no)])
4185   if test x"$samba_cv_HAVE_KRB5_REALM_TYPE" = x"yes"; then
4186     AC_DEFINE(HAVE_KRB5_REALM_TYPE,1,
4187                [Whether the type krb5_realm exists])
4188   fi
4190   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
4191                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
4192     AC_TRY_COMPILE([#include <krb5.h>],
4193     [
4194     krb5_context context;
4195     krb5_principal principal;
4196     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
4197     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
4198     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
4200   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
4201     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
4202               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
4203   fi
4205   AC_CACHE_CHECK([for krb5_addresses type],
4206                 samba_cv_HAVE_KRB5_ADDRESSES,[
4207     AC_TRY_COMPILE([#include <krb5.h>],
4208       [krb5_addresses addr;],
4209       samba_cv_HAVE_KRB5_ADDRESSES=yes,
4210       samba_cv_HAVE_KRB5_ADDRESSES=no)])
4212   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
4213     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
4214                [Whether the type krb5_addresses type exists])
4215   fi
4217   AC_CACHE_CHECK([whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal],
4218                 samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE, [
4219     AC_TRY_COMPILE([#include <krb5.h>],
4220     [
4221     krb5_mk_error(0,0,0);],
4222     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=yes,
4223     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=no)])
4225   if test x"$samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE" = x"yes"; then
4226     AC_DEFINE(HAVE_SHORT_KRB5_MK_ERROR_INTERFACE,1,
4227               [whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal])
4228   fi
4230   if test x"$ac_cv_func_ext_krb5_enctype_to_string" = x"yes"; then
4231     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_context context, krb5_enctype enctype, char **str)],
4232         smb_krb5_cv_enctype_to_string_takes_krb5_context_arg,[
4233         AC_TRY_RUN_STRICT([
4234                 #include <stdlib.h>
4235                 #include <krb5.h>
4236                 int main(void) {
4237                         krb5_context context = NULL;
4238                         char *str = NULL;
4239                         krb5_enctype_to_string(context, 1, &str);
4240                         if (str) free (str); 
4241                         return 0;
4242                 }
4243                 ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4244                 smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=yes,
4245                 smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=no)])
4247     if test x"$smb_krb5_cv_enctype_to_string_takes_krb5_context_arg" = x"yes"; then
4248       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG,1,
4249                 [whether krb5_enctype_to_string takes krb5_context argument])
4250     fi
4252     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_enctype enctype, char *str, size_t len)],
4253         smb_krb5_cv_enctype_to_string_takes_size_t_arg,[
4254         AC_TRY_RUN_STRICT([
4255                 #include <krb5.h>
4256                 int main(void) {
4257                         char buf[256];
4258                         krb5_enctype_to_string(1, buf, 256);
4259                         return 0;
4260                 }
4261                 ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4262                 smb_krb5_cv_enctype_to_string_takes_size_t_arg=yes,
4263                 smb_krb5_cv_enctype_to_string_takes_size_t_arg=no)])
4265     if test x"$smb_krb5_cv_enctype_to_string_takes_size_t_arg" = x"yes"; then
4266       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG,1,
4267                 [whether krb5_enctype_to_string takes size_t argument])
4268     fi
4269   fi
4271   AC_CACHE_CHECK([for krb5_principal_get_realm],
4272                 samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
4273     AC_TRY_LINK([#include <krb5.h>],
4274       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
4275       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
4276       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
4278   if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
4279     AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
4280                [Whether the function krb5_principal_get_realm is defined])
4281   fi
4283   AC_CACHE_CHECK([for krb5_princ_realm],
4284                 samba_cv_HAVE_KRB5_PRINC_REALM,[
4285     AC_TRY_LINK([#include <krb5.h>],
4286       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
4287       samba_cv_HAVE_KRB5_PRINC_REALM=yes,
4288       samba_cv_HAVE_KRB5_PRINC_REALM=no)])
4290   if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
4291     AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
4292                [Whether the macro krb5_princ_realm is defined])
4293   fi
4295   #
4296   #
4297   # Now the decisions whether we can support krb5
4298   #
4299   # NOTE: all tests should be done before this block!
4300   #
4301   #
4302   if test x"$found_arcfour_hmac" != x"yes"; then
4303     AC_MSG_WARN(arcfour-hmac-md5 encryption type not found in -lkrb5)
4304     use_ads=no
4305   fi
4307   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
4308     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
4309     use_ads=no
4310   fi
4312   if test x"$ac_cv_func_ext_krb5_principal2salt" != x"yes" -a \
4313           x"$ac_cv_func_ext_krb5_get_pw_salt" != x"yes"
4314   then
4315     AC_MSG_WARN(no CREATE_KEY_FUNCTIONS detected)
4316     use_ads=no
4317   fi
4319   if test x"$ac_cv_func_ext_krb5_get_permitted_enctypes" != x"yes" -a \
4320           x"$ac_cv_func_ext_krb5_get_default_in_tkt_etypes" != x"yes"
4321   then
4322     AC_MSG_WARN(no GET_ENCTYPES_FUNCTIONS detected)
4323     use_ads=no
4324   fi
4326   if test x"$ac_cv_func_ext_krb5_kt_free_entry" != x"yes" -a \
4327           x"$ac_cv_func_ext_krb5_free_keytab_entry_contents" != x"yes"
4328   then
4329     AC_MSG_WARN(no KT_FREE_FUNCTION detected)
4330     use_ads=no
4331   fi
4333   if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes" -a \
4334           x"$ac_cv_func_ext_krb5_verify_checksum" != x"yes"
4335   then
4336     AC_MSG_WARN(no KRB5_VERIFY_CHECKSUM_FUNCTION detected)
4337     use_ads=no
4338   fi
4340   if test x"$smb_krb5_cv_ticket_has_keyinfo" != x"yes" ; then
4342       # We only need the following functions if we can't get the enctype
4343       # and kvno out of the ticket directly (ie. on Heimdal).
4345       if test x"$ac_cv_func_ext_free_AP_REQ" != x"yes"
4346       then
4347         AC_MSG_WARN(no KRB5_AP_REQ_FREE_FUNCTION detected)
4348         use_ads=no
4349       fi
4351       if test x"$ac_cv_func_ext_krb5_decode_ap_req" != x"yes"
4352       then
4353         AC_MSG_WARN(no KRB5_AP_REQ_DECODING_FUNCTION detected)
4354         use_ads=no
4355       fi
4357   fi
4359   if test x"$use_ads" = x"yes"; then
4360     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
4361     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
4362     if test x"$have_gssapi" = x"yes"; then
4363       AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
4364     fi
4365   else
4366     if test x"$with_ads_support" = x"yes"; then
4367         AC_MSG_ERROR(krb5 libs don't have all features required for Active Directory support)
4368     else
4369         AC_MSG_WARN(krb5 libs don't have all features required for Active Directory support)
4370     fi
4371     AC_REMOVE_DEFINE(HAVE_KRB5_H)
4372     AC_REMOVE_DEFINE(HAVE_GSSAPI_H)
4373     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4374     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_H)
4375     KRB5_LIBS=""
4376     with_ads_support=no
4377   fi
4378   AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
4379   AC_MSG_RESULT([$use_ads])
4381 LIBS="$ac_save_LIBS"
4384 if test x"$use_ads" != xyes; then
4385         merged_build_possible=no
4388 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
4389 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
4392 ########################################################
4393 # Compile with DNS Updates support?
4395 with_dnsupdate_support=auto
4396 AC_MSG_CHECKING([whether to enable DNS Updates support])
4398 AC_ARG_WITH(dnsupdate,
4399 [AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default=auto)])],
4400 [ case "$withval" in
4401     yes|no)
4402         with_dnsupdate_support=$withval
4403         ;;
4404   esac ])
4406 AC_MSG_RESULT($with_dnsupdate_support)
4408 if test x"$with_dnsupdate_support" != x"no"; then
4410   ################################################################
4411   # first test for AD / GSSAPI support being enabled
4412         if test x"$have_gssapi" != xyes ; then
4413                 if test x"$with_dnsupdate_support" = x"yes" ; then
4414                         AC_MSG_ERROR(DNS Updates support only possible with AD and GSSAPI support)
4415                 else
4416                         AC_MSG_NOTICE(DNS Updates support only possible with AD and GSSAPI support)
4417                         with_dnsupdate_support=no
4418                 fi
4419         fi
4420   ##################################################################
4421   # then test for uuid.h (necessary to generate unique DNS keynames
4422   # (uuid.h is required for this test)
4423         AC_CHECK_HEADERS(uuid/uuid.h)
4425         
4426         if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
4427                 if test x"$with_dnsupdate_support" = x"yes"; then
4428                         AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
4429                 else
4430                         AC_MSG_NOTICE(uuid.h is needed to enable DNS Updates support)
4431                 fi
4432                 with_dnsupdate_support=no
4433         fi
4436 if test x"$with_dnsupdate_support" != x"no"; then
4438   ########################################################
4439   # Now see if we can find the uuid libs in standard paths
4440   # On some systems, the uuid API is in libc, so we have to
4441   # be careful not to insert a spurious -luuid.
4443   UUID_LIBS=""
4444   AC_LIBTESTFUNC(uuid, uuid_generate,
4445           [
4446             case " $LIBS " in
4447                 *\ -luuid\ *)
4448                 UUID_LIBS="-luuid"
4449                 SMB_REMOVE_LIB(uuid)
4450                 ;;
4451             esac
4453             with_dnsupdate_support=yes
4454             AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
4455         ],
4456         [
4457             if test x"$with_dnsupdate_support" = x"yes"; then
4458                 AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
4459             else
4460                 AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
4461             fi
4462             with_dnsupdate_support=no
4463         ])
4465   # finally print out the result:
4466 AC_MSG_CHECKING(whether DNS Updates support is used)
4467 AC_MSG_RESULT([$with_dnsupdate_support])
4470 #################################################
4471 # check for automount support
4472 AC_MSG_CHECKING(whether to use automount)
4473 AC_ARG_WITH(automount,
4474 [AS_HELP_STRING([--with-automount], [Include automount support (default=no)])],
4475 [ case "$withval" in
4476   yes)
4477     AC_MSG_RESULT(yes)
4478     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
4479     ;;
4480   *)
4481     AC_MSG_RESULT(no)
4482     ;;
4483   esac ],
4484   AC_MSG_RESULT(no)
4487 #################################################
4488 # Check for a PAM clear-text auth, accounts, password
4489 # and session support. Most PAM implementations keep their
4490 # headers in /usr/include/security. Darwin keeps its in
4491 # /usr/include/pam.
4493 with_pam_for_crypt=no
4494 try_pam=auto
4495 AC_MSG_CHECKING(whether to try PAM support)
4496 AC_ARG_WITH(pam,
4497 [AS_HELP_STRING([--with-pam], [Include PAM support (default=auto)])],
4498 [ case "$withval" in
4499   yes|no|auto)
4500     try_pam=$withval
4501     ;;
4502   esac
4504 AC_MSG_RESULT([$try_pam])
4506 use_pam=no
4507 create_pam_modules=no
4508 if test x"${try_pam}" != x"no";then
4509         use_pam=yes
4510         create_pam_modules=yes
4512         # Most systems have PAM headers in /usr/include/security, but Darwin
4513         # has them in /usr/include/pam.
4514         AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
4515         if test x"$ac_cv_header_security_pam_appl_h" != x"yes" -a \
4516                 x"$ac_cv_header_pam_pam_appl_h" != x"yes"; then
4517                 if test x"${try_pam}" = x"yes";then
4518                         AC_MSG_ERROR([--with-pam=yes but pam_appl.h not found])
4519                 fi
4520                 use_pam=no
4521                 create_pam_modules=no
4522         fi
4524         AC_CHECK_LIB_EXT(pam, PAM_LIBS, pam_get_data)
4525         if test x"$ac_cv_lib_ext_pam_pam_get_data" != x"yes"; then
4526                 if test x"${try_pam}" = x"yes";then
4527                         AC_MSG_ERROR([--with-pam=yes but libpam not found])
4528                 fi
4529                 use_pam=no
4530                 create_pam_modules=no
4531         fi
4533         AC_CHECK_HEADERS(security/pam_modules.h pam/pam_modules.h,,,[[
4534                 #if HAVE_SECURITY_PAM_APPL_H
4535                 #include <security/pam_appl.h>
4536                 #endif
4537                 #if HAVE_PAM_PAM_APPL_H
4538                 #include <pam/pam_appl.h>
4539                 #endif
4540         ]])
4541         if test x"$ac_cv_header_security_pam_modules_h" = x"no" -a \
4542                 x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
4543                 if test x"${try_pam}" = x"yes";then
4544                         AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
4545        fi
4546                 create_pam_modules=no
4547     fi
4549         if test x"$use_pam" = x"yes"; then
4550     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
4551                 AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
4552                 AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
4553     with_pam_for_crypt=yes
4555                 if test x"$create_pam_modules" = x"yes"; then
4556                         AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
4557                         # this checks are optional,
4558                         # we don't care about the results here
4559                         AC_CHECK_HEADERS(security/pam_ext.h security/_pam_macros.h)
4560                         AC_CHECK_HEADERS(pam/pam_ext.h pam/_pam_macros.h)
4561                         AC_CHECK_FUNC_EXT(pam_vsyslog,$PAM_LIBS)
4562                 else
4563                         AC_MSG_WARN([PAM support detected but PAM MODULES support is missing])          
4564                 fi
4565         fi
4566         AC_MSG_CHECKING(whether to use PAM support)
4567         AC_MSG_RESULT([$use_pam])
4569         AC_MSG_CHECKING(whether to have PAM MODULES support)
4570         AC_MSG_RESULT([$create_pam_modules])
4572         AC_TRY_COMPILE([
4573                 #if defined(HAVE_SECURITY_PAM_APPL_H)
4574                 #include <security/pam_appl.h>
4575                 #elif defined(HAVE_PAM_PAM_APPL_H)
4576                 #include <pam/pam_appl.h>
4577                 #endif],[
4578                 pam_set_item(0, PAM_RHOST, 0);
4579                 ],
4580                 AC_DEFINE(HAVE_PAM_RHOST, 1,
4581                           [Define to 1 if PAM_RHOST is available]),[])
4583         AC_TRY_COMPILE([
4584                 #if defined(HAVE_SECURITY_PAM_APPL_H)
4585                 #include <security/pam_appl.h>
4586                 #elif defined(HAVE_PAM_PAM_APPL_H)
4587                 #include <pam/pam_appl.h>
4588                 #endif],[
4589                 pam_set_item(0, PAM_TTY, 0);
4590                 ],
4591                 AC_DEFINE(HAVE_PAM_TTY, 1,
4592                           [Define to 1 if PAM_TTY is available]),[])
4594 fi # try_pam != no
4596 #################################################
4597 # check for PAM_RADIO_TYPE
4598 AC_TRY_COMPILE([
4599 #if (!defined(LINUX))
4601 #define PAM_EXTERN extern
4602 #if defined(HAVE_SECURITY_PAM_APPL_H)
4603 #include <security/pam_appl.h>
4604 #elif defined(HAVE_PAM_PAM_APPL_H)
4605 #include <pam/pam_appl.h>
4606 #endif
4608 #endif
4610 #if defined(HAVE_SECURITY_PAM_MODULES_H)
4611 #include <security/pam_modules.h>
4612 #elif defined(HAVE_PAM_PAM_MODULES_H)
4613 #include <pam/pam_modules.h>
4614 #endif
4616 #if defined(HAVE_SECURITY__PAM_MACROS_H)
4617 #include <security/_pam_macros.h>
4618 #elif defined(HAVE_PAM__PAM_MACROS_H)
4619 #include <pam/_pam_macros.h>
4620 #endif
4622 #ifdef HAVE_SECURITY_PAM_EXT_H
4623 #include <security/pam_ext.h>
4624 #endif
4626 [int i; i = PAM_RADIO_TYPE; ],
4627 AC_DEFINE(HAVE_PAM_RADIO_TYPE, 1, [Define to 1 if PAM_RADIO_TYPE is available]),[])
4629 #################################################
4630 # check for pam_smbpass support
4631 PAM_MODULES=""
4632 INSTALL_PAM_MODULES=""
4633 UNINSTALL_PAM_MODULES=""
4635 try_pam_smbpass=auto
4636 AC_MSG_CHECKING(whether to use pam_smbpass)
4637 AC_ARG_WITH(pam_smbpass,
4638 [AS_HELP_STRING([--with-pam_smbpass], [Build PAM module for authenticating against passdb backends (default=auto)])],
4639 [ case "$withval" in
4640   yes|no|auto)
4641     try_pam_smbpass=$withval
4642   ;;
4643   *)
4644     AC_MSG_ERROR([valid options are yes,no,auto])
4645   ;;
4646   esac
4649 if test x"${try_pam_smbpass}" = xno ; then
4650         use_pam_smbpass=no
4651 else
4652         use_pam_smbpass=yes
4653         # Conditions under which pam_smbpass can't be built.
4654         if test x"$BLDSHARED" != xtrue ; then
4655                 if test x"${try_pam_smbpass}" = xyes ; then
4656                         AC_MSG_ERROR([No support for shared modules])
4657                 fi
4658                 use_pam_smbpass=no
4659         elif test x"$create_pam_modules" != xyes ; then
4660                 if test x"${try_pam_smbpass}" = xyes ; then
4661                         AC_MSG_ERROR([No support for PAM MODULES])
4662                 fi
4663                 use_pam_smbpass=no
4664         fi
4666         if test x"${use_pam_smbpass}" = xyes ; then 
4667                 PAM_MODULES="pam_smbpass"
4668                 INSTALL_PAM_MODULES="installpammodules"
4669                 UNINSTALL_PAM_MODULES="uninstallpammodules"
4670         fi
4672 AC_MSG_RESULT([$use_pam_smbpass])
4676 ## moved after the check for -lcrypt in order to
4677 ## ensure that the necessary libraries are included
4678 ## check checking for truncated salt.  Wrapped by the
4679 ## $with_pam_for_crypt variable as above   --jerry
4681 if test $with_pam_for_crypt = no; then
4682 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
4683 crypt_LIBS="$LIBS"
4684 LIBS="$AUTH_LIBS $LIBS"
4685 AC_TRY_RUN([#include "${srcdir-.}/../tests/crypttest.c"],
4686         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
4687 LIBS="$crypt_LIBS"])
4688 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
4689         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
4693 #################################################
4694 # check for a NISPLUS_HOME support
4695 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
4696 AC_ARG_WITH(nisplus-home,
4697 [AS_HELP_STRING([--with-nisplus-home], [Include NISPLUS_HOME support (default=no)])],
4698 [ case "$withval" in
4699   yes)
4700     AC_MSG_RESULT(yes)
4701     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
4702     ;;
4703   *)
4704     AC_MSG_RESULT(no)
4705     ;;
4706   esac ],
4707   AC_MSG_RESULT(no)
4710 #################################################
4711 # check for syslog logging
4712 AC_MSG_CHECKING(whether to use syslog logging)
4713 AC_ARG_WITH(syslog,
4714 [AS_HELP_STRING([--with-syslog], [Include experimental SYSLOG support (default=no)])],
4715 [ case "$withval" in
4716   yes)
4717     AC_MSG_RESULT(yes)
4718     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
4719     ;;
4720   *)
4721     AC_MSG_RESULT(no)
4722     ;;
4723   esac ],
4724   AC_MSG_RESULT(no)
4727 #################################################
4728 # check for custom syslog facility
4729 AC_MSG_CHECKING(whether to use a custom syslog facility)
4730 AC_ARG_WITH(syslog-facility,
4731 [AS_HELP_STRING([--with-syslog-facility], [Use a custom syslog facility (default=none)])],
4733   if test "$withval" = "no" ; then
4734     AC_MSG_ERROR([argument to --with-syslog-facility must be a string])
4735   else
4736      if test "$withval" != "yes" ; then
4737         syslog_facility="$withval"
4738         AC_DEFINE_UNQUOTED(SYSLOG_FACILITY,$syslog_facility, [syslog facility to log to])
4739      fi
4740   fi
4743 #################################################
4744 # check for experimental disk-quotas support
4746 samba_cv_WITH_QUOTAS=auto
4747 samba_cv_TRY_QUOTAS=no
4748 samba_cv_RUN_QUOTA_TESTS=auto
4749 samba_cv_WITH_SYS_QUOTAS=auto
4750 samba_cv_TRY_SYS_QUOTAS=auto
4751 samba_cv_SYSQUOTA_FOUND=no
4753 AC_MSG_CHECKING(whether to try disk-quotas support)
4754 AC_ARG_WITH(quotas,
4755 [AS_HELP_STRING([--with-quotas], [Include disk-quota support (default=no)])],
4756 [ case "$withval" in
4757   yes)
4758     AC_MSG_RESULT(yes)
4759     samba_cv_WITH_QUOTAS=yes
4760     samba_cv_TRY_QUOTAS=yes
4761     samba_cv_RUN_QUOTA_TESTS=yes
4762     #set sys quotas to auto in this case
4763     samba_cv_TRY_SYS_QUOTAS=auto
4764     ;;
4765   auto)
4766     AC_MSG_RESULT(auto)
4767     samba_cv_WITH_QUOTAS=auto
4768     samba_cv_TRY_QUOTAS=auto
4769     samba_cv_RUN_QUOTA_TESTS=auto
4770     #set sys quotas to auto in this case
4771     samba_cv_TRY_SYS_QUOTAS=auto
4772     ;;
4773   no)
4774     AC_MSG_RESULT(no)
4775     samba_cv_WITH_QUOTAS=no
4776     samba_cv_TRY_QUOTAS=no
4777     samba_cv_RUN_QUOTA_TESTS=no
4778     ;;
4779   *)
4780     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4781     ;;
4782   esac ],
4783   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4786 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4787 AC_ARG_WITH(sys-quotas,
4788 [AS_HELP_STRING([--with-sys-quotas], [Include lib/sysquotas.c support (default=auto)])],
4789 [ case "$withval" in
4790   yes)
4791     AC_MSG_RESULT(yes)
4792     samba_cv_WITH_SYS_QUOTAS=yes
4793     samba_cv_TRY_SYS_QUOTAS=yes
4794     samba_cv_RUN_QUOTA_TESTS=yes
4795     ;;
4796   auto)
4797     AC_MSG_RESULT(auto)
4798     samba_cv_WITH_SYS_QUOTAS=auto
4799     samba_cv_TRY_SYS_QUOTAS=auto
4800     samba_cv_RUN_QUOTA_TESTS=auto
4801     ;;
4802   no)
4803     AC_MSG_RESULT(no)
4804     samba_cv_WITH_SYS_QUOTAS=no
4805     samba_cv_TRY_SYS_QUOTAS=no
4806     ;;
4807   *)
4808     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4809     ;;
4810   esac ],
4811   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4814 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4815 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4816   case "$host_os" in
4817         *linux*)
4818             AC_MSG_RESULT(yes)
4819             samba_cv_TRY_SYS_QUOTAS=yes
4820             samba_cv_RUN_QUOTA_TESTS=yes
4821             ;;
4822         *)
4823             AC_MSG_RESULT(no)
4824             samba_cv_TRY_SYS_QUOTAS=no
4825             ;;
4826   esac
4829 #############################################
4830 # only check for quota stuff if --with-quotas
4831 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4833 case "$host_os" in
4834         # on linux we didn't need to test we have builtin support
4835         *linux*)
4836             samba_cv_SYSQUOTA_FOUND=yes
4837             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4838             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4839             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4840             AC_MSG_RESULT(yes)
4842             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4843             samba_cv_found_xfs_header=yes
4844             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4845             AC_MSG_RESULT(yes)
4846             ;;
4847         *solaris*)
4848             # need to set this define when using static linking (BUG 1473)
4849             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4850             ;;
4851         *)
4852             ;;
4853 esac
4855 # some broken header files need this
4856 AC_CHECK_HEADER(asm/types.h,[
4857             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4858             AC_ADD_INCLUDE(<asm/types.h>)
4859             ])
4861 # For quotas on Veritas VxFS filesystems
4862 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4864 # For quotas on Linux XFS filesystems
4865 AC_CHECK_HEADERS(linux/dqblk_xfs.h)
4867 # For sys/quota.h and linux/quota.h
4868 AC_CHECK_HEADERS(sys/quota.h)
4870 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4871 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4872 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4873 AC_TRY_COMPILE([
4874 #include "confdefs.h"
4875 #ifdef HAVE_SYS_TYPES_H
4876 #include <sys/types.h>
4877 #endif
4878 #ifdef HAVE_ASM_TYPES_H
4879 #include <asm/types.h>
4880 #endif
4881 #include <sys/quota.h>
4882 ],[int i = Q_XGETQUOTA;],
4883 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4884 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4885         samba_cv_found_xfs_header=yes
4889 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX
4890 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4891 AC_TRY_COMPILE([
4892 #include "confdefs.h"
4893 #ifdef HAVE_SYS_QUOTA_H
4894 #include <sys/quota.h>
4895 #endif
4897 struct dqblk D;
4898 D.dqb_fsoftlimit = 0;],
4899 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4900 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4901         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
4904 ##################
4905 # look for a working quota system
4907 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4908 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
4909 AC_TRY_RUN_STRICT([
4910 #define HAVE_QUOTACTL_4A 1
4911 #define AUTOCONF_TEST 1
4912 #include "confdefs.h"
4913 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4914            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
4915 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
4916     samba_cv_SYSQUOTA_FOUND=yes;
4917     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
4918     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
4922 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4923 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
4924 AC_TRY_RUN_STRICT([
4925 #define HAVE_QUOTACTL_4B 1
4926 #define AUTOCONF_TEST 1
4927 #include "confdefs.h"
4928 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4929            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
4930 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
4931     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
4932     samba_cv_SYSQUOTA_FOUND=yes;
4933     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
4934     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
4938 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4939 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
4940 AC_TRY_RUN_STRICT([
4941 #define HAVE_QUOTACTL_3 1
4942 #define AUTOCONF_TEST 1
4943 #include "confdefs.h"
4944 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4945            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
4946 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
4947     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
4948     samba_cv_SYSQUOTA_FOUND=yes;
4949     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
4950     samba_cv_sysquotas_file="lib/sysquotas_3.c"
4954 #################################################
4955 # check for mntent.h and struct mntent
4956 AC_CHECK_HEADERS(mntent.h)
4957 #################################################
4958 # check for setmntent,getmntent,endmntent
4959 AC_CHECK_FUNCS(setmntent getmntent endmntent)
4961 #################################################
4962 # check for devnm.h and struct mntent
4963 AC_CHECK_HEADERS(devnm.h)
4964 #################################################
4965 # check for devnm
4966 AC_CHECK_FUNCS(devnm)
4968 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
4969     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4970         # if --with-sys-quotas=yes then build it
4971         # you have can use the get/set quota command smb.conf
4972         # options then
4973         samba_cv_SYSQUOTA_FOUND=auto
4974     fi
4975     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
4976         # if --with-sys-quotas=yes then build it
4977         # you have can use the get/set quota command smb.conf
4978         # options then
4979         samba_cv_TRY_SYS_QUOTAS=auto
4980     fi
4983 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
4984 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
4985 SAVE_CPPFLAGS="$CPPFLAGS"
4986 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4987 AC_TRY_COMPILE([
4988 #include "confdefs.h"
4989 #define NO_PROTO_H 1
4990 #define NO_CONFIG_H 1
4991 #define HAVE_SYS_QUOTAS 1
4992 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
4993 #include "${srcdir-.}/lib/sysquotas.c"
4994 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
4995 CPPFLAGS="$SAVE_CPPFLAGS"
4997 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
4998 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
4999     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
5000         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
5001         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
5002         samba_cv_WE_USE_SYS_QUOTAS=yes
5003         AC_MSG_RESULT(yes)
5004     else
5005         AC_MSG_RESULT(no)
5006     fi
5010 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
5011 AC_CACHE_CHECK([whether the sys_quota interface works with NFS],samba_cv_SYSQUOTA_WORKS_NFS,[
5012 SAVE_CPPFLAGS="$CPPFLAGS"
5013 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5014 AC_TRY_COMPILE([
5015 #include "confdefs.h"
5016 #define NO_PROTO_H 1
5017 #define NO_CONFIG_H 1
5018 #define HAVE_SYS_QUOTAS 1
5019 #define HAVE_NFS_QUOTAS 1
5020 #include "${srcdir-.}/lib/sysquotas_nfs.c"
5021 ],[],samba_cv_SYSQUOTA_WORKS_NFS=yes,samba_cv_SYSQUOTA_WORKS_NFS=no)
5022 CPPFLAGS="$SAVE_CPPFLAGS"
5024 if test x"$samba_cv_SYSQUOTA_WORKS_NFS" = x"yes"; then
5025     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
5026         AC_DEFINE(HAVE_NFS_QUOTAS,1,[Whether nfs quota support is available])
5027     fi
5031 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
5032 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
5033 SAVE_CPPFLAGS="$CPPFLAGS"
5034 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5035 AC_TRY_COMPILE([
5036 #include "confdefs.h"
5037 #define NO_PROTO_H 1
5038 #define NO_CONFIG_H 1
5039 #define HAVE_SYS_QUOTAS 1
5040 #define HAVE_XFS_QUOTAS 1
5041 #include "${srcdir-.}/lib/sysquotas_xfs.c"
5042 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
5043 CPPFLAGS="$SAVE_CPPFLAGS"
5045 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
5046     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
5047         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
5048     fi
5052 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
5053 SAVE_CPPFLAGS="$CPPFLAGS"
5054 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5055 AC_TRY_COMPILE([
5056 #include "confdefs.h"
5057 #define NO_PROTO_H 1
5058 #define NO_CONFIG_H 1
5059 #include "${srcdir-.}/smbd/quotas.c"
5060 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
5061 CPPFLAGS="$SAVE_CPPFLAGS"
5063 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
5064 AC_MSG_CHECKING(whether to use the old quota support)
5065     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
5066       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
5067         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
5068         AC_MSG_RESULT(yes)
5069       else
5070         AC_MSG_RESULT(no)
5071       fi
5072     else
5073       AC_MSG_RESULT(no)
5074     fi
5077 ####################
5078 # End of quota check samba_cv_RUN_QUOTA_TESTS
5081 #################################################
5082 # check for experimental utmp accounting
5084 AC_MSG_CHECKING(whether to support utmp accounting)
5085 WITH_UTMP=yes
5086 AC_ARG_WITH(utmp,
5087 [AS_HELP_STRING([--with-utmp], [Include utmp accounting (default, if supported by OS)])],
5088 [ case "$withval" in
5089   no)
5090                 WITH_UTMP=no
5091                 ;;
5092   *)
5093                 WITH_UTMP=yes
5094                 ;;
5095   esac ],
5098 # utmp requires utmp.h
5099 # Note similar check earlier, when checking utmp details.
5101 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
5102         utmp_no_reason=", no utmp.h on $host_os"
5103         WITH_UTMP=no
5106 # Display test results
5108 if test x"$WITH_UTMP" = x"yes"; then
5109         AC_MSG_RESULT(yes)
5110         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
5111 else
5112         AC_MSG_RESULT(no$utmp_no_reason)
5116 #################################################
5117 # these tests are taken from the GNU fileutils package
5118 AC_CHECKING(how to get filesystem space usage)
5119 space=no
5121 # Test for statvfs64.
5122 if test $space = no; then
5123   # SVR4
5124   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
5125   [AC_TRY_RUN([
5126 #if defined(HAVE_UNISTD_H)
5127 #include <unistd.h>
5128 #endif
5129 #include <sys/types.h>
5130 #include <sys/statvfs.h>
5131   main ()
5132   {
5133     struct statvfs64 fsd;
5134     exit (statvfs64 (".", &fsd));
5135   }],
5136   fu_cv_sys_stat_statvfs64=yes,
5137   fu_cv_sys_stat_statvfs64=no,
5138   fu_cv_sys_stat_statvfs64=cross)])
5139   if test $fu_cv_sys_stat_statvfs64 = yes; then
5140     space=yes
5141     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
5142   fi
5145 # Perform only the link test since it seems there are no variants of the
5146 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
5147 # because that got a false positive on SCO OSR5.  Adding the declaration
5148 # of a `struct statvfs' causes this test to fail (as it should) on such
5149 # systems.  That system is reported to work fine with STAT_STATFS4 which
5150 # is what it gets when this test fails.
5151 if test $space = no; then
5152   # SVR4
5153   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
5154                  [AC_TRY_LINK([#include <sys/types.h>
5155 #include <sys/statvfs.h>],
5156                               [struct statvfs fsd; statvfs (0, &fsd);],
5157                               fu_cv_sys_stat_statvfs=yes,
5158                               fu_cv_sys_stat_statvfs=no)])
5159   if test $fu_cv_sys_stat_statvfs = yes; then
5160     space=yes
5161     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
5162   fi
5165 # smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
5166 # This is not the case on ancient Linux systems.
5168 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
5169     AC_TRY_COMPILE([#include <sys/types.h>
5170 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
5171         samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
5172 if test x"$samba_cv_fsid_int" = x"yes"; then
5173     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
5176 # fsusage.c assumes that statvfs has an f_frsize entry. Some weird
5177 # systems use f_bsize.
5178 AC_CACHE_CHECK([that statvfs.f_frsize works],samba_cv_frsize, [
5179     AC_TRY_COMPILE([#include <sys/types.h>
5180 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_frsize = 0],
5181         samba_cv_frsize=yes,samba_cv_frsize=no)])
5182 if test x"$samba_cv_frsize" = x"yes"; then
5183     AC_DEFINE(HAVE_FRSIZE, 1, [Whether statvfs.f_frsize exists])
5186 # Some systems use f_flag in struct statvfs while others use f_flags
5187 AC_CACHE_CHECK([that statvfs.statvfs_f_flag works],samba_cv_statvfs_f_flag, [
5188     AC_TRY_COMPILE([#include <sys/types.h>
5189 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_flag = 0],
5190         samba_cv_statvfs_f_flag=yes,samba_cv_statvfs_f_flag=no)])
5191 if test x"$samba_cv_statvfs_f_flag" = x"yes"; then
5192     AC_DEFINE(HAVE_STATVFS_F_FLAG, 1, [Whether statvfs.f_flag exists])
5195 AC_CACHE_CHECK([that statvfs.statvfs_f_flags works],samba_cv_statvfs_f_flags, [
5196     AC_TRY_COMPILE([#include <sys/types.h>
5197 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_flags = 0],
5198         samba_cv_statvfs_f_flags=yes,samba_cv_statvfs_f_flags=no)])
5199 if test x"$samba_cv_statvfs_f_flags" = x"yes"; then
5200     AC_DEFINE(HAVE_STATVFS_F_FLAGS, 1, [Whether statvfs.f_flags exists])
5203 if test $space = no; then
5204   # DEC Alpha running OSF/1
5205   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
5206   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
5207   [AC_TRY_RUN([
5208 #include <sys/param.h>
5209 #include <sys/types.h>
5210 #include <sys/mount.h>
5211   main ()
5212   {
5213     struct statfs fsd;
5214     fsd.f_fsize = 0;
5215     exit (statfs (".", &fsd, sizeof (struct statfs)));
5216   }],
5217   fu_cv_sys_stat_statfs3_osf1=yes,
5218   fu_cv_sys_stat_statfs3_osf1=no,
5219   fu_cv_sys_stat_statfs3_osf1=no)])
5220   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
5221   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
5222     space=yes
5223     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
5224   fi
5227 if test $space = no; then
5228 # AIX
5229   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
5230 member (AIX, 4.3BSD)])
5231   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
5232   [AC_TRY_RUN([
5233 #ifdef HAVE_SYS_PARAM_H
5234 #include <sys/param.h>
5235 #endif
5236 #ifdef HAVE_SYS_MOUNT_H
5237 #include <sys/mount.h>
5238 #endif
5239 #ifdef HAVE_SYS_VFS_H
5240 #include <sys/vfs.h>
5241 #endif
5242   main ()
5243   {
5244   struct statfs fsd;
5245   fsd.f_bsize = 0;
5246   exit (statfs (".", &fsd));
5247   }],
5248   fu_cv_sys_stat_statfs2_bsize=yes,
5249   fu_cv_sys_stat_statfs2_bsize=no,
5250   fu_cv_sys_stat_statfs2_bsize=no)])
5251   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
5252   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
5253     space=yes
5254     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
5255   fi
5258 if test $space = no; then
5259 # SVR3
5260   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
5261   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
5262   [AC_TRY_RUN([#include <sys/types.h>
5263 #include <sys/statfs.h>
5264   main ()
5265   {
5266   struct statfs fsd;
5267   exit (statfs (".", &fsd, sizeof fsd, 0));
5268   }],
5269     fu_cv_sys_stat_statfs4=yes,
5270     fu_cv_sys_stat_statfs4=no,
5271     fu_cv_sys_stat_statfs4=no)])
5272   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
5273   if test $fu_cv_sys_stat_statfs4 = yes; then
5274     space=yes
5275     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
5276   fi
5279 if test $space = no; then
5280 # 4.4BSD and NetBSD
5281   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
5282 member (4.4BSD and NetBSD)])
5283   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
5284   [AC_TRY_RUN([#include <sys/types.h>
5285 #ifdef HAVE_SYS_PARAM_H
5286 #include <sys/param.h>
5287 #endif
5288 #ifdef HAVE_SYS_MOUNT_H
5289 #include <sys/mount.h>
5290 #endif
5291   main ()
5292   {
5293   struct statfs fsd;
5294   fsd.f_fsize = 0;
5295   exit (statfs (".", &fsd));
5296   }],
5297   fu_cv_sys_stat_statfs2_fsize=yes,
5298   fu_cv_sys_stat_statfs2_fsize=no,
5299   fu_cv_sys_stat_statfs2_fsize=no)])
5300   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
5301   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
5302     space=yes
5303         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
5304   fi
5307 if test $space = no; then
5308   # Ultrix
5309   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
5310   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
5311   [AC_TRY_RUN([#include <sys/types.h>
5312 #ifdef HAVE_SYS_PARAM_H
5313 #include <sys/param.h>
5314 #endif
5315 #ifdef HAVE_SYS_MOUNT_H
5316 #include <sys/mount.h>
5317 #endif
5318 #ifdef HAVE_SYS_FS_TYPES_H
5319 #include <sys/fs_types.h>
5320 #endif
5321   main ()
5322   {
5323   struct fs_data fsd;
5324   /* Ultrix's statfs returns 1 for success,
5325      0 for not mounted, -1 for failure.  */
5326   exit (statfs (".", &fsd) != 1);
5327   }],
5328   fu_cv_sys_stat_fs_data=yes,
5329   fu_cv_sys_stat_fs_data=no,
5330   fu_cv_sys_stat_fs_data=no)])
5331   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
5332   if test $fu_cv_sys_stat_fs_data = yes; then
5333     space=yes
5334     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
5335   fi
5339 # As a gating factor for large file support, in order to
5340 # use <4GB files we must have the following minimal support
5341 # available.
5342 # long long, and a 64 bit off_t or off64_t.
5343 # If we don't have all of these then disable large
5344 # file support.
5346 AC_MSG_CHECKING([if large file support can be enabled])
5347 AC_TRY_COMPILE([
5348 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
5349 #include <sys/types.h>
5350 #else
5351 __COMPILE_ERROR_
5352 #endif
5354 [int i],
5355 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
5356 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
5357         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
5359 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
5361 #################################################
5362 # check for cluster extensions
5364 CTDB_CFLAGS=""
5365 AC_SUBST(CTDB_CFLAGS)
5366 AC_ARG_WITH(ctdb,
5367 [AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])],
5368 [ case "$withval" in
5369   yes|no)
5370     AC_MSG_WARN([--with-ctdb called without argument])
5371     ;;
5372   *)
5373     CTDB_CPPFLAGS="-I$withval/include"
5374     ;;
5375   esac])
5377 SAVED_CPPFLAGS="$CPPFLAGS"
5378 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS} $CTDB_CPPFLAGS"
5379 ctdb_broken="missing or broken headers"
5381 AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
5382 #include "confdefs.h"
5383 #define NO_CONFIG_H
5384 #include "replace.h"
5385 #include "system/wait.h"
5386 #include "system/network.h"
5387 #define private #error __USED_RESERVED_WORD_private__
5388 #include <talloc.h>
5389 #include <tdb.h>
5390 #include <ctdb.h>
5393 AC_HAVE_DECL(CTDB_CONTROL_TRANS3_COMMIT,[
5394 #include "confdefs.h"
5395 #define NO_CONFIG_H
5396 #include "replace.h"
5397 #include "system/wait.h"
5398 #include "system/network.h"
5399 #include <talloc.h>
5400 #include <tdb.h>
5401 #include <ctdb.h>
5402 #include <ctdb_private.h>
5404 if test x"$ac_cv_have_CTDB_CONTROL_TRANS3_COMMIT_decl" = x"yes"; then
5405         ctdb_broken=no
5406 else
5407         ctdb_broken="ctdb transaction support missing or too old"
5410 # in ctdb 1.0.57 ctdb_control_tcp was temparary renamed to ctdb_tcp_client
5411 AC_CHECK_TYPE(struct ctdb_tcp_client,[
5412         AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support])
5413 ],,[
5414 #include "confdefs.h"
5415 #define NO_CONFIG_H
5416 #include "replace.h"
5417 #include "system/wait.h"
5418 #include "system/network.h"
5419 #include <talloc.h>
5420 #include <tdb.h>
5421 #include <ctdb.h>
5422 #include <ctdb_private.h>
5425 AC_CHECK_TYPE(struct ctdb_control_tcp,[
5426         AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP],[1],[ctdb ipv4 support])
5428         ctdb_broken="missing struct ctdb_control_tcp"
5430 #include "confdefs.h"
5431 #define NO_CONFIG_H
5432 #include "replace.h"
5433 #include "system/wait.h"
5434 #include "system/network.h"
5435 #include <talloc.h>
5436 #include <tdb.h>
5437 #include <ctdb.h>
5438 #include <ctdb_private.h>
5441 AC_CHECK_TYPE(struct ctdb_control_tcp_addr,[
5442         AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR],[1],[ctdb ipv6 support])
5443 ],,[
5444 #include "confdefs.h"
5445 #define NO_CONFIG_H
5446 #include "replace.h"
5447 #include "system/wait.h"
5448 #include "system/network.h"
5449 #include <talloc.h>
5450 #include <tdb.h>
5451 #include <ctdb.h>
5452 #include <ctdb_private.h>
5454 CPPFLAGS="$SAVED_CPPFLAGS"
5456 AC_MSG_CHECKING(cluster support)
5457 AC_ARG_WITH(cluster-support,
5458 [AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])])
5460 if test x"$with_cluster_support" = x ; then
5461         with_cluster_support="auto"
5464 if test x"$ac_cv_header_ctdb_private_h" != x"yes"; then
5465         if test "x$with_cluster_support" = "xyes"; then
5466                 AC_MSG_ERROR("ctdb_private.h is required for cluster support")
5467         fi
5468         with_cluster_support=no
5471 if test x"$ctdb_broken" != x"no"; then
5472         if test "x$with_cluster_support" = "xyes"; then
5473                 AC_MSG_ERROR(["cluster support: $ctdb_broken"])
5474         fi
5475         with_cluster_support=no
5478 if test "x$with_cluster_support" != "xno"; then
5479     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
5480     SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CTDB_CPPFLAGS}"
5481     AC_MSG_RESULT(yes)
5482 else
5483     AC_MSG_RESULT(no)
5486 #################################################
5487 # check for ACL support
5489 AC_MSG_CHECKING(whether to support ACLs)
5490 AC_ARG_WITH(acl-support,
5491 [AS_HELP_STRING([--with-acl-support], [Include ACL support (default=auto)])],
5492 [ case "$withval" in
5493         yes|no)
5494                 with_acl_support="$withval"
5495                 ;;
5496   esac ])
5498 if test x"$with_acl_support" = x ; then
5499         with_acl_support="auto"
5502 AC_MSG_RESULT($with_acl_support)
5504 if test x"$with_acl_support" = x"no"; then
5505         AC_MSG_RESULT(Disabling ACL support)
5506         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
5507 else
5508         AC_MSG_NOTICE(checking whether ACL support is available:)
5509         case "$host_os" in
5510         *sysv5*)
5511                 AC_MSG_NOTICE(Using UnixWare ACLs)
5512                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
5513                 default_static_modules="$default_static_modules vfs_solarisacl"
5514                 ;;
5515         *solaris*)
5516                 AC_MSG_NOTICE(Using solaris ACLs)
5517                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
5518                 ACL_LIBS="$ACL_LIBS -lsec"
5519                 default_static_modules="$default_static_modules vfs_solarisacl"
5520                 ;;
5521         *hpux*)
5522                 AC_MSG_NOTICE(Using HPUX ACLs)
5523                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
5524                 default_static_modules="$default_static_modules vfs_hpuxacl"
5525                 ;;
5526         *irix*)
5527                 AC_MSG_NOTICE(Using IRIX ACLs)
5528                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
5529                 default_static_modules="$default_static_modules vfs_irixacl"
5530                 ;;
5531         *aix*)
5532                 AC_MSG_NOTICE(Using AIX ACLs)
5533                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
5534                 default_static_modules="$default_static_modules vfs_aixacl"
5535                 ;;
5536         *osf*)
5537                 AC_MSG_NOTICE(Using Tru64 ACLs)
5538                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
5539                 ACL_LIBS="$ACL_LIBS -lpacl"
5540                 default_static_modules="$default_static_modules vfs_tru64acl"
5541                 ;;
5542         *darwin*)
5543                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
5544                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5545                 ;;
5546         *)
5547                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
5548                 case "$host_os" in
5549                 *linux*)
5550                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
5551                         ;;
5552                 esac
5553                 AC_CACHE_CHECK([for POSIX ACL support],samba_cv_HAVE_POSIX_ACLS,[
5554                         acl_LIBS=$LIBS
5555                         LIBS="$LIBS $ACL_LIBS"
5556                         AC_TRY_LINK([
5557                                 #include <sys/types.h>
5558                                 #include <sys/acl.h>
5559                         ],[
5560                                 acl_t acl;
5561                                 int entry_id;
5562                                 acl_entry_t *entry_p;
5563                                 return acl_get_entry(acl, entry_id, entry_p);
5564                         ],
5565                         [samba_cv_HAVE_POSIX_ACLS=yes],
5566                         [samba_cv_HAVE_POSIX_ACLS=no])
5567                         LIBS=$acl_LIBS
5568                 ])
5569                 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
5570                         AC_MSG_NOTICE(Using posix ACLs)
5571                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
5572                         AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
5573                                 acl_LIBS=$LIBS
5574                                 LIBS="$LIBS $ACL_LIBS"
5575                                 AC_TRY_LINK([
5576                                         #include <sys/types.h>
5577                                         #include <sys/acl.h>
5578                                 ],[
5579                                         acl_permset_t permset_d;
5580                                         acl_perm_t perm;
5581                                         return acl_get_perm_np(permset_d, perm);
5582                                 ],
5583                                 [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
5584                                 [samba_cv_HAVE_ACL_GET_PERM_NP=no])
5585                                 LIBS=$acl_LIBS
5586                         ])
5587                         if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
5588                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
5589                         fi
5590                         default_static_modules="$default_static_modules vfs_posixacl"
5591                 else
5592                         AC_MSG_NOTICE(ACL support is not avaliable)
5593                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5594                 fi
5595                 ;;
5596         esac
5597 fi # with_acl_support
5601 #################################################
5602 # check for AIO support
5604 AC_MSG_CHECKING(whether to support asynchronous io)
5605 AC_ARG_WITH(aio-support,
5606 [AS_HELP_STRING([--with-aio-support], [Include asynchronous io support (default=no)])],
5607 [ case "$withval" in
5608   yes)
5610         AC_MSG_RESULT(yes)
5611         case "$host_os" in
5612         *)
5613                 AIO_LIBS=$LIBS
5614                 no_rt_LIBS=$LIBS
5615                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
5616                 LIBS=$no_rt_LIBS
5617                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
5618                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
5619                 aio_LIBS=$LIBS
5620                 LIBS=$AIO_LIBS
5621                 AC_TRY_LINK([#include <sys/types.h>
5622 #include <aio.h>],
5623 [ struct aiocb a; return aio_read(&a);],
5624 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
5625                 LIBS=$aio_LIBS])
5626                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
5627                 aio_LIBS=$LIBS
5628                 LIBS=$AIO_LIBS
5629                 AC_TRY_LINK([#include <sys/types.h>
5630 #include <aio.h>],
5631 [ struct aiocb64 a; return aio_read64(&a);],
5632 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
5633                 LIBS=$aio_LIBS])
5634                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5635                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
5636                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5637                         LIBS=$AIO_LIBS
5638                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
5639                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5640                         LIBS=$AIO_LIBS
5641                 fi
5643                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5644                         AC_MSG_CHECKING(for aio_read)
5645                         AC_LINK_IFELSE([#include <aio.h>
5646 int main() { struct aiocb a; return aio_read(&a); }],
5647 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
5648 [AC_MSG_RESULT(no)])
5650                         AC_MSG_CHECKING(for aio_write)
5651                         AC_LINK_IFELSE([#include <aio.h>
5652 int main() { struct aiocb a; return aio_write(&a); }],
5653 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
5654 [AC_MSG_RESULT(no)])
5656                         AC_MSG_CHECKING(for aio_fsync)
5657                         AC_LINK_IFELSE([#include <aio.h>
5658 int main() { struct aiocb a; return aio_fsync(1, &a); }],
5659 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
5660 [AC_MSG_RESULT(no)])
5662                         AC_MSG_CHECKING(for aio_return)
5663                         AC_LINK_IFELSE([#include <aio.h>
5664 int main() { struct aiocb a; return aio_return(&a); }],
5665 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
5666 [AC_MSG_RESULT(no)])
5668                         AC_MSG_CHECKING(for aio_error)
5669                         AC_LINK_IFELSE([#include <aio.h>
5670 int main() { struct aiocb a; return aio_error(&a); }],
5671 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
5672 [AC_MSG_RESULT(no)])
5674                         AC_MSG_CHECKING(for aio_cancel)
5675                         AC_LINK_IFELSE([#include <aio.h>
5676 int main() { struct aiocb a; return aio_cancel(1, &a); }],
5677 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
5678 [AC_MSG_RESULT(no)])
5680                         AC_MSG_CHECKING(for aio_suspend)
5681                         AC_LINK_IFELSE([#include <aio.h>
5682 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
5683 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
5684 [AC_MSG_RESULT(no)])
5685                 fi
5687                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5688                         AC_MSG_CHECKING(for aio_read64)
5689                         AC_LINK_IFELSE([#include <aio.h>
5690 int main() { struct aiocb a; return aio_read64(&a); }],
5691 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
5692 [AC_MSG_RESULT(no)])
5694                         AC_MSG_CHECKING(for aio_write64)
5695                         AC_LINK_IFELSE([#include <aio.h>
5696 int main() { struct aiocb a; return aio_write64(&a); }],
5697 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
5698 [AC_MSG_RESULT(no)])
5700                         AC_MSG_CHECKING(for aio_fsync64)
5701                         AC_LINK_IFELSE([#include <aio.h>
5702 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
5703 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
5704 [AC_MSG_RESULT(no)])
5706                         AC_MSG_CHECKING(for aio_return64)
5707                         AC_LINK_IFELSE([#include <aio.h>
5708 int main() { struct aiocb a; return aio_return64(&a); }],
5709 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
5710 [AC_MSG_RESULT(no)])
5712                         AC_MSG_CHECKING(for aio_error64)
5713                         AC_LINK_IFELSE([#include <aio.h>
5714 int main() { struct aiocb a; return aio_error64(&a); }],
5715 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
5716 [AC_MSG_RESULT(no)])
5718                         AC_MSG_CHECKING(for aio_cancel64)
5719                         AC_LINK_IFELSE([#include <aio.h>
5720 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
5721 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
5722 [AC_MSG_RESULT(no)])
5724                         AC_MSG_CHECKING(for aio_suspend64)
5725                         AC_LINK_IFELSE([#include <aio.h>
5726 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
5727 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
5728 [AC_MSG_RESULT(no)])
5729                 fi
5730             ;;
5731         esac
5732         ;;
5733   *)
5734     AC_MSG_RESULT(no)
5735     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
5736     ;;
5737   esac ],
5738   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
5739   AC_MSG_RESULT(no)
5742 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5743         if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \
5744                 x"$samba_cv_msghdr_msg_acctright" = x"yes"; then
5745                 default_shared_modules="$default_shared_modules vfs_aio_fork"
5746         fi
5749 #################################################
5750 # check for sendfile support
5752 with_sendfile_support=yes
5753 AC_MSG_CHECKING(whether to check to support sendfile)
5754 AC_ARG_WITH(sendfile-support,
5755 [AS_HELP_STRING([--with-sendfile-support], [Check for sendfile support (default=yes)])],
5756 [ case "$withval" in
5757   yes)
5759         AC_MSG_RESULT(yes);
5761         case "$host_os" in
5762         *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
5763                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5764                 AC_TRY_LINK([#include <sys/sendfile.h>],
5766 int tofd, fromfd;
5767 off64_t offset;
5768 size_t total;
5769 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
5771 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5773                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
5774                 AC_TRY_LINK([#include <sys/sendfile.h>],
5776 int tofd, fromfd;
5777 off_t offset;
5778 size_t total;
5779 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5781 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5783 # Try and cope with broken Linux sendfile....
5784                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
5785                 AC_TRY_LINK([\
5786 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5787 #undef _FILE_OFFSET_BITS
5788 #endif
5789 #include <sys/sendfile.h>],
5791 int tofd, fromfd;
5792 off_t offset;
5793 size_t total;
5794 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5796 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5798         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5799                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5800                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5801                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5802         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5803                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5804                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5805                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5806         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5807                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5808                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5809         else
5810                 AC_MSG_RESULT(no);
5811         fi
5813         ;;
5814         *freebsd* | *dragonfly* )
5815                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5816                 AC_TRY_LINK([\
5817 #include <sys/types.h>
5818 #include <unistd.h>
5819 #include <sys/socket.h>
5820 #include <sys/uio.h>],
5822         int fromfd, tofd, ret, total=0;
5823         off_t offset, nwritten;
5824         struct sf_hdtr hdr;
5825         struct iovec hdtrl;
5826         hdr.headers = &hdtrl;
5827         hdr.hdr_cnt = 1;
5828         hdr.trailers = NULL;
5829         hdr.trl_cnt = 0;
5830         hdtrl.iov_base = NULL;
5831         hdtrl.iov_len = 0;
5832         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
5834 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5836         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5837                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
5838                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
5839                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5840         else
5841                 AC_MSG_RESULT(no);
5842         fi
5843         ;;
5845         *hpux*)
5846                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5847                 AC_TRY_LINK([\
5848 #include <sys/socket.h>
5849 #include <sys/uio.h>],
5851         int fromfd, tofd;
5852         size_t total=0;
5853         struct iovec hdtrl[2];
5854         ssize_t nwritten;
5855         off64_t offset;
5857         hdtrl[0].iov_base = 0;
5858         hdtrl[0].iov_len = 0;
5860         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
5862 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5863         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5864                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
5865                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5866                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5867         else
5868                 AC_MSG_RESULT(no);
5869         fi
5871                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
5872                 AC_TRY_LINK([\
5873 #include <sys/socket.h>
5874 #include <sys/uio.h>],
5876         int fromfd, tofd;
5877         size_t total=0;
5878         struct iovec hdtrl[2];
5879         ssize_t nwritten;
5880         off_t offset;
5882         hdtrl[0].iov_base = 0;
5883         hdtrl[0].iov_len = 0;
5885         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
5887 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5888         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5889                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5890                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5891                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5892         else
5893                 AC_MSG_RESULT(no);
5894         fi
5895         ;;
5897         *solaris*)
5898                 AC_CHECK_LIB(sendfile,sendfilev)
5899                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
5900                 AC_TRY_LINK([\
5901 #include <sys/sendfile.h>],
5903         int sfvcnt;
5904         size_t xferred;
5905         struct sendfilevec vec[2];
5906         ssize_t nwritten;
5907         int tofd;
5909         sfvcnt = 2;
5911         vec[0].sfv_fd = SFV_FD_SELF;
5912         vec[0].sfv_flag = 0;
5913         vec[0].sfv_off = 0;
5914         vec[0].sfv_len = 0;
5916         vec[1].sfv_fd = 0;
5917         vec[1].sfv_flag = 0;
5918         vec[1].sfv_off = 0;
5919         vec[1].sfv_len = 0;
5920         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
5922 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
5924         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
5925                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
5926                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
5927                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5928         else
5929                 AC_MSG_RESULT(no);
5930         fi
5932                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
5933                 AC_TRY_LINK([\
5934 #include <sys/sendfile.h>],
5936         int sfvcnt;
5937         size_t xferred;
5938         struct sendfilevec vec[2];
5939         ssize_t nwritten;
5940         int tofd;
5942         sfvcnt = 2;
5944         vec[0].sfv_fd = SFV_FD_SELF;
5945         vec[0].sfv_flag = 0;
5946         vec[0].sfv_off = 0;
5947         vec[0].sfv_len = 0;
5949         vec[1].sfv_fd = 0;
5950         vec[1].sfv_flag = 0;
5951         vec[1].sfv_off = 0;
5952         vec[1].sfv_len = 0;
5953         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
5955 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
5957         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
5958                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
5959                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
5960                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5961         else
5962                 AC_MSG_RESULT(no);
5963         fi
5964         ;;
5965         *aix*)
5966                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
5967                 AC_TRY_LINK([\
5968 #include <sys/socket.h>],
5970         int fromfd, tofd;
5971         size_t total=0;
5972         struct sf_parms hdtrl;
5973         ssize_t nwritten;
5974         off64_t offset;
5976         hdtrl.header_data = 0;
5977         hdtrl.header_length = 0;
5978         hdtrl.file_descriptor = fromfd;
5979         hdtrl.file_offset = 0;
5980         hdtrl.file_bytes = 0;
5981         hdtrl.trailer_data = 0;
5982         hdtrl.trailer_length = 0;
5984         nwritten = send_file(&tofd, &hdtrl, 0);
5986 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5987         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5988                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5989                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
5990                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5991         else
5992                 AC_MSG_RESULT(no);
5993         fi
5994         ;;
5995         *)
5996         ;;
5997         esac
5998         ;;
5999   *)
6000     AC_MSG_RESULT(no)
6001     ;;
6002   esac ],
6003   AC_MSG_RESULT(yes)
6006 ############################################
6007 # See if we have the Linux readahead syscall.
6009 AC_CACHE_CHECK([for Linux readahead],
6010                 samba_cv_HAVE_LINUX_READAHEAD,[
6011     AC_TRY_LINK([
6012 #if defined(HAVE_UNISTD_H)
6013 #include <unistd.h>
6014 #endif
6015 #include <fcntl.h>],
6016     [ssize_t err = readahead(0,0,0x80000);],
6017     samba_cv_HAVE_LINUX_READAHEAD=yes,
6018     samba_cv_HAVE_LINUX_READAHEAD=no)])
6020 if test x"$samba_cv_HAVE_LINUX_READAHEAD" = x"yes"; then
6021   AC_DEFINE(HAVE_LINUX_READAHEAD,1,
6022              [Whether Linux readahead is available])
6025 AC_HAVE_DECL(readahead, [#include <fcntl.h>])
6027 ############################################
6028 # See if we have the posix_fadvise syscall.
6030 AC_CACHE_CHECK([for posix_fadvise],
6031                 samba_cv_HAVE_POSIX_FADVISE,[
6032     AC_TRY_LINK([
6033 #if defined(HAVE_UNISTD_H)
6034 #include <unistd.h>
6035 #endif
6036 #include <fcntl.h>],
6037     [ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);],
6038     samba_cv_HAVE_POSIX_FADVISE=yes,
6039     samba_cv_HAVE_POSIX_FADVISE=no)])
6041 if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
6042   AC_DEFINE(HAVE_POSIX_FADVISE,1,
6043              [Whether posix_fadvise is available])
6046 ############################################
6047 # See if we have the Linux splice syscall.
6049 case "$host_os" in
6050 *linux*)
6051 AC_CACHE_CHECK([for Linux splice],
6052                 samba_cv_HAVE_LINUX_SPLICE,[
6053     AC_TRY_LINK([
6054 #if defined(HAVE_UNISTD_H)
6055 #include <unistd.h>
6056 #endif
6057 #include <fcntl.h>],
6058     [long ret = splice(0,0,1,0,400,0);],
6059     samba_cv_HAVE_LINUX_SPLICE=yes,
6060     samba_cv_HAVE_LINUX_SPLICE=no)])
6063 samba_cv_HAVE_LINUX_SPLICE=no
6065 esac
6067 if test x"$samba_cv_HAVE_LINUX_SPLICE" = x"yes"; then
6068   AC_DEFINE(HAVE_LINUX_SPLICE,1,
6069              [Whether Linux splice is available])
6072 AC_HAVE_DECL(splice, [#include <fcntl.h>])
6074 ############################################
6075 # See if we have the a broken readlink syscall.
6077 AC_CACHE_CHECK([for a broken readlink syscall],samba_cv_HAVE_BROKEN_READLINK,[
6078 AC_TRY_RUN([#include "${srcdir-.}/../tests/readlink.c"],
6079         samba_cv_HAVE_BROKEN_READLINK=no,samba_cv_HAVE_BROKEN_READLINK=yes,samba_cv_HAVE_BROKEN_READLINK=cross)
6081 if test x"$samba_cv_HAVE_BROKEN_READLINK" = x"yes"; then
6082         AC_DEFINE(HAVE_BROKEN_READLINK,1,[Whether the readlink syscall is broken])
6085 #################################################
6086 # Check whether winbind is supported on this platform.  If so we need to
6087 # build and install client programs, sbin programs and shared libraries
6089 AC_MSG_CHECKING(whether to build winbind)
6091 # Initially, the value of $host_os decides whether winbind is supported
6093 HAVE_WINBIND=yes
6094 HAVE_WBCLIENT=no
6096 # Define external wbclient library to link against.  This disables winbind.
6097 # We define this here so --with-winbind can override it.
6098 AC_ARG_WITH(wbclient,
6099 [AS_HELP_STRING([--with-wbclient], [Use external wbclient (optional)])],
6101   case "$withval" in
6102         no)
6103                 HAVE_WBCLIENT=no
6104                 ;;
6105         yes)
6106                 HAVE_WBCLIENT=yes
6107                 HAVE_WINBIND=no
6108                 ;;
6109         *)
6110                 HAVE_WBCLIENT=yes
6111                 HAVE_WINBIND=no
6112                 WBCLIENT_INCLUDES="-I$withval/include"
6113                 WBCLIENT_LDFLAGS="-L$withval/lib"
6114                 ;;
6115   esac ],
6118 AC_SUBST(WBCLIENT_INCLUDES)
6119 AC_SUBST(WBCLIENT_LDFLAGS)
6120 AC_SUBST(WBCLIENT_LIBS)
6123 # Define the winbind shared library name and any specific linker flags
6124 # it needs to be built with.
6126 WINBIND_NSS="../nsswitch/libnss_winbind.$SHLIBEXT"
6127 WINBIND_WINS_NSS="../nsswitch/libnss_wins.$SHLIBEXT"
6128 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
6129 NSSSONAMEVERSIONSUFFIX=""
6131 case "$host_os" in
6132         *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
6133                 NSSSONAMEVERSIONSUFFIX=".2"
6134                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_linux.o"
6135                 ;;
6136         *freebsd[[5-9]]*)
6137                 # FreeBSD winbind client is implemented as a wrapper around
6138                 # the Linux version.
6139                 NSSSONAMEVERSIONSUFFIX=".1"
6140                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_freebsd.o \
6141                     ../nsswitch/winbind_nss_linux.o"
6142                 WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
6143                 WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
6144                 ;;
6146         *netbsd*[[3-9]]*)
6147                 # NetBSD winbind client is implemented as a wrapper
6148                 # around the Linux version. It needs getpwent_r() to
6149                 # indicate libc's use of the correct nsdispatch API.
6150                 #
6151                 if test x"$ac_cv_func_getpwent_r" = x"yes"; then
6152                         WINBIND_NSS_EXTRA_OBJS="\
6153                             ../nsswitch/winbind_nss_netbsd.o \
6154                             ../nsswitch/winbind_nss_linux.o"
6155                         WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
6156                         WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
6157                 else
6158                         HAVE_WINBIND=no
6159                         winbind_no_reason=", getpwent_r is missing on $host_os so winbind is unsupported"
6160                 fi
6161                 ;;
6162         *irix*)
6163                 # IRIX has differently named shared libraries
6164                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_irix.o"
6165                 WINBIND_NSS="../nsswitch/libns_winbind.$SHLIBEXT"
6166                 WINBIND_WINS_NSS="../nsswitch/libns_wins.$SHLIBEXT"
6167                 ;;
6168         *solaris*)
6169                 # Solaris winbind client is implemented as a wrapper around
6170                 # the Linux version.
6171                 NSSSONAMEVERSIONSUFFIX=".1"
6172                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o \
6173                     ../nsswitch/winbind_nss_linux.o"
6174                 ;;
6175         *hpux11*)
6176                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o"
6177                 ;;
6178         *aix*)
6179                 # AIX has even differently named shared libraries.  No
6180                 # WINS support has been implemented yet.
6181                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_aix.o"
6182                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
6183                 WINBIND_NSS="../nsswitch/WINBIND"
6184                 WINBIND_WINS_NSS=""
6185                 ;;
6186         *)
6187                 HAVE_WINBIND=no
6188                 winbind_no_reason=", unsupported on $host_os"
6189                 ;;
6190 esac
6192 # Check the setting of --with-winbind
6194 AC_ARG_WITH(winbind,
6195 [AS_HELP_STRING([--with-winbind], [Build winbind (default, if supported by OS)])],
6197   case "$withval" in
6198         yes)
6199                 HAVE_WINBIND=yes
6200                 HAVE_WBCLIENT=no
6201                 ;;
6202         no)
6203                 HAVE_WINBIND=no
6204                 winbind_reason=""
6205                 ;;
6206   esac ],
6209 # We need unix domain sockets for winbind
6211 if test x"$HAVE_WINBIND" = x"yes"; then
6212         if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"no"; then
6213                 winbind_no_reason=", no unix domain socket support on $host_os"
6214                 HAVE_WINBIND=no
6215         fi
6218 # Display test results
6220 if test x"$HAVE_WINBIND" = x"no"; then
6221         WINBIND_NSS=""
6222         WINBIND_WINS_NSS=""
6224 if test x"$HAVE_WBCLIENT" = x"yes"; then
6225         AC_CHECK_LIB(wbclient, wbcInterfaceDetails,
6226                      [LIBWBCLIENT_LIBS="-lwbclient"], AC_MSG_ERROR([Could not find wbclient]), [$WBCLIENT_LDFLAGS])
6227         LIBWBCLIENT_LIBS="$LIBWBCLIENT_LIBS $WBCLIENT_LDFLAGS"
6228         AC_MSG_RESULT(yes)
6229         AC_DEFINE(WITH_WINBIND,1,[Whether to link to wbclient])
6230         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
6231 else
6232         if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
6233                 BUILD_LIBWBCLIENT_SHARED=no
6234         else
6235                 BUILD_LIBWBCLIENT_SHARED=yes
6236         fi
6238         LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
6239         LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
6240         LIBWBCLIENT_SOVER=0
6241         if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
6242                 NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
6243                 ## Only worry about libwbclient if we have shared
6244                 # library support
6245                 LIBWBCLIENT_SHARED=$LIBWBCLIENT_SHARED_TARGET
6246                 LIBWBCLIENT=libwbclient
6247                 INSTALL_LIBWBCLIENT=installlibwbclient
6248                 UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
6249                 LIBWBCLIENT_LIBS="-lwbclient"
6250         else
6251                 LIBWBCLIENT_STATIC=$LIBWBCLIENT_STATIC_TARGET
6252                 LIBWBCLIENT_LIBS=$LIBWBCLIENT_STATIC_TARGET
6253         fi
6256 if test x"$HAVE_WINBIND" = x"yes"; then
6257         AC_MSG_RESULT(yes)
6258         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
6260         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
6261         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
6262         if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
6263                 PAM_MODULES="$PAM_MODULES pam_winbind"
6264                 INSTALL_PAM_MODULES="installpammodules"
6265                 UNINSTALL_PAM_MODULES="uninstallpammodules"
6266         fi
6268         # we use winbind, check for krb5 locate_plugin support:
6269         AC_CHECK_HEADERS([krb5/locate_plugin.h], [], [],
6270                 [[#ifdef HAVE_KRB5_H
6271                  #include <krb5.h>
6272                  #endif
6273         ]])
6274         if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
6275                 WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
6276                 if test x"$BLDSHARED" = x"true" ; then
6277                         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
6278                 fi
6279         fi
6280         # end of krb5 locate_plugin check
6281 else
6282         AC_MSG_RESULT(no$winbind_no_reason)
6285 AC_SUBST(WINBIND_NSS)
6286 AC_SUBST(WINBIND_WINS_NSS)
6287 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
6288 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
6289 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
6291 AC_SUBST(WINBIND_KRB5_LOCATOR)
6293 # Solaris 10 does have new member in nss_XbyY_key
6294 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
6295                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
6296                 [#include <nss_dbdefs.h>])
6298 # Solaris has some extra fields in struct passwd that need to be
6299 # initialised otherwise nscd crashes.
6301 AC_CHECK_MEMBER(struct passwd.pw_comment,
6302                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
6303                 [#include <pwd.h>])
6305 AC_CHECK_MEMBER(struct passwd.pw_age,
6306                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
6307                 [#include <pwd.h>])
6309 # AIX 4.3.x and 5.1 do not have as many members in
6310 # struct secmethod_table as AIX 5.2
6311 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
6312        [#include <usersec.h>])
6313 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
6314        [#include <usersec.h>])
6316 AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
6317 AC_TRY_COMPILE([#include <sys/types.h>
6318 #include <sys/socket.h>],
6319 [struct ucred cred;
6320  socklen_t cred_len;
6321  int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
6323 samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
6324 if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
6325     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
6329 #################################################
6330 # Check to see if we should use the included popt
6332 AC_ARG_WITH(included-popt,
6333 [AS_HELP_STRING([--with-included-popt], [use bundled popt library, not from system])],
6335   case "$withval" in
6336         yes)
6337                 INCLUDED_POPT=yes
6338                 ;;
6339         no)
6340                 INCLUDED_POPT=no
6341                 ;;
6342   esac ],
6344 if test x"$INCLUDED_POPT" != x"yes"; then
6345     AC_CHECK_LIB(popt, poptGetContext,
6346                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
6349 AC_MSG_CHECKING(whether to use included popt)
6350 if test x"$INCLUDED_POPT" = x"yes"; then
6351     AC_MSG_RESULT(yes)
6352     BUILD_POPT='$(POPT_OBJ)'
6353     POPTLIBS='$(POPT_OBJ)'
6354     FLAGS1="-I\$(srcdir)/../lib/popt"
6355 else
6356     AC_MSG_RESULT(no)
6357         BUILD_POPT=""
6358     POPTLIBS="-lpopt"
6360 AC_SUBST(BUILD_POPT)
6361 AC_SUBST(POPTLIBS)
6362 AC_SUBST(FLAGS1)
6364 #################################################
6365 # Check if user wants DNS service discovery support
6367 AC_ARG_ENABLE(dnssd,
6368 [AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=no)])])
6370 AC_SUBST(DNSSD_LIBS)
6371 if test x"$enable_dnssd" = x"yes"; then
6372     have_dnssd_support=yes
6374     AC_CHECK_HEADERS(dns_sd.h)
6375     if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
6376         have_dnssd_support=no
6377     fi
6379     # On Darwin the DNSSD API is in libc, but on other platforms it's
6380     # probably in -ldns_sd
6381     AC_CHECK_FUNCS(DNSServiceRegister)
6382     AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
6383     if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
6384             x"$ac_cv_lib_ext_dns_sd_DNSServiceRegister" != x"yes"; then
6385         have_dnssd_support=no
6386     fi
6388     if test x"$have_dnssd_support" = x"yes"; then
6389         AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
6390                 [Whether to enable DNS service discovery support])
6391     else
6392         if test x"$enable_dnssd" = x"yes"; then
6393             AC_MSG_ERROR(DNS service discovery support not available)
6394         fi
6395     fi
6399 #################################################
6400 # Check if user wants avahi support
6402 AC_ARG_ENABLE(avahi,
6403 [AS_HELP_STRING([--enable-avahi], [Enable Avahi support (default=auto)])])
6405 if test x"$enable_avahi" != x"no"; then
6406     have_avahi_support=yes
6408     AC_CHECK_HEADERS(avahi-common/watch.h)
6409     if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
6410         have_avahi_support=no
6411     fi
6413     AC_CHECK_HEADERS(avahi-client/client.h)
6414     if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
6415         have_avahi_support=no
6416     fi
6418     save_LIBS="$LIBS"
6419     AC_CHECK_LIB(avahi-client, avahi_client_new,[have_avahi_client_new=yes])
6420     AC_CHECK_LIB(avahi-common, avahi_strerror,[have_avahi_strerror=yes])
6421     LIBS="$save_LIBS"
6423     if test x"$have_avahi_client_new" != x"yes" -o \
6424        x"$have_avahi_strerror" != x"yes" ; then
6425         have_avahi_support=no
6426     fi
6428     if test x"$have_avahi_support" = x"yes"; then
6429         AC_SUBST(AVAHI_LIBS, "-lavahi-client -lavahi-common")
6430         AC_DEFINE(WITH_AVAHI_SUPPORT, 1,
6431                 [Whether to enable avahi support])
6432         AC_SUBST(AVAHI_OBJ, "lib/avahi.o smbd/avahi_register.o")
6433     else
6434         if test x"$enable_avahi" = x"yes"; then
6435             AC_MSG_ERROR(avahi support not available)
6436         fi
6437     fi
6441 #################################################
6442 # Set pthread stuff
6444 PTHREAD_CFLAGS=error
6445 PTHREAD_LDFLAGS=error
6447 # If it's error, then the user didn't 
6448 # define it.
6449 if test "x$PTHREAD_LDFLAGS" = xerror; then
6450   AC_CHECK_LIB(pthread, pthread_attr_init, [
6451              PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
6452              PTHREAD_LDFLAGS="-lpthread" ])
6455 if test "x$PTHREAD_LDFLAGS" = xerror; then
6456   AC_CHECK_LIB(pthreads, pthread_attr_init, [
6457              PTHREAD_CFLAGS="-D_THREAD_SAFE"
6458              PTHREAD_LDFLAGS="-lpthreads" ])
6461 if test "x$PTHREAD_LDFLAGS" = xerror; then
6462    AC_CHECK_LIB(c_r, pthread_attr_init, [
6463                 PTHREAD_CFLAGS="-D_THREAD_SAFE -pthread"
6464                 PTHREAD_LDFLAGS="-pthread" ])
6467 if test "x$PTHREAD_LDFLAGS" = xerror; then
6468    AC_CHECK_FUNC(pthread_attr_init, [
6469                  PTHREAD_CFLAGS="-D_REENTRANT"
6470                  PTHREAD_LDFLAGS="-lpthread" ])
6473 # especially for HP-UX, where the AC_CHECK_FUNC macro fails to test for
6474 # pthread_attr_init. On pthread_mutex_lock it works there...
6475 if test "x$PTHREAD_LDFLAGS" = xerror; then
6476    AC_CHECK_LIB(pthread, pthread_mutex_lock, [
6477                 PTHREAD_CFLAGS="-D_REENTRANT"
6478                 PTHREAD_LDFLAGS="-lpthread" ])
6481 AC_SUBST(PTHREAD_CFLAGS)
6482 AC_SUBST(PTHREAD_LDFLAGS)
6484 samba_cv_HAVE_PTHREAD=no
6485 if test x"$PTHREAD_CFLAGS" != xerror -a x"$PTHREAD_LDFLAGS" != xerror; then
6486         samba_cv_HAVE_PTHREAD=yes
6487         # now check for pthread.h with pthread-correct CFLAGS and LDFLAGS:
6488         ac_save_CFLAGS=$CFLAGS
6489         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
6490         ac_save_LDFLAGS=$LDFLAGS
6491         LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
6492         AC_CHECK_HEADERS(pthread.h)
6493         CFLAGS=$ac_save_CFLAGS
6494         LDFLAGS=$ac_save_LDFLAGS
6495         AC_DEFINE(HAVE_PTHREAD, 1, [Do we have pthreads around?])
6498 #################################################
6499 # Check if user wants pthreadpool support
6501 AC_ARG_ENABLE(pthreadpool,
6502 [AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=no)])])
6504 if test x"$enable_pthreadpool" = xyes -a x"$samba_cv_HAVE_PTHREAD" != x"yes"; then
6505         AC_MSG_ERROR([pthreadpool support cannot be enabled when pthread support was not found])
6508 if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
6509     LIBS="$LIBS $PTHREAD_LDFLAGS"
6510     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
6511     AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
6512     AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
6515 #################################################
6516 # Check to see if we should use the included iniparser
6518 AC_ARG_WITH(included-iniparser,
6519 [AS_HELP_STRING([--with-included-iniparser], [use bundled iniparser library, not from system])],
6521   case "$withval" in
6522         yes)
6523                 INCLUDED_INIPARSER=yes
6524                 ;;
6525         no)
6526                 INCLUDED_INIPARSER=no
6527                 ;;
6528   esac ],
6530 if test x"$INCLUDED_INIPARSER" != x"yes"; then
6531     AC_CHECK_LIB(iniparser, iniparser_load,
6532                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
6535 AC_MSG_CHECKING(whether to use included iniparser)
6536 if test x"$INCLUDED_INIPARSER" = x"yes"; then
6537     AC_MSG_RESULT(yes)
6538     BUILD_INIPARSER='$(INIPARSER_OBJ)'
6539         INIPARSERLIBS=""
6540     FLAGS1="$FLAGS1 -I\$(srcdir)/../lib/iniparser/src"
6541 else
6542     AC_MSG_RESULT(no)
6543         BUILD_INIPARSER=""
6544     INIPARSERLIBS="-liniparser"
6546 AC_SUBST(BUILD_INIPARSER)
6547 AC_SUBST(INIPARSERLIBS)
6548 AC_SUBST(FLAGS1)
6550 ###################################################
6551 # Check for different/missing (set|get|end)netgrent prototypes
6552 CFLAGS_SAVE=$CFLAGS
6553 if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
6554         CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
6556 AC_CACHE_CHECK([for setnetgrent prototype],samba_cv_setnetgrent_prototype, [
6557     AC_TRY_COMPILE([#include<netdb.h>
6558                     #ifdef HAVE_NETGROUP_H
6559                     #include<netgroup.h>
6560                     #endif],[setnetgrent("foo")],
6561                     samba_cv_setnetgrent_prototype=yes, samba_cv_setnetgrent_prototype=no)])
6562 if test x"$samba_cv_setnetgrent_prototype" = x"yes"; then
6563     AC_DEFINE(HAVE_SETNETGRENT_PROTOTYPE, 1, [If setnetgrent prototype is defined])
6565 AC_CACHE_CHECK([for getnetgrent prototype],samba_cv_getnetgrent_prototype, [
6566     AC_TRY_COMPILE([#include<netdb.h>
6567                     #ifdef HAVE_NETGROUP_H
6568                     #include<netgroup.h>
6569                     #endif],[char *dom, *user,*host; getnetgrent(&dom,&user,&host)],
6570                     samba_cv_getnetgrent_prototype=yes, samba_cv_getnetgrent_prototype=no)])
6571 if test x"$samba_cv_getnetgrent_prototype" = x"yes"; then
6572     AC_DEFINE(HAVE_GETNETGRENT_PROTOTYPE, 1, [If getnetgrent prototype is defined])
6574 AC_CACHE_CHECK([for endnetgrent prototype],samba_cv_endnetgrent_prototype, [
6575     AC_TRY_COMPILE([#include<netdb.h>
6576                     #ifdef HAVE_NETGROUP_H
6577                     #include<netgroup.h>
6578                     #endif],[endnetgrent()],
6579                     samba_cv_endnetgrent_prototype=yes, samba_cv_endnetgrent_prototype=no)])
6580 if test x"$samba_cv_endnetgrent_prototype" = x"yes"; then
6581     AC_DEFINE(HAVE_ENDNETGRENT_PROTOTYPE, 1, [If endnetgrent prototype is defined])
6584 CFLAGS=$CFLAGS_SAVE
6586 # Checks for the vfs_fileid module
6587 # Start
6588 AC_CHECK_FUNC(getmntent)
6590 AC_CHECK_HEADERS(sys/statfs.h)
6592 AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
6593 AC_CACHE_VAL(vfsfileid_cv_statfs,[
6594              AC_TRY_RUN([
6595                 #include <sys/types.h>
6596                 #include <sys/statfs.h>
6597                 int main(void)
6598                 {
6599                         struct statfs fsd;
6600                         fsid_t fsid = fsd.f_fsid;
6601                         return statfs (".", &fsd);
6602                 }],
6603                 vfsfileid_cv_statfs=yes,
6604                 vfsfileid_cv_statfs=no,
6605                 vfsfileid_cv_statfs=cross)
6607 AC_MSG_RESULT($vfsfileid_cv_statfs)
6609 if test x"$ac_cv_func_getmntent" = x"yes" -a \
6610         x"$vfsfileid_cv_statfs" = x"yes"; then
6611         default_shared_modules="$default_shared_modules vfs_fileid"
6613 # End
6614 # Checks for the vfs_fileid module
6617 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
6619         eval MODULE_DEFAULT_$i=STATIC
6620 done
6622 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
6624         dnl Fall back to static if we cannot build shared libraries
6625         eval MODULE_DEFAULT_$i=STATIC
6627         if test $BLDSHARED = true; then
6628                 eval MODULE_DEFAULT_$i=SHARED
6629         fi
6630 done
6632 dnl Always build these modules static
6633 MODULE_rpc_spoolss=STATIC
6634 MODULE_rpc_srvsvc=STATIC
6635 MODULE_idmap_tdb=STATIC
6636 MODULE_idmap_passdb=STATIC
6637 MODULE_idmap_nss=STATIC
6639 MODULE_nss_info_template=STATIC
6641 AC_ARG_WITH(static-modules,
6642 [AS_HELP_STRING([--with-static-modules=MODULES], [Comma-separated list of names of modules to statically link in])],
6643 [ if test $withval; then
6644         for i in `echo $withval | sed -e 's/,/ /g'`
6645         do
6646                 eval MODULE_$i=STATIC
6647         done
6648 fi ])
6650 AC_ARG_WITH(shared-modules,
6651 [AS_HELP_STRING([--with-shared-modules=MODULES], [Comma-separated list of names of modules to build shared])],
6652 [ if test $withval; then
6653         for i in `echo $withval | sed -e 's/,/ /g'`
6654         do
6655                         eval MODULE_$i=SHARED
6656         done
6657 fi ])
6659 if test x"$MODULE_DEFAULT_vfs_notify_fam" = xSTATIC -o \
6660                 x"$MODULE_vfs_notify_fam" = xSTATIC ; then
6661         SMBD_FAM_LIBS="$SMB_FAM_LIBS"
6662         AC_SUBST(SMBD_FAM_LIBS)
6665 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB,
6666                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
6667 SMB_MODULE(pdb_ads, passdb/pdb_ads.o \$(TLDAP_OBJ), "bin/ads.$SHLIBEXT", PDB)
6668 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
6669 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
6670 SMB_MODULE(pdb_wbc_sam, passdb/pdb_wbc_sam.o, "bin/wbc_sam.$SHLIBEXT", PDB)
6671 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
6674 SMB_MODULE(rpc_lsarpc, \$(RPC_LSARPC_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
6675 SMB_MODULE(rpc_winreg, \$(RPC_WINREG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
6676 SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
6677 SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC)
6678 SMB_MODULE(rpc_wkssvc, \$(RPC_WKSSVC_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
6679 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
6680 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
6681 SMB_MODULE(rpc_netlogon, \$(RPC_NETLOGON_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
6682 SMB_MODULE(rpc_netdfs, \$(RPC_NETDFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
6683 SMB_MODULE(rpc_srvsvc, \$(RPC_SRVSVC_OBJ), "bin/librpc_svcsvc.$SHLIBEXT", RPC)
6684 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
6685 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
6686 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
6687 SMB_MODULE(rpc_rpcecho, \$(RPC_RPCECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
6688 SMB_SUBSYSTEM(RPC,smbd/process.o)
6690 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
6691 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
6692 SMB_MODULE(idmap_tdb2, winbindd/idmap_tdb2.o, "bin/tdb2.$SHLIBEXT", IDMAP)
6693 SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
6694 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
6695 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
6696 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
6697 SMB_MODULE(idmap_hash, \$(IDMAP_HASH_OBJ), "bin/hash.$SHLIBEXT", IDMAP)
6698 SMB_MODULE(idmap_adex, \$(IDMAP_ADEX_OBJ), "bin/adex.$SHLIBEXT", IDMAP)
6699 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
6701 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
6702 SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
6704 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
6705 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
6706 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
6707 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
6708 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
6710 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
6711 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
6712 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
6713 SMB_MODULE(auth_wbc, \$(AUTH_WBC_OBJ), "bin/wbc.$SHLIBEXT", AUTH)
6714 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
6715 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
6716 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
6717 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
6718 SMB_MODULE(auth_netlogond, \$(AUTH_NETLOGOND_OBJ), "bin/netlogond.$SHLIBEXT", AUTH)
6719 SMB_SUBSYSTEM(AUTH,auth/auth.o)
6721 SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
6722 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
6723 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
6724 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
6725 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
6726 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
6727 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
6728 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
6729 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
6730 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
6731 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
6732 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
6733 SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
6734 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
6735 SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
6736 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
6737 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
6738 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
6739 SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
6740 SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
6741 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
6742 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
6743 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
6744 SMB_MODULE(vfs_streams_xattr, \$(VFS_STREAMS_XATTR_OBJ), "bin/streams_xattr.$SHLIBEXT", VFS)
6745 SMB_MODULE(vfs_streams_depot, \$(VFS_STREAMS_DEPOT_OBJ), "bin/streams_depot.$SHLIBEXT", VFS)
6746 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
6747 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
6748 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
6749 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
6750 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
6751 SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
6752 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
6753 SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS)
6754 SMB_MODULE(vfs_preopen, \$(VFS_PREOPEN_OBJ), "bin/preopen.$SHLIBEXT", VFS)
6755 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
6756 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
6757 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
6758 SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS)
6759 SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
6760 SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_traffic_analyzer.$SHLIBEXT", VFS)
6761 SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
6762 SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_copy.$SHLIBEXT", VFS)
6763 SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS)
6764 SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT", VFS)
6765 SMB_MODULE(vfs_crossrename, \$(VFS_CROSSRENAME_OBJ), "bin/crossrename.$SHLIBEXT", VFS)
6766 SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$SHLIBEXT", VFS)
6767 SMB_MODULE(vfs_time_audit, \$(VFS_TIME_AUDIT_OBJ), "bin/time_audit.$SHLIBEXT", VFS)
6769 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
6771 SMB_MODULE(perfcount_onefs, \$(PERFCOUNT_ONEFS), "bin/pc_onefs.$SHLIBEXT", PERFCOUNT)
6772 SMB_MODULE(perfcount_test, \$(PERFCOUNT_TEST), "bin/pc_test.$SHLIBEXT", PERFCOUNT)
6773 SMB_SUBSYSTEM(PERFCOUNT,smbd/perfcount.o)
6775 SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT)
6776 SMB_MODULE(gpext_scripts, libgpo/gpext/scripts.o, "bin/scripts.$SHLIBEXT", GPEXT)
6777 SMB_MODULE(gpext_security, libgpo/gpext/security.o, "bin/security.$SHLIBEXT", GPEXT)
6778 SMB_SUBSYSTEM(GPEXT, libgpo/gpext/gpext.o)
6780 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
6782 #################################################
6783 # do extra things if we are running insure
6785 if test "${ac_cv_prog_CC}" = "insure"; then
6786         CPPFLAGS="$CPPFLAGS -D__INSURE__"
6789 #################################################
6790 # If run from the build farm, enable NASTY hacks
6791 #################################################
6792 AC_MSG_CHECKING(whether to enable build farm hacks)
6793 if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
6794         AC_MSG_RESULT(yes)
6795         AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
6796 else
6797         AC_MSG_RESULT(no)
6800 #################################################
6801 # check for bad librt/libpthread interactions
6803 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
6804     x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
6805     x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6806     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6808 SMB_IF_RTSIGNAL_BUG(
6809         [
6810             # Have RT_SIGNAL bug, need to check whether the problem will
6811             # affect anything we have configured.
6813             rt_do_error=no
6814             if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
6815                 if test x"$rt_signal_lease_ok" = x"no" ; then
6816                     rt_do_error=yes
6817                 fi
6818             fi
6820             if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
6821                 if test x"$rt_signal_notify_ok" = x"no" ; then
6822                     rt_do_error=yes
6823                 fi
6824             fi
6826             if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6827                     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6828                 if test x"$rt_signal_aio_ok" = x"no" ; then
6829                     rt_do_error=yes
6830                 fi
6831             fi
6833             if test x"$rt_do_error" = x"yes" ; then
6834                 SMB_IS_LIBPTHREAD_LINKED(
6835                     [
6836                         cat<<MSG
6838 *** On this platforms, linking Samba against pthreads causes problems
6839 *** with the oplock and change notification mechanisms. You may be
6840 *** using pthreads as a side-effect of using the --with-aio-support
6841 *** or --with-profiling-data options. Please remove these and try again.
6844                     ],
6845                     [
6846                         cat<<MSG
6848 *** On this platform, the oplock and change notification mechanisms do not
6849 *** appear to work. Please report this problem to samba-technical@samba.org
6850 *** and attach the config.log file from this directory.
6853                     ])
6854                 AC_MSG_ERROR(unable to use realtime signals on this platform)
6855             fi
6856         ],
6857         [
6858             # no RT_SIGNAL bug, we are golden
6859             SMB_IS_LIBPTHREAD_LINKED(
6860                 [
6861                     AC_MSG_WARN(using libpthreads - this may degrade performance)
6862                 ])
6864         ],
6865         [
6866             # cross compiling, I hope you know what you are doing
6867             true
6868         ])
6872 AC_ARG_ENABLE(merged-build, 
6873 [AS_HELP_STRING([--enable-merged-build], [Build Samba 4 as well])], 
6874 [ enable_merged_build=$enableval ], [ enable_merged_build=auto ])
6876 if test x"$enable_merged_build" = x"yes" -a \
6877         x"$merged_build_possible" = x"no" ; then
6878         AC_MSG_ERROR(Merged build required but not possible)
6881 m4_include(../lib/zlib/zlib.m4)
6883 if test x$enable_merged_build = xauto; then
6885         AC_MSG_CHECKING([whether it would be possible to do a merged build])
6886         AC_MSG_RESULT([$merged_build_possible])
6888         # Enable merged build automatically if possible, when in developer mode
6889         if test "x$developer" = xyes; then
6890                 enable_merged_build=$merged_build_possible
6891         fi
6894 if test x$enable_merged_build = xyes; then
6895         MERGED_BUILD=1
6896         saved_USESHARED="$USESHARED"
6897         USESHARED="false"
6898         smbtorture4_path="bin/smbtorture4"
6899         smbtorture4_option="-t bin/smbtorture4"
6900         AC_SUBST(smbtorture4_path)
6901         AC_SUBST(smbtorture4_option)
6902         USESHARED="$saved_USESHARED"
6903         SMBTORTURE4="bin/smbtorture4"
6904         AC_SUBST(SMBTORTURE4)
6907 AC_SUBST(ZLIB_LIBS)
6908 AC_SUBST(ZLIB_OBJS)
6909 AC_ZLIB([ZLIB_OBJS=""], [
6910         ZLIB_LIBS=""
6911         for o in adler32.o compress.o crc32.o gzio.o uncompr.o \
6912                      deflate.o trees.o zutil.o inflate.o infback.o \
6913                          inftrees.o inffast.o
6914         do
6915                 ZLIB_OBJS="$ZLIB_OBJS ../lib/zlib/$o"
6916         done
6917         CFLAGS="-I../lib/zlib $CFLAGS"
6920 AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
6922 if test "x$enable_dmalloc" = xyes
6923 then
6924         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
6925         AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
6926                   [Define to check invariants around some common functions])
6927         LIBS="$LIBS -ldmalloc"
6930 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
6931 LIB_REMOVE_USR_LIB(LDFLAGS)
6932 LIB_REMOVE_USR_LIB(LIBS)
6934 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
6935 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
6936 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
6938 #################################################
6939 # Display summary of libraries detected
6941 AC_MSG_RESULT([Using libraries:])
6942 AC_MSG_RESULT([    LIBS = $LIBS])
6943 if test x"$with_ads_support" != x"no"; then
6944     AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
6946 if test x"$with_ldap_support" != x"no"; then
6947     AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
6949 if test x"$with_dnsupdate_support" != x"no"; then
6950     AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
6952 if test x"$have_dnssd_support" != x"no"; then
6953     AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
6955 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
6957 #################################################
6958 # final configure stuff
6960 AC_MSG_CHECKING([configure summary])
6961 AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
6962            AC_MSG_RESULT(yes),
6963            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
6964            AC_MSG_WARN([cannot run when cross-compiling]))
6966 dnl Merge in developer cflags from now on
6967 AC_SUBST(DEVELOPER_CFLAGS)
6968 if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes" -o x"$picky_developer" = x"yes"; then
6969     CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
6972 # Stuff the smbd-only libraries at the end of the smbd link
6973 # path (if we have them).
6974 SMBD_LIBS="$samba_dmapi_libs"
6975 AC_SUBST(SMBD_LIBS)
6977 CFLAGS="${CFLAGS} \$(FLAGS)"
6978 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
6980 # If we had to expand the includes, make tsure the output file is moved back
6981 AC_OUTPUT_COMMANDS([
6982 if test -f Makefile-noincludes -a ! -f Makefile -a ! -h Makefile ; then
6983         ln -s Makefile-noincludes Makefile
6987 AC_OUTPUT(Makefile
6988           script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
6989           lib/netapi/examples/Makefile
6990           lib/netapi/tests/Makefile
6991           pkgconfig/smbclient.pc
6992           pkgconfig/wbclient.pc
6993           pkgconfig/netapi.pc
6994           pkgconfig/smbsharemodes.pc
6995           ../examples/libsmbclient/Makefile.internal
6996           )
6998 #################################################
6999 # Print very concise instructions on building/use
7000 if test "x$enable_dmalloc" = xyes
7001 then
7002         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
7003         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])