s3-smbd: Don't segfault if user specified ports out for range.
[Samba.git] / source3 / configure.in
blobfc1293aa941f74ffe86b61edf6f81141f9cefa9d
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-.}/librpc"
41 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
43 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt"
45 ## cleanup the $(srcdir) in the Makefile if we are outside of the tree
46 if test "x${srcdir-.}" != "x."; then
47         SAMBA_CPPFLAGS=`echo ${SAMBA_CPPFLAGS} | sed -e "s;${srcdir};\$\(srcdir\);g"`
50 dnl Unique-to-Samba variables we'll be playing with.
51 AC_SUBST(SAMBA_CPPFLAGS)
52 AC_SUBST(SHELL)
53 AC_SUBST(LDSHFLAGS)
54 AC_SUBST(SONAMEFLAG)
55 AC_SUBST(SHLD)
56 AC_SUBST(MODULE_EXPORTS)
57 AC_SUBST(DSO_EXPORTS)
58 AC_SUBST(HOST_OS)
59 AC_SUBST(PICFLAG)
60 AC_SUBST(PIE_CFLAGS)
61 AC_SUBST(PIE_LDFLAGS)
62 AC_SUBST(RELRO_LDFLAGS)
63 AC_SUBST(SHLIBEXT)
64 AC_SUBST(INSTALLLIBCMD_SH)
65 AC_SUBST(INSTALLLIBCMD_A)
66 AC_SUBST(UNINSTALLLIBCMD_SH)
67 AC_SUBST(UNINSTALLLIBCMD_A)
69 AC_SUBST(INSTALL_LIBWBCLIENT)
70 AC_SUBST(UNINSTALL_LIBWBCLIENT)
71 AC_SUBST(LIBWBCLIENT_SHARED_TARGET)
72 AC_SUBST(LIBWBCLIENT_SHARED_TARGET_SOVER)
73 AC_SUBST(LIBWBCLIENT_SHARED_TARGET_FULLVER)
74 AC_SUBST(LIBWBCLIENT_SHARED)
75 AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
76 AC_SUBST(LIBWBCLIENT_STATIC)
77 AC_SUBST(LIBWBCLIENT_SOVER)
78 AC_SUBST(LIBWBCLIENT_FULLVER)
79 AC_SUBST(LIBWBCLIENT)
80 AC_SUBST(LIBWBCLIENT_LIBS)
82 AC_SUBST(LIBSAMBAUTIL_SHARED)
84 AC_SUBST(PRINT_LIBS)
85 AC_SUBST(AUTH_LIBS)
86 AC_SUBST(ACL_LIBS)
87 AC_SUBST(PASSDB_LIBS)
88 AC_SUBST(IDMAP_LIBS)
89 AC_SUBST(KRB5_LIBS)
90 AC_SUBST(UUID_LIBS)
91 AC_SUBST(LDAP_LIBS)
92 AC_SUBST(GPEXT_LIBS)
93 AC_SUBST(PAM_MODULES)
94 AC_SUBST(INSTALL_PAM_MODULES)
95 AC_SUBST(UNINSTALL_PAM_MODULES)
96 AC_SUBST(NSS_MODULES)
97 AC_SUBST(EXTRA_BIN_PROGS)
98 AC_SUBST(CIFSMOUNT_PROGS)
99 AC_SUBST(INSTALL_CIFSMOUNT)
100 AC_SUBST(UNINSTALL_CIFSMOUNT)
101 AC_SUBST(CIFSUMOUNT_PROGS)
102 AC_SUBST(INSTALL_CIFSUMOUNT)
103 AC_SUBST(UNINSTALL_CIFSUMOUNT)
104 AC_SUBST(CIFSUPCALL_PROGS)
105 AC_SUBST(INSTALL_CIFSUPCALL)
106 AC_SUBST(UNINSTALL_CIFSUPCALL)
107 AC_SUBST(EXTRA_SBIN_PROGS)
108 AC_SUBST(EXTRA_ALL_TARGETS)
109 AC_SUBST(CONFIG_LIBS)
110 AC_SUBST(NSCD_LIBS)
112 # compile with optimization and without debugging by default, but
113 # allow people to set their own preference.
114 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
115 # if it has no value.  This prevent *very* large debug binaries from occurring
116 # by default.
117 if test "x$debug" = "xyes" ; then
118         CFLAGS="${CFLAGS} -g"
120 if test "x$CFLAGS" = x; then
121   CFLAGS="-O"
124 m4_include(../lib/socket_wrapper/config.m4)
125 m4_include(../lib/nss_wrapper/config.m4)
127 m4_include(m4/swat.m4)
129 DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
131 # Probe the gcc version for extra CFLAGS. We always stash these in
132 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
133 # Makefile edit, avoiding the need to re-run configure.
134 if test x"$ac_cv_prog_gcc" = x"yes" ; then
135         DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings"
136         # Add -Wdeclaration-after-statement if compiler supports it
137         AC_CACHE_CHECK(
138           [that the C compiler understands -Wdeclaration-after-statement],
139           samba_cv_HAVE_Wdeclaration_after_statement, [
140           AC_TRY_RUN_STRICT([
141             int main(void)
142             {
143                 return 0;
144             }],[$CFLAGS -Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
145             samba_cv_HAVE_Wdeclaration_after_statement=yes,
146             samba_cv_HAVE_Wdeclaration_after_statement=no,
147             samba_cv_HAVE_Wdeclaration_after_statement=cross)
148        ])
150         if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
151             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
152         fi
154         #-Werror-implicit-function-declaration
155         AC_CACHE_CHECK(
156           [that the C compiler understands -Werror-implicit-function-declaration],
157           samba_cv_HAVE_Werror_implicit_function_declaration, [
158           AC_TRY_RUN_STRICT([
159             int main(void)
160             {
161                 return 0;
162             }],[$CFLAGS -Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
163             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
164             samba_cv_HAVE_Werror_implicit_function_declaration=no,
165             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
166        ])
167        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
168             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
169        fi
171         # krb5developer is like developer, except we don't get
172         # -Wstrict-prototypes.
173        if test x"$krb5_developer" != x"$yes" ; then
174             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
175        fi
177        if test x"$picky_developer" = x"yes"; then
178             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Werror"
179        fi
182 #################################################
183 # check for a shared memory profiling support
184 AC_MSG_CHECKING(whether to use profiling)
185 AC_ARG_WITH(profiling-data,
186 [AS_HELP_STRING([--with-profiling-data], [Include gathering source code profile information (default=no)])],
187 [ case "$withval" in
188   yes)
189     AC_MSG_RESULT(yes)
190     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
191     samba_cv_WITH_PROFILE=yes
192     ;;
193   *)
194     AC_MSG_RESULT(no)
195     samba_cv_WITH_PROFILE=no
196     ;;
197   esac ],
198   AC_MSG_RESULT(no)
201 dnl Checks for programs.
202 AC_ARG_ENABLE(smbtorture4,
203         [AS_HELP_STRING([--enable-smbtorture4], [Enable building smbtorture4 (default=auto)])])
205 if test x$enable_smbtorture4 != xno; then
206         smbtorture4_possible=yes
207 else
208         smbtorture4_possible=no
211 AC_PROG_INSTALL
212 AC_PROG_AWK
213 # Check for GNU make
214 m4_include(../m4/check_make.m4)
215 AC_SAMBA_GNU_MAKE([true], [true])
217 # Check for perl
218 m4_include(../m4/check_perl.m4)
219 AC_SAMBA_PERL([true], [smbtorture4_possible=no])
221 # Check for python
222 m4_include(../m4/check_python.m4)
223 AC_SAMBA_PYTHON_DEVEL([true], [smbtorture4_possible=no])
225 AC_CHECK_TOOL(AR, ar)
227 dnl Check if we (actually our C compiler!) use GNU ld
228 AC_PROG_LD_GNU
230 dnl Certain versions of GNU ld the default is not to have the
231 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
232 dnl warnings when building modules.
233 if test "$ac_cv_prog_gnu_ld" = "yes"; then
234         ac_cv_gnu_ld_version=`$CC -Wl,-v /dev/null 2>&1 < /dev/null | grep "GNU ld"`
235         AC_MSG_CHECKING(GNU ld release date)
236         changequote(,)dnl
237         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'`
238         changequote([,])dnl
239         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
240         if test -n "$ac_cv_gnu_ld_date"; then
241         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
242                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
243         fi
244         if test "$ac_cv_gnu_ld_date" -gt 20030101; then
245                 ac_cv_gnu_ld_version_script=yes
246         fi
247         else
248            AC_MSG_CHECKING(GNU ld release version)
249            changequote(,)dnl
250            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'`
251            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
252            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
253            changequote([,])dnl
254            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
255            AC_MSG_CHECKING(GNU ld release version major)
256            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
257            AC_MSG_CHECKING(GNU ld release version minor)
258            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
259            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
260              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
261            fi
262            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
263              ac_cv_gnu_ld_version_script=yes
264            fi
265         fi
268 dnl look for executable suffix
269 AC_EXEEXT
271 dnl Check if C compiler understands -c and -o at the same time
272 AC_PROG_CC_C_O
273 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
274       BROKEN_CC=
275 else
276       BROKEN_CC=#
278 AC_SUBST(BROKEN_CC)
280 dnl Check if the C compiler understands -Werror (GNU)
281 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
282  AC_TRY_RUN_STRICT([
283   int main(void)
284   {
285         return 0;
286   }],[$CFLAGS -Werror],[$CPPFLAGS],[$LDFLAGS],
287   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
288 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
289    Werror_FLAGS="-Werror"
290 else
291 dnl Check if the C compiler understands -w2
292 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
293  AC_TRY_RUN_STRICT([
294   int main(void)
295   {
296         return 0;
297   }],[$CFLAGS -w2],[$CPPFLAGS],[$LDFLAGS],
298   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
299 if test x"$samba_cv_HAVE_w2" = x"yes"; then
300    Werror_FLAGS="-w2"
301 else
302 dnl Check if the C compiler understands -errwarn (Sun)
303 AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
304   AC_TRY_RUN_STRICT([
305    int main(void)
306    {
307         return 0;
308    }],[$CFLAGS -errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
309    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
310 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
311    Werror_FLAGS="-errwarn=%all"
312 else
313 dnl Check if the C compiler understands -qhalt (IBM)
314 AC_CACHE_CHECK([that the C compiler understands -qhalt],samba_cv_HAVE_qhalt, [
315   AC_TRY_RUN_STRICT([
316    int main(void)
317    {
318         return 0;
319    }],[$CFLAGS -qhalt=w],[$CPPFLAGS],[$LDFLAGS],
320    samba_cv_HAVE_qhalt=yes,samba_cv_HAVE_qhalt=no,samba_cv_HAVE_qhalt=cross)])
321 if test x"$samba_cv_HAVE_qhalt" = x"yes"; then
322    Werror_FLAGS="-qhalt=w"
328 ############################################
329 # check if the compiler can handle negative enum values
330 # and don't truncate the values to INT_MAX
331 # a runtime test is needed here
332 AC_SUBST(PIDL_ARGS)
333 AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
334     AC_TRY_RUN(
336         #include <stdio.h>
337         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
338         int main(void) {
339                 enum negative_values v1 = NEGATIVE_VALUE;
340                 unsigned v2 = NEGATIVE_VALUE;
342                 if (v1 != 0xFFFFFFFF) {
343                         printf("%u != 0xFFFFFFFF\n", v1);
344                         return 1;
345                 }
346                 if (v2 != 0xFFFFFFFF) {
347                         printf("%u != 0xFFFFFFFF\n", v2);
348                         return 1;
349                 }
351                 return 0;
352         }
354         samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv_CC_NEGATIVE_ENUM_VALUES=no)])
355 if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
356         AC_MSG_WARN([using --uint-enums for pidl])
357         PIDL_ARGS="$PIDL_ARGS --uint-enums"
360 dnl Figure out the flags to support named structure initializers
362 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
364 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
365 AC_MSG_CHECKING(uname -s)
366 AC_MSG_RESULT(${UNAME_S})
368 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
369 AC_MSG_CHECKING(uname -r)
370 AC_MSG_RESULT(${UNAME_R})
372 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
373 AC_MSG_CHECKING(uname -m)
374 AC_MSG_RESULT(${UNAME_M})
376 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
377 AC_MSG_CHECKING(uname -p)
378 AC_MSG_RESULT(${UNAME_P})
380 UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
381 AC_MSG_CHECKING(uname -i)
382 AC_MSG_RESULT(${UNAME_I})
384 dnl Add #include for broken IRIX header files
385   case "$host_os" in
386         *irix6*)
387                 #TODO add to libreplace
388                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
389                         dnl Fix sensible defaults for MIPSPro compilers. The
390                         dnl error numbers are valid for the 7.3 compilers,
391                         dnl hopefully also valid for the 7.4 series.
392                         dnl
393                         dnl Bugzilla 3801. Force an error on warning 1035
394                         dnl so we don't incorrectly detect stdint.h. This
395                         dnl warning is emitted for #error directives.
396                         CFLAGS="$CFLAGS -diag_error 1035"
397                         dnl 1209: Controlling expression is constant
398                         dnl 1174: Function foo declared but never referenced
399                         dnl 3201: Parameter foo was never referenced
400                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
401                 fi
402         ;;
403 esac
405 DYNEXP=
406 AC_SUBST(DYNEXP)
407 LDSHFLAGS_Z_DEFS=
408 AC_SUBST(LDSHFLAGS_Z_DEFS)
409 LDSHFLAGS_Z_NODEFS=
410 AC_SUBST(LDSHFLAGS_Z_NODEFS)
412 dnl Add modules that have to be built by default here
413 dnl These have to be built static:
414 default_static_modules=""
415 default_static_modules="$default_static_modules pdb_smbpasswd"
416 default_static_modules="$default_static_modules pdb_tdbsam"
417 default_static_modules="$default_static_modules pdb_wbc_sam"
418 default_static_modules="$default_static_modules rpc_lsarpc"
419 default_static_modules="$default_static_modules rpc_samr"
420 default_static_modules="$default_static_modules rpc_winreg"
421 default_static_modules="$default_static_modules rpc_initshutdown"
422 default_static_modules="$default_static_modules rpc_dssetup"
423 default_static_modules="$default_static_modules rpc_wkssvc"
424 default_static_modules="$default_static_modules rpc_svcctl"
425 default_static_modules="$default_static_modules rpc_ntsvcs"
426 default_static_modules="$default_static_modules rpc_netlogon"
427 default_static_modules="$default_static_modules rpc_netdfs"
428 default_static_modules="$default_static_modules rpc_srvsvc"
429 default_static_modules="$default_static_modules rpc_spoolss"
430 default_static_modules="$default_static_modules rpc_eventlog"
431 default_static_modules="$default_static_modules auth_sam"
432 default_static_modules="$default_static_modules auth_unix"
433 default_static_modules="$default_static_modules auth_winbind"
434 default_static_modules="$default_static_modules auth_wbc"
435 default_static_modules="$default_static_modules auth_server"
436 default_static_modules="$default_static_modules auth_domain"
437 default_static_modules="$default_static_modules auth_builtin"
438 default_static_modules="$default_static_modules vfs_default"
439 default_static_modules="$default_static_modules nss_info_template"
441 dnl These are preferably build shared, and static if dlopen() is not available
442 default_shared_modules=""
443 default_shared_modules="$default_shared_modules vfs_recycle"
444 default_shared_modules="$default_shared_modules vfs_audit"
445 default_shared_modules="$default_shared_modules vfs_extd_audit"
446 default_shared_modules="$default_shared_modules vfs_full_audit"
447 default_shared_modules="$default_shared_modules vfs_netatalk"
448 default_shared_modules="$default_shared_modules vfs_fake_perms"
449 default_shared_modules="$default_shared_modules vfs_default_quota"
450 default_shared_modules="$default_shared_modules vfs_readonly"
451 default_shared_modules="$default_shared_modules vfs_cap"
452 default_shared_modules="$default_shared_modules vfs_expand_msdfs"
453 default_shared_modules="$default_shared_modules vfs_shadow_copy"
454 default_shared_modules="$default_shared_modules vfs_shadow_copy2"
455 default_shared_modules="$default_shared_modules charset_CP850"
456 default_shared_modules="$default_shared_modules charset_CP437"
457 default_shared_modules="$default_shared_modules auth_script"
458 default_shared_modules="$default_shared_modules vfs_readahead"
459 default_shared_modules="$default_shared_modules vfs_xattr_tdb"
460 default_shared_modules="$default_shared_modules vfs_streams_xattr"
461 default_shared_modules="$default_shared_modules vfs_streams_depot"
462 default_shared_modules="$default_shared_modules vfs_acl_xattr"
463 default_shared_modules="$default_shared_modules vfs_acl_tdb"
464 default_shared_modules="$default_shared_modules vfs_smb_traffic_analyzer"
465 default_shared_modules="$default_shared_modules vfs_preopen"
466 default_shared_modules="$default_shared_modules vfs_catia"
467 default_shared_modules="$default_shared_modules vfs_scannedonly"
468 default_shared_modules="$default_shared_modules vfs_crossrename"
469 default_shared_modules="$default_shared_modules vfs_linux_xfs_sgid"
470 default_shared_modules="$default_shared_modules vfs_time_audit"
471 default_shared_modules="$default_shared_modules idmap_autorid"
473 if test "x$developer" = xyes; then
474    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
475    default_static_modules="$default_static_modules auth_netlogond"
476    default_shared_modules="$default_shared_modules charset_weird perfcount_test"
480 # Config CPPFLAG settings for strange OS's that must be set
481 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
482 # case statement; its first reference must be unconditional.
484 case "$host_os" in
485     *hpux*)
487 # Defines needed for HPUX support.
488 # HPUX has bigcrypt but (sometimes?) doesn't use it for
489 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
491       case `uname -r` in
492                 *9*|*10*|*11)
493                         AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
494                 ;;
495       esac
496       ;;
499 # CRAY Unicos has broken const handling
500        *unicos*)
501           AC_MSG_RESULT([disabling const])
502           CPPFLAGS="$CPPFLAGS -Dconst="
503           ;;
504         
506 # AIX4.x doesn't even admit to having large
507 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
509     *aix4*)
510           AC_MSG_RESULT([enabling large file support])
511       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
512           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
513       ;;
515 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
516 # to the existance of large files..
517 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
518 # recommendations on large file support, however it makes the
519 # compile work using gcc 2.7 and 2.8, whereas using the Sun
520 # recommendation makes the compile fail on gcc2.7. JRA.
522 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
524         *solaris*)
525                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
526                 case `uname -r` in
527                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
528                                 AC_MSG_RESULT([no large file support])
529                                 ;;
530                         5.*)
531                         LDFLAGS="$LDFLAGS -lthread"
532                         CPPFLAGS="$CPPFLAGS -D_REENTRANT"
533                         AC_MSG_RESULT([enabling large file support])
534                         if test "$ac_cv_prog_gcc" = yes; then
535                                 ${CC-cc} -v >conftest.c 2>&1
536                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
537                                 rm -fr conftest.c
538                                 case "$ac_cv_gcc_compiler_version_number" in
539                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
540                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
541                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
542                                                 ;;
543                                         *)
544                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
545                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
546                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
547                                                 ;;
548                                 esac
549                         else
550                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
551                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
552                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
553                         fi
554                         ;;
555                 esac
556                 ;;
558 # IRIX uses SYSV printing.  Make sure to set that here
560         *irix*)
561                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
562                 ;;
563         *freebsd*|*dragonfly*)
564                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
565                 ;;
567 # VOS may need to have POSIX support and System V compatibility enabled.
569     *vos*)
570     case "$CPPFLAGS" in
571           *-D_POSIX_C_SOURCE*)
572                 ;;
573           *)
574                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
575                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
576                 ;;
577     esac
578     case "$CPPFLAGS" in
579           *-D_SYSV*|*-D_SVID_SOURCE*)
580                 ;;
581           *)
582                 CPPFLAGS="$CPPFLAGS -D_SYSV"
583                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
584     esac
585     ;;
587 # Tests needed for SINIX large file support.
589     *sysv4*)
590       if test $host = mips-sni-sysv4 ; then
591         AC_MSG_CHECKING([for LFS support])
592         old_CPPFLAGS="$CPPFLAGS"
593         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
594         AC_TRY_RUN([
595 #include <unistd.h>
596 main () {
597 #if _LFS64_LARGEFILE == 1
598 exit(0);
599 #else
600 exit(1);
601 #endif
602 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
603         CPPFLAGS="$old_CPPFLAGS"
604         if test x$SINIX_LFS_SUPPORT = xyes ; then
605           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
606                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
607           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
608           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
609           LIBS="`getconf LFS64_LIBS` $LIBS"
610         fi
611       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
612       fi
613     ;;
615 # Systems with LFS support.
617     gnu* | k*bsd*-gnu | kopensolaris*-gnu)
618         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
619         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
620         AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
621         AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
622         ;;
624 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
626     *linux*)
627         AC_MSG_CHECKING([for LFS support])
628         old_CPPFLAGS="$CPPFLAGS"
629         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
630        AC_TRY_RUN([
631 #include <unistd.h>
632 #include <sys/utsname.h>
633 #include <string.h>
634 #include <stdlib.h>
635 main() {
636 #if _LFS64_LARGEFILE == 1
637        struct utsname uts;
638        char *release;
639        int major, minor;
641        /* Ensure this is glibc 2.2 or higher */
642 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
643        int libc_major = __GLIBC__;
644        int libc_minor = __GLIBC_MINOR__;
646        if (libc_major < 2)
647               exit(1);
648        if (libc_minor < 2)
649               exit(1);
650 #endif
652        /* Ensure this is kernel 2.4 or higher */
654        uname(&uts);
655        release = strdup(uts.release);
656        major = atoi(strsep(&release, "."));
657        minor = atoi(strsep(&release, "."));
659        if (major > 2 || (major == 2 && minor > 3))
660                exit(0);
661        exit(1);
662 #else
663        exit(1);
664 #endif
666 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
667         CPPFLAGS="$old_CPPFLAGS"
668         if test x$LINUX_LFS_SUPPORT = xyes ; then
669                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
670                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
671                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
672                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
673         fi
674         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
675         ;;
678 # MacOS X is the *only* system that uses compose character in utf8. This
679 # is so horribly broken....
681     *darwin*)
682         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
684 # Add a system specific charset module.
685         default_shared_modules="$default_shared_modules charset_macosxfs"
687         ;;
688     *hurd*)
689         AC_MSG_CHECKING([for LFS support])
690         old_CPPFLAGS="$CPPFLAGS"
691         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
692         AC_TRY_RUN([
693 #include <unistd.h>
694 main () {
695 #if _LFS64_LARGEFILE == 1
696 exit(0);
697 #else
698 exit(1);
699 #endif
700 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
701         CPPFLAGS="$old_CPPFLAGS"
702         if test x$GLIBC_LFS_SUPPORT = xyes ; then
703           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
704                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
705           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
706         fi
707       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
708     ;;
709     *qnx*)
710         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
711         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
712         ;;
714 esac
716 SAVE_CPPFLAGS="${CPPFLAGS}"
717 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
719 AC_LIBREPLACE_BROKEN_CHECKS
720 AC_CHECK_FUNCS([syslog],[],[AC_MSG_ERROR([Required function not found])])
721 AC_LIBREPLACE_NETWORK_CHECKS
723 CPPFLAGS="${SAVE_CPPFLAGS}"
725 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
727 LIBREPLACE_OBJS="${LIBREPLACEOBJ}"
728 AC_SUBST(LIBREPLACE_OBJS)
730 LIBREPLACE_LIBS="${LIBREPLACE_NETWORK_LIBS}"
731 AC_SUBST(LIBREPLACE_LIBS)
734 # add -ldl to the global LIBS
735 LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}"
736 AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
739 AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
740 AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h)
741 AC_CHECK_HEADERS(limits.h float.h libintl.h)
742 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
743 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)
744 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
745 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
746 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h)
747 AC_CHECK_HEADERS(sys/sysmacros.h)
748 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
749 AC_CHECK_HEADERS(langinfo.h locale.h)
750 AC_CHECK_HEADERS(xfs/libxfs.h)
751 AC_CHECK_HEADERS(netgroup.h)
752 AC_CHECK_HEADERS(linux/falloc.h)
754 dnl check for OS implementation of md5 conformant to rfc1321
755 AC_CHECK_HEADERS(md5.h)
757 samba_cv_md5lib=none
759 if test x"$ac_cv_header_md5_h" = x"yes"; then
760         AC_DEFINE(HAVE_MD5_H, 1,
761                 [Whether md5.h is available.])
762         AC_CHECK_LIB(md5, MD5Update, [samba_cv_md5lib=md5])
765 if test x"$ac_cv_header_md5_h" = x"yes" -a \
766         x"$samba_cv_md5lib" = x"none" ; then
767         AC_CHECK_LIB(md, MD5Update, [samba_cv_md5lib=md])
770 if test x"$ac_cv_header_md5_h" = x"yes" -a \
771         x"$samba_cv_md5lib" = x"none" ; then
772         AC_CHECK_LIB(c, MD5Update, [samba_cv_md5lib=""])
775 if test x"$samba_cv_md5lib" != x"none" ; then
776         if test x"$samba_cv_md5lib" != x ; then
777                 LIBS="${LIBS} -l${samba_cv_md5lib}"
778         fi
779         CRYPTO_MD5_OBJ=
780         AC_DEFINE(HAVE_LIBMD5, 1,
781             [Whether libmd5 conformant to rfc1321 is available.])
782 else
783         CRYPTO_MD5_OBJ="../lib/crypto/md5.o"
786 AC_SUBST(CRYPTO_MD5_OBJ)
789 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
790 #if HAVE_RPC_RPC_H
791 #include <rpc/rpc.h>
792 #endif
795 ## These fail to compile on IRIX so just check for their presence
796 AC_CHECK_HEADERS(sys/mode.h,,,)
798 # Look for Darwin headers
799 old_CPPFLAGS="$CPPFLAGS"
800 CPPFLAGS="-Iinclude $CPPFLAGS"
801 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
802 CPPFLAGS="$old_CPPFLAGS"
804 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
805 # subdirectory of headers.
806 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
808 if test x"$enable_developer" = x"yes" ; then
809    if test x"$ac_cv_header_valgrind_h" = xyes -o \
810            x"$ac_cv_header_valgrind_valgrind_h" = xyes ; then
811       AC_DEFINE(VALGRIND,1,[Whether we have valgrind headers])
812    fi
816 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
817 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
819 case "$host_os" in
820     *hpux*)
821                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
822                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
823                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
824                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
825                 fi
826         ;;
827 esac
828 AC_CHECK_HEADERS(shadow.h)
829 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
830 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
832 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
833 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
835 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
837 # For experimental utmp support (lastlog on some BSD-like systems)
838 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
840 AC_CHECK_SIZEOF(int,cross)
841 AC_CHECK_SIZEOF(long,cross)
842 AC_CHECK_SIZEOF(long long,cross)
843 AC_CHECK_SIZEOF(short,cross)
845 AC_C_CONST
846 AC_C_INLINE
847 AC_C_BIGENDIAN
848 AC_C_CHAR_UNSIGNED
850 AC_TYPE_SIGNAL
851 AC_TYPE_UID_T
852 AC_TYPE_MODE_T
853 AC_TYPE_OFF_T
854 AC_TYPE_SIZE_T
855 AC_TYPE_PID_T
856 AC_STRUCT_ST_RDEV
857 AC_DIRENT_D_OFF
858 AC_CHECK_TYPE(ssize_t, int)
859 AC_CHECK_TYPE(wchar_t, unsigned short)
861 ############################################
862 # for cups support we need libcups, and a handful of header files
864 AC_ARG_ENABLE(cups,
865 [AS_HELP_STRING([--enable-cups], [Turn on CUPS support (default=auto)])])
867 if test x$enable_cups != xno; then
868         AC_PATH_PROG(CUPS_CONFIG, cups-config)
870         if test "x$CUPS_CONFIG" != x; then
872                 ac_save_LDFLAGS=$LDFLAGS
873                 ac_save_PRINT_LIBS=$PRINT_LIBS
874                 AC_CHECK_HEADERS(cups/cups.h cups/language.h)
876                 if test x"$ac_cv_header_cups_cups_h" = xyes -a \
877                         x"$ac_cv_header_cups_language_h" = xyes; then
878                         # try linking with -lcups alone first. That should work unless libcups is
879                         # underlinked. With cups-config --libs we pull in unwanted and unneeded
880                         # dendencies including thread libraries - use cups-config only if really
881                         # required. 
882                         AC_CHECK_LIB_EXT(cups, ac_save_PRINT_LIBS , httpConnect,
883                                 [PRINT_LIBS="$ac_save_PRINT_LIBS -lcups"],
884                                 [AC_MSG_WARN([your cups library doesn't link with -lcups alone, it might be underlinked.]) ;
885                                  PRINT_LIBS="$ac_save_PRINT_LIBS `$CUPS_CONFIG --libs`"])
887                         AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
888                         samba_cv_HAVE_CUPS=yes
889                         AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
890                 else
891                         AC_MSG_WARN([cups-config around but cups-devel not installed])
892                         CFLAGS=$ac_save_CFLAGS
893                         LDFLAGS=$ac_save_LDFLAGS
894                         PRINT_LIBS=$ac_save_PRINT_LIBS
895                 fi
897         elif test x"$enable_cups" = x"yes"; then
898                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
899         fi
902 AC_ARG_ENABLE(iprint,
903 [AS_HELP_STRING([--enable-iprint], [Turn on iPrint support (default=yes if cups is yes)])])
905 if test x$enable_iprint != xno; then
906         if test x"$samba_cv_HAVE_CUPS" = xyes; then
907                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
908         elif test x"$enable_iprint" = x"yes"; then
909                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
910         fi
913 ############################################
914 # check if the compiler will optimize out function calls
915 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
916     AC_TRY_LINK([
917 #include <stdio.h>],
919                 if (0) {
920                    this_function_does_not_exist();
921                 } else {
922                   return 1;
923                 }
926         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
927 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
928    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
931 #############################################
932 # check for fd passing struct via msg_control
933 AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [
934     AC_TRY_COMPILE([
935 #include <sys/types.h>
936 #include <stdlib.h>
937 #include <stddef.h>
938 #include <sys/socket.h>
939 #include <sys/un.h>],
941         struct msghdr msg;
942         union {
943               struct cmsghdr cm;
944               char control[CMSG_SPACE(sizeof(int))];
945         } control_un;
946         msg.msg_control = control_un.control;
947         msg.msg_controllen = sizeof(control_un.control);
949         samba_cv_msghdr_msg_control=yes,samba_cv_msghdr_msg_control=no)])
950 if test x"$samba_cv_msghdr_msg_control" = x"yes"; then
951    AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1,
952              [If we can use msg_control for passing file descriptors])
955 #############################################
956 # check for fd passing struct via msg_acctrights
957 AC_CACHE_CHECK([for fd passing via msg_acctrights],
958                 samba_cv_msghdr_msg_acctrights, [
959     AC_TRY_COMPILE([
960 #include <sys/types.h>
961 #include <stdlib.h>
962 #include <stddef.h>
963 #include <sys/socket.h>
964 #include <sys/un.h>],
966         struct msghdr msg;
967         int fd;
968         msg.msg_acctrights = (caddr_t) &fd;
969         msg.msg_acctrightslen = sizeof(fd);
971         samba_cv_msghdr_msg_acctrights=yes,samba_cv_msghdr_msg_acctrights=no)])
972 if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then
973    AC_DEFINE(HAVE_MSGHDR_MSG_ACCTRIGHTS,1,
974              [If we can use msg_acctrights for passing file descriptors])
977 AC_CHECK_FUNCS(dirfd)
978 if test x"$ac_cv_func_dirfd" = x"yes"; then
979         default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort"
982 AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [
983     AC_TRY_COMPILE([
984 #include <sys/types.h>
985 #if STDC_HEADERS
986 #include <stdlib.h>
987 #include <stddef.h>
988 #endif
989 #include <signal.h>],[struct sigevent s;],
990         samba_cv_struct_sigevent=yes,samba_cv_struct_sigevent=no)])
991 if test x"$samba_cv_struct_sigevent" = x"yes"; then
992    AC_DEFINE(HAVE_STRUCT_SIGEVENT,1,[Whether we have the struct sigevent])
993    AC_CHECK_MEMBERS([struct sigevent.sigev_value.sival_ptr,struct sigevent.sigev_value.sigval_ptr], , ,
994         [#include <signal.h>])
997 # and glibc has setresuid under linux but the function does
998 # nothing until kernel 2.1.44! very dumb.
999 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
1000     AC_TRY_RUN([#include <errno.h>
1001 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
1002         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
1003 if test x"$samba_cv_have_setresuid" = x"yes"; then
1004     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
1007 # Do the same check for setresguid...
1009 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
1010     AC_TRY_RUN([#include <unistd.h>
1011 #include <errno.h>
1012 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
1013         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
1014 if test x"$samba_cv_have_setresgid" = x"yes"; then
1015     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
1018 AC_FUNC_MEMCMP
1020 ###############################################
1021 # Readline included by default unless explicitly asked not to
1022 test "${with_readline+set}" != "set" && with_readline=yes
1024 # test for where we get readline() from
1025 AC_MSG_CHECKING(whether to use readline)
1026 AC_ARG_WITH(readline,
1027 [AS_HELP_STRING([--with-readline[=DIR]], [Look for readline include/libs in DIR (default=auto)])],
1028 [  case "$with_readline" in
1029   yes)
1030     AC_MSG_RESULT(yes)
1032     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1033     AC_CHECK_HEADERS(readline/history.h)
1035     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1036       for termlib in ncurses curses termcap terminfo termlib tinfo; do
1037        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1038       done
1039       AC_CHECK_LIB(readline, rl_callback_handler_install,
1040        [TERMLIBS="-lreadline $TERMLIBS"
1041        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1042        break], [TERMLIBS=], $TERMLIBS)])
1043     ;;
1044   no)
1045     AC_MSG_RESULT(no)
1046     ;;
1047   *)
1048     AC_MSG_RESULT(yes)
1050     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1051     # alternate readline path
1052     _ldflags=${LDFLAGS}
1053     _cppflags=${CPPFLAGS}
1055     # Add additional search path
1056     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1057     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1059     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1060     AC_CHECK_HEADERS(readline/history.h)
1062     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1063       for termlib in ncurses curses termcap terminfo termlib; do
1064        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1065       done
1066       AC_CHECK_LIB(readline, rl_callback_handler_install,
1067        [TERMLDFLAGS="-L$with_readline/lib"
1068        TERMCPPFLAGS="-I$with_readline/include"
1069        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1070        TERMLIBS="-lreadline $TERMLIBS"
1071        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1072        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1074     LDFLAGS=$_ldflags
1075     ;;
1076   esac],
1077   AC_MSG_RESULT(no)
1079 AC_SUBST(TERMLIBS)
1080 AC_SUBST(TERMLDFLAGS)
1082 # The readline API changed slightly from readline3 to readline4, so
1083 # code will generate warnings on one of them unless we have a few
1084 # special cases.
1085 AC_CHECK_LIB(readline, rl_completion_matches,
1086              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
1087                         [Do we have rl_completion_matches?])],
1088              [],
1089              [$TERMLIBS])
1091 # not all readline libs have rl_event_hook or history_list
1092 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
1093 AC_CHECK_LIB(readline, history_list,
1094              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
1095              [],
1096              [$TERMLIBS])
1098 ###############################################
1099 # test for where we get yp_get_default_domain() from
1100 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1101 AC_CHECK_FUNCS(yp_get_default_domain)
1103 # Check if we have execl, if not we need to compile smbrun.
1104 AC_CHECK_FUNCS(execl)
1105 if test x"$ac_cv_func_execl" = x"no"; then
1106     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1109 AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64)
1110 AC_CHECK_FUNCS(strtol)
1111 AC_CHECK_FUNCS(strchr chflags)
1112 AC_CHECK_FUNCS(getrlimit fsync setpgid)
1113 AC_CHECK_FUNCS(fdatasync,,[AC_CHECK_LIB_EXT(rt, LIBS, fdatasync)])
1114 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
1115 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1116 AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf)
1117 AC_CHECK_FUNCS(getgrset)
1118 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
1119 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
1120 AC_CHECK_FUNCS(fallocate fallocate64)
1121 AC_CHECK_FUNCS(fseeko fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
1122 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1123 AC_CHECK_FUNCS(fdopendir fdopendir64)
1124 AC_CHECK_FUNCS(getpwent_r)
1125 AC_CHECK_FUNCS(getdents64)
1126 AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
1127 AC_CHECK_FUNCS(syslog vsyslog timegm)
1128 AC_CHECK_FUNCS(setlocale nl_langinfo)
1129 AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
1130 AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
1131 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1132 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
1133 AC_CHECK_HEADERS(sys/mman.h)
1134 # setbuffer, shmget, shm_open are needed for smbtorture
1135 AC_CHECK_FUNCS(shmget shm_open)
1136 AC_CHECK_FUNCS(gettext dgettext)
1137 AC_CHECK_FUNCS(bindtextdomain textdomain)
1138 AC_CHECK_FUNCS(strupr)
1140 # Find a method of generating a stack trace
1141 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1142 # libexecinfo provides backtrace_symbols on FreeBSD
1143 AC_SEARCH_LIBS(backtrace_symbols, [execinfo])
1144 AC_CHECK_FUNCS(backtrace_symbols)
1145 AC_CHECK_LIB(exc, trace_back_stack)
1147 # check for sysctlbyname for BSD systems
1148 AC_CHECK_FUNCS(sysctlbyname)
1150 #################################################
1151 # Check to see if core dump directory is defined in linux
1152 # with /proc/sys/kernel/core_pattern
1154 AC_CHECK_FILE([/proc/sys/kernel/core_pattern],
1155         AC_DEFINE(HAVE_SYS_KERNEL_PROC_CORE_PATTERN, 1,
1156         [Whether Linux kernel uses core_pattern for core files]),
1157          [])
1159 #############################
1160 # check if building with gpfs
1161 AC_CHECK_HEADERS(gpfs_gpl.h)
1162 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
1163     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
1164     default_shared_modules="$default_shared_modules vfs_gpfs"
1165     default_shared_modules="$default_shared_modules vfs_gpfs_hsm_notify"
1168 #############################################
1169 # check if building on Isilon OneFS
1170 printf "%s" "checking for Isilon OneFS... "
1171 save_LIBS="$LIBS"
1172 LIBS="$LIBS -lisi_version"
1173 AC_TRY_LINK([#include <isi_version/isi_version.h>],
1174           [get_isilon_copyright()],
1175           samba_cv_HAVE_ONEFS=yes,
1176           samba_cv_HAVE_ONEFS=no)
1177 echo $samba_cv_HAVE_ONEFS
1178 if test x"$samba_cv_HAVE_ONEFS" = x"yes"; then
1179     AC_DEFINE(HAVE_ONEFS,1,[Whether building on Isilon OneFS])
1180     default_shared_modules="$default_shared_modules vfs_onefs vfs_onefs_shadow_copy perfcount_onefs"
1181     default_static_modules="$default_static_modules"
1182     ONEFS_LIBS="-lisi_acl -lisi_ecs -lisi_event -lisi_util"
1183     # Need to also add general libs for oplocks support
1184     save_LIBS="$save_LIBS -lisi_ecs -lisi_event -lisi_util -ldevstat"
1186 AC_SUBST(ONEFS_LIBS)
1187 LIBS="$save_LIBS"
1189 # Note that all the libunwind symbols in the API are defined to internal
1190 # platform-specific version, so we must include libunwind.h before checking
1191 # any of them.
1192 AC_MSG_CHECKING([for libunwind])
1193 save_LIBS=$LIBS
1195 UNWIND_ARCH="unknown"
1196 if test x"$UNAME_I" != x"unknown"; then
1197         UNWIND_ARCH="$UNAME_I"
1198 elif test x"$UNAME_M" != x"unknown"; then
1199         UNWIND_ARCH="$UNAME_M"
1200 elif test x"$UNAME_P" != x"unknown"; then
1201         UNWIND_ARCH="$UNAME_P"
1204 case "$UNWIND_ARCH" in
1205         unknown)
1206                 # This probably won't link without
1207                 # the platform-specific libunwind.
1208                 LIBS="$LIBS -lunwind"
1209                 ;;
1210         i386|i586|i686)
1211                 # Add the platform-specific libunwind module.
1212                 LIBS="$LIBS -lunwind -lunwind-x86"
1213                 ;;
1214         *)
1215                 # Add the platform-specific libunwind module.
1216                 # based on uname -i, uname -m or uname -p
1217                 LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
1218                 ;;
1219 esac
1221 AC_TRY_LINK(
1222     [
1223 #ifdef HAVE_LIBUNWIND_H
1224 #include <libunwind.h>
1225 #endif
1226     ],
1227     [
1228         unw_context_t ctx; unw_cursor_t cur;
1229         char buf[256]; unw_word_t off;
1230         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1231         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1232     ],
1233     [
1234         AC_MSG_RESULT(yes)
1235         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1237         # If we have libunwind, test whether we also have libunwind-ptrace
1238         # which would let us unwind arbitrary processes.
1239         save_LIBS=$LIBS
1240         AC_CHECK_HEADERS(libunwind-ptrace.h)
1241         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1242             [
1243                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1244                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1245                     [Whether libunwind-ptrace.a is available.])
1246             ],
1247             [ LIBUNWIND_PTRACE="" ])
1249         LIBS=$save_LIBS
1250     ],
1251     [
1252         AC_MSG_RESULT(no)
1253         LIBS=$save_LIBS
1254     ])
1256 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1257 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1258     AC_CHECK_HEADERS(sys/ptrace.h)
1259     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1260     AC_TRY_LINK(
1261             [
1262 #if HAVE_SYS_TYPES_H
1263 #include <sys/types.h>
1264 #endif
1265 #if HAVE_SYS_PTRACE_H
1266 #include <sys/ptrace.h>
1267 #endif
1268             ],
1269             [
1270                 pid_t me = (pid_t)-1;
1271                 ptrace(PTRACE_ATTACH, me, 0, 0);
1272                 ptrace(PTRACE_DETACH, me, 0, 0);
1273                 return 0;
1274             ],
1275             [
1276                 AC_MSG_RESULT(yes)
1277                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1278                     [Whether the Linux ptrace(2) interface is available.])
1279             ],
1280             [
1281                 AC_MSG_RESULT(no)
1282                 LIBUNWIND_PTRACE=""
1283             ])
1286 AC_SUBST(LIBUNWIND_PTRACE)
1288 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1289 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1290 AC_CHECK_FUNCS(__getcwd _getcwd)
1291 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1292 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1293 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1294 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1295 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1296 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1297 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1298 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1299 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1300 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1301 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1302 AC_CHECK_FUNCS(prctl)
1304 AC_TRY_COMPILE([
1305 #ifdef HAVE_SYS_PRCTL_H
1306 #include <sys/prctl.h>
1307 #endif
1309 [int i; i = prtcl(0); ],
1310 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1315 case "$host_os" in
1316     *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
1317        # glibc <= 2.3.2 has a broken getgrouplist
1318        AC_CACHE_CHECK([for good getgrouplist],samba_cv_linux_getgrouplist_ok,[AC_TRY_RUN([
1319 #include <unistd.h>
1320 #include <sys/utsname.h>
1321 main() {
1322        /* glibc up to 2.3 has a broken getgrouplist */
1323 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1324        int libc_major = __GLIBC__;
1325        int libc_minor = __GLIBC_MINOR__;
1327        if (libc_major < 2)
1328               exit(1);
1329        if ((libc_major == 2) && (libc_minor <= 3))
1330               exit(1);
1331 #endif
1332        exit(0);
1334 ], [samba_cv_linux_getgrouplist_ok=yes],
1335    [samba_cv_linux_getgrouplist_ok=no],
1336    [samba_cv_linux_getgrouplist_ok=cross])])
1337        if test x"$samba_cv_linux_getgrouplist_ok" = x"yes"; then
1338           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1339        fi
1340        ;;
1341     *)
1342        AC_CHECK_FUNCS(getgrouplist)
1343        ;;
1344 esac
1347 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1350 if test x$ac_cv_func_stat64 = xno ; then
1351   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1352   AC_TRY_LINK([
1353 #if defined(HAVE_UNISTD_H)
1354 #include <unistd.h>
1355 #endif
1356 #include <sys/stat.h>
1357 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1358   AC_MSG_RESULT([$ac_cv_func_stat64])
1359   if test x$ac_cv_func_stat64 = xyes ; then
1360     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1361   fi
1364 if test x$ac_cv_func_lstat64 = xno ; then
1365   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1366   AC_TRY_LINK([
1367 #if defined(HAVE_UNISTD_H)
1368 #include <unistd.h>
1369 #endif
1370 #include <sys/stat.h>
1371 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1372   AC_MSG_RESULT([$ac_cv_func_lstat64])
1373   if test x$ac_cv_func_lstat64 = xyes ; then
1374     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1375   fi
1378 if test x$ac_cv_func_fstat64 = xno ; then
1379   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1380   AC_TRY_LINK([
1381 #if defined(HAVE_UNISTD_H)
1382 #include <unistd.h>
1383 #endif
1384 #include <sys/stat.h>
1385 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1386   AC_MSG_RESULT([$ac_cv_func_fstat64])
1387   if test x$ac_cv_func_fstat64 = xyes ; then
1388     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1389   fi
1392 #################################################
1393 # Check whether struct stat has timestamps with sub-second resolution.
1396 samba_cv_stat_hires=no
1397 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec], # Linux, Solaris
1398         [samba_cv_stat_hires=yes])
1399 AC_CHECK_MEMBERS([struct stat.st_mtimensec], # BSD, if defined _POSIX_SOURCE
1400         [samba_cv_stat_hires=yes])
1401 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec], # BSD, if not defined _POSIX_SOURCE
1402         [samba_cv_stat_hires=yes])
1403 AC_CHECK_MEMBERS([struct stat.st_mtime_n], # AIX
1404         [samba_cv_stat_hires=yes])
1405 AC_CHECK_MEMBERS([struct stat.st_umtime], # Tru64
1406         [samba_cv_stat_hires=yes])
1408 if test x"$samba_cv_stat_hires" = x"yes" ; then
1409     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1410             [whether struct stat has sub-second timestamps])
1413 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1414 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
1415 AC_CHECK_MEMBERS([struct stat.st_birthtime], AC_CHECK_MEMBERS([struct stat.st_birthtimensec]))
1418 AC_CACHE_CHECK([whether there is DOS flags support in the stat struct], samba_cv_stat_dos_flags,
1419     [
1420         AC_TRY_COMPILE(
1421             [#include <sys/stat.h>],
1422             [
1423                 int a = UF_DOS_ARCHIVE;
1424                 int h = UF_DOS_HIDDEN;
1425                 int r = UF_DOS_RO;
1426                 int s = UF_DOS_SYSTEM;
1427                 int i = UF_DOS_NOINDEX;
1428                 int f = UF_DOS_FLAGS;
1429             ],
1430             samba_cv_stat_dos_flags=yes, samba_cv_stat_dos_flags=no)
1431     ])
1433 if test x"$samba_cv_stat_dos_flags" = x"yes" ; then
1434     AC_DEFINE(HAVE_STAT_DOS_FLAGS, 1, [whether there is DOS flags support in the stat struct])
1437 AC_CACHE_CHECK([whether we can compile with __attribute__((destructor))],
1438                samba_cv_function_attribute_destructor,
1439                [
1440                  AC_COMPILE_IFELSE(
1441                         [
1442                                 __attribute__((destructor))
1443                                 static void cleanup(void) { }
1444                         ],
1445                         samba_cv_function_attribute_destructor=yes)
1446                 ])
1448 if test x"$samba_cv_function_attribute_destructor" = xyes ; then
1449    AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR, 1,
1450              [whether we can compile with __attribute__((destructor))])
1453 #####################################
1454 # needed for SRV lookups
1455 AC_CHECK_LIB(resolv, dn_expand)
1456 AC_CHECK_LIB(resolv, _dn_expand)
1457 AC_CHECK_LIB(resolv, __dn_expand)
1460 # Check for the functions putprpwnam, set_auth_parameters,
1461 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1462 # Needed for OSF1 and HPUX.
1465 AC_LIBTESTFUNC(security, putprpwnam)
1466 AC_LIBTESTFUNC(sec, putprpwnam)
1468 AC_LIBTESTFUNC(security, set_auth_parameters)
1469 AC_LIBTESTFUNC(sec, set_auth_parameters)
1471 # UnixWare 7.x has its getspnam in -lgen
1472 AC_LIBTESTFUNC(gen, getspnam)
1474 AC_LIBTESTFUNC(security, getspnam)
1475 AC_LIBTESTFUNC(sec, getspnam)
1477 AC_LIBTESTFUNC(security, bigcrypt)
1478 AC_LIBTESTFUNC(sec, bigcrypt)
1480 AC_LIBTESTFUNC(security, getprpwnam)
1481 AC_LIBTESTFUNC(sec, getprpwnam)
1483 AC_CHECK_FUNCS(strsignal)
1485 ############################################
1486 # Check for EA implementations
1487 case "$host_os" in
1488   *osf*)
1489         AC_SEARCH_LIBS(getproplist, [proplist])
1490         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1491         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1492         AC_CHECK_FUNCS(sizeof_proplist_entry)
1493   ;;
1494   *freebsd4* | *dragonfly* )
1495         AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1496   ;;
1497   *solaris*)
1498         AC_CHECK_FUNCS(attropen)
1499   ;;
1500   *)
1501         AC_SEARCH_LIBS(getxattr, [attr])
1502         AC_CHECK_FUNCS(getxattr,[
1503                 AC_CHECK_FUNCS(lgetxattr fgetxattr listxattr llistxattr flistxattr removexattr lremovexattr fremovexattr setxattr lsetxattr fsetxattr)
1504                 ])
1505         AC_CHECK_FUNCS(getea,[
1506                 AC_CHECK_FUNCS(fgetea lgetea listea flistea llistea removeea fremoveea lremoveea setea fsetea lsetea)
1507                 ])
1508         AC_CHECK_FUNCS(attr_get,[
1509                 AC_CHECK_FUNCS(attr_list attr_set attr_remove attr_getf attr_listf attr_setf attr_removef)
1510                 ])
1511         AC_CHECK_FUNCS(extattr_delete_file,[
1512                 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)
1513                 ])
1514   ;;
1515 esac
1517 ########################################################
1518 # Do xattr functions take additional options like on Darwin?
1519 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1520         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1521                 old_LIBS=$LIBS
1522                 LIBS="$LIBS $ACL_LIBS"
1523                 AC_TRY_COMPILE([
1524                         #include <sys/types.h>
1525                         #if HAVE_ATTR_XATTR_H
1526                         #include <attr/xattr.h>
1527                         #elif HAVE_SYS_XATTR_H
1528                         #include <sys/xattr.h>
1529                         #endif
1530                 ],[
1531                         getxattr(0, 0, 0, 0, 0, 0);
1532                 ],
1533                 [smb_attr_cv_xattr_add_opt=yes],
1534                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1535         ])
1536         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1537                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1538         fi
1541 AC_DISABLE_STATIC
1542 AC_ENABLE_SHARED
1544 # Set defaults
1545 PIE_CFLAGS=""
1546 PIE_LDFLAGS=""
1547 AC_ARG_ENABLE(pie, [AS_HELP_STRING([--enable-pie], [Turn on pie support if available (default=yes)])])
1549 if test "x$enable_pie" != xno
1550 then
1551         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1552         [
1553                 cat > conftest.c <<EOF
1554 int foo;
1555 int main () { return 0;}
1557                 if AC_TRY_COMMAND_NO_STDERR([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c])
1558                 then
1559                         samba_cv_fpie=yes
1560                 else
1561                         samba_cv_fpie=no
1562                 fi
1563                 rm -f conftest*
1564         ])
1565         if test x"${samba_cv_fpie}" = x"yes"
1566         then
1567                 PIE_CFLAGS="-fPIE"
1568                 PIE_LDFLAGS="-pie"
1569         fi
1572 # Set defaults
1573 RELRO_LDFLAGS=""
1574 AC_ARG_ENABLE(relro, [AS_HELP_STRING([--enable-relro], [Turn on Relocations Read-Only (relro) support if available (default=yes)])])
1576 if test "x$enable_relro" != xno
1577 then
1578         AC_CACHE_CHECK([for -Wl,-z,relro], samba_cv_relro,
1579         [
1580                 cat > conftest.c <<EOF
1581 int foo;
1582 main () { return 0;}
1584                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1585                 then
1586                         samba_cv_relro=yes
1587                 else
1588                         samba_cv_relro=no
1589                 fi
1590                 rm -f conftest*
1591         ])
1592         if test x"${samba_cv_relro}" = x"yes"
1593         then
1594                 RELRO_LDFLAGS="-Wl,-z,relro"
1595         fi
1598 # Set defaults
1599 SYMSEXT="syms"
1600 AC_SUBST(SYMSEXT)
1602 # Assume non-shared by default and override below
1603 BLDSHARED="false"
1605 # these are the defaults, good for lots of systems
1606 HOST_OS="$host_os"
1607 LDSHFLAGS="-shared"
1608 MODULE_EXPORTS=""
1609 SONAMEFLAG="#"
1610 SHLD="\${CC} \${CFLAGS}"
1611 PICFLAG="${PIE_CFLAGS}"
1612 SHLIBEXT="so"
1613 DSO_EXPORTS=""
1615 # this bit needs to be modified for each OS that supports share libs
1616 # You need to specify how to create a shared library and
1617   # how to compile C code to produce PIC object files
1619   AC_MSG_CHECKING([ability to build shared libraries])
1621   # and these are for particular systems
1622   case "$host_os" in
1623                 *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
1624                         case "$host_os" in
1625                                 *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
1626                                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) ;;
1627                         esac
1628                         BLDSHARED="true"
1629                         LDSHFLAGS="-shared -Wl,-Bsymbolic"
1630                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1631                                 LDSHFLAGS_Z_NODEFS="-Wl,--allow-shlib-undefined"
1632                         fi
1633                         DYNEXP="-Wl,--export-dynamic"
1634                         PICFLAG="-fPIC"
1635                         SONAMEFLAG="-Wl,-soname="
1636                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1637                         ;;
1638                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1639                         BLDSHARED="true"
1640                         if test "${GCC}" = "yes"; then
1641                                 PICFLAG="-fPIC"
1642                                 SONAMEFLAG="-Wl,-soname="
1643                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1644                                         DYNEXP="-Wl,-E"
1645                                 fi
1646                                 LDSHFLAGS="-shared"
1647                         else
1648                                 PICFLAG="-KPIC"
1649                                 LDSHFLAGS="-G"
1650                         fi
1651                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1652                                 SONAMEFLAG="-Wl,-soname="
1653                         else
1654                                 SONAMEFLAG="-Wl,-h,"
1655                         fi
1656                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1657                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1658                         ;;
1659                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1660                         BLDSHARED="true"
1661                         LDSHFLAGS="-G"
1662                         SONAMEFLAG="-Wl,-h,"
1663                         PICFLAG="-KPIC"   # Is this correct for SunOS
1664                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1665                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1666                         ;;
1667                 *netbsd* | *freebsd* | *dragonfly* )
1668                         BLDSHARED="true"
1669                         LDSHFLAGS="-shared"
1670                         DYNEXP="-Wl,--export-dynamic"
1671                         SONAMEFLAG="-Wl,-soname,"
1672                         PICFLAG="-fPIC -DPIC"
1673                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1674                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1675                         ;;
1676                 *openbsd*)  BLDSHARED="true"
1677                         LDSHFLAGS="-shared"
1678                         DYNEXP="-Wl,-Bdynamic"
1679                         SONAMEFLAG="-Wl,-soname,"
1680                         PICFLAG="-fPIC"
1681                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1682                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1683                         ;;
1684                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1685                         case "$host_os" in
1686                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1687                         ;;
1688                         esac
1689                         BLDSHARED="true"
1690                         LDSHFLAGS="-Wl,-set_version,sgi1.0 -shared"
1691                         SONAMEFLAG="-Wl,-soname,"
1692                         if test "${GCC}" = "yes"; then
1693                                 PICFLAG="-fPIC"
1694                         else
1695                                 PICFLAG="-KPIC"
1696                         fi
1697                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1698                         ;;
1699                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1700                         BLDSHARED="true"
1701                         # use expfull to export underscored symbols
1702                         # add rtl to remove /lib/crt0.o warning
1703                         LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc,-brtl"
1704                         DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
1705                         PICFLAG="-O2"
1706                         # as AIX code is always position independent...
1707                         # .po will just create compile warnings, use po.o:
1708                         if test "${GCC}" != "yes"; then
1709                                 ## for funky AIX compiler using strncpy()
1710                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 -qhalt=e"
1711                         fi
1713                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1714                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1715                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1716                         ;;
1717                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1718                         # ia64: 64bit build using gcc with CFLAGS="-mpl64"
1719                         #       64bit build using HP's cc with CFLAGS="+DD64"
1720                         # hppa: 64bit build unsupported by gcc
1721                         #       64bit build using HP's cc with CFLAGS="+DA2.0w"
1722                         # HP-UX 11.00 ld needs PHSS_33034
1723                         BLDSHARED="true"
1724                         if test "${GCC}" = "yes"; then
1725                                 PICFLAG="-fPIC"
1726                                 LDSHFLAGS="-shared"
1727                         else
1728                                 PICFLAG="+z"
1729                                 LDSHFLAGS="-b"
1730                                 # "Uses depth-first symbol resolution"
1731                                 LDSHFLAGS="$LDSHFLAGS -Wl,-B,symbolic,-b"
1732                                 if test "$host_cpu" != "ia64"; then
1733                                         # "don't store literals in read-only memory" (?):
1734                                         PICFLAG="$PICFLAG +ESnolit"
1735                                 fi
1736                         fi
1737                         if test "$host_cpu" = "ia64"; then
1738                                 SHLIBEXT="so"
1739                                 # TODO: does the linker find the right 32/64 bit version of the libs? :
1740                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32:/usr/local/lib/hpux64:/usr/lib/hpux64"
1741                         else
1742                                 SHLIBEXT="sl"
1743                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1744                         fi
1745                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1746                                 SONAMEFLAG="-Wl,-soname="
1747                         else
1748                                 SONAMEFLAG="-Wl,+h,"
1749                         fi
1750                         # PIE/PIC flags at link time are required on HP-UX because
1751                         # linking requires a temporary source file, which is being
1752                         # compiled with the indicated flags - which need to contain
1753                         # PIC flags when we don't support PIE flags:
1754                         if test "$PIE_LDFLAGS" = "" ; then
1755                                 PIE_LDFLAGS=\${PICFLAG}
1756                         fi
1757                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1758                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1759                         ;;
1760                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1761                         BLDSHARED="true"
1762                         LDSHFLAGS="-shared"
1763                         SONAMEFLAG="-Wl,-soname,"
1764                         if test "${GCC}" = "yes"; then
1765                                 PICFLAG="-fPIC"
1766                         fi
1767                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1768                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1769                         for flags in "-expect_unresolved '*'" "-Wl,-expect_unresolved,'*'" ; do
1770                                 saved_ldflags="$LDFLAGS"
1771                                 AC_MSG_CHECKING([if $flags works])
1772                                 LDFLAGS="$flags $saved_ldflags"
1773                                 AC_TRY_LINK([],[],
1774                                         [AC_MSG_RESULT([yes])
1775                                         LDSHFLAGS_Z_NODEFS=$flags],
1776                                         AC_MSG_RESULT([no]))
1777                                 LDFLAGS="$saved_ldflags"
1778                                 test x"$LDSHFLAGS_Z_NODEFS" != x && break
1779                         done
1780                         ;;
1781                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1782                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1783                         ;;
1784                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1785                         BLDSHARED="true"
1786                         LDSHFLAGS="-shared"
1787                         SONAMEFLAG="-Wl,-soname,"
1788                         PICFLAG="-KPIC"
1789                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1790                         ;;
1791                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1792                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1793                         ;;
1794                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1795                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1796                         ;;
1797                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1798                         case "$host" in
1799                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1800                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1801                                         fi
1802                                         LDSHFLAGS="-G"
1803                                         DYNEXP="-Bexport"
1804                                 ;;
1805                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1806                         esac
1807                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1808                         ;;
1810                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1811                         if [ test "$GCC" != yes ]; then
1812                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1813                         fi
1814                         LDSHFLAGS="-G"
1815                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1816                         ;;
1817                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1818                         BLDSHARED="false"
1819                         LDSHFLAGS=""
1820                         ;;
1822                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1823                         BLDSHARED="true"
1824                         LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress"
1825                         CFLAGS="$CFLAGS -fno-common"
1826                         SHLD="\${CC}"
1827                         SHLIBEXT="dylib"
1828                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
1829                         SHLIBEXT="dylib"
1830                         # Since gcc doesn't fail on unrecognised options, the
1831                         # PIE test incorrectly succeeds. Darwin gcc does not
1832                         # actually support the PIE stuff.
1833                         PIE_LDFLAGS=
1834                         PIE_CFLAGS=
1835                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1836                         ;;
1838                 *)
1839                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1840                         ;;
1841   esac
1843 if test "$enable_shared" != "yes"; then
1844         BLDSHARED=false
1847 if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
1848         DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
1851 if test x"$BLDSHARED" = x"true" ; then
1852         LDFLAGS="$LDFLAGS -L./bin"
1855 AC_MSG_RESULT($BLDSHARED)
1857 if test x"$enable_developer" = x"yes" ; then
1858         default_as_needed=auto
1859 else
1860         default_as_needed=no
1862 AC_ARG_ENABLE(as-needed,
1863         AS_HELP_STRING([--enable-as-needed],
1864         [Turn on as-needed support if available (default=no)]),
1865         [enable_as_needed=$enableval],
1866         [enable_as_needed=$default_as_needed])
1867 if test "x$enable_as_needed" != xno; then
1868     saved_before_as_needed_ldflags="$LDFLAGS"
1869     for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
1870         saved_ldflags="$LDFLAGS"
1871         AC_MSG_CHECKING([if $flags works])
1872         LDFLAGS="$flags $saved_ldflags"
1873         AC_TRY_LINK([],[],
1874                 [AC_MSG_RESULT([yes])
1875                 LD_AS_NEEDED_FLAG=$flags
1876                 ld_as_needed_flag_found=yes],
1877                 AC_MSG_RESULT([no]))
1878         LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
1879         test x"$ld_as_needed_flag_found" = xyes && break
1880     done
1883 if test x$ld_as_needed_flag_found = xyes -a x$enable_as_needed = xauto ; then
1884 # check if ld has bug described in https://bugzilla.samba.org/show_bug.cgi?id=7209#c17
1885         AC_MSG_CHECKING([if $LD_AS_NEEDED_FLAG has explicit external libs bug])
1886 cat > conftest_shb.c <<END
1887 void b() {}
1889 cat > conftest_sha.c <<END
1890 extern void b();
1891 void a() {
1892         b();
1895 cat > conftest.c <<END
1896 extern void a();
1897 int main() {
1898         a();
1899         return 0;
1903         rm -fr conftest
1904         AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o conftest_sha.o conftest_sha.c 1>&AS_MESSAGE_LOG_FD 2>&1])
1905         AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o conftest_shb.o conftest_shb.c 1>&AS_MESSAGE_LOG_FD 2>&1])
1906         TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
1907         AC_TRY_COMMAND([$TESTCMD -o libconftest_shb.$SHLIBEXT conftest_shb.o 1>&AS_MESSAGE_LOG_FD 2>&1])
1908         AC_TRY_COMMAND([$TESTCMD -o libconftest_sha.$SHLIBEXT conftest_sha.o 1>&AS_MESSAGE_LOG_FD 2>&1])
1909         AC_TRY_COMMAND([$CC -o conftest conftest.c $LDFLAGS -L. -lconftest_sha -lconftest_shb 1>&AS_MESSAGE_LOG_FD 2>&1])
1910         if AC_TRY_COMMAND([eval "$LIB_PATH_VAR=. ./conftest 1>&AS_MESSAGE_LOG_FD 2>&1"])
1911         then
1912                 AC_MSG_RESULT([no])
1913         else
1914                 ld_as_needed_flag_found=no
1915                 LDFLAGS="$saved_before_as_needed_ldflags"
1916                 AC_MSG_RESULT([yes])
1917         fi
1918         rm conftest* libconftest*
1921 # check if we have to disable LD_AS_NEEDED_FLAG:
1922 # On some systems for a veriety of reasons linking with
1923 # -Wl,--as-needed -lreadline -lncurses fails
1924 # we have to retest, if these combination is detected before.
1925 # Bugzilla #7209
1927 if test x$ac_cv_lib_readline_rl_callback_handler_install = xyes ; then
1928         if test x$ld_as_needed_flag_found = xyes ; then
1929                 AC_MSG_CHECKING([if $LD_AS_NEEDED_FLAG works with readline])
1930                 # try if check no fails
1931                 save_LIBS=$LIBS
1932                 LIBS="$LIBS $TERMLIBS"
1933                 AC_TRY_LINK([], [rl_callback_handler_install();], [AC_MSG_RESULT([yes])],[ AC_MSG_RESULT([no]); LDFLAGS="$saved_before_as_needed_ldflags"])
1934                 LIBS="$save_LIBS"
1935         fi
1940 # for historical reasons almost all linkers don't complain about unresolved
1941 # symbols in shared libs. Except for the internal samba modules we want to get
1942 # errors when we produce a shared lib with unresolved symbols. On some
1943 # platforms unresolved symbols might be intended, so we might have to add
1944 # platform specific exceptions here.
1946 for flags in "-Wl,-z,defs" "-error_unresolved" "-Wl,-error_unresolved" ; do
1947         saved_ldflags="$LDFLAGS"
1948         AC_MSG_CHECKING([if $flags works])
1949         LDFLAGS="$flags $saved_ldflags"
1950         AC_TRY_LINK([],[],
1951         [AC_MSG_RESULT([yes])
1952         LDSHFLAGS_Z_DEFS=$flags
1953         ldshflags_z_defs_found=yes],
1954         AC_MSG_RESULT([no]))
1955         LDFLAGS=$saved_ldflags
1956         test x"$ldshflags_z_defs_found" = xyes && break
1957 done
1959 AC_MSG_CHECKING([LDSHFLAGS_Z_DEFS])
1960 AC_MSG_RESULT([$LDSHFLAGS_Z_DEFS])
1961 AC_MSG_CHECKING([LDFLAGS])
1962 AC_MSG_RESULT([$LDFLAGS])
1963 AC_MSG_CHECKING([DYNEXP])
1964 AC_MSG_RESULT([$DYNEXP])
1966 #######################################################
1967 # test whether building a shared library actually works
1968 if test $BLDSHARED = true; then
1970 AC_MSG_CHECKING([SHLD])
1971 AC_MSG_RESULT([$SHLD])
1972 AC_MSG_CHECKING([LDSHFLAGS])
1973 AC_MSG_RESULT([$LDSHFLAGS])
1975 AC_MSG_CHECKING([SHLIBEXT])
1976 AC_MSG_RESULT([$SHLIBEXT])
1977 AC_MSG_CHECKING([SONAMEFLAG])
1978 AC_MSG_RESULT([$SONAMEFLAG])
1980 AC_MSG_CHECKING([PICFLAG])
1981 AC_MSG_RESULT([$PICFLAG])
1983 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
1984 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
1986 AC_CACHE_CHECK([whether building shared libraries actually works],
1987                [ac_cv_shlib_works],[
1988    # try building a trivial shared library
1989    ac_cv_shlib_works=no
1990    # The $SHLD and $LDSHFLAGS variables may contain references to other
1991    # variables so they need to be eval'ed.
1992    if AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.o ${srcdir-.}/../tests/shlib.c 1>&AS_MESSAGE_LOG_FD])
1993    then
1994      TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
1995      TESTCMD="$TESTCMD -o \"shlib.$SHLIBEXT\" shlib.o"
1996      if AC_TRY_COMMAND([eval $TESTCMD 1>&AS_MESSAGE_LOG_FD 2>&1])
1997      then
1998        ac_cv_shlib_works=yes
1999      fi
2000    fi
2001    rm -f "shlib.$SHLIBEXT" shlib.o
2004 if test $ac_cv_shlib_works = no; then
2005    BLDSHARED=false
2009 if test x"$BLDSHARED" != x"true"; then
2010         LDSHFLAGS="shared-libraries-disabled"
2011         SONAMEFLAG="shared-libraries-disabled"
2012         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
2013         SHLD="shared-libraries-disabled"
2014         PICFLAG="${PIE_CFLAGS}"
2015         SHLIBEXT="shared_libraries_disabled"
2016         smbtorture4_possible=no
2019 AC_MSG_CHECKING([used PICFLAG])
2020 AC_MSG_RESULT([$PICFLAG])
2022 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
2026 ###########################################################
2028 # Configuration of subsystems / libraries
2030 ###########################################################
2032 INSTALLLIBCMD_SH=:
2033 INSTALLLIBCMD_A=:
2034 UNINSTALLLIBCMD_SH=:
2035 UNINSTALLLIBCMD_A=:
2037 if test $BLDSHARED = true; then
2038         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
2039         UNINSTALLLIBCMD_SH="rm -f"
2041 if test $enable_static = yes; then
2042         INSTALLLIBCMD_A="\$(INSTALLCMD)"
2043         UNINSTALLLIBCMD_A="rm -f"
2046 #################################################
2047 # --disable-shared-libs
2048 # can be used to disable the internal use of shared libs altogether
2049 # (this only has an effect when building shared libs is enabled)
2051 USESHARED=false
2052 AC_SUBST(USESHARED)
2054 AC_MSG_CHECKING(whether to use shared libraries internally)
2055 AC_ARG_ENABLE([shared-libs],
2056         AS_HELP_STRING([--enable-shared-libs],
2057                 [Use shared libraries internally (default=yes)]),
2058         [enable_shared_libs=$enableval],
2059         [enable_shared_libs=yes])
2061 if test x"$enable_shared_libs" != x"no" ; then
2062         USESHARED=$BLDSHARED
2065 AC_MSG_RESULT([$USESHARED])
2067 if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
2068         AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
2071 #################################################
2072 # --with-static-libs=LIBS:
2073 #   link (internal) libs dynamically or statically?
2075 # If a subsystem is built as a library then this controls whether they are
2076 # linked into Samba targets statically or dynamically:
2078 # * If we build the shared library at all, we link dynamically by default.
2080 # * We only link statically if we don't build shared or if the library
2081 #   appears in the --with-static-libs configure option.
2083 # Example:
2084 #   --with-static-libs=libtalloc makes use of libtalloc.a instead
2085 #   of linking the dynamic variant with -ltalloc.
2087 # NOTE: This option only affects libraries that we do not only build
2088 # but that samba also links against as libraries (as opposed to linking
2089 # the plain object files. - This has to be configured in Makefile.in.
2090 # So in particular it does not harm to give invalid or unknown names here.
2093 AC_ARG_WITH([static-libs],
2094         [AS_HELP_STRING([--with-static-libs=LIBS],
2095                 [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
2096         [AS_IF([test $withval],
2097                 [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
2098                         [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
2099                         eval LINK_$lib=STATIC
2100                 done], [])],
2101         [])
2104 # WORKAROUND:
2105 #   until we have organized other internal subsystems (as util, registry
2106 #   and smbconf) into shared libraries, we CAN NOT link libnetapi
2107 #   dynamically to samba programs.
2109 LINK_LIBNETAPI=STATIC
2111 LINK_LIBSMBCLIENT=STATIC
2114 #  The library versions are hardcoded here
2115 #  and filled into the LIBFOO_SOVER variable.
2117 #  TODO: for talloc and tdb (at least), these should
2118 #  be extracted from their respective source directories
2120 AC_ARG_ENABLE(external_libtalloc,
2121         [AS_HELP_STRING([--enable-external-libtalloc],
2122                 [Enable external talloc [default=auto]])],
2123         [ enable_external_libtalloc=$enableval ],
2124         [ enable_external_libtalloc=auto ])
2126 if test "x$enable_external_libtalloc" != xno
2127 then
2128         PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1,
2129                 [ enable_external_libtalloc=yes ],
2130                 [ if test x$enable_external_libtalloc = xyes; then
2131                         AC_MSG_ERROR([Unable to find libtalloc])
2132                   else
2133                         enable_external_libtalloc=no
2134                   fi
2135                 ])
2138 if test "x$enable_external_libtalloc" = xno
2139 then
2140         m4_include(../lib/talloc/libtalloc.m4)
2141         if test x"$USESHARED" = x"no" ; then
2142                 LINK_LIBTALLOC=STATIC
2143         fi
2144         LIBTALLOCVERSION=`grep ^VERSION ${tallocdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
2145         SMB_LIBRARY(talloc, 2, ${LIBTALLOCVERSION})
2146         LIBTALLOC_OBJ0=""
2147         for obj in ${TALLOC_OBJ}; do
2148                 LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
2149         done
2150         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
2151         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TALLOC_CFLAGS}"
2152         AC_SUBST(LIBTALLOC_OBJ0)
2154         TALLOCTORT="bin/talloctort\$(EXEEXT)"
2155         AC_SUBST(TALLOCTORT)
2159 AC_ARG_ENABLE(external_libtdb,
2160         [AS_HELP_STRING([--enable-external-libtdb],
2161                 [Enable external tdb [default=auto]])],
2162                 [ enable_external_libtdb=$enableval ],
2163                 [ enable_external_libtdb=auto ])
2165 if test "x$enable_external_libtdb" != xno
2166 then
2167         PKG_CHECK_MODULES(LIBTDB, tdb >= 1.2.6,
2168                 [ enable_external_libtdb=yes ],
2169                 [
2170                 if test x$enable_external_libtdb = xyes; then
2171                         AC_MSG_ERROR([Unable to find libtdb])
2172                 else
2173                         enable_external_libtdb=no
2174                 fi
2175                 ])
2178 AC_SUBST(LIBTDB_OBJ0)
2179 if test "x$enable_external_libtdb" = xno
2180 then
2181         m4_include(../lib/tdb/libtdb.m4)
2182         if test x"$USESHARED" = x"no" ; then
2183                 LINK_LIBTDB=STATIC
2184         fi
2185         LIBTDBVERSION=`grep ^VERSION ${tdbdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
2186         SMB_LIBRARY(tdb, 1, ${LIBTDBVERSION})
2187         LIBTDB_OBJ0=""
2188         LIBTDB_LIBS="$LIBTDB_LIBS $TDB_DEPS"
2189         for obj in ${TDB_OBJ}; do
2190                 LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
2191         done
2192         AC_SUBST(LIBTDB_OBJ0)
2193         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
2194         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TDB_CFLAGS}"
2196         TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
2197         AC_SUBST(TDBBACKUP)
2198         TDBDUMP="bin/tdbdump\$(EXEEXT)"
2199         AC_SUBST(TDBDUMP)
2200         TDBRESTORE="bin/tdbrestore\$(EXEEXT)"
2201         AC_SUBST(TDBRESTORE)
2202         TDBTOOL="bin/tdbtool\$(EXEEXT)"
2203         AC_SUBST(TDBTOOL)
2204         TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
2205         AC_SUBST(TDBTORTURE)
2206         ac_cv_have_tdb_err_nesting=yes
2207 else
2208         AC_TRY_COMPILE([#include <tdb.h>],
2209                        [enum TDB_ERROR err = TDB_ERR_NESTING],
2210                        ac_cv_have_tdb_err_nesting=yes,
2211                        ac_cv_have_tdb_err_nesting=no)
2214 if test x"$ac_cv_have_tdb_err_nesting" = xyes; then
2215    AC_DEFINE(HAVE_TDB_ERR_NESTING, 1, [Whether we have TDB_ERR_NESTING])
2218 SMB_LIBRARY(netapi, 0)
2219 SMB_LIBRARY(smbclient, 0)
2220 SMB_LIBRARY(smbsharemodes, 0)
2221 SMB_LIBRARY(addns, 0, [], no, [undefined API])
2225 ################
2227 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
2228 AC_TRY_RUN([#include <stdio.h>
2229 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
2230 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
2231 if test x"$samba_cv_have_longlong" = x"yes"; then
2232     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
2233     AC_CHECK_TYPE(intptr_t, unsigned long long)
2234 else
2235     AC_CHECK_TYPE(intptr_t, unsigned long)
2239 # Check if the compiler supports the LL prefix on long long integers.
2240 # AIX needs this.
2242 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
2243     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
2244         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
2245 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
2246    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
2250 AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
2251 AC_TRY_RUN([#include <time.h>
2252 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
2253 samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
2254 if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
2255     AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
2258 AC_CACHE_CHECK([for TIME_T_MAX],samba_cv_TIME_T_MAX,[
2259 AC_TRY_RUN([#include <time.h>
2260 main() {
2261         struct tm *tm;
2262         if (sizeof(time_t) == 8) {
2263                 time_t max_time = 0x7fffffffffffffffll;
2264                 tm = gmtime(&max_time);
2265                 /* This should fail with 32-bit tm_year. */
2266                 if (tm == NULL) {
2267                         /* Max time_t that works with 32-bit int tm_year in struct tm. */
2268                         max_time = 67768036191676799ll;
2269                         tm = gmtime(&max_time);
2270                         if (tm) {
2271                                 exit(0);
2272                         }
2273                 }
2274         }
2275         exit(1);
2277 samba_cv_TIME_T_MAX=yes,samba_cv_TIME_T_MAX=no,samba_cv_TIME_T_MAX=cross)])
2278 if test x"$samba_cv_TIME_T_MAX" = x"yes"; then
2279     AC_DEFINE(TIME_T_MAX,67768036191676799ll,[The maximum value of the 'time_t' type])
2283 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
2284 AC_TRY_RUN([#include <stdio.h>
2285 #include <sys/stat.h>
2286 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
2287 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
2288 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
2289     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
2292 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
2293 AC_TRY_RUN([
2294 #if defined(HAVE_UNISTD_H)
2295 #include <unistd.h>
2296 #endif
2297 #include <stdio.h>
2298 #include <sys/stat.h>
2299 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2300 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
2301 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
2302     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
2305 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
2306 AC_TRY_RUN([
2307 #if defined(HAVE_UNISTD_H)
2308 #include <unistd.h>
2309 #endif
2310 #include <stdio.h>
2311 #include <sys/stat.h>
2312 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
2313 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
2314 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
2315     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
2318 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
2319 AC_TRY_RUN([
2320 #if defined(HAVE_UNISTD_H)
2321 #include <unistd.h>
2322 #endif
2323 #include <stdio.h>
2324 #include <sys/stat.h>
2325 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2326 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
2327 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
2328     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
2331 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
2332 AC_TRY_RUN([
2333 #if defined(HAVE_UNISTD_H)
2334 #include <unistd.h>
2335 #endif
2336 #include <stdio.h>
2337 #include <sys/stat.h>
2338 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
2339 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
2340 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
2341     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
2344 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
2345 AC_TRY_RUN([
2346 #if defined(HAVE_UNISTD_H)
2347 #include <unistd.h>
2348 #endif
2349 #include <stdio.h>
2350 #include <sys/stat.h>
2351 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2352 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
2353 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
2354     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
2357 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
2358 AC_TRY_COMPILE([
2359 #if defined(HAVE_UNISTD_H)
2360 #include <unistd.h>
2361 #endif
2362 #include <sys/types.h>
2363 #include <dirent.h>],
2364 [DIR64 de;],
2365 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
2366 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2367     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
2370 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
2371 AC_TRY_COMPILE([
2372 #if defined(HAVE_UNISTD_H)
2373 #include <unistd.h>
2374 #endif
2375 #include <sys/types.h>
2376 #include <dirent.h>],
2377 [struct dirent64 de;],
2378 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
2379 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2380     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
2383 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
2384 AC_TRY_RUN([
2385 #if defined(HAVE_UNISTD_H)
2386 #include <unistd.h>
2387 #endif
2388 #include <sys/types.h>
2389 main() { dev_t dev; int i = major(dev); return 0; }],
2390 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
2391 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
2392     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
2395 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
2396 AC_TRY_RUN([
2397 #if defined(HAVE_UNISTD_H)
2398 #include <unistd.h>
2399 #endif
2400 #include <sys/types.h>
2401 main() { dev_t dev; int i = minor(dev); return 0; }],
2402 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
2403 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
2404     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
2407 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
2408 AC_TRY_RUN([
2409 #if defined(HAVE_UNISTD_H)
2410 #include <unistd.h>
2411 #endif
2412 #include <sys/types.h>
2413 main() { dev_t dev = makedev(1,2); return 0; }],
2414 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
2415 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
2416     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
2419 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
2420 AC_TRY_RUN([#include <stdio.h>
2421 main() { char c; c=250; exit((c > 0)?0:1); }],
2422 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
2423 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
2424     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
2427 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
2428 AC_TRY_COMPILE([#include <sys/types.h>
2429 #include <dirent.h>
2430 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2431 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2432 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2433     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2436 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2437 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2438 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2439 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2440     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2443 if test x"$libreplace_cv_HAVE_CLOCK_GETTIME_IN_LIBRT" = xyes ; then
2444         LIBS="$LIBS -lrt"
2447 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2448 AC_TRY_RUN([#include <sys/types.h>
2449 #include <dirent.h>
2450 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2451 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2452 di->d_name[0] == 0) exit(0); exit(1);} ],
2453 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2454 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2455     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2458 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2459 AC_TRY_COMPILE([#include <sys/types.h>
2460 #include <utime.h>],
2461 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2462 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2463 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2464     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2467 ##############
2468 # Check utmp details, but only if our OS offers utmp.h
2469 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2470 dnl  utmp and utmpx come in many flavours
2471 dnl  We need to check for many of them
2472 dnl  But we don't need to do each and every one, because our code uses
2473 dnl  mostly just the utmp (not utmpx) fields.
2475 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx getutxent)
2477 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2478 AC_TRY_COMPILE([#include <sys/types.h>
2479 #include <utmp.h>],
2480 [struct utmp ut;  ut.ut_name[0] = 'a';],
2481 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2482 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2483     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2486 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2487 AC_TRY_COMPILE([#include <sys/types.h>
2488 #include <utmp.h>],
2489 [struct utmp ut;  ut.ut_user[0] = 'a';],
2490 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2491 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2492     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2495 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2496 AC_TRY_COMPILE([#include <sys/types.h>
2497 #include <utmp.h>],
2498 [struct utmp ut;  ut.ut_id[0] = 'a';],
2499 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2500 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2501     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2504 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2505 AC_TRY_COMPILE([#include <sys/types.h>
2506 #include <utmp.h>],
2507 [struct utmp ut;  ut.ut_host[0] = 'a';],
2508 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2509 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2510     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2513 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2514 AC_TRY_COMPILE([#include <sys/types.h>
2515 #include <utmp.h>],
2516 [struct utmp ut;  time_t t; ut.ut_time = t;],
2517 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2518 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2519     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2522 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2523 AC_TRY_COMPILE([#include <sys/types.h>
2524 #include <utmp.h>],
2525 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2526 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2527 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2528     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2531 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2532 AC_TRY_COMPILE([#include <sys/types.h>
2533 #include <utmp.h>],
2534 [struct utmp ut;  ut.ut_type = 0;],
2535 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2536 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2537     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2540 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2541 AC_TRY_COMPILE([#include <sys/types.h>
2542 #include <utmp.h>],
2543 [struct utmp ut;  ut.ut_pid = 0;],
2544 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2545 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2546     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2549 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2550 AC_TRY_COMPILE([#include <sys/types.h>
2551 #include <utmp.h>],
2552 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2553 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2554 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2555     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2558 dnl Look for the IPv6 varient by preference. Many systems have both.
2559 AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
2560 AC_TRY_COMPILE([#include <sys/types.h>
2561 #include <utmp.h>],
2562 [struct utmp ut;  ut.ut_addr_v6[0] = 0;],
2563 samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
2564 if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
2565     AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
2568 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2569 AC_TRY_COMPILE([#include <sys/types.h>
2570 #include <utmp.h>],
2571 [struct utmp ut;  ut.ut_addr = 0;],
2572 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2573 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2574     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2577 if test x$ac_cv_func_pututline = xyes ; then
2578   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2579   AC_TRY_COMPILE([#include <sys/types.h>
2580 #include <utmp.h>],
2581   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2582   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2583   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2584       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2585   fi
2588 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2589 AC_TRY_COMPILE([#include <sys/types.h>
2590 #include <utmpx.h>],
2591 [struct utmpx ux;  ux.ut_syslen = 0;],
2592 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2593 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2594     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2598 # end utmp details
2600 AC_CACHE_CHECK([for linux fallocate],samba_cv_HAVE_LINUX_FALLOCATE,[
2601 AC_TRY_COMPILE([
2602 #if defined(HAVE_UNISTD_H)
2603 #include <unistd.h>
2604 #endif
2605 #include <sys/types.h>
2606 #define _GNU_SOURCE
2607 #include <fcntl.h>
2608 #if defined(HAVE_LINUX_FALLOC_H)
2609 #include <linux/falloc.h>
2610 #endif],
2611 [int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);],
2612 samba_cv_HAVE_LINUX_FALLOCATE=yes,samba_cv_HAVE_LINUX_FALLOCATE=no)])
2613 if test x"$samba_cv_HAVE_LINUX_FALLOCATE" = x"yes" && test x"$ac_cv_func_fallocate" = x"yes"; then
2614     AC_DEFINE(HAVE_LINUX_FALLOCATE,1,[Whether the Linux 'fallocate' function is available])
2617 AC_CACHE_CHECK([for linux fallocate64],samba_cv_HAVE_LINUX_FALLOCATE64,[
2618 AC_TRY_COMPILE([
2619 #if defined(HAVE_UNISTD_H)
2620 #include <unistd.h>
2621 #endif
2622 #include <sys/types.h>
2623 #define _GNU_SOURCE
2624 #include <fcntl.h>
2625 #if defined(HAVE_LINUX_FALLOC_H)
2626 #include <linux/falloc.h>
2627 #endif],
2628 [int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);],
2629 samba_cv_HAVE_LINUX_FALLOCATE64=yes,samba_cv_HAVE_LINUX_FALLOCATE64=no)])
2630 if test x"$samba_cv_HAVE_LINUX_FALLOCATE64" = x"yes" && test x"$ac_cv_func_fallocate64" = x"yes"; then
2631     AC_DEFINE(HAVE_LINUX_FALLOCATE64,1,[Whether the Linux 'fallocate64' function is available])
2634 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
2635 AC_ARG_WITH(libiconv,
2636 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
2638   if test "$withval" = "no" ; then
2639     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2640   else
2641      if test "$withval" != "yes" ; then
2642         ICONV_PATH_SPEC=yes
2643         ICONV_LOOK_DIRS="$withval"
2644      fi
2645   fi
2648 for i in $ICONV_LOOK_DIRS ; do
2650     save_LIBS="$LIBS"
2651     save_LDFLAGS="$LDFLAGS"
2652     save_CPPFLAGS="$CPPFLAGS"
2654     iconv_current_LIBS=""
2655     iconv_current_LDFLAGS=""
2656     iconv_current_CPPFLAGS=""
2658     ICONV_FOUND="no"
2659     unset libext
2661     #  This is here to handle -withval stuff for --with-libiconv
2662     #  Perhaps we should always add a -L
2663     CPPFLAGS="$save_CPPFLAGS -I$i/include"
2665     # Check lib and lib32 library variants to cater for IRIX ABI-specific
2666     # installation paths. This gets a little tricky since we might have iconv
2667     # in both libiconv and in libc. In this case the jm_ICONV test will always
2668     # succeed when the header is found. To counter this, make sure the
2669     # library directory is there and check the ABI directory first (which
2670     # should be harmless on other systems, but causes tons of linker warnings on
2671     # 64bit Ubuntu systems).
2672     # As the build farm doesn't seem to have any IRIX machines with iconv.h
2673     # installed, I've decided to fix the linker warnings.
2674     # -- Kai
2675     # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2676     for l in "lib" "lib32" "lib/hpux32"; do
2677         if test -d "$i/$l" ; then
2678                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2679                 LIBS=
2680                 export LDFLAGS LIBS CPPFLAGS
2681                 # Try to find iconv(3)
2682                 jm_ICONV($i/$l)
2683                 if test x"$ICONV_FOUND" = "xyes" ; then
2684                     libext="$l"
2685                     break
2686                 fi
2687         fi
2688     done
2690     if test x"$ICONV_FOUND" = "xyes" ; then
2691         iconv_current_LDFLAGS="-L$i/$libext"
2692         iconv_current_CPPFLAGS="-I$i/include"
2694         if test x"$jm_cv_lib_iconv" != x; then
2695             iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
2696         else
2697             # We found iconv in libc.
2698             iconv_current_LIBS=""
2699         fi
2701     fi
2703     if test x"$ICONV_FOUND" = "xyes" ; then
2705         LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
2706         CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
2707         LIBS="$save_LIBS $iconv_current_LIBS"
2708         export LDFLAGS LIBS CPPFLAGS
2710         default_dos_charset=no
2711         default_display_charset=no
2712         default_unix_charset=no
2714         # check for default dos charset name
2715         for j in CP850 IBM850 ; do
2716             rjs_CHARSET($j)
2717             default_dos_charset="$ICONV_CHARSET"
2718             if test x"$default_dos_charset" = x"$j"; then
2719                 break
2720             fi
2721         done
2723         # check for default display charset name
2724         for j in ASCII 646 ; do
2725             rjs_CHARSET($j)
2726             default_display_charset="$ICONV_CHARSET"
2727             if test x"$default_display_charset" = x"$j"; then
2728                 break
2729             fi
2730         done
2732         # check for default unix charset name
2733         for j in UTF-8 UTF8 ; do
2734             rjs_CHARSET($j)
2735             default_unix_charset="$ICONV_CHARSET"
2736             if test x"$default_unix_charset" = x"$j"; then
2737                 break
2738             fi
2739         done
2741         if test "$default_dos_charset" != "no" -a \
2742                 "$default_dos_charset" != "cross" -a \
2743                 "$default_display_charset" != "no" -a \
2744                 "$default_display_charset" != "cross" -a \
2745                 "$default_unix_charset" != "no" -a \
2746                 "$default_unix_charset" != "cross"
2747         then
2748                 samba_cv_HAVE_NATIVE_ICONV=yes
2749         else
2750             if test "$default_dos_charset" = "cross" -o \
2751                      "$default_display_charset" = "cross" -o \
2752                      "$default_unix_charset" = "cross"
2753             then
2754                     samba_cv_HAVE_NATIVE_ICONV=cross
2755             else
2756                     samba_cv_HAVE_NATIVE_ICONV=no
2757             fi
2758         fi
2760         # At this point, we have a libiconv candidate. We know that
2761         # we have the right headers and libraries, but we don't know
2762         # whether it does the conversions we want. We can't test this
2763         # because we are cross-compiling. This is not necessarily a big
2764         # deal, since we can't guarantee that the results we get now will
2765         # match the results we get at runtime anyway.
2766         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
2767             default_dos_charset="CP850"
2768             default_display_charset="ASCII"
2769             default_unix_charset="UTF-8"
2770             samba_cv_HAVE_NATIVE_ICONV=yes
2771             AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
2772             AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
2773         fi
2775         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
2777             CPPFLAGS=$save_CPPFLAGS
2778             LDFLAGS=$save_LDFLAGS
2779             LIBS=$save_LIBS
2781             if test x"$iconv_current_LIBS" != x; then
2782                 LIBS="$LIBS $iconv_current_LIBS"
2783             fi
2785             # Add the flags we need to CPPFLAGS and LDFLAGS
2786             CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
2787             LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
2789             # Turn the #defines into string literals
2790             default_dos_charset="\"$default_dos_charset\""
2791             default_display_charset="\"$default_display_charset\""
2792             default_unix_charset="\"$default_unix_charset\""
2794             AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2795             AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2796             AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2797             AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2799            break
2800         fi
2802     # We didn't find a working iconv, so keep going
2803     fi
2805     #  We only need to clean these up here for the next pass through the loop
2806     CPPFLAGS=$save_CPPFLAGS
2807     LDFLAGS=$save_LDFLAGS
2808     LIBS=$save_LIBS
2809     export LDFLAGS LIBS CPPFLAGS
2810 done
2811 unset libext
2814 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2815     AC_MSG_WARN([Sufficient support for iconv function was not found.
2816     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2817    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2818    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2819    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2823 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2824 AC_TRY_RUN([
2825 #include <sys/types.h>
2826 #include <fcntl.h>
2827 #ifndef F_GETLEASE
2828 #define F_GETLEASE      1025
2829 #endif
2830 main() {
2831        int fd = open("/dev/null", O_RDONLY);
2832        return fcntl(fd, F_GETLEASE, 0) == -1;
2835 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2836 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2837     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2840 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2841 AC_TRY_RUN([
2842 #include <sys/types.h>
2843 #include <fcntl.h>
2844 #include <signal.h>
2845 #ifndef F_NOTIFY
2846 #define F_NOTIFY 1026
2847 #endif
2848 main() {
2849         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2852 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2853 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2854     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2857 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2858 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h sys/inotify.h)
2859 AC_CHECK_FUNCS(inotify_init)
2860 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2862 samba_cv_HAVE_INOTIFY=yes,
2863 samba_cv_HAVE_INOTIFY=no,
2864 samba_cv_HAVE_INOTIFY=cross)
2866 if test x"$ac_cv_func_inotify_init" = x"yes"; then
2867     if test  x"$ac_cv_header_sys_inotify_h" = x"yes" -o x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2868         AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel or sys has inotify support])
2869     fi
2872 #################################################
2873 # Check if FAM notifications are available. For FAM info, see
2874 #       http://oss.sgi.com/projects/fam/
2875 #       http://savannah.nongnu.org/projects/fam/
2876 AC_ARG_ENABLE(fam,
2877 [AS_HELP_STRING([--enable-fam], [Turn on FAM support (default=auto)])])
2879 if test x$enable_fam != xno; then
2880     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2881     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2882         # On IRIX, libfam requires libC, but other FAM implementations
2883         # might not need it.
2884         AC_CHECK_LIB(fam, FAMOpen2,
2885             [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam";
2886             AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2887             [samba_cv_HAVE_LIBFAM=no])
2889         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2890             samba_fam_xtra=-lC
2891             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2892                 [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC";
2893                 AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2894                 [samba_cv_HAVE_LIBFAM=no])
2895             unset samba_fam_xtra
2896         fi
2897     fi
2898     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2899         default_shared_modules="$default_shared_modules vfs_notify_fam"
2900         AC_TRY_COMPILE([#include <fam.h>],
2901                     [enum FAMCodes code = FAMChanged;],
2902                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2903                         [Whether fam.h contains a typedef for enum FAMCodes]),
2904                     [])
2905     fi
2907     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2908         AC_CHECK_LIB(fam, FAMNoExists,
2909             [AC_DEFINE(HAVE_FAMNOEXISTS, 1, Define to 1 if there is support for FAMNoExists)])
2910     fi
2912     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2913         AC_MSG_ERROR(FAM support requested but FAM library not available )
2914     fi
2917 AC_SUBST(SMB_FAM_LIBS)
2919 #################################################
2920 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2923 with_dmapi_support=auto
2924 AC_MSG_CHECKING(whether to use DMAPI support)
2925 AC_ARG_WITH(dmapi,
2926 [AS_HELP_STRING([--with-dmapi], [Include DMAPI/XDSM support (default=auto)])],
2927 [ case "$withval" in
2928   yes|no)
2929     with_dmapi_support=$withval
2930     ;;
2931   esac ]
2933 AC_MSG_RESULT([$with_dmapi_support])
2935 if test x"$with_dmapi_support" != xno ; then
2936         SMB_CHECK_DMAPI([], [
2937                 AC_MSG_NOTICE(DMAPI support not present)
2938                 if test x"$with_dmapi_support" = xyes ; then
2939                         AC_MSG_ERROR(no DMAPI support found but requested!)
2940                 fi
2941                 ]
2942         )
2945 # Add TSM SM VFS module only if there are both GPFS and DMAPI support
2946 # Theoretically it should work with AIX JFS2 too but this needs testing
2947 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
2948     default_shared_modules="$default_shared_modules vfs_tsmsm"
2951 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2952 AC_TRY_RUN([
2953 #include <sys/types.h>
2954 #include <fcntl.h>
2955 #include <signal.h>
2956 #include <sys/file.h>
2957 #ifndef LOCK_MAND
2958 #define LOCK_MAND       32
2959 #define LOCK_READ       64
2960 #endif
2961 main() {
2962         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2965 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2966 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2967     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2971 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2972 AC_TRY_COMPILE([#include <sys/types.h>
2973 #include <fcntl.h>],
2974 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2975 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2976 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2977     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2980 #################################################
2981 # Check for POSIX capability support
2983 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2984     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2985     [], [])
2987 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2989     ac_save_LIBS=$LIBS
2990     AC_LIBTESTFUNC(cap, cap_get_proc)
2992     AC_CACHE_CHECK([for POSIX capabilities],
2993             samba_cv_HAVE_POSIX_CAPABILITIES,
2994             [
2995                 AC_TRY_RUN([
2996 #include <sys/types.h>
2997 #include <sys/capability.h>
2998 main() {
2999  cap_t cap;
3000  cap_value_t vals[1];
3001  if (!(cap = cap_get_proc()))
3002    exit(1);
3003  vals[0] = CAP_CHOWN;
3004  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
3005  cap_set_proc(cap);
3006  exit(0);
3008                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
3009                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
3010                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
3011             ])
3013 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
3014     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
3015             [Whether POSIX capabilities are available])
3016 else
3017     LIBS=$ac_save_LIBS
3023 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
3024 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
3027 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
3028 AC_TRY_COMPILE([#include <sys/types.h>
3029 #if defined(HAVE_RPC_RPC_H)
3030 #include <rpc/rpc.h>
3031 #endif],
3032 [int16 testvar;],
3033 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
3034 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
3035     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
3038 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
3039 AC_TRY_COMPILE([#include <sys/types.h>
3040 #if defined(HAVE_RPC_RPC_H)
3041 #include <rpc/rpc.h>
3042 #endif],
3043 [uint16 testvar;],
3044 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
3045 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
3046     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
3049 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
3050 AC_TRY_COMPILE([#include <sys/types.h>
3051 #if defined(HAVE_RPC_RPC_H)
3052 #include <rpc/rpc.h>
3053 #endif],
3054 [int32 testvar;],
3055 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
3056 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
3057     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
3060 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
3061 AC_TRY_COMPILE([#include <sys/types.h>
3062 #if defined(HAVE_RPC_RPC_H)
3063 #include <rpc/rpc.h>
3064 #endif],
3065 [uint32 testvar;],
3066 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
3067 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
3068     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
3072 dnl Some systems (SCO) have a problem including
3073 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
3074 dnl as a #define in <prot.h> and as part of an enum
3075 dnl in <rpc/rpc.h>.
3078 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
3079 AC_TRY_COMPILE([#include <sys/types.h>
3080 #ifdef HAVE_SYS_SECURITY_H
3081 #include <sys/security.h>
3082 #include <prot.h>
3083 #endif  /* HAVE_SYS_SECURITY_H */
3084 #if defined(HAVE_RPC_RPC_H)
3085 #include <rpc/rpc.h>
3086 #endif],
3087 [int testvar;],
3088 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
3089 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
3090     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
3093 AC_MSG_CHECKING([for test routines])
3094 AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
3095            AC_MSG_RESULT(yes),
3096            AC_MSG_ERROR([cant find test code. Aborting config]),
3097            AC_MSG_WARN([cannot run when cross-compiling]))
3099 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
3100 AC_TRY_RUN([#include "${srcdir-.}/../tests/ftruncate.c"],
3101            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
3102 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
3103     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
3106 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
3107 AC_TRY_RUN([#include "${srcdir-.}/../tests/getgroups.c"],
3108            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
3109 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
3110     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
3113 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
3114 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
3115 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
3116 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
3117 AC_CHECK_FUNCS(getpagesize)
3119 ################################################
3120 # look for a method of setting the effective uid
3121 seteuid=no;
3123 if test $seteuid = no; then
3124 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
3125 AC_TRY_RUN([
3126 #define AUTOCONF_TEST 1
3127 #define USE_SETREUID 1
3128 #include "confdefs.h"
3129 #include "${srcdir-.}/lib/util_sec.c"],
3130            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
3131 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
3132     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
3136 # we check for setresuid second as it conflicts with AIO on Linux. 
3137 # see http://samba.org/~tridge/junkcode/aio_uid.c
3138 if test $seteuid = no; then
3139 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
3140 AC_TRY_RUN([
3141 #define AUTOCONF_TEST 1
3142 #define USE_SETRESUID 1
3143 #include "confdefs.h"
3144 #include "${srcdir-.}/lib/util_sec.c"],
3145            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
3146 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
3147     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
3151 if test $seteuid = no; then
3152 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
3153 AC_TRY_RUN([
3154 #define AUTOCONF_TEST 1
3155 #define USE_SETEUID 1
3156 #include "confdefs.h"
3157 #include "${srcdir-.}/lib/util_sec.c"],
3158            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
3159 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
3160     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
3164 if test $seteuid = no; then
3165 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
3166 AC_TRY_RUN([
3167 #define AUTOCONF_TEST 1
3168 #define USE_SETUIDX 1
3169 #include "confdefs.h"
3170 #include "${srcdir-.}/lib/util_sec.c"],
3171            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
3172 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
3173     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
3177 AC_CACHE_CHECK([for the Darwin initgroups system call],
3178         samba_cv_DARWIN_INITGROUPS,
3179         AC_TRY_LINK([
3180 #include <sys/syscall.h>
3181 #include <unistd.h>
3182         ],
3183         [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
3184         samba_cv_DARWIN_INITGROUPS=yes,
3185         samba_cv_DARWIN_INITGROUPS=no)
3188 if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
3189     AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
3190         [Whether to use the Darwin-specific initgroups system call])
3193 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
3194 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock.c"],
3195            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
3196 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
3197     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
3200 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
3201 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock64.c"],
3202            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
3203 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
3204     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
3206 else
3209 dnl Don't check for 64 bit fcntl locking if we know that the
3210 dnl glibc2.1 broken check has succeeded.
3213   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
3214   AC_TRY_RUN([
3215 #if defined(HAVE_UNISTD_H)
3216 #include <unistd.h>
3217 #endif
3218 #include <stdio.h>
3219 #include <stdlib.h>
3221 #ifdef HAVE_FCNTL_H
3222 #include <fcntl.h>
3223 #endif
3225 #ifdef HAVE_SYS_FCNTL_H
3226 #include <sys/fcntl.h>
3227 #endif
3228 main() { struct flock64 fl64;
3229 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
3230 exit(0);
3231 #else
3232 exit(1);
3233 #endif
3235        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
3237   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
3238       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
3239   fi
3242 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
3243 AC_CACHE_CHECK([for broken posix_fallocate],samba_cv_HAVE_BROKEN_POSIX_FALLOCATE,[
3244 AC_TRY_COMPILE([
3245   #define _XOPEN_SOURCE 600
3246   #include <stdlib.h>
3247   #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
3248     probably broken posix_fallocate
3249   #endif
3250 ], [
3251 ], 
3252 samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=no,samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=yes)])
3253 if test x"$samba_cv_HAVE_BROKEN_POSIX_FALLOCATE" = xyes; then
3254         AC_DEFINE(HAVE_BROKEN_POSIX_FALLOCATE,, Whether we have a broken posix_fallocate)
3258 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
3259 AC_TRY_COMPILE([#include <sys/types.h>
3260 #include <sys/stat.h>
3261 #include <unistd.h>],
3262 [struct stat st;  st.st_blocks = 0;],
3263 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
3264 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
3265     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
3268 AC_CHECK_TYPES([blksize_t, blkcnt_t], [], [], [[#include <sys/stat.h>]])
3270 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
3271 AC_TRY_COMPILE([#include <sys/types.h>
3272 #include <sys/stat.h>
3273 #include <unistd.h>],
3274 [struct stat st;  st.st_blksize = 0;],
3275 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
3276 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
3277     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
3280 AC_CACHE_CHECK([for st_flags in struct stat],
3281         samba_cv_HAVE_STAT_ST_FLAGS,
3282         [
3283             AC_TRY_COMPILE([#include <sys/types.h>
3284 #include <sys/stat.h>
3285 #include <unistd.h>],
3286             [struct stat st;  st.st_flags = 0;],
3287             samba_cv_HAVE_STAT_ST_FLAGS=yes,
3288             samba_cv_HAVE_STAT_ST_FLAGS=no,
3289             samba_cv_HAVE_STAT_ST_FLAGS=cross)
3290         ])
3292 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
3293     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
3294                 [Whether the stat struct has a st_flags member])
3297 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
3298 AC_TRY_COMPILE([
3299 #include <sys/types.h>
3300 #include <sys/acl.h>
3301 #if defined(HAVE_RPCSVC_NIS_H)
3302 #include <rpcsvc/nis.h>
3303 #endif],
3304 [int i;],
3305 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
3306 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
3307         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
3310 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
3311 AC_TRY_RUN([
3312 #include <stdio.h>
3313 #include <limits.h>
3314 #include <signal.h>
3316 void exit_on_core(int ignored) {
3317         exit(1);
3320 main() {
3321         char *newpath;
3322         signal(SIGSEGV, exit_on_core);
3323         newpath = realpath("/tmp", NULL);
3324         exit((newpath != NULL) ? 0 : 1);
3327 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
3328 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
3329     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
3332 #################################################
3333 # check for AFS clear-text auth support
3334 samba_cv_WITH_AFS=no
3335 AC_MSG_CHECKING(whether to use AFS clear-text auth)
3336 AC_ARG_WITH(afs,
3337 [AS_HELP_STRING([--with-afs], [Include AFS clear-text auth support (default=no)])],
3338 [ case "$withval" in
3339   yes|auto)
3340     AC_MSG_RESULT($withval)
3341     samba_cv_WITH_AFS=$withval
3342     ;;
3343   *)
3344     AC_MSG_RESULT(no)
3345     ;;
3346   esac ],
3347   AC_MSG_RESULT(no)
3350 ####################################################
3351 # check for Linux-specific AFS fake-kaserver support
3352 samba_cv_WITH_FAKE_KASERVER=no
3353 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3354 AC_ARG_WITH(fake-kaserver,
3355 [AS_HELP_STRING([--with-fake-kaserver], [Include AFS fake-kaserver support (default=no)])],
3356 [ case "$withval" in
3357   yes|auto)
3358     AC_MSG_RESULT($withval)
3359     samba_cv_WITH_FAKE_KASERVER=$withval
3360     ;;
3361   *)
3362     AC_MSG_RESULT(no)
3363     ;;
3364   esac ],
3365   AC_MSG_RESULT(no)
3368 #################################################
3369 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3370 if test x"$samba_cv_WITH_AFS" != x"no" ||
3371    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3373     # see if this box has the OpenSSL DES libraries
3374     AC_CHECK_LIB( crypto, DES_pcbc_encrypt, LIBS="$LIBS -lcrypto" , [AC_ERROR(OpenSSL library: libcrypto ot found!)] )
3376     # see if this box has the afs-headers in /usr/include/afs
3377     AC_MSG_CHECKING(for /usr/include/afs)
3378     if test -d /usr/include/afs; then
3379           AC_MSG_RESULT(yes)
3380     else
3381       AC_MSG_RESULT(no)
3382     fi
3384     # check for afs.h
3385     have_afs_headers=no
3386     AC_CHECK_HEADERS(afs.h afs/afs.h)
3387     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3388         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3389            test x"$samba_cv_WITH_AFS" = x"auto"; then
3390                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3391         else
3392                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3393         fi
3394     else
3395         have_afs_headers=yes
3396     fi
3399 FAKE_KASERVER_OBJ=""
3400 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3401     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3402     FAKE_KASERVER_OBJ="utils/net_afs.o"
3404 AC_SUBST(FAKE_KASERVER_OBJ)
3406 #################################################
3407 # check whether to compile AFS/NT ACL mapping module
3408 samba_cv_WITH_VFS_AFSACL=no
3409 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
3410 AC_ARG_WITH(vfs-afsacl,
3411 [AS_HELP_STRING([--with-vfs-afsacl], [Include AFS to NT ACL mapping module (default=no)])],
3412 [ case "$withval" in
3413   yes|auto)
3414     AC_MSG_RESULT($withval)
3415     samba_cv_WITH_VFS_AFSACL=yes
3416     ;;
3417   *)
3418     AC_MSG_RESULT(no)
3419     ;;
3420   esac ],
3421   AC_MSG_RESULT(no)
3424 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3425    default_shared_modules="$default_shared_modules vfs_afsacl"
3427         
3428 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3429     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3432 #################################################
3433 # check for the DFS clear-text auth system
3434 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3435 AC_ARG_WITH(dfs,
3436 [AS_HELP_STRING([--with-dce-dfs], [Include DCE/DFS clear-text auth support (default=no)])],
3437 [ case "$withval" in
3438   yes)
3439     AC_MSG_RESULT(yes)
3440     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3441     ;;
3442   *)
3443     AC_MSG_RESULT(no)
3444     ;;
3445   esac ],
3446   AC_MSG_RESULT(no)
3449 ########################################################
3450 # Compile with LDAP support?
3452 with_ldap_support=auto
3453 AC_MSG_CHECKING([for LDAP support])
3455 AC_ARG_WITH(ldap,
3456 [AS_HELP_STRING([--with-ldap], [LDAP support (default=auto)])],
3457 [ case "$withval" in
3458     yes|no)
3459         with_ldap_support=$withval
3460         ;;
3461   esac ])
3463 AC_MSG_RESULT($with_ldap_support)
3465 SMBLDAP=""
3466 AC_SUBST(SMBLDAP)
3467 SMBLDAPUTIL=""
3468 AC_SUBST(SMBLDAPUTIL)
3470 if test x"$with_ldap_support" != x"no"; then
3472   ##################################################################
3473   # first test for ldap.h and lber.h
3474   # (ldap.h is required for this test)
3475   AC_CHECK_HEADERS(ldap.h lber.h)
3477   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3478         if test x"$with_ldap_support" = x"yes"; then
3479          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3480         else
3481          AC_MSG_WARN(ldap.h is needed for LDAP support)
3482         fi
3483         
3484         with_ldap_support=no
3485   fi
3487   ##################################################################
3488   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
3489   # unsigned int in include/includes.h
3490   case $host_os in
3491         *hpux*)
3492          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3493          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
3494         with_ldap_support=yes
3495         ;;
3496         *)
3497         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3498         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3499                 if test x"$with_ldap_support" = x"yes"; then
3500                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3501                 else
3502                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3503                 fi
3504                 with_ldap_support=no
3505         fi
3506         ;;
3507   esac
3510 if test x"$with_ldap_support" != x"no"; then
3511   ac_save_LIBS=$LIBS
3513   ##################################################################
3514   # we might need the lber lib on some systems. To avoid link errors
3515   # this test must be before the libldap test
3516   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3518   ########################################################
3519   # If ber_sockbuf_add_io() is available we can add
3520   # SASL wrapping hooks
3521   AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
3523   AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
3524                  AC_TRY_COMPILE([#include <ldap.h>],
3525                                 [int val = LDAP_OPT_SOCKBUF;],
3526                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
3527                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
3529   if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
3530           x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
3531         AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
3532   fi
3534   #######################################################
3535   # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
3536   # ldap logging and print it out in the samba logs
3537   AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
3538                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
3539                  [AC_TRY_COMPILE([#include <lber.h>],
3540                                  [int val = LBER_OPT_LOG_PRINT_FN;],
3541                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
3542                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
3544   if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
3545         AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
3546                   [Support for LDAP/LBER logging interception])
3547   fi
3549   ########################################################
3550   # now see if we can find the ldap libs in standard paths
3551   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3553   ########################################################
3554   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3555   # Check found in pam_ldap 145.
3556   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3558   LIBS="$LIBS $LDAP_LIBS"
3559   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3560     AC_TRY_COMPILE([
3561         #include <lber.h>
3562         #include <ldap.h>],
3563         [ldap_set_rebind_proc(0, 0, 0);],
3564         [smb_ldap_cv_ldap_set_rebind_proc=3],
3565         [smb_ldap_cv_ldap_set_rebind_proc=2]
3566     )
3567   ])
3569   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3571   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3573   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3574     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3575     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3576     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3577     default_shared_modules="$default_shared_modules";
3578     SMBLDAP="lib/smbldap.o"
3579     SMBLDAPUTIL="lib/smbldap_util.o"
3580     with_ldap_support=yes
3581     AC_MSG_CHECKING(whether LDAP support is used)
3582     AC_MSG_RESULT(yes)
3583   else
3584     if test x"$with_ldap_support" = x"yes"; then
3585         AC_MSG_ERROR(libldap is needed for LDAP support)
3586     else
3587         AC_MSG_WARN(libldap is needed for LDAP support)
3588     fi
3590     LDAP_LIBS=""
3591     with_ldap_support=no
3592   fi
3593   LIBS=$ac_save_LIBS
3597 #################################################
3598 # active directory support
3600 with_ads_support=auto
3601 AC_MSG_CHECKING([for Active Directory and krb5 support])
3603 AC_ARG_WITH(ads,
3604 [AS_HELP_STRING([--with-ads], [Active Directory support (default=auto)])],
3605 [ case "$withval" in
3606     yes|no)
3607         with_ads_support="$withval"
3608         ;;
3609   esac ])
3611 AC_MSG_RESULT($with_ads_support)
3613 FOUND_KRB5=no
3614 KRB5_LIBS=""
3616 if test x"$with_ldap_support" != x"yes"; then
3618     if test x"$with_ads_support" = x"yes"; then
3619         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3620     elif test x"$with_ads_support" = x"auto"; then
3621         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3622         with_ads_support=no
3623     fi
3625 else
3627     # Check to see whether there is enough LDAP functionality to be able
3628     # to build AD support.
3630 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3631 case "$host_os" in
3632         *hpux*)
3633     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3635     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3636         if test x"$with_ads_support" = x"yes"; then
3637             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3638         elif test x"$with_ads_support" = x"auto"; then
3639             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3640             with_ads_support=no
3641         fi
3642     fi
3643     ;;
3644         *)
3645     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3647     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3648         if test x"$with_ads_support" = x"yes"; then
3649             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3650         elif test x"$with_ads_support" = x"auto"; then
3651             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3652             with_ads_support=no
3653         fi
3654     fi
3655     ;;
3656 esac
3659     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3661     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3662         if test x"$with_ads_support" = x"yes"; then
3663             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3664         elif test x"$with_ads_support" = x"auto"; then
3665             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3666             with_ads_support=no
3667         fi
3668     fi
3672 if test x"$with_ads_support" != x"no"; then
3674   # Do no harm to the values of CFLAGS and LIBS while testing for
3675   # Kerberos support.
3677   if test x$FOUND_KRB5 = x"no"; then
3678     #################################################
3679     # check for location of Kerberos 5 install
3680     AC_MSG_CHECKING(for kerberos 5 install path)
3681     AC_ARG_WITH(krb5,
3682     [AS_HELP_STRING([--with-krb5=base-dir], [Locate Kerberos 5 support (default=/usr)])],
3683     [ case "$withval" in
3684       no)
3685         AC_MSG_RESULT(no krb5-path given)
3686         ;;
3687       yes)
3688         AC_MSG_RESULT(/usr)
3689         FOUND_KRB5=yes
3690         ;;
3691       *)
3692         AC_MSG_RESULT($withval)
3693         KRB5_CFLAGS="-I$withval/include"
3694         KRB5_CPPFLAGS="-I$withval/include"
3695         KRB5_LDFLAGS="-L$withval/lib"
3696         FOUND_KRB5=yes
3697         if test -x "$withval/bin/krb5-config"; then
3698                 KRB5CONFIG=$withval/bin/krb5-config
3699         fi
3700         ;;
3701       esac ],
3702       AC_MSG_RESULT(no krb5-path given)
3703     )
3704   fi
3706   #################################################
3707   # check for krb5-config from recent MIT and Heimdal kerberos 5
3708   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3709   AC_MSG_CHECKING(for working krb5-config)
3710   if test -x "$KRB5CONFIG" && $KRB5CONFIG --libs gssapi > /dev/null ; then
3711     ac_save_CFLAGS=$CFLAGS
3712     CFLAGS="";export CFLAGS
3713     ac_save_LDFLAGS=$LDFLAGS
3714     LDFLAGS="";export LDFLAGS
3715     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3716     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3717     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3718     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3719     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3720     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3721     FOUND_KRB5=yes
3722     AC_MSG_RESULT(yes)
3723   else
3724     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3725   fi
3727   if test x$FOUND_KRB5 = x"no"; then
3728     #################################################
3729     # see if this box has the SuSE location for the heimdal krb implementation
3730     AC_MSG_CHECKING(for /usr/include/heimdal)
3731     if test -d /usr/include/heimdal; then
3732       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3733           KRB5_CFLAGS="-I/usr/include/heimdal"
3734           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3735           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3736           FOUND_KRB5=yes
3737           AC_MSG_RESULT(yes)
3738       else
3739           KRB5_CFLAGS="-I/usr/include/heimdal"
3740           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3741           FOUND_KRB5=yes
3742           AC_MSG_RESULT(yes)
3743       fi
3744     else
3745       AC_MSG_RESULT(no)
3746     fi
3747   fi
3749   if test x$FOUND_KRB5 = x"no"; then
3750     #################################################
3751     # see if this box has the RedHat location for kerberos
3752     AC_MSG_CHECKING(for /usr/kerberos)
3753     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3754       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3755       KRB5_CFLAGS="-I/usr/kerberos/include"
3756       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3757       FOUND_KRB5=yes
3758       AC_MSG_RESULT(yes)
3759     else
3760       AC_MSG_RESULT(no)
3761     fi
3762   fi
3764   if test x$FOUND_KRB5 = x"no"; then
3765     #################################################
3766     # see if this box has the OpenBSD location for heimdal krb5
3767     AC_MSG_CHECKING(for /usr/include/kerberosV)
3768     if test -d /usr/include/kerberosV; then
3769       KRB5_CPPFLAGS="-I/usr/include/kerberosV"
3770       KRB5_LIBS="-lcrypto"
3771       FOUND_KRB5=yes
3772       AC_MSG_RESULT(yes)
3773     else
3774       AC_MSG_RESULT(no)
3775     fi
3776   fi
3778   ac_save_CFLAGS=$CFLAGS
3779   ac_save_CPPFLAGS=$CPPFLAGS
3780   ac_save_LDFLAGS=$LDFLAGS
3782   # remove needless evil rpath stuff as early as possible:
3783   LIB_REMOVE_USR_LIB(KRB5_LIBS)
3784   LIB_REMOVE_USR_LIB(KRB5_LDFLAGS)
3785   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3786   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3787   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3789   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3791   # now check for krb5.h. Some systems have the libraries without the headers!
3792   # note that this check is done here to allow for different kerberos
3793   # include paths
3794   AC_CHECK_HEADERS(krb5.h)
3796   if test x"$ac_cv_header_krb5_h" = x"no"; then
3798     # Give a warning if AD support was not explicitly requested,
3799     # i.e with_ads_support = auto, otherwise die with an error.
3801     if test x"$with_ads_support" = x"yes"; then
3802       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3803     else
3804       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3805     fi
3807     # Turn off AD support and restore CFLAGS and LIBS variables
3809     with_ads_support="no"
3811     CFLAGS=$ac_save_CFLAGS
3812     CPPFLAGS=$ac_save_CPPFLAGS
3813     LDFLAGS=$ac_save_LDFLAGS
3814   fi
3816   # check for new heimdal KRB5_DEPRECATED handling
3818   AC_CACHE_CHECK([for KRB5_DEPRECATED define taking an identifier],
3819                 samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER,[
3820     AC_TRY_COMPILE(
3821       [#define KRB5_DEPRECATED 1
3822       #include <krb5.h>],
3823       [],
3824       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=yes,
3825       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=no)])
3827   if test x"$samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER" = x"yes"; then
3828     AC_DEFINE(HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER, 1,
3829                [Whether to use deprecated krb5 interfaces])
3830   fi
3833 # Now we have determined whether we really want ADS support
3834 use_ads=no
3835 if test x"$with_ads_support" != x"no"; then
3836   use_ads=yes
3837   have_gssapi=no
3838   ac_save_LIBS=$LIBS
3840   # now check for gssapi headers.  This is also done here to allow for
3841   # different kerberos include paths
3842   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h)
3844   ##################################################################
3845   # we might need the k5crypto and com_err libraries on some systems
3846   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3847   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3849   # Heimdal checks.
3850   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3851   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3852   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3854   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3855   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3857   ########################################################
3858   # now see if we can find the krb5 libs in standard paths
3859   # or as specified above
3860   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3861   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3863   ########################################################
3864   # now see if we can find the gssapi libs in standard paths
3865   if test x"$have_gssapi" != x"yes"; then
3866      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3867      AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
3868   fi
3870   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3871   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3872   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3873   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3874   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3875   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3876   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3877   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3878   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3879   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3880   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3881   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3882   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3883   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3884   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3885   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3886   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3887   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3888   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3889   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3890   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3891   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3892   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3893   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3894   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3895   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3896   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3897   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3898   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3899   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3900   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3901   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3902   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3903   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3904   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3905   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3906   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3907   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3908   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3909   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3910   AC_CHECK_FUNC_EXT(krb5_fwd_tgt_creds, $KRB5_LIBS)
3911   AC_CHECK_FUNC_EXT(krb5_auth_con_set_req_cksumtype, $KRB5_LIBS)
3912   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_alloc, $KRB5_LIBS)
3913   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_set_impersonate, $KRB5_LIBS)
3914   AC_CHECK_FUNC_EXT(krb5_get_creds, $KRB5_LIBS)
3915   AC_CHECK_FUNC_EXT(krb5_get_credentials_for_user, $KRB5_LIBS)
3916   AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS)
3917   AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS)
3918   AC_CHECK_FUNC_EXT(gss_get_name_attribute, $KRB5_LIBS)
3920   # MIT krb5 1.8 does not expose this call (yet)
3921   AC_CHECK_DECLS(krb5_get_credentials_for_user, [], [], [#include <krb5.h>])
3923   # MIT krb5 1.7beta3 (in Ubuntu Karmic) does not have this declaration
3924   # but does have the symbol
3925   AC_CHECK_DECLS(krb5_auth_con_set_req_cksumtype, [], [], [#include <krb5.h>])
3927   LIBS="$KRB5_LIBS $LIBS"
3929   AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
3930         smb_krb5_cv_ticket_has_keyinfo,
3931         [
3932             AC_TRY_COMPILE(
3933             [
3934                 #include <krb5.h>
3935             ],
3936             [
3937                 krb5_ticket ticket;
3938                 krb5_kvno kvno;
3939                 krb5_enctype enctype;
3941                 enctype = ticket.enc_part.enctype;
3942                 kvno = ticket.enc_part.kvno;
3943             ],
3944             [ smb_krb5_cv_ticket_has_keyinfo=yes ],
3945             [ smb_krb5_cv_ticket_has_keyinfo=no ])
3946         ])
3948   if test x"$smb_krb5_cv_ticket_has_keyinfo" = x"yes" ; then
3949         AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
3950             [Whether the krb5_ticket structure contains the kvno and enctype])
3951   fi
3953   AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
3954           smb_krb5_cv_creds_opt_free_context,
3955           [
3956                 AC_TRY_COMPILE([
3957                     #include <krb5.h>],
3958                     [
3959                         krb5_context ctx;
3960                         krb5_get_init_creds_opt *opt = NULL;
3961                         krb5_get_init_creds_opt_free(ctx, opt);
3962                     ],
3963                     [smb_krb5_cv_creds_opt_free_context=yes],
3964                     [smb_krb5_cv_creds_opt_free_context=no]
3965                 )
3966           ])
3968   if test x"$smb_krb5_cv_creds_opt_free_context" = x"yes" ; then
3969         AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
3970             [Whether krb5_get_init_creds_opt_free takes a context argument])
3971   fi
3973   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_cv_verify_checksum, [
3974     AC_TRY_COMPILE([
3975         #include <krb5.h>],
3976         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
3977         [smb_krb5_cv_verify_checksum=7],
3978         [smb_krb5_cv_verify_checksum=6],
3979     )
3980   ])
3981   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_cv_verify_checksum, [Number of arguments to krb5_verify_checksum])
3983   AC_CACHE_CHECK([for checksum in krb5_checksum],
3984                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3985     AC_TRY_COMPILE([#include <krb5.h>],
3986       [krb5_checksum cksum; cksum.checksum.length = 0;],
3987       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3988       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3990   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3991     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3992                [Whether the krb5_checksum struct has a checksum property])
3993   fi
3995   AC_CACHE_CHECK([for etype in EncryptedData],
3996                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3997     AC_TRY_COMPILE([#include <krb5.h>],
3998       [EncryptedData edata; edata.etype = 0;],
3999       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
4000       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
4002   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
4003     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
4004                [Whether the EncryptedData struct has a etype property])
4005   fi
4007   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
4008                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
4009     AC_TRY_COMPILE([#include <krb5.h>],
4010       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
4011       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
4012       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
4014   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
4015     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
4016                [Whether the krb5_ap_req struct has a ticket pointer])
4017   fi
4019   AC_CACHE_CHECK([for e_data pointer in krb5_error],
4020                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
4021     AC_TRY_COMPILE([#include <krb5.h>],
4022       [krb5_error err; err.e_data = NULL;],
4023       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
4024       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
4026   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
4027     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
4028                [Whether the krb5_error struct has a e_data pointer])
4029   fi
4031   AC_CACHE_CHECK([for krb5_crypto type],
4032                 samba_cv_HAVE_KRB5_CRYPTO,[
4033     AC_TRY_COMPILE([#include <krb5.h>],
4034       [krb5_crypto crypto;],
4035       samba_cv_HAVE_KRB5_CRYPTO=yes,
4036       samba_cv_HAVE_KRB5_CRYPTO=no)])
4038   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
4039     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
4040                [Whether the type krb5_crypto exists])
4041   fi
4043   AC_CACHE_CHECK([for krb5_encrypt_block type],
4044                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
4045     AC_TRY_COMPILE([#include <krb5.h>],
4046       [krb5_encrypt_block block;],
4047       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
4048       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
4050   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
4051     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
4052                [Whether the type krb5_encrypt_block exists])
4053   fi
4055   AC_CACHE_CHECK([for addrtype in krb5_address],
4056                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
4057     AC_TRY_COMPILE([#include <krb5.h>],
4058       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
4059       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
4060       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
4062   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
4063     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
4064                [Whether the krb5_address struct has a addrtype property])
4065   fi
4067   AC_CACHE_CHECK([for addr_type in krb5_address],
4068                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
4069     AC_TRY_COMPILE([#include <krb5.h>],
4070       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
4071       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
4072       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
4074   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
4075     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
4076               [Whether the krb5_address struct has a addr_type property])
4077   fi
4079   AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
4080                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
4081                  [AC_TRY_COMPILE([#include <krb5.h>],
4082     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
4083     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
4085   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
4086     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
4087               [Whether the krb5_ticket struct has a enc_part2 property])
4088   fi
4090   AC_CACHE_CHECK([for keyblock in krb5_creds],
4091                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
4092     AC_TRY_COMPILE([#include <krb5.h>],
4093       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
4094       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
4095       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
4097   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
4098     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
4099               [Whether the krb5_creds struct has a keyblock property])
4100   fi
4102   AC_CACHE_CHECK([for session in krb5_creds],
4103                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
4104     AC_TRY_COMPILE([#include <krb5.h>],
4105       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
4106       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
4107       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
4109   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
4110     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
4111               [Whether the krb5_creds struct has a session property])
4112   fi
4114   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
4115                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
4116     AC_TRY_COMPILE([#include <krb5.h>],
4117       [krb5_keyblock key; key.keyvalue.data = NULL;],
4118       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
4119       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
4121   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
4122     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
4123               [Whether the krb5_keyblock struct has a keyvalue property])
4124   fi
4126   found_arcfour_hmac=no
4127   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
4128                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
4129     AC_TRY_COMPILE([#include <krb5.h>],
4130       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
4131       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
4132       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
4133   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
4134                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
4135     AC_TRY_COMPILE([#include <krb5.h>],
4136       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
4137       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
4138       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
4139 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
4140 # w.r.t. arcfour and windows, so we must not enable it here
4141   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
4142           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
4143     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
4144               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available])
4145     found_arcfour_hmac=yes
4146   fi
4147   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC],
4148                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC,[
4149     AC_TRY_COMPILE([#include <krb5.h>],
4150       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC;],
4151       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC=yes,
4152       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC=no)])
4153   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC" = x"yes"; then
4154     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC,1,
4155               [Whether the ENCTYPE_ARCFOUR_HMAC key type definition is available])
4156     found_arcfour_hmac=yes
4157   fi
4159   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
4160                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
4161     AC_TRY_COMPILE([#include <krb5.h>],
4162       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
4163       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
4164       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
4166   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
4167     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
4168               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
4169   fi
4171   AC_CACHE_CHECK([for KV5M_KEYTAB],
4172                  samba_cv_HAVE_KV5M_KEYTAB,[
4173     AC_TRY_COMPILE([#include <krb5.h>],
4174       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
4175       samba_cv_HAVE_KV5M_KEYTAB=yes,
4176       samba_cv_HAVE_KV5M_KEYTAB=no)])
4178   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
4179       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
4180              [Whether the KV5M_KEYTAB option is available])
4181   fi
4183   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
4184                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
4185     AC_TRY_COMPILE([#include <krb5.h>],
4186       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
4187       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
4188       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
4190   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
4191     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
4192               [Whether KRB5_KU_OTHER_CKSUM is available])
4193   fi
4195   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
4196                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
4197     AC_TRY_COMPILE([#include <krb5.h>],
4198       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
4199       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
4200       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
4202   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
4203     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
4204               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
4205   fi
4207   AC_CACHE_CHECK([for the krb5_princ_component macro],
4208                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
4209     AC_TRY_LINK([#include <krb5.h>],
4210       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
4211       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
4212       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
4214   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
4215     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
4216                [Whether krb5_princ_component is available])
4217   fi
4219   AC_CACHE_CHECK([for key in krb5_keytab_entry],
4220                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
4221     AC_TRY_COMPILE([#include <krb5.h>],
4222       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
4223       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
4224       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
4226   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
4227     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
4228               [Whether krb5_keytab_entry has key member])
4229   fi
4231   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
4232                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
4233     AC_TRY_COMPILE([#include <krb5.h>],
4234       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
4235       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
4236       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
4238   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
4239     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
4240               [Whether krb5_keytab_entry has keyblock member])
4241   fi
4243   AC_CACHE_CHECK([for magic in krb5_address],
4244                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
4245     AC_TRY_COMPILE([#include <krb5.h>],
4246       [krb5_address addr; addr.magic = 0;],
4247       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
4248       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
4250   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
4251     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
4252               [Whether the krb5_address struct has a magic property])
4253   fi
4255   AC_CACHE_CHECK([for WRFILE: keytab support],
4256                 samba_cv_HAVE_WRFILE_KEYTAB,[
4257     AC_TRY_RUN([
4258 #include<krb5.h>
4259   main()
4260   {
4261     krb5_context context;
4262     krb5_keytab keytab;
4264     krb5_init_context(&context);
4265     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
4266   }],
4267   samba_cv_HAVE_WRFILE_KEYTAB=yes,
4268   samba_cv_HAVE_WRFILE_KEYTAB=no)])
4270   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
4271       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
4272                [Whether the WRFILE:-keytab is supported])
4273   fi
4275   AC_CACHE_CHECK([for krb5_realm type],
4276                 samba_cv_HAVE_KRB5_REALM_TYPE,[
4277     AC_TRY_COMPILE([#include <krb5.h>],
4278       [krb5_realm realm;],
4279       samba_cv_HAVE_KRB5_REALM_TYPE=yes,
4280       samba_cv_HAVE_KRB5_REALM_TYPE=no)])
4282   if test x"$samba_cv_HAVE_KRB5_REALM_TYPE" = x"yes"; then
4283     AC_DEFINE(HAVE_KRB5_REALM_TYPE,1,
4284                [Whether the type krb5_realm exists])
4285   fi
4287   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
4288                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
4289     AC_TRY_COMPILE([#include <krb5.h>],
4290     [
4291     krb5_context context;
4292     krb5_principal principal;
4293     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
4294     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
4295     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
4297   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
4298     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
4299               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
4300   fi
4302   AC_CACHE_CHECK([for krb5_addresses type],
4303                 samba_cv_HAVE_KRB5_ADDRESSES,[
4304     AC_TRY_COMPILE([#include <krb5.h>],
4305       [krb5_addresses addr;],
4306       samba_cv_HAVE_KRB5_ADDRESSES=yes,
4307       samba_cv_HAVE_KRB5_ADDRESSES=no)])
4309   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
4310     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
4311                [Whether the type krb5_addresses type exists])
4312   fi
4314   AC_CACHE_CHECK([whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal],
4315                 samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE, [
4316     AC_TRY_COMPILE([#include <krb5.h>],
4317     [
4318     krb5_mk_error(0,0,0);],
4319     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=yes,
4320     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=no)])
4322   if test x"$samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE" = x"yes"; then
4323     AC_DEFINE(HAVE_SHORT_KRB5_MK_ERROR_INTERFACE,1,
4324               [whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal])
4325   fi
4327   if test x"$ac_cv_func_ext_krb5_enctype_to_string" = x"yes"; then
4328     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_context context, krb5_enctype enctype, char **str)],
4329         smb_krb5_cv_enctype_to_string_takes_krb5_context_arg,[
4330         AC_TRY_RUN_STRICT([
4331                 #include <stdlib.h>
4332                 #include <krb5.h>
4333                 int main(void) {
4334                         krb5_context context = NULL;
4335                         char *str = NULL;
4336                         krb5_enctype_to_string(context, 1, &str);
4337                         if (str) free (str); 
4338                         return 0;
4339                 }
4340                 ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4341                 smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=yes,
4342                 smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=no)])
4344     if test x"$smb_krb5_cv_enctype_to_string_takes_krb5_context_arg" = x"yes"; then
4345       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG,1,
4346                 [whether krb5_enctype_to_string takes krb5_context argument])
4347     fi
4349     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_enctype enctype, char *str, size_t len)],
4350         smb_krb5_cv_enctype_to_string_takes_size_t_arg,[
4351         AC_TRY_RUN_STRICT([
4352                 #include <krb5.h>
4353                 int main(void) {
4354                         char buf[256];
4355                         krb5_enctype_to_string(1, buf, 256);
4356                         return 0;
4357                 }
4358                 ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4359                 smb_krb5_cv_enctype_to_string_takes_size_t_arg=yes,
4360                 smb_krb5_cv_enctype_to_string_takes_size_t_arg=no)])
4362     if test x"$smb_krb5_cv_enctype_to_string_takes_size_t_arg" = x"yes"; then
4363       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG,1,
4364                 [whether krb5_enctype_to_string takes size_t argument])
4365     fi
4366   fi
4368   AC_CACHE_CHECK([for krb5_principal_get_realm],
4369                 samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
4370     AC_TRY_LINK([#include <krb5.h>],
4371       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
4372       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
4373       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
4375   if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
4376     AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
4377                [Whether the function krb5_principal_get_realm is defined])
4378   fi
4380   AC_CACHE_CHECK([for krb5_princ_realm],
4381                 samba_cv_HAVE_KRB5_PRINC_REALM,[
4382     AC_TRY_LINK([#include <krb5.h>],
4383       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
4384       samba_cv_HAVE_KRB5_PRINC_REALM=yes,
4385       samba_cv_HAVE_KRB5_PRINC_REALM=no)])
4387   if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
4388     AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
4389                [Whether the macro krb5_princ_realm is defined])
4390   fi
4392   #
4393   #
4394   # Now the decisions whether we can support krb5
4395   #
4396   # NOTE: all tests should be done before this block!
4397   #
4398   #
4399   if test x"$found_arcfour_hmac" != x"yes"; then
4400     AC_MSG_WARN(arcfour-hmac-md5 encryption type not found in -lkrb5)
4401     use_ads=no
4402   fi
4404   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
4405     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
4406     use_ads=no
4407   fi
4409   if test x"$ac_cv_func_ext_krb5_principal2salt" != x"yes" -a \
4410           x"$ac_cv_func_ext_krb5_get_pw_salt" != x"yes"
4411   then
4412     AC_MSG_WARN(no CREATE_KEY_FUNCTIONS detected)
4413     use_ads=no
4414   fi
4416   if test x"$ac_cv_func_ext_krb5_get_permitted_enctypes" != x"yes" -a \
4417           x"$ac_cv_func_ext_krb5_get_default_in_tkt_etypes" != x"yes"
4418   then
4419     AC_MSG_WARN(no GET_ENCTYPES_FUNCTIONS detected)
4420     use_ads=no
4421   fi
4423   if test x"$ac_cv_func_ext_krb5_kt_free_entry" != x"yes" -a \
4424           x"$ac_cv_func_ext_krb5_free_keytab_entry_contents" != x"yes"
4425   then
4426     AC_MSG_WARN(no KT_FREE_FUNCTION detected)
4427     use_ads=no
4428   fi
4430   if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes" -a \
4431           x"$ac_cv_func_ext_krb5_verify_checksum" != x"yes"
4432   then
4433     AC_MSG_WARN(no KRB5_VERIFY_CHECKSUM_FUNCTION detected)
4434     use_ads=no
4435   fi
4437   if test x"$smb_krb5_cv_ticket_has_keyinfo" != x"yes" ; then
4439       # We only need the following functions if we can't get the enctype
4440       # and kvno out of the ticket directly (ie. on Heimdal).
4442       if test x"$ac_cv_func_ext_free_AP_REQ" != x"yes"
4443       then
4444         AC_MSG_WARN(no KRB5_AP_REQ_FREE_FUNCTION detected)
4445         use_ads=no
4446       fi
4448       if test x"$ac_cv_func_ext_krb5_decode_ap_req" != x"yes"
4449       then
4450         AC_MSG_WARN(no KRB5_AP_REQ_DECODING_FUNCTION detected)
4451         use_ads=no
4452       fi
4454   fi
4456   if test x"$use_ads" = x"yes"; then
4457     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
4458     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
4459     if test x"$have_gssapi" = x"yes"; then
4460       AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
4461     fi
4462   else
4463     if test x"$with_ads_support" = x"yes"; then
4464         AC_MSG_ERROR(krb5 libs don't have all features required for Active Directory support)
4465     else
4466         AC_MSG_WARN(krb5 libs don't have all features required for Active Directory support)
4467     fi
4468     AC_REMOVE_DEFINE(HAVE_KRB5_H)
4469     AC_REMOVE_DEFINE(HAVE_GSSAPI_H)
4470     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4471     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_H)
4472     KRB5_LIBS=""
4473     with_ads_support=no
4474   fi
4475   AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
4476   AC_MSG_RESULT([$use_ads])
4478 LIBS="$ac_save_LIBS"
4481 if test x"$use_ads" != xyes; then
4482         smbtorture4_possible=no
4485 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
4486 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
4489 ########################################################
4490 # Compile with DNS Updates support?
4492 with_dnsupdate_support=auto
4493 AC_MSG_CHECKING([whether to enable DNS Updates support])
4495 AC_ARG_WITH(dnsupdate,
4496 [AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default=auto)])],
4497 [ case "$withval" in
4498     yes|no)
4499         with_dnsupdate_support=$withval
4500         ;;
4501   esac ])
4503 AC_MSG_RESULT($with_dnsupdate_support)
4505 if test x"$with_dnsupdate_support" != x"no"; then
4507   ################################################################
4508   # first test for AD / GSSAPI support being enabled
4509         if test x"$have_gssapi" != xyes ; then
4510                 if test x"$with_dnsupdate_support" = x"yes" ; then
4511                         AC_MSG_ERROR(DNS Updates support only possible with AD and GSSAPI support)
4512                 else
4513                         AC_MSG_NOTICE(DNS Updates support only possible with AD and GSSAPI support)
4514                         with_dnsupdate_support=no
4515                 fi
4516         fi
4517   ##################################################################
4518   # then test for uuid.h (necessary to generate unique DNS keynames
4519   # (uuid.h is required for this test)
4520         AC_CHECK_HEADERS(uuid/uuid.h)
4522         
4523         if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
4524                 if test x"$with_dnsupdate_support" = x"yes"; then
4525                         AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
4526                 else
4527                         AC_MSG_NOTICE(uuid.h is needed to enable DNS Updates support)
4528                 fi
4529                 with_dnsupdate_support=no
4530         fi
4533 if test x"$with_dnsupdate_support" != x"no"; then
4535   ########################################################
4536   # Now see if we can find the uuid libs in standard paths
4537   # On some systems, the uuid API is in libc, so we have to
4538   # be careful not to insert a spurious -luuid.
4540   UUID_LIBS=""
4541   AC_LIBTESTFUNC(uuid, uuid_generate,
4542           [
4543             case " $LIBS " in
4544                 *\ -luuid\ *)
4545                 UUID_LIBS="-luuid"
4546                 SMB_REMOVE_LIB(uuid)
4547                 ;;
4548             esac
4550             with_dnsupdate_support=yes
4551             AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
4552         ],
4553         [
4554             if test x"$with_dnsupdate_support" = x"yes"; then
4555                 AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
4556             else
4557                 AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
4558             fi
4559             with_dnsupdate_support=no
4560         ])
4562   # finally print out the result:
4563 AC_MSG_CHECKING(whether DNS Updates support is used)
4564 AC_MSG_RESULT([$with_dnsupdate_support])
4567 #################################################
4568 # check for automount support
4569 AC_MSG_CHECKING(whether to use automount)
4570 AC_ARG_WITH(automount,
4571 [AS_HELP_STRING([--with-automount], [Include automount support (default=no)])],
4572 [ case "$withval" in
4573   yes)
4574     AC_MSG_RESULT(yes)
4575     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
4576     ;;
4577   *)
4578     AC_MSG_RESULT(no)
4579     ;;
4580   esac ],
4581   AC_MSG_RESULT(no)
4584 #################################################
4585 # Check for a PAM clear-text auth, accounts, password
4586 # and session support. Most PAM implementations keep their
4587 # headers in /usr/include/security. Darwin keeps its in
4588 # /usr/include/pam.
4590 with_pam_for_crypt=no
4591 try_pam=auto
4592 AC_MSG_CHECKING(whether to try PAM support)
4593 AC_ARG_WITH(pam,
4594 [AS_HELP_STRING([--with-pam], [Include PAM support (default=auto)])],
4595 [ case "$withval" in
4596   yes|no|auto)
4597     try_pam=$withval
4598     ;;
4599   esac
4601 AC_MSG_RESULT([$try_pam])
4603 use_pam=no
4604 create_pam_modules=no
4605 if test x"${try_pam}" != x"no";then
4606         use_pam=yes
4607         create_pam_modules=yes
4609         # Most systems have PAM headers in /usr/include/security, but Darwin
4610         # has them in /usr/include/pam.
4611         AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
4612         if test x"$ac_cv_header_security_pam_appl_h" != x"yes" -a \
4613                 x"$ac_cv_header_pam_pam_appl_h" != x"yes"; then
4614                 if test x"${try_pam}" = x"yes";then
4615                         AC_MSG_ERROR([--with-pam=yes but pam_appl.h not found])
4616                 fi
4617                 use_pam=no
4618                 create_pam_modules=no
4619         fi
4621         AC_CHECK_LIB_EXT(pam, PAM_LIBS, pam_get_data)
4622         if test x"$ac_cv_lib_ext_pam_pam_get_data" != x"yes"; then
4623                 if test x"${try_pam}" = x"yes";then
4624                         AC_MSG_ERROR([--with-pam=yes but libpam not found])
4625                 fi
4626                 use_pam=no
4627                 create_pam_modules=no
4628         fi
4630         AC_CHECK_HEADERS(security/pam_modules.h pam/pam_modules.h,,,[[
4631                 #if HAVE_SECURITY_PAM_APPL_H
4632                 #include <security/pam_appl.h>
4633                 #endif
4634                 #if HAVE_PAM_PAM_APPL_H
4635                 #include <pam/pam_appl.h>
4636                 #endif
4637         ]])
4638         if test x"$ac_cv_header_security_pam_modules_h" = x"no" -a \
4639                 x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
4640                 if test x"${try_pam}" = x"yes";then
4641                         AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
4642        fi
4643                 create_pam_modules=no
4644     fi
4646         if test x"$use_pam" = x"yes"; then
4647     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
4648                 AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
4649                 AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
4650     with_pam_for_crypt=yes
4652                 if test x"$create_pam_modules" = x"yes"; then
4653                         AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
4654                         # this checks are optional,
4655                         # we don't care about the results here
4656                         AC_CHECK_HEADERS(security/pam_ext.h security/_pam_macros.h)
4657                         AC_CHECK_HEADERS(pam/pam_ext.h pam/_pam_macros.h)
4658                         AC_CHECK_FUNC_EXT(pam_vsyslog,$PAM_LIBS)
4659                 else
4660                         AC_MSG_WARN([PAM support detected but PAM MODULES support is missing])          
4661                 fi
4662         fi
4663         AC_MSG_CHECKING(whether to use PAM support)
4664         AC_MSG_RESULT([$use_pam])
4666         AC_MSG_CHECKING(whether to have PAM MODULES support)
4667         AC_MSG_RESULT([$create_pam_modules])
4669         AC_TRY_COMPILE([
4670                 #if defined(HAVE_SECURITY_PAM_APPL_H)
4671                 #include <security/pam_appl.h>
4672                 #elif defined(HAVE_PAM_PAM_APPL_H)
4673                 #include <pam/pam_appl.h>
4674                 #endif],[
4675                 pam_set_item(0, PAM_RHOST, 0);
4676                 ],
4677                 AC_DEFINE(HAVE_PAM_RHOST, 1,
4678                           [Define to 1 if PAM_RHOST is available]),[])
4680         AC_TRY_COMPILE([
4681                 #if defined(HAVE_SECURITY_PAM_APPL_H)
4682                 #include <security/pam_appl.h>
4683                 #elif defined(HAVE_PAM_PAM_APPL_H)
4684                 #include <pam/pam_appl.h>
4685                 #endif],[
4686                 pam_set_item(0, PAM_TTY, 0);
4687                 ],
4688                 AC_DEFINE(HAVE_PAM_TTY, 1,
4689                           [Define to 1 if PAM_TTY is available]),[])
4691 fi # try_pam != no
4693 #################################################
4694 # check for PAM_RADIO_TYPE
4695 AC_TRY_COMPILE([
4696 #if (!defined(LINUX))
4698 #define PAM_EXTERN extern
4699 #if defined(HAVE_SECURITY_PAM_APPL_H)
4700 #include <security/pam_appl.h>
4701 #elif defined(HAVE_PAM_PAM_APPL_H)
4702 #include <pam/pam_appl.h>
4703 #endif
4705 #endif
4707 #if defined(HAVE_SECURITY_PAM_MODULES_H)
4708 #include <security/pam_modules.h>
4709 #elif defined(HAVE_PAM_PAM_MODULES_H)
4710 #include <pam/pam_modules.h>
4711 #endif
4713 #if defined(HAVE_SECURITY__PAM_MACROS_H)
4714 #include <security/_pam_macros.h>
4715 #elif defined(HAVE_PAM__PAM_MACROS_H)
4716 #include <pam/_pam_macros.h>
4717 #endif
4719 #ifdef HAVE_SECURITY_PAM_EXT_H
4720 #include <security/pam_ext.h>
4721 #endif
4723 [int i; i = PAM_RADIO_TYPE; ],
4724 AC_DEFINE(HAVE_PAM_RADIO_TYPE, 1, [Define to 1 if PAM_RADIO_TYPE is available]),[])
4726 #################################################
4727 # check for pam_smbpass support
4728 PAM_MODULES=""
4729 INSTALL_PAM_MODULES=""
4730 UNINSTALL_PAM_MODULES=""
4732 try_pam_smbpass=auto
4733 AC_MSG_CHECKING(whether to use pam_smbpass)
4734 AC_ARG_WITH(pam_smbpass,
4735 [AS_HELP_STRING([--with-pam_smbpass], [Build PAM module for authenticating against passdb backends (default=auto)])],
4736 [ case "$withval" in
4737   yes|no|auto)
4738     try_pam_smbpass=$withval
4739   ;;
4740   *)
4741     AC_MSG_ERROR([valid options are yes,no,auto])
4742   ;;
4743   esac
4746 if test x"${try_pam_smbpass}" = xno ; then
4747         use_pam_smbpass=no
4748 else
4749         use_pam_smbpass=yes
4750         # Conditions under which pam_smbpass can't be built.
4751         if test x"$BLDSHARED" != xtrue ; then
4752                 if test x"${try_pam_smbpass}" = xyes ; then
4753                         AC_MSG_ERROR([No support for shared modules])
4754                 fi
4755                 use_pam_smbpass=no
4756         elif test x"$create_pam_modules" != xyes ; then
4757                 if test x"${try_pam_smbpass}" = xyes ; then
4758                         AC_MSG_ERROR([No support for PAM MODULES])
4759                 fi
4760                 use_pam_smbpass=no
4761         fi
4763         if test x"${use_pam_smbpass}" = xyes ; then 
4764                 PAM_MODULES="pam_smbpass"
4765                 INSTALL_PAM_MODULES="installpammodules"
4766                 UNINSTALL_PAM_MODULES="uninstallpammodules"
4767         fi
4769 AC_MSG_RESULT([$use_pam_smbpass])
4773 ## moved after the check for -lcrypt in order to
4774 ## ensure that the necessary libraries are included
4775 ## check checking for truncated salt.  Wrapped by the
4776 ## $with_pam_for_crypt variable as above   --jerry
4778 if test $with_pam_for_crypt = no; then
4779 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
4780 crypt_LIBS="$LIBS"
4781 LIBS="$AUTH_LIBS $LIBS"
4782 AC_TRY_RUN([#include "${srcdir-.}/../tests/crypttest.c"],
4783         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
4784 LIBS="$crypt_LIBS"])
4785 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
4786         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
4790 #################################################
4791 # check for a NISPLUS_HOME support
4792 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
4793 AC_ARG_WITH(nisplus-home,
4794 [AS_HELP_STRING([--with-nisplus-home], [Include NISPLUS_HOME support (default=no)])],
4795 [ case "$withval" in
4796   yes)
4797     AC_MSG_RESULT(yes)
4798     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
4799     ;;
4800   *)
4801     AC_MSG_RESULT(no)
4802     ;;
4803   esac ],
4804   AC_MSG_RESULT(no)
4807 #################################################
4808 # check for syslog logging
4809 AC_MSG_CHECKING(whether to use syslog logging)
4810 AC_ARG_WITH(syslog,
4811 [AS_HELP_STRING([--with-syslog], [Include experimental SYSLOG support (default=no)])],
4812 [ case "$withval" in
4813   yes)
4814     AC_MSG_RESULT(yes)
4815     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
4816     ;;
4817   *)
4818     AC_MSG_RESULT(no)
4819     ;;
4820   esac ],
4821   AC_MSG_RESULT(no)
4824 #################################################
4825 # check for custom syslog facility
4826 AC_MSG_CHECKING(whether to use a custom syslog facility)
4827 AC_ARG_WITH(syslog-facility,
4828 [AS_HELP_STRING([--with-syslog-facility], [Use a custom syslog facility (default=none)])],
4830   if test "$withval" = "no" ; then
4831     AC_MSG_ERROR([argument to --with-syslog-facility must be a string])
4832   else
4833      if test "$withval" != "yes" ; then
4834         syslog_facility="$withval"
4835         AC_DEFINE_UNQUOTED(SYSLOG_FACILITY,$syslog_facility, [syslog facility to log to])
4836      fi
4837   fi
4840 #################################################
4841 # check for experimental disk-quotas support
4843 samba_cv_WITH_QUOTAS=auto
4844 samba_cv_TRY_QUOTAS=no
4845 samba_cv_RUN_QUOTA_TESTS=auto
4846 samba_cv_WITH_SYS_QUOTAS=auto
4847 samba_cv_TRY_SYS_QUOTAS=auto
4848 samba_cv_SYSQUOTA_FOUND=no
4850 AC_MSG_CHECKING(whether to try disk-quotas support)
4851 AC_ARG_WITH(quotas,
4852 [AS_HELP_STRING([--with-quotas], [Include disk-quota support (default=no)])],
4853 [ case "$withval" in
4854   yes)
4855     AC_MSG_RESULT(yes)
4856     samba_cv_WITH_QUOTAS=yes
4857     samba_cv_TRY_QUOTAS=yes
4858     samba_cv_RUN_QUOTA_TESTS=yes
4859     #set sys quotas to auto in this case
4860     samba_cv_TRY_SYS_QUOTAS=auto
4861     ;;
4862   auto)
4863     AC_MSG_RESULT(auto)
4864     samba_cv_WITH_QUOTAS=auto
4865     samba_cv_TRY_QUOTAS=auto
4866     samba_cv_RUN_QUOTA_TESTS=auto
4867     #set sys quotas to auto in this case
4868     samba_cv_TRY_SYS_QUOTAS=auto
4869     ;;
4870   no)
4871     AC_MSG_RESULT(no)
4872     samba_cv_WITH_QUOTAS=no
4873     samba_cv_TRY_QUOTAS=no
4874     samba_cv_RUN_QUOTA_TESTS=no
4875     ;;
4876   *)
4877     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4878     ;;
4879   esac ],
4880   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4883 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4884 AC_ARG_WITH(sys-quotas,
4885 [AS_HELP_STRING([--with-sys-quotas], [Include lib/sysquotas.c support (default=auto)])],
4886 [ case "$withval" in
4887   yes)
4888     AC_MSG_RESULT(yes)
4889     samba_cv_WITH_SYS_QUOTAS=yes
4890     samba_cv_TRY_SYS_QUOTAS=yes
4891     samba_cv_RUN_QUOTA_TESTS=yes
4892     ;;
4893   auto)
4894     AC_MSG_RESULT(auto)
4895     samba_cv_WITH_SYS_QUOTAS=auto
4896     samba_cv_TRY_SYS_QUOTAS=auto
4897     samba_cv_RUN_QUOTA_TESTS=auto
4898     ;;
4899   no)
4900     AC_MSG_RESULT(no)
4901     samba_cv_WITH_SYS_QUOTAS=no
4902     samba_cv_TRY_SYS_QUOTAS=no
4903     ;;
4904   *)
4905     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4906     ;;
4907   esac ],
4908   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4911 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4912 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4913   case "$host_os" in
4914         *linux*)
4915             AC_MSG_RESULT(yes)
4916             samba_cv_TRY_SYS_QUOTAS=yes
4917             samba_cv_RUN_QUOTA_TESTS=yes
4918             ;;
4919         *)
4920             AC_MSG_RESULT(no)
4921             samba_cv_TRY_SYS_QUOTAS=no
4922             ;;
4923   esac
4926 #############################################
4927 # only check for quota stuff if --with-quotas
4928 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4930 case "$host_os" in
4931         # on linux we didn't need to test we have builtin support
4932         *linux*)
4933             samba_cv_SYSQUOTA_FOUND=yes
4934             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4935             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4936             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4937             AC_MSG_RESULT(yes)
4939             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4940             samba_cv_found_xfs_header=yes
4941             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4942             AC_MSG_RESULT(yes)
4943             ;;
4944         *solaris*)
4945             # need to set this define when using static linking (BUG 1473)
4946             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4947             ;;
4948         *)
4949             ;;
4950 esac
4952 # some broken header files need this
4953 AC_CHECK_HEADER(asm/types.h,[
4954             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4955             AC_ADD_INCLUDE(<asm/types.h>)
4956             ])
4958 # For quotas on Veritas VxFS filesystems
4959 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4961 # For quotas on Linux XFS filesystems
4962 AC_CHECK_HEADERS(linux/dqblk_xfs.h)
4964 # For sys/quota.h and linux/quota.h
4965 AC_CHECK_HEADERS(sys/quota.h)
4967 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4968 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4969 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4970 AC_TRY_COMPILE([
4971 #include "confdefs.h"
4972 #ifdef HAVE_SYS_TYPES_H
4973 #include <sys/types.h>
4974 #endif
4975 #ifdef HAVE_ASM_TYPES_H
4976 #include <asm/types.h>
4977 #endif
4978 #include <sys/quota.h>
4979 ],[int i = Q_XGETQUOTA;],
4980 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4981 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4982         samba_cv_found_xfs_header=yes
4986 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX
4987 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4988 AC_TRY_COMPILE([
4989 #include "confdefs.h"
4990 #ifdef HAVE_SYS_QUOTA_H
4991 #include <sys/quota.h>
4992 #endif
4994 struct dqblk D;
4995 D.dqb_fsoftlimit = 0;],
4996 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4997 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4998         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
5001 ##################
5002 # look for a working quota system
5004 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
5005 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
5006 AC_TRY_RUN_STRICT([
5007 #define HAVE_QUOTACTL_4A 1
5008 #define AUTOCONF_TEST 1
5009 #include "confdefs.h"
5010 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
5011            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
5012 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
5013     samba_cv_SYSQUOTA_FOUND=yes;
5014     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
5015     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
5019 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
5020 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
5021 AC_TRY_RUN_STRICT([
5022 #define HAVE_QUOTACTL_4B 1
5023 #define AUTOCONF_TEST 1
5024 #include "confdefs.h"
5025 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
5026            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
5027 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
5028     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
5029     samba_cv_SYSQUOTA_FOUND=yes;
5030     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
5031     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
5035 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
5036 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
5037 AC_TRY_RUN_STRICT([
5038 #define HAVE_QUOTACTL_3 1
5039 #define AUTOCONF_TEST 1
5040 #include "confdefs.h"
5041 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
5042            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
5043 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
5044     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
5045     samba_cv_SYSQUOTA_FOUND=yes;
5046     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
5047     samba_cv_sysquotas_file="lib/sysquotas_3.c"
5051 #################################################
5052 # check for mntent.h and struct mntent
5053 AC_CHECK_HEADERS(mntent.h)
5054 #################################################
5055 # check for setmntent,getmntent,endmntent
5056 AC_CHECK_FUNCS(setmntent getmntent endmntent)
5058 #################################################
5059 # check for devnm.h and struct mntent
5060 AC_CHECK_HEADERS(devnm.h)
5061 #################################################
5062 # check for devnm
5063 AC_CHECK_FUNCS(devnm)
5065 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
5066     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
5067         # if --with-sys-quotas=yes then build it
5068         # you have can use the get/set quota command smb.conf
5069         # options then
5070         samba_cv_SYSQUOTA_FOUND=auto
5071     fi
5072     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
5073         # if --with-sys-quotas=yes then build it
5074         # you have can use the get/set quota command smb.conf
5075         # options then
5076         samba_cv_TRY_SYS_QUOTAS=auto
5077     fi
5080 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
5081 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
5082 SAVE_CPPFLAGS="$CPPFLAGS"
5083 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5084 AC_TRY_COMPILE([
5085 #include "confdefs.h"
5086 #define NO_PROTO_H 1
5087 #define NO_CONFIG_H 1
5088 #define HAVE_SYS_QUOTAS 1
5089 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
5090 #include "${srcdir-.}/lib/sysquotas.c"
5091 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
5092 CPPFLAGS="$SAVE_CPPFLAGS"
5094 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
5095 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
5096     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
5097         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
5098         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
5099         samba_cv_WE_USE_SYS_QUOTAS=yes
5100         AC_MSG_RESULT(yes)
5101     else
5102         AC_MSG_RESULT(no)
5103     fi
5107 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
5108 AC_CACHE_CHECK([whether the sys_quota interface works with NFS],samba_cv_SYSQUOTA_WORKS_NFS,[
5109 SAVE_CPPFLAGS="$CPPFLAGS"
5110 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5111 AC_TRY_COMPILE([
5112 #include "confdefs.h"
5113 #define NO_PROTO_H 1
5114 #define NO_CONFIG_H 1
5115 #define HAVE_SYS_QUOTAS 1
5116 #define HAVE_NFS_QUOTAS 1
5117 #include "${srcdir-.}/lib/sysquotas_nfs.c"
5118 ],[],samba_cv_SYSQUOTA_WORKS_NFS=yes,samba_cv_SYSQUOTA_WORKS_NFS=no)
5119 CPPFLAGS="$SAVE_CPPFLAGS"
5121 if test x"$samba_cv_SYSQUOTA_WORKS_NFS" = x"yes"; then
5122     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
5123         AC_DEFINE(HAVE_NFS_QUOTAS,1,[Whether nfs quota support is available])
5124     fi
5128 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
5129 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
5130 SAVE_CPPFLAGS="$CPPFLAGS"
5131 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5132 AC_TRY_COMPILE([
5133 #include "confdefs.h"
5134 #define NO_PROTO_H 1
5135 #define NO_CONFIG_H 1
5136 #define HAVE_SYS_QUOTAS 1
5137 #define HAVE_XFS_QUOTAS 1
5138 #include "${srcdir-.}/lib/sysquotas_xfs.c"
5139 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
5140 CPPFLAGS="$SAVE_CPPFLAGS"
5142 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
5143     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
5144         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
5145     fi
5149 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
5150 SAVE_CPPFLAGS="$CPPFLAGS"
5151 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
5152 AC_TRY_COMPILE([
5153 #include "confdefs.h"
5154 #define NO_PROTO_H 1
5155 #define NO_CONFIG_H 1
5156 #include "${srcdir-.}/smbd/quotas.c"
5157 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
5158 CPPFLAGS="$SAVE_CPPFLAGS"
5160 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
5161 AC_MSG_CHECKING(whether to use the old quota support)
5162     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
5163       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
5164         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
5165         AC_MSG_RESULT(yes)
5166       else
5167         AC_MSG_RESULT(no)
5168       fi
5169     else
5170       AC_MSG_RESULT(no)
5171     fi
5174 ####################
5175 # End of quota check samba_cv_RUN_QUOTA_TESTS
5178 #################################################
5179 # check for experimental utmp accounting
5181 AC_MSG_CHECKING(whether to support utmp accounting)
5182 WITH_UTMP=yes
5183 AC_ARG_WITH(utmp,
5184 [AS_HELP_STRING([--with-utmp], [Include utmp accounting (default, if supported by OS)])],
5185 [ case "$withval" in
5186   no)
5187                 WITH_UTMP=no
5188                 ;;
5189   *)
5190                 WITH_UTMP=yes
5191                 ;;
5192   esac ],
5195 # utmp requires utmp.h
5196 # Note similar check earlier, when checking utmp details.
5198 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
5199         utmp_no_reason=", no utmp.h on $host_os"
5200         WITH_UTMP=no
5203 # Display test results
5205 if test x"$WITH_UTMP" = x"yes"; then
5206         AC_MSG_RESULT(yes)
5207         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
5208 else
5209         AC_MSG_RESULT(no$utmp_no_reason)
5213 #################################################
5214 # these tests are taken from the GNU fileutils package
5215 AC_CHECKING(how to get filesystem space usage)
5216 space=no
5218 # Test for statvfs64.
5219 if test $space = no; then
5220   # SVR4
5221   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
5222   [AC_TRY_RUN([
5223 #if defined(HAVE_UNISTD_H)
5224 #include <unistd.h>
5225 #endif
5226 #include <sys/types.h>
5227 #include <sys/statvfs.h>
5228   main ()
5229   {
5230     struct statvfs64 fsd;
5231     exit (statvfs64 (".", &fsd));
5232   }],
5233   fu_cv_sys_stat_statvfs64=yes,
5234   fu_cv_sys_stat_statvfs64=no,
5235   fu_cv_sys_stat_statvfs64=cross)])
5236   if test $fu_cv_sys_stat_statvfs64 = yes; then
5237     space=yes
5238     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
5239   fi
5242 # Perform only the link test since it seems there are no variants of the
5243 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
5244 # because that got a false positive on SCO OSR5.  Adding the declaration
5245 # of a `struct statvfs' causes this test to fail (as it should) on such
5246 # systems.  That system is reported to work fine with STAT_STATFS4 which
5247 # is what it gets when this test fails.
5248 if test $space = no; then
5249   # SVR4
5250   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
5251                  [AC_TRY_LINK([#include <sys/types.h>
5252 #include <sys/statvfs.h>],
5253                               [struct statvfs fsd; statvfs (0, &fsd);],
5254                               fu_cv_sys_stat_statvfs=yes,
5255                               fu_cv_sys_stat_statvfs=no)])
5256   if test $fu_cv_sys_stat_statvfs = yes; then
5257     space=yes
5258     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
5259   fi
5262 # smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
5263 # This is not the case on ancient Linux systems.
5265 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
5266     AC_TRY_COMPILE([#include <sys/types.h>
5267 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
5268         samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
5269 if test x"$samba_cv_fsid_int" = x"yes"; then
5270     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
5273 # fsusage.c assumes that statvfs has an f_frsize entry. Some weird
5274 # systems use f_bsize.
5275 AC_CACHE_CHECK([that statvfs.f_frsize works],samba_cv_frsize, [
5276     AC_TRY_COMPILE([#include <sys/types.h>
5277 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_frsize = 0],
5278         samba_cv_frsize=yes,samba_cv_frsize=no)])
5279 if test x"$samba_cv_frsize" = x"yes"; then
5280     AC_DEFINE(HAVE_FRSIZE, 1, [Whether statvfs.f_frsize exists])
5283 # Some systems use f_flag in struct statvfs while others use f_flags
5284 AC_CACHE_CHECK([that statvfs.statvfs_f_flag works],samba_cv_statvfs_f_flag, [
5285     AC_TRY_COMPILE([#include <sys/types.h>
5286 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_flag = 0],
5287         samba_cv_statvfs_f_flag=yes,samba_cv_statvfs_f_flag=no)])
5288 if test x"$samba_cv_statvfs_f_flag" = x"yes"; then
5289     AC_DEFINE(HAVE_STATVFS_F_FLAG, 1, [Whether statvfs.f_flag exists])
5292 AC_CACHE_CHECK([that statvfs.statvfs_f_flags works],samba_cv_statvfs_f_flags, [
5293     AC_TRY_COMPILE([#include <sys/types.h>
5294 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_flags = 0],
5295         samba_cv_statvfs_f_flags=yes,samba_cv_statvfs_f_flags=no)])
5296 if test x"$samba_cv_statvfs_f_flags" = x"yes"; then
5297     AC_DEFINE(HAVE_STATVFS_F_FLAGS, 1, [Whether statvfs.f_flags exists])
5300 if test $space = no; then
5301   # DEC Alpha running OSF/1
5302   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
5303   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
5304   [AC_TRY_RUN([
5305 #include <sys/param.h>
5306 #include <sys/types.h>
5307 #include <sys/mount.h>
5308   main ()
5309   {
5310     struct statfs fsd;
5311     fsd.f_fsize = 0;
5312     exit (statfs (".", &fsd, sizeof (struct statfs)));
5313   }],
5314   fu_cv_sys_stat_statfs3_osf1=yes,
5315   fu_cv_sys_stat_statfs3_osf1=no,
5316   fu_cv_sys_stat_statfs3_osf1=no)])
5317   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
5318   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
5319     space=yes
5320     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
5321   fi
5324 if test $space = no; then
5325 # AIX
5326   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
5327 member (AIX, 4.3BSD)])
5328   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
5329   [AC_TRY_RUN([
5330 #ifdef HAVE_SYS_PARAM_H
5331 #include <sys/param.h>
5332 #endif
5333 #ifdef HAVE_SYS_MOUNT_H
5334 #include <sys/mount.h>
5335 #endif
5336 #ifdef HAVE_SYS_VFS_H
5337 #include <sys/vfs.h>
5338 #endif
5339   main ()
5340   {
5341   struct statfs fsd;
5342   fsd.f_bsize = 0;
5343   exit (statfs (".", &fsd));
5344   }],
5345   fu_cv_sys_stat_statfs2_bsize=yes,
5346   fu_cv_sys_stat_statfs2_bsize=no,
5347   fu_cv_sys_stat_statfs2_bsize=no)])
5348   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
5349   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
5350     space=yes
5351     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
5352   fi
5355 if test $space = no; then
5356 # SVR3
5357   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
5358   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
5359   [AC_TRY_RUN([#include <sys/types.h>
5360 #include <sys/statfs.h>
5361   main ()
5362   {
5363   struct statfs fsd;
5364   exit (statfs (".", &fsd, sizeof fsd, 0));
5365   }],
5366     fu_cv_sys_stat_statfs4=yes,
5367     fu_cv_sys_stat_statfs4=no,
5368     fu_cv_sys_stat_statfs4=no)])
5369   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
5370   if test $fu_cv_sys_stat_statfs4 = yes; then
5371     space=yes
5372     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
5373   fi
5376 if test $space = no; then
5377 # 4.4BSD and NetBSD
5378   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
5379 member (4.4BSD and NetBSD)])
5380   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
5381   [AC_TRY_RUN([#include <sys/types.h>
5382 #ifdef HAVE_SYS_PARAM_H
5383 #include <sys/param.h>
5384 #endif
5385 #ifdef HAVE_SYS_MOUNT_H
5386 #include <sys/mount.h>
5387 #endif
5388   main ()
5389   {
5390   struct statfs fsd;
5391   fsd.f_fsize = 0;
5392   exit (statfs (".", &fsd));
5393   }],
5394   fu_cv_sys_stat_statfs2_fsize=yes,
5395   fu_cv_sys_stat_statfs2_fsize=no,
5396   fu_cv_sys_stat_statfs2_fsize=no)])
5397   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
5398   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
5399     space=yes
5400         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
5401   fi
5404 if test $space = no; then
5405   # Ultrix
5406   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
5407   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
5408   [AC_TRY_RUN([#include <sys/types.h>
5409 #ifdef HAVE_SYS_PARAM_H
5410 #include <sys/param.h>
5411 #endif
5412 #ifdef HAVE_SYS_MOUNT_H
5413 #include <sys/mount.h>
5414 #endif
5415 #ifdef HAVE_SYS_FS_TYPES_H
5416 #include <sys/fs_types.h>
5417 #endif
5418   main ()
5419   {
5420   struct fs_data fsd;
5421   /* Ultrix's statfs returns 1 for success,
5422      0 for not mounted, -1 for failure.  */
5423   exit (statfs (".", &fsd) != 1);
5424   }],
5425   fu_cv_sys_stat_fs_data=yes,
5426   fu_cv_sys_stat_fs_data=no,
5427   fu_cv_sys_stat_fs_data=no)])
5428   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
5429   if test $fu_cv_sys_stat_fs_data = yes; then
5430     space=yes
5431     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
5432   fi
5436 # As a gating factor for large file support, in order to
5437 # use <4GB files we must have the following minimal support
5438 # available.
5439 # long long, and a 64 bit off_t or off64_t.
5440 # If we don't have all of these then disable large
5441 # file support.
5443 AC_MSG_CHECKING([if large file support can be enabled])
5444 AC_TRY_COMPILE([
5445 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
5446 #include <sys/types.h>
5447 #else
5448 __COMPILE_ERROR_
5449 #endif
5451 [int i],
5452 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
5453 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
5454         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
5456 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
5459 #################################################
5460 # check for cluster extensions
5462 AC_MSG_CHECKING(cluster support)
5463 AC_ARG_WITH(cluster-support,
5464 [AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])])
5466 if test x"$with_cluster_support" = x ; then
5467         with_cluster_support="auto"
5470 AC_MSG_RESULT($with_cluster_support)
5472 AC_ARG_WITH(ctdb,
5473 [AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])],
5474 [ case "$withval" in
5475   yes|no)
5476     AC_MSG_WARN([--with-ctdb called without argument])
5477     ;;
5478   *)
5479     CTDB_CPPFLAGS="-I$withval/include"
5480     ;;
5481   esac])
5483 AC_ARG_ENABLE(old-ctdb,
5484         [AS_HELP_STRING([--enable-old-ctdb],
5485                 [Enable build against (too) old ctdb version (default=no)])],,
5486                 [enable_old_ctdb=no])
5489 if test "$with_cluster_support" != "no" ; then
5491 AC_MSG_NOTICE(checking whether cluster support is available)
5493 have_cluster_support="yes"
5494 ctdb_broken="no"
5496 SAVED_CPPFLAGS="$CPPFLAGS"
5497 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS} $CTDB_CPPFLAGS"
5499 AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
5500 #include "confdefs.h"
5501 #define NO_CONFIG_H
5502 #include "replace.h"
5503 #include "system/wait.h"
5504 #include "system/network.h"
5505 #define private #error __USED_RESERVED_WORD_private__
5506 #include <talloc.h>
5507 #include <tdb.h>
5508 #include <ctdb.h>
5511 if test "x$have_cluster_support" = "xyes" -a \
5512         "x$ac_cv_header_ctdb_h" != "xyes"
5513 then
5514         have_cluster_support=no
5515         ctdb_broken="ctdb.h is required for cluster support"
5518 if test "x$have_cluster_support" = "xyes" -a \
5519         "x$ac_cv_header_ctdb_h" != "xyes"
5520 then
5521         have_cluster_support=no
5522         ctdb_broken="ctdb_private.h is required for cluster support"
5526 if test "x$have_cluster_support" = "xyes" ; then
5527         AC_HAVE_DECL(CTDB_CONTROL_TRANS3_COMMIT,[
5528         #include "confdefs.h"
5529         #define NO_CONFIG_H
5530         #include "replace.h"
5531         #include "system/wait.h"
5532         #include "system/network.h"
5533         #include <talloc.h>
5534         #include <tdb.h>
5535         #include <ctdb.h>
5536         #include <ctdb_private.h>
5537         ])
5538         if test x"$ac_cv_have_CTDB_CONTROL_TRANS3_COMMIT_decl" != x"yes"; then
5539                 ctdb_broken="ctdb transaction support missing or too old"
5540                 have_cluster_support=no
5541         fi
5544 if test "x$have_cluster_support" = "xyes" ; then
5545         AC_HAVE_DECL(CTDB_CONTROL_SCHEDULE_FOR_DELETION,[
5546         #include "confdefs.h"
5547         #define NO_CONFIG_H
5548         #include "replace.h"
5549         #include "system/wait.h"
5550         #include "system/network.h"
5551         #include <talloc.h>
5552         #include <tdb.h>
5553         #include <ctdb.h>
5554         #include <ctdb_private.h>
5555         ])
5556         if test x"$ac_cv_have_CTDB_CONTROL_SCHEDULE_FOR_DELETION_decl" != x"yes"
5557         then
5558                 if test "x$enable_old_ctdb" = "xyes" ; then
5559                         AC_MSG_WARN([ignoring missing SCHEDULE_FOR_DELETION (--enable-old-ctdb)])
5560                 else
5561                         ctdb_broken="support for SCHEDULE_FOR_DELETION control missing"
5562                         have_cluster_support=no
5563                 fi
5564         fi
5567 if test "x$have_cluster_support" = "xyes" ; then
5568         # In ctdb 1.0.57, ctdb_control_tcp was temporarily renamed
5569         # to ctdb_tcp_client.
5570         AC_CHECK_TYPE(struct ctdb_tcp_client,[
5571                 AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support])
5572         ],,[
5573         #include "confdefs.h"
5574         #define NO_CONFIG_H
5575         #include "replace.h"
5576         #include "system/wait.h"
5577         #include "system/network.h"
5578         #include <talloc.h>
5579         #include <tdb.h>
5580         #include <ctdb.h>
5581         #include <ctdb_private.h>
5582         ])
5585 if test "x$have_cluster_support" = "xyes" ; then
5586         AC_CHECK_TYPE(struct ctdb_control_tcp,[
5587                 AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP],[1],[ctdb ipv4 support])
5588         ],[
5589                 ctdb_broken="missing struct ctdb_control_tcp"
5590                 have_cluster_support=no
5591         ],[
5592         #include "confdefs.h"
5593         #define NO_CONFIG_H
5594         #include "replace.h"
5595         #include "system/wait.h"
5596         #include "system/network.h"
5597         #include <talloc.h>
5598         #include <tdb.h>
5599         #include <ctdb.h>
5600         #include <ctdb_private.h>
5601         ])
5604 # test for optional ipv6 support in ctdb:
5605 if test "x$have_cluster_support" = "xyes" ; then
5606         AC_CHECK_TYPE(struct ctdb_control_tcp_addr,[
5607                 AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR],[1],[ctdb ipv6 support])
5608         ],,[
5609         #include "confdefs.h"
5610         #define NO_CONFIG_H
5611         #include "replace.h"
5612         #include "system/wait.h"
5613         #include "system/network.h"
5614         #include <talloc.h>
5615         #include <tdb.h>
5616         #include <ctdb.h>
5617         #include <ctdb_private.h>
5618         ])
5621 CPPFLAGS="$SAVED_CPPFLAGS"
5623 fi # (if test "$with_cluster_support" != "no")
5625 if test x"$have_cluster_support" = "xno" ; then
5626         case "$with_cluster_support" in
5627         yes)
5628                 AC_MSG_ERROR(["cluster support not available: $ctdb_broken"])
5629                 ;;
5630         auto)
5631                 AC_MSG_WARN(["cluster support not available: $ctdb_broken"])
5632                 ;;
5633         esac
5634         with_cluster_support=no
5637 if test "x$with_cluster_support" != "xno"; then
5638     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
5639     SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CTDB_CPPFLAGS}"
5640     AC_MSG_NOTICE(Building with cluster support)
5641 else
5642     AC_MSG_NOTICE(Building without cluster support)
5646 #################################################
5647 # check for rtnetlink
5649 AC_CHECK_HEADERS([linux/netlink.h],
5650   AC_CHECK_HEADERS([linux/rtnetlink.h],[],[],
5651                    [#include <bits/sockaddr.h>
5652                     #include <linux/netlink.h>]),
5653   [],[#include <bits/sockaddr.h>])
5655 #################################################
5656 # check for ACL support
5658 AC_MSG_CHECKING(whether to support ACLs)
5659 AC_ARG_WITH(acl-support,
5660 [AS_HELP_STRING([--with-acl-support], [Include ACL support (default=auto)])],
5661 [ case "$withval" in
5662         yes|no)
5663                 with_acl_support="$withval"
5664                 ;;
5665   esac ])
5667 if test x"$with_acl_support" = x ; then
5668         with_acl_support="auto"
5671 AC_MSG_RESULT($with_acl_support)
5673 if test x"$with_acl_support" = x"no"; then
5674         AC_MSG_RESULT(Disabling ACL support)
5675         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
5676 else
5677         AC_MSG_NOTICE(checking whether ACL support is available:)
5678         case "$host_os" in
5679         *sysv5*)
5680                 AC_MSG_NOTICE(Using UnixWare ACLs)
5681                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
5682                 default_static_modules="$default_static_modules vfs_solarisacl"
5683                 ;;
5684         *solaris*)
5685                 AC_MSG_NOTICE(Using solaris ACLs)
5686                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
5687                 ACL_LIBS="$ACL_LIBS -lsec"
5688                 default_static_modules="$default_static_modules vfs_solarisacl"
5689                 ;;
5690         *hpux*)
5691                 AC_MSG_NOTICE(Using HPUX ACLs)
5692                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
5693                 default_static_modules="$default_static_modules vfs_hpuxacl"
5694                 ;;
5695         *irix*)
5696                 AC_MSG_NOTICE(Using IRIX ACLs)
5697                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
5698                 default_static_modules="$default_static_modules vfs_irixacl"
5699                 ;;
5700         *aix*)
5701                 AC_MSG_NOTICE(Using AIX ACLs)
5702                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
5703                 default_static_modules="$default_static_modules vfs_aixacl"
5704                 ;;
5705         *osf*)
5706                 AC_MSG_NOTICE(Using Tru64 ACLs)
5707                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
5708                 ACL_LIBS="$ACL_LIBS -lpacl"
5709                 default_static_modules="$default_static_modules vfs_tru64acl"
5710                 ;;
5711         *darwin*)
5712                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
5713                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5714                 ;;
5715         *)
5716                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
5717                 case "$host_os" in
5718                 *linux*)
5719                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
5720                         ;;
5721                 esac
5722                 AC_CACHE_CHECK([for POSIX ACL support],samba_cv_HAVE_POSIX_ACLS,[
5723                         acl_LIBS=$LIBS
5724                         LIBS="$LIBS $ACL_LIBS"
5725                         AC_TRY_LINK([
5726                                 #include <sys/types.h>
5727                                 #include <sys/acl.h>
5728                         ],[
5729                                 acl_t acl;
5730                                 int entry_id;
5731                                 acl_entry_t *entry_p;
5732                                 return acl_get_entry(acl, entry_id, entry_p);
5733                         ],
5734                         [samba_cv_HAVE_POSIX_ACLS=yes],
5735                         [samba_cv_HAVE_POSIX_ACLS=no])
5736                         LIBS=$acl_LIBS
5737                 ])
5738                 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
5739                         AC_MSG_NOTICE(Using posix ACLs)
5740                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
5741                         AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
5742                                 acl_LIBS=$LIBS
5743                                 LIBS="$LIBS $ACL_LIBS"
5744                                 AC_TRY_LINK([
5745                                         #include <sys/types.h>
5746                                         #include <sys/acl.h>
5747                                 ],[
5748                                         acl_permset_t permset_d;
5749                                         acl_perm_t perm;
5750                                         return acl_get_perm_np(permset_d, perm);
5751                                 ],
5752                                 [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
5753                                 [samba_cv_HAVE_ACL_GET_PERM_NP=no])
5754                                 LIBS=$acl_LIBS
5755                         ])
5756                         if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
5757                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
5758                         fi
5759                         default_static_modules="$default_static_modules vfs_posixacl"
5760                 else
5761                         AC_MSG_NOTICE(ACL support is not avaliable)
5762                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5763                 fi
5764                 ;;
5765         esac
5766 fi # with_acl_support
5768 #################################################
5769 # check if we have FreeBSD sunacl
5770 case "$host_os" in
5771 *freebsd*)
5772     AC_CHECK_HEADER(sunacl.h)
5773     if test x"$ac_cv_header_sunacl_h" = xyes ; then
5774        AC_DEFINE(HAVE_FREEBSD_SUNACL_H,1,[Whether we have FreeBSD sunacl around])
5775        ZFSACL_LIBS=-lsunacl
5776        AC_SUBST(ZFSACL_LIBS)
5777        default_shared_modules="$default_shared_modules vfs_zfsacl"
5778     fi
5779     ;;
5780 esac
5782 #################################################
5783 # check for AIO support
5785 AC_MSG_CHECKING(whether to support asynchronous io)
5786 AC_ARG_WITH(aio-support,
5787 [AS_HELP_STRING([--with-aio-support], [Include asynchronous io support (default=no)])],
5788 [ case "$withval" in
5789   yes)
5791         AC_MSG_RESULT(yes)
5792         case "$host_os" in
5793         *)
5794                 AIO_LIBS=$LIBS
5795                 no_rt_LIBS=$LIBS
5796                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
5797                 LIBS=$no_rt_LIBS
5798                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
5799                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
5800                 aio_LIBS=$LIBS
5801                 LIBS=$AIO_LIBS
5802                 AC_TRY_LINK([#include <sys/types.h>
5803 #include <aio.h>],
5804 [ struct aiocb a; return aio_read(&a);],
5805 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
5806                 LIBS=$aio_LIBS])
5807                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
5808                 aio_LIBS=$LIBS
5809                 LIBS=$AIO_LIBS
5810                 AC_TRY_LINK([#include <sys/types.h>
5811 #include <aio.h>],
5812 [ struct aiocb64 a; return aio_read64(&a);],
5813 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
5814                 LIBS=$aio_LIBS])
5815                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5816                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
5817                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5818                         LIBS=$AIO_LIBS
5819                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
5820                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5821                         LIBS=$AIO_LIBS
5822                 fi
5824                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5825                         AC_MSG_CHECKING(for aio_read)
5826                         AC_LINK_IFELSE([#include <aio.h>
5827 int main() { struct aiocb a; return aio_read(&a); }],
5828 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
5829 [AC_MSG_RESULT(no)])
5831                         AC_MSG_CHECKING(for aio_write)
5832                         AC_LINK_IFELSE([#include <aio.h>
5833 int main() { struct aiocb a; return aio_write(&a); }],
5834 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
5835 [AC_MSG_RESULT(no)])
5837                         AC_MSG_CHECKING(for aio_fsync)
5838                         AC_LINK_IFELSE([#include <aio.h>
5839 int main() { struct aiocb a; return aio_fsync(1, &a); }],
5840 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
5841 [AC_MSG_RESULT(no)])
5843                         AC_MSG_CHECKING(for aio_return)
5844                         AC_LINK_IFELSE([#include <aio.h>
5845 int main() { struct aiocb a; return aio_return(&a); }],
5846 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
5847 [AC_MSG_RESULT(no)])
5849                         AC_MSG_CHECKING(for aio_error)
5850                         AC_LINK_IFELSE([#include <aio.h>
5851 int main() { struct aiocb a; return aio_error(&a); }],
5852 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
5853 [AC_MSG_RESULT(no)])
5855                         AC_MSG_CHECKING(for aio_cancel)
5856                         AC_LINK_IFELSE([#include <aio.h>
5857 int main() { struct aiocb a; return aio_cancel(1, &a); }],
5858 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
5859 [AC_MSG_RESULT(no)])
5861                         AC_MSG_CHECKING(for aio_suspend)
5862                         AC_LINK_IFELSE([#include <aio.h>
5863 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
5864 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
5865 [AC_MSG_RESULT(no)])
5866                 fi
5868                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5869                         AC_MSG_CHECKING(for aio_read64)
5870                         AC_LINK_IFELSE([#include <aio.h>
5871 int main() { struct aiocb a; return aio_read64(&a); }],
5872 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
5873 [AC_MSG_RESULT(no)])
5875                         AC_MSG_CHECKING(for aio_write64)
5876                         AC_LINK_IFELSE([#include <aio.h>
5877 int main() { struct aiocb a; return aio_write64(&a); }],
5878 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
5879 [AC_MSG_RESULT(no)])
5881                         AC_MSG_CHECKING(for aio_fsync64)
5882                         AC_LINK_IFELSE([#include <aio.h>
5883 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
5884 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
5885 [AC_MSG_RESULT(no)])
5887                         AC_MSG_CHECKING(for aio_return64)
5888                         AC_LINK_IFELSE([#include <aio.h>
5889 int main() { struct aiocb a; return aio_return64(&a); }],
5890 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
5891 [AC_MSG_RESULT(no)])
5893                         AC_MSG_CHECKING(for aio_error64)
5894                         AC_LINK_IFELSE([#include <aio.h>
5895 int main() { struct aiocb a; return aio_error64(&a); }],
5896 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
5897 [AC_MSG_RESULT(no)])
5899                         AC_MSG_CHECKING(for aio_cancel64)
5900                         AC_LINK_IFELSE([#include <aio.h>
5901 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
5902 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
5903 [AC_MSG_RESULT(no)])
5905                         AC_MSG_CHECKING(for aio_suspend64)
5906                         AC_LINK_IFELSE([#include <aio.h>
5907 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
5908 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
5909 [AC_MSG_RESULT(no)])
5910                 fi
5911             ;;
5912         esac
5913         ;;
5914   *)
5915     AC_MSG_RESULT(no)
5916     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
5917     ;;
5918   esac ],
5919   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
5920   AC_MSG_RESULT(no)
5923 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5924         if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \
5925                 x"$samba_cv_msghdr_msg_acctright" = x"yes"; then
5926                 default_shared_modules="$default_shared_modules vfs_aio_fork"
5927         fi
5930 #################################################
5931 # check for sendfile support
5933 with_sendfile_support=yes
5934 AC_MSG_CHECKING(whether to check to support sendfile)
5935 AC_ARG_WITH(sendfile-support,
5936 [AS_HELP_STRING([--with-sendfile-support], [Check for sendfile support (default=yes)])],
5937 [ case "$withval" in
5938   yes)
5940         AC_MSG_RESULT(yes);
5942         case "$host_os" in
5943         *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
5944                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5945                 AC_TRY_LINK([#include <sys/sendfile.h>],
5947 int tofd, fromfd;
5948 off64_t offset;
5949 size_t total;
5950 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
5952 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5954                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
5955                 AC_TRY_LINK([#include <sys/sendfile.h>],
5957 int tofd, fromfd;
5958 off_t offset;
5959 size_t total;
5960 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5962 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5964 # Try and cope with broken Linux sendfile....
5965                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
5966                 AC_TRY_LINK([\
5967 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5968 #undef _FILE_OFFSET_BITS
5969 #endif
5970 #include <sys/sendfile.h>],
5972 int tofd, fromfd;
5973 off_t offset;
5974 size_t total;
5975 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5977 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5979         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5980                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5981                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5982                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5983         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5984                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5985                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5986                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5987         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5988                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5989                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5990         else
5991                 AC_MSG_RESULT(no);
5992         fi
5994         ;;
5995         *freebsd* | *dragonfly* )
5996                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5997                 AC_TRY_LINK([\
5998 #include <sys/types.h>
5999 #include <unistd.h>
6000 #include <sys/socket.h>
6001 #include <sys/uio.h>],
6003         int fromfd, tofd, ret, total=0;
6004         off_t offset, nwritten;
6005         struct sf_hdtr hdr;
6006         struct iovec hdtrl;
6007         hdr.headers = &hdtrl;
6008         hdr.hdr_cnt = 1;
6009         hdr.trailers = NULL;
6010         hdr.trl_cnt = 0;
6011         hdtrl.iov_base = NULL;
6012         hdtrl.iov_len = 0;
6013         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
6015 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
6017         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
6018                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
6019                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
6020                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
6021         else
6022                 AC_MSG_RESULT(no);
6023         fi
6024         ;;
6026         *hpux*)
6027                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
6028                 AC_TRY_LINK([\
6029 #include <sys/socket.h>
6030 #include <sys/uio.h>],
6032         int fromfd, tofd;
6033         size_t total=0;
6034         struct iovec hdtrl[2];
6035         ssize_t nwritten;
6036         off64_t offset;
6038         hdtrl[0].iov_base = 0;
6039         hdtrl[0].iov_len = 0;
6041         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
6043 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
6044         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
6045                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
6046                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
6047                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
6048         else
6049                 AC_MSG_RESULT(no);
6050         fi
6052                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
6053                 AC_TRY_LINK([\
6054 #include <sys/socket.h>
6055 #include <sys/uio.h>],
6057         int fromfd, tofd;
6058         size_t total=0;
6059         struct iovec hdtrl[2];
6060         ssize_t nwritten;
6061         off_t offset;
6063         hdtrl[0].iov_base = 0;
6064         hdtrl[0].iov_len = 0;
6066         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
6068 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
6069         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
6070                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
6071                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
6072                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
6073         else
6074                 AC_MSG_RESULT(no);
6075         fi
6076         ;;
6078         *solaris*)
6079                 AC_CHECK_LIB(sendfile,sendfilev)
6080                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
6081                 AC_TRY_LINK([\
6082 #include <sys/sendfile.h>],
6084         int sfvcnt;
6085         size_t xferred;
6086         struct sendfilevec vec[2];
6087         ssize_t nwritten;
6088         int tofd;
6090         sfvcnt = 2;
6092         vec[0].sfv_fd = SFV_FD_SELF;
6093         vec[0].sfv_flag = 0;
6094         vec[0].sfv_off = 0;
6095         vec[0].sfv_len = 0;
6097         vec[1].sfv_fd = 0;
6098         vec[1].sfv_flag = 0;
6099         vec[1].sfv_off = 0;
6100         vec[1].sfv_len = 0;
6101         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
6103 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
6105         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
6106                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
6107                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
6108                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
6109         else
6110                 AC_MSG_RESULT(no);
6111         fi
6113                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
6114                 AC_TRY_LINK([\
6115 #include <sys/sendfile.h>],
6117         int sfvcnt;
6118         size_t xferred;
6119         struct sendfilevec vec[2];
6120         ssize_t nwritten;
6121         int tofd;
6123         sfvcnt = 2;
6125         vec[0].sfv_fd = SFV_FD_SELF;
6126         vec[0].sfv_flag = 0;
6127         vec[0].sfv_off = 0;
6128         vec[0].sfv_len = 0;
6130         vec[1].sfv_fd = 0;
6131         vec[1].sfv_flag = 0;
6132         vec[1].sfv_off = 0;
6133         vec[1].sfv_len = 0;
6134         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
6136 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
6138         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
6139                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
6140                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
6141                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
6142         else
6143                 AC_MSG_RESULT(no);
6144         fi
6145         ;;
6146         *aix*)
6147                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
6148                 AC_TRY_LINK([\
6149 #include <sys/socket.h>],
6151         int fromfd, tofd;
6152         size_t total=0;
6153         struct sf_parms hdtrl;
6154         ssize_t nwritten;
6155         off64_t offset;
6157         hdtrl.header_data = 0;
6158         hdtrl.header_length = 0;
6159         hdtrl.file_descriptor = fromfd;
6160         hdtrl.file_offset = 0;
6161         hdtrl.file_bytes = 0;
6162         hdtrl.trailer_data = 0;
6163         hdtrl.trailer_length = 0;
6165         nwritten = send_file(&tofd, &hdtrl, 0);
6167 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
6168         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
6169                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
6170                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
6171                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
6172         else
6173                 AC_MSG_RESULT(no);
6174         fi
6175         ;;
6176         *)
6177         ;;
6178         esac
6179         ;;
6180   *)
6181     AC_MSG_RESULT(no)
6182     ;;
6183   esac ],
6184   AC_MSG_RESULT(yes)
6187 ############################################
6188 # See if we have the Linux readahead syscall.
6190 AC_CACHE_CHECK([for Linux readahead],
6191                 samba_cv_HAVE_LINUX_READAHEAD,[
6192     AC_TRY_LINK([
6193 #if defined(HAVE_UNISTD_H)
6194 #include <unistd.h>
6195 #endif
6196 #include <fcntl.h>],
6197     [ssize_t err = readahead(0,0,0x80000);],
6198     samba_cv_HAVE_LINUX_READAHEAD=yes,
6199     samba_cv_HAVE_LINUX_READAHEAD=no)])
6201 if test x"$samba_cv_HAVE_LINUX_READAHEAD" = x"yes"; then
6202   AC_DEFINE(HAVE_LINUX_READAHEAD,1,
6203              [Whether Linux readahead is available])
6206 AC_HAVE_DECL(readahead, [#include <fcntl.h>])
6208 ############################################
6209 # See if we have the posix_fadvise syscall.
6211 AC_CACHE_CHECK([for posix_fadvise],
6212                 samba_cv_HAVE_POSIX_FADVISE,[
6213     AC_TRY_LINK([
6214 #if defined(HAVE_UNISTD_H)
6215 #include <unistd.h>
6216 #endif
6217 #include <fcntl.h>],
6218     [ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);],
6219     samba_cv_HAVE_POSIX_FADVISE=yes,
6220     samba_cv_HAVE_POSIX_FADVISE=no)])
6222 if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
6223   AC_DEFINE(HAVE_POSIX_FADVISE,1,
6224              [Whether posix_fadvise is available])
6227 ############################################
6228 # See if we have the Linux splice syscall.
6230 case "$host_os" in
6231 *linux*)
6232 AC_CACHE_CHECK([for Linux splice],
6233                 samba_cv_HAVE_LINUX_SPLICE,[
6234     AC_TRY_LINK([
6235 #if defined(HAVE_UNISTD_H)
6236 #include <unistd.h>
6237 #endif
6238 #include <fcntl.h>],
6239     [long ret = splice(0,0,1,0,400,0);],
6240     samba_cv_HAVE_LINUX_SPLICE=yes,
6241     samba_cv_HAVE_LINUX_SPLICE=no)])
6244 samba_cv_HAVE_LINUX_SPLICE=no
6246 esac
6248 if test x"$samba_cv_HAVE_LINUX_SPLICE" = x"yes"; then
6249   AC_DEFINE(HAVE_LINUX_SPLICE,1,
6250              [Whether Linux splice is available])
6253 AC_HAVE_DECL(splice, [#include <fcntl.h>])
6255 ############################################
6256 # See if we have the a broken readlink syscall.
6258 AC_CACHE_CHECK([for a broken readlink syscall],samba_cv_HAVE_BROKEN_READLINK,[
6259 AC_TRY_RUN([#include "${srcdir-.}/../tests/readlink.c"],
6260         samba_cv_HAVE_BROKEN_READLINK=no,samba_cv_HAVE_BROKEN_READLINK=yes,samba_cv_HAVE_BROKEN_READLINK=cross)
6262 if test x"$samba_cv_HAVE_BROKEN_READLINK" = x"yes"; then
6263         AC_DEFINE(HAVE_BROKEN_READLINK,1,[Whether the readlink syscall is broken])
6266 #################################################
6267 # Check whether winbind is supported on this platform.  If so we need to
6268 # build and install client programs, sbin programs and shared libraries
6270 AC_MSG_CHECKING(whether to build winbind)
6272 # Initially, the value of $host_os decides whether winbind is supported
6274 HAVE_WINBIND=yes
6275 HAVE_WBCLIENT=no
6277 # Define external wbclient library to link against.  This disables winbind.
6278 # We define this here so --with-winbind can override it.
6279 AC_ARG_WITH(wbclient,
6280 [AS_HELP_STRING([--with-wbclient], [Use external wbclient (optional)])],
6282   case "$withval" in
6283         no)
6284                 HAVE_WBCLIENT=no
6285                 ;;
6286         yes)
6287                 HAVE_WBCLIENT=yes
6288                 HAVE_WINBIND=no
6289                 ;;
6290         *)
6291                 HAVE_WBCLIENT=yes
6292                 HAVE_WINBIND=no
6293                 WBCLIENT_INCLUDES="-I$withval/include"
6294                 WBCLIENT_LDFLAGS="-L$withval/lib"
6295                 ;;
6296   esac ],
6299 AC_SUBST(WBCLIENT_INCLUDES)
6300 AC_SUBST(WBCLIENT_LDFLAGS)
6301 AC_SUBST(WBCLIENT_LIBS)
6304 # Define the winbind shared library name and any specific linker flags
6305 # it needs to be built with.
6307 WINBIND_NSS="../nsswitch/libnss_winbind.$SHLIBEXT"
6308 WINBIND_WINS_NSS="../nsswitch/libnss_wins.$SHLIBEXT"
6309 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
6310 NSSSONAMEVERSIONSUFFIX=""
6312 case "$host_os" in
6313         *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
6314                 NSSSONAMEVERSIONSUFFIX=".2"
6315                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_linux.o"
6316                 ;;
6317         *freebsd[[5-9]]*)
6318                 # FreeBSD winbind client is implemented as a wrapper around
6319                 # the Linux version.
6320                 NSSSONAMEVERSIONSUFFIX=".1"
6321                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_freebsd.o \
6322                     ../nsswitch/winbind_nss_linux.o"
6323                 WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
6324                 WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
6325                 ;;
6327         *netbsd*[[3-9]]*)
6328                 # NetBSD winbind client is implemented as a wrapper
6329                 # around the Linux version. It needs getpwent_r() to
6330                 # indicate libc's use of the correct nsdispatch API.
6331                 #
6332                 if test x"$ac_cv_func_getpwent_r" = x"yes"; then
6333                         WINBIND_NSS_EXTRA_OBJS="\
6334                             ../nsswitch/winbind_nss_netbsd.o \
6335                             ../nsswitch/winbind_nss_linux.o"
6336                         WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
6337                         WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
6338                 else
6339                         HAVE_WINBIND=no
6340                         winbind_no_reason=", getpwent_r is missing on $host_os so winbind is unsupported"
6341                 fi
6342                 ;;
6343         *irix*)
6344                 # IRIX has differently named shared libraries
6345                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_irix.o"
6346                 WINBIND_NSS="../nsswitch/libns_winbind.$SHLIBEXT"
6347                 WINBIND_WINS_NSS="../nsswitch/libns_wins.$SHLIBEXT"
6348                 ;;
6349         *solaris*)
6350                 # Solaris winbind client is implemented as a wrapper around
6351                 # the Linux version.
6352                 NSSSONAMEVERSIONSUFFIX=".1"
6353                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o \
6354                     ../nsswitch/winbind_nss_linux.o"
6355                 ;;
6356         *hpux11*)
6357                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o"
6358                 ;;
6359         *aix*)
6360                 # AIX has even differently named shared libraries.  No
6361                 # WINS support has been implemented yet.
6362                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_aix.o"
6363                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
6364                 WINBIND_NSS="../nsswitch/WINBIND"
6365                 WINBIND_WINS_NSS=""
6366                 ;;
6367         *)
6368                 HAVE_WINBIND=no
6369                 winbind_no_reason=", unsupported on $host_os"
6370                 ;;
6371 esac
6373 # Check the setting of --with-winbind
6375 AC_ARG_WITH(winbind,
6376 [AS_HELP_STRING([--with-winbind], [Build winbind (default, if supported by OS)])],
6378   case "$withval" in
6379         yes)
6380                 HAVE_WINBIND=yes
6381                 HAVE_WBCLIENT=no
6382                 ;;
6383         no)
6384                 HAVE_WINBIND=no
6385                 winbind_reason=""
6386                 ;;
6387   esac ],
6390 # We need unix domain sockets for winbind
6392 if test x"$HAVE_WINBIND" = x"yes"; then
6393         if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"no"; then
6394                 winbind_no_reason=", no unix domain socket support on $host_os"
6395                 HAVE_WINBIND=no
6396         fi
6399 # Display test results
6401 if test x"$HAVE_WINBIND" = x"no"; then
6402         WINBIND_NSS=""
6403         WINBIND_WINS_NSS=""
6405 if test x"$HAVE_WBCLIENT" = x"yes"; then
6406         AC_CHECK_LIB(wbclient, wbcInterfaceDetails,
6407                      [LIBWBCLIENT_LIBS="-lwbclient"], AC_MSG_ERROR([Could not find wbclient]), [$WBCLIENT_LDFLAGS])
6408         LIBWBCLIENT_LIBS="$LIBWBCLIENT_LIBS $WBCLIENT_LDFLAGS"
6409         AC_MSG_RESULT(yes)
6410         AC_DEFINE(WITH_WINBIND,1,[Whether to link to wbclient])
6411         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
6412 else
6413         if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
6414                 BUILD_LIBWBCLIENT_SHARED=no
6415         else
6416                 BUILD_LIBWBCLIENT_SHARED=yes
6417         fi
6419         LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
6420         LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
6421         LIBWBCLIENT_SOVER=0
6422         LIBWBCLIENT_FULLVER=0
6423         LIBWBCLIENT_SHARED_TARGET_SOVER=$LIBWBCLIENT_SHARED_TARGET.$LIBWBCLIENT_SOVER
6424         LIBWBCLIENT_SHARED_TARGET_FULLVER=$LIBWBCLIENT_SHARED_TARGET.$LIBWBCLIENT_FULLVER
6425         if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
6426                 NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
6427                 ## Only worry about libwbclient if we have shared
6428                 # library support
6429                 LIBWBCLIENT_SHARED=$LIBWBCLIENT_SHARED_TARGET
6430                 LIBWBCLIENT=libwbclient
6431                 INSTALL_LIBWBCLIENT=installlibwbclient
6432                 UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
6433                 LIBWBCLIENT_LIBS="-lwbclient"
6434         else
6435                 LIBWBCLIENT_STATIC=$LIBWBCLIENT_STATIC_TARGET
6436                 LIBWBCLIENT_LIBS=$LIBWBCLIENT_STATIC_TARGET
6437         fi
6440 if test x"$HAVE_WINBIND" = x"yes"; then
6441         AC_MSG_RESULT(yes)
6442         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
6444         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
6445         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
6446         if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
6447                 PAM_MODULES="$PAM_MODULES pam_winbind"
6448                 INSTALL_PAM_MODULES="installpammodules"
6449                 UNINSTALL_PAM_MODULES="uninstallpammodules"
6450         fi
6452         # we use winbind, check for krb5 locate_plugin support:
6453         AC_CHECK_HEADERS([krb5/locate_plugin.h], [], [],
6454                 [[#ifdef HAVE_KRB5_H
6455                  #include <krb5.h>
6456                  #endif
6457         ]])
6458         if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
6459                 WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
6460                 if test x"$BLDSHARED" = x"true" ; then
6461                         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
6462                 fi
6463         fi
6464         # end of krb5 locate_plugin check
6465 else
6466         AC_MSG_RESULT(no$winbind_no_reason)
6469 AC_SUBST(WINBIND_NSS)
6470 AC_SUBST(WINBIND_WINS_NSS)
6471 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
6472 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
6473 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
6475 AC_SUBST(WINBIND_KRB5_LOCATOR)
6477 # Solaris 10 does have new member in nss_XbyY_key
6478 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
6479                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
6480                 [#include <nss_dbdefs.h>])
6482 # Solaris has some extra fields in struct passwd that need to be
6483 # initialised otherwise nscd crashes.
6485 AC_CHECK_MEMBER(struct passwd.pw_comment,
6486                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
6487                 [#include <pwd.h>])
6489 AC_CHECK_MEMBER(struct passwd.pw_age,
6490                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
6491                 [#include <pwd.h>])
6493 # AIX 4.3.x and 5.1 do not have as many members in
6494 # struct secmethod_table as AIX 5.2
6495 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
6496        [#include <usersec.h>])
6497 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
6498        [#include <usersec.h>])
6500 AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
6501 AC_TRY_COMPILE([#include <sys/types.h>
6502 #include <sys/socket.h>],
6503 [struct ucred cred;
6504  socklen_t cred_len;
6505  int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
6507 samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
6508 if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
6509     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
6512 AC_CACHE_CHECK([for getpeereid],samba_cv_HAVE_GETPEEREID,[
6513 AC_TRY_LINK([#include <sys/types.h>
6514 #include <unistd.h>],
6515 [uid_t uid; gid_t gid; int ret;
6516  ret = getpeereid(0, &uid, &gid);
6518 samba_cv_HAVE_GETPEEREID=yes,samba_cv_HAVE_GETPEEREID=no)])
6519 if test x"$samba_cv_HAVE_GETPEEREID" = xyes; then
6520    AC_DEFINE(HAVE_GETPEEREID,1,
6521              [Whether we have getpeereid to get socket credentials])
6525 #################################################
6526 # Check to see if we should use the included popt
6528 AC_ARG_WITH(included-popt,
6529 [AS_HELP_STRING([--with-included-popt], [use bundled popt library, not from system])],
6531   case "$withval" in
6532         yes)
6533                 INCLUDED_POPT=yes
6534                 ;;
6535         no)
6536                 INCLUDED_POPT=no
6537                 ;;
6538   esac ],
6540 if test x"$INCLUDED_POPT" != x"yes"; then
6541     AC_CHECK_LIB(popt, poptGetContext,
6542                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
6545 AC_MSG_CHECKING(whether to use included popt)
6546 if test x"$INCLUDED_POPT" = x"yes"; then
6547     AC_MSG_RESULT(yes)
6548     BUILD_POPT='$(POPT_OBJ)'
6549     POPTLIBS='$(POPT_OBJ)'
6550     FLAGS1="-I\$(srcdir)/../lib/popt"
6551 else
6552     AC_MSG_RESULT(no)
6553         BUILD_POPT=""
6554     POPTLIBS="-lpopt"
6556 AC_SUBST(BUILD_POPT)
6557 AC_SUBST(POPTLIBS)
6558 AC_SUBST(FLAGS1)
6560 #################################################
6561 # Check if user wants DNS service discovery support
6563 AC_ARG_ENABLE(dnssd,
6564 [AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=no)])])
6566 AC_SUBST(DNSSD_LIBS)
6567 if test x"$enable_dnssd" = x"yes"; then
6568     have_dnssd_support=yes
6570     AC_CHECK_HEADERS(dns_sd.h)
6571     if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
6572         have_dnssd_support=no
6573     fi
6575     # On Darwin the DNSSD API is in libc, but on other platforms it's
6576     # probably in -ldns_sd
6577     AC_CHECK_FUNCS(DNSServiceRegister)
6578     AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
6579     if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
6580             x"$ac_cv_lib_ext_dns_sd_DNSServiceRegister" != x"yes"; then
6581         have_dnssd_support=no
6582     fi
6584     if test x"$have_dnssd_support" = x"yes"; then
6585         AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
6586                 [Whether to enable DNS service discovery support])
6587     else
6588         if test x"$enable_dnssd" = x"yes"; then
6589             AC_MSG_ERROR(DNS service discovery support not available)
6590         fi
6591     fi
6595 #################################################
6596 # Check if user wants avahi support
6598 AC_ARG_ENABLE(avahi,
6599 [AS_HELP_STRING([--enable-avahi], [Enable Avahi support (default=auto)])])
6601 if test x"$enable_avahi" != x"no"; then
6602     have_avahi_support=yes
6604     AC_CHECK_HEADERS(avahi-common/watch.h)
6605     if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
6606         have_avahi_support=no
6607     fi
6609     AC_CHECK_HEADERS(avahi-client/client.h)
6610     if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
6611         have_avahi_support=no
6612     fi
6614     save_LIBS="$LIBS"
6615     AC_CHECK_LIB(avahi-client, avahi_client_new,[have_avahi_client_new=yes])
6616     AC_CHECK_LIB(avahi-common, avahi_strerror,[have_avahi_strerror=yes])
6617     LIBS="$save_LIBS"
6619     if test x"$have_avahi_client_new" != x"yes" -o \
6620        x"$have_avahi_strerror" != x"yes" ; then
6621         have_avahi_support=no
6622     fi
6624     if test x"$have_avahi_support" = x"yes"; then
6625         AC_SUBST(AVAHI_LIBS, "-lavahi-client -lavahi-common")
6626         AC_DEFINE(WITH_AVAHI_SUPPORT, 1,
6627                 [Whether to enable avahi support])
6628         AC_SUBST(AVAHI_OBJ, "lib/avahi.o smbd/avahi_register.o")
6629     else
6630         if test x"$enable_avahi" = x"yes"; then
6631             AC_MSG_ERROR(avahi support not available)
6632         fi
6633     fi
6637 #################################################
6638 # Set pthread stuff
6640 PTHREAD_CFLAGS=error
6641 PTHREAD_LDFLAGS=error
6643 # If it's error, then the user didn't 
6644 # define it.
6645 if test "x$PTHREAD_LDFLAGS" = xerror; then
6646   AC_CHECK_LIB(pthread, pthread_attr_init, [
6647              PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
6648              PTHREAD_LDFLAGS="-lpthread" ])
6651 if test "x$PTHREAD_LDFLAGS" = xerror; then
6652   AC_CHECK_LIB(pthreads, pthread_attr_init, [
6653              PTHREAD_CFLAGS="-D_THREAD_SAFE"
6654              PTHREAD_LDFLAGS="-lpthreads" ])
6657 if test "x$PTHREAD_LDFLAGS" = xerror; then
6658    AC_CHECK_LIB(c_r, pthread_attr_init, [
6659                 PTHREAD_CFLAGS="-D_THREAD_SAFE -pthread"
6660                 PTHREAD_LDFLAGS="-pthread" ])
6663 if test "x$PTHREAD_LDFLAGS" = xerror; then
6664    AC_CHECK_FUNC(pthread_attr_init, [
6665                  PTHREAD_CFLAGS="-D_REENTRANT"
6666                  PTHREAD_LDFLAGS="-lpthread" ])
6669 # especially for HP-UX, where the AC_CHECK_FUNC macro fails to test for
6670 # pthread_attr_init. On pthread_mutex_lock it works there...
6671 if test "x$PTHREAD_LDFLAGS" = xerror; then
6672    AC_CHECK_LIB(pthread, pthread_mutex_lock, [
6673                 PTHREAD_CFLAGS="-D_REENTRANT"
6674                 PTHREAD_LDFLAGS="-lpthread" ])
6677 AC_SUBST(PTHREAD_CFLAGS)
6678 AC_SUBST(PTHREAD_LDFLAGS)
6680 samba_cv_HAVE_PTHREAD=no
6681 if test x"$PTHREAD_CFLAGS" != xerror -a x"$PTHREAD_LDFLAGS" != xerror; then
6682         samba_cv_HAVE_PTHREAD=yes
6683         # now check for pthread.h with pthread-correct CFLAGS and LDFLAGS:
6684         ac_save_CFLAGS=$CFLAGS
6685         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
6686         ac_save_LDFLAGS=$LDFLAGS
6687         LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
6688         AC_CHECK_HEADERS(pthread.h)
6689         CFLAGS=$ac_save_CFLAGS
6690         LDFLAGS=$ac_save_LDFLAGS
6691         AC_DEFINE(HAVE_PTHREAD, 1, [Do we have pthreads around?])
6694 #################################################
6695 # Check if user wants pthreadpool support
6697 AC_ARG_ENABLE(pthreadpool,
6698 [AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=no)])])
6700 if test x"$enable_pthreadpool" = xyes -a x"$samba_cv_HAVE_PTHREAD" != x"yes"; then
6701         AC_MSG_ERROR([pthreadpool support cannot be enabled when pthread support was not found])
6704 if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
6705     LIBS="$LIBS $PTHREAD_LDFLAGS"
6706     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
6707     AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
6708     AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool/pthreadpool.o")
6709     PTHREADPOOLTEST="bin/pthreadpooltest\$(EXEEXT)"
6710     AC_SUBST(PTHREADPOOLTEST)
6711     if test x"$samba_cv_HAVE_AIO" = x"yes"; then
6712         default_shared_modules="$default_shared_modules vfs_aio_pthread"
6713     fi
6716 #################################################
6717 # Check to see if we should use the included iniparser
6719 AC_ARG_WITH(included-iniparser,
6720 [AS_HELP_STRING([--with-included-iniparser], [use bundled iniparser library, not from system])],
6722   case "$withval" in
6723         yes)
6724                 INCLUDED_INIPARSER=yes
6725                 ;;
6726         no)
6727                 INCLUDED_INIPARSER=no
6728                 ;;
6729   esac ],
6731 if test x"$INCLUDED_INIPARSER" != x"yes"; then
6732     AC_CHECK_LIB(iniparser, iniparser_load,
6733                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
6736 AC_MSG_CHECKING(whether to use included iniparser)
6737 if test x"$INCLUDED_INIPARSER" = x"yes"; then
6738     AC_MSG_RESULT(yes)
6739     BUILD_INIPARSER='$(INIPARSER_OBJ)'
6740         INIPARSERLIBS=""
6741     FLAGS1="$FLAGS1 -I\$(srcdir)/../lib/iniparser/src"
6742 else
6743     AC_MSG_RESULT(no)
6744         BUILD_INIPARSER=""
6745     INIPARSERLIBS="-liniparser"
6747 AC_SUBST(BUILD_INIPARSER)
6748 AC_SUBST(INIPARSERLIBS)
6749 AC_SUBST(FLAGS1)
6751 ###################################################
6752 # Check for different/missing (set|get|end)netgrent prototypes
6753 CFLAGS_SAVE=$CFLAGS
6754 if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
6755         CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
6757 AC_CACHE_CHECK([for setnetgrent prototype],samba_cv_setnetgrent_prototype, [
6758     AC_TRY_COMPILE([#include<netdb.h>
6759                     #ifdef HAVE_NETGROUP_H
6760                     #include<netgroup.h>
6761                     #endif],[setnetgrent("foo")],
6762                     samba_cv_setnetgrent_prototype=yes, samba_cv_setnetgrent_prototype=no)])
6763 if test x"$samba_cv_setnetgrent_prototype" = x"yes"; then
6764     AC_DEFINE(HAVE_SETNETGRENT_PROTOTYPE, 1, [If setnetgrent prototype is defined])
6766 AC_CACHE_CHECK([for getnetgrent prototype],samba_cv_getnetgrent_prototype, [
6767     AC_TRY_COMPILE([#include<netdb.h>
6768                     #ifdef HAVE_NETGROUP_H
6769                     #include<netgroup.h>
6770                     #endif],[char *dom, *user,*host; getnetgrent(&dom,&user,&host)],
6771                     samba_cv_getnetgrent_prototype=yes, samba_cv_getnetgrent_prototype=no)])
6772 if test x"$samba_cv_getnetgrent_prototype" = x"yes"; then
6773     AC_DEFINE(HAVE_GETNETGRENT_PROTOTYPE, 1, [If getnetgrent prototype is defined])
6775 AC_CACHE_CHECK([for endnetgrent prototype],samba_cv_endnetgrent_prototype, [
6776     AC_TRY_COMPILE([#include<netdb.h>
6777                     #ifdef HAVE_NETGROUP_H
6778                     #include<netgroup.h>
6779                     #endif],[endnetgrent()],
6780                     samba_cv_endnetgrent_prototype=yes, samba_cv_endnetgrent_prototype=no)])
6781 if test x"$samba_cv_endnetgrent_prototype" = x"yes"; then
6782     AC_DEFINE(HAVE_ENDNETGRENT_PROTOTYPE, 1, [If endnetgrent prototype is defined])
6785 CFLAGS=$CFLAGS_SAVE
6787 # Checks for the vfs_fileid module
6788 # Start
6789 AC_CHECK_FUNC(getmntent)
6791 AC_CHECK_HEADERS(sys/statfs.h)
6793 AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
6794 AC_CACHE_VAL(vfsfileid_cv_statfs,[
6795              AC_TRY_RUN([
6796                 #include <sys/types.h>
6797                 #include <sys/statfs.h>
6798                 int main(void)
6799                 {
6800                         struct statfs fsd;
6801                         fsid_t fsid = fsd.f_fsid;
6802                         return statfs (".", &fsd);
6803                 }],
6804                 vfsfileid_cv_statfs=yes,
6805                 vfsfileid_cv_statfs=no,
6806                 vfsfileid_cv_statfs=cross)
6808 AC_MSG_RESULT($vfsfileid_cv_statfs)
6810 if test x"$ac_cv_func_getmntent" = x"yes" -a \
6811         x"$vfsfileid_cv_statfs" = x"yes"; then
6812         default_shared_modules="$default_shared_modules vfs_fileid"
6814 # End
6815 # Checks for the vfs_fileid module
6818 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
6820         eval MODULE_DEFAULT_$i=STATIC
6821 done
6823 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
6825         dnl Fall back to static if we cannot build shared libraries
6826         eval MODULE_DEFAULT_$i=STATIC
6828         if test $BLDSHARED = true; then
6829                 eval MODULE_DEFAULT_$i=SHARED
6830         fi
6831 done
6833 dnl Always build these modules static
6834 MODULE_rpc_spoolss=STATIC
6835 MODULE_rpc_srvsvc=STATIC
6836 MODULE_idmap_tdb=STATIC
6837 MODULE_idmap_passdb=STATIC
6838 MODULE_idmap_nss=STATIC
6840 MODULE_nss_info_template=STATIC
6842 AC_ARG_WITH(static-modules,
6843 [AS_HELP_STRING([--with-static-modules=MODULES], [Comma-separated list of names of modules to statically link in])],
6844 [ if test $withval; then
6845         for i in `echo $withval | sed -e 's/,/ /g'`
6846         do
6847                 eval MODULE_$i=STATIC
6848         done
6849 fi ])
6851 AC_ARG_WITH(shared-modules,
6852 [AS_HELP_STRING([--with-shared-modules=MODULES], [Comma-separated list of names of modules to build shared])],
6853 [ if test $withval; then
6854         for i in `echo $withval | sed -e 's/,/ /g'`
6855         do
6856                         eval MODULE_$i=SHARED
6857         done
6858 fi ])
6860 if test x"$MODULE_DEFAULT_vfs_notify_fam" = xSTATIC -o \
6861                 x"$MODULE_vfs_notify_fam" = xSTATIC ; then
6862         SMBD_FAM_LIBS="$SMB_FAM_LIBS"
6863         AC_SUBST(SMBD_FAM_LIBS)
6866 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o passdb/pdb_ipa.o,
6867                    "bin/ldapsam.$SHLIBEXT", PDB,
6868                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
6869 SMB_MODULE(pdb_ads, passdb/pdb_ads.o \$(TLDAP_OBJ), "bin/ads.$SHLIBEXT", PDB)
6870 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
6871 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
6872 SMB_MODULE(pdb_wbc_sam, passdb/pdb_wbc_sam.o, "bin/wbc_sam.$SHLIBEXT", PDB)
6873 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
6875 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
6876 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
6877 SMB_MODULE(idmap_tdb2, winbindd/idmap_tdb2.o, "bin/tdb2.$SHLIBEXT", IDMAP)
6878 SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
6879 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
6880 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
6881 SMB_MODULE(idmap_autorid, winbindd/idmap_autorid.o, "bin/autorid.$SHLIBEXT", IDMAP)
6882 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
6883 SMB_MODULE(idmap_hash, \$(IDMAP_HASH_OBJ), "bin/hash.$SHLIBEXT", IDMAP)
6884 SMB_MODULE(idmap_adex, \$(IDMAP_ADEX_OBJ), "bin/adex.$SHLIBEXT", IDMAP)
6885 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
6887 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
6888 SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
6890 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
6891 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
6892 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
6893 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
6894 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
6896 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
6897 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
6898 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
6899 SMB_MODULE(auth_wbc, \$(AUTH_WBC_OBJ), "bin/wbc.$SHLIBEXT", AUTH)
6900 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
6901 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
6902 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
6903 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
6904 SMB_MODULE(auth_netlogond, \$(AUTH_NETLOGOND_OBJ), "bin/netlogond.$SHLIBEXT", AUTH)
6905 SMB_SUBSYSTEM(AUTH,auth/auth.o)
6907 SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
6908 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
6909 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
6910 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
6911 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
6912 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
6913 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
6914 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
6915 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
6916 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
6917 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
6918 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
6919 SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
6920 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
6921 SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
6922 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
6923 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
6924 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
6925 SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
6926 SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
6927 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
6928 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
6929 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
6930 SMB_MODULE(vfs_streams_xattr, \$(VFS_STREAMS_XATTR_OBJ), "bin/streams_xattr.$SHLIBEXT", VFS)
6931 SMB_MODULE(vfs_streams_depot, \$(VFS_STREAMS_DEPOT_OBJ), "bin/streams_depot.$SHLIBEXT", VFS)
6932 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
6933 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
6934 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
6935 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
6936 SMB_MODULE(vfs_gpfs_hsm_notify, \$(VFS_GPFS_PREFETCH_OBJ), "bin/gpfs_hsm_notify.$SHLIBEXT", VFS)
6937 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
6938 SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
6939 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
6940 SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS)
6941 SMB_MODULE(vfs_aio_pthread, \$(VFS_AIO_PTHREAD_OBJ), "bin/aio_pthread.$SHLIBEXT", VFS)
6942 SMB_MODULE(vfs_preopen, \$(VFS_PREOPEN_OBJ), "bin/preopen.$SHLIBEXT", VFS)
6943 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
6944 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
6945 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
6946 SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS)
6947 SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
6948 SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_traffic_analyzer.$SHLIBEXT", VFS)
6949 SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
6950 SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_copy.$SHLIBEXT", VFS)
6951 SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS)
6952 SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT", VFS)
6953 SMB_MODULE(vfs_crossrename, \$(VFS_CROSSRENAME_OBJ), "bin/crossrename.$SHLIBEXT", VFS)
6954 SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$SHLIBEXT", VFS)
6955 SMB_MODULE(vfs_time_audit, \$(VFS_TIME_AUDIT_OBJ), "bin/time_audit.$SHLIBEXT", VFS)
6957 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
6959 SMB_MODULE(perfcount_onefs, \$(PERFCOUNT_ONEFS), "bin/pc_onefs.$SHLIBEXT", PERFCOUNT)
6960 SMB_MODULE(perfcount_test, \$(PERFCOUNT_TEST), "bin/pc_test.$SHLIBEXT", PERFCOUNT)
6961 SMB_SUBSYSTEM(PERFCOUNT,smbd/perfcount.o)
6963 SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT)
6964 SMB_MODULE(gpext_scripts, libgpo/gpext/scripts.o, "bin/scripts.$SHLIBEXT", GPEXT)
6965 SMB_MODULE(gpext_security, libgpo/gpext/security.o, "bin/security.$SHLIBEXT", GPEXT)
6966 SMB_SUBSYSTEM(GPEXT, libgpo/gpext/gpext.o)
6968 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
6970 #################################################
6971 # do extra things if we are running insure
6973 if test "${ac_cv_prog_CC}" = "insure"; then
6974         CPPFLAGS="$CPPFLAGS -D__INSURE__"
6977 #################################################
6978 # If run from the build farm, enable NASTY hacks
6979 #################################################
6980 AC_MSG_CHECKING(whether to enable build farm hacks)
6981 if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
6982         AC_MSG_RESULT(yes)
6983         AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
6984 else
6985         AC_MSG_RESULT(no)
6988 #################################################
6989 # check for bad librt/libpthread interactions
6991 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
6992     x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
6993     x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6994     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6996 SMB_IF_RTSIGNAL_BUG(
6997         [
6998             # Have RT_SIGNAL bug, need to check whether the problem will
6999             # affect anything we have configured.
7001             rt_do_error=no
7002             if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
7003                 if test x"$rt_signal_lease_ok" = x"no" ; then
7004                     rt_do_error=yes
7005                 fi
7006             fi
7008             if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
7009                 if test x"$rt_signal_notify_ok" = x"no" ; then
7010                     rt_do_error=yes
7011                 fi
7012             fi
7014             if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
7015                     x"$samba_cv_HAVE_AIO" = x"yes" ; then
7016                 if test x"$rt_signal_aio_ok" = x"no" ; then
7017                     rt_do_error=yes
7018                 fi
7019             fi
7021             if test x"$rt_do_error" = x"yes" ; then
7022                 SMB_IS_LIBPTHREAD_LINKED(
7023                     [
7024                         cat<<MSG
7026 *** On this platforms, linking Samba against pthreads causes problems
7027 *** with the oplock and change notification mechanisms. You may be
7028 *** using pthreads as a side-effect of using the --with-aio-support
7029 *** or --with-profiling-data options. Please remove these and try again.
7032                     ],
7033                     [
7034                         cat<<MSG
7036 *** On this platform, the oplock and change notification mechanisms do not
7037 *** appear to work. Please report this problem to samba-technical@samba.org
7038 *** and attach the config.log file from this directory.
7041                     ])
7042                 AC_MSG_ERROR(unable to use realtime signals on this platform)
7043             fi
7044         ],
7045         [
7046             # no RT_SIGNAL bug, we are golden
7047             SMB_IS_LIBPTHREAD_LINKED(
7048                 [
7049                     AC_MSG_WARN(using libpthreads - this may degrade performance)
7050                 ])
7052         ],
7053         [
7054             # cross compiling, I hope you know what you are doing
7055             true
7056         ])
7060 m4_include(../lib/zlib/zlib.m4)
7062 if test x$smbtorture4_possible = xyes; then
7063         saved_USESHARED="$USESHARED"
7064         USESHARED="false"
7065         smbtorture4_path="bin/smbtorture4"
7066         smbtorture4_option="-t bin/smbtorture4"
7067         AC_SUBST(smbtorture4_path)
7068         AC_SUBST(smbtorture4_option)
7069         USESHARED="$saved_USESHARED"
7070         SMBTORTURE4="bin/smbtorture4"
7071         AC_SUBST(SMBTORTURE4)
7074 AC_SUBST(ZLIB_LIBS)
7075 AC_SUBST(ZLIB_OBJS)
7076 AC_ZLIB([ZLIB_OBJS=""], [
7077         ZLIB_LIBS=""
7078         for o in adler32.o compress.o crc32.o gzio.o uncompr.o \
7079                      deflate.o trees.o zutil.o inflate.o infback.o \
7080                          inftrees.o inffast.o
7081         do
7082                 ZLIB_OBJS="$ZLIB_OBJS ../lib/zlib/$o"
7083         done
7084         CFLAGS="-I../lib/zlib $CFLAGS"
7087 AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
7089 if test "x$enable_dmalloc" = xyes
7090 then
7091         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
7092         AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
7093                   [Define to check invariants around some common functions])
7094         LIBS="$LIBS -ldmalloc"
7097 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
7098 LIB_REMOVE_USR_LIB(LDFLAGS)
7099 LIB_REMOVE_USR_LIB(LIBS)
7101 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
7102 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
7103 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
7105 #################################################
7106 # Display summary of libraries detected
7108 AC_MSG_RESULT([Using libraries:])
7109 AC_MSG_RESULT([    LIBS = $LIBS])
7110 if test x"$with_ads_support" != x"no"; then
7111     AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
7113 if test x"$with_ldap_support" != x"no"; then
7114     AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
7116 if test x"$with_dnsupdate_support" != x"no"; then
7117     AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
7119 if test x"$have_dnssd_support" != x"no"; then
7120     AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
7122 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
7124 #################################################
7125 # final configure stuff
7127 AC_MSG_CHECKING([configure summary])
7128 AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
7129            AC_MSG_RESULT(yes),
7130            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
7131            AC_MSG_WARN([cannot run when cross-compiling]))
7133 dnl Merge in developer cflags from now on
7134 AC_SUBST(DEVELOPER_CFLAGS)
7135 if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes" -o x"$picky_developer" = x"yes"; then
7136     CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
7139 # Stuff the smbd-only libraries at the end of the smbd link
7140 # path (if we have them).
7141 SMBD_LIBS="$samba_dmapi_libs"
7142 AC_SUBST(SMBD_LIBS)
7144 CFLAGS="${CFLAGS} \$(FLAGS)"
7145 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
7147 # If we had to expand the includes, make tsure the output file is moved back
7148 AC_OUTPUT_COMMANDS([
7149 if test -f Makefile-noincludes -a ! -f Makefile -a ! -h Makefile ; then
7150         ln -s Makefile-noincludes Makefile
7154 AC_OUTPUT(Makefile
7155           script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
7156           lib/netapi/examples/Makefile
7157           lib/netapi/tests/Makefile
7158           pkgconfig/smbclient.pc
7159           pkgconfig/wbclient.pc
7160           pkgconfig/netapi.pc
7161           pkgconfig/smbsharemodes.pc
7162           ../examples/libsmbclient/Makefile.internal
7163           )
7165 #################################################
7166 # Print very concise instructions on building/use
7167 if test "x$enable_dmalloc" = xyes
7168 then
7169         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
7170         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])