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