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