r15601: Fix segfaults with 'security=share' and 'guest only = yes'
[Samba/nascimento.git] / source3 / configure.in
blobd26e13a6bbba9871b725860f757998eb754d0027
1 dnl Process this file with autoconf to produce a configure script.
3 dnl We must use autotools 2.53 or above
4 AC_PREREQ(2.53)
5 AC_INIT(include/includes.h)
6 AC_CONFIG_HEADER(include/config.h)
8 AC_DISABLE_STATIC
9 AC_ENABLE_SHARED
11 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
12 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
14 SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
15 if test -n "${SAMBA_VERSION_SVN_REVISION}";then
16         echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
19 #################################################
20 # Directory handling stuff to support both the
21 # legacy SAMBA directories and FHS compliant
22 # ones...
23 AC_PREFIX_DEFAULT(/usr/local/samba)
25 rootsbindir="\${SBINDIR}"
26 lockdir="\${VARDIR}/locks"
27 piddir="\${VARDIR}/locks"
28 test "${mandir}" || mandir="\${prefix}/man"
29 logfilebase="\${VARDIR}"
30 privatedir="\${prefix}/private"
31 test "${libdir}" || libdir="\${prefix}/lib"
32 pammodulesdir="\${LIBDIR}/security"
33 configdir="\${LIBDIR}"
34 swatdir="\${prefix}/swat"
36 AC_ARG_WITH(fhs, 
37 [  --with-fhs              Use FHS-compliant paths (default=no)],
38 [ case "$withval" in
39   yes)
40     lockdir="\${VARDIR}/lib/samba"
41     piddir="\${VARDIR}/run"
42     mandir="\${prefix}/share/man"
43     logfilebase="\${VARDIR}/log/samba"
44     privatedir="\${CONFIGDIR}/private"
45     libdir="\${prefix}/lib/samba"
46     configdir="${sysconfdir}/samba"
47     swatdir="\${DATADIR}/samba/swat"
48     ;;
49   esac])
51 #################################################
52 # set private directory location
53 AC_ARG_WITH(privatedir,
54 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
55 [ case "$withval" in
56   yes|no)
57   #
58   # Just in case anybody calls it without argument
59   #
60     AC_MSG_WARN([--with-privatedir called without argument - will use default])
61   ;;
62   * )
63     privatedir="$withval"
64     ;;
65   esac])
67 #################################################
68 # set root sbin directory location
69 AC_ARG_WITH(rootsbindir,
70 [  --with-rootsbindir=DIR  Which directory to use for root sbin ($ac_default_prefix/sbin)],
71 [ case "$withval" in
72   yes|no)
73   #
74   # Just in case anybody calls it without argument
75   #
76     AC_MSG_WARN([--with-rootsbindir called without argument - will use default])
77   ;;
78   * )
79     rootsbindir="$withval"
80     ;;
81   esac])
83 #################################################
84 # set lock directory location
85 AC_ARG_WITH(lockdir,
86 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
87 [ case "$withval" in
88   yes|no)
89   #
90   # Just in case anybody calls it without argument
91   #
92     AC_MSG_WARN([--with-lockdir called without argument - will use default])
93   ;;
94   * )
95     lockdir="$withval"
96     ;;
97   esac])
99 #################################################
100 # set pid directory location
101 AC_ARG_WITH(piddir,
102 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
103 [ case "$withval" in
104   yes|no)
105   #
106   # Just in case anybody calls it without argument
107   #
108     AC_MSG_WARN([--with-piddir called without argument - will use default])
109   ;;
110   * )
111     piddir="$withval"
112     ;;
113   esac])
115 #################################################
116 # set SWAT directory location
117 AC_ARG_WITH(swatdir,
118 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
119 [ case "$withval" in
120   yes|no)
121   #
122   # Just in case anybody does it
123   #
124     AC_MSG_WARN([--with-swatdir called without argument - will use default])
125   ;;
126   * )
127     swatdir="$withval"
128     ;;
129   esac])
131 #################################################
132 # set configuration directory location
133 AC_ARG_WITH(configdir,
134 [  --with-configdir=DIR    Where to put configuration files ($libdir)],
135 [ case "$withval" in
136   yes|no)
137   #
138   # Just in case anybody does it
139   #
140     AC_MSG_WARN([--with-configdir called without argument - will use default])
141   ;;
142   * )
143     configdir="$withval"
144     ;;
145   esac])
147 #################################################
148 # set log directory location
149 AC_ARG_WITH(logfilebase,
150 [  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
151 [ case "$withval" in
152   yes|no)
153   #
154   # Just in case anybody does it
155   #
156     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
157   ;;
158   * )
159     logfilebase="$withval"
160     ;;
161   esac])
163 #################################################
164 # set lib directory location
165 AC_ARG_WITH(libdir,
166 [  --with-libdir=DIR       Where to put libdir ($libdir)],
167 [ case "$withval" in
168   yes|no)
169   #
170   # Just in case anybody does it
171   #
172     AC_MSG_WARN([--with-libdir without argument - will use default])
173   ;;
174   * )
175     libdir="$withval"
176     ;;
177   esac])
179 #################################################
180 # set PAM modules directory location
181 AC_ARG_WITH(pammodulesdir,
182 [  --with-pammodulesdir=DIR  Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)],
183 [ case "$withval" in
184   yes|no)
185   #
186   # Just in case anybody calls it without argument
187   #
188     AC_MSG_WARN([--with-pammodulesdir called without argument - will use default])
189   ;;
190   * )
191     pammodulesdir="$withval"
192     ;;
193   esac])
195 #################################################
196 # set man directory location
197 AC_ARG_WITH(mandir,
198 [  --with-mandir=DIR       Where to put man pages ($mandir)],
199 [ case "$withval" in
200   yes|no)
201   #
202   # Just in case anybody does it
203   #
204     AC_MSG_WARN([--with-mandir without argument - will use default])
205   ;;
206   * )
207     mandir="$withval"
208     ;;
209   esac])
211 AC_ARG_WITH(cfenc,
212 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
213                           for optimization (Mac OS X/Darwin only)],
215 # May be in source $withval/CoreFoundation/StringEncodings.subproj.
216 # Should have been in framework $withval/CoreFoundation.framework/Headers.
217 for d in \
218     $withval/CoreFoundation/StringEncodings.subproj \
219     $withval/StringEncodings.subproj \
220     $withval/CoreFoundation.framework/Headers \
221     $withval/Headers \
222     $withval
224     if test -r $d/CFStringEncodingConverter.h; then
225         ln -sfh $d include/CoreFoundation
226     fi
227 done
230 AC_SUBST(configdir)
231 AC_SUBST(lockdir)
232 AC_SUBST(piddir)
233 AC_SUBST(logfilebase)
234 AC_SUBST(privatedir)
235 AC_SUBST(swatdir)
236 AC_SUBST(bindir)
237 AC_SUBST(sbindir)
238 AC_SUBST(rootsbindir)
239 AC_SUBST(pammodulesdir)
241 dnl Unique-to-Samba variables we'll be playing with.
242 AC_SUBST(SHELL)
243 AC_SUBST(LDSHFLAGS)
244 AC_SUBST(SONAMEFLAG)
245 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
246 AC_SUBST(SHLD)
247 AC_SUBST(HOST_OS)
248 AC_SUBST(PICFLAGS)
249 AC_SUBST(PICSUFFIX)
250 AC_SUBST(libc_cv_fpie)
251 AC_SUBST(PIE_CFLAGS)
252 AC_SUBST(PIE_LDFLAGS)
253 AC_SUBST(SHLIBEXT)
254 AC_SUBST(INSTALLLIBCMD_SH)
255 AC_SUBST(INSTALLLIBCMD_A)
256 AC_SUBST(UNINSTALLLIBCMD_SH)
257 AC_SUBST(UNINSTALLLIBCMD_A)
258 AC_SUBST(INSTALL_LIBMSRPC)
259 AC_SUBST(UNINSTALL_LIBMSRPC)
260 AC_SUBST(LIBMSRPC_SHARED)
261 AC_SUBST(LIBMSRPC)
262 AC_SUBST(INSTALL_LIBSMBCLIENT)
263 AC_SUBST(UNINSTALL_LIBSMBCLIENT)
264 AC_SUBST(LIBSMBCLIENT_SHARED)
265 AC_SUBST(LIBSMBCLIENT)
266 AC_SUBST(INSTALL_LIBSMBSHAREMODES)
267 AC_SUBST(LIBSMBSHAREMODES_SHARED)
268 AC_SUBST(LIBSMBSHAREMODES)
269 AC_SUBST(PRINT_LIBS)
270 AC_SUBST(AUTH_LIBS)
271 AC_SUBST(ACL_LIBS)
272 AC_SUBST(PASSDB_LIBS)
273 AC_SUBST(IDMAP_LIBS)
274 AC_SUBST(KRB5_LIBS)
275 AC_SUBST(LDAP_LIBS)
276 AC_SUBST(SHLIB_PROGS)
277 AC_SUBST(PAM_MODULES)
278 AC_SUBST(INSTALL_PAM_MODULES)
279 AC_SUBST(UNINSTALL_PAM_MODULES)
280 AC_SUBST(SMBWRAPPER)
281 AC_SUBST(SMBWRAP_OBJS)
282 AC_SUBST(SMBWRAP_INC)
283 AC_SUBST(EXTRA_BIN_PROGS)
284 AC_SUBST(CIFSMOUNT_PROGS)
285 AC_SUBST(INSTALL_CIFSMOUNT)
286 AC_SUBST(UNINSTALL_CIFSMOUNT)
287 AC_SUBST(EXTRA_SBIN_PROGS)
288 AC_SUBST(EXTRA_ALL_TARGETS)
289 AC_SUBST(CONFIG_LIBS)
290 AC_SUBST(NSCD_LIBS)
292 # Set defaults
293 PIE_CFLAGS=""
294 PIE_LDFLAGS=""
295 AC_ARG_ENABLE(pie, [  --enable-pie            Turn on pie support if available (default=yes)])
297 if test "x$enable_pie" != xno
298 then
299         AC_CACHE_CHECK(for -fPIE, libc_cv_fpie, [dnl
300                 cat > conftest.c <<EOF
301 int foo;
302 main () { return 0;}
304                 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
305                 then
306                         libc_cv_fpie=yes
307                         PIE_CFLAGS="-fPIE"
308                         PIE_LDFLAGS="-pie"
309                 fi
310                 rm -f conftest*])
312 if test "x$PIE_CFLAGS" = x
313 then
314         libc_cv_fpie=no
317 AC_ARG_ENABLE(debug, 
318 [  --enable-debug          Turn on compiler debugging information (default=no)],
319     [if eval "test x$enable_debug = xyes"; then
320         CFLAGS="${CFLAGS} -g"
321     fi])
323 AC_SUBST(SOCKWRAP)
324 AC_ARG_ENABLE(socket-wrapper, 
325 [  --enable-socket-wrapper         Turn on socket wrapper library (default=no)],
326     [if eval "test x$enable_socket_wrapper = xyes"; then
327         AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
328         SOCKWRAP="\$(SOCKET_WRAPPER_OBJ)"
329     fi])
331 #################################################
332 # set prefix for 'make test'
333 selftest_prefix="./"
334 AC_SUBST(selftest_prefix)
335 AC_ARG_WITH(selftest-prefix,
336 [  --with-selftest-prefix=DIR    The prefix where make test will be runned ($selftest_prefix)],
337 [ case "$withval" in
338   yes|no)
339     AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
340   ;;
341   * )
342     selftest_prefix="$withval"
343     ;;
344   esac
347 #################################################
348 # set path of samba4's smbtorture
349 smbtorture4_path=""
350 AC_SUBST(smbtorture4_path)
351 AC_ARG_WITH(smbtorture4_path,
352 [  --with-smbtorture4-path=PATH    The path to a samba4 smbtorture for make test (none)],
353 [ case "$withval" in
354   yes|no)
355     AC_MSG_ERROR([--with-smbtorture4-path should take a path])
356   ;;
357   * )
358     smbtorture4_path="$withval"
359     if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
360         AC_MSG_ERROR(['$smbtorture_path' does not  exist!]) 
361     fi
362   ;;
363  esac
366 # compile with optimization and without debugging by default, but
367 # allow people to set their own preference.
368 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
369 # if it has no value.  This prevent *very* large debug binaries from occurring
370 # by default.
371 if test "x$CFLAGS" = x; then
372   CFLAGS="-O"
375 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
377 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
378     [if eval "test x$enable_developer = xyes"; then
379         developer=yes
380         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
381         # Add -Wdeclaration-after-statement if compiler supports it
382         AC_CACHE_CHECK(
383           [that the C compiler understands -Wdeclaration-after-statement],
384           samba_cv_HAVE_Wdeclaration_after_statement, [
385           AC_TRY_RUN_STRICT([
386             int main(void)
387             {
388                 return 0;
389             }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
390             samba_cv_HAVE_Wdeclaration_after_statement=yes,
391             samba_cv_HAVE_Wdeclaration_after_statement=no,
392             samba_cv_HAVE_Wdeclaration_after_statement=cross)
393        ])
394        if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
395             CFLAGS="${CFLAGS} -Wdeclaration-after-statement"
396        fi
397     fi])
399 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
400     [if eval "test x$enable_krb5developer = xyes"; then
401         developer=yes
402         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
403     fi])
405 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
407 if test "x$enable_dmalloc" = xyes
408 then
409         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
410         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
411                   [Define to check invariants around some common functions])
412         LIBS="$LIBS -ldmalloc"  
415 dnl Checks for programs.
418 ## for some reason this macro resets the CFLAGS
419 ## so save and restore
421 OLD_CFLAGS=${CFLAGS}
422 AC_PROG_CC
423 CFLAGS=${OLD_CFLAGS}
425 OLD_CFLAGS=${CFLAGS}
426 AC_PROG_CPP
427 CFLAGS=${OLD_CFLAGS}
429 AC_PROG_INSTALL
430 AC_PROG_AWK
431 AC_PATH_PROG(PERL, perl)
433 AC_CHECK_TOOL(AR, ar)
435 dnl Check if we use GNU ld
436 LD=ld
437 AC_PROG_LD_GNU
439 dnl Certain versions of GNU ld the default is not to have the 
440 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
441 dnl warnings when building modules.
442 if test "$ac_cv_prog_gnu_ld" = "yes"; then
443         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
444         AC_MSG_CHECKING(GNU ld release date)
445         changequote(,)dnl
446         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'`
447         changequote([,])dnl
448         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
449         if test -n "$ac_cv_gnu_ld_date"; then
450         if test "$ac_cv_gnu_ld_date" -lt 20030217; then
451                 ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
452         fi
453         else
454            AC_MSG_CHECKING(GNU ld release version)
455            changequote(,)dnl
456            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
457            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
458            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
459            changequote([,])dnl
460            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
461            AC_MSG_CHECKING(GNU ld release version major)
462            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
463            AC_MSG_CHECKING(GNU ld release version minor)
464            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
465            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
466              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
467            fi
468         fi
471 dnl needed before AC_TRY_COMPILE
472 AC_ISC_POSIX
474 dnl look for executable suffix
475 AC_EXEEXT
477 dnl Check if C compiler understands -c and -o at the same time
478 AC_PROG_CC_C_O
479 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
480       BROKEN_CC=
481 else
482       BROKEN_CC=#
484 AC_SUBST(BROKEN_CC)
486 dnl Check if the C compiler understands -Werror
487 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
488  AC_TRY_RUN_STRICT([
489   int main(void)
490   {
491         return 0;
492   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
493   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
494 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
495    Werror_FLAGS="-Werror"
496 else 
497 dnl Check if the C compiler understands -w2
498 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
499  AC_TRY_RUN_STRICT([
500   int main(void)
501   {
502         return 0;
503   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
504   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
505 if test x"$samba_cv_HAVE_w2" = x"yes"; then
506    Werror_FLAGS="-w2"
510 dnl Check if the C compiler understands volatile (it should, being ANSI).
511 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
512     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
513         samba_cv_volatile=yes,samba_cv_volatile=no)])
514 if test x"$samba_cv_volatile" = x"yes"; then
515    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
518 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
519 AC_MSG_CHECKING(uname -s)
520 AC_MSG_RESULT(${UNAME_S})
522 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
523 AC_MSG_CHECKING(uname -r)
524 AC_MSG_RESULT(${UNAME_R})
526 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
527 AC_MSG_CHECKING(uname -m)
528 AC_MSG_RESULT(${UNAME_M})
530 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
531 AC_MSG_CHECKING(uname -p)
532 AC_MSG_RESULT(${UNAME_P})
534 AC_CANONICAL_SYSTEM
536 dnl Add #include for broken IRIX header files
537   case "$host_os" in
538         *irix6*) AC_ADD_INCLUDE(<standards.h>)
539         ;;
540 esac
542 AC_VALIDATE_CACHE_SYSTEM_TYPE
544 DYNEXP=
546 dnl Add modules that have to be built by default here
547 dnl These have to be built static:
548 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
550 dnl These are preferably build shared, and static if dlopen() is not available
551 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 charset_CP850 charset_CP437 auth_script"
553 if test "x$developer" = xyes; then
554    default_static_modules="$default_static_modules rpc_echo"
555    default_shared_modules="$default_shared_modules charset_weird"
559 # Config CPPFLAG settings for strange OS's that must be set
560 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
561 # case statement; its first reference must be unconditional.
563 case "$host_os" in
564 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
565     *hpux*)
566     
567       AC_PROG_CC_FLAG(Ae)
568       # mmap on HPUX is completely broken...
569       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
570       if test $ac_cv_prog_cc_Ae = yes; then
571         CPPFLAGS="$CPPFLAGS -Ae"
572       fi
574 # Defines needed for HPUX support.
575 # HPUX has bigcrypt but (sometimes?) doesn't use it for
576 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
578       case `uname -r` in
579                         *9*|*10*)
580                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
581                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
582                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
583                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
584                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
585                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
586                                 ;;
587                         *11*)
588                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
589                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
590                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
591                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
592                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
593                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
594                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
595                                 ;;
596       esac
597       ;;
600 # CRAY Unicos has broken const handling
601        *unicos*)
602           AC_MSG_RESULT([disabling const])
603           CPPFLAGS="$CPPFLAGS -Dconst="
604           ;;
605         
607 # AIX4.x doesn't even admit to having large
608 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
610     *aix4*)
611           AC_MSG_RESULT([enabling large file support])
612       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
613           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
614       ;;    
616 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
617 # to the existance of large files..
618 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
619 # recommendations on large file support, however it makes the
620 # compile work using gcc 2.7 and 2.8, whereas using the Sun
621 # recommendation makes the compile fail on gcc2.7. JRA.
623 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
625         *solaris*)
626                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
627                 case `uname -r` in
628                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
629                                 AC_MSG_RESULT([no large file support])
630                                 ;;
631                         5.*)
632                         AC_MSG_RESULT([enabling large file support])
633                         if test "$ac_cv_prog_gcc" = yes; then
634                                 ${CC-cc} -v >conftest.c 2>&1
635                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
636                                 rm -fr conftest.c
637                                 case "$ac_cv_gcc_compiler_version_number" in
638                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
639                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
640                                                 LDFLAGS="$LDFLAGS -lthread"
641                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
642                                                 ;;
643                                         *)
644                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
645                                                 LDFLAGS="$LDFLAGS -lthread"
646                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
647                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
648                                                 ;;
649                                 esac
650                         else
651                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
652                                 LDFLAGS="$LDFLAGS -lthread"
653                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
654                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
655                         fi
656                         ;;
657                 esac
658                 ;;
660 # IRIX uses SYSV printing.  Make sure to set that here
662         *irix*)
663                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
664                 ;;
665         *freebsd*|*dragonfly*)
666                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
667                 ;;
669 # VOS may need to have POSIX support and System V compatibility enabled.
671     *vos*)
672     case "$CPPFLAGS" in
673           *-D_POSIX_C_SOURCE*)
674                 ;;
675           *)
676                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
677                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
678                 ;;
679     esac
680     case "$CPPFLAGS" in
681           *-D_SYSV*|*-D_SVID_SOURCE*)
682                 ;;
683           *)
684                 CPPFLAGS="$CPPFLAGS -D_SYSV"
685                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
686     esac
687     ;;
689 # Tests needed for SINIX large file support.
691     *sysv4*)
692       if test $host = mips-sni-sysv4 ; then
693         AC_MSG_CHECKING([for LFS support])
694         old_CPPFLAGS="$CPPFLAGS"
695         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
696         AC_TRY_RUN([
697 #include <unistd.h>
698 main () {
699 #if _LFS64_LARGEFILE == 1
700 exit(0);
701 #else
702 exit(1);
703 #endif
704 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
705         CPPFLAGS="$old_CPPFLAGS"
706         if test x$SINIX_LFS_SUPPORT = xyes ; then
707           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
708                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
709           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
710           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
711           LIBS="`getconf LFS64_LIBS` $LIBS"
712         fi
713       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
714       fi
715     ;;
717 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
719     *linux*)
720         AC_MSG_CHECKING([for LFS support])
721         old_CPPFLAGS="$CPPFLAGS"
722         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
723        AC_TRY_RUN([
724 #include <unistd.h>
725 #include <sys/utsname.h>
726 #include <string.h>
727 #include <stdlib.h>
728 main() {
729 #if _LFS64_LARGEFILE == 1
730        struct utsname uts;
731        char *release;
732        int major, minor;
734        /* Ensure this is glibc 2.2 or higher */
735 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
736        int libc_major = __GLIBC__;
737        int libc_minor = __GLIBC_MINOR__;
739        if (libc_major < 2)
740               exit(1);
741        if (libc_minor < 2)
742               exit(1);
743 #endif
745        /* Ensure this is kernel 2.4 or higher */
747        uname(&uts);
748        release = strdup(uts.release);
749        major = atoi(strsep(&release, "."));
750        minor = atoi(strsep(&release, "."));
752        if (major > 2 || (major == 2 && minor > 3))
753                exit(0);
754        exit(1);
755 #else
756        exit(1);
757 #endif
759 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
760         CPPFLAGS="$old_CPPFLAGS"
761         if test x$LINUX_LFS_SUPPORT = xyes ; then
762                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
763                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
764                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
765                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
766         fi
767         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
768         ;;
771 # MacOS X is the *only* system that uses compose character in utf8. This
772 # is so horribly broken....
774     *darwin*)
775         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
776 # Add Fink directories for various packages, like dlcompat.
777 # Note: iconv does that explicitly below, but other packages
778 # don't.
779         CPPFLAGS="$CPPFLAGS -I/sw/include"
780         LDFLAGS="$LDFLAGS -L/sw/lib"
782 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
783 # use that instead of plain dlsym.
785         AC_CHECK_LIB(dl,dlopen)
786         AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
788 # Add a system specific charset module.
790         default_shared_modules="$default_shared_modules charset_macosxfs"
791         ;;
792     *hurd*)
793         AC_MSG_CHECKING([for LFS support])
794         old_CPPFLAGS="$CPPFLAGS"
795         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
796         AC_TRY_RUN([
797 #include <unistd.h>
798 main () {
799 #if _LFS64_LARGEFILE == 1
800 exit(0);
801 #else
802 exit(1);
803 #endif
804 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
805         CPPFLAGS="$old_CPPFLAGS"
806         if test x$GLIBC_LFS_SUPPORT = xyes ; then
807           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
808                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
809           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
810         fi
811       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
812     ;;
814 esac
816 AC_INLINE
817 AC_HEADER_STDC
818 AC_HEADER_DIRENT
819 AC_HEADER_TIME
820 AC_HEADER_SYS_WAIT
821 AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
822 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h alloca.h)
823 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
824 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
825 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
826 AC_CHECK_HEADERS(sys/un.h)
827 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
828 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
829 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
830 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
831 AC_CHECK_HEADERS(langinfo.h locale.h)
832 AC_CHECK_HEADERS(sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h)
834 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
835 #if HAVE_RPC_RPC_H
836 #include <rpc/rpc.h>
837 #endif
840 ## These fail to compile on IRIX so just check for their presence
841 AC_CHECK_HEADERS(sys/mode.h,,,)
843 # Look for Darwin headers
844 old_CPPFLAGS="$CPPFLAGS"
845 CPPFLAGS="-Iinclude $CPPFLAGS"
846 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
847 CPPFLAGS="$old_CPPFLAGS"
849 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
850 # subdirectory of headers.
851 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
853 # check for linux on amd64 since valgrind is not quite there yet
854 case "$host_os" in
855         *linux*)
856                 case "$UNAME_P" in
857                         *x86_64*)
858                                 AC_DEFINE(HAVE_64BIT_LINUX,1,[Whether we are running on 64bit linux])
859                                 ;;
860                 esac
861                 ;;
862 esac
866 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
867 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
869 case "$host_os" in
870     *hpux*)
871                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
872                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
873                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
874                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
875                 fi
876         ;;
877 esac
878 AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
879 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
880 AC_CHECK_HEADERS(stropts.h poll.h)
881 AC_CHECK_HEADERS(syscall.h sys/syscall.h)
883 AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
884 AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
886 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
888 AC_CHECK_HEADERS(netinet/ip.h,,,[[
889 #include <sys/types.h>
890 #if HAVE_SYS_SOCKET_H
891 #include <sys/socket.h>
892 #endif
893 #include <netinet/in.h>
894 #if HAVE_NETINET_IN_SYSTM_H
895 #include <netinet/in_systm.h>
896 #endif
899 AC_CHECK_HEADERS(net/if.h,,,[[
900 #include <sys/types.h>
901 #if HAVE_SYS_SOCKET_H
902 #include <sys/socket.h>
903 #endif
906 AC_CHECK_HEADERS(security/pam_modules.h,,,[[
907 #if HAVE_SECURITY_PAM_APPL_H
908 #include <security/pam_appl.h>
909 #endif
912 # For experimental utmp support (lastlog on some BSD-like systems)
913 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
915 AC_CHECK_SIZEOF(int,cross)
916 AC_CHECK_SIZEOF(long,cross)
917 AC_CHECK_SIZEOF(long long,cross)
918 AC_CHECK_SIZEOF(short,cross)
920 AC_C_CONST
921 AC_C_INLINE
922 AC_C_BIGENDIAN
923 AC_C_CHAR_UNSIGNED
925 AC_TYPE_SIGNAL
926 AC_TYPE_UID_T
927 AC_TYPE_MODE_T
928 AC_TYPE_OFF_T
929 AC_TYPE_SIZE_T
930 AC_TYPE_PID_T
931 AC_STRUCT_ST_RDEV
932 AC_DIRENT_D_OFF
933 AC_CHECK_TYPE(ino_t,unsigned)
934 AC_CHECK_TYPE(loff_t,off_t)
935 AC_CHECK_TYPE(offset_t,loff_t)
936 AC_CHECK_TYPE(ssize_t, int)
937 AC_CHECK_TYPE(wchar_t, unsigned short)
939 ############################################
940 # for cups support we need libcups, and a handful of header files
942 AC_ARG_ENABLE(cups,
943 [  --enable-cups           Turn on CUPS support (default=auto)])
945 if test x$enable_cups != xno; then
946         AC_PATH_PROG(CUPS_CONFIG, cups-config)
948         if test "x$CUPS_CONFIG" != x; then
949                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
950                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
951                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
952                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
953         elif test x"$enable_cups" = x"yes"; then
954                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
955         fi
958 AC_ARG_ENABLE(iprint,
959 [  --enable-iprint         Turn on iPrint support (default=yes if cups is yes)])
961 if test x$enable_iprint != xno; then
962         if test "x$CUPS_CONFIG" != x; then
963                 AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
964         elif test x"$enable_iprint" = x"yes"; then
965                 AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
966         fi
969 ############################################
970 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
971 AC_SEARCH_LIBS(dlopen, [dl])
972 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
974 ############################################
975 # check if the compiler can do immediate structures
976 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
977     AC_TRY_COMPILE([
978 #include <stdio.h>],
980    typedef struct {unsigned x;} FOOBAR;
981    #define X_FOOBAR(x) ((FOOBAR) { x })
982    #define FOO_ONE X_FOOBAR(1)
983    FOOBAR f = FOO_ONE;   
984    static struct {
985         FOOBAR y; 
986         } f2[] = {
987                 {FOO_ONE}
988         };   
990         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
991 if test x"$samba_cv_immediate_structures" = x"yes"; then
992    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
995 ############################################
996 # check if the compiler can do immediate structures
997 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
998     AC_TRY_LINK([
999 #include <stdio.h>],
1001                 if (0) {
1002                    this_function_does_not_exist();
1003                 } else {
1004                   return 1;
1005                 }
1008         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
1009 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
1010    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
1013 ############################################
1014 # check for unix domain sockets
1015 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
1016     AC_TRY_COMPILE([
1017 #include <sys/types.h>
1018 #include <stdlib.h>
1019 #include <stddef.h>
1020 #include <sys/socket.h>
1021 #include <sys/un.h>],
1023   struct sockaddr_un sunaddr; 
1024   sunaddr.sun_family = AF_UNIX;
1026         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
1027 if test x"$samba_cv_unixsocket" = x"yes"; then
1028    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
1032 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
1033     AC_TRY_COMPILE([
1034 #include <sys/types.h>
1035 #if STDC_HEADERS
1036 #include <stdlib.h>
1037 #include <stddef.h>
1038 #endif
1039 #include <sys/socket.h>],[socklen_t i = 0],
1040         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
1041 if test x"$samba_cv_socklen_t" = x"yes"; then
1042    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
1045 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
1046     AC_TRY_COMPILE([
1047 #include <sys/types.h>
1048 #if STDC_HEADERS
1049 #include <stdlib.h>
1050 #include <stddef.h>
1051 #endif
1052 #include <signal.h>],[sig_atomic_t i = 0],
1053         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
1054 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
1055    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
1058 AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
1059     AC_TRY_COMPILE([
1060 #include <sys/types.h>
1061 #if STDC_HEADERS
1062 #include <stdlib.h>
1063 #include <stddef.h>
1064 #endif
1065 #if TIME_WITH_SYS_TIME
1066 # include <sys/time.h>
1067 # include <time.h>
1068 #else
1069 # if HAVE_SYS_TIME_H
1070 #  include <sys/time.h>
1071 # else
1072 #  include <time.h>
1073 # endif
1074 #endif
1075 #if HAVE_AIO_H
1076 #include <aio.h>
1077 #endif
1078 ],[struct timespec ts;],
1079         samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
1080 if test x"$samba_cv_struct_timespec" = x"yes"; then
1081    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
1084 # stupid headers have the functions but no declaration. grrrr.
1085 AC_HAVE_DECL(errno, [#include <errno.h>])
1086 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
1087 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
1088 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
1089 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
1090 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
1091 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
1093 # and glibc has setresuid under linux but the function does
1094 # nothing until kernel 2.1.44! very dumb.
1095 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
1096     AC_TRY_RUN([#include <errno.h>
1097 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
1098         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
1099 if test x"$samba_cv_have_setresuid" = x"yes"; then
1100     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
1103 # Do the same check for setresguid...
1105 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
1106     AC_TRY_RUN([#include <unistd.h>
1107 #include <errno.h>
1108 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
1109         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
1110 if test x"$samba_cv_have_setresgid" = x"yes"; then
1111     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
1114 AC_FUNC_MEMCMP
1116 ###############################################
1117 # Readline included by default unless explicitly asked not to
1118 test "${with_readline+set}" != "set" && with_readline=yes
1120 # test for where we get readline() from
1121 AC_MSG_CHECKING(whether to use readline)
1122 AC_ARG_WITH(readline,
1123 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
1124 [  case "$with_readline" in
1125   yes)
1126     AC_MSG_RESULT(yes)
1128     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1129     AC_CHECK_HEADERS(readline/history.h)
1131     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1132       for termlib in ncurses curses termcap terminfo termlib tinfo; do
1133        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1134       done
1135       AC_CHECK_LIB(readline, rl_callback_handler_install,
1136        [TERMLIBS="-lreadline $TERMLIBS"
1137        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1138        break], [TERMLIBS=], $TERMLIBS)])
1139     ;;
1140   no)
1141     AC_MSG_RESULT(no)
1142     ;;
1143   *)
1144     AC_MSG_RESULT(yes)
1146     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
1147     # alternate readline path
1148     _ldflags=${LDFLAGS}
1149     _cppflags=${CPPFLAGS}
1151     # Add additional search path
1152     LDFLAGS="-L$with_readline/lib $LDFLAGS"
1153     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1155     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
1156     AC_CHECK_HEADERS(readline/history.h)
1158     AC_CHECK_HEADERS(readline.h readline/readline.h,[
1159       for termlib in ncurses curses termcap terminfo termlib; do
1160        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
1161       done
1162       AC_CHECK_LIB(readline, rl_callback_handler_install,
1163        [TERMLDFLAGS="-L$with_readline/lib"
1164        TERMCPPFLAGS="-I$with_readline/include"
1165        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
1166        TERMLIBS="-lreadline $TERMLIBS"
1167        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
1168        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
1170     LDFLAGS=$_ldflags
1171     ;;
1172   esac],
1173   AC_MSG_RESULT(no)
1175 AC_SUBST(TERMLIBS)
1176 AC_SUBST(TERMLDFLAGS)
1178 # The readline API changed slightly from readline3 to readline4, so
1179 # code will generate warnings on one of them unless we have a few
1180 # special cases.
1181 AC_CHECK_LIB(readline, rl_completion_matches,
1182              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
1183                         [Do we have rl_completion_matches?])],
1184              [],
1185              [$TERMLIBS])
1187 # The following test taken from the cvs sources
1188 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
1189 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
1190 # libsocket.so which has a bad implementation of gethostbyname (it
1191 # only looks in /etc/hosts), so we only look for -lsocket if we need
1192 # it.
1193 AC_CHECK_FUNCS(connect)
1194 if test x"$ac_cv_func_connect" = x"no"; then
1195     case "$LIBS" in
1196     *-lnsl*) ;;
1197     *) AC_CHECK_LIB(nsl_s, connect) ;;
1198     esac
1199     case "$LIBS" in
1200     *-lnsl*) ;;
1201     *) AC_CHECK_LIB(nsl, connect) ;;
1202     esac
1203     case "$LIBS" in
1204     *-lsocket*) ;;
1205     *) AC_CHECK_LIB(socket, connect) ;;
1206     esac
1207     case "$LIBS" in
1208     *-linet*) ;;
1209     *) AC_CHECK_LIB(inet, connect) ;;
1210     esac
1211     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
1212     dnl has been cached.
1213     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
1214        test x"$ac_cv_lib_inet_connect" = x"yes"; then
1215         # ac_cv_func_connect=yes
1216         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
1217         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
1218     fi
1221 ###############################################
1222 # test for where we get yp_get_default_domain() from
1223 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1224 AC_CHECK_FUNCS(yp_get_default_domain)
1226 # Check if we have execl, if not we need to compile smbrun.
1227 AC_CHECK_FUNCS(execl)
1228 if test x"$ac_cv_func_execl" = x"no"; then
1229     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1232 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
1233 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
1234 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
1235 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1236 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1237 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
1238 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
1239 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1240 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
1241 AC_CHECK_FUNCS(getdents getdents64)
1242 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1243 AC_CHECK_FUNCS(syslog vsyslog timegm)
1244 AC_CHECK_FUNCS(setlocale nl_langinfo)
1245 AC_CHECK_FUNCS(nanosleep)
1246 # setbuffer, shmget, shm_open are needed for smbtorture
1247 AC_CHECK_FUNCS(setbuffer shmget shm_open)
1249 # Find a method of generating a stack trace
1250 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
1251 AC_CHECK_FUNCS(backtrace_symbols)
1252 AC_CHECK_LIB(exc, trace_back_stack)
1254 # Note that all the libunwind symbols in the API are defined to internal
1255 # platform-specific version, so we must include libunwind.h before checking
1256 # any of them.
1257 AC_MSG_CHECKING([for libunwind])
1258 save_LIBS=$LIBS
1259 if test x"$UNAME_P" = xunknown ; then
1260     # This probably won't link without the platform-specific libunwind.
1261     LIBS="$LIBS -lunwind"
1262 else
1263     # Add the platform-specific libunwind module. uname -p seems the most
1264     # plausible option and works for ia64, where libunwind is most useful.
1265     LIBS="$LIBS -lunwind -lunwind-$UNAME_P"
1268 AC_TRY_LINK(
1269     [
1270 #ifdef HAVE_LIBUNWIND_H
1271 #include <libunwind.h>
1272 #endif
1273     ],
1274     [
1275         unw_context_t ctx; unw_cursor_t cur;
1276         char buf[256]; unw_word_t off; 
1277         unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
1278         unw_get_proc_name(&cur, buf, sizeof(buf), &off);
1279     ],
1280     [
1281         AC_MSG_RESULT(yes)
1282         AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
1284         # If we have libunwind, test whether we also have libunwind-ptrace
1285         # which would let us unwind arbitrary processes.
1286         save_LIBS=$LIBS
1287         AC_CHECK_HEADERS(libunwind-ptrace.h)
1288         AC_CHECK_LIB(unwind-ptrace, _UPT_create,
1289             [
1290                 LIBUNWIND_PTRACE="-lunwind-ptrace";
1291                 AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
1292                     [Whether libunwind-ptrace.a is available.])
1293             ],
1294             [ LIBUNWIND_PTRACE="" ])
1296         LIBS=$save_LIBS
1297     ],
1298     [
1299         AC_MSG_RESULT(no)
1300         LIBS=$save_LIBS
1301     ])
1303 # To use libunwind-ptrace, we also need to make some ptrace system calls.
1304 if test x"$LIBUNWIND_PTRACE" != x"" ; then
1305     AC_CHECK_HEADERS(sys/ptrace.h)
1306     AC_MSG_CHECKING([for the Linux ptrace(2) interface])
1307     AC_TRY_LINK(
1308             [
1309 #if HAVE_SYS_TYPES_H
1310 #include <sys/types.h>
1311 #endif
1312 #if HAVE_SYS_PTRACE_H
1313 #include <sys/ptrace.h>
1314 #endif
1315             ],
1316             [
1317                 int main(int argc, const char ** argv)
1318                 {
1319                         pid_t me = (pid_t)-1;
1320                         ptrace(PTRACE_ATTACH, me, 0, 0);
1321                         ptrace(PTRACE_DETACH, me, 0, 0);
1322                         return 0;
1323                 }
1324             ],
1325             [
1326                 AC_MSG_RESULT(yes)
1327                 AC_DEFINE(HAVE_LINUX_PTRACE, 1,
1328                     [Whether the Linux ptrace(2) interface is available.])
1329             ],
1330             [
1331                 AC_MSG_RESULT(no)
1332                 LIBUNWIND_PTRACE=""
1333             ])
1336 AC_SUBST(LIBUNWIND_PTRACE)
1338 # syscall() is needed for smbwrapper.
1339 AC_CHECK_FUNCS(syscall)
1341 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1342 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1343 AC_CHECK_FUNCS(__getcwd _getcwd)
1344 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1345 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1346 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1347 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1348 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
1349 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1350 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1351 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1352 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1353 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1354 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1355 AC_CHECK_FUNCS(prctl)
1357 AC_TRY_COMPILE([
1358 #ifdef HAVE_SYS_PRCTL_H
1359 #include <sys/prctl.h>
1360 #endif
1362 [int i; i = prtcl(0); ],
1363 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
1368 case "$host_os" in
1369     *linux*)
1370        # glibc <= 2.3.2 has a broken getgrouplist
1371        AC_TRY_RUN([
1372 #include <unistd.h>
1373 #include <sys/utsname.h>
1374 main() {
1375        /* glibc up to 2.3 has a broken getgrouplist */
1376 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1377        int libc_major = __GLIBC__;
1378        int libc_minor = __GLIBC_MINOR__;
1380        if (libc_major < 2)
1381               exit(1);
1382        if ((libc_major == 2) && (libc_minor <= 3))
1383               exit(1);
1384 #endif
1385        exit(0);
1387 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1388        if test x"$linux_getgrouplist_ok" = x"yes"; then
1389           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1390        fi
1391        ;;
1392     *)
1393        AC_CHECK_FUNCS(getgrouplist)
1394        ;;
1395 esac
1398 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1401 if test x$ac_cv_func_stat64 = xno ; then
1402   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1403   AC_TRY_LINK([
1404 #if defined(HAVE_UNISTD_H)
1405 #include <unistd.h>
1406 #endif
1407 #include <sys/stat.h>
1408 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1409   AC_MSG_RESULT([$ac_cv_func_stat64])
1410   if test x$ac_cv_func_stat64 = xyes ; then
1411     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1412   fi
1415 if test x$ac_cv_func_lstat64 = xno ; then
1416   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1417   AC_TRY_LINK([
1418 #if defined(HAVE_UNISTD_H)
1419 #include <unistd.h>
1420 #endif
1421 #include <sys/stat.h>
1422 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1423   AC_MSG_RESULT([$ac_cv_func_lstat64])
1424   if test x$ac_cv_func_lstat64 = xyes ; then
1425     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1426   fi
1429 if test x$ac_cv_func_fstat64 = xno ; then
1430   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1431   AC_TRY_LINK([
1432 #if defined(HAVE_UNISTD_H)
1433 #include <unistd.h>
1434 #endif
1435 #include <sys/stat.h>
1436 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1437   AC_MSG_RESULT([$ac_cv_func_fstat64])
1438   if test x$ac_cv_func_fstat64 = xyes ; then
1439     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1440   fi
1443 #################################################
1444 # Check whether struct stat has timestamps with sub-second resolution.
1445 # At least IRIX and Solaris have these.
1447 # We check that 
1448 #       all of st_mtim, st_atim and st_ctim exist
1449 #       all of the members are in fact of type struct timespec
1451 # There is some conflicting standards weirdness about whether we should use
1452 # "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we
1453 # prefer struct timespec.
1455 AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_stat_hires,
1456     [
1457         AC_TRY_COMPILE(
1458             [
1459 #if TIME_WITH_SYS_TIME
1460 # include <sys/time.h>
1461 # include <time.h>
1462 #else
1463 # if HAVE_SYS_TIME_H
1464 #  include <sys/time.h>
1465 # else
1466 #  include <time.h>
1467 # endif
1468 #endif
1469 #ifdef HAVE_SYS_STAT_H
1470 #include <sys/stat.h>
1471 #endif
1472             ],
1473             [
1474                 struct timespec t;
1475                 struct stat s = {0};
1476                 t.tv_sec = s.st_mtim.tv_sec;
1477                 t.tv_nsec = s.st_mtim.tv_nsec;
1478                 t.tv_sec = s.st_ctim.tv_sec;
1479                 t.tv_nsec = s.st_ctim.tv_nsec;
1480                 t.tv_sec = s.st_atim.tv_sec;
1481                 t.tv_nsec = s.st_atim.tv_nsec;
1482             ],
1483             samba_stat_hires=yes, samba_stat_hires=no)
1484     ])
1486 if test x"$samba_stat_hires" = x"yes" ; then
1487     AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim])
1488     AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim])
1489     AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim])
1490     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1491             [whether struct stat has sub-second timestamps])
1494 AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_stat_hires_notimespec,
1495     [
1496         AC_TRY_COMPILE(
1497             [
1498 #if TIME_WITH_SYS_TIME
1499 # include <sys/time.h>
1500 # include <time.h>
1501 #else
1502 # if HAVE_SYS_TIME_H
1503 #  include <sys/time.h>
1504 # else
1505 #  include <time.h>
1506 # endif
1507 #endif
1508 #ifdef HAVE_SYS_STAT_H
1509 #include <sys/stat.h>
1510 #endif
1511             ],
1512             [
1513                 struct timespec t;
1514                 struct stat s = {0};
1515                 t.tv_sec = s.st_mtime;
1516                 t.tv_nsec = s.st_mtimensec;
1517                 t.tv_sec = s.st_ctime;
1518                 t.tv_nsec = s.st_ctimensec;
1519                 t.tv_sec = s.st_atime;
1520                 t.tv_nsec = s.st_atimensec;
1521             ],
1522             samba_stat_hires=yes, samba_stat_hires=no)
1523     ])
1525 if test x"$samba_stat_hires_notimespec" = x"yes" ; then
1526     AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
1527     AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
1528     AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
1529     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
1530             [whether struct stat has sub-second timestamps without struct timespec])
1533 #####################################
1534 # needed for SRV lookups
1535 AC_CHECK_LIB(resolv, dn_expand)
1536 AC_CHECK_LIB(resolv, _dn_expand)
1537 AC_CHECK_LIB(resolv, __dn_expand)
1540 # Check for the functions putprpwnam, set_auth_parameters,
1541 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1542 # Needed for OSF1 and HPUX.
1545 AC_LIBTESTFUNC(security, putprpwnam)
1546 AC_LIBTESTFUNC(sec, putprpwnam)
1548 AC_LIBTESTFUNC(security, set_auth_parameters)
1549 AC_LIBTESTFUNC(sec, set_auth_parameters)
1551 # UnixWare 7.x has its getspnam in -lgen
1552 AC_LIBTESTFUNC(gen, getspnam)
1554 AC_LIBTESTFUNC(security, getspnam)
1555 AC_LIBTESTFUNC(sec, getspnam)
1557 AC_LIBTESTFUNC(security, bigcrypt)
1558 AC_LIBTESTFUNC(sec, bigcrypt)
1560 AC_LIBTESTFUNC(security, getprpwnam)
1561 AC_LIBTESTFUNC(sec, getprpwnam)
1563 AC_CHECK_FUNCS(strsignal)
1565 ############################################
1566 # Check if we have libattr
1567 case "$host_os" in
1568   *osf*)
1569         AC_SEARCH_LIBS(getproplist, [proplist])
1570         AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
1571         AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
1572         AC_CHECK_FUNCS(sizeof_proplist_entry)
1573   ;;
1574   *)
1575         AC_SEARCH_LIBS(getxattr, [attr])
1576         AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1577         AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
1578         AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
1579         AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1580         AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1581         AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1582         AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1583   ;;
1584 esac
1586 # Check if we have extattr
1587 case "$host_os" in
1588   *freebsd4* | *dragonfly* )
1589     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1590     ;;
1591   *)
1592     AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
1593     AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
1594     AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
1595     AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
1596     ;;
1597 esac
1599 # Assume non-shared by default and override below
1600 BLDSHARED="false"
1602 # these are the defaults, good for lots of systems
1603 HOST_OS="$host_os"
1604 LDSHFLAGS="-shared"
1605 SONAMEFLAG="#"
1606 NSSSONAMEVERSIONSUFFIX=""
1607 SHLD="\${CC} \${CFLAGS}"
1608 PICFLAGS=""
1609 PICSUFFIX="po"
1610 SHLIBEXT="so"
1612 if test "$enable_shared" = "yes"; then
1613   # this bit needs to be modified for each OS that is suported by
1614   # smbwrapper. You need to specify how to create a shared library and
1615   # how to compile C code to produce PIC object files
1617   AC_MSG_CHECKING([ability to build shared libraries])
1619   # and these are for particular systems
1620   case "$host_os" in
1621                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1622                         BLDSHARED="true"
1623                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1624                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
1625                         else
1626                                 LDSHFLAGS="-shared -Wl,-Bsymbolic" 
1627                         fi
1628                         DYNEXP="-Wl,--export-dynamic"
1629                         PICFLAGS="-fPIC"
1630                         SONAMEFLAG="-Wl,-soname="
1631                         NSSSONAMEVERSIONSUFFIX=".2"
1632                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1633                         ;;
1634                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1635                         BLDSHARED="true"
1636                         LDSHFLAGS="-G"
1637                         SONAMEFLAG="-h "
1638                         if test "${GCC}" = "yes"; then
1639                                 PICFLAGS="-fPIC"
1640                                 SONAMEFLAG="-Wl,-soname="
1641                                 NSSSONAMEVERSIONSUFFIX=".1"
1642                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1643                                         DYNEXP="-Wl,-E"
1644                                 fi
1645                         else
1646                                 PICFLAGS="-KPIC"
1647                                 ## ${CFLAGS} added for building 64-bit shared 
1648                                 ## libs using Sun's Compiler
1649                                 LDSHFLAGS="-G \${CFLAGS}"
1650                                 PICSUFFIX="po.o"
1651                         fi
1652                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1653                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1654                         ;;
1655                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1656                         BLDSHARED="true"
1657                         LDSHFLAGS="-G"
1658                         SONAMEFLAG="-Wl,-h,"
1659                         PICFLAGS="-KPIC"   # Is this correct for SunOS
1660                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1661                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1662                         ;;
1663                 *netbsd* | *freebsd* | *dragonfly* )  
1664                         BLDSHARED="true"
1665                         LDSHFLAGS="-shared"
1666                         DYNEXP="-Wl,--export-dynamic"
1667                         SONAMEFLAG="-Wl,-soname,"
1668                         PICFLAGS="-fPIC -DPIC"
1669                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1670                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1671                         ;;
1672                 *openbsd*)  BLDSHARED="true"
1673                         LDSHFLAGS="-shared"
1674                         DYNEXP="-Wl,-Bdynamic"
1675                         SONAMEFLAG="-Wl,-soname,"
1676                         PICFLAGS="-fPIC"
1677                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1678                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1679                         ;;
1680                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1681                         case "$host_os" in
1682                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1683                         ;;
1684                         esac
1685                         BLDSHARED="true"
1686                         LDSHFLAGS="-set_version sgi1.0 -shared"
1687                         SONAMEFLAG="-soname "
1688                         SHLD="\${LD}"
1689                         if test "${GCC}" = "yes"; then
1690                                 PICFLAGS="-fPIC"
1691                         else 
1692                                 PICFLAGS="-KPIC"
1693                         fi
1694                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1695                         ;;
1696                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1697                         BLDSHARED="true"
1698                         LDSHFLAGS="-Wl,-G,-bexpall"
1699                         DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
1700                         PICFLAGS="-O2"
1701                         if test "${GCC}" != "yes"; then
1702                                 ## for funky AIX compiler using strncpy()
1703                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1704                         fi
1706                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1707                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1708                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1709                         ;;
1710                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1711                         # Use special PIC flags for the native HP-UX compiler.
1712                         if test $ac_cv_prog_cc_Ae = yes; then
1713                                 BLDSHARED="true"
1714                                 SHLD="cc"
1715                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1716                                 SONAMEFLAG="-Wl,+h "
1717                                 PICFLAGS="+z"
1718                         elif test "${GCC}" = "yes"; then
1719                                 PICFLAGS="-fPIC"
1720                         fi
1721                         if test "$host_cpu" = "ia64"; then
1722                                 SHLIBEXT="so"
1723                                 DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
1724                         else
1725                                 SHLIBEXT="sl"
1726                                 DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
1727                         fi
1728                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1729                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1730                         ;;
1731                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1732                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1733                         ;;
1734                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1735                         BLDSHARED="true"
1736                         LDSHFLAGS="-shared"
1737                         SONAMEFLAG="-Wl,-soname,"
1738                         PICFLAGS="-fPIC"
1739                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1740                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1741                         ;;
1742                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1743                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1744                         ;;
1745                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1746                         BLDSHARED="true"
1747                         LDSHFLAGS="-shared"
1748                         SONAMEFLAG="-Wl,-soname,"
1749                         PICFLAGS="-KPIC"
1750                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1751                         ;;
1752                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1753                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1754                         ;;
1755                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1756                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1757                         ;;
1758                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1759                         case "$host" in
1760                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1761                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1762                                         fi
1763                                         LDSHFLAGS="-G"
1764                                         DYNEXP="-Bexport"
1765                                 ;;
1766                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1767                         esac
1768                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1769                         ;;
1771                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1772                         if [ test "$GCC" != yes ]; then
1773                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1774                         fi
1775                         LDSHFLAGS="-G"
1776                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1777                         ;;
1778                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1779                         BLDSHARED="false"
1780                         LDSHFLAGS=""
1781                         ;;
1783                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1784                         BLDSHARED="true"
1785                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1786                         SHLIBEXT="dylib"
1787                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1788                         ;;
1790                 *)
1791                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1792                         ;;
1793   esac
1794   AC_SUBST(DYNEXP)
1795   AC_MSG_RESULT($BLDSHARED)
1796   AC_MSG_CHECKING([linker flags for shared libraries])
1797   AC_MSG_RESULT([$LDSHFLAGS])
1798   AC_MSG_CHECKING([compiler flags for position-independent code])
1799   AC_MSG_RESULT([$PICFLAGS])
1802 #######################################################
1803 # test whether building a shared library actually works
1804 if test $BLDSHARED = true; then
1805 AC_CACHE_CHECK([whether building shared libraries actually works], 
1806                [ac_cv_shlib_works],[
1807    # try building a trivial shared library
1808    ac_cv_shlib_works=no
1809    # The $SHLD and $LDSHFLAGS variables may contain references to other
1810    # variables so they need to be eval'ed.
1811    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
1812         shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
1813    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1814         shlib.$PICSUFFIX && ac_cv_shlib_works=yes
1815    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
1817 if test $ac_cv_shlib_works = no; then
1818    BLDSHARED=false
1822 ################
1824 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1825 AC_TRY_RUN([#include <stdio.h>
1826 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1827 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1828 if test x"$samba_cv_have_longlong" = x"yes"; then
1829     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1833 # Check if the compiler supports the LL prefix on long long integers.
1834 # AIX needs this.
1836 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1837     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1838         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1839 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1840    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1843   
1844 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1845 AC_TRY_RUN([#include <stdio.h>
1846 #include <sys/stat.h>
1847 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1848 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1849 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1850     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1853 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1854 AC_TRY_RUN([
1855 #if defined(HAVE_UNISTD_H)
1856 #include <unistd.h>
1857 #endif
1858 #include <stdio.h>
1859 #include <sys/stat.h>
1860 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1861 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1862 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1863     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1866 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1867 AC_TRY_RUN([
1868 #if defined(HAVE_UNISTD_H)
1869 #include <unistd.h>
1870 #endif
1871 #include <stdio.h>
1872 #include <sys/stat.h>
1873 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1874 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1875 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1876     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1879 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1880 AC_TRY_RUN([
1881 #if defined(HAVE_UNISTD_H)
1882 #include <unistd.h>
1883 #endif
1884 #include <stdio.h>
1885 #include <sys/stat.h>
1886 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1887 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1888 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1889     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1892 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
1893 AC_TRY_RUN([
1894 #if defined(HAVE_UNISTD_H)
1895 #include <unistd.h>
1896 #endif
1897 #include <stdio.h>
1898 #include <sys/stat.h>
1899 main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
1900 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
1901 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
1902     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
1905 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1906 AC_TRY_RUN([
1907 #if defined(HAVE_UNISTD_H)
1908 #include <unistd.h>
1909 #endif
1910 #include <stdio.h>
1911 #include <sys/stat.h>
1912 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1913 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1914 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1915     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1918 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
1919 AC_TRY_COMPILE([
1920 #if defined(HAVE_UNISTD_H)
1921 #include <unistd.h>
1922 #endif
1923 #include <sys/types.h>
1924 #include <dirent.h>],
1925 [DIR64 de;],
1926 samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
1927 if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1928     AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
1931 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1932 AC_TRY_COMPILE([
1933 #if defined(HAVE_UNISTD_H)
1934 #include <unistd.h>
1935 #endif
1936 #include <sys/types.h>
1937 #include <dirent.h>],
1938 [struct dirent64 de;],
1939 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1940 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1941     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1944 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1945 AC_TRY_RUN([
1946 #if defined(HAVE_UNISTD_H)
1947 #include <unistd.h>
1948 #endif
1949 #include <sys/types.h>
1950 main() { dev_t dev; int i = major(dev); return 0; }],
1951 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1952 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1953     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1956 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1957 AC_TRY_RUN([
1958 #if defined(HAVE_UNISTD_H)
1959 #include <unistd.h>
1960 #endif
1961 #include <sys/types.h>
1962 main() { dev_t dev; int i = minor(dev); return 0; }],
1963 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1964 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1965     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1968 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1969 AC_TRY_RUN([
1970 #if defined(HAVE_UNISTD_H)
1971 #include <unistd.h>
1972 #endif
1973 #include <sys/types.h>
1974 main() { dev_t dev = makedev(1,2); return 0; }],
1975 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1976 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1977     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1980 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1981 AC_TRY_RUN([#include <stdio.h>
1982 main() { char c; c=250; exit((c > 0)?0:1); }],
1983 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1984 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1985     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1988 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1989 AC_TRY_COMPILE([#include <sys/types.h>
1990 #include <sys/socket.h>
1991 #include <netinet/in.h>],
1992 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1993 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1994 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1995     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1998 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1999 AC_TRY_COMPILE([#include <sys/types.h>
2000 #include <dirent.h>
2001 void seekdir(DIR *d, long loc) { return; }],[return 0;],
2002 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
2003 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
2004     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
2007 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
2008 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
2009 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
2010 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
2011     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
2014 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
2015 AC_TRY_RUN([
2016 #include <sys/time.h>
2017 #include <unistd.h>
2018 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
2019            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
2020 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
2021     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
2024 AC_LIBTESTFUNC(rt, clock_gettime)
2026 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
2027 AC_TRY_LINK([#include <stdarg.h>
2028 va_list ap1,ap2;], [va_copy(ap1,ap2);],
2029 samba_cv_HAVE_VA_COPY=yes,
2030 samba_cv_HAVE_VA_COPY=no)])
2031 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
2032     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
2033 else
2034     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
2035     AC_TRY_LINK([#include <stdarg.h>
2036     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
2037     samba_cv_HAVE___VA_COPY=yes,
2038     samba_cv_HAVE___VA_COPY=no)])
2039     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
2040         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
2041     fi
2044 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
2045 AC_TRY_RUN([
2046 #include <sys/types.h>
2047 #include <stdarg.h>
2048 void foo(const char *format, ...) { 
2049        va_list ap;
2050        int len;
2051        char buf[5];
2053        va_start(ap, format);
2054        len = vsnprintf(buf, 0, format, ap);
2055        va_end(ap);
2056        if (len != 5) exit(1);
2058        va_start(ap, format);
2059        len = vsnprintf(0, 0, format, ap);
2060        va_end(ap);
2061        if (len != 5) exit(1);
2063        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
2065        exit(0);
2067 main() { foo("hello"); }
2069 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
2070 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
2071     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
2074 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
2075 AC_TRY_RUN([#include <sys/types.h>
2076 #include <dirent.h>
2077 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
2078 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
2079 di->d_name[0] == 0) exit(0); exit(1);} ],
2080 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
2081 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
2082     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
2085 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
2086 AC_TRY_COMPILE([#include <sys/types.h>
2087 #include <utime.h>],
2088 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
2089 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
2090 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
2091     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
2094 ##############
2095 # Check utmp details, but only if our OS offers utmp.h
2096 if test x"$ac_cv_header_utmp_h" = x"yes"; then
2097 dnl  utmp and utmpx come in many flavours
2098 dnl  We need to check for many of them
2099 dnl  But we don't need to do each and every one, because our code uses
2100 dnl  mostly just the utmp (not utmpx) fields.
2102 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
2104 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
2105 AC_TRY_COMPILE([#include <sys/types.h>
2106 #include <utmp.h>],
2107 [struct utmp ut;  ut.ut_name[0] = 'a';],
2108 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
2109 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
2110     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
2111 fi 
2113 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
2114 AC_TRY_COMPILE([#include <sys/types.h>
2115 #include <utmp.h>],
2116 [struct utmp ut;  ut.ut_user[0] = 'a';],
2117 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
2118 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
2119     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
2120 fi 
2122 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
2123 AC_TRY_COMPILE([#include <sys/types.h>
2124 #include <utmp.h>],
2125 [struct utmp ut;  ut.ut_id[0] = 'a';],
2126 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
2127 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
2128     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
2129 fi 
2131 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
2132 AC_TRY_COMPILE([#include <sys/types.h>
2133 #include <utmp.h>],
2134 [struct utmp ut;  ut.ut_host[0] = 'a';],
2135 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
2136 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
2137     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
2138 fi 
2140 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
2141 AC_TRY_COMPILE([#include <sys/types.h>
2142 #include <utmp.h>],
2143 [struct utmp ut;  time_t t; ut.ut_time = t;],
2144 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
2145 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
2146     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
2147 fi 
2149 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
2150 AC_TRY_COMPILE([#include <sys/types.h>
2151 #include <utmp.h>],
2152 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
2153 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
2154 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
2155     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
2156 fi 
2158 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
2159 AC_TRY_COMPILE([#include <sys/types.h>
2160 #include <utmp.h>],
2161 [struct utmp ut;  ut.ut_type = 0;],
2162 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
2163 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
2164     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
2165 fi 
2167 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
2168 AC_TRY_COMPILE([#include <sys/types.h>
2169 #include <utmp.h>],
2170 [struct utmp ut;  ut.ut_pid = 0;],
2171 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
2172 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
2173     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
2174 fi 
2176 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
2177 AC_TRY_COMPILE([#include <sys/types.h>
2178 #include <utmp.h>],
2179 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
2180 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
2181 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
2182     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
2183 fi 
2185 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
2186 AC_TRY_COMPILE([#include <sys/types.h>
2187 #include <utmp.h>],
2188 [struct utmp ut;  ut.ut_addr = 0;],
2189 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
2190 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
2191     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
2192 fi 
2194 if test x$ac_cv_func_pututline = xyes ; then
2195   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
2196   AC_TRY_COMPILE([#include <sys/types.h>
2197 #include <utmp.h>],
2198   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
2199   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
2200   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
2201       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
2202   fi
2205 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
2206 AC_TRY_COMPILE([#include <sys/types.h>
2207 #include <utmpx.h>],
2208 [struct utmpx ux;  ux.ut_syslen = 0;],
2209 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
2210 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
2211     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
2212 fi 
2215 # end utmp details
2218 ICONV_LOCATION=standard
2219 LOOK_DIRS="/usr /usr/local /sw /opt"
2220 AC_ARG_WITH(libiconv,
2221 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
2223   if test "$withval" = "no" ; then
2224     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
2225   else
2226      if test "$withval" != "yes" ; then
2227         ICONV_PATH_SPEC=yes
2228         LOOK_DIRS="$withval"
2229      fi
2230   fi
2233 for i in $LOOK_DIRS ; do
2234     save_LIBS=$LIBS
2235     save_LDFLAGS=$LDFLAGS
2236     save_CPPFLAGS=$CPPFLAGS
2237     ICONV_FOUND="no"
2238     unset libext
2239     CPPFLAGS="$CPPFLAGS -I$i/include"
2240 dnl This is here to handle -withval stuff for --with-libiconv
2241 dnl Perhaps we should always add a -L
2243 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
2244 dnl installation paths. This gets a little tricky since we might have iconv
2245 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
2246 dnl succeed when the header is found. To counter this, make sure the 
2247 dnl library directory is there and check the ABI directory first (which
2248 dnl should be harmless on other systems.
2249 dnl For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
2250     for l in "lib32" "lib" "lib/hpux32"; do
2251         if test -d "$i/$l" ; then
2252                 LDFLAGS="$save_LDFLAGS -L$i/$l"
2253         LIBS=
2254         export LDFLAGS LIBS CPPFLAGS
2255 dnl Try to find iconv(3)
2256                 jm_ICONV($i/$l)
2257                 if test x"$ICONV_FOUND" = "xyes" ; then
2258             libext="$l"
2259             break;
2260         fi
2261         fi
2262     done
2264     if test x"$ICONV_FOUND" = "xyes" ; then
2265         LDFLAGS=$save_LDFLAGS
2266         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
2267         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
2268         LIBS="$save_LIBS"
2269         ICONV_LOCATION=$i
2270         export LDFLAGS LIBS CPPFLAGS
2271 dnl Now, check for a working iconv ... we want to do it here because
2272 dnl there might be a working iconv further down the list of LOOK_DIRS
2274         ############
2275         # check for iconv in libc
2276         ic_save_LIBS="$LIBS"
2277         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
2278            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
2279         fi
2280         if test x"$jm_cv_lib_iconv" != x; then
2281            LIBS="$LIBS -l$jm_cv_lib_iconv"
2282         fi
2283 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
2284         default_dos_charset=no
2285         default_display_charset=no
2286         default_unix_charset=no
2288         # check for default dos charset name
2289         for j in CP850 IBM850 ; do
2290             rjs_CHARSET($j)
2291             if test x"$ICONV_CHARSET" = x"$j"; then
2292                 default_dos_charset="\"$j\""
2293                 break
2294             fi
2295         done
2296         # check for default display charset name
2297         for j in ASCII 646 ; do
2298             rjs_CHARSET($j)
2299             if test x"$ICONV_CHARSET" = x"$j"; then
2300                 default_display_charset="\"$j\""
2301                 break
2302             fi
2303         done
2304         # check for default unix charset name
2305         for j in UTF-8 UTF8 ; do
2306             rjs_CHARSET($j)
2307             if test x"$ICONV_CHARSET" = x"$j"; then
2308                 default_unix_charset="\"$j\""
2309                 break
2310             fi
2311         done
2312         
2313         if test "$default_dos_charset" != "no" -a \
2314                 "$default_dos_charset" != "cross" -a \
2315                 "$default_display_charset" != "no" -a \ 
2316                 "$default_display_charset" != "cross" -a \
2317                 "$default_unix_charset" != "no" -a \
2318                 "$default_unix_charset" != "cross"
2319         then
2320                 samba_cv_HAVE_NATIVE_ICONV=yes
2321         else if test "$default_dos_charset" = "cross" -o \
2322                      "$default_display_charset" = "cross" -o \
2323                      "$default_unix_charset" = "cross"
2324         then
2325                 samba_cv_HAVE_NATIVE_ICONV=cross
2326         else
2327                 samba_cv_HAVE_NATIVE_ICONV=no
2328         fi
2329         fi
2330 dnl ])
2332         LIBS="$ic_save_LIBS"
2333         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
2334            CPPFLAGS=$save_CPPFLAGS
2335            LDFLAGS=$save_LDFLAGS
2336            LIBS=$save_LIBS
2337            if test x"$jm_cv_lib_iconv" != x; then
2338               LIBS="$LIBS -l$jm_cv_lib_iconv"
2339            fi
2340            dnl Add the flags we need to CPPFLAGS and LDFLAGS
2341            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
2342            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
2343            export CPPFLAGS
2344            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
2345            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
2346            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
2347            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
2348            break
2349         fi
2350 dnl We didn't find a working iconv, so keep going
2351     fi
2352 dnl We only need to clean these up here for the next pass through the loop
2353     CPPFLAGS=$save_CPPFLAGS
2354     LDFLAGS=$save_LDFLAGS
2355     LIBS=$save_LIBS
2356     export LDFLAGS LIBS CPPFLAGS
2357 done
2358 unset libext
2361 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
2362     AC_MSG_WARN([Sufficient support for iconv function was not found. 
2363     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
2364    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
2365    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
2366    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
2370 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
2371 AC_TRY_RUN([
2372 #include <sys/types.h>
2373 #include <fcntl.h>
2374 #ifndef F_GETLEASE
2375 #define F_GETLEASE      1025
2376 #endif
2377 main() {
2378        int fd = open("/dev/null", O_RDONLY);
2379        return fcntl(fd, F_GETLEASE, 0) == -1;
2382 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
2383 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
2384     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
2387 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
2388 AC_TRY_RUN([
2389 #include <sys/types.h>
2390 #include <fcntl.h>
2391 #include <signal.h>
2392 #ifndef F_NOTIFY
2393 #define F_NOTIFY 1026
2394 #endif
2395 main() {
2396         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
2399 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
2400 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
2401     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
2404 #################################################
2405 # Check if FAM notifications are available. For FAM info, see
2406 #       http://oss.sgi.com/projects/fam/
2407 #       http://savannah.nongnu.org/projects/fam/
2409 AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
2410 if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
2411     # On IRIX, libfam requires libC, but other FAM implementations might not
2412     # need it.
2413     AC_CHECK_LIB(fam, FAMOpen2,
2414             [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam"],
2415             [samba_cv_HAVE_LIBFAM=no])
2417     if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
2418         samba_fam_xtra=-lC
2419         AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
2420                 [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam -lC"],
2421                 [samba_cv_HAVE_LIBFAM=no])
2422         unset samba_fam_xtra
2423     fi
2426 if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
2427     AC_DEFINE(HAVE_FAM_CHANGE_NOTIFY, 1,
2428             [Whether FAM is file notifications are available])
2429     AC_TRY_COMPILE([#include <fam.h>],
2430                 [FAMCodes code = FAMChanged;],
2431                 AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
2432                     [Whether fam.h contains a typedef for enum FAMCodes]),
2433                 [])
2436 #################################################
2437 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
2439 AC_CHECK_LIB(dm, dm_get_eventlist,
2440         [samba_cv_HAVE_LIBDM=yes; samba_dmapi_libs="-ldm"],
2441         [samba_cv_HAVE_LIBDM=no])
2443 if test x"$samba_cv_HAVE_LIBDM" = x"yes" ; then
2444         AC_DEFINE(HAVE_LIBDM, 1, [Whether dmapi libdm is available])
2447 AC_CHECK_LIB(jfsdm, dm_get_eventlist,
2448         [samba_cv_HAVE_LIBJFSDM=yes; samba_dmapi_libs="-ljfsdm"],
2449         [samba_cv_HAVE_LIBJFSDM=no])
2451 if test x"$samba_cv_HAVE_LIBJFSDM" = x"yes" ; then
2452         AC_DEFINE(HAVE_LIBJFSDM, 1, [Whether dmapi libjfsdm is available])
2455 AC_CHECK_LIB(xdsm, dm_get_eventlist,
2456         [samba_cv_HAVE_LIBXDSM=yes; samba_dmapi_libs="-lxdsm"],
2457         [samba_cv_HAVE_LIBXDSM=no])
2459 if test x"$samba_cv_HAVE_LIBXDSM" = x"yes" ; then
2460         AC_DEFINE(HAVE_LIBXDSM, 1, [Whether dmapi libxdsm is available])
2463 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
2464 AC_TRY_RUN([
2465 #include <sys/types.h>
2466 #include <fcntl.h>
2467 #include <signal.h>
2468 #include <sys/file.h>
2469 #ifndef LOCK_MAND
2470 #define LOCK_MAND       32
2471 #define LOCK_READ       64
2472 #endif
2473 main() {
2474         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
2477 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
2478 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
2479     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
2483 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
2484 AC_TRY_COMPILE([#include <sys/types.h>
2485 #include <fcntl.h>],
2486 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
2487 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
2488 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
2489     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
2492 #################################################
2493 # Check for POSIX capability support
2495 AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
2496     AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
2497     [], [])
2499 if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
2501     ac_save_LIBS=$LIBS
2502     AC_LIBTESTFUNC(cap, cap_get_proc)
2504     AC_CACHE_CHECK([for POSIX capabilities],
2505             samba_cv_HAVE_POSIX_CAPABILITIES,
2506             [
2507                 AC_TRY_RUN([
2508 #include <sys/types.h>
2509 #include <sys/capability.h>
2510 main() {
2511  cap_t cap;
2512  cap_value_t vals[1];
2513  if (!(cap = cap_get_proc()))
2514    exit(1);
2515  vals[0] = CAP_CHOWN;
2516  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
2517  cap_set_proc(cap);
2518  exit(0);
2520                 samba_cv_HAVE_POSIX_CAPABILITIES=yes,
2521                 samba_cv_HAVE_POSIX_CAPABILITIES=no,
2522                 samba_cv_HAVE_POSIX_CAPABILITIES=cross)
2523             ])
2525 if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
2526     AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
2527             [Whether POSIX capabilities are available])
2528 else
2529     LIBS=$ac_save_LIBS
2535 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2536 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2539 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2540 AC_TRY_COMPILE([#include <sys/types.h>
2541 #if defined(HAVE_RPC_RPC_H)
2542 #include <rpc/rpc.h>
2543 #endif],
2544 [int16 testvar;],
2545 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2546 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2547     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2550 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2551 AC_TRY_COMPILE([#include <sys/types.h>
2552 #if defined(HAVE_RPC_RPC_H)
2553 #include <rpc/rpc.h>
2554 #endif],
2555 [uint16 testvar;],
2556 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2557 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2558     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2561 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2562 AC_TRY_COMPILE([#include <sys/types.h>
2563 #if defined(HAVE_RPC_RPC_H)
2564 #include <rpc/rpc.h>
2565 #endif],
2566 [int32 testvar;],
2567 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2568 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2569     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2572 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2573 AC_TRY_COMPILE([#include <sys/types.h>
2574 #if defined(HAVE_RPC_RPC_H)
2575 #include <rpc/rpc.h>
2576 #endif],
2577 [uint32 testvar;],
2578 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2579 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2580     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2584 dnl Some systems (SCO) have a problem including
2585 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2586 dnl as a #define in <prot.h> and as part of an enum
2587 dnl in <rpc/rpc.h>.
2590 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2591 AC_TRY_COMPILE([#include <sys/types.h>
2592 #ifdef HAVE_SYS_SECURITY_H
2593 #include <sys/security.h>
2594 #include <prot.h>
2595 #endif  /* HAVE_SYS_SECURITY_H */
2596 #if defined(HAVE_RPC_RPC_H)
2597 #include <rpc/rpc.h>
2598 #endif],
2599 [int testvar;],
2600 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2601 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2602     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2605 AC_MSG_CHECKING([for test routines])
2606 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2607            AC_MSG_RESULT(yes),
2608            AC_MSG_ERROR([cant find test code. Aborting config]),
2609            AC_MSG_WARN([cannot run when cross-compiling]))
2611 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2612 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2613            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2614 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2615     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2618 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2619 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2620            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2621            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2622            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2623 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2624 then
2625     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2628 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2629 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2630            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2631 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2632     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2635 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
2636 SAVE_CPPFLAGS="$CPPFLAGS"
2637 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt"
2638 AC_TRY_COMPILE([
2639 #define REPLACE_GETPASS 1
2640 #define NO_PROTO_H 1
2641 #define NO_CONFIG_H 1
2642 #define main dont_declare_main
2643 #include "${srcdir-.}/lib/getsmbpass.c"
2644 #undef main
2645 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
2646 CPPFLAGS="$SAVE_CPPFLAGS"
2648 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
2649         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
2652 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
2653 AC_TRY_RUN([
2654 #include <stdio.h>
2655 #include <sys/types.h>
2656 #include <netinet/in.h>
2657 #ifdef HAVE_ARPA_INET_H
2658 #include <arpa/inet.h>
2659 #endif
2660 main() { struct in_addr ip; ip.s_addr = 0x12345678;
2661 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2662     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
2663 exit(1);}],
2664            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
2665 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
2666     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
2669 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2670 AC_TRY_RUN([#include <stdlib.h>
2671 #include <sys/types.h>
2672 #include <sys/stat.h>
2673 #include <unistd.h>
2674 main() { 
2675   struct stat st;
2676   char tpl[20]="/tmp/test.XXXXXX"; 
2677   int fd = mkstemp(tpl); 
2678   if (fd == -1) exit(1);
2679   unlink(tpl);
2680   if (fstat(fd, &st) != 0) exit(1);
2681   if ((st.st_mode & 0777) != 0600) exit(1);
2682   exit(0);
2684 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2685 samba_cv_HAVE_SECURE_MKSTEMP=no,
2686 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2687 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2688     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2691 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
2692         AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
2693                 [samba_cv_HAVE_BROKEN_READDIR=no],
2694                         [samba_cv_HAVE_BROKEN_READDIR=yes],
2695                         [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
2697 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
2698 AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
2699         AC_TRY_RUN([
2700 #include "${srcdir-.}/lib/repdir.c"
2701 #include "${srcdir-.}/tests/os2_delete.c"],
2702         samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
2705 if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then
2706         AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
2709 SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
2710 SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
2711 SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
2712 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
2714 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
2715 AC_TRY_RUN([main() { exit(getuid() != 0); }],
2716            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
2717 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
2718     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
2719 else
2720     AC_MSG_WARN(running as non-root will disable some tests)
2723 ##################
2724 # look for a method of finding the list of network interfaces
2725 iface=no;
2726 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2727 AC_TRY_RUN([
2728 #define HAVE_IFACE_AIX 1
2729 #define AUTOCONF_TEST 1
2730 #include "confdefs.h"
2731 #include "${srcdir-.}/lib/interfaces.c"],
2732            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2733 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2734     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2737 if test $iface = no; then
2738 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2739 AC_TRY_RUN([
2740 #define HAVE_IFACE_IFCONF 1
2741 #define AUTOCONF_TEST 1
2742 #include "confdefs.h"
2743 #include "${srcdir-.}/lib/interfaces.c"],
2744            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2745 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2746     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2750 if test $iface = no; then
2751 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2752 AC_TRY_RUN([
2753 #define HAVE_IFACE_IFREQ 1
2754 #define AUTOCONF_TEST 1
2755 #include "confdefs.h"
2756 #include "${srcdir-.}/lib/interfaces.c"],
2757            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2758 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2759     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2764 ################################################
2765 # look for a method of setting the effective uid
2766 seteuid=no;
2767 if test $seteuid = no; then
2768 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2769 AC_TRY_RUN([
2770 #define AUTOCONF_TEST 1
2771 #define USE_SETRESUID 1
2772 #include "confdefs.h"
2773 #include "${srcdir-.}/lib/util_sec.c"],
2774            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2775 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2776     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2781 if test $seteuid = no; then
2782 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2783 AC_TRY_RUN([
2784 #define AUTOCONF_TEST 1
2785 #define USE_SETREUID 1
2786 #include "confdefs.h"
2787 #include "${srcdir-.}/lib/util_sec.c"],
2788            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2789 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2790     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2794 if test $seteuid = no; then
2795 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2796 AC_TRY_RUN([
2797 #define AUTOCONF_TEST 1
2798 #define USE_SETEUID 1
2799 #include "confdefs.h"
2800 #include "${srcdir-.}/lib/util_sec.c"],
2801            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2802 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2803     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2807 if test $seteuid = no; then
2808 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2809 AC_TRY_RUN([
2810 #define AUTOCONF_TEST 1
2811 #define USE_SETUIDX 1
2812 #include "confdefs.h"
2813 #include "${srcdir-.}/lib/util_sec.c"],
2814            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2815 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2816     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2821 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
2822 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
2823            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
2824 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
2825     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
2828 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2829 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2830            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2831 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2832     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2835 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2836 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2837            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2838 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2839     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2841 else
2844 dnl Don't check for 64 bit fcntl locking if we know that the
2845 dnl glibc2.1 broken check has succeeded.
2846 dnl 
2848   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2849   AC_TRY_RUN([
2850 #if defined(HAVE_UNISTD_H)
2851 #include <unistd.h>
2852 #endif
2853 #include <stdio.h>
2854 #include <stdlib.h>
2856 #ifdef HAVE_FCNTL_H
2857 #include <fcntl.h>
2858 #endif
2860 #ifdef HAVE_SYS_FCNTL_H
2861 #include <sys/fcntl.h>
2862 #endif
2863 main() { struct flock64 fl64;
2864 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2865 exit(0);
2866 #else
2867 exit(1);
2868 #endif
2870        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2872   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2873       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2874   fi
2877 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2878 AC_TRY_COMPILE([#include <sys/types.h>
2879 #include <sys/stat.h>
2880 #include <unistd.h>],
2881 [struct stat st;  st.st_blocks = 0;],
2882 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2883 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2884     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2885 fi 
2887 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2888 AC_TRY_COMPILE([#include <sys/types.h>
2889 #include <sys/stat.h>
2890 #include <unistd.h>],
2891 [struct stat st;  st.st_blksize = 0;],
2892 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2893 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2894     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2897 case "$host_os" in
2898 *linux*)
2899 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
2900 AC_TRY_COMPILE([
2901 #ifdef HAVE_SYS_VFS_H
2902 #include <sys/vfs.h>
2903 #endif
2904 #ifdef HAVE_SYS_CAPABILITY_H
2905 #include <sys/capability.h>
2906 #endif
2907 ],[int i;],
2908    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2909 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2910    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2913 esac
2915 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2916 AC_TRY_COMPILE([
2917 #include <sys/types.h>
2918 #include <sys/acl.h>
2919 #if defined(HAVE_RPCSVC_NIS_H)
2920 #include <rpcsvc/nis.h>
2921 #endif],
2922 [int i;],
2923 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2924 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2925         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2928 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2929 AC_TRY_RUN([
2930 #include <stdio.h>
2931 #include <limits.h>
2932 main() {
2933         char *newpath = realpath("/tmp", NULL);
2934         exit ((newpath != NULL) ? 0 : 1);
2937 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2938 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2939     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2942 #################################################
2943 # check for smbwrapper support
2944 AC_MSG_CHECKING(whether to use smbwrapper)
2945 AC_ARG_WITH(smbwrapper,
2946 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
2947 [ case "$withval" in
2948   yes)
2949     AC_MSG_RESULT(yes)
2950     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
2951         WRAPPROG="bin/smbsh\$(EXEEXT)"
2952         WRAP="bin/smbwrapper.$SHLIBEXT"
2953         WRAP_OBJS="\$(SMBW_OBJ1) \$(SMBWRAPPER_OBJ1)"
2954         WRAP_INC="-I\$(srcdir)/smbwrapper"
2956 # Conditions under which smbwrapper should not be built.
2958         if test x"$PICFLAGS" = x; then
2959            echo No support for PIC code - disabling smbwrapper and smbsh
2960            WRAPPROG=""
2961            WRAP=""
2962            WRAP_OBJS=""
2963            WRAP_INC=""
2964         elif test x$ac_cv_func_syscall = xno; then
2965            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
2966            WRAPPROG=""
2967            WRAP=""
2968            WRAP_OBJS=""
2969            WRAP_INC=""
2970         fi
2971         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
2972         SMBWRAPPER="$WRAPPROG $WRAP"
2973         SMBWRAP_OBJS="$WRAP_OBJS"
2974         SMBWRAP_INC="$WRAP_INC"
2975     ;;
2976   *)
2977     AC_MSG_RESULT(no)
2978     ;;
2979   esac ],
2980   AC_MSG_RESULT(no)
2983 #################################################
2984 # check for AFS clear-text auth support
2985 samba_cv_WITH_AFS=no
2986 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2987 AC_ARG_WITH(afs,
2988 [  --with-afs              Include AFS clear-text auth support (default=no) ],
2989 [ case "$withval" in
2990   yes|auto)
2991     AC_MSG_RESULT($withval)
2992     samba_cv_WITH_AFS=$withval
2993     ;;
2994   *)
2995     AC_MSG_RESULT(no)
2996     ;;
2997   esac ],
2998   AC_MSG_RESULT(no)
3001 ####################################################
3002 # check for Linux-specific AFS fake-kaserver support
3003 samba_cv_WITH_FAKE_KASERVER=no
3004 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3005 AC_ARG_WITH(fake-kaserver,
3006 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
3007 [ case "$withval" in
3008   yes|auto)
3009     AC_MSG_RESULT($withval)
3010     samba_cv_WITH_FAKE_KASERVER=$withval
3011     ;;
3012   *)
3013     AC_MSG_RESULT(no)
3014     ;;
3015   esac ],
3016   AC_MSG_RESULT(no)
3019 #################################################
3020 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
3021 if test x"$samba_cv_WITH_AFS" != x"no" ||
3022    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
3024     # see if this box has the afs-headers in /usr/include/afs
3025     AC_MSG_CHECKING(for /usr/include/afs)
3026     if test -d /usr/include/afs; then
3027           CFLAGS="$CFLAGS -I/usr/include/afs"
3028           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
3029           AC_MSG_RESULT(yes)
3030     else
3031       AC_MSG_RESULT(no)
3032     fi
3033    
3034     # check for afs.h
3035     have_afs_headers=no
3036     AC_CHECK_HEADERS(afs.h afs/afs.h)
3037     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
3038         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
3039            test x"$samba_cv_WITH_AFS" = x"auto"; then
3040                 AC_MSG_WARN([AFS cannot be supported without afs.h])
3041         else
3042                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
3043         fi
3044     else
3045         have_afs_headers=yes
3046     fi
3049 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
3050     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
3053 #################################################
3054 # check whether to compile AFS/NT ACL mapping module
3055 samba_cv_WITH_VFS_AFSACL=no
3056 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
3057 AC_ARG_WITH(vfs-afsacl,
3058 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
3059 [ case "$withval" in
3060   yes|auto)
3061     AC_MSG_RESULT($withval)
3062     samba_cv_WITH_VFS_AFSACL=yes
3063     ;;
3064   *)
3065     AC_MSG_RESULT(no)
3066     ;;
3067   esac ],
3068   AC_MSG_RESULT(no)
3071 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
3072    default_shared_modules="$default_shared_modules vfs_afsacl"
3074         
3075 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
3076     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
3079 #################################################
3080 # check for the DFS clear-text auth system
3081 AC_MSG_CHECKING(whether to use DFS clear-text auth)
3082 AC_ARG_WITH(dfs,
3083 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
3084 [ case "$withval" in
3085   yes)
3086     AC_MSG_RESULT(yes)
3087     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
3088     ;;
3089   *)
3090     AC_MSG_RESULT(no)
3091     ;;
3092   esac ],
3093   AC_MSG_RESULT(no)
3096 ########################################################
3097 # Compile with LDAP support?
3099 with_ldap_support=auto
3100 AC_MSG_CHECKING([for LDAP support])
3102 AC_ARG_WITH(ldap,
3103 [  --with-ldap             LDAP support (default yes)],
3104 [ case "$withval" in
3105     yes|no)
3106         with_ldap_support=$withval
3107         ;;
3108   esac ])
3110 AC_MSG_RESULT($with_ldap_support)
3112 SMBLDAP=""
3113 AC_SUBST(SMBLDAP)
3114 SMBLDAPUTIL=""
3115 AC_SUBST(SMBLDAPUTIL)
3116 if test x"$with_ldap_support" != x"no"; then
3118   ##################################################################
3119   # first test for ldap.h and lber.h
3120   # (ldap.h is required for this test)
3121   AC_CHECK_HEADERS(ldap.h lber.h)
3122   
3123   if test x"$ac_cv_header_ldap_h" != x"yes"; then
3124         if test x"$with_ldap_support" = x"yes"; then
3125          AC_MSG_ERROR(ldap.h is needed for LDAP support)
3126         else
3127          AC_MSG_WARN(ldap.h is needed for LDAP support)
3128         fi
3129         
3130         with_ldap_support=no
3131   fi
3134 if test x"$with_ldap_support" != x"no"; then
3135   ac_save_LIBS=$LIBS
3137   ##################################################################
3138   # we might need the lber lib on some systems. To avoid link errors
3139   # this test must be before the libldap test
3140   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
3142   ########################################################
3143   # now see if we can find the ldap libs in standard paths
3144   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
3146   ########################################################
3147   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
3148   # Check found in pam_ldap 145.
3149   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
3151   LIBS="$LIBS $LDAP_LIBS"
3152   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
3153     AC_TRY_COMPILE([
3154         #include <lber.h>
3155         #include <ldap.h>], 
3156         [ldap_set_rebind_proc(0, 0, 0);], 
3157         [smb_ldap_cv_ldap_set_rebind_proc=3], 
3158         [smb_ldap_cv_ldap_set_rebind_proc=2]
3159     ) 
3160   ])
3161   
3162   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
3164   AC_CHECK_FUNC_EXT(ldap_dn2ad_canonical,$LDAP_LIBS)    
3165   
3166   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
3167     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
3168     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
3169     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
3170     default_shared_modules="$default_shared_modules";
3171     SMBLDAP="lib/smbldap.o"
3172     SMBLDAPUTIL="lib/smbldap_util.o"
3173     with_ldap_support=yes
3174     AC_MSG_CHECKING(whether LDAP support is used)
3175     AC_MSG_RESULT(yes)
3176   else
3177     if test x"$with_ldap_support" = x"yes"; then
3178         AC_MSG_ERROR(libldap is needed for LDAP support)
3179     else
3180         AC_MSG_WARN(libldap is needed for LDAP support)
3181     fi
3182     
3183     LDAP_LIBS=""
3184     with_ldap_support=no
3185   fi
3186   LIBS=$ac_save_LIBS
3190 #################################################
3191 # active directory support
3193 with_ads_support=auto
3194 AC_MSG_CHECKING([for Active Directory and krb5 support])
3196 AC_ARG_WITH(ads,
3197 [  --with-ads              Active Directory support (default auto)],
3198 [ case "$withval" in
3199     yes|no)
3200         with_ads_support="$withval"
3201         ;;
3202   esac ])
3204 AC_MSG_RESULT($with_ads_support)
3206 FOUND_KRB5=no
3207 KRB5_LIBS=""
3209 if test x"$with_ldap_support" != x"yes"; then
3211     if test x"$with_ads_support" = x"yes"; then
3212         AC_MSG_ERROR(Active Directory Support requires LDAP support)
3213     elif test x"$with_ads_support" = x"auto"; then
3214         AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
3215         with_ads_support=no
3216     fi
3218 else
3220     # Check to see whether there is enough LDAP functionality to be able
3221     # to build AD support.
3223     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
3225     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
3226         if test x"$with_ads_support" = x"yes"; then
3227             AC_MSG_ERROR(Active Directory support requires ldap_initialize)
3228         elif test x"$with_ads_support" = x"auto"; then
3229             AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
3230             with_ads_support=no
3231         fi
3232     fi
3234     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
3236     if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
3237         if test x"$with_ads_support" = x"yes"; then
3238             AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
3239         elif test x"$with_ads_support" = x"auto"; then
3240             AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
3241             with_ads_support=no
3242         fi
3243     fi
3247 if test x"$with_ads_support" != x"no"; then
3249   # Do no harm to the values of CFLAGS and LIBS while testing for
3250   # Kerberos support.
3252   if test x$FOUND_KRB5 = x"no"; then
3253     #################################################
3254     # check for location of Kerberos 5 install
3255     AC_MSG_CHECKING(for kerberos 5 install path)
3256     AC_ARG_WITH(krb5,
3257     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
3258     [ case "$withval" in
3259       no)
3260         AC_MSG_RESULT(no krb5-path given)
3261         ;;
3262       yes)
3263         AC_MSG_RESULT(/usr)
3264         FOUND_KRB5=yes
3265         ;;
3266       *)
3267         AC_MSG_RESULT($withval)
3268         KRB5_CFLAGS="-I$withval/include"
3269         KRB5_CPPFLAGS="-I$withval/include"
3270         KRB5_LDFLAGS="-L$withval/lib"
3271         FOUND_KRB5=yes
3272         if test -x "$withval/bin/krb5-config"; then
3273                 KRB5CONFIG=$withval/bin/krb5-config
3274         fi
3275         ;;
3276       esac ],
3277       AC_MSG_RESULT(no krb5-path given)
3278     )
3279   fi
3281   #################################################
3282   # check for krb5-config from recent MIT and Heimdal kerberos 5
3283   AC_PATH_PROG(KRB5CONFIG, krb5-config)
3284   AC_MSG_CHECKING(for working krb5-config)
3285   if test -x "$KRB5CONFIG"; then
3286     ac_save_CFLAGS=$CFLAGS
3287     CFLAGS="";export CFLAGS
3288     ac_save_LDFLAGS=$LDFLAGS
3289     LDFLAGS="";export LDFLAGS
3290     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
3291     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
3292     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
3293     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
3294     CFLAGS=$ac_save_CFLAGS;export CFLAGS
3295     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
3296     FOUND_KRB5=yes
3297     AC_MSG_RESULT(yes)
3298   else
3299     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
3300   fi
3302   if test x$FOUND_KRB5 = x"no"; then
3303     #################################################
3304     # see if this box has the SuSE location for the heimdal krb implementation
3305     AC_MSG_CHECKING(for /usr/include/heimdal)
3306     if test -d /usr/include/heimdal; then
3307       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
3308           KRB5_CFLAGS="-I/usr/include/heimdal"
3309           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3310           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
3311           AC_MSG_RESULT(yes)
3312       else
3313           KRB5_CFLAGS="-I/usr/include/heimdal"
3314           KRB5_CPPFLAGS="-I/usr/include/heimdal"
3315           AC_MSG_RESULT(yes)
3316       fi
3317     else
3318       AC_MSG_RESULT(no)
3319     fi
3320   fi
3322   if test x$FOUND_KRB5 = x"no"; then
3323     #################################################
3324     # see if this box has the RedHat location for kerberos
3325     AC_MSG_CHECKING(for /usr/kerberos)
3326     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
3327       KRB5_LDFLAGS="-L/usr/kerberos/lib"
3328       KRB5_CFLAGS="-I/usr/kerberos/include"
3329       KRB5_CPPFLAGS="-I/usr/kerberos/include"
3330       AC_MSG_RESULT(yes)
3331     else
3332       AC_MSG_RESULT(no)
3333     fi
3334   fi
3336   ac_save_CFLAGS=$CFLAGS
3337   ac_save_CPPFLAGS=$CPPFLAGS
3338   ac_save_LDFLAGS=$LDFLAGS
3340   CFLAGS="$KRB5_CFLAGS $CFLAGS"
3341   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
3342   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
3344   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
3346   # now check for krb5.h. Some systems have the libraries without the headers!
3347   # note that this check is done here to allow for different kerberos
3348   # include paths
3349   AC_CHECK_HEADERS(krb5.h)
3351   if test x"$ac_cv_header_krb5_h" = x"no"; then
3353     # Give a warning if AD support was not explicitly requested,
3354     # i.e with_ads_support = auto, otherwise die with an error.
3356     if test x"$with_ads_support" = x"yes"; then
3357       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
3358     else
3359       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
3360     fi
3362     # Turn off AD support and restore CFLAGS and LIBS variables
3364     with_ads_support="no"
3365     
3366     CFLAGS=$ac_save_CFLAGS
3367     CPPFLAGS=$ac_save_CPPFLAGS
3368     LDFLAGS=$ac_save_LDFLAGS
3369   fi
3372 # Now we have determined whether we really want ADS support
3374 if test x"$with_ads_support" != x"no"; then
3375   ac_save_LIBS=$LIBS
3377   # now check for gssapi headers.  This is also done here to allow for
3378   # different kerberos include paths
3379   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
3381   ##################################################################
3382   # we might need the k5crypto and com_err libraries on some systems
3383   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
3384   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
3386   # Heimdal checks.
3387   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
3388   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
3389   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
3391   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
3392   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
3393                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
3395   ########################################################
3396   # now see if we can find the krb5 libs in standard paths
3397   # or as specified above
3398   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
3399   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
3401   ########################################################
3402   # now see if we can find the gssapi libs in standard paths
3403   AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
3404             AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
3406   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
3407   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
3408   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
3409   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
3410   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
3411   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
3412   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
3413   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
3414   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
3415   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
3416   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
3417   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
3418   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
3419   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
3420   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
3421   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
3422   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
3423   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
3424   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
3425   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
3426   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
3427   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
3428   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
3429   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
3430   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
3431   AC_CHECK_FUNC_EXT(decode_krb5_ap_req, $KRB5_LIBS)
3432   AC_CHECK_FUNC_EXT(krb5_free_ap_req, $KRB5_LIBS)
3433   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
3434   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
3435   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
3436   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
3437   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
3438   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
3439   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
3440   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
3442   LIBS="$KRB5_LIBS $LIBS"
3444   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
3445     AC_TRY_COMPILE([
3446         #include <krb5.h>], 
3447         [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);], 
3448         [smb_krb5_verify_checksum=7], 
3449         [smb_krb5_verify_checksum=6], 
3450     ) 
3451   ])
3452   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_verify_checksum, [Number of arguments to krb5_verify_checksum])
3454   AC_CACHE_CHECK([for checksum in krb5_checksum],
3455                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
3456     AC_TRY_COMPILE([#include <krb5.h>],
3457       [krb5_checksum cksum; cksum.checksum.length = 0;],
3458       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
3459       samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
3461   if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
3462     AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
3463                [Whether the krb5_checksum struct has a checksum property])
3464   fi
3466   AC_CACHE_CHECK([for etype in EncryptedData],
3467                 samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
3468     AC_TRY_COMPILE([#include <krb5.h>],
3469       [EncryptedData edata; edata.etype = 0;],
3470       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
3471       samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
3473   if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
3474     AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
3475                [Whether the EncryptedData struct has a etype property])
3476   fi
3478   AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
3479                 samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
3480     AC_TRY_COMPILE([#include <krb5.h>],
3481       [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
3482       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
3483       samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
3485   if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
3486     AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
3487                [Whether the krb5_ap_req struct has a ticket pointer])
3488   fi
3490   AC_CACHE_CHECK([for krb5_crypto type],
3491                 samba_cv_HAVE_KRB5_CRYPTO,[
3492     AC_TRY_COMPILE([#include <krb5.h>],
3493       [krb5_crypto crypto;],
3494       samba_cv_HAVE_KRB5_CRYPTO=yes,
3495       samba_cv_HAVE_KRB5_CRYPTO=no)])
3497   if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
3498     AC_DEFINE(HAVE_KRB5_CRYPTO,1,
3499                [Whether the type krb5_crypto exists])
3500   fi
3502   AC_CACHE_CHECK([for krb5_encrypt_block type],
3503                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
3504     AC_TRY_COMPILE([#include <krb5.h>],
3505       [krb5_encrypt_block block;],
3506       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
3507       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
3509   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
3510     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
3511                [Whether the type krb5_encrypt_block exists])
3512   fi
3514   AC_CACHE_CHECK([for addrtype in krb5_address],
3515                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
3516     AC_TRY_COMPILE([#include <krb5.h>],
3517       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
3518       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
3519       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
3521   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
3522     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
3523                [Whether the krb5_address struct has a addrtype property])
3524   fi
3526   AC_CACHE_CHECK([for addr_type in krb5_address],
3527                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
3528     AC_TRY_COMPILE([#include <krb5.h>],
3529       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
3530       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
3531       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
3533   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
3534     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
3535               [Whether the krb5_address struct has a addr_type property])
3536   fi
3538   AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
3539                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
3540                  [AC_TRY_COMPILE([#include <krb5.h>],
3541     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
3542     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
3544   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
3545     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
3546               [Whether the krb5_ticket struct has a enc_part2 property])
3547   fi
3549   AC_CACHE_CHECK([for keyblock in krb5_creds],
3550                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
3551     AC_TRY_COMPILE([#include <krb5.h>],
3552       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
3553       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
3554       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
3556   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
3557     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
3558               [Whether the krb5_creds struct has a keyblock property])
3559   fi
3561   AC_CACHE_CHECK([for session in krb5_creds],
3562                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
3563     AC_TRY_COMPILE([#include <krb5.h>],
3564       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
3565       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
3566       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
3568   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
3569     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
3570               [Whether the krb5_creds struct has a session property])
3571   fi
3573   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
3574                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
3575     AC_TRY_COMPILE([#include <krb5.h>],
3576       [krb5_keyblock key; key.keyvalue.data = NULL;],
3577       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
3578       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
3580   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
3581     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
3582               [Whether the krb5_keyblock struct has a keyvalue property])
3583   fi
3585   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
3586                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
3587     AC_TRY_COMPILE([#include <krb5.h>],
3588       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
3589       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
3590       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
3591   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
3592                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
3593     AC_TRY_COMPILE([#include <krb5.h>],
3594       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
3595       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
3596       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
3597 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
3598 # w.r.t. arcfour and windows, so we must not enable it here
3599   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
3600           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
3601     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
3602               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
3603   fi
3605   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
3606                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
3607     AC_TRY_COMPILE([#include <krb5.h>],
3608       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
3609       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
3610       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
3612   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
3613     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
3614               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
3615   fi
3617   AC_CACHE_CHECK([for KV5M_KEYTAB],
3618                  samba_cv_HAVE_KV5M_KEYTAB,[
3619     AC_TRY_COMPILE([#include <krb5.h>],
3620       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
3621       samba_cv_HAVE_KV5M_KEYTAB=yes,
3622       samba_cv_HAVE_KV5M_KEYTAB=no)])
3624   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
3625       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
3626              [Whether the KV5M_KEYTAB option is available])
3627   fi
3629   AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
3630                  samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
3631     AC_TRY_COMPILE([#include <krb5.h>],
3632       [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
3633       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
3634       samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
3636   if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
3637     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
3638               [Whether KRB5_KU_OTHER_CKSUM is available])
3639   fi
3640   
3641   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
3642                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
3643     AC_TRY_COMPILE([#include <krb5.h>],
3644       [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
3645       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
3646       samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
3648   if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
3649     AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
3650               [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
3651   fi
3653   AC_CACHE_CHECK([for the krb5_princ_component macro],
3654                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
3655     AC_TRY_LINK([#include <krb5.h>],
3656       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
3657       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
3658       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
3660   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
3661     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
3662                [Whether krb5_princ_component is available])
3663   fi
3665   AC_CACHE_CHECK([for key in krb5_keytab_entry],
3666                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
3667     AC_TRY_COMPILE([#include <krb5.h>],
3668       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
3669       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
3670       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
3672   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
3673     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
3674               [Whether krb5_keytab_entry has key member])
3675   fi
3677   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
3678                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
3679     AC_TRY_COMPILE([#include <krb5.h>],
3680       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
3681       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
3682       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
3684   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
3685     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
3686               [Whether krb5_keytab_entry has keyblock member])
3687   fi
3689   AC_CACHE_CHECK([for magic in krb5_address],
3690                  samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
3691     AC_TRY_COMPILE([#include <krb5.h>],
3692       [krb5_address addr; addr.magic = 0;],
3693       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
3694       samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
3696   if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
3697     AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
3698               [Whether the krb5_address struct has a magic property])
3699   fi
3701   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
3702     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
3703     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
3704     AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
3705     AC_MSG_RESULT(yes)
3706   else
3707     if test x"$with_ads_support" = x"yes"; then
3708         AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
3709     else
3710         AC_MSG_WARN(libkrb5 is needed for Active Directory support)
3711     fi
3712     KRB5_LIBS=""
3713     with_ads_support=no 
3714   fi
3716   AC_CACHE_CHECK([for WRFILE: keytab support],
3717                 samba_cv_HAVE_WRFILE_KEYTAB,[
3718     AC_TRY_RUN([
3719 #include<krb5.h>
3720   main()
3721   {
3722     krb5_context context;
3723     krb5_keytab keytab;
3725     krb5_init_context(&context);
3726     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
3727   }],
3728   samba_cv_HAVE_WRFILE_KEYTAB=yes,
3729   samba_cv_HAVE_WRFILE_KEYTAB=no)])
3731   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
3732       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
3733                [Whether the WRFILE:-keytab is supported])
3734   fi
3736   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
3737                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3738     AC_TRY_COMPILE([#include <krb5.h>],
3739     [
3740     krb5_context context;
3741     krb5_principal principal;
3742     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3743     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3744     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3746   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3747     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3748               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3749   fi
3751   AC_CACHE_CHECK([for krb5_addresses type],
3752                 samba_cv_HAVE_KRB5_ADDRESSES,[
3753     AC_TRY_COMPILE([#include <krb5.h>],
3754       [krb5_addresses addr;],
3755       samba_cv_HAVE_KRB5_ADDRESSES=yes,
3756       samba_cv_HAVE_KRB5_ADDRESSES=no)])
3758   if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
3759     AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
3760                [Whether the type krb5_addresses type exists])
3761   fi
3763 LIBS="$ac_save_LIBS"
3766 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
3768 #################################################
3769 # check for automount support
3770 AC_MSG_CHECKING(whether to use automount)
3771 AC_ARG_WITH(automount,
3772 [  --with-automount        Include automount support (default=no)],
3773 [ case "$withval" in
3774   yes)
3775     AC_MSG_RESULT(yes)
3776     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3777     ;;
3778   *)
3779     AC_MSG_RESULT(no)
3780     ;;
3781   esac ],
3782   AC_MSG_RESULT(no)
3785 #################################################
3786 # check for smbmount support
3787 AC_MSG_CHECKING(whether to use smbmount)
3788 AC_ARG_WITH(smbmount,
3789 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
3790 [ case "$withval" in
3791   yes)
3792         case "$host_os" in
3793         *linux*)
3794                 AC_MSG_RESULT(yes)
3795                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
3796                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
3797                 ;;
3798         *)
3799                 AC_MSG_ERROR(not on a linux system!)
3800                 ;;
3801         esac
3802     ;;
3803   *)
3804     AC_MSG_RESULT(no)
3805     ;;
3806   esac ],
3807   AC_MSG_RESULT(no)
3810 #################################################
3811 # check for mount- and umount.cifs support
3812 CIFSMOUNT_PROGS=""
3813 INSTALL_CIFSMOUNT=""
3814 UNINSTALL_CIFSMOUNT=""
3815 AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
3816 AC_ARG_WITH(cifsmount,
3817 [  --with-cifsmount        Include mount.cifs and umount.cifs (Linux only) support (default=yes)],
3818 [ case "$withval" in
3819   no)
3820         AC_MSG_RESULT(no)
3821         ;;
3822   *)
3823         case "$host_os" in
3824         *linux*)
3825                 AC_MSG_RESULT(yes)
3826                 AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
3827                 CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
3828                 INSTALL_CIFSMOUNT="installcifsmount"
3829                 UNINSTALL_CIFSMOUNT="uninstallcifsmount"
3830                 ;;
3831         *)
3832                 AC_MSG_ERROR(not on a linux system!)
3833                 ;;
3834         esac
3835     ;;
3836   esac ],
3837 [ case "$host_os" in
3838   *linux*)
3839         AC_MSG_RESULT(yes)
3840         AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
3841         CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
3842         INSTALL_CIFSMOUNT="installcifsmount"
3843         UNINSTALL_CIFSMOUNT="uninstallcifsmount"
3844         ;;
3845   *)
3846         AC_MSG_RESULT(no)
3847         ;;
3848   esac ]
3852 #################################################
3853 # check for a PAM clear-text auth, accounts, password and session support
3854 with_pam_for_crypt=no
3855 AC_MSG_CHECKING(whether to use PAM)
3856 AC_ARG_WITH(pam,
3857 [  --with-pam              Include PAM support (default=no)],
3858 [ case "$withval" in
3859   yes)
3860     AC_MSG_RESULT(yes)
3861     if test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3862        if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
3863           if test x"$ac_cv_header_security__pam_macros_h" = x"no"; then
3864              AC_MSG_ERROR(--with-pam specified but no PAM headers found)
3865           fi
3866        fi
3867     fi
3868     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
3869     AUTH_LIBS="$AUTH_LIBS -lpam"
3870     with_pam_for_crypt=yes
3871     ;;
3872   *)
3873     AC_MSG_RESULT(no)
3874     ;;
3875   esac ],
3876   AC_MSG_RESULT(no)
3879 # we can't build a pam module if we don't have pam.
3880 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
3882 #################################################
3883 # check for pam_smbpass support
3884 PAM_MODULES=""
3885 INSTALL_PAM_MODULES=""
3886 UNINSTALL_PAM_MODULES=""
3887 AC_MSG_CHECKING(whether to use pam_smbpass)
3888 AC_ARG_WITH(pam_smbpass,
3889 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
3890 [ case "$withval" in
3891   yes)
3892     AC_MSG_RESULT(yes)
3894        # Conditions under which pam_smbpass should not be built.
3896        if test x"$PICFLAGS" = x; then
3897           AC_MSG_ERROR([No support for PIC code])
3898        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3899           AC_MSG_ERROR([No security/pam_appl.h found])
3900        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
3901           AC_MSG_ERROR([No libpam found])
3902        else
3903           AUTH_LIBS="$AUTH_LIBS -lpam"
3904           PAM_MODULES="pam_smbpass"
3905           INSTALL_PAM_MODULES="installpammodules"
3906           UNINSTALL_PAM_MODULES="uninstallpammodules"
3907        fi
3908     ;;
3909   *)
3910     AC_MSG_RESULT(no)
3911     ;;
3912   esac ],
3913   AC_MSG_RESULT(no)
3917 ###############################################
3918 # test for where we get crypt() from
3919 AC_SEARCH_LIBS(crypt, [crypt],
3920   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
3921   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
3924 ## moved after the check for -lcrypt in order to
3925 ## ensure that the necessary libraries are included
3926 ## check checking for truncated salt.  Wrapped by the
3927 ## $with_pam_for_crypt variable as above   --jerry
3929 if test $with_pam_for_crypt = no; then
3930 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
3931 crypt_LIBS="$LIBS"
3932 LIBS="$AUTH_LIBS $LIBS"
3933 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
3934         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
3935 LIBS="$crypt_LIBS"])
3936 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
3937         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
3941 #################################################
3942 # check for a NISPLUS_HOME support 
3943 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
3944 AC_ARG_WITH(nisplus-home,
3945 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
3946 [ case "$withval" in
3947   yes)
3948     AC_MSG_RESULT(yes)
3949     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
3950     ;;
3951   *)
3952     AC_MSG_RESULT(no)
3953     ;;
3954   esac ],
3955   AC_MSG_RESULT(no)
3958 #################################################
3959 # check for syslog logging
3960 AC_MSG_CHECKING(whether to use syslog logging)
3961 AC_ARG_WITH(syslog,
3962 [  --with-syslog           Include experimental SYSLOG support (default=no)],
3963 [ case "$withval" in
3964   yes)
3965     AC_MSG_RESULT(yes)
3966     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
3967     ;;
3968   *)
3969     AC_MSG_RESULT(no)
3970     ;;
3971   esac ],
3972   AC_MSG_RESULT(no)
3975 #################################################
3976 # check for a shared memory profiling support
3977 AC_MSG_CHECKING(whether to use profiling)
3978 AC_ARG_WITH(profiling-data,
3979 [  --with-profiling-data   Include gathering source code profile information (default=no)],
3980 [ case "$withval" in
3981   yes)
3982     AC_MSG_RESULT(yes)
3983     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
3984     ;;
3985   *)
3986     AC_MSG_RESULT(no)
3987     ;;
3988   esac ],
3989   AC_MSG_RESULT(no)
3993 #################################################
3994 # check for experimental disk-quotas support
3996 samba_cv_WITH_QUOTAS=auto
3997 samba_cv_TRY_QUOTAS=no
3998 samba_cv_RUN_QUOTA_TESTS=auto
3999 samba_cv_WITH_SYS_QUOTAS=auto
4000 samba_cv_TRY_SYS_QUOTAS=auto
4001 samba_cv_SYSQUOTA_FOUND=no
4003 AC_MSG_CHECKING(whether to try disk-quotas support)
4004 AC_ARG_WITH(quotas,
4005 [  --with-quotas           Include disk-quota support (default=no)],
4006 [ case "$withval" in
4007   yes)
4008     AC_MSG_RESULT(yes)
4009     samba_cv_WITH_QUOTAS=yes
4010     samba_cv_TRY_QUOTAS=yes
4011     samba_cv_RUN_QUOTA_TESTS=yes
4012     #set sys quotas to auto in this case
4013     samba_cv_TRY_SYS_QUOTAS=auto
4014     ;;
4015   auto)
4016     AC_MSG_RESULT(auto)
4017     samba_cv_WITH_QUOTAS=auto
4018     samba_cv_TRY_QUOTAS=auto
4019     samba_cv_RUN_QUOTA_TESTS=auto
4020     #set sys quotas to auto in this case
4021     samba_cv_TRY_SYS_QUOTAS=auto
4022     ;;
4023   no)
4024     AC_MSG_RESULT(no)
4025     samba_cv_WITH_QUOTAS=no
4026     samba_cv_TRY_QUOTAS=no
4027     samba_cv_RUN_QUOTA_TESTS=no
4028     ;;
4029   *)
4030     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4031     ;;
4032   esac ],
4033   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
4036 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
4037 AC_ARG_WITH(sys-quotas,
4038 [  --with-sys-quotas       Include lib/sysquotas.c support (default=auto)],
4039 [ case "$withval" in
4040   yes)
4041     AC_MSG_RESULT(yes)
4042     samba_cv_WITH_SYS_QUOTAS=yes
4043     samba_cv_TRY_SYS_QUOTAS=yes
4044     samba_cv_RUN_QUOTA_TESTS=yes
4045     ;;
4046   auto)
4047     AC_MSG_RESULT(auto)
4048     samba_cv_WITH_SYS_QUOTAS=auto
4049     samba_cv_TRY_SYS_QUOTAS=auto
4050     samba_cv_RUN_QUOTA_TESTS=auto
4051     ;;
4052   no)
4053     AC_MSG_RESULT(no)
4054     samba_cv_WITH_SYS_QUOTAS=no
4055     samba_cv_TRY_SYS_QUOTAS=no
4056     ;;
4057   *)
4058     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4059     ;;
4060   esac ],
4061   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
4064 if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
4065 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
4066   case "$host_os" in
4067         *linux*)
4068             AC_MSG_RESULT(yes)
4069             samba_cv_TRY_SYS_QUOTAS=yes
4070             samba_cv_RUN_QUOTA_TESTS=yes
4071             ;;
4072         *)
4073             AC_MSG_RESULT(no)
4074             samba_cv_TRY_SYS_QUOTAS=no
4075             ;;
4076   esac
4079 #############################################
4080 # only check for quota stuff if --with-quotas
4081 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
4083 case "$host_os" in
4084         # on linux we didn't need to test we have builtin support
4085         *linux*)
4086             samba_cv_SYSQUOTA_FOUND=yes
4087             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
4088             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
4089             AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
4090             AC_MSG_RESULT(yes)
4092             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
4093             samba_cv_found_xfs_header=yes
4094             AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
4095             AC_MSG_RESULT(yes)
4096             ;;
4097         *solaris*)
4098             # need to set this define when using static linking (BUG 1473)
4099             CPPFLAGS="$CPPFLAGS -DSUNOS5"
4100             ;;
4101         *)
4102             ;;
4103 esac
4105 # some broken header files need this
4106 AC_CHECK_HEADER(asm/types.h,[
4107             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
4108             AC_ADD_INCLUDE(<asm/types.h>)
4109             ])
4111 # For quotas on Veritas VxFS filesystems
4112 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
4114 # For sys/quota.h and linux/quota.h
4115 AC_CHECK_HEADERS(sys/quota.h)
4117 if test x"$samba_cv_found_xfs_header" != x"yes"; then
4118 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
4119 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
4120 AC_TRY_COMPILE([
4121 #include "confdefs.h"
4122 #ifdef HAVE_SYS_TYPES_H
4123 #include <sys/types.h>
4124 #endif
4125 #ifdef HAVE_ASM_TYPES_H
4126 #include <asm/types.h>
4127 #endif
4128 #include <sys/quota.h>
4129 ],[int i = Q_XGETQUOTA;],
4130 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
4131 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
4132         samba_cv_found_xfs_header=yes
4136 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
4137 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
4138 AC_TRY_COMPILE([
4139 #include "confdefs.h"
4140 #ifdef HAVE_SYS_QUOTA_H
4141 #include <sys/quota.h>
4142 #endif
4144 struct dqblk D;
4145 D.dqb_fsoftlimit = 0;],
4146 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
4147 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
4148         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
4151 ##################
4152 # look for a working quota system
4154 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4155 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
4156 AC_TRY_RUN_STRICT([
4157 #define HAVE_QUOTACTL_4A 1
4158 #define AUTOCONF_TEST 1
4159 #include "confdefs.h"
4160 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4161            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
4162 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
4163     samba_cv_SYSQUOTA_FOUND=yes;
4164     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
4165     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
4169 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4170 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
4171 AC_TRY_RUN_STRICT([
4172 #define HAVE_QUOTACTL_4B 1
4173 #define AUTOCONF_TEST 1
4174 #include "confdefs.h"
4175 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4176            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
4177 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
4178     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
4179     samba_cv_SYSQUOTA_FOUND=yes;
4180     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
4181     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
4185 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4186 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
4187 AC_TRY_RUN_STRICT([
4188 #define HAVE_QUOTACTL_3 1
4189 #define AUTOCONF_TEST 1
4190 #include "confdefs.h"
4191 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
4192            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
4193 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
4194     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
4195     samba_cv_SYSQUOTA_FOUND=yes;
4196     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
4197     samba_cv_sysquotas_file="lib/sysquotas_3.c"
4201 #################################################
4202 # check for mntent.h and struct mntent
4203 AC_CHECK_HEADERS(mntent.h)
4204 #################################################
4205 # check for setmntent,getmntent,endmntent
4206 AC_CHECK_FUNCS(setmntent getmntent endmntent)
4208 #################################################
4209 # check for devnm.h and struct mntent
4210 AC_CHECK_HEADERS(devnm.h)
4211 #################################################
4212 # check for devnm
4213 AC_CHECK_FUNCS(devnm)
4215 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
4216     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
4217         # if --with-sys-quotas=yes then build it 
4218         # you have can use the get/set quota command smb.conf
4219         # options then
4220         samba_cv_SYSQUOTA_FOUND=auto
4221     fi
4222     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
4223         # if --with-sys-quotas=yes then build it 
4224         # you have can use the get/set quota command smb.conf
4225         # options then
4226         samba_cv_TRY_SYS_QUOTAS=auto
4227     fi
4230 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
4231 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
4232 SAVE_CPPFLAGS="$CPPFLAGS"
4233 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
4234 AC_TRY_COMPILE([
4235 #include "confdefs.h"
4236 #define NO_PROTO_H 1
4237 #define NO_CONFIG_H 1
4238 #define HAVE_SYS_QUOTAS 1
4239 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
4240 #include "${srcdir-.}/lib/sysquotas.c"
4241 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
4242 CPPFLAGS="$SAVE_CPPFLAGS"
4244 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
4245 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
4246     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
4247         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4248         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
4249         samba_cv_WE_USE_SYS_QUOTAS=yes
4250         AC_MSG_RESULT(yes)
4251     else
4252         AC_MSG_RESULT(no)
4253     fi
4257 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
4258 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
4259 SAVE_CPPFLAGS="$CPPFLAGS"
4260 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
4261 AC_TRY_COMPILE([
4262 #include "confdefs.h"
4263 #define NO_PROTO_H 1
4264 #define NO_CONFIG_H 1
4265 #define HAVE_SYS_QUOTAS 1
4266 #define HAVE_XFS_QUOTAS 1
4267 #include "${srcdir-.}/lib/sysquotas_xfs.c"
4268 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
4269 CPPFLAGS="$SAVE_CPPFLAGS"
4271 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
4272     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
4273         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
4274     fi
4278 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
4279 SAVE_CPPFLAGS="$CPPFLAGS"
4280 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch -I${srcdir-.}/smbwrapper"
4281 AC_TRY_COMPILE([
4282 #include "confdefs.h"
4283 #define NO_PROTO_H 1
4284 #define NO_CONFIG_H 1
4285 #include "${srcdir-.}/smbd/quotas.c"
4286 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
4287 CPPFLAGS="$SAVE_CPPFLAGS"
4289 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
4290 AC_MSG_CHECKING(whether to use the old quota support)
4291     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
4292       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
4293         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
4294         AC_MSG_RESULT(yes)
4295       else
4296         AC_MSG_RESULT(no)
4297       fi
4298     else
4299       AC_MSG_RESULT(no)
4300     fi
4303 ####################
4304 # End of quota check samba_cv_RUN_QUOTA_TESTS
4307 #################################################
4308 # check for experimental utmp accounting
4310 AC_MSG_CHECKING(whether to support utmp accounting)
4311 WITH_UTMP=yes
4312 AC_ARG_WITH(utmp,
4313 [  --with-utmp             Include utmp accounting (default, if supported by OS)],
4314 [ case "$withval" in
4315   no)
4316                 WITH_UTMP=no
4317                 ;;
4318   *)
4319                 WITH_UTMP=yes
4320                 ;;
4321   esac ],
4324 # utmp requires utmp.h
4325 # Note similar check earlier, when checking utmp details.
4327 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
4328         utmp_no_reason=", no utmp.h on $host_os"
4329         WITH_UTMP=no
4332 # Display test results
4334 if test x"$WITH_UTMP" = x"yes"; then
4335         AC_MSG_RESULT(yes)
4336         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
4337 else
4338         AC_MSG_RESULT(no$utmp_no_reason)
4341 INSTALLLIBCMD_SH=:
4342 INSTALLLIBCMD_A=:
4343 UNINSTALLLIBCMD_SH=:
4344 UNINSTALLLIBCMD_A=:
4346 if test $BLDSHARED = true; then
4347         INSTALLLIBCMD_SH="\$(INSTALLCMD)"
4348         UNINSTALLLIBCMD_SH="rm -f"
4350 if test $enable_static = yes; then
4351         INSTALLLIBCMD_A="\$(INSTALLCMD)"
4352         UNINSTALLLIBCMD_A="rm -f"
4355 #################################################
4356 # should we build libmsrpc?
4357 INSTALL_LIBMSRPC=
4358 UNINSTALL_LIBMSRPC=
4359 LIBMSRPC_SHARED=
4360 LIBMSRPC=
4361 AC_MSG_CHECKING(whether to build the libmsrpc shared library)
4362 AC_ARG_WITH(libmsrpc,
4363 [  --with-libmsrpc         Build the libmsrpc shared library (default=yes if shared libs supported)],
4364 [ case "$withval" in
4365   no) 
4366      AC_MSG_RESULT(no)
4367      ;;
4368   *)
4369      if test $BLDSHARED = true; then
4370         LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
4371         LIBMSRPC=libmsrpc
4372         AC_MSG_RESULT(yes)
4373      else
4374         enable_static=yes
4375         AC_MSG_RESULT(no shared library support -- will supply static library)
4376      fi
4377      if test $enable_static = yes; then
4378         LIBMSRPC=libmsrpc
4379      fi
4380      INSTALL_LIBMSRPC=installlibmsrpc
4381      UNINSTALL_LIBMSRPC=uninstalllibmsrpc
4382      ;;
4383   esac ],
4385 # if unspecified, default is to built it if possible.
4386   if test $BLDSHARED = true; then
4387      LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
4388      LIBMSRPC=libmsrpc
4389      AC_MSG_RESULT(yes)
4390    else
4391      enable_static=yes
4392      AC_MSG_RESULT(no shared library support -- will supply static library)
4393    fi
4394    if test $enable_static = yes; then
4395      LIBMSRPC=libmsrpc
4396   fi]
4397   INSTALL_LIBMSRPC=installlibmsrpc
4398   UNINSTALL_LIBMSRPC=uninstalllibmsrpc
4401 #################################################
4402 # should we build libsmbclient?
4403 INSTALL_LIBSMBCLIENT=
4404 UNINSTALL_LIBSMBCLIENT=
4405 LIBSMBCLIENT_SHARED=
4406 LIBSMBCLIENT=
4407 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
4408 AC_ARG_WITH(libsmbclient,
4409 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
4410 [ case "$withval" in
4411   no) 
4412      AC_MSG_RESULT(no)
4413      ;;
4414   *)
4415      if test $BLDSHARED = true; then
4416         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4417         LIBSMBCLIENT=libsmbclient
4418         AC_MSG_RESULT(yes)
4419      else
4420         enable_static=yes
4421         AC_MSG_RESULT(no shared library support -- will supply static library)
4422      fi
4423      if test $enable_static = yes; then
4424         LIBSMBCLIENT=libsmbclient
4425      fi
4426      INSTALL_LIBSMBCLIENT=installclientlib
4427      UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4428      ;;
4429   esac ],
4431 # if unspecified, default is to built it if possible.
4432   if test $BLDSHARED = true; then
4433      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
4434      LIBSMBCLIENT=libsmbclient
4435      AC_MSG_RESULT(yes)
4436    else
4437      enable_static=yes
4438      AC_MSG_RESULT(no shared library support -- will supply static library)
4439    fi
4440    if test $enable_static = yes; then
4441      LIBSMBCLIENT=libsmbclient
4442   fi]
4443   INSTALL_LIBSMBCLIENT=installclientlib
4444   UNINSTALL_LIBSMBCLIENT=uninstallclientlib
4447 INSTALL_LIBSMBSHAREMODES=
4448 LIBSMBSHAREMODES_SHARED=
4449 LIBSMBSHAREMODES=
4450 AC_MSG_CHECKING(whether to build the libsmbsharemodes shared library)
4451 AC_ARG_WITH(libsmbsharemodes,
4452 [  --with-libsmbsharemodes     Build the libsmbsharemodes shared library (default=yes if shared libs supported)],
4453 [ case "$withval" in
4454   no)
4455      AC_MSG_RESULT(no)
4456      ;;
4457   *)
4458      if test $BLDSHARED = true; then
4459         LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4460         LIBSMBSHAREMODES=libsmbsharemodes
4461         AC_MSG_RESULT(yes)
4462      else
4463         enable_static=yes
4464         AC_MSG_RESULT(no shared library support -- will supply static library)
4465      fi
4466      if test $enable_static = yes; then
4467         LIBSMBSHAREMODES=libsmbsharemodes
4468      fi
4469      INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4470      ;;
4471   esac ],
4473 # if unspecified, default is to built it if possible.
4474   if test $BLDSHARED = true; then
4475      LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
4476      LIBSMBSHAREMODES=libsmbsharemodes
4477      AC_MSG_RESULT(yes)
4478    else
4479      enable_static=yes
4480      AC_MSG_RESULT(no shared library support -- will supply static library)
4481    fi
4482    if test $enable_static = yes; then
4483      LIBSMBSHAREMODES=libsmbsharemodes
4484   fi]
4485   INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
4488 #################################################
4489 # these tests are taken from the GNU fileutils package
4490 AC_CHECKING(how to get filesystem space usage)
4491 space=no
4493 # Test for statvfs64.
4494 if test $space = no; then
4495   # SVR4
4496   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
4497   [AC_TRY_RUN([
4498 #if defined(HAVE_UNISTD_H)
4499 #include <unistd.h>
4500 #endif
4501 #include <sys/types.h>
4502 #include <sys/statvfs.h>
4503   main ()
4504   {
4505     struct statvfs64 fsd;
4506     exit (statvfs64 (".", &fsd));
4507   }],
4508   fu_cv_sys_stat_statvfs64=yes,
4509   fu_cv_sys_stat_statvfs64=no,
4510   fu_cv_sys_stat_statvfs64=cross)])
4511   if test $fu_cv_sys_stat_statvfs64 = yes; then
4512     space=yes
4513     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
4514   fi
4517 # Perform only the link test since it seems there are no variants of the
4518 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
4519 # because that got a false positive on SCO OSR5.  Adding the declaration
4520 # of a `struct statvfs' causes this test to fail (as it should) on such
4521 # systems.  That system is reported to work fine with STAT_STATFS4 which
4522 # is what it gets when this test fails.
4523 if test $space = no; then
4524   # SVR4
4525   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
4526                  [AC_TRY_LINK([#include <sys/types.h>
4527 #include <sys/statvfs.h>],
4528                               [struct statvfs fsd; statvfs (0, &fsd);],
4529                               fu_cv_sys_stat_statvfs=yes,
4530                               fu_cv_sys_stat_statvfs=no)])
4531   if test $fu_cv_sys_stat_statvfs = yes; then
4532     space=yes
4533     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
4534   fi
4537 if test $space = no; then
4538   # DEC Alpha running OSF/1
4539   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
4540   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
4541   [AC_TRY_RUN([
4542 #include <sys/param.h>
4543 #include <sys/types.h>
4544 #include <sys/mount.h>
4545   main ()
4546   {
4547     struct statfs fsd;
4548     fsd.f_fsize = 0;
4549     exit (statfs (".", &fsd, sizeof (struct statfs)));
4550   }],
4551   fu_cv_sys_stat_statfs3_osf1=yes,
4552   fu_cv_sys_stat_statfs3_osf1=no,
4553   fu_cv_sys_stat_statfs3_osf1=no)])
4554   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
4555   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
4556     space=yes
4557     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
4558   fi
4561 if test $space = no; then
4562 # AIX
4563   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
4564 member (AIX, 4.3BSD)])
4565   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
4566   [AC_TRY_RUN([
4567 #ifdef HAVE_SYS_PARAM_H
4568 #include <sys/param.h>
4569 #endif
4570 #ifdef HAVE_SYS_MOUNT_H
4571 #include <sys/mount.h>
4572 #endif
4573 #ifdef HAVE_SYS_VFS_H
4574 #include <sys/vfs.h>
4575 #endif
4576   main ()
4577   {
4578   struct statfs fsd;
4579   fsd.f_bsize = 0;
4580   exit (statfs (".", &fsd));
4581   }],
4582   fu_cv_sys_stat_statfs2_bsize=yes,
4583   fu_cv_sys_stat_statfs2_bsize=no,
4584   fu_cv_sys_stat_statfs2_bsize=no)])
4585   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
4586   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
4587     space=yes
4588     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
4589   fi
4592 if test $space = no; then
4593 # SVR3
4594   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
4595   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
4596   [AC_TRY_RUN([#include <sys/types.h>
4597 #include <sys/statfs.h>
4598   main ()
4599   {
4600   struct statfs fsd;
4601   exit (statfs (".", &fsd, sizeof fsd, 0));
4602   }],
4603     fu_cv_sys_stat_statfs4=yes,
4604     fu_cv_sys_stat_statfs4=no,
4605     fu_cv_sys_stat_statfs4=no)])
4606   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
4607   if test $fu_cv_sys_stat_statfs4 = yes; then
4608     space=yes
4609     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
4610   fi
4613 if test $space = no; then
4614 # 4.4BSD and NetBSD
4615   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
4616 member (4.4BSD and NetBSD)])
4617   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
4618   [AC_TRY_RUN([#include <sys/types.h>
4619 #ifdef HAVE_SYS_PARAM_H
4620 #include <sys/param.h>
4621 #endif
4622 #ifdef HAVE_SYS_MOUNT_H
4623 #include <sys/mount.h>
4624 #endif
4625   main ()
4626   {
4627   struct statfs fsd;
4628   fsd.f_fsize = 0;
4629   exit (statfs (".", &fsd));
4630   }],
4631   fu_cv_sys_stat_statfs2_fsize=yes,
4632   fu_cv_sys_stat_statfs2_fsize=no,
4633   fu_cv_sys_stat_statfs2_fsize=no)])
4634   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
4635   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
4636     space=yes
4637         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
4638   fi
4641 if test $space = no; then
4642   # Ultrix
4643   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
4644   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
4645   [AC_TRY_RUN([#include <sys/types.h>
4646 #ifdef HAVE_SYS_PARAM_H
4647 #include <sys/param.h>
4648 #endif
4649 #ifdef HAVE_SYS_MOUNT_H
4650 #include <sys/mount.h>
4651 #endif
4652 #ifdef HAVE_SYS_FS_TYPES_H
4653 #include <sys/fs_types.h>
4654 #endif
4655   main ()
4656   {
4657   struct fs_data fsd;
4658   /* Ultrix's statfs returns 1 for success,
4659      0 for not mounted, -1 for failure.  */
4660   exit (statfs (".", &fsd) != 1);
4661   }],
4662   fu_cv_sys_stat_fs_data=yes,
4663   fu_cv_sys_stat_fs_data=no,
4664   fu_cv_sys_stat_fs_data=no)])
4665   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
4666   if test $fu_cv_sys_stat_fs_data = yes; then
4667     space=yes
4668     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
4669   fi
4673 # As a gating factor for large file support, in order to
4674 # use <4GB files we must have the following minimal support
4675 # available.
4676 # long long, and a 64 bit off_t or off64_t.
4677 # If we don't have all of these then disable large
4678 # file support.
4680 AC_MSG_CHECKING([if large file support can be enabled])
4681 AC_TRY_COMPILE([
4682 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
4683 #include <sys/types.h>
4684 #else
4685 __COMPILE_ERROR_
4686 #endif
4688 [int i],
4689 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
4690 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
4691         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
4693 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
4695 AC_ARG_WITH(spinlocks, 
4696 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
4697 if test "x$with_spinlocks" = "xyes"; then
4698     AC_DEFINE(USE_SPINLOCKS,1,[Whether to use spin locks instead of fcntl locks])
4700     case "$host_cpu" in
4701         sparc)
4702             AC_DEFINE(SPARC_SPINLOCKS,1,[Whether to use sparc spinlocks])
4703             ;;
4705         i386|i486|i586|i686)
4706             AC_DEFINE(INTEL_SPINLOCKS,1,[Whether to use intel spinlocks])
4707             ;;
4709         mips)
4710             AC_DEFINE(MIPS_SPINLOCKS,1,[Whether to use mips spinlocks])
4711             ;;
4713         powerpc)
4714             AC_DEFINE(POWERPC_SPINLOCKS,1,[Whether to use powerpc spinlocks])
4715             ;;
4716     esac
4719 #################################################
4720 # check for ACL support
4722 AC_MSG_CHECKING(whether to support ACLs)
4723 AC_ARG_WITH(acl-support,
4724 [  --with-acl-support      Include ACL support (default=no)],
4725 [ case "$withval" in
4726   yes)
4728         case "$host_os" in
4729         *sysv5*)
4730                 AC_MSG_RESULT(Using UnixWare ACLs)
4731                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
4732                 ;;
4733         *solaris*)
4734                 AC_MSG_RESULT(Using solaris ACLs)
4735                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
4736                 ACL_LIBS="$ACL_LIBS -lsec"
4737                 ;;
4738         *hpux*)
4739                 AC_MSG_RESULT(Using HPUX ACLs)
4740                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
4741                 ;;
4742         *irix*)
4743                 AC_MSG_RESULT(Using IRIX ACLs)
4744                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
4745                 ;;
4746         *aix*)
4747                 AC_MSG_RESULT(Using AIX ACLs)
4748                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
4749                 ;;
4750         *osf*)
4751                 AC_MSG_RESULT(Using Tru64 ACLs)
4752                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
4753                 ACL_LIBS="$ACL_LIBS -lpacl"
4754                 ;;
4755         *freebsd[[5-9]]*)
4756                 AC_MSG_RESULT(Using FreeBSD posix ACLs)
4757                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
4758                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4759                 ;;
4760         *linux*)
4761                 AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
4762                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
4763                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
4764                 acl_LIBS=$LIBS
4765                 LIBS="$LIBS -lacl"
4766                 AC_TRY_LINK([#include <sys/types.h>
4767 #include <sys/acl.h>],
4768 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
4769 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
4770                 LIBS=$acl_LIBS])
4771                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4772                                 AC_MSG_RESULT(Using posix ACLs)
4773                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4774                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4775                                 acl_LIBS=$LIBS
4776                                 LIBS="$LIBS -lacl"
4777                                 AC_TRY_LINK([#include <sys/types.h>
4778 #include <sys/acl.h>],
4779 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4780 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4781                                 LIBS=$acl_LIBS])
4782                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4783                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4784                                 fi
4785                         fi
4786             ;;
4787          *)
4788                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
4789                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
4790                 acl_LIBS=$LIBS
4791                 LIBS="$LIBS -lacl"
4792                 AC_TRY_LINK([#include <sys/types.h>
4793 #include <sys/acl.h>],
4794 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
4795 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
4796                 LIBS=$acl_LIBS])
4797                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4798                                 AC_MSG_RESULT(Using posix ACLs)
4799                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4800                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4801                                 acl_LIBS=$LIBS
4802                                 LIBS="$LIBS -lacl"
4803                                 AC_TRY_LINK([#include <sys/types.h>
4804 #include <sys/acl.h>],
4805 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4806 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4807                                 LIBS=$acl_LIBS])
4808                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4809                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4810                                 fi
4811                         fi
4812             ;;
4813         esac
4814         ;;
4815   *)
4816     AC_MSG_RESULT(no)
4817     AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
4818     ;;
4819   esac ],
4820   AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
4821   AC_MSG_RESULT(no)
4824 #################################################
4825 # check for AIO support
4827 AC_MSG_CHECKING(whether to support asynchronous io)
4828 AC_ARG_WITH(aio-support,
4829 [  --with-aio-support      Include asynchronous io support (default=no)],
4830 [ case "$withval" in
4831   yes)
4833         AC_MSG_RESULT(yes)
4834         case "$host_os" in
4835         *)
4836                 AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
4837                 AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
4838                 AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
4839                 aio_LIBS=$LIBS
4840                 LIBS=$AIO_LIBS
4841                 AC_TRY_LINK([#include <sys/types.h>
4842 #include <aio.h>],
4843 [ struct aiocb a; return aio_read(&a);],
4844 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
4845                 LIBS=$aio_LIBS])
4846                 AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
4847                 aio_LIBS=$LIBS
4848                 LIBS=$AIO_LIBS
4849                 AC_TRY_LINK([#include <sys/types.h>
4850 #include <aio.h>],
4851 [ struct aiocb64 a; return aio_read64(&a);],
4852 samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
4853                 LIBS=$aio_LIBS])
4854                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
4855                         AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
4856                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
4857                         LIBS=$AIO_LIBS
4858                 elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
4859                         AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
4860                         LIBS=$AIO_LIBS
4861                 fi
4863                 if test x"$samba_cv_HAVE_AIO" = x"yes"; then
4864                         AC_MSG_CHECKING(for aio_read)
4865                         AC_LINK_IFELSE([#include <aio.h>
4866 int main() { struct aiocb a; return aio_read(&a); }],
4867 [AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
4868 [AC_MSG_RESULT(no)])
4870                         AC_MSG_CHECKING(for aio_write)
4871                         AC_LINK_IFELSE([#include <aio.h>
4872 int main() { struct aiocb a; return aio_write(&a); }],
4873 [AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
4874 [AC_MSG_RESULT(no)])
4876                         AC_MSG_CHECKING(for aio_fsync)
4877                         AC_LINK_IFELSE([#include <aio.h>
4878 int main() { struct aiocb a; return aio_fsync(1, &a); }],
4879 [AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
4880 [AC_MSG_RESULT(no)])
4882                         AC_MSG_CHECKING(for aio_return)
4883                         AC_LINK_IFELSE([#include <aio.h>
4884 int main() { struct aiocb a; return aio_return(&a); }],
4885 [AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
4886 [AC_MSG_RESULT(no)])
4888                         AC_MSG_CHECKING(for aio_error)
4889                         AC_LINK_IFELSE([#include <aio.h>
4890 int main() { struct aiocb a; return aio_error(&a); }],
4891 [AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
4892 [AC_MSG_RESULT(no)])
4894                         AC_MSG_CHECKING(for aio_cancel)
4895                         AC_LINK_IFELSE([#include <aio.h>
4896 int main() { struct aiocb a; return aio_cancel(1, &a); }],
4897 [AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
4898 [AC_MSG_RESULT(no)])
4900                         AC_MSG_CHECKING(for aio_suspend)
4901                         AC_LINK_IFELSE([#include <aio.h>
4902 int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
4903 [AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
4904 [AC_MSG_RESULT(no)])
4905                 fi
4907                 if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
4908                         AC_MSG_CHECKING(for aio_read64)
4909                         AC_LINK_IFELSE([#include <aio.h>
4910 int main() { struct aiocb a; return aio_read64(&a); }],
4911 [AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
4912 [AC_MSG_RESULT(no)])
4914                         AC_MSG_CHECKING(for aio_write64)
4915                         AC_LINK_IFELSE([#include <aio.h>
4916 int main() { struct aiocb a; return aio_write64(&a); }],
4917 [AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
4918 [AC_MSG_RESULT(no)])
4920                         AC_MSG_CHECKING(for aio_fsync64)
4921                         AC_LINK_IFELSE([#include <aio.h>
4922 int main() { struct aiocb a; return aio_fsync64(1, &a); }],
4923 [AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
4924 [AC_MSG_RESULT(no)])
4926                         AC_MSG_CHECKING(for aio_return64)
4927                         AC_LINK_IFELSE([#include <aio.h>
4928 int main() { struct aiocb a; return aio_return64(&a); }],
4929 [AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
4930 [AC_MSG_RESULT(no)])
4932                         AC_MSG_CHECKING(for aio_error64)
4933                         AC_LINK_IFELSE([#include <aio.h>
4934 int main() { struct aiocb a; return aio_error64(&a); }],
4935 [AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
4936 [AC_MSG_RESULT(no)])
4938                         AC_MSG_CHECKING(for aio_cancel64)
4939                         AC_LINK_IFELSE([#include <aio.h>
4940 int main() { struct aiocb a; return aio_cancel64(1, &a); }],
4941 [AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
4942 [AC_MSG_RESULT(no)])
4944                         AC_MSG_CHECKING(for aio_suspend64)
4945                         AC_LINK_IFELSE([#include <aio.h>
4946 int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
4947 [AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
4948 [AC_MSG_RESULT(no)])
4949                 fi
4950             ;;
4951         esac
4952         ;;
4953   *)
4954     AC_MSG_RESULT(no)
4955     AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
4956     ;;
4957   esac ],
4958   AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
4959   AC_MSG_RESULT(no)
4962 #################################################
4963 # check for sendfile support
4965 with_sendfile_support=yes
4966 AC_MSG_CHECKING(whether to check to support sendfile)
4967 AC_ARG_WITH(sendfile-support,
4968 [  --with-sendfile-support Check for sendfile support (default=yes)],
4969 [ case "$withval" in
4970   yes)
4972         AC_MSG_RESULT(yes);
4974         case "$host_os" in
4975         *linux*)
4976                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4977                 AC_TRY_LINK([#include <sys/sendfile.h>],
4979 int tofd, fromfd;
4980 off64_t offset;
4981 size_t total;
4982 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
4984 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4986                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
4987                 AC_TRY_LINK([#include <sys/sendfile.h>],
4989 int tofd, fromfd;
4990 off_t offset;
4991 size_t total;
4992 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4994 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4996 # Try and cope with broken Linux sendfile....
4997                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
4998                 AC_TRY_LINK([\
4999 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
5000 #undef _FILE_OFFSET_BITS
5001 #endif
5002 #include <sys/sendfile.h>],
5004 int tofd, fromfd;
5005 off_t offset;
5006 size_t total;
5007 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
5009 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
5011         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5012                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
5013                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5014                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5015         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5016                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5017                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
5018                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
5019         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
5020                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
5021                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
5022         else
5023                 AC_MSG_RESULT(no);
5024         fi
5026         ;;
5027         *freebsd* | *dragonfly* )
5028                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
5029                 AC_TRY_LINK([\
5030 #include <sys/types.h>
5031 #include <unistd.h>
5032 #include <sys/socket.h>
5033 #include <sys/uio.h>],
5035         int fromfd, tofd, ret, total=0;
5036         off_t offset, nwritten;
5037         struct sf_hdtr hdr;
5038         struct iovec hdtrl;
5039         hdr.headers = &hdtrl;
5040         hdr.hdr_cnt = 1;
5041         hdr.trailers = NULL;
5042         hdr.trl_cnt = 0;
5043         hdtrl.iov_base = NULL;
5044         hdtrl.iov_len = 0;
5045         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
5047 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5049         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5050                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
5051                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
5052                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5053         else
5054                 AC_MSG_RESULT(no);
5055         fi
5056         ;;
5058         *hpux*)
5059                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
5060                 AC_TRY_LINK([\
5061 #include <sys/socket.h>
5062 #include <sys/uio.h>],
5064         int fromfd, tofd;
5065         size_t total=0;
5066         struct iovec hdtrl[2];
5067         ssize_t nwritten;
5068         off64_t offset;
5070         hdtrl[0].iov_base = 0;
5071         hdtrl[0].iov_len = 0;
5073         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
5075 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
5076         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
5077                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
5078                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5079                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5080         else
5081                 AC_MSG_RESULT(no);
5082         fi
5084                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
5085                 AC_TRY_LINK([\
5086 #include <sys/socket.h>
5087 #include <sys/uio.h>],
5089         int fromfd, tofd;
5090         size_t total=0;
5091         struct iovec hdtrl[2];
5092         ssize_t nwritten;
5093         off_t offset;
5095         hdtrl[0].iov_base = 0;
5096         hdtrl[0].iov_len = 0;
5098         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
5100 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5101         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5102                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5103                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
5104                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5105         else
5106                 AC_MSG_RESULT(no);
5107         fi
5108         ;;
5110         *solaris*)
5111                 AC_CHECK_LIB(sendfile,sendfilev)
5112                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
5113                 AC_TRY_LINK([\
5114 #include <sys/sendfile.h>],
5116         int sfvcnt;
5117         size_t xferred;
5118         struct sendfilevec vec[2];
5119         ssize_t nwritten;
5120         int tofd;
5122         sfvcnt = 2;
5124         vec[0].sfv_fd = SFV_FD_SELF;
5125         vec[0].sfv_flag = 0;
5126         vec[0].sfv_off = 0;
5127         vec[0].sfv_len = 0;
5129         vec[1].sfv_fd = 0;
5130         vec[1].sfv_flag = 0;
5131         vec[1].sfv_off = 0;
5132         vec[1].sfv_len = 0;
5133         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
5135 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
5137         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
5138                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
5139                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
5140                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
5141         else
5142                 AC_MSG_RESULT(no);
5143         fi
5145                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
5146                 AC_TRY_LINK([\
5147 #include <sys/sendfile.h>],
5149         int sfvcnt;
5150         size_t xferred;
5151         struct sendfilevec vec[2];
5152         ssize_t nwritten;
5153         int tofd;
5155         sfvcnt = 2;
5157         vec[0].sfv_fd = SFV_FD_SELF;
5158         vec[0].sfv_flag = 0;
5159         vec[0].sfv_off = 0;
5160         vec[0].sfv_len = 0;
5162         vec[1].sfv_fd = 0;
5163         vec[1].sfv_flag = 0;
5164         vec[1].sfv_off = 0;
5165         vec[1].sfv_len = 0;
5166         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
5168 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
5170         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
5171                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
5172                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
5173                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5174         else
5175                 AC_MSG_RESULT(no);
5176         fi
5177         ;;
5178         *aix*)
5179                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
5180                 AC_TRY_LINK([\
5181 #include <sys/socket.h>],
5183         int fromfd, tofd;
5184         size_t total=0;
5185         struct sf_parms hdtrl;
5186         ssize_t nwritten;
5187         off64_t offset;
5189         hdtrl.header_data = 0;
5190         hdtrl.header_length = 0;
5191         hdtrl.file_descriptor = fromfd;
5192         hdtrl.file_offset = 0;
5193         hdtrl.file_bytes = 0;
5194         hdtrl.trailer_data = 0;
5195         hdtrl.trailer_length = 0;
5197         nwritten = send_file(&tofd, &hdtrl, 0);
5199 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
5200         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
5201                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
5202                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
5203                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
5204         else
5205                 AC_MSG_RESULT(no);
5206         fi
5207         ;;
5208         *)
5209         ;;
5210         esac
5211         ;;
5212   *)
5213     AC_MSG_RESULT(no)
5214     ;;
5215   esac ],
5216   AC_MSG_RESULT(yes)
5220 #################################################
5221 # Check whether winbind is supported on this platform.  If so we need to
5222 # build and install client programs, sbin programs and shared libraries
5224 AC_MSG_CHECKING(whether to build winbind)
5226 # Initially, the value of $host_os decides whether winbind is supported
5228 HAVE_WINBIND=yes
5230 # Define the winbind shared library name and any specific linker flags
5231 # it needs to be built with.
5233 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
5234 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
5235 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
5237 case "$host_os" in
5238         *linux*)
5239                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
5240                 ;;
5241         *freebsd[[5-9]]*)
5242                 # FreeBSD winbind client is implemented as a wrapper around
5243                 # the Linux version.
5244                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
5245                     nsswitch/winbind_nss_linux.o"
5246                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
5247                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
5248                 ;;
5249         *irix*)
5250                 # IRIX has differently named shared libraries
5251                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
5252                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
5253                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
5254                 ;;
5255         *solaris*)
5256                 # Solaris winbind client is implemented as a wrapper around
5257                 # the Linux version.
5258                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
5259                     nsswitch/winbind_nss_linux.o"
5260                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
5261                 ;;
5262         *hpux11*)
5263                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
5264                 ;;
5265         *aix*)
5266                 # AIX has even differently named shared libraries.  No
5267                 # WINS support has been implemented yet.
5268                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
5269                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
5270                 WINBIND_NSS="nsswitch/WINBIND"
5271                 WINBIND_WINS_NSS=""
5272                 ;;
5273         *)
5274                 HAVE_WINBIND=no
5275                 winbind_no_reason=", unsupported on $host_os"
5276                 ;;
5277 esac
5279 AC_SUBST(WINBIND_NSS)
5280 AC_SUBST(WINBIND_WINS_NSS)
5281 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
5282 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
5283 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
5285 # Check the setting of --with-winbind
5287 AC_ARG_WITH(winbind,
5288 [  --with-winbind          Build winbind (default, if supported by OS)],
5290   case "$withval" in
5291         yes)
5292                 HAVE_WINBIND=yes
5293                 ;;
5294         no)
5295                 HAVE_WINBIND=no
5296                 winbind_reason=""
5297                 ;;
5298   esac ],
5301 # We need unix domain sockets for winbind
5303 if test x"$HAVE_WINBIND" = x"yes"; then
5304         if test x"$samba_cv_unixsocket" = x"no"; then
5305                 winbind_no_reason=", no unix domain socket support on $host_os"
5306                 HAVE_WINBIND=no
5307         fi
5310 # Display test results
5312 if test x"$HAVE_WINBIND" = x"yes"; then
5313         AC_MSG_RESULT(yes)
5314         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
5316         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
5317         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
5318         if test $BLDSHARED = true; then
5319                 SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
5321                 if test x"$with_pam" = x"yes"; then
5322                         PAM_MODULES="$PAM_MODULES pam_winbind"
5323                         INSTALL_PAM_MODULES="installpammodules"
5324                         UNINSTALL_PAM_MODULES="uninstallpammodules"
5325                 fi
5326         fi
5327 else
5328         AC_MSG_RESULT(no$winbind_no_reason)
5331 # Solaris 10 does have new member in nss_XbyY_key
5332 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
5333                 AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
5334                 [#include <nss_dbdefs.h>])
5336 # Solaris has some extra fields in struct passwd that need to be
5337 # initialised otherwise nscd crashes.  
5339 AC_CHECK_MEMBER(struct passwd.pw_comment,
5340                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
5341                 [#include <pwd.h>])
5343 AC_CHECK_MEMBER(struct passwd.pw_age,
5344                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
5345                 [#include <pwd.h>])
5347 # AIX 4.3.x and 5.1 do not have as many members in
5348 # struct secmethod_table as AIX 5.2
5349 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
5350        [#include <usersec.h>])
5351 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
5352        [#include <usersec.h>])
5355 #################################################
5356 # Check to see if we should use the included popt 
5358 AC_ARG_WITH(included-popt,
5359 [  --with-included-popt    use bundled popt library, not from system],
5361   case "$withval" in
5362         yes)
5363                 INCLUDED_POPT=yes
5364                 ;;
5365         no)
5366                 INCLUDED_POPT=no
5367                 ;;
5368   esac ],
5370 if test x"$INCLUDED_POPT" != x"yes"; then
5371     AC_CHECK_LIB(popt, poptGetContext,
5372                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
5375 AC_MSG_CHECKING(whether to use included popt)
5376 if test x"$INCLUDED_POPT" = x"yes"; then
5377     AC_MSG_RESULT(yes)
5378     BUILD_POPT='$(POPT_OBJS)'
5379         POPTLIBS='$(POPT_OBJS)'
5380     FLAGS1="-I$srcdir/popt"
5381 else
5382     AC_MSG_RESULT(no)
5383         BUILD_POPT=""
5384     POPTLIBS="-lpopt"
5386 AC_SUBST(BUILD_POPT)
5387 AC_SUBST(POPTLIBS)
5388 AC_SUBST(FLAGS1)
5390 #################################################
5391 # Check to see if we should use the included iniparser 
5393 AC_ARG_WITH(included-iniparser,
5394 [  --with-included-iniparser    use bundled iniparser library, not from system],
5396   case "$withval" in
5397         yes)
5398                 INCLUDED_INIPARSER=yes
5399                 ;;
5400         no)
5401                 INCLUDED_INIPARSER=no
5402                 ;;
5403   esac ],
5405 if test x"$INCLUDED_INIPARSER" != x"yes"; then
5406     AC_CHECK_LIB(iniparser, iniparser_load,
5407                  INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
5410 AC_MSG_CHECKING(whether to use included iniparser)
5411 if test x"$INCLUDED_INIPARSER" = x"yes"; then
5412     AC_MSG_RESULT(yes)
5413     BUILD_INIPARSER='$(INIPARSER_OBJ)'
5414         INIPARSERLIBS=""
5415     FLAGS1="$FLAGS1 -I$srcdir/iniparser/src"
5416 else
5417     AC_MSG_RESULT(no)
5418         BUILD_INIPARSER=""
5419     INIPARSERLIBS="-liniparser"
5421 AC_SUBST(BUILD_INIPARSER)
5422 AC_SUBST(INIPARSERLIBS)
5423 AC_SUBST(FLAGS1)
5427 #################################################
5428 # Check if the user wants Python
5430 # At the moment, you can use this to set which Python binary to link
5431 # against.  (Libraries built for Python2.2 can't be used by 2.1,
5432 # though they can coexist in different directories.)  In the future
5433 # this might make the Python stuff be built by default.
5435 # Defaulting python breaks the clean target if python isn't installed
5437 PYTHON=
5439 AC_ARG_WITH(python,
5440 [  --with-python=PYTHONNAME  build Python libraries],
5441 [ case "${withval-python}" in
5442   yes)
5443         PYTHON=python
5444         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
5445         ;;
5446   no)
5447         PYTHON=
5448         ;;
5449   *)
5450         PYTHON=${withval-python}
5451         ;;
5452   esac ])
5453 AC_SUBST(PYTHON)
5455 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
5457         eval MODULE_DEFAULT_$i=STATIC
5458 done
5460 for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
5462         dnl Fall back to static if we cannot build shared libraries
5463         eval MODULE_DEFAULT_$i=STATIC
5465         if test $BLDSHARED = true; then
5466                 eval MODULE_DEFAULT_$i=SHARED
5467         fi
5468 done
5470 dnl Always built these modules static
5471 MODULE_rpc_spoolss=STATIC
5472 MODULE_rpc_srv=STATIC
5473 MODULE_idmap_tdb=STATIC
5475 AC_ARG_WITH(static-modules,
5476 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
5477 [ if test $withval; then
5478         for i in `echo $withval | sed -e 's/,/ /g'`
5479         do
5480                 eval MODULE_$i=STATIC
5481         done
5482 fi ])
5484 AC_ARG_WITH(shared-modules,
5485 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
5486 [ if test $withval; then
5487         for i in `echo $withval | sed -e 's/,/ /g'`
5488         do
5489                         eval MODULE_$i=SHARED
5490         done
5491 fi ])
5493 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB, 
5494                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
5495 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
5496 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
5497 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
5500 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
5501 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
5502 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
5503 SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
5504 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
5505 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
5506 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
5507 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
5508 SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
5509 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
5510 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
5511 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
5512 SMB_MODULE(rpc_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
5513 SMB_SUBSYSTEM(RPC,smbd/server.o)
5515 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
5516 SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
5517 SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
5518 SMB_MODULE(idmap_ad, sam/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
5519 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
5521 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
5522 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
5523 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
5524 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
5525 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
5527 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
5528 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
5529 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
5530 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
5531 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
5532 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
5533 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
5534 SMB_SUBSYSTEM(AUTH,auth/auth.o)
5536 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
5537 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
5538 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
5539 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
5540 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
5541 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
5542 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
5543 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
5544 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
5545 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
5546 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
5547 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
5548 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
5549 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
5551 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
5553 #################################################
5554 # do extra things if we are running insure
5556 if test "${ac_cv_prog_CC}" = "insure"; then
5557         CPPFLAGS="$CPPFLAGS -D__INSURE__"
5560 #################################################
5561 # Display summary of libraries detected
5563 AC_MSG_RESULT([Using libraries:])
5564 AC_MSG_RESULT([    LIBS = $LIBS])
5565 if test x"$with_ads_support" != x"no"; then
5566    AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
5568 if test x"$with_ldap_support" != x"no"; then
5569    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
5571 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
5573 #################################################
5574 # final configure stuff
5576 AC_MSG_CHECKING([configure summary])
5577 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
5578            AC_MSG_RESULT(yes),
5579            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
5580            AC_MSG_WARN([cannot run when cross-compiling]))
5582 builddir=`pwd`
5583 AC_SUBST(builddir)
5585 # Stuff the smbd-only libraries at the end of the smbd link
5586 # path (if we have them).
5587 SMBD_LIBS="$samba_fam_libs $samba_dmapi_libs"
5588 AC_SUBST(SMBD_LIBS)
5590 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
5591 LIB_REMOVE_USR_LIB(LDFLAGS)
5592 LIB_REMOVE_USR_LIB(LIBS)
5594 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
5595 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
5596 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
5598 AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)
5600 #################################################
5601 # Print very concise instructions on building/use
5602 if test "x$enable_dmalloc" = xyes
5603 then
5604         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
5605         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])