s3: Add vfs_linux_xfs_sgid
[Samba/ekacnet.git] / source3 / configure.in
blob146dc855cfc5807c44ecb8f5034c6b5f1dac7646
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
27 m4_include(../lib/tevent/libtevent.m4)
29 LIBTEVENT_OBJ0=""
30 for obj in ${TEVENT_OBJ}; do
31         LIBTEVENT_OBJ0="${LIBTEVENT_OBJ0} ${teventdir}/${obj}"
32 done
33 AC_SUBST(LIBTEVENT_OBJ0)
34 LIBS="${LIBS} ${TEVENT_LIBS}"
36 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
37 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
38 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
39 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
40 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
41 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
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)
73 AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
74 AC_SUBST(LIBWBCLIENT_STATIC)
75 AC_SUBST(LIBWBCLIENT_SOVER)
76 AC_SUBST(LIBWBCLIENT)
77 AC_SUBST(LIBWBCLIENT_LIBS)
79 AC_SUBST(LIBSAMBAUTIL_SHARED)
81 AC_SUBST(PRINT_LIBS)
82 AC_SUBST(AUTH_LIBS)
83 AC_SUBST(ACL_LIBS)
84 AC_SUBST(PASSDB_LIBS)
85 AC_SUBST(IDMAP_LIBS)
86 AC_SUBST(KRB5_LIBS)
87 AC_SUBST(UUID_LIBS)
88 AC_SUBST(LDAP_LIBS)
89 AC_SUBST(GPEXT_LIBS)
90 AC_SUBST(PAM_MODULES)
91 AC_SUBST(INSTALL_PAM_MODULES)
92 AC_SUBST(UNINSTALL_PAM_MODULES)
93 AC_SUBST(NSS_MODULES)
94 AC_SUBST(EXTRA_BIN_PROGS)
95 AC_SUBST(CIFSMOUNT_PROGS)
96 AC_SUBST(INSTALL_CIFSMOUNT)
97 AC_SUBST(UNINSTALL_CIFSMOUNT)
98 AC_SUBST(CIFSUMOUNT_PROGS)
99 AC_SUBST(INSTALL_CIFSUMOUNT)
100 AC_SUBST(UNINSTALL_CIFSUMOUNT)
101 AC_SUBST(CIFSUPCALL_PROGS)
102 AC_SUBST(INSTALL_CIFSUPCALL)
103 AC_SUBST(UNINSTALL_CIFSUPCALL)
104 AC_SUBST(EXTRA_SBIN_PROGS)
105 AC_SUBST(EXTRA_ALL_TARGETS)
106 AC_SUBST(CONFIG_LIBS)
107 AC_SUBST(NSCD_LIBS)
109 # compile with optimization and without debugging by default, but
110 # allow people to set their own preference.
111 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
112 # if it has no value.  This prevent *very* large debug binaries from occurring
113 # by default.
114 if test "x$debug" = "xyes" ; then
115         CFLAGS="${CFLAGS} -g"
117 if test "x$CFLAGS" = x; then
118   CFLAGS="-O"
121 m4_include(../lib/socket_wrapper/config.m4)
122 m4_include(../lib/nss_wrapper/config.m4)
123 m4_include(../lib/util/time.m4)
125 m4_include(m4/swat.m4)
127 DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
129 # Probe the gcc version for extra CFLAGS. We always stash these in
130 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
131 # Makefile edit, avoiding the need to re-run configure.
132 if test x"$ac_cv_prog_gcc" = x"yes" ; then
133         DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings"
134         # Add -Wdeclaration-after-statement if compiler supports it
135         AC_CACHE_CHECK(
136           [that the C compiler understands -Wdeclaration-after-statement],
137           samba_cv_HAVE_Wdeclaration_after_statement, [
138           AC_TRY_RUN_STRICT([
139             int main(void)
140             {
141                 return 0;
142             }],[$CFLAGS -Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
143             samba_cv_HAVE_Wdeclaration_after_statement=yes,
144             samba_cv_HAVE_Wdeclaration_after_statement=no,
145             samba_cv_HAVE_Wdeclaration_after_statement=cross)
146        ])
148         if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
149             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
150         fi
152         #-Werror-implicit-function-declaration
153         AC_CACHE_CHECK(
154           [that the C compiler understands -Werror-implicit-function-declaration],
155           samba_cv_HAVE_Werror_implicit_function_declaration, [
156           AC_TRY_RUN_STRICT([
157             int main(void)
158             {
159                 return 0;
160             }],[$CFLAGS -Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
161             samba_cv_HAVE_Werror_implicit_function_declaration=yes,
162             samba_cv_HAVE_Werror_implicit_function_declaration=no,
163             samba_cv_HAVE_Werror_implicit_function_declaration=cross)
164        ])
165        if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
166             DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
167        fi
169         # krb5developer is like developer, except we don't get
170         # -Wstrict-prototypes.
171        if test x"$krb5_developer" != x"$yes" ; then
172             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
173        fi
175        if test x"$picky_developer" = x"yes"; then
176             DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Werror"
177        fi
180 #################################################
181 # check for a shared memory profiling support
182 AC_MSG_CHECKING(whether to use profiling)
183 AC_ARG_WITH(profiling-data,
184 [AS_HELP_STRING([--with-profiling-data], [Include gathering source code profile information (default=no)])],
185 [ case "$withval" in
186   yes)
187     AC_MSG_RESULT(yes)
188     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
189     samba_cv_WITH_PROFILE=yes
190     ;;
191   *)
192     AC_MSG_RESULT(no)
193     samba_cv_WITH_PROFILE=no
194     ;;
195   esac ],
196   AC_MSG_RESULT(no)
199 dnl Checks for programs.
200 merged_build_possible=yes
202 AC_PROG_INSTALL
203 AC_PROG_AWK
204 # Check for GNU make
205 m4_include(../m4/check_make.m4)
206 AC_SAMBA_GNU_MAKE([true], [true])
208 # Check for perl
209 m4_include(../m4/check_perl.m4)
210 AC_SAMBA_PERL([true], [merged_build_possible=no])
212 AC_CHECK_TOOL(AR, ar)
214 dnl Check if we (actually our C compiler!) use GNU ld
215 AC_PROG_LD_GNU
217 dnl Certain versions of GNU ld the default is not to have the
218 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
219 dnl warnings when building modules.
220 if test "$ac_cv_prog_gnu_ld" = "yes"; then
221         ac_cv_gnu_ld_version=`$CC -Wl,-v /dev/null 2>/dev/null | head -1`
222         AC_MSG_CHECKING(GNU ld release date)
223         changequote(,)dnl
224         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'`
225         changequote([,])dnl
226         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
227         if test -n "$ac_cv_gnu_ld_date"; then
228         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
229                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
230         fi
231         if test "$ac_cv_gnu_ld_date" -gt 20030101; then
232                 ac_cv_gnu_ld_version_script=yes
233         fi
234         else
235            AC_MSG_CHECKING(GNU ld release version)
236            changequote(,)dnl
237            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'`
238            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
239            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
240            changequote([,])dnl
241            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
242            AC_MSG_CHECKING(GNU ld release version major)
243            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
244            AC_MSG_CHECKING(GNU ld release version minor)
245            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
246            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
247              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
248            fi
249            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
250              ac_cv_gnu_ld_version_script=yes
251            fi
252         fi
255 dnl look for executable suffix
256 AC_EXEEXT
258 dnl Check if C compiler understands -c and -o at the same time
259 AC_PROG_CC_C_O
260 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
261       BROKEN_CC=
262 else
263       BROKEN_CC=#
265 AC_SUBST(BROKEN_CC)
267 dnl Check if the C compiler understands -Werror (GNU)
268 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
269  AC_TRY_RUN_STRICT([
270   int main(void)
271   {
272         return 0;
273   }],[$CFLAGS -Werror],[$CPPFLAGS],[$LDFLAGS],
274   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
275 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
276    Werror_FLAGS="-Werror"
277 else
278 dnl Check if the C compiler understands -w2
279 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
280  AC_TRY_RUN_STRICT([
281   int main(void)
282   {
283         return 0;
284   }],[$CFLAGS -w2],[$CPPFLAGS],[$LDFLAGS],
285   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
286 if test x"$samba_cv_HAVE_w2" = x"yes"; then
287    Werror_FLAGS="-w2"
288 else
289 dnl Check if the C compiler understands -errwarn (Sun)
290 AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
291   AC_TRY_RUN_STRICT([
292    int main(void)
293    {
294         return 0;
295    }],[$CFLAGS -errwarn=%all],[$CPPFLAGS],[$LDFLAGS],
296    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
297 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
298    Werror_FLAGS="-errwarn=%all"
299 else
300 dnl Check if the C compiler understands -qhalt (IBM)
301 AC_CACHE_CHECK([that the C compiler understands -qhalt],samba_cv_HAVE_qhalt, [
302   AC_TRY_RUN_STRICT([
303    int main(void)
304    {
305         return 0;
306    }],[$CFLAGS -qhalt=w],[$CPPFLAGS],[$LDFLAGS],
307    samba_cv_HAVE_qhalt=yes,samba_cv_HAVE_qhalt=no,samba_cv_HAVE_qhalt=cross)])
308 if test x"$samba_cv_HAVE_qhalt" = x"yes"; then
309    Werror_FLAGS="-qhalt=w"
315 ############################################
316 # check if the compiler can handle negative enum values
317 # and don't truncate the values to INT_MAX
318 # a runtime test is needed here
319 AC_SUBST(PIDL_ARGS)
320 AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
321     AC_TRY_RUN(
323         #include <stdio.h>
324         enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
325         int main(void) {
326                 enum negative_values v1 = NEGATIVE_VALUE;
327                 unsigned v2 = NEGATIVE_VALUE;
329                 if (v1 != 0xFFFFFFFF) {
330                         printf("%u != 0xFFFFFFFF\n", v1);
331                         return 1;
332                 }
333                 if (v2 != 0xFFFFFFFF) {
334                         printf("%u != 0xFFFFFFFF\n", v2);
335                         return 1;
336                 }
338                 return 0;
339         }
341         samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv__CC_NEGATIVE_ENUM_VALUES=no)])
342 if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
343         AC_MSG_WARN([using --uint-enums for pidl])
344         PIDL_ARGS="$PIDL_ARGS --uint-enums"
347 dnl Figure out the flags to support named structure initializers
349 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
351 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
352 AC_MSG_CHECKING(uname -s)
353 AC_MSG_RESULT(${UNAME_S})
355 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
356 AC_MSG_CHECKING(uname -r)
357 AC_MSG_RESULT(${UNAME_R})
359 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
360 AC_MSG_CHECKING(uname -m)
361 AC_MSG_RESULT(${UNAME_M})
363 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
364 AC_MSG_CHECKING(uname -p)
365 AC_MSG_RESULT(${UNAME_P})
367 UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
368 AC_MSG_CHECKING(uname -i)
369 AC_MSG_RESULT(${UNAME_I})
371 dnl Add #include for broken IRIX header files
372   case "$host_os" in
373         *irix6*)
374                 #TODO add to libreplace
375                 if test x"$ac_cv_prog_gcc" != x"yes" ; then
376                         dnl Fix sensible defaults for MIPSPro compilers. The
377                         dnl error numbers are valid for the 7.3 compilers,
378                         dnl hopefully also valid for the 7.4 series.
379                         dnl
380                         dnl Bugzilla 3801. Force an error on warning 1035
381                         dnl so we don't incorrectly detect stdint.h. This
382                         dnl warning is emitted for #error directives.
383                         CFLAGS="$CFLAGS -diag_error 1035"
384                         dnl 1209: Controlling expression is constant
385                         dnl 1174: Function foo declared but never referenced
386                         dnl 3201: Parameter foo was never referenced
387                         CFLAGS="$CFLAGS -woff 1209,1174,3201"
388                 fi
389         ;;
390 esac
392 DYNEXP=
393 AC_SUBST(DYNEXP)
394 LDSHFLAGS_Z_DEFS=
395 AC_SUBST(LDSHFLAGS_Z_DEFS)
396 LDSHFLAGS_Z_NODEFS=
397 AC_SUBST(LDSHFLAGS_Z_NODEFS)
399 dnl Add modules that have to be built by default here
400 dnl These have to be built static:
401 default_static_modules=""
402 default_static_modules="$default_static_modules pdb_smbpasswd"
403 default_static_modules="$default_static_modules pdb_tdbsam"
404 default_static_modules="$default_static_modules pdb_wbc_sam"
405 default_static_modules="$default_static_modules rpc_lsarpc"
406 default_static_modules="$default_static_modules rpc_samr"
407 default_static_modules="$default_static_modules rpc_winreg"
408 default_static_modules="$default_static_modules rpc_initshutdown"
409 default_static_modules="$default_static_modules rpc_dssetup"
410 default_static_modules="$default_static_modules rpc_wkssvc"
411 default_static_modules="$default_static_modules rpc_svcctl"
412 default_static_modules="$default_static_modules rpc_ntsvcs"
413 default_static_modules="$default_static_modules rpc_netlogon"
414 default_static_modules="$default_static_modules rpc_netdfs"
415 default_static_modules="$default_static_modules rpc_srvsvc"
416 default_static_modules="$default_static_modules rpc_spoolss"
417 default_static_modules="$default_static_modules rpc_eventlog"
418 default_static_modules="$default_static_modules auth_sam"
419 default_static_modules="$default_static_modules auth_unix"
420 default_static_modules="$default_static_modules auth_winbind"
421 default_static_modules="$default_static_modules auth_wbc"
422 default_static_modules="$default_static_modules auth_server"
423 default_static_modules="$default_static_modules auth_domain"
424 default_static_modules="$default_static_modules auth_builtin"
425 default_static_modules="$default_static_modules auth_netlogond"
426 default_static_modules="$default_static_modules vfs_default"
427 default_static_modules="$default_static_modules nss_info_template"
429 dnl These are preferably build shared, and static if dlopen() is not available
430 default_shared_modules=""
431 default_shared_modules="$default_shared_modules vfs_recycle"
432 default_shared_modules="$default_shared_modules vfs_audit"
433 default_shared_modules="$default_shared_modules vfs_extd_audit"
434 default_shared_modules="$default_shared_modules vfs_full_audit"
435 default_shared_modules="$default_shared_modules vfs_netatalk"
436 default_shared_modules="$default_shared_modules vfs_fake_perms"
437 default_shared_modules="$default_shared_modules vfs_default_quota"
438 default_shared_modules="$default_shared_modules vfs_readonly"
439 default_shared_modules="$default_shared_modules vfs_cap"
440 default_shared_modules="$default_shared_modules vfs_expand_msdfs"
441 default_shared_modules="$default_shared_modules vfs_shadow_copy"
442 default_shared_modules="$default_shared_modules vfs_shadow_copy2"
443 default_shared_modules="$default_shared_modules charset_CP850"
444 default_shared_modules="$default_shared_modules charset_CP437"
445 default_shared_modules="$default_shared_modules auth_script"
446 default_shared_modules="$default_shared_modules vfs_readahead"
447 default_shared_modules="$default_shared_modules vfs_xattr_tdb"
448 default_shared_modules="$default_shared_modules vfs_streams_xattr"
449 default_shared_modules="$default_shared_modules vfs_streams_depot"
450 default_shared_modules="$default_shared_modules vfs_acl_xattr"
451 default_shared_modules="$default_shared_modules vfs_acl_tdb"
452 default_shared_modules="$default_shared_modules vfs_smb_traffic_analyzer"
453 default_shared_modules="$default_shared_modules vfs_preopen"
454 default_shared_modules="$default_shared_modules vfs_catia"
455 default_shared_modules="$default_shared_modules vfs_scannedonly"
456 default_shared_modules="$default_shared_modules vfs_crossrename"
457 default_shared_modules="$default_shared_modules vfs_linux_xfs_sgid"
459 if test "x$developer" = xyes; then
460    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
461    default_shared_modules="$default_shared_modules charset_weird perfcount_test"
465 # Config CPPFLAG settings for strange OS's that must be set
466 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
467 # case statement; its first reference must be unconditional.
469 case "$host_os" in
470     *hpux*)
472 # Defines needed for HPUX support.
473 # HPUX has bigcrypt but (sometimes?) doesn't use it for
474 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
476       case `uname -r` in
477                 *9*|*10*|*11)
478                         AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
479                 ;;
480       esac
481       ;;
484 # CRAY Unicos has broken const handling
485        *unicos*)
486           AC_MSG_RESULT([disabling const])
487           CPPFLAGS="$CPPFLAGS -Dconst="
488           ;;
489         
491 # AIX4.x doesn't even admit to having large
492 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
494     *aix4*)
495           AC_MSG_RESULT([enabling large file support])
496       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
497           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
498       ;;
500 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
501 # to the existance of large files..
502 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
503 # recommendations on large file support, however it makes the
504 # compile work using gcc 2.7 and 2.8, whereas using the Sun
505 # recommendation makes the compile fail on gcc2.7. JRA.
507 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
509         *solaris*)
510                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
511                 case `uname -r` in
512                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
513                                 AC_MSG_RESULT([no large file support])
514                                 ;;
515                         5.*)
516                         AC_MSG_RESULT([enabling large file support])
517                         if test "$ac_cv_prog_gcc" = yes; then
518                                 ${CC-cc} -v >conftest.c 2>&1
519                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
520                                 rm -fr conftest.c
521                                 case "$ac_cv_gcc_compiler_version_number" in
522                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
523                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
524                                                 LDFLAGS="$LDFLAGS -lthread"
525                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
526                                                 ;;
527                                         *)
528                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
529                                                 LDFLAGS="$LDFLAGS -lthread"
530                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
531                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
532                                                 ;;
533                                 esac
534                         else
535                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
536                                 LDFLAGS="$LDFLAGS -lthread"
537                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
538                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
539                         fi
540                         ;;
541                 esac
542                 ;;
544 # IRIX uses SYSV printing.  Make sure to set that here
546         *irix*)
547                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
548                 ;;
549         *freebsd*|*dragonfly*)
550                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
551                 ;;
553 # VOS may need to have POSIX support and System V compatibility enabled.
555     *vos*)
556     case "$CPPFLAGS" in
557           *-D_POSIX_C_SOURCE*)
558                 ;;
559           *)
560                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
561                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
562                 ;;
563     esac
564     case "$CPPFLAGS" in
565           *-D_SYSV*|*-D_SVID_SOURCE*)
566                 ;;
567           *)
568                 CPPFLAGS="$CPPFLAGS -D_SYSV"
569                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
570     esac
571     ;;
573 # Tests needed for SINIX large file support.
575     *sysv4*)
576       if test $host = mips-sni-sysv4 ; then
577         AC_MSG_CHECKING([for LFS support])
578         old_CPPFLAGS="$CPPFLAGS"
579         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
580         AC_TRY_RUN([
581 #include <unistd.h>
582 main () {
583 #if _LFS64_LARGEFILE == 1
584 exit(0);
585 #else
586 exit(1);
587 #endif
588 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
589         CPPFLAGS="$old_CPPFLAGS"
590         if test x$SINIX_LFS_SUPPORT = xyes ; then
591           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
592                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
593           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
594           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
595           LIBS="`getconf LFS64_LIBS` $LIBS"
596         fi
597       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
598       fi
599     ;;
601 # Systems with LFS support.
603     gnu* | k*bsd*-gnu | kopensolaris*-gnu)
604         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
605         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
606         AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
607         AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
608         ;;
610 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
612     *linux*)
613         AC_MSG_CHECKING([for LFS support])
614         old_CPPFLAGS="$CPPFLAGS"
615         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
616        AC_TRY_RUN([
617 #include <unistd.h>
618 #include <sys/utsname.h>
619 #include <string.h>
620 #include <stdlib.h>
621 main() {
622 #if _LFS64_LARGEFILE == 1
623        struct utsname uts;
624        char *release;
625        int major, minor;
627        /* Ensure this is glibc 2.2 or higher */
628 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
629        int libc_major = __GLIBC__;
630        int libc_minor = __GLIBC_MINOR__;
632        if (libc_major < 2)
633               exit(1);
634        if (libc_minor < 2)
635               exit(1);
636 #endif
638        /* Ensure this is kernel 2.4 or higher */
640        uname(&uts);
641        release = strdup(uts.release);
642        major = atoi(strsep(&release, "."));
643        minor = atoi(strsep(&release, "."));
645        if (major > 2 || (major == 2 && minor > 3))
646                exit(0);
647        exit(1);
648 #else
649        exit(1);
650 #endif
652 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
653         CPPFLAGS="$old_CPPFLAGS"
654         if test x$LINUX_LFS_SUPPORT = xyes ; then
655                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
656                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
657                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
658                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
659         fi
660         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
661         ;;
664 # MacOS X is the *only* system that uses compose character in utf8. This
665 # is so horribly broken....
667     *darwin*)
668         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
670 # Add a system specific charset module.
671         default_shared_modules="$default_shared_modules charset_macosxfs"
673         ;;
674     *hurd*)
675         AC_MSG_CHECKING([for LFS support])
676         old_CPPFLAGS="$CPPFLAGS"
677         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
678         AC_TRY_RUN([
679 #include <unistd.h>
680 main () {
681 #if _LFS64_LARGEFILE == 1
682 exit(0);
683 #else
684 exit(1);
685 #endif
686 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
687         CPPFLAGS="$old_CPPFLAGS"
688         if test x$GLIBC_LFS_SUPPORT = xyes ; then
689           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
690                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
691           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
692         fi
693       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
694     ;;
695     *qnx*)
696         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
697         AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
698         ;;
700 esac
702 SAVE_CPPFLAGS="${CPPFLAGS}"
703 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
705 AC_LIBREPLACE_BROKEN_CHECKS
706 AC_CHECK_FUNCS([syslog],[],[AC_MSG_ERROR([Required function not found])])
707 AC_LIBREPLACE_NETWORK_CHECKS
709 CPPFLAGS="${SAVE_CPPFLAGS}"
711 LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
713 LIBREPLACE_OBJS="${LIBREPLACEOBJ}"
714 AC_SUBST(LIBREPLACE_OBJS)
716 LIBREPLACE_LIBS="${LIBREPLACE_NETWORK_LIBS}"
717 AC_SUBST(LIBREPLACE_LIBS)
720 # add -ldl to the global LIBS
721 LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}"
722 AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
725 AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
726 AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h)
727 AC_CHECK_HEADERS(limits.h float.h libintl.h)
728 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
729 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)
730 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
731 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
732 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h)
733 AC_CHECK_HEADERS(sys/sysmacros.h)
734 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
735 AC_CHECK_HEADERS(langinfo.h locale.h)
736 AC_CHECK_HEADERS(xfs/libxfs.h)
737 AC_CHECK_HEADERS(netgroup.h)
739 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
740 #if HAVE_RPC_RPC_H
741 #include <rpc/rpc.h>
742 #endif
745 ## These fail to compile on IRIX so just check for their presence
746 AC_CHECK_HEADERS(sys/mode.h,,,)
748 # Look for Darwin headers
749 old_CPPFLAGS="$CPPFLAGS"
750 CPPFLAGS="-Iinclude $CPPFLAGS"
751 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
752 CPPFLAGS="$old_CPPFLAGS"
754 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
755 # subdirectory of headers.
756 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
759 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
760 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
762 case "$host_os" in
763     *hpux*)
764                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
765                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
766                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
767                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
768                 fi
769         ;;
770 esac
771 AC_CHECK_HEADERS(shadow.h)
772 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
773 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
775 AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
776 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
778 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
780 # For experimental utmp support (lastlog on some BSD-like systems)
781 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
783 AC_CHECK_SIZEOF(int,cross)
784 AC_CHECK_SIZEOF(long,cross)
785 AC_CHECK_SIZEOF(long long,cross)
786 AC_CHECK_SIZEOF(short,cross)
788 AC_C_CONST
789 AC_C_INLINE
790 AC_C_BIGENDIAN
791 AC_C_CHAR_UNSIGNED
793 AC_TYPE_SIGNAL
794 AC_TYPE_UID_T
795 AC_TYPE_MODE_T
796 AC_TYPE_OFF_T
797 AC_TYPE_SIZE_T
798 AC_TYPE_PID_T
799 AC_STRUCT_ST_RDEV
800 AC_DIRENT_D_OFF
801 AC_CHECK_TYPE(ssize_t, int)
802 AC_CHECK_TYPE(wchar_t, unsigned short)
804 ############################################
805 # for cups support we need libcups, and a handful of header files
807 AC_ARG_ENABLE(cups,
808 [AS_HELP_STRING([--enable-cups], [Turn on CUPS support (default=auto)])])
810 if test x$enable_cups != xno; then
811         AC_PATH_PROG(CUPS_CONFIG, cups-config)
813         if test "x$CUPS_CONFIG" != x; then
815                 ac_save_CFLAGS=$CFLAGS
816                 ac_save_LDFLAGS=$LDFLAGS
817                 ac_save_PRINT_LIBS=$PRINT_LIBS
818                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
819                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
820                 PRINT_LIBS="$PRINT_LIBS -lcups"
821                 AC_CHECK_HEADERS(cups/cups.h cups/language.h)
822                 if test x"$ac_cv_header_cups_cups_h" = xyes -a \
823                         x"$ac_cv_header_cups_language_h" = xyes; then
824                         AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
825                         samba_cv_HAVE_CUPS=yes
826                         AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
827                 else
828                         AC_MSG_WARN([cups-config around but cups-devel not installed])
829                         CFLAGS=$ac_save_CFLAGS
830                         LDFLAGS=$ac_save_LDFLAGS
831                         PRINT_LIBS=$ac_save_PRINT_LIBS
832                 fi
834         elif test x"$enable_cups" = x"yes"; then
835                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
836         fi
839 AC_ARG_ENABLE(iprint,
840 [AS_HELP_STRING([--enable-iprint], [Turn on iPrint support (default=yes if cups is yes)])])
842 if test x$enable_iprint != xno; then
843         if test x"$samba_cv_HAVE_CUPS" = xyes; then
844                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
845         elif test x"$enable_iprint" = x"yes"; then
846                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
847         fi
850 ############################################
851 # check if the compiler will optimize out function calls
852 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
853     AC_TRY_LINK([
854 #include <stdio.h>],
856                 if (0) {
857                    this_function_does_not_exist();
858                 } else {
859                   return 1;
860                 }
863         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
864 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
865    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
868 #############################################
869 # check for fd passing struct via msg_control
870 AC_CACHE_CHECK([for fd passing via msg_control],samba_cv_msghdr_msg_control, [
871     AC_TRY_COMPILE([
872 #include <sys/types.h>
873 #include <stdlib.h>
874 #include <stddef.h>
875 #include <sys/socket.h>
876 #include <sys/un.h>],
878         struct msghdr msg;
879         union {
880               struct cmsghdr cm;
881               char control[CMSG_SPACE(sizeof(int))];
882         } control_un;
883         msg.msg_control = control_un.control;
884         msg.msg_controllen = sizeof(control_un.control);
886         samba_cv_msghdr_msg_control=yes,samba_cv_msghdr_msg_control=no)])
887 if test x"$samba_cv_msghdr_msg_control" = x"yes"; then
888    AC_DEFINE(HAVE_MSGHDR_MSG_CONTROL,1,
889              [If we can use msg_control for passing file descriptors])
892 #############################################
893 # check for fd passing struct via msg_acctrights
894 AC_CACHE_CHECK([for fd passing via msg_acctrights],
895                 samba_cv_msghdr_msg_acctrights, [
896     AC_TRY_COMPILE([
897 #include <sys/types.h>
898 #include <stdlib.h>
899 #include <stddef.h>
900 #include <sys/socket.h>
901 #include <sys/un.h>],
903         struct msghdr msg;
904         int fd;
905         msg.msg_acctrights = (caddr_t) &fd;
906         msg.msg_acctrightslen = sizeof(fd);
908         samba_cv_msghdr_msg_acctrights=yes,samba_cv_msghdr_msg_acctrights=no)])
909 if test x"$samba_cv_msghdr_msg_acctrights" = x"yes"; then
910    AC_DEFINE(HAVE_MSGHDR_MSG_ACCTRIGHTS,1,
911              [If we can use msg_acctrights for passing file descriptors])
914 AC_CHECK_FUNCS(dirfd)
915 if test x"$ac_cv_func_dirfd" = x"yes"; then
916         default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort"
919 AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [
920     AC_TRY_COMPILE([
921 #include <sys/types.h>
922 #if STDC_HEADERS
923 #include <stdlib.h>
924 #include <stddef.h>
925 #endif
926 #include <signal.h>],[struct sigevent s;],
927         samba_cv_struct_sigevent=yes,samba_cv_struct_sigevent=no)])
928 if test x"$samba_cv_struct_sigevent" = x"yes"; then
929    AC_DEFINE(HAVE_STRUCT_SIGEVENT,1,[Whether we have the struct sigevent])
930    AC_CHECK_MEMBERS([struct sigevent.sigev_value.sival_ptr,struct sigevent.sigev_value.sigval_ptr], , ,
931         [#include <signal.h>])
934 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
935     AC_TRY_COMPILE([
936 #include <sys/types.h>
937 #if STDC_HEADERS
938 #include <stdlib.h>
939 #include <stddef.h>
940 #endif
941 #if TIME_WITH_SYS_TIME
942 # include <sys/time.h>
943 # include <time.h>
944 #else
945 # if HAVE_SYS_TIME_H
946 #  include <sys/time.h>
947 # else
948 #  include <time.h>
949 # endif
950 #endif
951 ],[struct timespec ts;],
952         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
953 if test x"$samba_cv_struct_timespec" = x"yes"; then
954    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
957 # and glibc has setresuid under linux but the function does
958 # nothing until kernel 2.1.44! very dumb.
959 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
960     AC_TRY_RUN([#include <errno.h>
961 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
962         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
963 if test x"$samba_cv_have_setresuid" = x"yes"; then
964     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
967 # Do the same check for setresguid...
969 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
970     AC_TRY_RUN([#include <unistd.h>
971 #include <errno.h>
972 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
973         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
974 if test x"$samba_cv_have_setresgid" = x"yes"; then
975     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
978 AC_FUNC_MEMCMP
980 ###############################################
981 # Readline included by default unless explicitly asked not to
982 test "${with_readline+set}" != "set" && with_readline=yes
984 # test for where we get readline() from
985 AC_MSG_CHECKING(whether to use readline)
986 AC_ARG_WITH(readline,
987 [AS_HELP_STRING([--with-readline[=DIR]], [Look for readline include/libs in DIR (default=auto)])],
988 [  case "$with_readline" in
989   yes)
990     AC_MSG_RESULT(yes)
992     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
993     AC_CHECK_HEADERS(readline/history.h)
995     AC_CHECK_HEADERS(readline.h readline/readline.h,[
996       for termlib in ncurses curses termcap terminfo termlib tinfo; do
997        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
998       done
999       AC_CHECK_LIB(readline, rl_callback_handler_install,
1000        [TERMLIBS="-lreadline $TERMLIBS"
1001        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1002        break], [TERMLIBS=], $TERMLIBS)])
1003     ;;
1004   no)
1005     AC_MSG_RESULT(no)
1006     ;;
1007   *)
1008     AC_MSG_RESULT(yes)
1010     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1011     # alternate readline path
1012     _ldflags=${LDFLAGS}
1013     _cppflags=${CPPFLAGS}
1015     # Add additional search path
1016     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1017     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1019     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1020     AC_CHECK_HEADERS(readline/history.h)
1022     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1023       for termlib in ncurses curses termcap terminfo termlib; do
1024        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1025       done
1026       AC_CHECK_LIB(readline, rl_callback_handler_install,
1027        [TERMLDFLAGS="-L$with_readline/lib"
1028        TERMCPPFLAGS="-I$with_readline/include"
1029        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1030        TERMLIBS="-lreadline $TERMLIBS"
1031        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1032        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1034     LDFLAGS=$_ldflags
1035     ;;
1036   esac],
1037   AC_MSG_RESULT(no)
1039 AC_SUBST(TERMLIBS)
1040 AC_SUBST(TERMLDFLAGS)
1042 # The readline API changed slightly from readline3 to readline4, so
1043 # code will generate warnings on one of them unless we have a few
1044 # special cases.
1045 AC_CHECK_LIB(readline, rl_completion_matches,
1046              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
1047                         [Do we have rl_completion_matches?])],
1048              [],
1049              [$TERMLIBS])
1051 # not all readline libs have rl_event_hook or history_list
1052 AC_CHECK_DECLS(rl_event_hook, [], [], [#include <readline/readline.h>])
1053 AC_CHECK_LIB(readline, history_list,
1054              [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
1055              [],
1056              [$TERMLIBS])
1058 ###############################################
1059 # test for where we get yp_get_default_domain() from
1060 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1061 AC_CHECK_FUNCS(yp_get_default_domain)
1063 # Check if we have execl, if not we need to compile smbrun.
1064 AC_CHECK_FUNCS(execl)
1065 if test x"$ac_cv_func_execl" = x"no"; then
1066     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1069 AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64)
1070 AC_CHECK_FUNCS(strtol)
1071 AC_CHECK_FUNCS(strchr chflags)
1072 AC_CHECK_FUNCS(getrlimit fsync setpgid)
1073 AC_CHECK_FUNCS(fdatasync,,[AC_CHECK_LIB_EXT(rt, LIBS, fdatasync)])
1074 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
1075 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1076 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
1077 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
1078 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
1079 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
1080 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1081 AC_CHECK_FUNCS(getpwent_r)
1082 AC_CHECK_FUNCS(getdents64)
1083 AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
1084 AC_CHECK_FUNCS(syslog vsyslog timegm)
1085 AC_CHECK_FUNCS(setlocale nl_langinfo)
1086 AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
1087 AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
1088 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
1089 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
1090 AC_CHECK_HEADERS(sys/mman.h)
1091 # setbuffer, shmget, shm_open are needed for smbtorture
1092 AC_CHECK_FUNCS(shmget shm_open)
1093 AC_CHECK_FUNCS(gettext dgettext)
1094 AC_CHECK_FUNCS(bindtextdomain textdomain)
1095 AC_CHECK_FUNCS(strupr)
1097 # Find a method of generating a stack trace
1098 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1099 # libexecinfo provides backtrace_symbols on FreeBSD
1100 AC_SEARCH_LIBS(backtrace_symbols, [execinfo])
1101 AC_CHECK_FUNCS(backtrace_symbols)
1102 AC_CHECK_LIB(exc, trace_back_stack)
1104 # check for sysctlbyname for BSD systems
1105 AC_CHECK_FUNCS(sysctlbyname)
1107 #############################
1108 # check if building with gpfs
1109 AC_CHECK_HEADERS(gpfs_gpl.h)
1110 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
1111     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
1112     default_shared_modules="$default_shared_modules vfs_gpfs"
1115 #############################################
1116 # check if building on Isilon OneFS
1117 printf "%s" "checking for Isilon OneFS... "
1118 save_LIBS="$LIBS"
1119 LIBS="$LIBS -lisi_version"
1120 AC_TRY_LINK([#include <isi_version/isi_version.h>],
1121           [get_isilon_copyright()],
1122           samba_cv_HAVE_ONEFS=yes,
1123           samba_cv_HAVE_ONEFS=no)
1124 echo $samba_cv_HAVE_ONEFS
1125 if test x"$samba_cv_HAVE_ONEFS" = x"yes"; then
1126     AC_DEFINE(HAVE_ONEFS,1,[Whether building on Isilon OneFS])
1127     default_shared_modules="$default_shared_modules vfs_onefs vfs_onefs_shadow_copy perfcount_onefs"
1128     default_static_modules="$default_static_modules"
1129     ONEFS_LIBS="-lisi_acl -lisi_ecs -lisi_event -lisi_util"
1130     # Need to also add general libs for oplocks support
1131     save_LIBS="$save_LIBS -lisi_ecs -lisi_event -lisi_util -ldevstat"
1133 AC_SUBST(ONEFS_LIBS)
1134 LIBS="$save_LIBS"
1136 # Note that all the libunwind symbols in the API are defined to internal
1137 # platform-specific version, so we must include libunwind.h before checking
1138 # any of them.
1139 AC_MSG_CHECKING([for libunwind])
1140 save_LIBS=$LIBS
1142 UNWIND_ARCH="unknown"
1143 if test x"$UNAME_I" != x"unknown"; then
1144         UNWIND_ARCH="$UNAME_I"
1145 elif test x"$UNAME_M" != x"unknown"; then
1146         UNWIND_ARCH="$UNAME_M"
1147 elif test x"$UNAME_P" != x"unknown"; then
1148         UNWIND_ARCH="$UNAME_P"
1151 case "$UNWIND_ARCH" in
1152         unknown)
1153                 # This probably won't link without
1154                 # the platform-specific libunwind.
1155                 LIBS="$LIBS -lunwind"
1156                 ;;
1157         i386|i586|i686)
1158                 # Add the platform-specific libunwind module.
1159                 LIBS="$LIBS -lunwind -lunwind-x86"
1160                 ;;
1161         *)
1162                 # Add the platform-specific libunwind module.
1163                 # based on uname -i, uname -m or uname -p
1164                 LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
1165                 ;;
1166 esac
1168 AC_TRY_LINK(
1169     [
1170 #ifdef HAVE_LIBUNWIND_H
1171 #include <libunwind.h>
1172 #endif
1173     ],
1174     [
1175         unw_context_t ctx; unw_cursor_t cur;
1176         char buf[256]; unw_word_t off;
1177         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1178         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1179     ],
1180     [
1181         AC_MSG_RESULT(yes)
1182         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1184         # If we have libunwind, test whether we also have libunwind-ptrace
1185         # which would let us unwind arbitrary processes.
1186         save_LIBS=$LIBS
1187         AC_CHECK_HEADERS(libunwind-ptrace.h)
1188         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1189             [
1190                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1191                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1192                     [Whether libunwind-ptrace.a is available.])
1193             ],
1194             [ LIBUNWIND_PTRACE="" ])
1196         LIBS=$save_LIBS
1197     ],
1198     [
1199         AC_MSG_RESULT(no)
1200         LIBS=$save_LIBS
1201     ])
1203 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1204 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1205     AC_CHECK_HEADERS(sys/ptrace.h)
1206     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1207     AC_TRY_LINK(
1208             [
1209 #if HAVE_SYS_TYPES_H
1210 #include <sys/types.h>
1211 #endif
1212 #if HAVE_SYS_PTRACE_H
1213 #include <sys/ptrace.h>
1214 #endif
1215             ],
1216             [
1217                 pid_t me = (pid_t)-1;
1218                 ptrace(PTRACE_ATTACH, me, 0, 0);
1219                 ptrace(PTRACE_DETACH, me, 0, 0);
1220                 return 0;
1221             ],
1222             [
1223                 AC_MSG_RESULT(yes)
1224                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1225                     [Whether the Linux ptrace(2) interface is available.])
1226             ],
1227             [
1228                 AC_MSG_RESULT(no)
1229                 LIBUNWIND_PTRACE=""
1230             ])
1233 AC_SUBST(LIBUNWIND_PTRACE)
1235 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1236 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1237 AC_CHECK_FUNCS(__getcwd _getcwd)
1238 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1239 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1240 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1241 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1242 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1243 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1244 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1245 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1246 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1247 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1248 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1249 AC_CHECK_FUNCS(prctl)
1251 AC_TRY_COMPILE([
1252 #ifdef HAVE_SYS_PRCTL_H
1253 #include <sys/prctl.h>
1254 #endif
1256 [int i; i = prtcl(0); ],
1257 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1262 case "$host_os" in
1263     *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
1264        # glibc <= 2.3.2 has a broken getgrouplist
1265        AC_CACHE_CHECK([for good getgrouplist],samba_cv_linux_getgrouplist_ok,[AC_TRY_RUN([
1266 #include <unistd.h>
1267 #include <sys/utsname.h>
1268 main() {
1269        /* glibc up to 2.3 has a broken getgrouplist */
1270 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1271        int libc_major = __GLIBC__;
1272        int libc_minor = __GLIBC_MINOR__;
1274        if (libc_major < 2)
1275               exit(1);
1276        if ((libc_major == 2) && (libc_minor <= 3))
1277               exit(1);
1278 #endif
1279        exit(0);
1281 ], [samba_cv_linux_getgrouplist_ok=yes],
1282    [samba_cv_linux_getgrouplist_ok=no],
1283    [samba_cv_linux_getgrouplist_ok=cross])])
1284        if test x"$samba_cv_linux_getgrouplist_ok" = x"yes"; then
1285           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1286        fi
1287        ;;
1288     *)
1289        AC_CHECK_FUNCS(getgrouplist)
1290        ;;
1291 esac
1294 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1297 if test x$ac_cv_func_stat64 = xno ; then
1298   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1299   AC_TRY_LINK([
1300 #if defined(HAVE_UNISTD_H)
1301 #include <unistd.h>
1302 #endif
1303 #include <sys/stat.h>
1304 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1305   AC_MSG_RESULT([$ac_cv_func_stat64])
1306   if test x$ac_cv_func_stat64 = xyes ; then
1307     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1308   fi
1311 if test x$ac_cv_func_lstat64 = xno ; then
1312   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1313   AC_TRY_LINK([
1314 #if defined(HAVE_UNISTD_H)
1315 #include <unistd.h>
1316 #endif
1317 #include <sys/stat.h>
1318 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1319   AC_MSG_RESULT([$ac_cv_func_lstat64])
1320   if test x$ac_cv_func_lstat64 = xyes ; then
1321     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1322   fi
1325 if test x$ac_cv_func_fstat64 = xno ; then
1326   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1327   AC_TRY_LINK([
1328 #if defined(HAVE_UNISTD_H)
1329 #include <unistd.h>
1330 #endif
1331 #include <sys/stat.h>
1332 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1333   AC_MSG_RESULT([$ac_cv_func_fstat64])
1334   if test x$ac_cv_func_fstat64 = xyes ; then
1335     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1336   fi
1339 #################################################
1340 # Check whether struct stat has timestamps with sub-second resolution.
1343 samba_cv_stat_hires=no
1344 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec], # Linux, Solaris
1345         [samba_cv_stat_hires=yes])
1346 AC_CHECK_MEMBERS([struct stat.st_mtimensec], # BSD, if defined _POSIX_SOURCE
1347         [samba_cv_stat_hires=yes])
1348 AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec], # BSD, if not defined _POSIX_SOURCE
1349         [samba_cv_stat_hires=yes])
1350 AC_CHECK_MEMBERS([struct stat.st_mtime_n], # AIX
1351         [samba_cv_stat_hires=yes])
1352 AC_CHECK_MEMBERS([struct stat.st_umtime], # Tru64
1353         [samba_cv_stat_hires=yes])
1355 if test x"$samba_cv_stat_hires" = x"yes" ; then
1356     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1357             [whether struct stat has sub-second timestamps])
1360 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1361 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
1362 AC_CHECK_MEMBERS([struct stat.st_birthtime], AC_CHECK_MEMBERS([struct stat.st_birthtimensec]))
1365 AC_CACHE_CHECK([whether there is DOS flags support in the stat struct], samba_cv_stat_dos_flags,
1366     [
1367         AC_TRY_COMPILE(
1368             [#include <sys/stat.h>],
1369             [
1370                 int a = UF_DOS_ARCHIVE;
1371                 int h = UF_DOS_HIDDEN;
1372                 int r = UF_DOS_RO;
1373                 int s = UF_DOS_SYSTEM;
1374                 int i = UF_DOS_NOINDEX;
1375                 int f = UF_DOS_FLAGS;
1376             ],
1377             samba_cv_stat_dos_flags=yes, samba_cv_stat_dos_flags=no)
1378     ])
1380 if test x"$samba_cv_stat_dos_flags" = x"yes" ; then
1381     AC_DEFINE(HAVE_STAT_DOS_FLAGS, 1, [whether there is DOS flags support in the stat struct])
1384 AC_CACHE_CHECK([whether we can compile with __attribute__((destructor))],
1385                samba_cv_function_attribute_destructor,
1386                [
1387                  AC_COMPILE_IFELSE(
1388                         [
1389                                 __attribute__((destructor))
1390                                 static void cleanup(void) { }
1391                         ],
1392                         samba_cv_function_attribute_destructor=yes)
1393                 ])
1395 if test x"$samba_cv_function_attribute_destructor" = xyes ; then
1396    AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR, 1,
1397              [whether we can compile with __attribute__((destructor))])
1400 #####################################
1401 # needed for SRV lookups
1402 AC_CHECK_LIB(resolv, dn_expand)
1403 AC_CHECK_LIB(resolv, _dn_expand)
1404 AC_CHECK_LIB(resolv, __dn_expand)
1407 # Check for the functions putprpwnam, set_auth_parameters,
1408 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1409 # Needed for OSF1 and HPUX.
1412 AC_LIBTESTFUNC(security, putprpwnam)
1413 AC_LIBTESTFUNC(sec, putprpwnam)
1415 AC_LIBTESTFUNC(security, set_auth_parameters)
1416 AC_LIBTESTFUNC(sec, set_auth_parameters)
1418 # UnixWare 7.x has its getspnam in -lgen
1419 AC_LIBTESTFUNC(gen, getspnam)
1421 AC_LIBTESTFUNC(security, getspnam)
1422 AC_LIBTESTFUNC(sec, getspnam)
1424 AC_LIBTESTFUNC(security, bigcrypt)
1425 AC_LIBTESTFUNC(sec, bigcrypt)
1427 AC_LIBTESTFUNC(security, getprpwnam)
1428 AC_LIBTESTFUNC(sec, getprpwnam)
1430 AC_CHECK_FUNCS(strsignal)
1432 ############################################
1433 # Check for EA implementations
1434 case "$host_os" in
1435   *osf*)
1436         AC_SEARCH_LIBS(getproplist, [proplist])
1437         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1438         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1439         AC_CHECK_FUNCS(sizeof_proplist_entry)
1440   ;;
1441   *freebsd4* | *dragonfly* )
1442         AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1443   ;;
1444   *solaris*)
1445         AC_CHECK_FUNCS(attropen)
1446   ;;
1447   *)
1448         AC_SEARCH_LIBS(getxattr, [attr])
1449         AC_CHECK_FUNCS(getxattr,[
1450                 AC_CHECK_FUNCS(lgetxattr fgetxattr listxattr llistxattr flistxattr removexattr lremovexattr fremovexattr setxattr lsetxattr fsetxattr)
1451                 ])
1452         AC_CHECK_FUNCS(getea,[
1453                 AC_CHECK_FUNCS(fgetea lgetea listea flistea llistea removeea fremoveea lremoveea setea fsetea lsetea)
1454                 ])
1455         AC_CHECK_FUNCS(attr_get,[
1456                 AC_CHECK_FUNCS(attr_list attr_set attr_remove attr_getf attr_listf attr_setf attr_removef)
1457                 ])
1458         AC_CHECK_FUNCS(extattr_delete_file,[
1459                 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)
1460                 ])
1461   ;;
1462 esac
1464 ########################################################
1465 # Do xattr functions take additional options like on Darwin?
1466 if test x"$ac_cv_func_getxattr" = x"yes" ; then
1467         AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
1468                 old_LIBS=$LIBS
1469                 LIBS="$LIBS $ACL_LIBS"
1470                 AC_TRY_COMPILE([
1471                         #include <sys/types.h>
1472                         #if HAVE_ATTR_XATTR_H
1473                         #include <attr/xattr.h>
1474                         #elif HAVE_SYS_XATTR_H
1475                         #include <sys/xattr.h>
1476                         #endif
1477                 ],[
1478                         getxattr(0, 0, 0, 0, 0, 0);
1479                 ],
1480                 [smb_attr_cv_xattr_add_opt=yes],
1481                 [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
1482         ])
1483         if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
1484                 AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
1485         fi
1488 AC_DISABLE_STATIC
1489 AC_ENABLE_SHARED
1491 # Set defaults
1492 PIE_CFLAGS=""
1493 PIE_LDFLAGS=""
1494 AC_ARG_ENABLE(pie, [AS_HELP_STRING([--enable-pie], [Turn on pie support if available (default=yes)])])
1496 if test "x$enable_pie" != xno
1497 then
1498         AC_CACHE_CHECK(for -pie and -fPIE, samba_cv_fpie,
1499         [
1500                 cat > conftest.c <<EOF
1501 int foo;
1502 int main () { return 0;}
1504                 if AC_TRY_COMMAND_NO_STDERR([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c])
1505                 then
1506                         samba_cv_fpie=yes
1507                 else
1508                         samba_cv_fpie=no
1509                 fi
1510                 rm -f conftest*
1511         ])
1512         if test x"${samba_cv_fpie}" = x"yes"
1513         then
1514                 PIE_CFLAGS="-fPIE"
1515                 PIE_LDFLAGS="-pie"
1516         fi
1519 # Set defaults
1520 RELRO_LDFLAGS=""
1521 AC_ARG_ENABLE(relro, [AS_HELP_STRING([--enable-relro], [Turn on Relocations Read-Only (relro) support if available (default=yes)])])
1523 if test "x$enable_relro" != xno
1524 then
1525         AC_CACHE_CHECK([for -Wl,-z,relro], samba_cv_relro,
1526         [
1527                 cat > conftest.c <<EOF
1528 int foo;
1529 main () { return 0;}
1531                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
1532                 then
1533                         samba_cv_relro=yes
1534                 else
1535                         samba_cv_relro=no
1536                 fi
1537                 rm -f conftest*
1538         ])
1539         if test x"${samba_cv_relro}" = x"yes"
1540         then
1541                 RELRO_LDFLAGS="-Wl,-z,relro"
1542         fi
1545 # Set defaults
1546 SYMSEXT="syms"
1547 AC_SUBST(SYMSEXT)
1549 # Assume non-shared by default and override below
1550 BLDSHARED="false"
1552 # these are the defaults, good for lots of systems
1553 HOST_OS="$host_os"
1554 LDSHFLAGS="-shared"
1555 MODULE_EXPORTS=""
1556 SONAMEFLAG="#"
1557 SHLD="\${CC} \${CFLAGS}"
1558 PICFLAG="${PIE_CFLAGS}"
1559 SHLIBEXT="so"
1560 DSO_EXPORTS=""
1562 # this bit needs to be modified for each OS that supports share libs
1563 # You need to specify how to create a shared library and
1564   # how to compile C code to produce PIC object files
1566   AC_MSG_CHECKING([ability to build shared libraries])
1568   # and these are for particular systems
1569   case "$host_os" in
1570                 *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
1571                         case "$host_os" in
1572                                 *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
1573                                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) ;;
1574                         esac
1575                         BLDSHARED="true"
1576                         LDSHFLAGS="-shared -Wl,-Bsymbolic"
1577                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1578                                 LDSHFLAGS_Z_NODEFS="-Wl,--allow-shlib-undefined"
1579                         fi
1580                         DYNEXP="-Wl,--export-dynamic"
1581                         PICFLAG="-fPIC"
1582                         SONAMEFLAG="-Wl,-soname="
1583                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1584                         ;;
1585                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1586                         BLDSHARED="true"
1587                         if test "${GCC}" = "yes"; then
1588                                 PICFLAG="-fPIC"
1589                                 SONAMEFLAG="-Wl,-soname="
1590                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1591                                         DYNEXP="-Wl,-E"
1592                                 fi
1593                                 LDSHFLAGS="-shared"
1594                         else
1595                                 PICFLAG="-KPIC"
1596                                 LDSHFLAGS="-G"
1597                         fi
1598                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1599                                 SONAMEFLAG="-Wl,-soname="
1600                         else
1601                                 SONAMEFLAG="-Wl,-h,"
1602                         fi
1603                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1604                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1605                         ;;
1606                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1607                         BLDSHARED="true"
1608                         LDSHFLAGS="-G"
1609                         SONAMEFLAG="-Wl,-h,"
1610                         PICFLAG="-KPIC"   # Is this correct for SunOS
1611                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1612                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1613                         ;;
1614                 *netbsd* | *freebsd* | *dragonfly* )
1615                         BLDSHARED="true"
1616                         LDSHFLAGS="-shared"
1617                         DYNEXP="-Wl,--export-dynamic"
1618                         SONAMEFLAG="-Wl,-soname,"
1619                         PICFLAG="-fPIC -DPIC"
1620                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1621                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1622                         ;;
1623                 *openbsd*)  BLDSHARED="true"
1624                         LDSHFLAGS="-shared"
1625                         DYNEXP="-Wl,-Bdynamic"
1626                         SONAMEFLAG="-Wl,-soname,"
1627                         PICFLAG="-fPIC"
1628                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1629                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1630                         ;;
1631                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1632                         case "$host_os" in
1633                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1634                         ;;
1635                         esac
1636                         BLDSHARED="true"
1637                         LDSHFLAGS="-set_version sgi1.0 -shared"
1638                         SONAMEFLAG="-soname "
1639                         SHLD="\${LD}"
1640                         if test "${GCC}" = "yes"; then
1641                                 PICFLAG="-fPIC"
1642                         else
1643                                 PICFLAG="-KPIC"
1644                         fi
1645                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1646                         ;;
1647                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1648                         BLDSHARED="true"
1649                         # use expfull to export underscored symbols
1650                         # add rtl to remove /lib/crt0.o warning
1651                         LDSHFLAGS="-Wl,-G,-bexpfull,-bbigtoc,-brtl"
1652                         DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
1653                         PICFLAG="-O2"
1654                         # as AIX code is always position independent...
1655                         # .po will just create compile warnings, use po.o:
1656                         if test "${GCC}" != "yes"; then
1657                                 ## for funky AIX compiler using strncpy()
1658                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 -qhalt=e"
1659                         fi
1661                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1662                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1663                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1664                         ;;
1665                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1666                         # ia64: 64bit build using gcc with CFLAGS="-mpl64"
1667                         #       64bit build using HP's cc with CFLAGS="+DD64"
1668                         # hppa: 64bit build unsupported by gcc
1669                         #       64bit build using HP's cc with CFLAGS="+DA2.0w"
1670                         # HP-UX 11.00 ld needs PHSS_33034
1671                         BLDSHARED="true"
1672                         if test "${GCC}" = "yes"; then
1673                                 PICFLAG="-fPIC"
1674                                 LDSHFLAGS="-shared"
1675                         else
1676                                 PICFLAG="+z"
1677                                 LDSHFLAGS="-Wl,-B,symbolic,-b"
1678                                 if test "$host_cpu" != "ia64"; then
1679                                         # "don't store literals in read-only memory" (?):
1680                                         PICFLAG="$PICFLAG +ESnolit"
1681                                 fi
1682                         fi
1683                         if test "$host_cpu" = "ia64"; then
1684                                 SHLIBEXT="so"
1685                                 # TODO: does the linker find the right 32/64 bit version of the libs? :
1686                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32:/usr/local/lib/hpux64:/usr/lib/hpux64"
1687                         else
1688                                 SHLIBEXT="sl"
1689                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1690                         fi
1691                         if test "$ac_cv_prog_gnu_ld" = "yes"; then
1692                                 SONAMEFLAG="-Wl,-soname="
1693                         else
1694                                 SONAMEFLAG="-Wl,+h,"
1695                         fi
1696                         # PIE/PIC flags at link time are required on HP-UX because
1697                         # linking requires a temporary source file, which is being
1698                         # compiled with the indicated flags - which need to contain
1699                         # PIC flags when we don't support PIE flags:
1700                         if test "$PIE_LDFLAGS" = "" ; then
1701                                 PIE_LDFLAGS=\${PICFLAG}
1702                         fi
1703                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1704                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1705                         ;;
1706                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1707                         BLDSHARED="true"
1708                         LDSHFLAGS="-shared"
1709                         SONAMEFLAG="-Wl,-soname,"
1710                         PICFLAG="-fPIC"
1711                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1712                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1713                         for flags in "-expect_unresolved '*'" "-Wl,-expect_unresolved,'*'" ; do
1714                                 saved_ldflags="$LDFLAGS"
1715                                 AC_MSG_CHECKING([if $flags works])
1716                                 LDFLAGS="$flags $saved_ldflags"
1717                                 AC_TRY_LINK([],[],
1718                                         [AC_MSG_RESULT([yes])
1719                                         LDSHFLAGS_Z_NODEFS=$flags],
1720                                         AC_MSG_RESULT([no]))
1721                                 LDFLAGS="$saved_ldflags"
1722                                 test x"$LDSHFLAGS_Z_NODEFS" != x && break
1723                         done
1724                         ;;
1725                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1726                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1727                         ;;
1728                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1729                         BLDSHARED="true"
1730                         LDSHFLAGS="-shared"
1731                         SONAMEFLAG="-Wl,-soname,"
1732                         PICFLAG="-KPIC"
1733                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1734                         ;;
1735                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1736                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1737                         ;;
1738                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1739                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1740                         ;;
1741                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1742                         case "$host" in
1743                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1744                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1745                                         fi
1746                                         LDSHFLAGS="-G"
1747                                         DYNEXP="-Bexport"
1748                                 ;;
1749                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1750                         esac
1751                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1752                         ;;
1754                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1755                         if [ test "$GCC" != yes ]; then
1756                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1757                         fi
1758                         LDSHFLAGS="-G"
1759                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1760                         ;;
1761                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1762                         BLDSHARED="false"
1763                         LDSHFLAGS=""
1764                         ;;
1766                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1767                         BLDSHARED="true"
1768                         LDSHFLAGS="-dynamiclib -flat_namespace -undefined suppress"
1769                         CFLAGS="$CFLAGS -fno-common"
1770                         SHLD="\${CC}"
1771                         SHLIBEXT="dylib"
1772                         MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
1773                         SHLIBEXT="dylib"
1774                         # Since gcc doesn't fail on unrecognised options, the
1775                         # PIE test incorrectly succeeds. Darwin gcc does not
1776                         # actually support the PIE stuff.
1777                         PIE_LDFLAGS=
1778                         PIE_CFLAGS=
1779                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1780                         ;;
1782                 *)
1783                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1784                         ;;
1785   esac
1787 if test "$enable_shared" != "yes"; then
1788         BLDSHARED=false
1791 if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
1792         DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
1795 if test x"$BLDSHARED" = x"true" ; then
1796         LDFLAGS="$LDFLAGS -L./bin"
1799 AC_MSG_RESULT($BLDSHARED)
1801 for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
1802         saved_ldflags="$LDFLAGS"
1803         AC_MSG_CHECKING([if $flags works])
1804         LDFLAGS="$flags $saved_ldflags"
1805         AC_TRY_LINK([],[],
1806                 [AC_MSG_RESULT([yes])
1807                 LD_AS_NEEDED_FLAG=$flags
1808                 ld_as_needed_flag_found=yes],
1809                 AC_MSG_RESULT([no]))
1810         LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
1811         test x"$ld_as_needed_flag_found" = xyes && break
1812 done
1814 # for historical reasons almost all linkers don't complain about unresolved
1815 # symbols in shared libs. Except for the internal samba modules we want to get
1816 # errors when we produce a shared lib with unresolved symbols. On some
1817 # platforms unresolved symbols might be intended, so we might have to add
1818 # platform specific exceptions here.
1820 for flags in "-Wl,-z,defs" "-error_unresolved" "-Wl,-error_unresolved" ; do
1821         saved_ldflags="$LDFLAGS"
1822         AC_MSG_CHECKING([if $flags works])
1823         LDFLAGS="$flags $saved_ldflags"
1824         AC_TRY_LINK([],[],
1825         [AC_MSG_RESULT([yes])
1826         LDSHFLAGS_Z_DEFS=$flags
1827         ldshflags_z_defs_found=yes],
1828         AC_MSG_RESULT([no]))
1829         LDFLAGS=$saved_ldflags
1830         test x"$ldshflags_z_defs_found" = xyes && break
1831 done
1833 AC_MSG_CHECKING([LDSHFLAGS_Z_DEFS])
1834 AC_MSG_RESULT([$LDSHFLAGS_Z_DEFS])
1835 AC_MSG_CHECKING([LDFLAGS])
1836 AC_MSG_RESULT([$LDFLAGS])
1837 AC_MSG_CHECKING([DYNEXP])
1838 AC_MSG_RESULT([$DYNEXP])
1840 #######################################################
1841 # test whether building a shared library actually works
1842 if test $BLDSHARED = true; then
1844 AC_MSG_CHECKING([SHLD])
1845 AC_MSG_RESULT([$SHLD])
1846 AC_MSG_CHECKING([LDSHFLAGS])
1847 AC_MSG_RESULT([$LDSHFLAGS])
1849 AC_MSG_CHECKING([SHLIBEXT])
1850 AC_MSG_RESULT([$SHLIBEXT])
1851 AC_MSG_CHECKING([SONAMEFLAG])
1852 AC_MSG_RESULT([$SONAMEFLAG])
1854 AC_MSG_CHECKING([PICFLAG])
1855 AC_MSG_RESULT([$PICFLAG])
1857 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
1858 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
1860 AC_CACHE_CHECK([whether building shared libraries actually works],
1861                [ac_cv_shlib_works],[
1862    # try building a trivial shared library
1863    ac_cv_shlib_works=no
1864    # The $SHLD and $LDSHFLAGS variables may contain references to other
1865    # variables so they need to be eval'ed.
1866    if AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.o ${srcdir-.}/../tests/shlib.c 1>&AS_MESSAGE_LOG_FD])
1867    then
1868      TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
1869      TESTCMD="$TESTCMD -o \"shlib.$SHLIBEXT\" shlib.o"
1870      if AC_TRY_COMMAND([$TESTCMD 1>&AS_MESSAGE_LOG_FD 2>&1])
1871      then
1872        ac_cv_shlib_works=yes
1873      fi
1874    fi
1875    rm -f "shlib.$SHLIBEXT" shlib.o
1878 if test $ac_cv_shlib_works = no; then
1879    BLDSHARED=false
1883 if test x"$BLDSHARED" != x"true"; then
1884         LDSHFLAGS="shared-libraries-disabled"
1885         SONAMEFLAG="shared-libraries-disabled"
1886         NSSSONAMEVERSIONSUFFIX="shared-libraries-disabled"
1887         SHLD="shared-libraries-disabled"
1888         PICFLAG="${PIE_CFLAGS}"
1889         SHLIBEXT="shared_libraries_disabled"
1890         merged_build_possible=no
1893 AC_MSG_CHECKING([used PICFLAG])
1894 AC_MSG_RESULT([$PICFLAG])
1896 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
1898 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
1901 ###########################################################
1903 # Configuration of subsystems / libraries
1905 ###########################################################
1907 INSTALLLIBCMD_SH=:
1908 INSTALLLIBCMD_A=:
1909 UNINSTALLLIBCMD_SH=:
1910 UNINSTALLLIBCMD_A=:
1912 if test $BLDSHARED = true; then
1913         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
1914         UNINSTALLLIBCMD_SH="rm -f"
1916 if test $enable_static = yes; then
1917         INSTALLLIBCMD_A="\$(INSTALLCMD)"
1918         UNINSTALLLIBCMD_A="rm -f"
1921 #################################################
1922 # --disable-shared-libs
1923 # can be used to disable the internal use of shared libs altogether
1924 # (this only has an effect when building shared libs is enabled)
1926 USESHARED=false
1927 AC_SUBST(USESHARED)
1929 AC_MSG_CHECKING(whether to use shared libraries internally)
1930 AC_ARG_ENABLE([shared-libs],
1931         AS_HELP_STRING([--enable-shared-libs],
1932                 [Use shared libraries internally (default=yes)]),
1933         [enable_shared_libs=$enableval],
1934         [enable_shared_libs=yes])
1936 if test x"$enable_shared_libs" != x"no" ; then
1937         USESHARED=$BLDSHARED
1940 AC_MSG_RESULT([$USESHARED])
1942 if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
1943         AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
1946 #################################################
1947 # --with-static-libs=LIBS:
1948 #   link (internal) libs dynamically or statically?
1950 # If a subsystem is built as a library then this controls whether they are
1951 # linked into Samba targets statically or dynamically:
1953 # * If we build the shared library at all, we link dynamically by default.
1955 # * We only link statically if we don't build shared or if the library
1956 #   appears in the --with-static-libs configure option.
1958 # Example:
1959 #   --with-static-libs=libtalloc makes use of libtalloc.a instead
1960 #   of linking the dynamic variant with -ltalloc.
1962 # NOTE: This option only affects libraries that we do not only build
1963 # but that samba also links against as libraries (as opposed to linking
1964 # the plain object files. - This has to be configured in Makefile.in.
1965 # So in particular it does not harm to give invalid or unknown names here.
1968 AC_ARG_WITH([static-libs],
1969         [AS_HELP_STRING([--with-static-libs=LIBS],
1970                 [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
1971         [AS_IF([test $withval],
1972                 [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
1973                         [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
1974                         eval LINK_$lib=STATIC
1975                 done], [])],
1976         [])
1979 # WORKAROUND:
1980 #   until we have organized other internal subsystems (as util, registry
1981 #   and smbconf) into shared libraries, we CAN NOT link libnetapi
1982 #   dynamically to samba programs.
1984 LINK_LIBNETAPI=STATIC
1986 LINK_LIBSMBCLIENT=STATIC
1989 #  The library versions are hardcoded here
1990 #  and filled into the LIBFOO_SOVER variable.
1992 #  TODO: for talloc and tdb (at least), these should
1993 #  be extracted from their respective source directories
1995 AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
1996 [ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
1998 if test "x$enable_external_libtalloc" != xno
1999 then
2000         PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1,
2001                 [ enable_external_libtalloc=yes ],
2002                 [ if test x$enable_external_libtalloc = xyes; then
2003                         AC_MSG_ERROR([Unable to find libtalloc])
2004                   else
2005                         enable_external_libtalloc=no
2006                   fi
2007                 ])
2010 if test "x$enable_external_libtalloc" = xno
2011 then
2012         m4_include(../lib/talloc/libtalloc.m4)
2013         LINK_LIBTALLOC=STATIC
2014         SMB_LIBRARY(talloc, 2)
2015         LIBTALLOC_OBJ0=""
2016         for obj in ${TALLOC_OBJ}; do
2017                 LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
2018         done
2019         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
2020         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TALLOC_CFLAGS}"
2021         AC_SUBST(LIBTALLOC_OBJ0)
2023         TALLOCTORT="bin/talloctort\$(EXEEXT)"
2024         AC_SUBST(TALLOCTORT)
2028 AC_ARG_ENABLE(external_libtdb,
2029         [AS_HELP_STRING([--enable-external-libtdb],
2030                 [Enable external tdb [default=auto]])],
2031                 [ enable_external_libtalloc=$enableval ],
2032                 [ enable_external_libtalloc=auto ])
2034 if test "x$enable_external_libtdb" != xno
2035 then
2036         PKG_CHECK_MODULES(LIBTDB, tdb >= 1.2.2,
2037                 [ enable_external_libtdb=yes ],
2038                 [
2039                 if test x$enable_external_libtdb = xyes; then
2040                         AC_MSG_ERROR([Unable to find libtdb])
2041                 else
2042                         enable_external_libtdb=no
2043                 fi
2044                 ])
2047 AC_SUBST(LIBTDB_OBJ0)
2048 if test "x$enable_external_libtdb" = xno
2049 then
2050         m4_include(../lib/tdb/libtdb.m4)
2051         LINK_LIBTDB=STATIC
2052         SMB_LIBRARY(tdb, 1)
2053         LIBTDB_OBJ0=""
2054         for obj in ${TDB_OBJ}; do
2055                 LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
2056         done
2057         AC_SUBST(LIBTDB_OBJ0)
2058         SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
2059         SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TDB_CFLAGS}"
2061         TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
2062         AC_SUBST(TDBBACKUP)
2063         TDBDUMP="bin/tdbdump\$(EXEEXT)"
2064         AC_SUBST(TDBDUMP)
2065         TDBTOOL="bin/tdbtool\$(EXEEXT)"
2066         AC_SUBST(TDBTOOL)
2067         TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
2068         AC_SUBST(TDBTORTURE)
2069         ac_cv_have_tdb_err_nesting=yes
2070 else
2071         AC_TRY_COMPILE([#include "tdb.h"],
2072                        [enum TDB_ERROR err = TDB_ERR_NESTING],
2073                        ac_cv_have_tdb_err_nesting=yes,
2074                        ac_cv_have_tdb_err_nesting=no)
2077 if test x"$ac_cv_have_tdb_err_nesting" = xyes; then
2078    AC_DEFINE(HAVE_TDB_ERR_NESTING, 1, [Whether we have TDB_ERR_NESTING])
2081 SMB_LIBRARY(netapi, 0)
2082 SMB_LIBRARY(smbclient, 0)
2083 SMB_LIBRARY(smbsharemodes, 0)
2084 SMB_LIBRARY(addns, 0, no, [undefined API])
2088 ################
2090 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
2091 AC_TRY_RUN([#include <stdio.h>
2092 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
2093 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
2094 if test x"$samba_cv_have_longlong" = x"yes"; then
2095     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
2096     AC_CHECK_TYPE(intptr_t, unsigned long long)
2097 else
2098     AC_CHECK_TYPE(intptr_t, unsigned long)
2102 # Check if the compiler supports the LL prefix on long long integers.
2103 # AIX needs this.
2105 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
2106     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
2107         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
2108 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
2109    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
2113 AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
2114 AC_TRY_RUN([#include <time.h>
2115 main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
2116 samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
2117 if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
2118     AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
2121 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
2122 AC_TRY_RUN([#include <stdio.h>
2123 #include <sys/stat.h>
2124 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
2125 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
2126 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
2127     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
2130 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
2131 AC_TRY_RUN([
2132 #if defined(HAVE_UNISTD_H)
2133 #include <unistd.h>
2134 #endif
2135 #include <stdio.h>
2136 #include <sys/stat.h>
2137 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2138 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
2139 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
2140     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
2143 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
2144 AC_TRY_RUN([
2145 #if defined(HAVE_UNISTD_H)
2146 #include <unistd.h>
2147 #endif
2148 #include <stdio.h>
2149 #include <sys/stat.h>
2150 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
2151 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
2152 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
2153     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
2156 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
2157 AC_TRY_RUN([
2158 #if defined(HAVE_UNISTD_H)
2159 #include <unistd.h>
2160 #endif
2161 #include <stdio.h>
2162 #include <sys/stat.h>
2163 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2164 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
2165 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
2166     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
2169 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
2170 AC_TRY_RUN([
2171 #if defined(HAVE_UNISTD_H)
2172 #include <unistd.h>
2173 #endif
2174 #include <stdio.h>
2175 #include <sys/stat.h>
2176 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
2177 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
2178 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
2179     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
2182 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
2183 AC_TRY_RUN([
2184 #if defined(HAVE_UNISTD_H)
2185 #include <unistd.h>
2186 #endif
2187 #include <stdio.h>
2188 #include <sys/stat.h>
2189 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
2190 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
2191 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
2192     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
2195 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
2196 AC_TRY_COMPILE([
2197 #if defined(HAVE_UNISTD_H)
2198 #include <unistd.h>
2199 #endif
2200 #include <sys/types.h>
2201 #include <dirent.h>],
2202 [DIR64 de;],
2203 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
2204 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2205     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
2208 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
2209 AC_TRY_COMPILE([
2210 #if defined(HAVE_UNISTD_H)
2211 #include <unistd.h>
2212 #endif
2213 #include <sys/types.h>
2214 #include <dirent.h>],
2215 [struct dirent64 de;],
2216 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
2217 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
2218     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
2221 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
2222 AC_TRY_RUN([
2223 #if defined(HAVE_UNISTD_H)
2224 #include <unistd.h>
2225 #endif
2226 #include <sys/types.h>
2227 main() { dev_t dev; int i = major(dev); return 0; }],
2228 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
2229 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
2230     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
2233 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
2234 AC_TRY_RUN([
2235 #if defined(HAVE_UNISTD_H)
2236 #include <unistd.h>
2237 #endif
2238 #include <sys/types.h>
2239 main() { dev_t dev; int i = minor(dev); return 0; }],
2240 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
2241 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
2242     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
2245 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
2246 AC_TRY_RUN([
2247 #if defined(HAVE_UNISTD_H)
2248 #include <unistd.h>
2249 #endif
2250 #include <sys/types.h>
2251 main() { dev_t dev = makedev(1,2); return 0; }],
2252 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
2253 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
2254     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
2257 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
2258 AC_TRY_RUN([#include <stdio.h>
2259 main() { char c; c=250; exit((c > 0)?0:1); }],
2260 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
2261 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
2262     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
2265 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
2266 AC_TRY_COMPILE([#include <sys/types.h>
2267 #include <dirent.h>
2268 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2269 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2270 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2271     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2274 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2275 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2276 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2277 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2278     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2282 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
2284     # On some systems (eg. Linux) librt can pull in libpthread. We
2285     # don't want this to happen because libpthreads changes signal delivery
2286     # semantics in ways we are not prepared for. This breaks Linux oplocks
2287     # which rely on signals.
2289     AC_LIBTESTFUNC(rt, clock_gettime,
2290             [
2291                             AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
2292                                 [Whether clock_gettime is available])
2293                             SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
2294                             SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
2295                             SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
2296                         ])
2300 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2301 AC_TRY_RUN([#include <sys/types.h>
2302 #include <dirent.h>
2303 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2304 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2305 di->d_name[0] == 0) exit(0); exit(1);} ],
2306 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2307 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2308     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2311 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2312 AC_TRY_COMPILE([#include <sys/types.h>
2313 #include <utime.h>],
2314 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2315 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2316 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2317     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2320 ##############
2321 # Check utmp details, but only if our OS offers utmp.h
2322 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2323 dnl  utmp and utmpx come in many flavours
2324 dnl  We need to check for many of them
2325 dnl  But we don't need to do each and every one, because our code uses
2326 dnl  mostly just the utmp (not utmpx) fields.
2328 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx getutxent)
2330 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2331 AC_TRY_COMPILE([#include <sys/types.h>
2332 #include <utmp.h>],
2333 [struct utmp ut;  ut.ut_name[0] = 'a';],
2334 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2335 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2336     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2339 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2340 AC_TRY_COMPILE([#include <sys/types.h>
2341 #include <utmp.h>],
2342 [struct utmp ut;  ut.ut_user[0] = 'a';],
2343 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2344 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2345     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2348 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2349 AC_TRY_COMPILE([#include <sys/types.h>
2350 #include <utmp.h>],
2351 [struct utmp ut;  ut.ut_id[0] = 'a';],
2352 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2353 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2354     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2357 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2358 AC_TRY_COMPILE([#include <sys/types.h>
2359 #include <utmp.h>],
2360 [struct utmp ut;  ut.ut_host[0] = 'a';],
2361 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2362 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2363     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2366 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2367 AC_TRY_COMPILE([#include <sys/types.h>
2368 #include <utmp.h>],
2369 [struct utmp ut;  time_t t; ut.ut_time = t;],
2370 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2371 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2372     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2375 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2376 AC_TRY_COMPILE([#include <sys/types.h>
2377 #include <utmp.h>],
2378 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2379 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2380 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2381     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2384 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2385 AC_TRY_COMPILE([#include <sys/types.h>
2386 #include <utmp.h>],
2387 [struct utmp ut;  ut.ut_type = 0;],
2388 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2389 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2390     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2393 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2394 AC_TRY_COMPILE([#include <sys/types.h>
2395 #include <utmp.h>],
2396 [struct utmp ut;  ut.ut_pid = 0;],
2397 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2398 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2399     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2402 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2403 AC_TRY_COMPILE([#include <sys/types.h>
2404 #include <utmp.h>],
2405 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2406 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2407 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2408     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2411 dnl Look for the IPv6 varient by preference. Many systems have both.
2412 AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
2413 AC_TRY_COMPILE([#include <sys/types.h>
2414 #include <utmp.h>],
2415 [struct utmp ut;  ut.ut_addr_v6[0] = 0;],
2416 samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
2417 if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
2418     AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
2421 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2422 AC_TRY_COMPILE([#include <sys/types.h>
2423 #include <utmp.h>],
2424 [struct utmp ut;  ut.ut_addr = 0;],
2425 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2426 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2427     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2430 if test x$ac_cv_func_pututline = xyes ; then
2431   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2432   AC_TRY_COMPILE([#include <sys/types.h>
2433 #include <utmp.h>],
2434   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2435   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2436   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2437       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2438   fi
2441 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2442 AC_TRY_COMPILE([#include <sys/types.h>
2443 #include <utmpx.h>],
2444 [struct utmpx ux;  ux.ut_syslen = 0;],
2445 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2446 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2447     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2451 # end utmp details
2454 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
2455 AC_ARG_WITH(libiconv,
2456 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
2458   if test "$withval" = "no" ; then
2459     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2460   else
2461      if test "$withval" != "yes" ; then
2462         ICONV_PATH_SPEC=yes
2463         ICONV_LOOK_DIRS="$withval"
2464      fi
2465   fi
2468 for i in $ICONV_LOOK_DIRS ; do
2470     save_LIBS="$LIBS"
2471     save_LDFLAGS="$LDFLAGS"
2472     save_CPPFLAGS="$CPPFLAGS"
2474     iconv_current_LIBS=""
2475     iconv_current_LDFLAGS=""
2476     iconv_current_CPPFLAGS=""
2478     ICONV_FOUND="no"
2479     unset libext
2481     #  This is here to handle -withval stuff for --with-libiconv
2482     #  Perhaps we should always add a -L
2483     CPPFLAGS="$save_CPPFLAGS -I$i/include"
2485     # Check lib and lib32 library variants to cater for IRIX ABI-specific
2486     # installation paths. This gets a little tricky since we might have iconv
2487     # in both libiconv and in libc. In this case the jm_ICONV test will always
2488     # succeed when the header is found. To counter this, make sure the
2489     # library directory is there and check the ABI directory first (which
2490     # should be harmless on other systems, but causes tons of linker warnings on
2491     # 64bit Ubuntu systems).
2492     # As the build farm doesn't seem to have any IRIX machines with iconv.h
2493     # installed, I've decided to fix the linker warnings.
2494     # -- Kai
2495     # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2496     for l in "lib" "lib32" "lib/hpux32"; do
2497         if test -d "$i/$l" ; then
2498                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2499                 LIBS=
2500                 export LDFLAGS LIBS CPPFLAGS
2501                 # Try to find iconv(3)
2502                 jm_ICONV($i/$l)
2503                 if test x"$ICONV_FOUND" = "xyes" ; then
2504                     libext="$l"
2505                     break
2506                 fi
2507         fi
2508     done
2510     if test x"$ICONV_FOUND" = "xyes" ; then
2511         iconv_current_LDFLAGS="-L$i/$libext"
2512         iconv_current_CPPFLAGS="-I$i/include"
2514         if test x"$jm_cv_lib_iconv" != x; then
2515             iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
2516         else
2517             # We found iconv in libc.
2518             iconv_current_LIBS=""
2519         fi
2521     fi
2523     if test x"$ICONV_FOUND" = "xyes" ; then
2525         LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
2526         CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
2527         LIBS="$save_LIBS $iconv_current_LIBS"
2528         export LDFLAGS LIBS CPPFLAGS
2530         default_dos_charset=no
2531         default_display_charset=no
2532         default_unix_charset=no
2534         # check for default dos charset name
2535         for j in CP850 IBM850 ; do
2536             rjs_CHARSET($j)
2537             default_dos_charset="$ICONV_CHARSET"
2538             if test x"$default_dos_charset" = x"$j"; then
2539                 break
2540             fi
2541         done
2543         # check for default display charset name
2544         for j in ASCII 646 ; do
2545             rjs_CHARSET($j)
2546             default_display_charset="$ICONV_CHARSET"
2547             if test x"$default_display_charset" = x"$j"; then
2548                 break
2549             fi
2550         done
2552         # check for default unix charset name
2553         for j in UTF-8 UTF8 ; do
2554             rjs_CHARSET($j)
2555             default_unix_charset="$ICONV_CHARSET"
2556             if test x"$default_unix_charset" = x"$j"; then
2557                 break
2558             fi
2559         done
2561         if test "$default_dos_charset" != "no" -a \
2562                 "$default_dos_charset" != "cross" -a \
2563                 "$default_display_charset" != "no" -a \
2564                 "$default_display_charset" != "cross" -a \
2565                 "$default_unix_charset" != "no" -a \
2566                 "$default_unix_charset" != "cross"
2567         then
2568                 samba_cv_HAVE_NATIVE_ICONV=yes
2569         else
2570             if test "$default_dos_charset" = "cross" -o \
2571                      "$default_display_charset" = "cross" -o \
2572                      "$default_unix_charset" = "cross"
2573             then
2574                     samba_cv_HAVE_NATIVE_ICONV=cross
2575             else
2576                     samba_cv_HAVE_NATIVE_ICONV=no
2577             fi
2578         fi
2580         # At this point, we have a libiconv candidate. We know that
2581         # we have the right headers and libraries, but we don't know
2582         # whether it does the conversions we want. We can't test this
2583         # because we are cross-compiling. This is not necessarily a big
2584         # deal, since we can't guarantee that the results we get now will
2585         # match the results we get at runtime anyway.
2586         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
2587             default_dos_charset="CP850"
2588             default_display_charset="ASCII"
2589             default_unix_charset="UTF-8"
2590             samba_cv_HAVE_NATIVE_ICONV=yes
2591             AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
2592             AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
2593         fi
2595         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
2597             CPPFLAGS=$save_CPPFLAGS
2598             LDFLAGS=$save_LDFLAGS
2599             LIBS=$save_LIBS
2601             if test x"$iconv_current_LIBS" != x; then
2602                 LIBS="$LIBS $iconv_current_LIBS"
2603             fi
2605             # Add the flags we need to CPPFLAGS and LDFLAGS
2606             CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
2607             LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
2609             # Turn the #defines into string literals
2610             default_dos_charset="\"$default_dos_charset\""
2611             default_display_charset="\"$default_display_charset\""
2612             default_unix_charset="\"$default_unix_charset\""
2614             AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2615             AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2616             AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2617             AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2619            break
2620         fi
2622     # We didn't find a working iconv, so keep going
2623     fi
2625     #  We only need to clean these up here for the next pass through the loop
2626     CPPFLAGS=$save_CPPFLAGS
2627     LDFLAGS=$save_LDFLAGS
2628     LIBS=$save_LIBS
2629     export LDFLAGS LIBS CPPFLAGS
2630 done
2631 unset libext
2634 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2635     AC_MSG_WARN([Sufficient support for iconv function was not found.
2636     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2637    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2638    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2639    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2643 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2644 AC_TRY_RUN([
2645 #include <sys/types.h>
2646 #include <fcntl.h>
2647 #ifndef F_GETLEASE
2648 #define F_GETLEASE      1025
2649 #endif
2650 main() {
2651        int fd = open("/dev/null", O_RDONLY);
2652        return fcntl(fd, F_GETLEASE, 0) == -1;
2655 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2656 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2657     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2660 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2661 AC_TRY_RUN([
2662 #include <sys/types.h>
2663 #include <fcntl.h>
2664 #include <signal.h>
2665 #ifndef F_NOTIFY
2666 #define F_NOTIFY 1026
2667 #endif
2668 main() {
2669         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2672 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2673 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2674     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2677 AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
2678 AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h sys/inotify.h)
2679 AC_CHECK_FUNCS(inotify_init)
2680 AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
2682 samba_cv_HAVE_INOTIFY=yes,
2683 samba_cv_HAVE_INOTIFY=no,
2684 samba_cv_HAVE_INOTIFY=cross)
2686 if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
2687     AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
2690 #################################################
2691 # Check if FAM notifications are available. For FAM info, see
2692 #       http://oss.sgi.com/projects/fam/
2693 #       http://savannah.nongnu.org/projects/fam/
2694 AC_ARG_ENABLE(fam,
2695 [AS_HELP_STRING([--enable-fam], [Turn on FAM support (default=auto)])])
2697 if test x$enable_fam != xno; then
2698     AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2699     if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2700         # On IRIX, libfam requires libC, but other FAM implementations
2701         # might not need it.
2702         AC_CHECK_LIB(fam, FAMOpen2,
2703             [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam";
2704             AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2705             [samba_cv_HAVE_LIBFAM=no])
2707         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2708             samba_fam_xtra=-lC
2709             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2710                 [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC";
2711                 AC_DEFINE(HAVE_FAMOPEN2, 1, Define to 1 if there is support for FAMOpen2)],
2712                 [samba_cv_HAVE_LIBFAM=no])
2713             unset samba_fam_xtra
2714         fi
2715     fi
2716     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2717         default_shared_modules="$default_shared_modules vfs_notify_fam"
2718         AC_TRY_COMPILE([#include <fam.h>],
2719                     [enum FAMCodes code = FAMChanged;],
2720                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2721                         [Whether fam.h contains a typedef for enum FAMCodes]),
2722                     [])
2723     fi
2725     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2726         AC_CHECK_LIB(fam, FAMNoExists,
2727             [AC_DEFINE(HAVE_FAMNOEXISTS, 1, Define to 1 if there is support for FAMNoExists)])
2728     fi
2730     if test x$enable_fam = xyes && test x"$samba_cv_HAVE_LIBFAM" != xyes ; then
2731         AC_MSG_ERROR(FAM support requested but FAM library not available )
2732     fi
2735 AC_SUBST(SMB_FAM_LIBS)
2737 #################################################
2738 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2741 with_dmapi_support=auto
2742 AC_MSG_CHECKING(whether to use DMAPI support)
2743 AC_ARG_WITH(dmapi,
2744 [AS_HELP_STRING([--with-dmapi], [Include DMAPI/XDSM support (default=auto)])],
2745 [ case "$withval" in
2746   yes|no)
2747     with_dmapi_support=$withval
2748     ;;
2749   esac ]
2751 AC_MSG_RESULT([$with_dmapi_support])
2753 if test x"$with_dmapi_support" != xno ; then
2754         SMB_CHECK_DMAPI([], [
2755                 AC_MSG_NOTICE(DMAPI support not present)
2756                 if test x"$with_dmapi_support" = xyes ; then
2757                         AC_MSG_ERROR(no DMAPI support found but requested!)
2758                 fi
2759                 ]
2760         )
2763 # Add TSM SM VFS module only if there are both GPFS and DMAPI support
2764 # Theoretically it should work with AIX JFS2 too but this needs testing
2765 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
2766     default_shared_modules="$default_shared_modules vfs_tsmsm"
2769 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2770 AC_TRY_RUN([
2771 #include <sys/types.h>
2772 #include <fcntl.h>
2773 #include <signal.h>
2774 #include <sys/file.h>
2775 #ifndef LOCK_MAND
2776 #define LOCK_MAND       32
2777 #define LOCK_READ       64
2778 #endif
2779 main() {
2780         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2783 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2784 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2785     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2789 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2790 AC_TRY_COMPILE([#include <sys/types.h>
2791 #include <fcntl.h>],
2792 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2793 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2794 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2795     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2798 #################################################
2799 # Check for POSIX capability support
2801 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2802     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2803     [], [])
2805 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2807     ac_save_LIBS=$LIBS
2808     AC_LIBTESTFUNC(cap, cap_get_proc)
2810     AC_CACHE_CHECK([for POSIX capabilities],
2811             samba_cv_HAVE_POSIX_CAPABILITIES,
2812             [
2813                 AC_TRY_RUN([
2814 #include <sys/types.h>
2815 #include <sys/capability.h>
2816 main() {
2817  cap_t cap;
2818  cap_value_t vals[1];
2819  if (!(cap = cap_get_proc()))
2820    exit(1);
2821  vals[0] = CAP_CHOWN;
2822  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2823  cap_set_proc(cap);
2824  exit(0);
2826                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2827                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2828                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2829             ])
2831 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2832     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2833             [Whether POSIX capabilities are available])
2834 else
2835     LIBS=$ac_save_LIBS
2841 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2842 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2845 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2846 AC_TRY_COMPILE([#include <sys/types.h>
2847 #if defined(HAVE_RPC_RPC_H)
2848 #include <rpc/rpc.h>
2849 #endif],
2850 [int16 testvar;],
2851 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2852 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2853     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2856 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2857 AC_TRY_COMPILE([#include <sys/types.h>
2858 #if defined(HAVE_RPC_RPC_H)
2859 #include <rpc/rpc.h>
2860 #endif],
2861 [uint16 testvar;],
2862 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2863 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2864     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2867 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2868 AC_TRY_COMPILE([#include <sys/types.h>
2869 #if defined(HAVE_RPC_RPC_H)
2870 #include <rpc/rpc.h>
2871 #endif],
2872 [int32 testvar;],
2873 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2874 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2875     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2878 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2879 AC_TRY_COMPILE([#include <sys/types.h>
2880 #if defined(HAVE_RPC_RPC_H)
2881 #include <rpc/rpc.h>
2882 #endif],
2883 [uint32 testvar;],
2884 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2885 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2886     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2890 dnl Some systems (SCO) have a problem including
2891 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2892 dnl as a #define in <prot.h> and as part of an enum
2893 dnl in <rpc/rpc.h>.
2896 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2897 AC_TRY_COMPILE([#include <sys/types.h>
2898 #ifdef HAVE_SYS_SECURITY_H
2899 #include <sys/security.h>
2900 #include <prot.h>
2901 #endif  /* HAVE_SYS_SECURITY_H */
2902 #if defined(HAVE_RPC_RPC_H)
2903 #include <rpc/rpc.h>
2904 #endif],
2905 [int testvar;],
2906 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2907 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2908     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2911 AC_MSG_CHECKING([for test routines])
2912 AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
2913            AC_MSG_RESULT(yes),
2914            AC_MSG_ERROR([cant find test code. Aborting config]),
2915            AC_MSG_WARN([cannot run when cross-compiling]))
2917 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2918 AC_TRY_RUN([#include "${srcdir-.}/../tests/ftruncate.c"],
2919            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2920 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2921     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2924 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2925 AC_TRY_RUN([#include "${srcdir-.}/../tests/getgroups.c"],
2926            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2927 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2928     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2931 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2932 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2933 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2934 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2935 AC_CHECK_FUNCS(getpagesize)
2937 ################################################
2938 # look for a method of setting the effective uid
2939 seteuid=no;
2941 if test $seteuid = no; then
2942 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2943 AC_TRY_RUN([
2944 #define AUTOCONF_TEST 1
2945 #define USE_SETREUID 1
2946 #include "confdefs.h"
2947 #include "${srcdir-.}/lib/util_sec.c"],
2948            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2949 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2950     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2954 # we check for setresuid second as it conflicts with AIO on Linux. 
2955 # see http://samba.org/~tridge/junkcode/aio_uid.c
2956 if test $seteuid = no; then
2957 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2958 AC_TRY_RUN([
2959 #define AUTOCONF_TEST 1
2960 #define USE_SETRESUID 1
2961 #include "confdefs.h"
2962 #include "${srcdir-.}/lib/util_sec.c"],
2963            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2964 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2965     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2969 if test $seteuid = no; then
2970 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2971 AC_TRY_RUN([
2972 #define AUTOCONF_TEST 1
2973 #define USE_SETEUID 1
2974 #include "confdefs.h"
2975 #include "${srcdir-.}/lib/util_sec.c"],
2976            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2977 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2978     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2982 if test $seteuid = no; then
2983 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2984 AC_TRY_RUN([
2985 #define AUTOCONF_TEST 1
2986 #define USE_SETUIDX 1
2987 #include "confdefs.h"
2988 #include "${srcdir-.}/lib/util_sec.c"],
2989            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2990 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2991     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2995 AC_CACHE_CHECK([for the Darwin initgroups system call],
2996         samba_cv_DARWIN_INITGROUPS,
2997         AC_TRY_LINK([
2998 #include <sys/syscall.h>
2999 #include <unistd.h>
3000         ],
3001         [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
3002         samba_cv_DARWIN_INITGROUPS=yes,
3003         samba_cv_DARWIN_INITGROUPS=no)
3006 if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
3007     AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
3008         [Whether to use the Darwin-specific initgroups system call])
3011 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
3012 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock.c"],
3013            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
3014 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
3015     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
3018 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
3019 AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock64.c"],
3020            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
3021 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
3022     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
3024 else
3027 dnl Don't check for 64 bit fcntl locking if we know that the
3028 dnl glibc2.1 broken check has succeeded.
3031   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
3032   AC_TRY_RUN([
3033 #if defined(HAVE_UNISTD_H)
3034 #include <unistd.h>
3035 #endif
3036 #include <stdio.h>
3037 #include <stdlib.h>
3039 #ifdef HAVE_FCNTL_H
3040 #include <fcntl.h>
3041 #endif
3043 #ifdef HAVE_SYS_FCNTL_H
3044 #include <sys/fcntl.h>
3045 #endif
3046 main() { struct flock64 fl64;
3047 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
3048 exit(0);
3049 #else
3050 exit(1);
3051 #endif
3053        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
3055   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
3056       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
3057   fi
3060 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
3061 AC_CACHE_CHECK([for broken posix_fallocate],samba_cv_HAVE_BROKEN_POSIX_FALLOCATE,[
3062 AC_TRY_COMPILE([
3063   #define _XOPEN_SOURCE 600
3064   #include <stdlib.h>
3065   #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
3066     probably broken posix_fallocate
3067   #endif
3068 ], [
3069 ], 
3070 samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=no,samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=yes)])
3071 if test x"$samba_cv_HAVE_BROKEN_POSIX_FALLOCATE" = xyes; then
3072         AC_DEFINE(HAVE_BROKEN_POSIX_FALLOCATE,, Whether we have a broken posix_fallocate)
3076 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
3077 AC_TRY_COMPILE([#include <sys/types.h>
3078 #include <sys/stat.h>
3079 #include <unistd.h>],
3080 [struct stat st;  st.st_blocks = 0;],
3081 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
3082 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
3083     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
3086 AC_CHECK_TYPES([blksize_t, blkcnt_t], [], [], [[#include <sys/stat.h>]])
3088 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
3089 AC_TRY_COMPILE([#include <sys/types.h>
3090 #include <sys/stat.h>
3091 #include <unistd.h>],
3092 [struct stat st;  st.st_blksize = 0;],
3093 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
3094 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
3095     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
3098 AC_CACHE_CHECK([for st_flags in struct stat],
3099         samba_cv_HAVE_STAT_ST_FLAGS,
3100         [
3101             AC_TRY_COMPILE([#include <sys/types.h>
3102 #include <sys/stat.h>
3103 #include <unistd.h>],
3104             [struct stat st;  st.st_flags = 0;],
3105             samba_cv_HAVE_STAT_ST_FLAGS=yes,
3106             samba_cv_HAVE_STAT_ST_FLAGS=no,
3107             samba_cv_HAVE_STAT_ST_FLAGS=cross)
3108         ])
3110 if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
3111     AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
3112                 [Whether the stat struct has a st_flags member])
3115 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
3116 AC_TRY_COMPILE([
3117 #include <sys/types.h>
3118 #include <sys/acl.h>
3119 #if defined(HAVE_RPCSVC_NIS_H)
3120 #include <rpcsvc/nis.h>
3121 #endif],
3122 [int i;],
3123 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
3124 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
3125         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
3128 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
3129 AC_TRY_RUN([
3130 #include <stdio.h>
3131 #include <limits.h>
3132 #include <signal.h>
3134 void exit_on_core(int ignored) {
3135         exit(1);
3138 main() {
3139         char *newpath;
3140         signal(SIGSEGV, exit_on_core);
3141         newpath = realpath("/tmp", NULL);
3142         exit((newpath != NULL) ? 0 : 1);
3145 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
3146 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
3147     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
3150 #################################################
3151 # check for AFS clear-text auth support
3152 samba_cv_WITH_AFS=no
3153 AC_MSG_CHECKING(whether to use AFS clear-text auth)
3154 AC_ARG_WITH(afs,
3155 [AS_HELP_STRING([--with-afs], [Include AFS clear-text auth support (default=no)])],
3156 [ case "$withval" in
3157   yes|auto)
3158     AC_MSG_RESULT($withval)
3159     samba_cv_WITH_AFS=$withval
3160     ;;
3161   *)
3162     AC_MSG_RESULT(no)
3163     ;;
3164   esac ],
3165   AC_MSG_RESULT(no)
3168 ####################################################
3169 # check for Linux-specific AFS fake-kaserver support
3170 samba_cv_WITH_FAKE_KASERVER=no
3171 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3172 AC_ARG_WITH(fake-kaserver,
3173 [AS_HELP_STRING([--with-fake-kaserver], [Include AFS fake-kaserver support (default=no)])],
3174 [ case "$withval" in
3175   yes|auto)
3176     AC_MSG_RESULT($withval)
3177     samba_cv_WITH_FAKE_KASERVER=$withval
3178     ;;
3179   *)
3180     AC_MSG_RESULT(no)
3181     ;;
3182   esac ],
3183   AC_MSG_RESULT(no)
3186 #################################################
3187 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3188 if test x"$samba_cv_WITH_AFS" != x"no" ||
3189    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3191     # see if this box has the OpenSSL DES libraries
3192     AC_CHECK_LIB( crypto, DES_pcbc_encrypt, LIBS="$LIBS -lcrypto" , [AC_ERROR(OpenSSL library: libcrypto ot found!)] )
3194     # see if this box has the afs-headers in /usr/include/afs
3195     AC_MSG_CHECKING(for /usr/include/afs)
3196     if test -d /usr/include/afs; then
3197           AC_MSG_RESULT(yes)
3198     else
3199       AC_MSG_RESULT(no)
3200     fi
3202     # check for afs.h
3203     have_afs_headers=no
3204     AC_CHECK_HEADERS(afs.h afs/afs.h)
3205     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3206         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3207            test x"$samba_cv_WITH_AFS" = x"auto"; then
3208                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3209         else
3210                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3211         fi
3212     else
3213         have_afs_headers=yes
3214     fi
3217 FAKE_KASERVER_OBJ=""
3218 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3219     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3220     FAKE_KASERVER_OBJ="utils/net_afs.o"
3222 AC_SUBST(FAKE_KASERVER_OBJ)
3224 #################################################
3225 # check whether to compile AFS/NT ACL mapping module
3226 samba_cv_WITH_VFS_AFSACL=no
3227 AC_MSG_CHECKING(whether to use AFS ACL mapping module)
3228 AC_ARG_WITH(vfs-afsacl,
3229 [AS_HELP_STRING([--with-vfs-afsacl], [Include AFS to NT ACL mapping module (default=no)])],
3230 [ case "$withval" in
3231   yes|auto)
3232     AC_MSG_RESULT($withval)
3233     samba_cv_WITH_VFS_AFSACL=yes
3234     ;;
3235   *)
3236     AC_MSG_RESULT(no)
3237     ;;
3238   esac ],
3239   AC_MSG_RESULT(no)
3242 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3243    default_shared_modules="$default_shared_modules vfs_afsacl"
3245         
3246 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3247     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3250 #################################################
3251 # check for the DFS clear-text auth system
3252 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3253 AC_ARG_WITH(dfs,
3254 [AS_HELP_STRING([--with-dce-dfs], [Include DCE/DFS clear-text auth support (default=no)])],
3255 [ case "$withval" in
3256   yes)
3257     AC_MSG_RESULT(yes)
3258     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3259     ;;
3260   *)
3261     AC_MSG_RESULT(no)
3262     ;;
3263   esac ],
3264   AC_MSG_RESULT(no)
3267 ########################################################
3268 # Compile with LDAP support?
3270 with_ldap_support=auto
3271 AC_MSG_CHECKING([for LDAP support])
3273 AC_ARG_WITH(ldap,
3274 [AS_HELP_STRING([--with-ldap], [LDAP support (default=auto)])],
3275 [ case "$withval" in
3276     yes|no)
3277         with_ldap_support=$withval
3278         ;;
3279   esac ])
3281 AC_MSG_RESULT($with_ldap_support)
3283 SMBLDAP=""
3284 AC_SUBST(SMBLDAP)
3285 SMBLDAPUTIL=""
3286 AC_SUBST(SMBLDAPUTIL)
3288 if test x"$with_ldap_support" != x"no"; then
3290   ##################################################################
3291   # first test for ldap.h and lber.h
3292   # (ldap.h is required for this test)
3293   AC_CHECK_HEADERS(ldap.h lber.h)
3295   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3296         if test x"$with_ldap_support" = x"yes"; then
3297          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3298         else
3299          AC_MSG_WARN(ldap.h is needed for LDAP support)
3300         fi
3301         
3302         with_ldap_support=no
3303   fi
3305   ##################################################################
3306   # HP/UX does not have ber_tag_t in lber.h - it must be configured as
3307   # unsigned int in include/includes.h
3308   case $host_os in
3309         *hpux*)
3310          AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3311          AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
3312         with_ldap_support=yes
3313         ;;
3314         *)
3315         AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
3316         if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
3317                 if test x"$with_ldap_support" = x"yes"; then
3318                 AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
3319                 else
3320                 AC_MSG_WARN(ber_tag_t is needed for LDAP support)
3321                 fi
3322                 with_ldap_support=no
3323         fi
3324         ;;
3325   esac
3328 if test x"$with_ldap_support" != x"no"; then
3329   ac_save_LIBS=$LIBS
3331   ##################################################################
3332   # we might need the lber lib on some systems. To avoid link errors
3333   # this test must be before the libldap test
3334   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3336   ########################################################
3337   # If ber_sockbuf_add_io() is available we can add
3338   # SASL wrapping hooks
3339   AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
3341   AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
3342                  AC_TRY_COMPILE([#include <ldap.h>],
3343                                 [int val = LDAP_OPT_SOCKBUF;],
3344                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
3345                         samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
3347   if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
3348           x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
3349         AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
3350   fi
3352   #######################################################
3353   # if we have LBER_OPT_LOG_PRINT_FN, we can intercept
3354   # ldap logging and print it out in the samba logs
3355   AC_CACHE_CHECK([for LBER_OPT_LOG_PRINT_FN],
3356                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN,
3357                  [AC_TRY_COMPILE([#include <lber.h>],
3358                                  [int val = LBER_OPT_LOG_PRINT_FN;],
3359                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=yes,
3360                                  samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN=no)])
3362   if test x"$samba_cv_HAVE_LBER_OPT_LOG_PRINT_FN" = x"yes"; then
3363         AC_DEFINE(HAVE_LBER_LOG_PRINT_FN, 1,
3364                   [Support for LDAP/LBER logging interception])
3365   fi
3367   ########################################################
3368   # now see if we can find the ldap libs in standard paths
3369   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3371   ########################################################
3372   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3373   # Check found in pam_ldap 145.
3374   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3376   LIBS="$LIBS $LDAP_LIBS"
3377   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3378     AC_TRY_COMPILE([
3379         #include <lber.h>
3380         #include <ldap.h>],
3381         [ldap_set_rebind_proc(0, 0, 0);],
3382         [smb_ldap_cv_ldap_set_rebind_proc=3],
3383         [smb_ldap_cv_ldap_set_rebind_proc=2]
3384     )
3385   ])
3387   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3389   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3391   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3392     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3393     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3394     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3395     default_shared_modules="$default_shared_modules";
3396     SMBLDAP="lib/smbldap.o"
3397     SMBLDAPUTIL="lib/smbldap_util.o"
3398     with_ldap_support=yes
3399     AC_MSG_CHECKING(whether LDAP support is used)
3400     AC_MSG_RESULT(yes)
3401   else
3402     if test x"$with_ldap_support" = x"yes"; then
3403         AC_MSG_ERROR(libldap is needed for LDAP support)
3404     else
3405         AC_MSG_WARN(libldap is needed for LDAP support)
3406     fi
3408     LDAP_LIBS=""
3409     with_ldap_support=no
3410   fi
3411   LIBS=$ac_save_LIBS
3415 #################################################
3416 # active directory support
3418 with_ads_support=auto
3419 AC_MSG_CHECKING([for Active Directory and krb5 support])
3421 AC_ARG_WITH(ads,
3422 [AS_HELP_STRING([--with-ads], [Active Directory support (default=auto)])],
3423 [ case "$withval" in
3424     yes|no)
3425         with_ads_support="$withval"
3426         ;;
3427   esac ])
3429 AC_MSG_RESULT($with_ads_support)
3431 FOUND_KRB5=no
3432 KRB5_LIBS=""
3434 if test x"$with_ldap_support" != x"yes"; then
3436     if test x"$with_ads_support" = x"yes"; then
3437         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3438     elif test x"$with_ads_support" = x"auto"; then
3439         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3440         with_ads_support=no
3441     fi
3443 else
3445     # Check to see whether there is enough LDAP functionality to be able
3446     # to build AD support.
3448 # HPUX only has ldap_init; ok, we take care of this in smbldap.c
3449 case "$host_os" in
3450         *hpux*)
3451     AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
3453     if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
3454         if test x"$with_ads_support" = x"yes"; then
3455             AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
3456         elif test x"$with_ads_support" = x"auto"; then
3457             AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
3458             with_ads_support=no
3459         fi
3460     fi
3461     ;;
3462         *)
3463     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3465     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3466         if test x"$with_ads_support" = x"yes"; then
3467             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3468         elif test x"$with_ads_support" = x"auto"; then
3469             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3470             with_ads_support=no
3471         fi
3472     fi
3473     ;;
3474 esac
3477     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3479     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3480         if test x"$with_ads_support" = x"yes"; then
3481             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3482         elif test x"$with_ads_support" = x"auto"; then
3483             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3484             with_ads_support=no
3485         fi
3486     fi
3490 if test x"$with_ads_support" != x"no"; then
3492   # Do no harm to the values of CFLAGS and LIBS while testing for
3493   # Kerberos support.
3495   if test x$FOUND_KRB5 = x"no"; then
3496     #################################################
3497     # check for location of Kerberos 5 install
3498     AC_MSG_CHECKING(for kerberos 5 install path)
3499     AC_ARG_WITH(krb5,
3500     [AS_HELP_STRING([--with-krb5=base-dir], [Locate Kerberos 5 support (default=/usr)])],
3501     [ case "$withval" in
3502       no)
3503         AC_MSG_RESULT(no krb5-path given)
3504         ;;
3505       yes)
3506         AC_MSG_RESULT(/usr)
3507         FOUND_KRB5=yes
3508         ;;
3509       *)
3510         AC_MSG_RESULT($withval)
3511         KRB5_CFLAGS="-I$withval/include"
3512         KRB5_CPPFLAGS="-I$withval/include"
3513         KRB5_LDFLAGS="-L$withval/lib"
3514         FOUND_KRB5=yes
3515         if test -x "$withval/bin/krb5-config"; then
3516                 KRB5CONFIG=$withval/bin/krb5-config
3517         fi
3518         ;;
3519       esac ],
3520       AC_MSG_RESULT(no krb5-path given)
3521     )
3522   fi
3524   #################################################
3525   # check for krb5-config from recent MIT and Heimdal kerberos 5
3526   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3527   AC_MSG_CHECKING(for working krb5-config)
3528   if test -x "$KRB5CONFIG" && $KRB5CONFIG --libs gssapi > /dev/null ; then
3529     ac_save_CFLAGS=$CFLAGS
3530     CFLAGS="";export CFLAGS
3531     ac_save_LDFLAGS=$LDFLAGS
3532     LDFLAGS="";export LDFLAGS
3533     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3534     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3535     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3536     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3537     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3538     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3539     FOUND_KRB5=yes
3540     AC_MSG_RESULT(yes)
3541   else
3542     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3543   fi
3545   if test x$FOUND_KRB5 = x"no"; then
3546     #################################################
3547     # see if this box has the SuSE location for the heimdal krb implementation
3548     AC_MSG_CHECKING(for /usr/include/heimdal)
3549     if test -d /usr/include/heimdal; then
3550       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3551           KRB5_CFLAGS="-I/usr/include/heimdal"
3552           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3553           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3554           FOUND_KRB5=yes
3555           AC_MSG_RESULT(yes)
3556       else
3557           KRB5_CFLAGS="-I/usr/include/heimdal"
3558           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3559           FOUND_KRB5=yes
3560           AC_MSG_RESULT(yes)
3561       fi
3562     else
3563       AC_MSG_RESULT(no)
3564     fi
3565   fi
3567   if test x$FOUND_KRB5 = x"no"; then
3568     #################################################
3569     # see if this box has the RedHat location for kerberos
3570     AC_MSG_CHECKING(for /usr/kerberos)
3571     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3572       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3573       KRB5_CFLAGS="-I/usr/kerberos/include"
3574       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3575       FOUND_KRB5=yes
3576       AC_MSG_RESULT(yes)
3577     else
3578       AC_MSG_RESULT(no)
3579     fi
3580   fi
3582   if test x$FOUND_KRB5 = x"no"; then
3583     #################################################
3584     # see if this box has the OpenBSD location for heimdal krb5
3585     AC_MSG_CHECKING(for /usr/include/kerberosV)
3586     if test -d /usr/include/kerberosV; then
3587       KRB5_CPPFLAGS="-I/usr/include/kerberosV"
3588       KRB5_LIBS="-lcrypto"
3589       FOUND_KRB5=yes
3590       AC_MSG_RESULT(yes)
3591     else
3592       AC_MSG_RESULT(no)
3593     fi
3594   fi
3596   ac_save_CFLAGS=$CFLAGS
3597   ac_save_CPPFLAGS=$CPPFLAGS
3598   ac_save_LDFLAGS=$LDFLAGS
3600   # remove needless evil rpath stuff as early as possible:
3601   LIB_REMOVE_USR_LIB(KRB5_LIBS)
3602   LIB_REMOVE_USR_LIB(KRB5_LDFLAGS)
3603   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3604   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3605   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3607   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3609   # now check for krb5.h. Some systems have the libraries without the headers!
3610   # note that this check is done here to allow for different kerberos
3611   # include paths
3612   AC_CHECK_HEADERS(krb5.h)
3614   if test x"$ac_cv_header_krb5_h" = x"no"; then
3616     # Give a warning if AD support was not explicitly requested,
3617     # i.e with_ads_support = auto, otherwise die with an error.
3619     if test x"$with_ads_support" = x"yes"; then
3620       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3621     else
3622       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3623     fi
3625     # Turn off AD support and restore CFLAGS and LIBS variables
3627     with_ads_support="no"
3629     CFLAGS=$ac_save_CFLAGS
3630     CPPFLAGS=$ac_save_CPPFLAGS
3631     LDFLAGS=$ac_save_LDFLAGS
3632   fi
3633   AC_CHECK_HEADERS([krb5/locate_plugin.h], [], [],
3634 [[#ifdef HAVE_KRB5_H
3635  #include <krb5.h>
3636  #endif
3639   if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
3640         WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
3641         if test x"$BLDSHARED" = x"true" ; then
3642                 EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
3643         fi
3644   fi
3646   # check for new heimdal KRB5_DEPRECATED handling
3648   AC_CACHE_CHECK([for KRB5_DEPRECATED define taking an identifier],
3649                 samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER,[
3650     AC_TRY_COMPILE(
3651       [#define KRB5_DEPRECATED 1
3652       #include <krb5.h>],
3653       [],
3654       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=yes,
3655       samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=no)])
3657   if test x"$samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER" = x"yes"; then
3658     AC_DEFINE(HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER, 1,
3659                [Whether to use deprecated krb5 interfaces])
3660   fi
3663 # Now we have determined whether we really want ADS support
3664 use_ads=no
3665 if test x"$with_ads_support" != x"no"; then
3666   use_ads=yes
3667   have_gssapi=no
3668   ac_save_LIBS=$LIBS
3670   # now check for gssapi headers.  This is also done here to allow for
3671   # different kerberos include paths
3672   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3674   ##################################################################
3675   # we might need the k5crypto and com_err libraries on some systems
3676   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3677   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3679   # Heimdal checks.
3680   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3681   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3682   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3684   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3685   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],have_gssapi=yes)
3687   ########################################################
3688   # now see if we can find the krb5 libs in standard paths
3689   # or as specified above
3690   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3691   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3693   ########################################################
3694   # now see if we can find the gssapi libs in standard paths
3695   if test x"$have_gssapi" != x"yes"; then
3696      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
3697   fi
3699   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3700   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3701   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_enctypes, $KRB5_LIBS)
3702   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3703   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3704   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3705   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
3706   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3707   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
3708   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3709   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
3710   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3711   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
3712   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
3713   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3714   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3715   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3716   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3717   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3718   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
3719   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3720   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3721   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3722   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3723   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3724   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3725   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3726   AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
3727   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3728   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3729   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3730   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3731   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3732   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3733   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3734   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
3735   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
3736   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
3737   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
3738   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
3739   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
3740   AC_CHECK_FUNC_EXT(krb5_fwd_tgt_creds, $KRB5_LIBS)
3741   AC_CHECK_FUNC_EXT(krb5_auth_con_set_req_cksumtype, $KRB5_LIBS)
3742   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_alloc, $KRB5_LIBS)
3743   AC_CHECK_FUNC_EXT(krb5_get_creds_opt_set_impersonate, $KRB5_LIBS)
3744   AC_CHECK_FUNC_EXT(krb5_get_creds, $KRB5_LIBS)
3745   AC_CHECK_FUNC_EXT(krb5_get_credentials_for_user, $KRB5_LIBS)
3746   AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS)
3747   AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS)
3749   # MIT krb5 1.8 does not expose this call (yet)
3750   AC_CHECK_DECLS(krb5_get_credentials_for_user, [], [], [#include <krb5.h>])
3752   # MIT krb5 1.7beta3 (in Ubuntu Karmic) does not have this declaration
3753   # but does have the symbol
3754   AC_CHECK_DECLS(krb5_auth_con_set_req_cksumtype, [], [], [#include <krb5.h>])
3756   LIBS="$KRB5_LIBS $LIBS"
3758   AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
3759         smb_krb5_cv_ticket_has_keyinfo,
3760         [
3761             AC_TRY_COMPILE(
3762             [
3763                 #include <krb5.h>
3764             ],
3765             [
3766                 krb5_ticket ticket;
3767                 krb5_kvno kvno;
3768                 krb5_enctype enctype;
3770                 enctype = ticket.enc_part.enctype;
3771                 kvno = ticket.enc_part.kvno;
3772             ],
3773             [ smb_krb5_cv_ticket_has_keyinfo=yes ],
3774             [ smb_krb5_cv_ticket_has_keyinfo=no ])
3775         ])
3777   if test x"$smb_krb5_cv_ticket_has_keyinfo" = x"yes" ; then
3778         AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
3779             [Whether the krb5_ticket structure contains the kvno and enctype])
3780   fi
3782   AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
3783           smb_krb5_cv_creds_opt_free_context,
3784           [
3785                 AC_TRY_COMPILE([
3786                     #include <krb5.h>],
3787                     [
3788                         krb5_context ctx;
3789                         krb5_get_init_creds_opt *opt = NULL;
3790                         krb5_get_init_creds_opt_free(ctx, opt);
3791                     ],
3792                     [smb_krb5_cv_creds_opt_free_context=yes],
3793                     [smb_krb5_cv_creds_opt_free_context=no]
3794                 )
3795           ])
3797   if test x"$smb_krb5_cv_creds_opt_free_context" = x"yes" ; then
3798         AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
3799             [Whether krb5_get_init_creds_opt_free takes a context argument])
3800   fi
3802   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_cv_verify_checksum, [
3803     AC_TRY_COMPILE([
3804         #include <krb5.h>],
3805         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
3806         [smb_krb5_cv_verify_checksum=7],
3807         [smb_krb5_cv_verify_checksum=6],
3808     )
3809   ])
3810   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_cv_verify_checksum, [Number of arguments to krb5_verify_checksum])
3812   AC_CACHE_CHECK([for checksum in krb5_checksum],
3813                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3814     AC_TRY_COMPILE([#include <krb5.h>],
3815       [krb5_checksum cksum; cksum.checksum.length = 0;],
3816       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3817       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3819   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3820     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3821                [Whether the krb5_checksum struct has a checksum property])
3822   fi
3824   AC_CACHE_CHECK([for etype in EncryptedData],
3825                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3826     AC_TRY_COMPILE([#include <krb5.h>],
3827       [EncryptedData edata; edata.etype = 0;],
3828       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3829       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3831   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3832     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3833                [Whether the EncryptedData struct has a etype property])
3834   fi
3836   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3837                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3838     AC_TRY_COMPILE([#include <krb5.h>],
3839       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3840       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3841       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3843   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3844     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3845                [Whether the krb5_ap_req struct has a ticket pointer])
3846   fi
3848   AC_CACHE_CHECK([for e_data pointer in krb5_error],
3849                 samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
3850     AC_TRY_COMPILE([#include <krb5.h>],
3851       [krb5_error err; err.e_data = NULL;],
3852       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
3853       samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
3855   if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
3856     AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
3857                [Whether the krb5_error struct has a e_data pointer])
3858   fi
3860   AC_CACHE_CHECK([for krb5_crypto type],
3861                 samba_cv_HAVE_KRB5_CRYPTO,[
3862     AC_TRY_COMPILE([#include <krb5.h>],
3863       [krb5_crypto crypto;],
3864       samba_cv_HAVE_KRB5_CRYPTO=yes,
3865       samba_cv_HAVE_KRB5_CRYPTO=no)])
3867   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3868     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3869                [Whether the type krb5_crypto exists])
3870   fi
3872   AC_CACHE_CHECK([for krb5_encrypt_block type],
3873                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3874     AC_TRY_COMPILE([#include <krb5.h>],
3875       [krb5_encrypt_block block;],
3876       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3877       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3879   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3880     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3881                [Whether the type krb5_encrypt_block exists])
3882   fi
3884   AC_CACHE_CHECK([for addrtype in krb5_address],
3885                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3886     AC_TRY_COMPILE([#include <krb5.h>],
3887       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3888       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3889       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3891   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3892     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3893                [Whether the krb5_address struct has a addrtype property])
3894   fi
3896   AC_CACHE_CHECK([for addr_type in krb5_address],
3897                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3898     AC_TRY_COMPILE([#include <krb5.h>],
3899       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3900       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3901       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3903   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3904     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3905               [Whether the krb5_address struct has a addr_type property])
3906   fi
3908   AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
3909                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3910                  [AC_TRY_COMPILE([#include <krb5.h>],
3911     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3912     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3914   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3915     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3916               [Whether the krb5_ticket struct has a enc_part2 property])
3917   fi
3919   AC_CACHE_CHECK([for keyblock in krb5_creds],
3920                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3921     AC_TRY_COMPILE([#include <krb5.h>],
3922       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3923       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3924       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
3926   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
3927     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
3928               [Whether the krb5_creds struct has a keyblock property])
3929   fi
3931   AC_CACHE_CHECK([for session in krb5_creds],
3932                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
3933     AC_TRY_COMPILE([#include <krb5.h>],
3934       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
3935       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
3936       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
3938   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
3939     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
3940               [Whether the krb5_creds struct has a session property])
3941   fi
3943   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
3944                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
3945     AC_TRY_COMPILE([#include <krb5.h>],
3946       [krb5_keyblock key; key.keyvalue.data = NULL;],
3947       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
3948       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
3950   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
3951     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
3952               [Whether the krb5_keyblock struct has a keyvalue property])
3953   fi
3955   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
3956                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
3957     AC_TRY_COMPILE([#include <krb5.h>],
3958       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
3959       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
3960       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
3961   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
3962                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
3963     AC_TRY_COMPILE([#include <krb5.h>],
3964       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
3965       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
3966       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
3967 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
3968 # w.r.t. arcfour and windows, so we must not enable it here
3969   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
3970           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
3971     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
3972               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
3973   fi
3975   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
3976                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
3977     AC_TRY_COMPILE([#include <krb5.h>],
3978       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
3979       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
3980       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
3982   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
3983     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
3984               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
3985   fi
3987   AC_CACHE_CHECK([for KV5M_KEYTAB],
3988                  samba_cv_HAVE_KV5M_KEYTAB,[
3989     AC_TRY_COMPILE([#include <krb5.h>],
3990       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
3991       samba_cv_HAVE_KV5M_KEYTAB=yes,
3992       samba_cv_HAVE_KV5M_KEYTAB=no)])
3994   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
3995       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
3996              [Whether the KV5M_KEYTAB option is available])
3997   fi
3999   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
4000                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
4001     AC_TRY_COMPILE([#include <krb5.h>],
4002       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
4003       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
4004       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
4006   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
4007     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
4008               [Whether KRB5_KU_OTHER_CKSUM is available])
4009   fi
4011   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
4012                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
4013     AC_TRY_COMPILE([#include <krb5.h>],
4014       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
4015       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
4016       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
4018   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
4019     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
4020               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
4021   fi
4023   AC_CACHE_CHECK([for the krb5_princ_component macro],
4024                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
4025     AC_TRY_LINK([#include <krb5.h>],
4026       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
4027       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
4028       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
4030   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
4031     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
4032                [Whether krb5_princ_component is available])
4033   fi
4035   AC_CACHE_CHECK([for key in krb5_keytab_entry],
4036                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
4037     AC_TRY_COMPILE([#include <krb5.h>],
4038       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
4039       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
4040       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
4042   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
4043     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
4044               [Whether krb5_keytab_entry has key member])
4045   fi
4047   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
4048                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
4049     AC_TRY_COMPILE([#include <krb5.h>],
4050       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
4051       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
4052       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
4054   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
4055     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
4056               [Whether krb5_keytab_entry has keyblock member])
4057   fi
4059   AC_CACHE_CHECK([for magic in krb5_address],
4060                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
4061     AC_TRY_COMPILE([#include <krb5.h>],
4062       [krb5_address addr; addr.magic = 0;],
4063       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
4064       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
4066   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
4067     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
4068               [Whether the krb5_address struct has a magic property])
4069   fi
4071   AC_CACHE_CHECK([for WRFILE: keytab support],
4072                 samba_cv_HAVE_WRFILE_KEYTAB,[
4073     AC_TRY_RUN([
4074 #include<krb5.h>
4075   main()
4076   {
4077     krb5_context context;
4078     krb5_keytab keytab;
4080     krb5_init_context(&context);
4081     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
4082   }],
4083   samba_cv_HAVE_WRFILE_KEYTAB=yes,
4084   samba_cv_HAVE_WRFILE_KEYTAB=no)])
4086   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
4087       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
4088                [Whether the WRFILE:-keytab is supported])
4089   fi
4091   AC_CACHE_CHECK([for krb5_realm type],
4092                 samba_cv_HAVE_KRB5_REALM_TYPE,[
4093     AC_TRY_COMPILE([#include <krb5.h>],
4094       [krb5_realm realm;],
4095       samba_cv_HAVE_KRB5_REALM_TYPE=yes,
4096       samba_cv_HAVE_KRB5_REALM_TYPE=no)])
4098   if test x"$samba_cv_HAVE_KRB5_REALM_TYPE" = x"yes"; then
4099     AC_DEFINE(HAVE_KRB5_REALM_TYPE,1,
4100                [Whether the type krb5_realm exists])
4101   fi
4103   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
4104                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
4105     AC_TRY_COMPILE([#include <krb5.h>],
4106     [
4107     krb5_context context;
4108     krb5_principal principal;
4109     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
4110     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
4111     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
4113   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
4114     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
4115               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
4116   fi
4118   AC_CACHE_CHECK([for krb5_addresses type],
4119                 samba_cv_HAVE_KRB5_ADDRESSES,[
4120     AC_TRY_COMPILE([#include <krb5.h>],
4121       [krb5_addresses addr;],
4122       samba_cv_HAVE_KRB5_ADDRESSES=yes,
4123       samba_cv_HAVE_KRB5_ADDRESSES=no)])
4125   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
4126     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
4127                [Whether the type krb5_addresses type exists])
4128   fi
4130   AC_CACHE_CHECK([whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal],
4131                 samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE, [
4132     AC_TRY_COMPILE([#include <krb5.h>],
4133     [
4134     krb5_mk_error(0,0,0);],
4135     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=yes,
4136     samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=no)])
4138   if test x"$samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE" = x"yes"; then
4139     AC_DEFINE(HAVE_SHORT_KRB5_MK_ERROR_INTERFACE,1,
4140               [whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal])
4141   fi
4143   if test x"$ac_cv_func_ext_krb5_enctype_to_string" = x"yes"; then
4144     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_context context, krb5_enctype enctype, char **str)],
4145         smb_krb5_cv_enctype_to_string_takes_krb5_context_arg,[
4146         AC_TRY_RUN_STRICT([
4147                 #include <stdlib.h>
4148                 #include <krb5.h>
4149                 int main(void) {
4150                         krb5_context context = NULL;
4151                         char *str = NULL;
4152                         krb5_enctype_to_string(context, 1, &str);
4153                         if (str) free (str); 
4154                         return 0;
4155                 }
4156                 ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4157                 smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=yes,
4158                 smb_krb5_cv_enctype_to_string_takes_krb5_context_arg=no)])
4160     if test x"$smb_krb5_cv_enctype_to_string_takes_krb5_context_arg" = x"yes"; then
4161       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG,1,
4162                 [whether krb5_enctype_to_string takes krb5_context argument])
4163     fi
4165     AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_enctype enctype, char *str, size_t len)],
4166         smb_krb5_cv_enctype_to_string_takes_size_t_arg,[
4167         AC_TRY_RUN_STRICT([
4168                 #include <krb5.h>
4169                 int main(void) {
4170                         char buf[256];
4171                         krb5_enctype_to_string(1, buf, 256);
4172                         return 0;
4173                 }
4174                 ],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4175                 smb_krb5_cv_enctype_to_string_takes_size_t_arg=yes,
4176                 smb_krb5_cv_enctype_to_string_takes_size_t_arg=no)])
4178     if test x"$smb_krb5_cv_enctype_to_string_takes_size_t_arg" = x"yes"; then
4179       AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG,1,
4180                 [whether krb5_enctype_to_string takes size_t argument])
4181     fi
4182   fi
4184   AC_CACHE_CHECK([for krb5_principal_get_realm],
4185                 samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
4186     AC_TRY_LINK([#include <krb5.h>],
4187       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
4188       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
4189       samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
4191   if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
4192     AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
4193                [Whether the function krb5_principal_get_realm is defined])
4194   fi
4196   AC_CACHE_CHECK([for krb5_princ_realm],
4197                 samba_cv_HAVE_KRB5_PRINC_REALM,[
4198     AC_TRY_LINK([#include <krb5.h>],
4199       [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
4200       samba_cv_HAVE_KRB5_PRINC_REALM=yes,
4201       samba_cv_HAVE_KRB5_PRINC_REALM=no)])
4203   if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
4204     AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
4205                [Whether the macro krb5_princ_realm is defined])
4206   fi
4208   #
4209   #
4210   # Now the decisions whether we can support krb5
4211   #
4212   # NOTE: all tests should be done before this block!
4213   #
4214   #
4215   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
4216     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
4217     use_ads=no
4218   fi
4220   if test x"$ac_cv_func_ext_krb5_principal2salt" != x"yes" -a \
4221           x"$ac_cv_func_ext_krb5_get_pw_salt" != x"yes"
4222   then
4223     AC_MSG_WARN(no CREATE_KEY_FUNCTIONS detected)
4224     use_ads=no
4225   fi
4227   if test x"$ac_cv_func_ext_krb5_get_permitted_enctypes" != x"yes" -a \
4228           x"$ac_cv_func_ext_krb5_get_default_in_tkt_etypes" != x"yes"
4229   then
4230     AC_MSG_WARN(no GET_ENCTYPES_FUNCTIONS detected)
4231     use_ads=no
4232   fi
4234   if test x"$ac_cv_func_ext_krb5_kt_free_entry" != x"yes" -a \
4235           x"$ac_cv_func_ext_krb5_free_keytab_entry_contents" != x"yes"
4236   then
4237     AC_MSG_WARN(no KT_FREE_FUNCTION detected)
4238     use_ads=no
4239   fi
4241   if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes" -a \
4242           x"$ac_cv_func_ext_krb5_verify_checksum" != x"yes"
4243   then
4244     AC_MSG_WARN(no KRB5_VERIFY_CHECKSUM_FUNCTION detected)
4245     use_ads=no
4246   fi
4248   if test x"$smb_krb5_cv_ticket_has_keyinfo" != x"yes" ; then
4250       # We only need the following functions if we can't get the enctype
4251       # and kvno out of the ticket directly (ie. on Heimdal).
4253       if test x"$ac_cv_func_ext_free_AP_REQ" != x"yes"
4254       then
4255         AC_MSG_WARN(no KRB5_AP_REQ_FREE_FUNCTION detected)
4256         use_ads=no
4257       fi
4259       if test x"$ac_cv_func_ext_krb5_decode_ap_req" != x"yes"
4260       then
4261         AC_MSG_WARN(no KRB5_AP_REQ_DECODING_FUNCTION detected)
4262         use_ads=no
4263       fi
4265   fi
4267   if test x"$use_ads" = x"yes"; then
4268     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
4269     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
4270     if test x"$have_gssapi" = x"yes"; then
4271       AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
4272     fi
4273   else
4274     if test x"$with_ads_support" = x"yes"; then
4275         AC_MSG_ERROR(krb5 libs don't have all features required for Active Directory support)
4276     else
4277         AC_MSG_WARN(krb5 libs don't have all features required for Active Directory support)
4278     fi
4279     AC_REMOVE_DEFINE(HAVE_KRB5_H)
4280     AC_REMOVE_DEFINE(HAVE_GSSAPI_H)
4281     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4282     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_H)
4283     KRB5_LIBS=""
4284     with_ads_support=no
4285   fi
4286   AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
4287   AC_MSG_RESULT([$use_ads])
4289 LIBS="$ac_save_LIBS"
4292 if test x"$use_ads" != xyes; then
4293         merged_build_possible=no
4296 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
4297 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
4300 ########################################################
4301 # Compile with DNS Updates support?
4303 with_dnsupdate_support=auto
4304 AC_MSG_CHECKING([whether to enable DNS Updates support])
4306 AC_ARG_WITH(dnsupdate,
4307 [AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default=auto)])],
4308 [ case "$withval" in
4309     yes|no)
4310         with_dnsupdate_support=$withval
4311         ;;
4312   esac ])
4314 AC_MSG_RESULT($with_dnsupdate_support)
4316 if test x"$with_dnsupdate_support" != x"no"; then
4318   ################################################################
4319   # first test for AD / GSSAPI support being enabled
4320         if test x"$have_gssapi" != xyes ; then
4321                 if test x"$with_dnsupdate_support" = x"yes" ; then
4322                         AC_MSG_ERROR(DNS Updates support only possible with AD and GSSAPI support)
4323                 else
4324                         AC_MSG_NOTICE(DNS Updates support only possible with AD and GSSAPI support)
4325                         with_dnsupdate_support=no
4326                 fi
4327         fi
4328   ##################################################################
4329   # then test for uuid.h (necessary to generate unique DNS keynames
4330   # (uuid.h is required for this test)
4331         AC_CHECK_HEADERS(uuid/uuid.h)
4333         
4334         if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
4335                 if test x"$with_dnsupdate_support" = x"yes"; then
4336                         AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
4337                 else
4338                         AC_MSG_NOTICE(uuid.h is needed to enable DNS Updates support)
4339                 fi
4340                 with_dnsupdate_support=no
4341         fi
4344 if test x"$with_dnsupdate_support" != x"no"; then
4346   ########################################################
4347   # Now see if we can find the uuid libs in standard paths
4348   # On some systems, the uuid API is in libc, so we have to
4349   # be careful not to insert a spurious -luuid.
4351   UUID_LIBS=""
4352   AC_LIBTESTFUNC(uuid, uuid_generate,
4353           [
4354             case " $LIBS " in
4355                 *\ -luuid\ *)
4356                 UUID_LIBS="-luuid"
4357                 SMB_REMOVE_LIB(uuid)
4358                 ;;
4359             esac
4361             with_dnsupdate_support=yes
4362             AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
4363         ],
4364         [
4365             if test x"$with_dnsupdate_support" = x"yes"; then
4366                 AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
4367             else
4368                 AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
4369             fi
4370             with_dnsupdate_support=no
4371         ])
4373   # finally print out the result:
4374 AC_MSG_CHECKING(whether DNS Updates support is used)
4375 AC_MSG_RESULT([$with_dnsupdate_support])
4378 #################################################
4379 # check for automount support
4380 AC_MSG_CHECKING(whether to use automount)
4381 AC_ARG_WITH(automount,
4382 [AS_HELP_STRING([--with-automount], [Include automount support (default=no)])],
4383 [ case "$withval" in
4384   yes)
4385     AC_MSG_RESULT(yes)
4386     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
4387     ;;
4388   *)
4389     AC_MSG_RESULT(no)
4390     ;;
4391   esac ],
4392   AC_MSG_RESULT(no)
4395 #################################################
4396 # Check for a PAM clear-text auth, accounts, password
4397 # and session support. Most PAM implementations keep their
4398 # headers in /usr/include/security. Darwin keeps its in
4399 # /usr/include/pam.
4401 with_pam_for_crypt=no
4402 try_pam=auto
4403 AC_MSG_CHECKING(whether to try PAM support)
4404 AC_ARG_WITH(pam,
4405 [AS_HELP_STRING([--with-pam], [Include PAM support (default=auto)])],
4406 [ case "$withval" in
4407   yes|no|auto)
4408     try_pam=$withval
4409     ;;
4410   esac
4412 AC_MSG_RESULT([$try_pam])
4414 use_pam=no
4415 create_pam_modules=no
4416 if test x"${try_pam}" != x"no";then
4417         use_pam=yes
4418         create_pam_modules=yes
4420         # Most systems have PAM headers in /usr/include/security, but Darwin
4421         # has them in /usr/include/pam.
4422         AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
4423         if test x"$ac_cv_header_security_pam_appl_h" != x"yes" -a \
4424                 x"$ac_cv_header_pam_pam_appl_h" != x"yes"; then
4425                 if test x"${try_pam}" = x"yes";then
4426                         AC_MSG_ERROR([--with-pam=yes but pam_appl.h not found])
4427                 fi
4428                 use_pam=no
4429                 create_pam_modules=no
4430         fi
4432         AC_CHECK_LIB_EXT(pam, PAM_LIBS, pam_get_data)
4433         if test x"$ac_cv_lib_ext_pam_pam_get_data" != x"yes"; then
4434                 if test x"${try_pam}" = x"yes";then
4435                         AC_MSG_ERROR([--with-pam=yes but libpam not found])
4436                 fi
4437                 use_pam=no
4438                 create_pam_modules=no
4439         fi
4441         AC_CHECK_HEADERS(security/pam_modules.h pam/pam_modules.h,,,[[
4442                 #if HAVE_SECURITY_PAM_APPL_H
4443                 #include <security/pam_appl.h>
4444                 #endif
4445                 #if HAVE_PAM_PAM_APPL_H
4446                 #include <pam/pam_appl.h>
4447                 #endif
4448         ]])
4449         if test x"$ac_cv_header_security_pam_modules_h" = x"no" -a \
4450                 x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
4451                 if test x"${try_pam}" = x"yes";then
4452                         AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
4453        fi
4454                 create_pam_modules=no
4455     fi
4457         if test x"$use_pam" = x"yes"; then
4458     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
4459                 AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
4460                 AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
4461     with_pam_for_crypt=yes
4463                 if test x"$create_pam_modules" = x"yes"; then
4464                         AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
4465                         # this checks are optional,
4466                         # we don't care about the results here
4467                         AC_CHECK_HEADERS(security/pam_ext.h security/_pam_macros.h)
4468                         AC_CHECK_HEADERS(pam/pam_ext.h pam/_pam_macros.h)
4469                         AC_CHECK_FUNC_EXT(pam_vsyslog,$PAM_LIBS)
4470                 else
4471                         AC_MSG_WARN([PAM support detected but PAM MODULES support is missing])          
4472                 fi
4473         fi
4474         AC_MSG_CHECKING(whether to use PAM support)
4475         AC_MSG_RESULT([$use_pam])
4477         AC_MSG_CHECKING(whether to have PAM MODULES support)
4478         AC_MSG_RESULT([$create_pam_modules])
4479 fi # try_pam != no
4481 #################################################
4482 # check for PAM_RADIO_TYPE
4483 AC_TRY_COMPILE([
4484 #if (!defined(LINUX))
4486 #define PAM_EXTERN extern
4487 #if defined(HAVE_SECURITY_PAM_APPL_H)
4488 #include <security/pam_appl.h>
4489 #elif defined(HAVE_PAM_PAM_APPL_H)
4490 #include <pam/pam_appl.h>
4491 #endif
4493 #endif
4495 #if defined(HAVE_SECURITY_PAM_MODULES_H)
4496 #include <security/pam_modules.h>
4497 #elif defined(HAVE_PAM_PAM_MODULES_H)
4498 #include <pam/pam_modules.h>
4499 #endif
4501 #if defined(HAVE_SECURITY__PAM_MACROS_H)
4502 #include <security/_pam_macros.h>
4503 #elif defined(HAVE_PAM__PAM_MACROS_H)
4504 #include <pam/_pam_macros.h>
4505 #endif
4507 #ifdef HAVE_SECURITY_PAM_EXT_H
4508 #include <security/pam_ext.h>
4509 #endif
4511 [int i; i = PAM_RADIO_TYPE; ],
4512 AC_DEFINE(HAVE_PAM_RADIO_TYPE, 1, [Define to 1 if PAM_RADIO_TYPE is available]),[])
4514 #################################################
4515 # check for pam_smbpass support
4516 PAM_MODULES=""
4517 INSTALL_PAM_MODULES=""
4518 UNINSTALL_PAM_MODULES=""
4520 try_pam_smbpass=auto
4521 AC_MSG_CHECKING(whether to use pam_smbpass)
4522 AC_ARG_WITH(pam_smbpass,
4523 [AS_HELP_STRING([--with-pam_smbpass], [Build PAM module for authenticating against passdb backends (default=auto)])],
4524 [ case "$withval" in
4525   yes|no|auto)
4526     try_pam_smbpass=$withval
4527   ;;
4528   *)
4529     AC_MSG_ERROR([valid options are yes,no,auto])
4530   ;;
4531   esac
4534 if test x"${try_pam_smbpass}" = xno ; then
4535         use_pam_smbpass=no
4536 else
4537         use_pam_smbpass=yes
4538         # Conditions under which pam_smbpass can't be built.
4539         if test x"$BLDSHARED" != xtrue ; then
4540                 if test x"${try_pam_smbpass}" = xyes ; then
4541                         AC_MSG_ERROR([No support for shared modules])
4542                 fi
4543                 use_pam_smbpass=no
4544         elif test x"$create_pam_modules" != xyes ; then
4545                 if test x"${try_pam_smbpass}" = xyes ; then
4546                         AC_MSG_ERROR([No support for PAM MODULES])
4547                 fi
4548                 use_pam_smbpass=no
4549         fi
4551         if test x"${use_pam_smbpass}" = xyes ; then 
4552                 PAM_MODULES="pam_smbpass"
4553                 INSTALL_PAM_MODULES="installpammodules"
4554                 UNINSTALL_PAM_MODULES="uninstallpammodules"
4555         fi
4557 AC_MSG_RESULT([$use_pam_smbpass])
4561 ## moved after the check for -lcrypt in order to
4562 ## ensure that the necessary libraries are included
4563 ## check checking for truncated salt.  Wrapped by the
4564 ## $with_pam_for_crypt variable as above   --jerry
4566 if test $with_pam_for_crypt = no; then
4567 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
4568 crypt_LIBS="$LIBS"
4569 LIBS="$AUTH_LIBS $LIBS"
4570 AC_TRY_RUN([#include "${srcdir-.}/../tests/crypttest.c"],
4571         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
4572 LIBS="$crypt_LIBS"])
4573 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
4574         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
4578 #################################################
4579 # check for a NISPLUS_HOME support
4580 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
4581 AC_ARG_WITH(nisplus-home,
4582 [AS_HELP_STRING([--with-nisplus-home], [Include NISPLUS_HOME support (default=no)])],
4583 [ case "$withval" in
4584   yes)
4585     AC_MSG_RESULT(yes)
4586     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
4587     ;;
4588   *)
4589     AC_MSG_RESULT(no)
4590     ;;
4591   esac ],
4592   AC_MSG_RESULT(no)
4595 #################################################
4596 # check for syslog logging
4597 AC_MSG_CHECKING(whether to use syslog logging)
4598 AC_ARG_WITH(syslog,
4599 [AS_HELP_STRING([--with-syslog], [Include experimental SYSLOG support (default=no)])],
4600 [ case "$withval" in
4601   yes)
4602     AC_MSG_RESULT(yes)
4603     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
4604     ;;
4605   *)
4606     AC_MSG_RESULT(no)
4607     ;;
4608   esac ],
4609   AC_MSG_RESULT(no)
4612 #################################################
4613 # check for custom syslog facility
4614 AC_MSG_CHECKING(whether to use a custom syslog facility)
4615 AC_ARG_WITH(syslog-facility,
4616 [AS_HELP_STRING([--with-syslog-facility], [Use a custom syslog facility (default=none)])],
4618   if test "$withval" = "no" ; then
4619     AC_MSG_ERROR([argument to --with-syslog-facility must be a string])
4620   else
4621      if test "$withval" != "yes" ; then
4622         syslog_facility="$withval"
4623         AC_DEFINE_UNQUOTED(SYSLOG_FACILITY,$syslog_facility, [syslog facility to log to])
4624      fi
4625   fi
4628 #################################################
4629 # check for experimental disk-quotas support
4631 samba_cv_WITH_QUOTAS=auto
4632 samba_cv_TRY_QUOTAS=no
4633 samba_cv_RUN_QUOTA_TESTS=auto
4634 samba_cv_WITH_SYS_QUOTAS=auto
4635 samba_cv_TRY_SYS_QUOTAS=auto
4636 samba_cv_SYSQUOTA_FOUND=no
4638 AC_MSG_CHECKING(whether to try disk-quotas support)
4639 AC_ARG_WITH(quotas,
4640 [AS_HELP_STRING([--with-quotas], [Include disk-quota support (default=no)])],
4641 [ case "$withval" in
4642   yes)
4643     AC_MSG_RESULT(yes)
4644     samba_cv_WITH_QUOTAS=yes
4645     samba_cv_TRY_QUOTAS=yes
4646     samba_cv_RUN_QUOTA_TESTS=yes
4647     #set sys quotas to auto in this case
4648     samba_cv_TRY_SYS_QUOTAS=auto
4649     ;;
4650   auto)
4651     AC_MSG_RESULT(auto)
4652     samba_cv_WITH_QUOTAS=auto
4653     samba_cv_TRY_QUOTAS=auto
4654     samba_cv_RUN_QUOTA_TESTS=auto
4655     #set sys quotas to auto in this case
4656     samba_cv_TRY_SYS_QUOTAS=auto
4657     ;;
4658   no)
4659     AC_MSG_RESULT(no)
4660     samba_cv_WITH_QUOTAS=no
4661     samba_cv_TRY_QUOTAS=no
4662     samba_cv_RUN_QUOTA_TESTS=no
4663     ;;
4664   *)
4665     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4666     ;;
4667   esac ],
4668   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4671 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4672 AC_ARG_WITH(sys-quotas,
4673 [AS_HELP_STRING([--with-sys-quotas], [Include lib/sysquotas.c support (default=auto)])],
4674 [ case "$withval" in
4675   yes)
4676     AC_MSG_RESULT(yes)
4677     samba_cv_WITH_SYS_QUOTAS=yes
4678     samba_cv_TRY_SYS_QUOTAS=yes
4679     samba_cv_RUN_QUOTA_TESTS=yes
4680     ;;
4681   auto)
4682     AC_MSG_RESULT(auto)
4683     samba_cv_WITH_SYS_QUOTAS=auto
4684     samba_cv_TRY_SYS_QUOTAS=auto
4685     samba_cv_RUN_QUOTA_TESTS=auto
4686     ;;
4687   no)
4688     AC_MSG_RESULT(no)
4689     samba_cv_WITH_SYS_QUOTAS=no
4690     samba_cv_TRY_SYS_QUOTAS=no
4691     ;;
4692   *)
4693     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4694     ;;
4695   esac ],
4696   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4699 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4700 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4701   case "$host_os" in
4702         *linux*)
4703             AC_MSG_RESULT(yes)
4704             samba_cv_TRY_SYS_QUOTAS=yes
4705             samba_cv_RUN_QUOTA_TESTS=yes
4706             ;;
4707         *)
4708             AC_MSG_RESULT(no)
4709             samba_cv_TRY_SYS_QUOTAS=no
4710             ;;
4711   esac
4714 #############################################
4715 # only check for quota stuff if --with-quotas
4716 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4718 case "$host_os" in
4719         # on linux we didn't need to test we have builtin support
4720         *linux*)
4721             samba_cv_SYSQUOTA_FOUND=yes
4722             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4723             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4724             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4725             AC_MSG_RESULT(yes)
4727             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4728             samba_cv_found_xfs_header=yes
4729             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4730             AC_MSG_RESULT(yes)
4731             ;;
4732         *solaris*)
4733             # need to set this define when using static linking (BUG 1473)
4734             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4735             ;;
4736         *)
4737             ;;
4738 esac
4740 # some broken header files need this
4741 AC_CHECK_HEADER(asm/types.h,[
4742             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4743             AC_ADD_INCLUDE(<asm/types.h>)
4744             ])
4746 # For quotas on Veritas VxFS filesystems
4747 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4749 # For quotas on Linux XFS filesystems
4750 AC_CHECK_HEADERS(linux/dqblk_xfs.h)
4752 # For sys/quota.h and linux/quota.h
4753 AC_CHECK_HEADERS(sys/quota.h)
4755 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4756 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4757 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4758 AC_TRY_COMPILE([
4759 #include "confdefs.h"
4760 #ifdef HAVE_SYS_TYPES_H
4761 #include <sys/types.h>
4762 #endif
4763 #ifdef HAVE_ASM_TYPES_H
4764 #include <asm/types.h>
4765 #endif
4766 #include <sys/quota.h>
4767 ],[int i = Q_XGETQUOTA;],
4768 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4769 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4770         samba_cv_found_xfs_header=yes
4774 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX
4775 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4776 AC_TRY_COMPILE([
4777 #include "confdefs.h"
4778 #ifdef HAVE_SYS_QUOTA_H
4779 #include <sys/quota.h>
4780 #endif
4782 struct dqblk D;
4783 D.dqb_fsoftlimit = 0;],
4784 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4785 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4786         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
4789 ##################
4790 # look for a working quota system
4792 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4793 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
4794 AC_TRY_RUN_STRICT([
4795 #define HAVE_QUOTACTL_4A 1
4796 #define AUTOCONF_TEST 1
4797 #include "confdefs.h"
4798 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4799            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
4800 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
4801     samba_cv_SYSQUOTA_FOUND=yes;
4802     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
4803     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
4807 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4808 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
4809 AC_TRY_RUN_STRICT([
4810 #define HAVE_QUOTACTL_4B 1
4811 #define AUTOCONF_TEST 1
4812 #include "confdefs.h"
4813 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4814            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
4815 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
4816     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
4817     samba_cv_SYSQUOTA_FOUND=yes;
4818     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
4819     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
4823 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4824 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
4825 AC_TRY_RUN_STRICT([
4826 #define HAVE_QUOTACTL_3 1
4827 #define AUTOCONF_TEST 1
4828 #include "confdefs.h"
4829 #include "${srcdir-.}/../tests/sysquotas.c"],[$CFLAGS $Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4830            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
4831 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
4832     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
4833     samba_cv_SYSQUOTA_FOUND=yes;
4834     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
4835     samba_cv_sysquotas_file="lib/sysquotas_3.c"
4839 #################################################
4840 # check for mntent.h and struct mntent
4841 AC_CHECK_HEADERS(mntent.h)
4842 #################################################
4843 # check for setmntent,getmntent,endmntent
4844 AC_CHECK_FUNCS(setmntent getmntent endmntent)
4846 #################################################
4847 # check for devnm.h and struct mntent
4848 AC_CHECK_HEADERS(devnm.h)
4849 #################################################
4850 # check for devnm
4851 AC_CHECK_FUNCS(devnm)
4853 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
4854     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4855         # if --with-sys-quotas=yes then build it
4856         # you have can use the get/set quota command smb.conf
4857         # options then
4858         samba_cv_SYSQUOTA_FOUND=auto
4859     fi
4860     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
4861         # if --with-sys-quotas=yes then build it
4862         # you have can use the get/set quota command smb.conf
4863         # options then
4864         samba_cv_TRY_SYS_QUOTAS=auto
4865     fi
4868 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
4869 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
4870 SAVE_CPPFLAGS="$CPPFLAGS"
4871 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4872 AC_TRY_COMPILE([
4873 #include "confdefs.h"
4874 #define NO_PROTO_H 1
4875 #define NO_CONFIG_H 1
4876 #define HAVE_SYS_QUOTAS 1
4877 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
4878 #include "${srcdir-.}/lib/sysquotas.c"
4879 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
4880 CPPFLAGS="$SAVE_CPPFLAGS"
4882 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
4883 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
4884     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
4885         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4886         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
4887         samba_cv_WE_USE_SYS_QUOTAS=yes
4888         AC_MSG_RESULT(yes)
4889     else
4890         AC_MSG_RESULT(no)
4891     fi
4895 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
4896 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
4897 SAVE_CPPFLAGS="$CPPFLAGS"
4898 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4899 AC_TRY_COMPILE([
4900 #include "confdefs.h"
4901 #define NO_PROTO_H 1
4902 #define NO_CONFIG_H 1
4903 #define HAVE_SYS_QUOTAS 1
4904 #define HAVE_XFS_QUOTAS 1
4905 #include "${srcdir-.}/lib/sysquotas_xfs.c"
4906 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
4907 CPPFLAGS="$SAVE_CPPFLAGS"
4909 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
4910     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
4911         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
4912     fi
4916 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
4917 SAVE_CPPFLAGS="$CPPFLAGS"
4918 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
4919 AC_TRY_COMPILE([
4920 #include "confdefs.h"
4921 #define NO_PROTO_H 1
4922 #define NO_CONFIG_H 1
4923 #include "${srcdir-.}/smbd/quotas.c"
4924 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
4925 CPPFLAGS="$SAVE_CPPFLAGS"
4927 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
4928 AC_MSG_CHECKING(whether to use the old quota support)
4929     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
4930       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
4931         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4932         AC_MSG_RESULT(yes)
4933       else
4934         AC_MSG_RESULT(no)
4935       fi
4936     else
4937       AC_MSG_RESULT(no)
4938     fi
4941 ####################
4942 # End of quota check samba_cv_RUN_QUOTA_TESTS
4945 #################################################
4946 # check for experimental utmp accounting
4948 AC_MSG_CHECKING(whether to support utmp accounting)
4949 WITH_UTMP=yes
4950 AC_ARG_WITH(utmp,
4951 [AS_HELP_STRING([--with-utmp], [Include utmp accounting (default, if supported by OS)])],
4952 [ case "$withval" in
4953   no)
4954                 WITH_UTMP=no
4955                 ;;
4956   *)
4957                 WITH_UTMP=yes
4958                 ;;
4959   esac ],
4962 # utmp requires utmp.h
4963 # Note similar check earlier, when checking utmp details.
4965 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
4966         utmp_no_reason=", no utmp.h on $host_os"
4967         WITH_UTMP=no
4970 # Display test results
4972 if test x"$WITH_UTMP" = x"yes"; then
4973         AC_MSG_RESULT(yes)
4974         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
4975 else
4976         AC_MSG_RESULT(no$utmp_no_reason)
4980 #################################################
4981 # these tests are taken from the GNU fileutils package
4982 AC_CHECKING(how to get filesystem space usage)
4983 space=no
4985 # Test for statvfs64.
4986 if test $space = no; then
4987   # SVR4
4988   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
4989   [AC_TRY_RUN([
4990 #if defined(HAVE_UNISTD_H)
4991 #include <unistd.h>
4992 #endif
4993 #include <sys/types.h>
4994 #include <sys/statvfs.h>
4995   main ()
4996   {
4997     struct statvfs64 fsd;
4998     exit (statvfs64 (".", &fsd));
4999   }],
5000   fu_cv_sys_stat_statvfs64=yes,
5001   fu_cv_sys_stat_statvfs64=no,
5002   fu_cv_sys_stat_statvfs64=cross)])
5003   if test $fu_cv_sys_stat_statvfs64 = yes; then
5004     space=yes
5005     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
5006   fi
5009 # Perform only the link test since it seems there are no variants of the
5010 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
5011 # because that got a false positive on SCO OSR5.  Adding the declaration
5012 # of a `struct statvfs' causes this test to fail (as it should) on such
5013 # systems.  That system is reported to work fine with STAT_STATFS4 which
5014 # is what it gets when this test fails.
5015 if test $space = no; then
5016   # SVR4
5017   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
5018                  [AC_TRY_LINK([#include <sys/types.h>
5019 #include <sys/statvfs.h>],
5020                               [struct statvfs fsd; statvfs (0, &fsd);],
5021                               fu_cv_sys_stat_statvfs=yes,
5022                               fu_cv_sys_stat_statvfs=no)])
5023   if test $fu_cv_sys_stat_statvfs = yes; then
5024     space=yes
5025     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
5026   fi
5029 # smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
5030 # This is not the case on ancient Linux systems.
5032 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
5033     AC_TRY_COMPILE([#include <sys/types.h>
5034 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
5035         samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
5036 if test x"$samba_cv_fsid_int" = x"yes"; then
5037     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
5040 # fsusage.c assumes that statvfs has an f_frsize entry. Some weird
5041 # systems use f_bsize.
5042 AC_CACHE_CHECK([that statvfs.f_frsize works],samba_cv_frsize, [
5043     AC_TRY_COMPILE([#include <sys/types.h>
5044 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_frsize = 0],
5045         samba_cv_frsize=yes,samba_cv_frsize=no)])
5046 if test x"$samba_cv_frsize" = x"yes"; then
5047     AC_DEFINE(HAVE_FRSIZE, 1, [Whether statvfs.f_frsize exists])
5050 # Some systems use f_flag in struct statvfs while others use f_flags
5051 AC_CACHE_CHECK([that statvfs.statvfs_f_flag works],samba_cv_statvfs_f_flag, [
5052     AC_TRY_COMPILE([#include <sys/types.h>
5053 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_flag = 0],
5054         samba_cv_statvfs_f_flag=yes,samba_cv_statvfs_f_flag=no)])
5055 if test x"$samba_cv_statvfs_f_flag" = x"yes"; then
5056     AC_DEFINE(HAVE_STATVFS_F_FLAG, 1, [Whether statvfs.f_flag exists])
5059 AC_CACHE_CHECK([that statvfs.statvfs_f_flags works],samba_cv_statvfs_f_flags, [
5060     AC_TRY_COMPILE([#include <sys/types.h>
5061 #include <sys/statvfs.h>],[struct statvfs buf; buf.f_flags = 0],
5062         samba_cv_statvfs_f_flags=yes,samba_cv_statvfs_f_flags=no)])
5063 if test x"$samba_cv_statvfs_f_flags" = x"yes"; then
5064     AC_DEFINE(HAVE_STATVFS_F_FLAGS, 1, [Whether statvfs.f_flags exists])
5067 if test $space = no; then
5068   # DEC Alpha running OSF/1
5069   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
5070   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
5071   [AC_TRY_RUN([
5072 #include <sys/param.h>
5073 #include <sys/types.h>
5074 #include <sys/mount.h>
5075   main ()
5076   {
5077     struct statfs fsd;
5078     fsd.f_fsize = 0;
5079     exit (statfs (".", &fsd, sizeof (struct statfs)));
5080   }],
5081   fu_cv_sys_stat_statfs3_osf1=yes,
5082   fu_cv_sys_stat_statfs3_osf1=no,
5083   fu_cv_sys_stat_statfs3_osf1=no)])
5084   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
5085   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
5086     space=yes
5087     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
5088   fi
5091 if test $space = no; then
5092 # AIX
5093   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
5094 member (AIX, 4.3BSD)])
5095   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
5096   [AC_TRY_RUN([
5097 #ifdef HAVE_SYS_PARAM_H
5098 #include <sys/param.h>
5099 #endif
5100 #ifdef HAVE_SYS_MOUNT_H
5101 #include <sys/mount.h>
5102 #endif
5103 #ifdef HAVE_SYS_VFS_H
5104 #include <sys/vfs.h>
5105 #endif
5106   main ()
5107   {
5108   struct statfs fsd;
5109   fsd.f_bsize = 0;
5110   exit (statfs (".", &fsd));
5111   }],
5112   fu_cv_sys_stat_statfs2_bsize=yes,
5113   fu_cv_sys_stat_statfs2_bsize=no,
5114   fu_cv_sys_stat_statfs2_bsize=no)])
5115   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
5116   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
5117     space=yes
5118     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
5119   fi
5122 if test $space = no; then
5123 # SVR3
5124   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
5125   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
5126   [AC_TRY_RUN([#include <sys/types.h>
5127 #include <sys/statfs.h>
5128   main ()
5129   {
5130   struct statfs fsd;
5131   exit (statfs (".", &fsd, sizeof fsd, 0));
5132   }],
5133     fu_cv_sys_stat_statfs4=yes,
5134     fu_cv_sys_stat_statfs4=no,
5135     fu_cv_sys_stat_statfs4=no)])
5136   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
5137   if test $fu_cv_sys_stat_statfs4 = yes; then
5138     space=yes
5139     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
5140   fi
5143 if test $space = no; then
5144 # 4.4BSD and NetBSD
5145   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
5146 member (4.4BSD and NetBSD)])
5147   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
5148   [AC_TRY_RUN([#include <sys/types.h>
5149 #ifdef HAVE_SYS_PARAM_H
5150 #include <sys/param.h>
5151 #endif
5152 #ifdef HAVE_SYS_MOUNT_H
5153 #include <sys/mount.h>
5154 #endif
5155   main ()
5156   {
5157   struct statfs fsd;
5158   fsd.f_fsize = 0;
5159   exit (statfs (".", &fsd));
5160   }],
5161   fu_cv_sys_stat_statfs2_fsize=yes,
5162   fu_cv_sys_stat_statfs2_fsize=no,
5163   fu_cv_sys_stat_statfs2_fsize=no)])
5164   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
5165   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
5166     space=yes
5167         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
5168   fi
5171 if test $space = no; then
5172   # Ultrix
5173   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
5174   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
5175   [AC_TRY_RUN([#include <sys/types.h>
5176 #ifdef HAVE_SYS_PARAM_H
5177 #include <sys/param.h>
5178 #endif
5179 #ifdef HAVE_SYS_MOUNT_H
5180 #include <sys/mount.h>
5181 #endif
5182 #ifdef HAVE_SYS_FS_TYPES_H
5183 #include <sys/fs_types.h>
5184 #endif
5185   main ()
5186   {
5187   struct fs_data fsd;
5188   /* Ultrix's statfs returns 1 for success,
5189      0 for not mounted, -1 for failure.  */
5190   exit (statfs (".", &fsd) != 1);
5191   }],
5192   fu_cv_sys_stat_fs_data=yes,
5193   fu_cv_sys_stat_fs_data=no,
5194   fu_cv_sys_stat_fs_data=no)])
5195   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
5196   if test $fu_cv_sys_stat_fs_data = yes; then
5197     space=yes
5198     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
5199   fi
5203 # As a gating factor for large file support, in order to
5204 # use <4GB files we must have the following minimal support
5205 # available.
5206 # long long, and a 64 bit off_t or off64_t.
5207 # If we don't have all of these then disable large
5208 # file support.
5210 AC_MSG_CHECKING([if large file support can be enabled])
5211 AC_TRY_COMPILE([
5212 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
5213 #include <sys/types.h>
5214 #else
5215 __COMPILE_ERROR_
5216 #endif
5218 [int i],
5219 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
5220 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
5221         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
5223 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
5225 #################################################
5226 # check for cluster extensions
5228 CTDB_CFLAGS=""
5229 AC_SUBST(CTDB_CFLAGS)
5230 AC_ARG_WITH(ctdb,
5231 [AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])],
5232 [ case "$withval" in
5233   yes|no)
5234     AC_MSG_WARN([--with-ctdb called without argument])
5235     ;;
5236   *)
5237     CTDB_CPPFLAGS="-I$withval/include"
5238     ;;
5239   esac])
5241 SAVED_CPPFLAGS="$CPPFLAGS"
5242 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS} $CTDB_CPPFLAGS"
5243 ctdb_broken="missing or broken headers"
5245 AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
5246 #include "confdefs.h"
5247 #define NO_CONFIG_H
5248 #include "replace.h"
5249 #include "system/wait.h"
5250 #include "system/network.h"
5251 #define private #error __USED_RESERVED_WORD_private__
5252 #include <talloc.h>
5253 #include <tdb.h>
5254 #include <ctdb.h>
5257 AC_HAVE_DECL(CTDB_CONTROL_TRANS3_COMMIT,[
5258 #include "confdefs.h"
5259 #define NO_CONFIG_H
5260 #include "replace.h"
5261 #include "system/wait.h"
5262 #include "system/network.h"
5263 #include <talloc.h>
5264 #include <tdb.h>
5265 #include <ctdb.h>
5266 #include <ctdb_private.h>
5268 if test x"$ac_cv_have_CTDB_CONTROL_TRANS3_COMMIT_decl" = x"yes"; then
5269         ctdb_broken=no
5270 else
5271         ctdb_broken="ctdb transaction support missing or too old"
5274 # in ctdb 1.0.57 ctdb_control_tcp was temparary renamed to ctdb_tcp_client
5275 AC_CHECK_TYPE(struct ctdb_tcp_client,[
5276         AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support])
5277 ],,[
5278 #include "confdefs.h"
5279 #define NO_CONFIG_H
5280 #include "replace.h"
5281 #include "system/wait.h"
5282 #include "system/network.h"
5283 #include <talloc.h>
5284 #include <tdb.h>
5285 #include <ctdb.h>
5286 #include <ctdb_private.h>
5289 AC_CHECK_TYPE(struct ctdb_control_tcp,[
5290         AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP],[1],[ctdb ipv4 support])
5292         ctdb_broken="missing struct ctdb_control_tcp"
5294 #include "confdefs.h"
5295 #define NO_CONFIG_H
5296 #include "replace.h"
5297 #include "system/wait.h"
5298 #include "system/network.h"
5299 #include <talloc.h>
5300 #include <tdb.h>
5301 #include <ctdb.h>
5302 #include <ctdb_private.h>
5305 AC_CHECK_TYPE(struct ctdb_control_tcp_addr,[
5306         AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR],[1],[ctdb ipv6 support])
5307 ],,[
5308 #include "confdefs.h"
5309 #define NO_CONFIG_H
5310 #include "replace.h"
5311 #include "system/wait.h"
5312 #include "system/network.h"
5313 #include <talloc.h>
5314 #include <tdb.h>
5315 #include <ctdb.h>
5316 #include <ctdb_private.h>
5318 CPPFLAGS="$SAVED_CPPFLAGS"
5320 AC_MSG_CHECKING(cluster support)
5321 AC_ARG_WITH(cluster-support,
5322 [AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])])
5324 if test x"$with_cluster_support" = x ; then
5325         with_cluster_support="auto"
5328 if test x"$ac_cv_header_ctdb_private_h" != x"yes"; then
5329         if test "x$with_cluster_support" = "xyes"; then
5330                 AC_MSG_ERROR("ctdb_private.h is required for cluster support")
5331         fi
5332         with_cluster_support=no
5335 if test x"$ctdb_broken" != x"no"; then
5336         if test "x$with_cluster_support" = "xyes"; then
5337                 AC_MSG_ERROR(["cluster support: $ctdb_broken"])
5338         fi
5339         with_cluster_support=no
5342 if test "x$with_cluster_support" != "xno"; then
5343     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
5344     SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CTDB_CPPFLAGS}"
5345     AC_MSG_RESULT(yes)
5346 else
5347     AC_MSG_RESULT(no)
5350 #################################################
5351 # check for ACL support
5353 AC_MSG_CHECKING(whether to support ACLs)
5354 AC_ARG_WITH(acl-support,
5355 [AS_HELP_STRING([--with-acl-support], [Include ACL support (default=auto)])],
5356 [ case "$withval" in
5357         yes|no)
5358                 with_acl_support="$withval"
5359                 ;;
5360   esac ])
5362 if test x"$with_acl_support" = x ; then
5363         with_acl_support="auto"
5366 AC_MSG_RESULT($with_acl_support)
5368 if test x"$with_acl_support" = x"no"; then
5369         AC_MSG_RESULT(Disabling ACL support)
5370         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
5371 else
5372         AC_MSG_NOTICE(checking whether ACL support is available:)
5373         case "$host_os" in
5374         *sysv5*)
5375                 AC_MSG_NOTICE(Using UnixWare ACLs)
5376                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
5377                 default_static_modules="$default_static_modules vfs_solarisacl"
5378                 ;;
5379         *solaris*)
5380                 AC_MSG_NOTICE(Using solaris ACLs)
5381                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
5382                 ACL_LIBS="$ACL_LIBS -lsec"
5383                 default_static_modules="$default_static_modules vfs_solarisacl"
5384                 ;;
5385         *hpux*)
5386                 AC_MSG_NOTICE(Using HPUX ACLs)
5387                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
5388                 default_static_modules="$default_static_modules vfs_hpuxacl"
5389                 ;;
5390         *irix*)
5391                 AC_MSG_NOTICE(Using IRIX ACLs)
5392                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
5393                 default_static_modules="$default_static_modules vfs_irixacl"
5394                 ;;
5395         *aix*)
5396                 AC_MSG_NOTICE(Using AIX ACLs)
5397                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
5398                 default_static_modules="$default_static_modules vfs_aixacl"
5399                 ;;
5400         *osf*)
5401                 AC_MSG_NOTICE(Using Tru64 ACLs)
5402                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
5403                 ACL_LIBS="$ACL_LIBS -lpacl"
5404                 default_static_modules="$default_static_modules vfs_tru64acl"
5405                 ;;
5406         *darwin*)
5407                 AC_MSG_NOTICE(ACLs on Darwin currently not supported)
5408                 AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5409                 ;;
5410         *)
5411                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
5412                 case "$host_os" in
5413                 *linux*)
5414                         AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
5415                         ;;
5416                 esac
5417                 AC_CACHE_CHECK([for POSIX ACL support],samba_cv_HAVE_POSIX_ACLS,[
5418                         acl_LIBS=$LIBS
5419                         LIBS="$LIBS $ACL_LIBS"
5420                         AC_TRY_LINK([
5421                                 #include <sys/types.h>
5422                                 #include <sys/acl.h>
5423                         ],[
5424                                 acl_t acl;
5425                                 int entry_id;
5426                                 acl_entry_t *entry_p;
5427                                 return acl_get_entry(acl, entry_id, entry_p);
5428                         ],
5429                         [samba_cv_HAVE_POSIX_ACLS=yes],
5430                         [samba_cv_HAVE_POSIX_ACLS=no])
5431                         LIBS=$acl_LIBS
5432                 ])
5433                 if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
5434                         AC_MSG_NOTICE(Using posix ACLs)
5435                         AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
5436                         AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
5437                                 acl_LIBS=$LIBS
5438                                 LIBS="$LIBS $ACL_LIBS"
5439                                 AC_TRY_LINK([
5440                                         #include <sys/types.h>
5441                                         #include <sys/acl.h>
5442                                 ],[
5443                                         acl_permset_t permset_d;
5444                                         acl_perm_t perm;
5445                                         return acl_get_perm_np(permset_d, perm);
5446                                 ],
5447                                 [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
5448                                 [samba_cv_HAVE_ACL_GET_PERM_NP=no])
5449                                 LIBS=$acl_LIBS
5450                         ])
5451                         if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
5452                                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
5453                         fi
5454                         default_static_modules="$default_static_modules vfs_posixacl"
5455                 else
5456                         AC_MSG_NOTICE(ACL support is not avaliable)
5457                         AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
5458                 fi
5459                 ;;
5460         esac
5461 fi # with_acl_support
5465 #################################################
5466 # check for AIO support
5468 AC_MSG_CHECKING(whether to support asynchronous io)
5469 AC_ARG_WITH(aio-support,
5470 [AS_HELP_STRING([--with-aio-support], [Include asynchronous io support (default=no)])],
5471 [ case "$withval" in
5472   yes)
5474         AC_MSG_RESULT(yes)
5475         case "$host_os" in
5476         *)
5477                 AIO_LIBS=$LIBS
5478                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
5479                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
5480                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
5481                 aio_LIBS=$LIBS
5482                 LIBS=$AIO_LIBS
5483                 AC_TRY_LINK([#include <sys/types.h>
5484 #include <aio.h>],
5485 [ struct aiocb a; return aio_read(&a);],
5486 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
5487                 LIBS=$aio_LIBS])
5488                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
5489                 aio_LIBS=$LIBS
5490                 LIBS=$AIO_LIBS
5491                 AC_TRY_LINK([#include <sys/types.h>
5492 #include <aio.h>],
5493 [ struct aiocb64 a; return aio_read64(&a);],
5494 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
5495                 LIBS=$aio_LIBS])
5496                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5497                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
5498                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5499                         LIBS=$AIO_LIBS
5500                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
5501                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
5502                         LIBS=$AIO_LIBS
5503                 fi
5505                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5506                         AC_MSG_CHECKING(for aio_read)
5507                         AC_LINK_IFELSE([#include <aio.h>
5508 int main() { struct aiocb a; return aio_read(&a); }],
5509 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
5510 [AC_MSG_RESULT(no)])
5512                         AC_MSG_CHECKING(for aio_write)
5513                         AC_LINK_IFELSE([#include <aio.h>
5514 int main() { struct aiocb a; return aio_write(&a); }],
5515 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
5516 [AC_MSG_RESULT(no)])
5518                         AC_MSG_CHECKING(for aio_fsync)
5519                         AC_LINK_IFELSE([#include <aio.h>
5520 int main() { struct aiocb a; return aio_fsync(1, &a); }],
5521 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
5522 [AC_MSG_RESULT(no)])
5524                         AC_MSG_CHECKING(for aio_return)
5525                         AC_LINK_IFELSE([#include <aio.h>
5526 int main() { struct aiocb a; return aio_return(&a); }],
5527 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
5528 [AC_MSG_RESULT(no)])
5530                         AC_MSG_CHECKING(for aio_error)
5531                         AC_LINK_IFELSE([#include <aio.h>
5532 int main() { struct aiocb a; return aio_error(&a); }],
5533 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
5534 [AC_MSG_RESULT(no)])
5536                         AC_MSG_CHECKING(for aio_cancel)
5537                         AC_LINK_IFELSE([#include <aio.h>
5538 int main() { struct aiocb a; return aio_cancel(1, &a); }],
5539 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
5540 [AC_MSG_RESULT(no)])
5542                         AC_MSG_CHECKING(for aio_suspend)
5543                         AC_LINK_IFELSE([#include <aio.h>
5544 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
5545 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
5546 [AC_MSG_RESULT(no)])
5547                 fi
5549                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
5550                         AC_MSG_CHECKING(for aio_read64)
5551                         AC_LINK_IFELSE([#include <aio.h>
5552 int main() { struct aiocb a; return aio_read64(&a); }],
5553 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
5554 [AC_MSG_RESULT(no)])
5556                         AC_MSG_CHECKING(for aio_write64)
5557                         AC_LINK_IFELSE([#include <aio.h>
5558 int main() { struct aiocb a; return aio_write64(&a); }],
5559 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
5560 [AC_MSG_RESULT(no)])
5562                         AC_MSG_CHECKING(for aio_fsync64)
5563                         AC_LINK_IFELSE([#include <aio.h>
5564 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
5565 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
5566 [AC_MSG_RESULT(no)])
5568                         AC_MSG_CHECKING(for aio_return64)
5569                         AC_LINK_IFELSE([#include <aio.h>
5570 int main() { struct aiocb a; return aio_return64(&a); }],
5571 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
5572 [AC_MSG_RESULT(no)])
5574                         AC_MSG_CHECKING(for aio_error64)
5575                         AC_LINK_IFELSE([#include <aio.h>
5576 int main() { struct aiocb a; return aio_error64(&a); }],
5577 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
5578 [AC_MSG_RESULT(no)])
5580                         AC_MSG_CHECKING(for aio_cancel64)
5581                         AC_LINK_IFELSE([#include <aio.h>
5582 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
5583 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
5584 [AC_MSG_RESULT(no)])
5586                         AC_MSG_CHECKING(for aio_suspend64)
5587                         AC_LINK_IFELSE([#include <aio.h>
5588 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
5589 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
5590 [AC_MSG_RESULT(no)])
5591                 fi
5592             ;;
5593         esac
5594         ;;
5595   *)
5596     AC_MSG_RESULT(no)
5597     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
5598     ;;
5599   esac ],
5600   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
5601   AC_MSG_RESULT(no)
5604 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
5605         if test x"$samba_cv_msghdr_msg_control" = x"yes" -o \
5606                 x"$samba_cv_msghdr_msg_acctright" = x"yes"; then
5607                 default_shared_modules="$default_shared_modules vfs_aio_fork"
5608         fi
5611 #################################################
5612 # check for sendfile support
5614 with_sendfile_support=yes
5615 AC_MSG_CHECKING(whether to check to support sendfile)
5616 AC_ARG_WITH(sendfile-support,
5617 [AS_HELP_STRING([--with-sendfile-support], [Check for sendfile support (default=yes)])],
5618 [ case "$withval" in
5619   yes)
5621         AC_MSG_RESULT(yes);
5623         case "$host_os" in
5624         *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
5625                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5626                 AC_TRY_LINK([#include <sys/sendfile.h>],
5628 int tofd, fromfd;
5629 off64_t offset;
5630 size_t total;
5631 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
5633 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5635                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
5636                 AC_TRY_LINK([#include <sys/sendfile.h>],
5638 int tofd, fromfd;
5639 off_t offset;
5640 size_t total;
5641 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5643 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5645 # Try and cope with broken Linux sendfile....
5646                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
5647                 AC_TRY_LINK([\
5648 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5649 #undef _FILE_OFFSET_BITS
5650 #endif
5651 #include <sys/sendfile.h>],
5653 int tofd, fromfd;
5654 off_t offset;
5655 size_t total;
5656 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5658 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5660         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5661                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5662                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5663                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5664         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5665                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5666                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5667                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5668         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5669                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5670                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5671         else
5672                 AC_MSG_RESULT(no);
5673         fi
5675         ;;
5676         *freebsd* | *dragonfly* )
5677                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5678                 AC_TRY_LINK([\
5679 #include <sys/types.h>
5680 #include <unistd.h>
5681 #include <sys/socket.h>
5682 #include <sys/uio.h>],
5684         int fromfd, tofd, ret, total=0;
5685         off_t offset, nwritten;
5686         struct sf_hdtr hdr;
5687         struct iovec hdtrl;
5688         hdr.headers = &hdtrl;
5689         hdr.hdr_cnt = 1;
5690         hdr.trailers = NULL;
5691         hdr.trl_cnt = 0;
5692         hdtrl.iov_base = NULL;
5693         hdtrl.iov_len = 0;
5694         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
5696 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5698         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5699                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
5700                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
5701                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5702         else
5703                 AC_MSG_RESULT(no);
5704         fi
5705         ;;
5707         *hpux*)
5708                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5709                 AC_TRY_LINK([\
5710 #include <sys/socket.h>
5711 #include <sys/uio.h>],
5713         int fromfd, tofd;
5714         size_t total=0;
5715         struct iovec hdtrl[2];
5716         ssize_t nwritten;
5717         off64_t offset;
5719         hdtrl[0].iov_base = 0;
5720         hdtrl[0].iov_len = 0;
5722         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
5724 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5725         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5726                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
5727                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5728                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5729         else
5730                 AC_MSG_RESULT(no);
5731         fi
5733                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
5734                 AC_TRY_LINK([\
5735 #include <sys/socket.h>
5736 #include <sys/uio.h>],
5738         int fromfd, tofd;
5739         size_t total=0;
5740         struct iovec hdtrl[2];
5741         ssize_t nwritten;
5742         off_t offset;
5744         hdtrl[0].iov_base = 0;
5745         hdtrl[0].iov_len = 0;
5747         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
5749 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5750         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5751                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5752                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5753                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5754         else
5755                 AC_MSG_RESULT(no);
5756         fi
5757         ;;
5759         *solaris*)
5760                 AC_CHECK_LIB(sendfile,sendfilev)
5761                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
5762                 AC_TRY_LINK([\
5763 #include <sys/sendfile.h>],
5765         int sfvcnt;
5766         size_t xferred;
5767         struct sendfilevec vec[2];
5768         ssize_t nwritten;
5769         int tofd;
5771         sfvcnt = 2;
5773         vec[0].sfv_fd = SFV_FD_SELF;
5774         vec[0].sfv_flag = 0;
5775         vec[0].sfv_off = 0;
5776         vec[0].sfv_len = 0;
5778         vec[1].sfv_fd = 0;
5779         vec[1].sfv_flag = 0;
5780         vec[1].sfv_off = 0;
5781         vec[1].sfv_len = 0;
5782         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
5784 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
5786         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
5787                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
5788                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
5789                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5790         else
5791                 AC_MSG_RESULT(no);
5792         fi
5794                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
5795                 AC_TRY_LINK([\
5796 #include <sys/sendfile.h>],
5798         int sfvcnt;
5799         size_t xferred;
5800         struct sendfilevec vec[2];
5801         ssize_t nwritten;
5802         int tofd;
5804         sfvcnt = 2;
5806         vec[0].sfv_fd = SFV_FD_SELF;
5807         vec[0].sfv_flag = 0;
5808         vec[0].sfv_off = 0;
5809         vec[0].sfv_len = 0;
5811         vec[1].sfv_fd = 0;
5812         vec[1].sfv_flag = 0;
5813         vec[1].sfv_off = 0;
5814         vec[1].sfv_len = 0;
5815         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
5817 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
5819         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
5820                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
5821                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
5822                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5823         else
5824                 AC_MSG_RESULT(no);
5825         fi
5826         ;;
5827         *aix*)
5828                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
5829                 AC_TRY_LINK([\
5830 #include <sys/socket.h>],
5832         int fromfd, tofd;
5833         size_t total=0;
5834         struct sf_parms hdtrl;
5835         ssize_t nwritten;
5836         off64_t offset;
5838         hdtrl.header_data = 0;
5839         hdtrl.header_length = 0;
5840         hdtrl.file_descriptor = fromfd;
5841         hdtrl.file_offset = 0;
5842         hdtrl.file_bytes = 0;
5843         hdtrl.trailer_data = 0;
5844         hdtrl.trailer_length = 0;
5846         nwritten = send_file(&tofd, &hdtrl, 0);
5848 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5849         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5850                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5851                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
5852                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5853         else
5854                 AC_MSG_RESULT(no);
5855         fi
5856         ;;
5857         *)
5858         ;;
5859         esac
5860         ;;
5861   *)
5862     AC_MSG_RESULT(no)
5863     ;;
5864   esac ],
5865   AC_MSG_RESULT(yes)
5868 ############################################
5869 # See if we have the Linux readahead syscall.
5871 AC_CACHE_CHECK([for Linux readahead],
5872                 samba_cv_HAVE_LINUX_READAHEAD,[
5873     AC_TRY_LINK([
5874 #if defined(HAVE_UNISTD_H)
5875 #include <unistd.h>
5876 #endif
5877 #include <fcntl.h>],
5878     [ssize_t err = readahead(0,0,0x80000);],
5879     samba_cv_HAVE_LINUX_READAHEAD=yes,
5880     samba_cv_HAVE_LINUX_READAHEAD=no)])
5882 if test x"$samba_cv_HAVE_LINUX_READAHEAD" = x"yes"; then
5883   AC_DEFINE(HAVE_LINUX_READAHEAD,1,
5884              [Whether Linux readahead is available])
5887 AC_HAVE_DECL(readahead, [#include <fcntl.h>])
5889 ############################################
5890 # See if we have the posix_fadvise syscall.
5892 AC_CACHE_CHECK([for posix_fadvise],
5893                 samba_cv_HAVE_POSIX_FADVISE,[
5894     AC_TRY_LINK([
5895 #if defined(HAVE_UNISTD_H)
5896 #include <unistd.h>
5897 #endif
5898 #include <fcntl.h>],
5899     [ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);],
5900     samba_cv_HAVE_POSIX_FADVISE=yes,
5901     samba_cv_HAVE_POSIX_FADVISE=no)])
5903 if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
5904   AC_DEFINE(HAVE_POSIX_FADVISE,1,
5905              [Whether posix_fadvise is available])
5908 ############################################
5909 # See if we have the Linux splice syscall.
5911 case "$host_os" in
5912 *linux*)
5913 AC_CACHE_CHECK([for Linux splice],
5914                 samba_cv_HAVE_LINUX_SPLICE,[
5915     AC_TRY_LINK([
5916 #if defined(HAVE_UNISTD_H)
5917 #include <unistd.h>
5918 #endif
5919 #include <fcntl.h>],
5920     [long ret = splice(0,0,1,0,400,0);],
5921     samba_cv_HAVE_LINUX_SPLICE=yes,
5922     samba_cv_HAVE_LINUX_SPLICE=no)])
5925 samba_cv_HAVE_LINUX_SPLICE=no
5927 esac
5929 if test x"$samba_cv_HAVE_LINUX_SPLICE" = x"yes"; then
5930   AC_DEFINE(HAVE_LINUX_SPLICE,1,
5931              [Whether Linux splice is available])
5934 AC_HAVE_DECL(splice, [#include <fcntl.h>])
5936 ############################################
5937 # See if we have the a broken readlink syscall.
5939 AC_CACHE_CHECK([for a broken readlink syscall],samba_cv_HAVE_BROKEN_READLINK,[
5940 AC_TRY_RUN([#include "${srcdir-.}/../tests/readlink.c"],
5941         samba_cv_HAVE_BROKEN_READLINK=no,samba_cv_HAVE_BROKEN_READLINK=yes,samba_cv_HAVE_BROKEN_READLINK=cross)
5943 if test x"$samba_cv_HAVE_BROKEN_READLINK" = x"yes"; then
5944         AC_DEFINE(HAVE_BROKEN_READLINK,1,[Whether the readlink syscall is broken])
5947 #################################################
5948 # Check whether winbind is supported on this platform.  If so we need to
5949 # build and install client programs, sbin programs and shared libraries
5951 AC_MSG_CHECKING(whether to build winbind)
5953 # Initially, the value of $host_os decides whether winbind is supported
5955 HAVE_WINBIND=yes
5956 HAVE_WBCLIENT=no
5958 # Define external wbclient library to link against.  This disables winbind.
5959 # We define this here so --with-winbind can override it.
5960 AC_ARG_WITH(wbclient,
5961 [AS_HELP_STRING([--with-wbclient], [Use external wbclient (optional)])],
5963   case "$withval" in
5964         no)
5965                 HAVE_WBCLIENT=no
5966                 ;;
5967         yes)
5968                 HAVE_WBCLIENT=yes
5969                 HAVE_WINBIND=no
5970                 ;;
5971         *)
5972                 HAVE_WBCLIENT=yes
5973                 HAVE_WINBIND=no
5974                 WBCLIENT_INCLUDES="-I$withval/include"
5975                 WBCLIENT_LDFLAGS="-L$withval/lib"
5976                 ;;
5977   esac ],
5980 AC_SUBST(WBCLIENT_INCLUDES)
5981 AC_SUBST(WBCLIENT_LDFLAGS)
5982 AC_SUBST(WBCLIENT_LIBS)
5985 # Define the winbind shared library name and any specific linker flags
5986 # it needs to be built with.
5988 WINBIND_NSS="../nsswitch/libnss_winbind.$SHLIBEXT"
5989 WINBIND_WINS_NSS="../nsswitch/libnss_wins.$SHLIBEXT"
5990 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
5991 NSSSONAMEVERSIONSUFFIX=""
5993 case "$host_os" in
5994         *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
5995                 NSSSONAMEVERSIONSUFFIX=".2"
5996                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_linux.o"
5997                 ;;
5998         *freebsd[[5-9]]*)
5999                 # FreeBSD winbind client is implemented as a wrapper around
6000                 # the Linux version.
6001                 NSSSONAMEVERSIONSUFFIX=".1"
6002                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_freebsd.o \
6003                     ../nsswitch/winbind_nss_linux.o"
6004                 WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
6005                 WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
6006                 ;;
6008         *netbsd*[[3-9]]*)
6009                 # NetBSD winbind client is implemented as a wrapper
6010                 # around the Linux version. It needs getpwent_r() to
6011                 # indicate libc's use of the correct nsdispatch API.
6012                 #
6013                 if test x"$ac_cv_func_getpwent_r" = x"yes"; then
6014                         WINBIND_NSS_EXTRA_OBJS="\
6015                             ../nsswitch/winbind_nss_netbsd.o \
6016                             ../nsswitch/winbind_nss_linux.o"
6017                         WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
6018                         WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
6019                 else
6020                         HAVE_WINBIND=no
6021                         winbind_no_reason=", getpwent_r is missing on $host_os so winbind is unsupported"
6022                 fi
6023                 ;;
6024         *irix*)
6025                 # IRIX has differently named shared libraries
6026                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_irix.o"
6027                 WINBIND_NSS="../nsswitch/libns_winbind.$SHLIBEXT"
6028                 WINBIND_WINS_NSS="../nsswitch/libns_wins.$SHLIBEXT"
6029                 ;;
6030         *solaris*)
6031                 # Solaris winbind client is implemented as a wrapper around
6032                 # the Linux version.
6033                 NSSSONAMEVERSIONSUFFIX=".1"
6034                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o \
6035                     ../nsswitch/winbind_nss_linux.o"
6036                 ;;
6037         *hpux11*)
6038                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o"
6039                 ;;
6040         *aix*)
6041                 # AIX has even differently named shared libraries.  No
6042                 # WINS support has been implemented yet.
6043                 WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_aix.o"
6044                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
6045                 WINBIND_NSS="../nsswitch/WINBIND"
6046                 WINBIND_WINS_NSS=""
6047                 ;;
6048         *)
6049                 HAVE_WINBIND=no
6050                 winbind_no_reason=", unsupported on $host_os"
6051                 ;;
6052 esac
6054 # Check the setting of --with-winbind
6056 AC_ARG_WITH(winbind,
6057 [AS_HELP_STRING([--with-winbind], [Build winbind (default, if supported by OS)])],
6059   case "$withval" in
6060         yes)
6061                 HAVE_WINBIND=yes
6062                 HAVE_WBCLIENT=no
6063                 ;;
6064         no)
6065                 HAVE_WINBIND=no
6066                 winbind_reason=""
6067                 ;;
6068   esac ],
6071 # We need unix domain sockets for winbind
6073 if test x"$HAVE_WINBIND" = x"yes"; then
6074         if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"no"; then
6075                 winbind_no_reason=", no unix domain socket support on $host_os"
6076                 HAVE_WINBIND=no
6077         fi
6080 # Display test results
6082 if test x"$HAVE_WINBIND" = x"no"; then
6083         WINBIND_NSS=""
6084         WINBIND_WINS_NSS=""
6086 if test x"$HAVE_WBCLIENT" = x"yes"; then
6087         AC_CHECK_LIB(wbclient, wbcInterfaceDetails,
6088                      [LIBWBCLIENT_LIBS="-lwbclient"], AC_MSG_ERROR([Could not find wbclient]), [$WBCLIENT_LDFLAGS])
6089         LIBWBCLIENT_LIBS="$LIBWBCLIENT_LIBS $WBCLIENT_LDFLAGS"
6090         AC_MSG_RESULT(yes)
6091         AC_DEFINE(WITH_WINBIND,1,[Whether to link to wbclient])
6092         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
6093 else
6094         if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
6095                 BUILD_LIBWBCLIENT_SHARED=no
6096         else
6097                 BUILD_LIBWBCLIENT_SHARED=yes
6098         fi
6100         LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
6101         LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
6102         LIBWBCLIENT_SOVER=0
6103         if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
6104                 NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
6105                 ## Only worry about libwbclient if we have shared
6106                 # library support
6107                 LIBWBCLIENT_SHARED=$LIBWBCLIENT_SHARED_TARGET
6108                 LIBWBCLIENT=libwbclient
6109                 INSTALL_LIBWBCLIENT=installlibwbclient
6110                 UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
6111                 LIBWBCLIENT_LIBS="-lwbclient"
6112         else
6113                 LIBWBCLIENT_STATIC=$LIBWBCLIENT_STATIC_TARGET
6114                 LIBWBCLIENT_LIBS=$LIBWBCLIENT_STATIC_TARGET
6115         fi
6118 if test x"$HAVE_WINBIND" = x"yes"; then
6119         AC_MSG_RESULT(yes)
6120         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
6122         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
6123         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
6124         if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
6125                 PAM_MODULES="$PAM_MODULES pam_winbind"
6126                 INSTALL_PAM_MODULES="installpammodules"
6127                 UNINSTALL_PAM_MODULES="uninstallpammodules"
6128         fi
6129 else
6130         AC_MSG_RESULT(no$winbind_no_reason)
6133 AC_SUBST(WINBIND_NSS)
6134 AC_SUBST(WINBIND_WINS_NSS)
6135 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
6136 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
6137 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
6139 AC_SUBST(WINBIND_KRB5_LOCATOR)
6141 # Solaris 10 does have new member in nss_XbyY_key
6142 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
6143                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
6144                 [#include <nss_dbdefs.h>])
6146 # Solaris has some extra fields in struct passwd that need to be
6147 # initialised otherwise nscd crashes.
6149 AC_CHECK_MEMBER(struct passwd.pw_comment,
6150                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
6151                 [#include <pwd.h>])
6153 AC_CHECK_MEMBER(struct passwd.pw_age,
6154                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
6155                 [#include <pwd.h>])
6157 # AIX 4.3.x and 5.1 do not have as many members in
6158 # struct secmethod_table as AIX 5.2
6159 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
6160        [#include <usersec.h>])
6161 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
6162        [#include <usersec.h>])
6164 AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
6165 AC_TRY_COMPILE([#include <sys/types.h>
6166 #include <sys/socket.h>],
6167 [struct ucred cred;
6168  socklen_t cred_len;
6169  int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
6171 samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
6172 if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
6173     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
6177 #################################################
6178 # Check to see if we should use the included popt
6180 AC_ARG_WITH(included-popt,
6181 [AS_HELP_STRING([--with-included-popt], [use bundled popt library, not from system])],
6183   case "$withval" in
6184         yes)
6185                 INCLUDED_POPT=yes
6186                 ;;
6187         no)
6188                 INCLUDED_POPT=no
6189                 ;;
6190   esac ],
6192 if test x"$INCLUDED_POPT" != x"yes"; then
6193     AC_CHECK_LIB(popt, poptGetContext,
6194                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
6197 AC_MSG_CHECKING(whether to use included popt)
6198 if test x"$INCLUDED_POPT" = x"yes"; then
6199     AC_MSG_RESULT(yes)
6200     BUILD_POPT='$(POPT_OBJ)'
6201     POPTLIBS='$(POPT_OBJ)'
6202     FLAGS1="-I\$(srcdir)/../lib/popt"
6203 else
6204     AC_MSG_RESULT(no)
6205         BUILD_POPT=""
6206     POPTLIBS="-lpopt"
6208 AC_SUBST(BUILD_POPT)
6209 AC_SUBST(POPTLIBS)
6210 AC_SUBST(FLAGS1)
6212 #################################################
6213 # Check if user wants DNS service discovery support
6215 AC_ARG_ENABLE(dnssd,
6216 [AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=no)])])
6218 AC_SUBST(DNSSD_LIBS)
6219 if test x"$enable_dnssd" = x"yes"; then
6220     have_dnssd_support=yes
6222     AC_CHECK_HEADERS(dns_sd.h)
6223     if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
6224         have_dnssd_support=no
6225     fi
6227     # On Darwin the DNSSD API is in libc, but on other platforms it's
6228     # probably in -ldns_sd
6229     AC_CHECK_FUNCS(DNSServiceRegister)
6230     AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
6231     if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
6232             x"$ac_cv_lib_ext_dns_sd_DNSServiceRegister" != x"yes"; then
6233         have_dnssd_support=no
6234     fi
6236     if test x"$have_dnssd_support" = x"yes"; then
6237         AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
6238                 [Whether to enable DNS service discovery support])
6239     else
6240         if test x"$enable_dnssd" = x"yes"; then
6241             AC_MSG_ERROR(DNS service discovery support not available)
6242         fi
6243     fi
6247 #################################################
6248 # Check if user wants avahi support
6250 AC_ARG_ENABLE(avahi,
6251 [AS_HELP_STRING([--enable-avahi], [Enable Avahi support (default=auto)])])
6253 if test x"$enable_avahi" != x"no"; then
6254     have_avahi_support=yes
6256     AC_CHECK_HEADERS(avahi-common/watch.h)
6257     if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
6258         have_avahi_support=no
6259     fi
6261     AC_CHECK_HEADERS(avahi-client/client.h)
6262     if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
6263         have_avahi_support=no
6264     fi
6266     save_LIBS="$LIBS"
6267     AC_CHECK_LIB(avahi-client, avahi_client_new,[have_avahi_client_new=yes])
6268     AC_CHECK_LIB(avahi-common, avahi_strerror,[have_avahi_strerror=yes])
6269     LIBS="$save_LIBS"
6271     if test x"$have_avahi_client_new" != x"yes" -o \
6272        x"$have_avahi_strerror" != x"yes" ; then
6273         have_avahi_support=no
6274     fi
6276     if test x"$have_avahi_support" = x"yes"; then
6277         AC_SUBST(AVAHI_LIBS, "-lavahi-client -lavahi-common")
6278         AC_DEFINE(WITH_AVAHI_SUPPORT, 1,
6279                 [Whether to enable avahi support])
6280         AC_SUBST(AVAHI_OBJ, "lib/avahi.o smbd/avahi_register.o")
6281     else
6282         if test x"$enable_avahi" = x"yes"; then
6283             AC_MSG_ERROR(avahi support not available)
6284         fi
6285     fi
6289 #################################################
6290 # Set pthread stuff
6292 PTHREAD_CFLAGS=error
6293 PTHREAD_LDFLAGS=error
6295 # If it's error, then the user didn't 
6296 # define it.
6297 if test "x$PTHREAD_LDFLAGS" = xerror; then
6298   AC_CHECK_LIB(pthread, pthread_attr_init, [
6299              PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
6300              PTHREAD_LDFLAGS="-lpthread" ])
6303 if test "x$PTHREAD_LDFLAGS" = xerror; then
6304   AC_CHECK_LIB(pthreads, pthread_attr_init, [
6305              PTHREAD_CFLAGS="-D_THREAD_SAFE"
6306              PTHREAD_LDFLAGS="-lpthreads" ])
6309 if test "x$PTHREAD_LDFLAGS" = xerror; then
6310    AC_CHECK_LIB(c_r, pthread_attr_init, [
6311                 PTHREAD_CFLAGS="-D_THREAD_SAFE -pthread"
6312                 PTHREAD_LDFLAGS="-pthread" ])
6315 if test "x$PTHREAD_LDFLAGS" = xerror; then
6316    AC_CHECK_FUNC(pthread_attr_init, [
6317                  PTHREAD_CFLAGS="-D_REENTRANT"
6318                  PTHREAD_LDFLAGS="-lpthread" ])
6321 # especially for HP-UX, where the AC_CHECK_FUNC macro fails to test for
6322 # pthread_attr_init. On pthread_mutex_lock it works there...
6323 if test "x$PTHREAD_LDFLAGS" = xerror; then
6324    AC_CHECK_LIB(pthread, pthread_mutex_lock, [
6325                 PTHREAD_CFLAGS="-D_REENTRANT"
6326                 PTHREAD_LDFLAGS="-lpthread" ])
6329 AC_SUBST(PTHREAD_CFLAGS)
6330 AC_SUBST(PTHREAD_LDFLAGS)
6332 samba_cv_HAVE_PTHREAD=no
6333 if test x"$PTHREAD_CFLAGS" != xerror -a x"$PTHREAD_LDFLAGS" != xerror; then
6334         samba_cv_HAVE_PTHREAD=yes
6335         # now check for pthread.h with pthread-correct CFLAGS and LDFLAGS:
6336         ac_save_CFLAGS=$CFLAGS
6337         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
6338         ac_save_LDFLAGS=$LDFLAGS
6339         LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
6340         AC_CHECK_HEADERS(pthread.h)
6341         CFLAGS=$ac_save_CFLAGS
6342         LDFLAGS=$ac_save_LDFLAGS
6343         AC_DEFINE(HAVE_PTHREAD, 1, [Do we have pthreads around?])
6346 #################################################
6347 # Check if user wants pthreadpool support
6349 AC_ARG_ENABLE(pthreadpool,
6350 [AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=no)])])
6352 if test x"$enable_pthreadpool" = xyes -a x"$samba_cv_HAVE_PTHREAD" != x"yes"; then
6353         AC_MSG_ERROR([pthreadpool support cannot be enabled when pthread support was not found])
6356 if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
6357     LIBS="$LIBS $PTHREAD_LDFLAGS"
6358     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
6359     AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
6360     AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
6363 #################################################
6364 # Check to see if we should use the included iniparser
6366 AC_ARG_WITH(included-iniparser,
6367 [AS_HELP_STRING([--with-included-iniparser], [use bundled iniparser library, not from system])],
6369   case "$withval" in
6370         yes)
6371                 INCLUDED_INIPARSER=yes
6372                 ;;
6373         no)
6374                 INCLUDED_INIPARSER=no
6375                 ;;
6376   esac ],
6378 if test x"$INCLUDED_INIPARSER" != x"yes"; then
6379     AC_CHECK_LIB(iniparser, iniparser_load,
6380                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
6383 AC_MSG_CHECKING(whether to use included iniparser)
6384 if test x"$INCLUDED_INIPARSER" = x"yes"; then
6385     AC_MSG_RESULT(yes)
6386     BUILD_INIPARSER='$(INIPARSER_OBJ)'
6387         INIPARSERLIBS=""
6388     FLAGS1="$FLAGS1 -I\$(srcdir)/../lib/iniparser/src"
6389 else
6390     AC_MSG_RESULT(no)
6391         BUILD_INIPARSER=""
6392     INIPARSERLIBS="-liniparser"
6394 AC_SUBST(BUILD_INIPARSER)
6395 AC_SUBST(INIPARSERLIBS)
6396 AC_SUBST(FLAGS1)
6400 # Checks for the vfs_fileid module
6401 # Start
6402 AC_CHECK_FUNC(getmntent)
6404 AC_CHECK_HEADERS(sys/statfs.h)
6406 AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
6407 AC_CACHE_VAL(vfsfileid_cv_statfs,[
6408              AC_TRY_RUN([
6409                 #include <sys/types.h>
6410                 #include <sys/statfs.h>
6411                 int main(void)
6412                 {
6413                         struct statfs fsd;
6414                         fsid_t fsid = fsd.f_fsid;
6415                         return statfs (".", &fsd);
6416                 }],
6417                 vfsfileid_cv_statfs=yes,
6418                 vfsfileid_cv_statfs=no,
6419                 vfsfileid_cv_statfs=cross)
6421 AC_MSG_RESULT($vfsfileid_cv_statfs)
6423 if test x"$ac_cv_func_getmntent" = x"yes" -a \
6424         x"$vfsfileid_cv_statfs" = x"yes"; then
6425         default_shared_modules="$default_shared_modules vfs_fileid"
6427 # End
6428 # Checks for the vfs_fileid module
6431 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
6433         eval MODULE_DEFAULT_$i=STATIC
6434 done
6436 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
6438         dnl Fall back to static if we cannot build shared libraries
6439         eval MODULE_DEFAULT_$i=STATIC
6441         if test $BLDSHARED = true; then
6442                 eval MODULE_DEFAULT_$i=SHARED
6443         fi
6444 done
6446 dnl Always build these modules static
6447 MODULE_rpc_spoolss=STATIC
6448 MODULE_rpc_srvsvc=STATIC
6449 MODULE_idmap_tdb=STATIC
6450 MODULE_idmap_passdb=STATIC
6451 MODULE_idmap_nss=STATIC
6453 MODULE_nss_info_template=STATIC
6455 AC_ARG_WITH(static-modules,
6456 [AS_HELP_STRING([--with-static-modules=MODULES], [Comma-separated list of names of modules to statically link in])],
6457 [ if test $withval; then
6458         for i in `echo $withval | sed -e 's/,/ /g'`
6459         do
6460                 eval MODULE_$i=STATIC
6461         done
6462 fi ])
6464 AC_ARG_WITH(shared-modules,
6465 [AS_HELP_STRING([--with-shared-modules=MODULES], [Comma-separated list of names of modules to build shared])],
6466 [ if test $withval; then
6467         for i in `echo $withval | sed -e 's/,/ /g'`
6468         do
6469                         eval MODULE_$i=SHARED
6470         done
6471 fi ])
6473 if test x"$MODULE_DEFAULT_vfs_notify_fam" = xSTATIC -o \
6474                 x"$MODULE_vfs_notify_fam" = xSTATIC ; then
6475         SMBD_FAM_LIBS="$SMB_FAM_LIBS"
6476         AC_SUBST(SMBD_FAM_LIBS)
6479 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB,
6480                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
6481 SMB_MODULE(pdb_ads, passdb/pdb_ads.o \$(TLDAP_OBJ), "bin/ads.$SHLIBEXT", PDB)
6482 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
6483 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
6484 SMB_MODULE(pdb_wbc_sam, passdb/pdb_wbc_sam.o, "bin/wbc_sam.$SHLIBEXT", PDB)
6485 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
6488 SMB_MODULE(rpc_lsarpc, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
6489 SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
6490 SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
6491 SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC)
6492 SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
6493 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
6494 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
6495 SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
6496 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
6497 SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc.$SHLIBEXT", RPC)
6498 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
6499 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
6500 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
6501 SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
6502 SMB_SUBSYSTEM(RPC,smbd/process.o)
6504 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
6505 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
6506 SMB_MODULE(idmap_tdb2, winbindd/idmap_tdb2.o, "bin/tdb2.$SHLIBEXT", IDMAP)
6507 SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
6508 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
6509 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
6510 SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
6511 SMB_MODULE(idmap_hash, \$(IDMAP_HASH_OBJ), "bin/hash.$SHLIBEXT", IDMAP)
6512 SMB_MODULE(idmap_adex, \$(IDMAP_ADEX_OBJ), "bin/adex.$SHLIBEXT", IDMAP)
6513 SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
6515 SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
6516 SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
6518 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
6519 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
6520 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
6521 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
6522 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
6524 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
6525 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
6526 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
6527 SMB_MODULE(auth_wbc, \$(AUTH_WBC_OBJ), "bin/wbc.$SHLIBEXT", AUTH)
6528 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
6529 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
6530 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
6531 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
6532 SMB_MODULE(auth_netlogond, \$(AUTH_NETLOGOND_OBJ), "bin/netlogond.$SHLIBEXT", AUTH)
6533 SMB_SUBSYSTEM(AUTH,auth/auth.o)
6535 SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
6536 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
6537 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
6538 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
6539 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
6540 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
6541 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
6542 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
6543 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
6544 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
6545 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
6546 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
6547 SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
6548 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
6549 SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
6550 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
6551 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
6552 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
6553 SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
6554 SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
6555 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
6556 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
6557 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
6558 SMB_MODULE(vfs_streams_xattr, \$(VFS_STREAMS_XATTR_OBJ), "bin/streams_xattr.$SHLIBEXT", VFS)
6559 SMB_MODULE(vfs_streams_depot, \$(VFS_STREAMS_DEPOT_OBJ), "bin/streams_depot.$SHLIBEXT", VFS)
6560 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
6561 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
6562 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
6563 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
6564 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
6565 SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
6566 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
6567 SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS)
6568 SMB_MODULE(vfs_preopen, \$(VFS_PREOPEN_OBJ), "bin/preopen.$SHLIBEXT", VFS)
6569 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
6570 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
6571 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
6572 SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS)
6573 SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
6574 SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_traffic_analyzer.$SHLIBEXT", VFS)
6575 SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
6576 SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_copy.$SHLIBEXT", VFS)
6577 SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS)
6578 SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT", VFS)
6579 SMB_MODULE(vfs_crossrename, \$(VFS_CROSSRENAME_OBJ), "bin/crossrename.$SHLIBEXT", VFS)
6580 SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$SHLIBEXT", VFS)
6582 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
6584 SMB_MODULE(perfcount_onefs, \$(PERFCOUNT_ONEFS), "bin/pc_onefs.$SHLIBEXT", PERFCOUNT)
6585 SMB_MODULE(perfcount_test, \$(PERFCOUNT_TEST), "bin/pc_test.$SHLIBEXT", PERFCOUNT)
6586 SMB_SUBSYSTEM(PERFCOUNT,smbd/perfcount.o)
6588 SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT)
6589 SMB_MODULE(gpext_scripts, libgpo/gpext/scripts.o, "bin/scripts.$SHLIBEXT", GPEXT)
6590 SMB_MODULE(gpext_security, libgpo/gpext/security.o, "bin/security.$SHLIBEXT", GPEXT)
6591 SMB_SUBSYSTEM(GPEXT, libgpo/gpext/gpext.o)
6593 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
6595 #################################################
6596 # do extra things if we are running insure
6598 if test "${ac_cv_prog_CC}" = "insure"; then
6599         CPPFLAGS="$CPPFLAGS -D__INSURE__"
6602 #################################################
6603 # If run from the build farm, enable NASTY hacks
6604 #################################################
6605 AC_MSG_CHECKING(whether to enable build farm hacks)
6606 if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
6607         AC_MSG_RESULT(yes)
6608         AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
6609 else
6610         AC_MSG_RESULT(no)
6613 #################################################
6614 # check for bad librt/libpthread interactions
6616 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
6617     x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
6618     x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6619     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6621 SMB_IF_RTSIGNAL_BUG(
6622         [
6623             # Have RT_SIGNAL bug, need to check whether the problem will
6624             # affect anything we have configured.
6626             rt_do_error=no
6627             if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
6628                 if test x"$rt_signal_lease_ok" = x"no" ; then
6629                     rt_do_error=yes
6630                 fi
6631             fi
6633             if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
6634                 if test x"$rt_signal_notify_ok" = x"no" ; then
6635                     rt_do_error=yes
6636                 fi
6637             fi
6639             if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
6640                     x"$samba_cv_HAVE_AIO" = x"yes" ; then
6641                 if test x"$rt_signal_aio_ok" = x"no" ; then
6642                     rt_do_error=yes
6643                 fi
6644             fi
6646             if test x"$rt_do_error" = x"yes" ; then
6647                 SMB_IS_LIBPTHREAD_LINKED(
6648                     [
6649                         cat<<MSG
6651 *** On this platforms, linking Samba against pthreads causes problems
6652 *** with the oplock and change notification mechanisms. You may be
6653 *** using pthreads as a side-effect of using the --with-aio-support
6654 *** or --with-profiling-data options. Please remove these and try again.
6657                     ],
6658                     [
6659                         cat<<MSG
6661 *** On this platform, the oplock and change notification mechanisms do not
6662 *** appear to work. Please report this problem to samba-technical@samba.org
6663 *** and attach the config.log file from this directory.
6666                     ])
6667                 AC_MSG_ERROR(unable to use realtime signals on this platform)
6668             fi
6669         ],
6670         [
6671             # no RT_SIGNAL bug, we are golden
6672             SMB_IS_LIBPTHREAD_LINKED(
6673                 [
6674                     AC_MSG_WARN(using libpthreads - this may degrade performance)
6675                 ])
6677         ],
6678         [
6679             # cross compiling, I hope you know what you are doing
6680             true
6681         ])
6685 AC_ARG_ENABLE(merged-build, 
6686 [AS_HELP_STRING([--enable-merged-build], [Build Samba 4 as well])], 
6687 [ enable_merged_build=$enableval ], [ enable_merged_build=auto ])
6689 if test x"$enable_merged_build" = x"yes" -a \
6690         x"$merged_build_possible" = x"no" ; then
6691         AC_MSG_ERROR(Merged build required but not possible)
6694 m4_include(../lib/zlib/zlib.m4)
6696 if test x$enable_merged_build = xauto; then
6697         # Check for python
6698         m4_include(../m4/check_python.m4)
6699         AC_SAMBA_PYTHON_DEVEL([true], [merged_build_possible=no])
6701         AC_MSG_CHECKING([whether it would be possible to do a merged build])
6702         AC_MSG_RESULT([$merged_build_possible])
6704         # Enable merged build automatically if possible, when in developer mode
6705         if test "x$developer" = xyes; then
6706                 enable_merged_build=$merged_build_possible
6707         fi
6710 if test x$enable_merged_build = xyes; then
6711         MERGED_BUILD=1
6712         saved_USESHARED="$USESHARED"
6713         USESHARED="false"
6714         smbtorture4_path="bin/smbtorture4"
6715         smbtorture4_option="-t bin/smbtorture4"
6716         AC_SUBST(smbtorture4_path)
6717         AC_SUBST(smbtorture4_option)
6718         USESHARED="$saved_USESHARED"
6719         SMBTORTURE4="bin/smbtorture4"
6720         AC_SUBST(SMBTORTURE4)
6723 AC_SUBST(ZLIB_LIBS)
6724 AC_SUBST(ZLIB_OBJS)
6725 AC_ZLIB([ZLIB_OBJS=""], [
6726         ZLIB_LIBS=""
6727         for o in adler32.o compress.o crc32.o gzio.o uncompr.o \
6728                      deflate.o trees.o zutil.o inflate.o infback.o \
6729                          inftrees.o inffast.o
6730         do
6731                 ZLIB_OBJS="$ZLIB_OBJS ../lib/zlib/$o"
6732         done
6733         CFLAGS="-I../lib/zlib $CFLAGS"
6736 AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
6738 if test "x$enable_dmalloc" = xyes
6739 then
6740         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
6741         AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
6742                   [Define to check invariants around some common functions])
6743         LIBS="$LIBS -ldmalloc"
6746 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
6747 LIB_REMOVE_USR_LIB(LDFLAGS)
6748 LIB_REMOVE_USR_LIB(LIBS)
6750 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
6751 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
6752 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
6754 #################################################
6755 # Display summary of libraries detected
6757 AC_MSG_RESULT([Using libraries:])
6758 AC_MSG_RESULT([    LIBS = $LIBS])
6759 if test x"$with_ads_support" != x"no"; then
6760     AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
6762 if test x"$with_ldap_support" != x"no"; then
6763     AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
6765 if test x"$with_dnsupdate_support" != x"no"; then
6766     AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
6768 if test x"$have_dnssd_support" != x"no"; then
6769     AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
6771 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
6773 #################################################
6774 # final configure stuff
6776 AC_MSG_CHECKING([configure summary])
6777 AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
6778            AC_MSG_RESULT(yes),
6779            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
6780            AC_MSG_WARN([cannot run when cross-compiling]))
6782 dnl Merge in developer cflags from now on
6783 AC_SUBST(DEVELOPER_CFLAGS)
6784 if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes" -o x"$picky_developer" = x"yes"; then
6785     CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
6788 # Stuff the smbd-only libraries at the end of the smbd link
6789 # path (if we have them).
6790 SMBD_LIBS="$samba_dmapi_libs"
6791 AC_SUBST(SMBD_LIBS)
6793 CFLAGS="${CFLAGS} \$(FLAGS)"
6794 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
6796 # If we had to expand the includes, make tsure the output file is moved back
6797 AC_OUTPUT_COMMANDS([
6798 if test -f Makefile-noincludes -a ! -f Makefile -a ! -h Makefile ; then
6799         ln -s Makefile-noincludes Makefile
6803 AC_SUBST(MAKEFILE)
6804 if test x$samba_cv_gnu_make = xyes; then
6805         MAKEFILE=Makefile
6806 else
6807         # When we don't have GNU Make, generate a copy of Makefile.in 
6808         # that doesn't have the "include " statements but just includes 
6809         # the files verbatim.
6810         MAKEFILE=Makefile-noincludes
6811         $PERL ./script/expand-includes.pl Makefile.in > $MAKEFILE.in
6813 AC_OUTPUT($MAKEFILE
6814           script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
6815           lib/netapi/examples/Makefile
6816           lib/netapi/tests/Makefile
6817           pkgconfig/smbclient.pc
6818           pkgconfig/wbclient.pc
6819           pkgconfig/netapi.pc
6820           pkgconfig/smbsharemodes.pc
6821           ../examples/libsmbclient/Makefile.internal
6822           )
6824 #################################################
6825 # Print very concise instructions on building/use
6826 if test "x$enable_dmalloc" = xyes
6827 then
6828         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
6829         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])