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