r5735: rest of derrel's patch for BUG 2308; had to move the options structure from...
[Samba.git] / source / configure.in
blob7338b879eea59fb3e7678a0cc3847dd795d7e341
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 lockdir="\${VARDIR}/locks"
26 piddir="\${VARDIR}/locks"
27 mandir="\${prefix}/man"
28 logfilebase="\${VARDIR}"
29 privatedir="\${prefix}/private"
30 libdir="\${prefix}/lib"
31 configdir="\${LIBDIR}"
32 swatdir="\${prefix}/swat"
34 AC_ARG_WITH(fhs, 
35 [  --with-fhs              Use FHS-compliant paths (default=no)],
36 [ case "$withval" in
37   yes)
38     lockdir="\${VARDIR}/lib/samba"
39     piddir="\${VARDIR}/run"
40     mandir="\${prefix}/share/man"
41     logfilebase="\${VARDIR}/log/samba"
42     privatedir="\${CONFIGDIR}/private"
43     libdir="\${prefix}/lib/samba"
44     configdir="${sysconfdir}/samba"
45     swatdir="\${DATADIR}/samba/swat"
46     ;;
47   esac])
49 #################################################
50 # set private directory location
51 AC_ARG_WITH(privatedir,
52 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
53 [ case "$withval" in
54   yes|no)
55   #
56   # Just in case anybody calls it without argument
57   #
58     AC_MSG_WARN([--with-privatedir called without argument - will use default])
59   ;;
60   * )
61     privatedir="$withval"
62     ;;
63   esac])
65 #################################################
66 # set lock directory location
67 AC_ARG_WITH(lockdir,
68 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
69 [ case "$withval" in
70   yes|no)
71   #
72   # Just in case anybody calls it without argument
73   #
74     AC_MSG_WARN([--with-lockdir called without argument - will use default])
75   ;;
76   * )
77     lockdir="$withval"
78     ;;
79   esac])
81 #################################################
82 # set pid directory location
83 AC_ARG_WITH(piddir,
84 [  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
85 [ case "$withval" in
86   yes|no)
87   #
88   # Just in case anybody calls it without argument
89   #
90     AC_MSG_WARN([--with-piddir called without argument - will use default])
91   ;;
92   * )
93     piddir="$withval"
94     ;;
95   esac])
97 #################################################
98 # set SWAT directory location
99 AC_ARG_WITH(swatdir,
100 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
101 [ case "$withval" in
102   yes|no)
103   #
104   # Just in case anybody does it
105   #
106     AC_MSG_WARN([--with-swatdir called without argument - will use default])
107   ;;
108   * )
109     swatdir="$withval"
110     ;;
111   esac])
113 #################################################
114 # set configuration directory location
115 AC_ARG_WITH(configdir,
116 [  --with-configdir=DIR    Where to put configuration files ($libdir)],
117 [ case "$withval" in
118   yes|no)
119   #
120   # Just in case anybody does it
121   #
122     AC_MSG_WARN([--with-configdir called without argument - will use default])
123   ;;
124   * )
125     configdir="$withval"
126     ;;
127   esac])
129 #################################################
130 # set log directory location
131 AC_ARG_WITH(logfilebase,
132 [  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
133 [ case "$withval" in
134   yes|no)
135   #
136   # Just in case anybody does it
137   #
138     AC_MSG_WARN([--with-logfilebase called without argument - will use default])
139   ;;
140   * )
141     logfilebase="$withval"
142     ;;
143   esac])
145 #################################################
146 # set lib directory location
147 AC_ARG_WITH(libdir,
148 [  --with-libdir=DIR       Where to put libdir ($libdir)],
149 [ case "$withval" in
150   yes|no)
151   #
152   # Just in case anybody does it
153   #
154     AC_MSG_WARN([--with-libdir without argument - will use default])
155   ;;
156   * )
157     libdir="$withval"
158     ;;
159   esac])
161 #################################################
162 # set lib directory location
163 AC_ARG_WITH(mandir,
164 [  --with-mandir=DIR       Where to put man pages ($mandir)],
165 [ case "$withval" in
166   yes|no)
167   #
168   # Just in case anybody does it
169   #
170     AC_MSG_WARN([--with-mandir without argument - will use default])
171   ;;
172   * )
173     mandir="$withval"
174     ;;
175   esac])
177 AC_ARG_WITH(cfenc,
178 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
179                           for optimization (Mac OS X/Darwin only)],
181 # May be in source $withval/CoreFoundation/StringEncodings.subproj.
182 # Should have been in framework $withval/CoreFoundation.framework/Headers.
183 for d in \
184     $withval/CoreFoundation/StringEncodings.subproj \
185     $withval/StringEncodings.subproj \
186     $withval/CoreFoundation.framework/Headers \
187     $withval/Headers \
188     $withval
190     if test -r $d/CFStringEncodingConverter.h; then
191         ln -sfh $d include/CoreFoundation
192     fi
193 done
196 AC_SUBST(configdir)
197 AC_SUBST(lockdir)
198 AC_SUBST(piddir)
199 AC_SUBST(logfilebase)
200 AC_SUBST(privatedir)
201 AC_SUBST(swatdir)
202 AC_SUBST(bindir)
203 AC_SUBST(sbindir)
205 dnl Unique-to-Samba variables we'll be playing with.
206 AC_SUBST(SHELL)
207 AC_SUBST(LDSHFLAGS)
208 AC_SUBST(SONAMEFLAG)
209 AC_SUBST(SHLD)
210 AC_SUBST(HOST_OS)
211 AC_SUBST(PICFLAGS)
212 AC_SUBST(PICSUFFIX)
213 AC_SUBST(SHLIBEXT)
214 AC_SUBST(INSTALLCLIENT)
215 AC_SUBST(INSTALLCLIENTCMD_SH)
216 AC_SUBST(INSTALLCLIENTCMD_A)
217 AC_SUBST(LIBSMBCLIENT_SHARED)
218 AC_SUBST(LIBSMBCLIENT)
219 AC_SUBST(PRINT_LIBS)
220 AC_SUBST(AUTH_LIBS)
221 AC_SUBST(ACL_LIBS)
222 AC_SUBST(PASSDB_LIBS)
223 AC_SUBST(IDMAP_LIBS)
224 AC_SUBST(KRB5_LIBS)
225 AC_SUBST(LDAP_LIBS)
226 AC_SUBST(SHLIB_PROGS)
227 AC_SUBST(SMBWRAPPER)
228 AC_SUBST(EXTRA_BIN_PROGS)
229 AC_SUBST(EXTRA_SBIN_PROGS)
230 AC_SUBST(EXTRA_ALL_TARGETS)
232 AC_ARG_ENABLE(debug, 
233 [  --enable-debug          Turn on compiler debugging information (default=no)],
234     [if eval "test x$enable_debug = xyes"; then
235         CFLAGS="${CFLAGS} -g"
236     fi])
238 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
239     [if eval "test x$enable_developer = xyes"; then
240         developer=yes
241         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
242         # Add -Wdeclaration-after-statement if compiler supports it
243         AC_CACHE_CHECK(
244           [that the C compiler understands -Wdeclaration-after-statement],
245           samba_cv_HAVE_Wdeclaration_after_statement, [
246           AC_TRY_RUN_STRICT([
247             int main(void)
248             {
249                 return 0;
250             }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
251             samba_cv_HAVE_Wdeclaration_after_statement=yes,
252             samba_cv_HAVE_Wdeclaration_after_statement=no,
253             samba_cv_HAVE_Wdeclaration_after_statement=cross)
254        ])
255        if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
256             CFLAGS="${CFLAGS} -Wdeclaration-after-statement"
257        fi
258     fi])
260 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
261     [if eval "test x$enable_krb5developer = xyes"; then
262         developer=yes
263         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
264     fi])
266 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
268 if test "x$enable_dmalloc" = xyes
269 then
270         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
271         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
272                   [Define to check invariants around some common functions])
273         LIBS="$LIBS -ldmalloc"  
276 dnl Checks for programs.
279 ## for some reason this macro resets the CFLAGS
280 ## so save and restore
282 OLD_CFLAGS=${CFLAGS}
283 AC_PROG_CC
284 CFLAGS=${OLD_CFLAGS}
286 OLD_CFLAGS=${CFLAGS}
287 AC_PROG_CPP
288 CFLAGS=${OLD_CFLAGS}
290 AC_PROG_INSTALL
291 AC_PROG_AWK
292 AC_PATH_PROG(PERL, perl)
294 AC_CHECK_TOOL(AR, ar)
296 # compile with optimization and without debugging by default, but
297 # allow people to set their own preference.
298 if test "x$CFLAGS" = x
299 then
300   CFLAGS="-O ${CFLAGS}"
303 dnl Check if we use GNU ld
304 LD=ld
305 AC_PROG_LD_GNU
307 dnl Certain versions of GNU ld the default is not to have the 
308 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
309 dnl warnings when building modules.
310 if test "$ac_cv_prog_gnu_ld" = "yes"; then
311         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
312         AC_MSG_CHECKING(GNU ld release date)
313         changequote(,)dnl
314         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'`
315         changequote([,])dnl
316         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
317         if test -n "$ac_cv_gnu_ld_date"; then
318            if test "$ac_cv_gnu_ld_date" -lt 20030217; then
319               ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
320            fi
321         else
322            AC_MSG_CHECKING(GNU ld release version)
323            changequote(,)dnl
324            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
325            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
326            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
327            changequote([,])dnl
328            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
329            AC_MSG_CHECKING(GNU ld release version major)
330            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
331            AC_MSG_CHECKING(GNU ld release version minor)
332            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
333            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
334              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
335            fi
336         fi
339 dnl needed before AC_TRY_COMPILE
340 AC_ISC_POSIX
342 dnl look for executable suffix
343 AC_EXEEXT
345 dnl Check if C compiler understands -c and -o at the same time
346 AC_PROG_CC_C_O
347 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
348       BROKEN_CC=
349 else
350       BROKEN_CC=#
352 AC_SUBST(BROKEN_CC)
354 dnl Check if the C compiler understands -Werror
355 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
356  AC_TRY_RUN_STRICT([
357   int main(void)
358   {
359         return 0;
360   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
361   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
362 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
363    Werror_FLAGS="-Werror"
364 else 
365 dnl Check if the C compiler understands -w2
366 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
367  AC_TRY_RUN_STRICT([
368   int main(void)
369   {
370         return 0;
371   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
372   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
373 if test x"$samba_cv_HAVE_w2" = x"yes"; then
374    Werror_FLAGS="-w2"
378 dnl Check if the C compiler understands volatile (it should, being ANSI).
379 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
380     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
381         samba_cv_volatile=yes,samba_cv_volatile=no)])
382 if test x"$samba_cv_volatile" = x"yes"; then
383    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
386 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
387 AC_MSG_CHECKING(uname -s)
388 AC_MSG_RESULT(${UNAME_S})
390 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
391 AC_MSG_CHECKING(uname -r)
392 AC_MSG_RESULT(${UNAME_R})
394 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
395 AC_MSG_CHECKING(uname -m)
396 AC_MSG_RESULT(${UNAME_M})
398 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
399 AC_MSG_CHECKING(uname -p)
400 AC_MSG_RESULT(${UNAME_P})
402 AC_CANONICAL_SYSTEM
404 dnl Add #include for broken IRIX header files
405   case "$host_os" in
406         *irix6*) AC_ADD_INCLUDE(<standards.h>)
407         ;;
408 esac
410 AC_VALIDATE_CACHE_SYSTEM_TYPE
412 DYNEXP=
414 dnl Add modules that have to be built by default here
415 dnl These have to be built static:
416 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
418 dnl These are preferably build shared, and static if dlopen() is not available
419 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"
421 if test "x$developer" = xyes; then
422    default_static_modules="$default_static_modules rpc_echo"
423    default_shared_modules="$default_shared_modules charset_weird"
427 # Config CPPFLAG settings for strange OS's that must be set
428 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
429 # case statement; its first reference must be unconditional.
431 case "$host_os" in
432 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
433     *hpux*)
434     
435       AC_PROG_CC_FLAG(Ae)
436       # mmap on HPUX is completely broken...
437       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
438       if test $ac_cv_prog_cc_Ae = yes; then
439         CPPFLAGS="$CPPFLAGS -Ae"
440       fi
442 # Defines needed for HPUX support.
443 # HPUX has bigcrypt but (sometimes?) doesn't use it for
444 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
446       case `uname -r` in
447                         *9*|*10*)
448                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
449                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
450                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
451                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
452                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
453                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
454                                 ;;
455                         *11*)
456                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
457                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
458                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
459                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
460                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
461                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
462                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
463                                 ;;
464       esac
465       ;;
468 # CRAY Unicos has broken const handling
469        *unicos*)
470           AC_MSG_RESULT([disabling const])
471           CPPFLAGS="$CPPFLAGS -Dconst="
472           ;;
473         
475 # AIX4.x doesn't even admit to having large
476 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
478     *aix4*)
479           AC_MSG_RESULT([enabling large file support])
480       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
481           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
482       ;;    
484 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
485 # to the existance of large files..
486 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
487 # recommendations on large file support, however it makes the
488 # compile work using gcc 2.7 and 2.8, whereas using the Sun
489 # recommendation makes the compile fail on gcc2.7. JRA.
491 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
493         *solaris*)
494                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
495                 case `uname -r` in
496                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
497                                 AC_MSG_RESULT([no large file support])
498                                 ;;
499                         5.*)
500                         AC_MSG_RESULT([enabling large file support])
501                         if test "$ac_cv_prog_gcc" = yes; then
502                                 ${CC-cc} -v >conftest.c 2>&1
503                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
504                                 rm -fr conftest.c
505                                 case "$ac_cv_gcc_compiler_version_number" in
506                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
507                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
508                                                 LDFLAGS="$LDFLAGS -lthread"
509                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
510                                                 ;;
511                                         *)
512                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
513                                                 LDFLAGS="$LDFLAGS -lthread"
514                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
515                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
516                                                 ;;
517                                 esac
518                         else
519                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
520                                 LDFLAGS="$LDFLAGS -lthread"
521                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
522                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
523                         fi
524                         ;;
525                 esac
526                 ;;
528 # IRIX uses SYSV printing.  Make sure to set that here
530         *irix*)
531                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
532                 ;;
533         *freebsd*|*DragonFly*)
534                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
535                 ;;
537 # VOS may need to have POSIX support and System V compatibility enabled.
539     *vos*)
540     case "$CPPFLAGS" in
541           *-D_POSIX_C_SOURCE*)
542                 ;;
543           *)
544                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
545                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
546                 ;;
547     esac
548     case "$CPPFLAGS" in
549           *-D_SYSV*|*-D_SVID_SOURCE*)
550                 ;;
551           *)
552                 CPPFLAGS="$CPPFLAGS -D_SYSV"
553                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
554     esac
555     ;;
557 # Tests needed for SINIX large file support.
559     *sysv4*)
560       if test $host = mips-sni-sysv4 ; then
561         AC_MSG_CHECKING([for LFS support])
562         old_CPPFLAGS="$CPPFLAGS"
563         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
564         AC_TRY_RUN([
565 #include <unistd.h>
566 main () {
567 #if _LFS64_LARGEFILE == 1
568 exit(0);
569 #else
570 exit(1);
571 #endif
572 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
573         CPPFLAGS="$old_CPPFLAGS"
574         if test x$SINIX_LFS_SUPPORT = xyes ; then
575           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
576                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
577           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
578           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
579           LIBS="`getconf LFS64_LIBS` $LIBS"
580         fi
581       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
582       fi
583     ;;
585 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
587     *linux*)
588         AC_MSG_CHECKING([for LFS support])
589         old_CPPFLAGS="$CPPFLAGS"
590         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
591        AC_TRY_RUN([
592 #include <unistd.h>
593 #include <sys/utsname.h>
594 #include <string.h>
595 #include <stdlib.h>
596 main() {
597 #if _LFS64_LARGEFILE == 1
598        struct utsname uts;
599        char *release;
600        int major, minor;
602        /* Ensure this is glibc 2.2 or higher */
603 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
604        int libc_major = __GLIBC__;
605        int libc_minor = __GLIBC_MINOR__;
607        if (libc_major < 2)
608               exit(1);
609        if (libc_minor < 2)
610               exit(1);
611 #endif
613        /* Ensure this is kernel 2.4 or higher */
615        uname(&uts);
616        release = strdup(uts.release);
617        major = atoi(strsep(&release, "."));
618        minor = atoi(strsep(&release, "."));
620        if (major > 2 || (major == 2 && minor > 3))
621                exit(0);
622        exit(1);
623 #else
624        exit(1);
625 #endif
627 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
628         CPPFLAGS="$old_CPPFLAGS"
629         if test x$LINUX_LFS_SUPPORT = xyes ; then
630                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
631                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
632                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
633                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
634         fi
635         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
636         ;;
639 # MacOS X is the *only* system that uses compose character in utf8. This
640 # is so horribly broken....
642     *darwin*)
643         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
644 # Add Fink directories for various packages, like dlcompat.
645 # Note: iconv does that explicitly below, but other packages
646 # don't.
647         CPPFLAGS="$CPPFLAGS -I/sw/include"
648         LDFLAGS="$LDFLAGS -L/sw/lib"
650 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
651 # use that instead of plain dlsym.
653         AC_CHECK_LIB(dl,dlopen)
654         AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
656 # Add a system specific charset module.
658         default_shared_modules="$default_shared_modules charset_macosxfs"
659         ;;
660     *hurd*)
661         AC_MSG_CHECKING([for LFS support])
662         old_CPPFLAGS="$CPPFLAGS"
663         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
664         AC_TRY_RUN([
665 #include <unistd.h>
666 main () {
667 #if _LFS64_LARGEFILE == 1
668 exit(0);
669 #else
670 exit(1);
671 #endif
672 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
673         CPPFLAGS="$old_CPPFLAGS"
674         if test x$GLIBC_LFS_SUPPORT = xyes ; then
675           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
676                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
677           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
678         fi
679       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
680     ;;
682 esac
684 AC_INLINE
685 AC_HEADER_STDC
686 AC_HEADER_DIRENT
687 AC_HEADER_TIME
688 AC_HEADER_SYS_WAIT
689 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
690 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h)
691 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
692 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
693 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
694 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
695 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
696 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
697 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
698 AC_CHECK_HEADERS(langinfo.h locale.h)
700 # Look for Darwin headers
701 old_CPPFLAGS="$CPPFLAGS"
702 CPPFLAGS="-Iinclude $CPPFLAGS"
703 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
704 CPPFLAGS="$old_CPPFLAGS"
706 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
707 # subdirectory of headers.
708 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
711 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
712 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
714 case "$host_os" in
715     *hpux*)
716                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
717                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
718                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
719                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
720                 fi
721         ;;
722 esac
723 AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
724 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
725 AC_CHECK_HEADERS(stropts.h poll.h)
726 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
727 AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/cdefs.h glob.h)
728 # These faile to compile on Solaris so just check for their presence
729 AC_CHECK_HEADERS(security/pam_modules.h net/if.h netinet/ip.h, [], [], -)
731 # For experimental utmp support (lastlog on some BSD-like systems)
732 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
734 AC_CHECK_SIZEOF(int,cross)
735 AC_CHECK_SIZEOF(long,cross)
736 AC_CHECK_SIZEOF(short,cross)
738 AC_C_CONST
739 AC_C_INLINE
740 AC_C_BIGENDIAN
741 AC_C_CHAR_UNSIGNED
743 AC_TYPE_SIGNAL
744 AC_TYPE_UID_T
745 AC_TYPE_MODE_T
746 AC_TYPE_OFF_T
747 AC_TYPE_SIZE_T
748 AC_TYPE_PID_T
749 AC_STRUCT_ST_RDEV
750 AC_DIRENT_D_OFF
751 AC_CHECK_TYPE(ino_t,unsigned)
752 AC_CHECK_TYPE(loff_t,off_t)
753 AC_CHECK_TYPE(offset_t,loff_t)
754 AC_CHECK_TYPE(ssize_t, int)
755 AC_CHECK_TYPE(wchar_t, unsigned short)
757 ############################################
758 # for cups support we need libcups, and a handful of header files
760 AC_ARG_ENABLE(cups,
761 [  --enable-cups           Turn on CUPS support (default=auto)])
763 if test x$enable_cups != xno; then
764         AC_PATH_PROG(CUPS_CONFIG, cups-config)
766         if test "x$CUPS_CONFIG" != x; then
767                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
768                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
769                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
770                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
771         elif test x"$enable_cups" = x"yes"; then
772                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
773         fi
776 ############################################
777 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
778 AC_SEARCH_LIBS(dlopen, [dl])
779 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
781 ############################################
782 # check if the compiler can do immediate structures
783 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
784     AC_TRY_COMPILE([
785 #include <stdio.h>],
787    typedef struct {unsigned x;} FOOBAR;
788    #define X_FOOBAR(x) ((FOOBAR) { x })
789    #define FOO_ONE X_FOOBAR(1)
790    FOOBAR f = FOO_ONE;   
791    static struct {
792         FOOBAR y; 
793         } f2[] = {
794                 {FOO_ONE}
795         };   
797         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
798 if test x"$samba_cv_immediate_structures" = x"yes"; then
799    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
802 ############################################
803 # check if the compiler can do immediate structures
804 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
805     AC_TRY_LINK([
806 #include <stdio.h>],
808                 if (0) {
809                    this_function_does_not_exist();
810                 } else {
811                   return 1;
812                 }
815         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
816 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
817    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
820 ############################################
821 # check for unix domain sockets
822 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
823     AC_TRY_COMPILE([
824 #include <sys/types.h>
825 #include <stdlib.h>
826 #include <stddef.h>
827 #include <sys/socket.h>
828 #include <sys/un.h>],
830   struct sockaddr_un sunaddr; 
831   sunaddr.sun_family = AF_UNIX;
833         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
834 if test x"$samba_cv_unixsocket" = x"yes"; then
835    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
839 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
840     AC_TRY_COMPILE([
841 #include <sys/types.h>
842 #if STDC_HEADERS
843 #include <stdlib.h>
844 #include <stddef.h>
845 #endif
846 #include <sys/socket.h>],[socklen_t i = 0],
847         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
848 if test x"$samba_cv_socklen_t" = x"yes"; then
849    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
852 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
853     AC_TRY_COMPILE([
854 #include <sys/types.h>
855 #if STDC_HEADERS
856 #include <stdlib.h>
857 #include <stddef.h>
858 #endif
859 #include <signal.h>],[sig_atomic_t i = 0],
860         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
861 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
862    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
865 # stupid headers have the functions but no declaration. grrrr.
866 AC_HAVE_DECL(errno, [#include <errno.h>])
867 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
868 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
869 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
870 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
871 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
872 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
874 # and glibc has setresuid under linux but the function does
875 # nothing until kernel 2.1.44! very dumb.
876 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
877     AC_TRY_RUN([#include <errno.h>
878 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
879         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
880 if test x"$samba_cv_have_setresuid" = x"yes"; then
881     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
884 # Do the same check for setresguid...
886 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
887     AC_TRY_RUN([#include <unistd.h>
888 #include <errno.h>
889 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
890         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
891 if test x"$samba_cv_have_setresgid" = x"yes"; then
892     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
895 AC_FUNC_MEMCMP
897 ###############################################
898 # Readline included by default unless explicitly asked not to
899 test "${with_readline+set}" != "set" && with_readline=yes
901 # test for where we get readline() from
902 AC_MSG_CHECKING(whether to use readline)
903 AC_ARG_WITH(readline,
904 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
905 [  case "$with_readline" in
906   yes)
907     AC_MSG_RESULT(yes)
909     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
910     AC_CHECK_HEADERS(readline/history.h)
912     AC_CHECK_HEADERS(readline.h readline/readline.h,[
913       for termlib in ncurses curses termcap terminfo termlib tinfo; do
914        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
915       done
916       AC_CHECK_LIB(readline, rl_callback_handler_install,
917        [TERMLIBS="-lreadline $TERMLIBS"
918        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
919        break], [TERMLIBS=], $TERMLIBS)])
920     ;;
921   no)
922     AC_MSG_RESULT(no)
923     ;;
924   *)
925     AC_MSG_RESULT(yes)
927     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
928     # alternate readline path
929     _ldflags=${LDFLAGS}
930     _cppflags=${CPPFLAGS}
932     # Add additional search path
933     LDFLAGS="-L$with_readline/lib $LDFLAGS"
934     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
936     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
937     AC_CHECK_HEADERS(readline/history.h)
939     AC_CHECK_HEADERS(readline.h readline/readline.h,[
940       for termlib in ncurses curses termcap terminfo termlib; do
941        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
942       done
943       AC_CHECK_LIB(readline, rl_callback_handler_install,
944        [TERMLDFLAGS="-L$with_readline/lib"
945        TERMCPPFLAGS="-I$with_readline/include"
946        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
947        TERMLIBS="-lreadline $TERMLIBS"
948        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
949        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
951     LDFLAGS=$_ldflags
952     ;;
953   esac],
954   AC_MSG_RESULT(no)
956 AC_SUBST(TERMLIBS)
957 AC_SUBST(TERMLDFLAGS)
959 # The readline API changed slightly from readline3 to readline4, so
960 # code will generate warnings on one of them unless we have a few
961 # special cases.
962 AC_CHECK_LIB(readline, rl_completion_matches,
963              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
964                         [Do we have rl_completion_matches?])],
965              [],
966              [$TERMLIBS])
968 # The following test taken from the cvs sources
969 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
970 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
971 # libsocket.so which has a bad implementation of gethostbyname (it
972 # only looks in /etc/hosts), so we only look for -lsocket if we need
973 # it.
974 AC_CHECK_FUNCS(connect)
975 if test x"$ac_cv_func_connect" = x"no"; then
976     case "$LIBS" in
977     *-lnsl*) ;;
978     *) AC_CHECK_LIB(nsl_s, printf) ;;
979     esac
980     case "$LIBS" in
981     *-lnsl*) ;;
982     *) AC_CHECK_LIB(nsl, printf) ;;
983     esac
984     case "$LIBS" in
985     *-lsocket*) ;;
986     *) AC_CHECK_LIB(socket, connect) ;;
987     esac
988     case "$LIBS" in
989     *-linet*) ;;
990     *) AC_CHECK_LIB(inet, connect) ;;
991     esac
992     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
993     dnl has been cached.
994     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
995        test x"$ac_cv_lib_inet_connect" = x"yes"; then
996         # ac_cv_func_connect=yes
997         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
998         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
999     fi
1002 ###############################################
1003 # test for where we get yp_get_default_domain() from
1004 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1005 AC_CHECK_FUNCS(yp_get_default_domain)
1007 # Check if we have execl, if not we need to compile smbrun.
1008 AC_CHECK_FUNCS(execl)
1009 if test x"$ac_cv_func_execl" = x"no"; then
1010     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1013 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
1014 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
1015 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
1016 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1017 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1018 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
1019 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
1020 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1021 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1022 AC_CHECK_FUNCS(syslog vsyslog timegm)
1023 AC_CHECK_FUNCS(setlocale nl_langinfo)
1024 AC_CHECK_FUNCS(nanosleep)
1025 # setbuffer, shmget, shm_open are needed for smbtorture
1026 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
1027 AC_CHECK_HEADERS(libexc.h)
1028 AC_CHECK_LIB(exc, trace_back_stack)
1030 # syscall() is needed for smbwrapper.
1031 AC_CHECK_FUNCS(syscall)
1033 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1034 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1035 AC_CHECK_FUNCS(__getcwd _getcwd)
1036 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1037 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1038 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1039 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1040 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
1041 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1042 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1043 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1044 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1045 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1046 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1051 case "$host_os" in
1052     *linux*)
1053        # glibc <= 2.3.2 has a broken getgrouplist
1054        AC_TRY_RUN([
1055 #include <unistd.h>
1056 #include <sys/utsname.h>
1057 main() {
1058        /* glibc up to 2.3 has a broken getgrouplist */
1059 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1060        int libc_major = __GLIBC__;
1061        int libc_minor = __GLIBC_MINOR__;
1063        if (libc_major < 2)
1064               exit(1);
1065        if ((libc_major == 2) && (libc_minor <= 3))
1066               exit(1);
1067 #endif
1068        exit(0);
1070 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1071        if test x"$linux_getgrouplist_ok" = x"yes"; then
1072           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1073        fi
1074        ;;
1075     *)
1076        AC_CHECK_FUNCS(getgrouplist)
1077        ;;
1078 esac
1081 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1084 if test x$ac_cv_func_stat64 = xno ; then
1085   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1086   AC_TRY_LINK([
1087 #if defined(HAVE_UNISTD_H)
1088 #include <unistd.h>
1089 #endif
1090 #include <sys/stat.h>
1091 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1092   AC_MSG_RESULT([$ac_cv_func_stat64])
1093   if test x$ac_cv_func_stat64 = xyes ; then
1094     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1095   fi
1098 if test x$ac_cv_func_lstat64 = xno ; then
1099   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1100   AC_TRY_LINK([
1101 #if defined(HAVE_UNISTD_H)
1102 #include <unistd.h>
1103 #endif
1104 #include <sys/stat.h>
1105 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1106   AC_MSG_RESULT([$ac_cv_func_lstat64])
1107   if test x$ac_cv_func_lstat64 = xyes ; then
1108     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1109   fi
1112 if test x$ac_cv_func_fstat64 = xno ; then
1113   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1114   AC_TRY_LINK([
1115 #if defined(HAVE_UNISTD_H)
1116 #include <unistd.h>
1117 #endif
1118 #include <sys/stat.h>
1119 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1120   AC_MSG_RESULT([$ac_cv_func_fstat64])
1121   if test x$ac_cv_func_fstat64 = xyes ; then
1122     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1123   fi
1126 #####################################
1127 # we might need the resolv library on some systems
1128 AC_CHECK_LIB(resolv, dn_expand)
1131 # Check for the functions putprpwnam, set_auth_parameters,
1132 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1133 # Needed for OSF1 and HPUX.
1136 AC_LIBTESTFUNC(security, putprpwnam)
1137 AC_LIBTESTFUNC(sec, putprpwnam)
1139 AC_LIBTESTFUNC(security, set_auth_parameters)
1140 AC_LIBTESTFUNC(sec, set_auth_parameters)
1142 # UnixWare 7.x has its getspnam in -lgen
1143 AC_LIBTESTFUNC(gen, getspnam)
1145 AC_LIBTESTFUNC(security, getspnam)
1146 AC_LIBTESTFUNC(sec, getspnam)
1148 AC_LIBTESTFUNC(security, bigcrypt)
1149 AC_LIBTESTFUNC(sec, bigcrypt)
1151 AC_LIBTESTFUNC(security, getprpwnam)
1152 AC_LIBTESTFUNC(sec, getprpwnam)
1154 ############################################
1155 # Check if we have libattr
1156 AC_SEARCH_LIBS(getxattr, [attr])
1157 AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1158 AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1159 AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1160 AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1161 AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1163 # Assume non-shared by default and override below
1164 BLDSHARED="false"
1166 # these are the defaults, good for lots of systems
1167 HOST_OS="$host_os"
1168 LDSHFLAGS="-shared"
1169 SONAMEFLAG="#"
1170 SHLD="\${CC} \${CFLAGS}"
1171 PICFLAGS=""
1172 PICSUFFIX="po"
1173 SHLIBEXT="so"
1175 if test "$enable_shared" = "yes"; then
1176   # this bit needs to be modified for each OS that is suported by
1177   # smbwrapper. You need to specify how to created a shared library and
1178   # how to compile C code to produce PIC object files
1180   AC_MSG_CHECKING([ability to build shared libraries])
1182   # and these are for particular systems
1183   case "$host_os" in
1184                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1185                         BLDSHARED="true"
1186                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1187                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
1188                         else
1189                                 LDSHFLAGS="-shared -Wl,-Bsymbolic" 
1190                         fi
1191                         DYNEXP="-Wl,--export-dynamic"
1192                         PICFLAGS="-fPIC"
1193                         SONAMEFLAG="-Wl,-soname="
1194                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1195                         ;;
1196                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1197                         BLDSHARED="true"
1198                         LDSHFLAGS="-G"
1199                         SONAMEFLAG="-h "
1200                         if test "${GCC}" = "yes"; then
1201                                 PICFLAGS="-fPIC"
1202                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1203                                         DYNEXP="-Wl,-E"
1204                                 fi
1205                         else
1206                                 PICFLAGS="-KPIC"
1207                                 ## ${CFLAGS} added for building 64-bit shared 
1208                                 ## libs using Sun's Compiler
1209                                 LDSHFLAGS="-G \${CFLAGS}"
1210                                 PICSUFFIX="po.o"
1211                         fi
1212                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1213                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1214                         ;;
1215                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1216                         BLDSHARED="true"
1217                         LDSHFLAGS="-G"
1218                         SONAMEFLAG="-Wl,-h,"
1219                         PICFLAGS="-KPIC"   # Is this correct for SunOS
1220                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1221                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1222                         ;;
1223                 *netbsd* | *freebsd* | *DragonFly* )  
1224                         BLDSHARED="true"
1225                         LDSHFLAGS="-shared"
1226                         DYNEXP="-Wl,--export-dynamic"
1227                         SONAMEFLAG="-Wl,-soname,"
1228                         PICFLAGS="-fPIC -DPIC"
1229                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1230                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1231                         ;;
1232                 *openbsd*)  BLDSHARED="true"
1233                         LDSHFLAGS="-shared"
1234                         DYNEXP="-Wl,-Bdynamic"
1235                         SONAMEFLAG="-Wl,-soname,"
1236                         PICFLAGS="-fPIC"
1237                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1238                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1239                         ;;
1240                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1241                         case "$host_os" in
1242                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1243                         ;;
1244                         esac
1245                         BLDSHARED="true"
1246                         LDSHFLAGS="-set_version sgi1.0 -shared"
1247                         SONAMEFLAG="-soname "
1248                         SHLD="\${LD}"
1249                         if test "${GCC}" = "yes"; then
1250                                 PICFLAGS="-fPIC"
1251                         else 
1252                                 PICFLAGS="-KPIC"
1253                         fi
1254                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1255                         ;;
1256                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1257                         BLDSHARED="true"
1258                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
1259                         DYNEXP="-Wl,-brtl,-bexpall"
1260                         PICFLAGS="-O2"
1261                         if test "${GCC}" != "yes"; then
1262                                 ## for funky AIX compiler using strncpy()
1263                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1264                         fi
1266                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1267                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1268                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1269                         ;;
1270                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1271                         SHLIBEXT="sl"
1272                         # Use special PIC flags for the native HP-UX compiler.
1273                         if test $ac_cv_prog_cc_Ae = yes; then
1274                                 BLDSHARED="true"
1275                                 SHLD="cc"
1276                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1277                                 SONAMEFLAG="-Wl,+h "
1278                                 PICFLAGS="+z"
1279                         elif test "${GCC}" = "yes"; then
1280                                 PICFLAGS="-fPIC"
1281                         fi
1282                         DYNEXP="-Wl,-E"
1283                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1284                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1285                         ;;
1286                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1287                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1288                         ;;
1289                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1290                         BLDSHARED="true"
1291                         LDSHFLAGS="-shared"
1292                         SONAMEFLAG="-Wl,-soname,"
1293                         PICFLAGS="-fPIC"
1294                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1295                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1296                         ;;
1297                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1298                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1299                         ;;
1300                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1301                         BLDSHARED="true"
1302                         LDSHFLAGS="-shared"
1303                         SONAMEFLAG="-Wl,-soname,"
1304                         PICFLAGS="-KPIC"
1305                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1306                         ;;
1307                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1308                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1309                         ;;
1310                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1311                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1312                         ;;
1313                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1314                         case "$host" in
1315                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1316                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1317                                         fi
1318                                         LDSHFLAGS="-G"
1319                                         DYNEXP="-Bexport"
1320                                 ;;
1321                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1322                         esac
1323                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1324                         ;;
1326                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1327                         if [ test "$GCC" != yes ]; then
1328                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1329                         fi
1330                         LDSHFLAGS="-G"
1331                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1332                         ;;
1333                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1334                         BLDSHARED="false"
1335                         LDSHFLAGS=""
1336                         ;;
1338                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1339                         BLDSHARED="true"
1340                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1341                         SHLIBEXT="dylib"
1342                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1343                         ;;
1345                 *)
1346                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1347                         ;;
1348   esac
1349   AC_SUBST(DYNEXP)
1350   AC_MSG_RESULT($BLDSHARED)
1351   AC_MSG_CHECKING([linker flags for shared libraries])
1352   AC_MSG_RESULT([$LDSHFLAGS])
1353   AC_MSG_CHECKING([compiler flags for position-independent code])
1354   AC_MSG_RESULT([$PICFLAGS])
1357 #######################################################
1358 # test whether building a shared library actually works
1359 if test $BLDSHARED = true; then
1360 AC_CACHE_CHECK([whether building shared libraries actually works], 
1361                [ac_cv_shlib_works],[
1362    # try building a trivial shared library
1363    ac_cv_shlib_works=no
1364    # The $SHLD and $LDSHFLAGS variables may contain references to other
1365    # variables so they need to be eval'ed.
1366    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
1367         shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
1368    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1369         shlib.$PICSUFFIX && ac_cv_shlib_works=yes
1370    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
1372 if test $ac_cv_shlib_works = no; then
1373    BLDSHARED=false
1377 ################
1379 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1380 AC_TRY_RUN([#include <stdio.h>
1381 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1382 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1383 if test x"$samba_cv_have_longlong" = x"yes"; then
1384     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1388 # Check if the compiler supports the LL prefix on long long integers.
1389 # AIX needs this.
1391 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1392     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1393         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1394 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1395    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1398   
1399 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1400 AC_TRY_RUN([#include <stdio.h>
1401 #include <sys/stat.h>
1402 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1403 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1404 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1405     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1408 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1409 AC_TRY_RUN([
1410 #if defined(HAVE_UNISTD_H)
1411 #include <unistd.h>
1412 #endif
1413 #include <stdio.h>
1414 #include <sys/stat.h>
1415 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1416 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1417 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1418     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1421 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1422 AC_TRY_RUN([#include <stdio.h>
1423 #include <sys/stat.h>
1424 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1425 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1426 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1427     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1430 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1431 AC_TRY_RUN([
1432 #if defined(HAVE_UNISTD_H)
1433 #include <unistd.h>
1434 #endif
1435 #include <stdio.h>
1436 #include <sys/stat.h>
1437 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1438 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1439 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1440     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1443 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1444 AC_TRY_RUN([
1445 #if defined(HAVE_UNISTD_H)
1446 #include <unistd.h>
1447 #endif
1448 #include <stdio.h>
1449 #include <sys/stat.h>
1450 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1451 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1452 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1453     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1456 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1457 AC_TRY_COMPILE([
1458 #if defined(HAVE_UNISTD_H)
1459 #include <unistd.h>
1460 #endif
1461 #include <sys/types.h>
1462 #include <dirent.h>],
1463 [struct dirent64 de;],
1464 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1465 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1466     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1469 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1470 AC_TRY_RUN([
1471 #if defined(HAVE_UNISTD_H)
1472 #include <unistd.h>
1473 #endif
1474 #include <sys/types.h>
1475 main() { dev_t dev; int i = major(dev); return 0; }],
1476 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1477 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1478     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1481 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1482 AC_TRY_RUN([
1483 #if defined(HAVE_UNISTD_H)
1484 #include <unistd.h>
1485 #endif
1486 #include <sys/types.h>
1487 main() { dev_t dev; int i = minor(dev); return 0; }],
1488 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1489 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1490     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1493 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1494 AC_TRY_RUN([
1495 #if defined(HAVE_UNISTD_H)
1496 #include <unistd.h>
1497 #endif
1498 #include <sys/types.h>
1499 main() { dev_t dev = makedev(1,2); return 0; }],
1500 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1501 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1502     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1505 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1506 AC_TRY_RUN([#include <stdio.h>
1507 main() { char c; c=250; exit((c > 0)?0:1); }],
1508 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1509 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1510     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1513 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1514 AC_TRY_COMPILE([#include <sys/types.h>
1515 #include <sys/socket.h>
1516 #include <netinet/in.h>],
1517 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1518 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1519 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1520     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1523 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1524 AC_TRY_COMPILE([#include <sys/types.h>
1525 #include <dirent.h>
1526 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1527 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1528 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1529     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1532 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1533 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1534 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1535 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1536     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1539 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1540 AC_TRY_RUN([
1541 #include <sys/time.h>
1542 #include <unistd.h>
1543 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1544            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1545 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1546     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
1549 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
1550 AC_TRY_LINK([#include <stdarg.h>
1551 va_list ap1,ap2;], [va_copy(ap1,ap2);],
1552 samba_cv_HAVE_VA_COPY=yes,
1553 samba_cv_HAVE_VA_COPY=no)])
1554 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1555     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
1556 else
1557     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
1558     AC_TRY_LINK([#include <stdarg.h>
1559     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1560     samba_cv_HAVE___VA_COPY=yes,
1561     samba_cv_HAVE___VA_COPY=no)])
1562     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
1563         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
1564     fi
1567 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1568 AC_TRY_RUN([
1569 #include <sys/types.h>
1570 #include <stdarg.h>
1571 void foo(const char *format, ...) { 
1572        va_list ap;
1573        int len;
1574        char buf[5];
1576        va_start(ap, format);
1577        len = vsnprintf(buf, 0, format, ap);
1578        va_end(ap);
1579        if (len != 5) exit(1);
1581        va_start(ap, format);
1582        len = vsnprintf(0, 0, format, ap);
1583        va_end(ap);
1584        if (len != 5) exit(1);
1586        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1588        exit(0);
1590 main() { foo("hello"); }
1592 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1593 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1594     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1597 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1598 AC_TRY_RUN([#include <sys/types.h>
1599 #include <dirent.h>
1600 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1601 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1602 di->d_name[0] == 0) exit(0); exit(1);} ],
1603 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1604 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1605     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1608 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1609 AC_TRY_COMPILE([#include <sys/types.h>
1610 #include <utime.h>],
1611 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1612 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1613 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1614     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1617 ##############
1618 # Check utmp details, but only if our OS offers utmp.h
1619 if test x"$ac_cv_header_utmp_h" = x"yes"; then
1620 dnl  utmp and utmpx come in many flavours
1621 dnl  We need to check for many of them
1622 dnl  But we don't need to do each and every one, because our code uses
1623 dnl  mostly just the utmp (not utmpx) fields.
1625 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1627 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1628 AC_TRY_COMPILE([#include <sys/types.h>
1629 #include <utmp.h>],
1630 [struct utmp ut;  ut.ut_name[0] = 'a';],
1631 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1632 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1633     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
1634 fi 
1636 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1637 AC_TRY_COMPILE([#include <sys/types.h>
1638 #include <utmp.h>],
1639 [struct utmp ut;  ut.ut_user[0] = 'a';],
1640 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1641 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1642     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
1643 fi 
1645 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1646 AC_TRY_COMPILE([#include <sys/types.h>
1647 #include <utmp.h>],
1648 [struct utmp ut;  ut.ut_id[0] = 'a';],
1649 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1650 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1651     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
1652 fi 
1654 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1655 AC_TRY_COMPILE([#include <sys/types.h>
1656 #include <utmp.h>],
1657 [struct utmp ut;  ut.ut_host[0] = 'a';],
1658 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1659 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1660     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
1661 fi 
1663 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1664 AC_TRY_COMPILE([#include <sys/types.h>
1665 #include <utmp.h>],
1666 [struct utmp ut;  time_t t; ut.ut_time = t;],
1667 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1668 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1669     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
1670 fi 
1672 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1673 AC_TRY_COMPILE([#include <sys/types.h>
1674 #include <utmp.h>],
1675 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1676 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1677 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1678     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
1679 fi 
1681 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1682 AC_TRY_COMPILE([#include <sys/types.h>
1683 #include <utmp.h>],
1684 [struct utmp ut;  ut.ut_type = 0;],
1685 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1686 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1687     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
1688 fi 
1690 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1691 AC_TRY_COMPILE([#include <sys/types.h>
1692 #include <utmp.h>],
1693 [struct utmp ut;  ut.ut_pid = 0;],
1694 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1695 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1696     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
1697 fi 
1699 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1700 AC_TRY_COMPILE([#include <sys/types.h>
1701 #include <utmp.h>],
1702 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1703 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1704 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1705     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
1706 fi 
1708 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1709 AC_TRY_COMPILE([#include <sys/types.h>
1710 #include <utmp.h>],
1711 [struct utmp ut;  ut.ut_addr = 0;],
1712 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1713 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1714     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
1715 fi 
1717 if test x$ac_cv_func_pututline = xyes ; then
1718   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1719   AC_TRY_COMPILE([#include <sys/types.h>
1720 #include <utmp.h>],
1721   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1722   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1723   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1724       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
1725   fi
1728 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1729 AC_TRY_COMPILE([#include <sys/types.h>
1730 #include <utmpx.h>],
1731 [struct utmpx ux;  ux.ut_syslen = 0;],
1732 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1733 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1734     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
1735 fi 
1738 # end utmp details
1741 ICONV_LOCATION=standard
1742 LOOK_DIRS="/usr /usr/local /sw /opt"
1743 AC_ARG_WITH(libiconv,
1744 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1746   if test "$withval" = "no" ; then
1747     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
1748   else
1749      if test "$withval" != "yes" ; then
1750         ICONV_PATH_SPEC=yes
1751         LOOK_DIRS="$withval"
1752      fi
1753   fi
1756 for i in $LOOK_DIRS ; do
1757     save_LIBS=$LIBS
1758     save_LDFLAGS=$LDFLAGS
1759     save_CPPFLAGS=$CPPFLAGS
1760     ICONV_FOUND="no"
1761     unset libext
1762     CPPFLAGS="$CPPFLAGS -I$i/include"
1763 dnl This is here to handle -withval stuff for --with-libiconv
1764 dnl Perhaps we should always add a -L
1766 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
1767 dnl installation paths. This gets a little tricky since we might have iconv
1768 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
1769 dnl succeed when the header is found. To counter this, make sure the 
1770 dnl library directory is there and check the ABI directory first (which
1771 dnl should be harmless on other systems.
1772     for l in "lib32" "lib" ; do
1773         if test -d "$i/$l" ; then
1774                 LDFLAGS="$save_LDFLAGS -L$i/$l"
1775                 LIBS=
1776                 export LDFLAGS LIBS CPPFLAGS
1777 dnl Try to find iconv(3)
1778                 jm_ICONV($i/$l)
1779                 if test x"$ICONV_FOUND" = "xyes" ; then
1780                     libext="$l"
1781                     break;
1782                 fi
1783         fi
1784     done
1786     if test x"$ICONV_FOUND" = "xyes" ; then
1787         LDFLAGS=$save_LDFLAGS
1788         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1789         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1790         LIBS="$save_LIBS"
1791         ICONV_LOCATION=$i
1792         export LDFLAGS LIBS CPPFLAGS
1793 dnl Now, check for a working iconv ... we want to do it here because
1794 dnl there might be a working iconv further down the list of LOOK_DIRS
1796         ############
1797         # check for iconv in libc
1798         ic_save_LIBS="$LIBS"
1799         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
1800            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
1801         fi
1802         if test x"$jm_cv_lib_iconv" != x; then
1803            LIBS="$LIBS -l$jm_cv_lib_iconv"
1804         fi
1805 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1806         default_dos_charset=no
1807         default_display_charset=no
1808         default_unix_charset=no
1810         # check for default dos charset name
1811         for j in CP850 IBM850 ; do
1812             rjs_CHARSET($j)
1813             if test x"$ICONV_CHARSET" = x"$j"; then
1814                 default_dos_charset="\"$j\""
1815                 break
1816             fi
1817         done
1818         # check for default display charset name
1819         for j in ASCII 646 ; do
1820             rjs_CHARSET($j)
1821             if test x"$ICONV_CHARSET" = x"$j"; then
1822                 default_display_charset="\"$j\""
1823                 break
1824             fi
1825         done
1826         # check for default unix charset name
1827         for j in UTF-8 UTF8 ; do
1828             rjs_CHARSET($j)
1829             if test x"$ICONV_CHARSET" = x"$j"; then
1830                 default_unix_charset="\"$j\""
1831                 break
1832             fi
1833         done
1834         
1835         if test "$default_dos_charset" != "no" -a \
1836                 "$default_dos_charset" != "cross" -a \
1837                 "$default_display_charset" != "no" -a \ 
1838                 "$default_display_charset" != "cross" -a \
1839                 "$default_unix_charset" != "no" -a \
1840                 "$default_unix_charset" != "cross"
1841         then
1842                 samba_cv_HAVE_NATIVE_ICONV=yes
1843         else if test "$default_dos_charset" = "cross" -o \
1844                      "$default_display_charset" = "cross" -o \
1845                      "$default_unix_charset" = "cross"
1846         then
1847                 samba_cv_HAVE_NATIVE_ICONV=cross
1848         else
1849                 samba_cv_HAVE_NATIVE_ICONV=no
1850         fi
1851         fi
1852 dnl ])
1854         LIBS="$ic_save_LIBS"
1855         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1856            CPPFLAGS=$save_CPPFLAGS
1857            LDFLAGS=$save_LDFLAGS
1858            LIBS=$save_LIBS
1859            if test x"$jm_cv_lib_iconv" != x; then
1860               LIBS="$LIBS -l$jm_cv_lib_iconv"
1861            fi
1862            dnl Add the flags we need to CPPFLAGS and LDFLAGS
1863            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1864            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1865            export CPPFLAGS
1866            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
1867            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
1868            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
1869            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
1870            break
1871         fi
1872 dnl We didn't find a working iconv, so keep going
1873     fi
1874 dnl We only need to clean these up here for the next pass through the loop
1875     CPPFLAGS=$save_CPPFLAGS
1876     LDFLAGS=$save_LDFLAGS
1877     LIBS=$save_LIBS
1878     export LDFLAGS LIBS CPPFLAGS
1879 done
1880 unset libext
1883 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
1884     AC_MSG_WARN([Sufficient support for iconv function was not found. 
1885     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
1886    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
1887    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
1888    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
1892 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1893 AC_TRY_RUN([
1894 #include <sys/types.h>
1895 #include <fcntl.h>
1896 #ifndef F_GETLEASE
1897 #define F_GETLEASE      1025
1898 #endif
1899 main() {
1900        int fd = open("/dev/null", O_RDONLY);
1901        return fcntl(fd, F_GETLEASE, 0) == -1;
1904 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1905 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1906     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1909 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1910 AC_TRY_RUN([
1911 #include <sys/types.h>
1912 #include <fcntl.h>
1913 #include <signal.h>
1914 #ifndef F_NOTIFY
1915 #define F_NOTIFY 1026
1916 #endif
1917 main() {
1918         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1921 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1922 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1923     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1926 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1927 AC_TRY_RUN([
1928 #include <sys/types.h>
1929 #include <fcntl.h>
1930 #include <signal.h>
1931 #include <sys/file.h>
1932 #ifndef LOCK_MAND
1933 #define LOCK_MAND       32
1934 #define LOCK_READ       64
1935 #endif
1936 main() {
1937         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1940 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1941 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1942     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1948 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1949 AC_TRY_COMPILE([#include <sys/types.h>
1950 #include <fcntl.h>],
1951 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1952 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1953 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1954     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1957 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1958 AC_TRY_RUN([#include <sys/types.h>
1959 #include <sys/capability.h>
1960 main() {
1961  cap_t cap;
1962  if ((cap = cap_get_proc()) == NULL)
1963    exit(1);
1964  cap->cap_effective |= CAP_NETWORK_MGT;
1965  cap->cap_inheritable |= CAP_NETWORK_MGT;
1966  cap_set_proc(cap);
1967  exit(0);
1970 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1971 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1972     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1976 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1977 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1980 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1981 AC_TRY_COMPILE([#include <sys/types.h>
1982 #if defined(HAVE_RPC_RPC_H)
1983 #include <rpc/rpc.h>
1984 #endif],
1985 [int16 testvar;],
1986 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1987 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1988     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
1991 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1992 AC_TRY_COMPILE([#include <sys/types.h>
1993 #if defined(HAVE_RPC_RPC_H)
1994 #include <rpc/rpc.h>
1995 #endif],
1996 [uint16 testvar;],
1997 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1998 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1999     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2002 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2003 AC_TRY_COMPILE([#include <sys/types.h>
2004 #if defined(HAVE_RPC_RPC_H)
2005 #include <rpc/rpc.h>
2006 #endif],
2007 [int32 testvar;],
2008 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2009 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2010     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2013 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2014 AC_TRY_COMPILE([#include <sys/types.h>
2015 #if defined(HAVE_RPC_RPC_H)
2016 #include <rpc/rpc.h>
2017 #endif],
2018 [uint32 testvar;],
2019 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2020 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2021     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2025 dnl Some systems (SCO) have a problem including
2026 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2027 dnl as a #define in <prot.h> and as part of an enum
2028 dnl in <rpc/rpc.h>.
2031 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2032 AC_TRY_COMPILE([#include <sys/types.h>
2033 #ifdef HAVE_SYS_SECURITY_H
2034 #include <sys/security.h>
2035 #include <prot.h>
2036 #endif  /* HAVE_SYS_SECURITY_H */
2037 #if defined(HAVE_RPC_RPC_H)
2038 #include <rpc/rpc.h>
2039 #endif],
2040 [int testvar;],
2041 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2042 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2043     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2046 AC_MSG_CHECKING([for test routines])
2047 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2048            AC_MSG_RESULT(yes),
2049            AC_MSG_ERROR([cant find test code. Aborting config]),
2050            AC_MSG_WARN([cannot run when cross-compiling]))
2052 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2053 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2054            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2055 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2056     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2059 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2060 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2061            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2062            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2063            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2064 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2065 then
2066     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2069 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2070 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2071            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2072 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2073     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2076 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
2077 SAVE_CPPFLAGS="$CPPFLAGS"
2078 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
2079 AC_TRY_COMPILE([
2080 #define REPLACE_GETPASS 1
2081 #define NO_PROTO_H 1
2082 #define NO_CONFIG_H 1
2083 #define main dont_declare_main
2084 #include "${srcdir-.}/lib/getsmbpass.c"
2085 #undef main
2086 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
2087 CPPFLAGS="$SAVE_CPPFLAGS"
2089 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
2090         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
2093 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
2094 AC_TRY_RUN([
2095 #include <stdio.h>
2096 #include <sys/types.h>
2097 #include <netinet/in.h>
2098 #ifdef HAVE_ARPA_INET_H
2099 #include <arpa/inet.h>
2100 #endif
2101 main() { struct in_addr ip; ip.s_addr = 0x12345678;
2102 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2103     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
2104 exit(1);}],
2105            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
2106 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
2107     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
2110 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2111 AC_TRY_RUN([#include <stdlib.h>
2112 #include <sys/types.h>
2113 #include <sys/stat.h>
2114 #include <unistd.h>
2115 main() { 
2116   struct stat st;
2117   char tpl[20]="/tmp/test.XXXXXX"; 
2118   int fd = mkstemp(tpl); 
2119   if (fd == -1) exit(1);
2120   unlink(tpl);
2121   if (fstat(fd, &st) != 0) exit(1);
2122   if ((st.st_mode & 0777) != 0600) exit(1);
2123   exit(0);
2125 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2126 samba_cv_HAVE_SECURE_MKSTEMP=no,
2127 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2128 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2129     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2132 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
2133 AC_TRY_RUN([#include <unistd.h>
2134 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
2135 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
2136 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
2137     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
2140 AC_CACHE_CHECK([for sysconf(_SC_NPROC_ONLN)],samba_cv_SYSCONF_SC_NPROC_ONLN,[
2141 AC_TRY_RUN([#include <unistd.h>
2142 main() { exit(sysconf(_SC_NPROC_ONLN) == -1 ? 1 : 0); }],
2143 samba_cv_SYSCONF_SC_NPROC_ONLN=yes,samba_cv_SYSCONF_SC_NPROC_ONLN=no,samba_cv_SYSCONF_SC_NPROC_ONLN=cross)])
2144 if test x"$samba_cv_SYSCONF_SC_NPROC_ONLN" = x"yes"; then
2145     AC_DEFINE(SYSCONF_SC_NPROC_ONLN,1,[Whether sysconf(_SC_NPROC_ONLN) is available])
2148 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
2149 AC_TRY_RUN([main() { exit(getuid() != 0); }],
2150            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
2151 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
2152     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
2153 else
2154     AC_MSG_WARN(running as non-root will disable some tests)
2157 ##################
2158 # look for a method of finding the list of network interfaces
2159 iface=no;
2160 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2161 AC_TRY_RUN([
2162 #define HAVE_IFACE_AIX 1
2163 #define AUTOCONF_TEST 1
2164 #include "confdefs.h"
2165 #include "${srcdir-.}/lib/interfaces.c"],
2166            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2167 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2168     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2171 if test $iface = no; then
2172 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2173 AC_TRY_RUN([
2174 #define HAVE_IFACE_IFCONF 1
2175 #define AUTOCONF_TEST 1
2176 #include "confdefs.h"
2177 #include "${srcdir-.}/lib/interfaces.c"],
2178            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2179 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2180     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2184 if test $iface = no; then
2185 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2186 AC_TRY_RUN([
2187 #define HAVE_IFACE_IFREQ 1
2188 #define AUTOCONF_TEST 1
2189 #include "confdefs.h"
2190 #include "${srcdir-.}/lib/interfaces.c"],
2191            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2192 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2193     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2198 ################################################
2199 # look for a method of setting the effective uid
2200 seteuid=no;
2201 if test $seteuid = no; then
2202 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2203 AC_TRY_RUN([
2204 #define AUTOCONF_TEST 1
2205 #define USE_SETRESUID 1
2206 #include "confdefs.h"
2207 #include "${srcdir-.}/lib/util_sec.c"],
2208            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2209 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2210     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2215 if test $seteuid = no; then
2216 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2217 AC_TRY_RUN([
2218 #define AUTOCONF_TEST 1
2219 #define USE_SETREUID 1
2220 #include "confdefs.h"
2221 #include "${srcdir-.}/lib/util_sec.c"],
2222            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2223 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2224     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2228 if test $seteuid = no; then
2229 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2230 AC_TRY_RUN([
2231 #define AUTOCONF_TEST 1
2232 #define USE_SETEUID 1
2233 #include "confdefs.h"
2234 #include "${srcdir-.}/lib/util_sec.c"],
2235            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2236 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2237     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2241 if test $seteuid = no; then
2242 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2243 AC_TRY_RUN([
2244 #define AUTOCONF_TEST 1
2245 #define USE_SETUIDX 1
2246 #include "confdefs.h"
2247 #include "${srcdir-.}/lib/util_sec.c"],
2248            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2249 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2250     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2255 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
2256 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
2257            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
2258 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
2259     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
2262 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
2263 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
2264            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
2265 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
2266     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
2269 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2270 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2271            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2272 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2273     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2276 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2277 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2278            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2279 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2280     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2282 else
2285 dnl Don't check for 64 bit fcntl locking if we know that the
2286 dnl glibc2.1 broken check has succeeded.
2287 dnl 
2289   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2290   AC_TRY_RUN([
2291 #if defined(HAVE_UNISTD_H)
2292 #include <unistd.h>
2293 #endif
2294 #include <stdio.h>
2295 #include <stdlib.h>
2297 #ifdef HAVE_FCNTL_H
2298 #include <fcntl.h>
2299 #endif
2301 #ifdef HAVE_SYS_FCNTL_H
2302 #include <sys/fcntl.h>
2303 #endif
2304 main() { struct flock64 fl64;
2305 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2306 exit(0);
2307 #else
2308 exit(1);
2309 #endif
2311        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2313   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2314       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2315   fi
2318 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2319 AC_TRY_COMPILE([#include <sys/types.h>
2320 #include <sys/stat.h>
2321 #include <unistd.h>],
2322 [struct stat st;  st.st_blocks = 0;],
2323 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2324 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2325     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2326 fi 
2328 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2329 AC_TRY_COMPILE([#include <sys/types.h>
2330 #include <sys/stat.h>
2331 #include <unistd.h>],
2332 [struct stat st;  st.st_blksize = 0;],
2333 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2334 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2335     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2338 case "$host_os" in
2339 *linux*)
2340 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
2341 AC_TRY_COMPILE([
2342 #ifdef HAVE_SYS_VFS_H
2343 #include <sys/vfs.h>
2344 #endif
2345 #ifdef HAVE_SYS_CAPABILITY_H
2346 #include <sys/capability.h>
2347 #endif
2348 ],[int i;],
2349    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2350 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2351    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2354 esac
2356 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2357 AC_TRY_COMPILE([
2358 #include <sys/types.h>
2359 #include <sys/acl.h>
2360 #if defined(HAVE_RPCSVC_NIS_H)
2361 #include <rpcsvc/nis.h>
2362 #endif],
2363 [int i;],
2364 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2365 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2366         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2369 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2370 AC_TRY_RUN([
2371 #include <stdio.h>
2372 #include <limits.h>
2373 main() {
2374         char *newpath = realpath("/tmp", NULL);
2375         exit ((newpath != NULL) ? 0 : 1);
2378 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2379 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2380     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2383 #################################################
2384 # check for smbwrapper support
2385 AC_MSG_CHECKING(whether to use smbwrapper)
2386 AC_ARG_WITH(smbwrapper,
2387 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
2388 [ case "$withval" in
2389   yes)
2390     AC_MSG_RESULT(yes)
2391     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
2392         WRAPPROG="bin/smbsh\$(EXEEXT)"
2393         WRAP="bin/smbwrapper.$SHLIBEXT"
2395 # Conditions under which smbwrapper should not be built.
2397         if test x$PICFLAGS = x; then
2398            echo No support for PIC code - disabling smbwrapper and smbsh
2399            WRAPPROG=""
2400            WRAP=""
2401         elif test x$ac_cv_func_syscall = xno; then
2402            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
2403            WRAPPROG=""
2404            WRAP=""
2405         fi
2406         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
2407         SMBWRAPPER="$WRAPPROG $WRAP"
2408     ;;
2409   *)
2410     AC_MSG_RESULT(no)
2411     ;;
2412   esac ],
2413   AC_MSG_RESULT(no)
2416 #################################################
2417 # check for AFS clear-text auth support
2418 samba_cv_WITH_AFS=no
2419 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2420 AC_ARG_WITH(afs,
2421 [  --with-afs              Include AFS clear-text auth support (default=no) ],
2422 [ case "$withval" in
2423   yes|auto)
2424     AC_MSG_RESULT($withval)
2425     samba_cv_WITH_AFS=$withval
2426     ;;
2427   *)
2428     AC_MSG_RESULT(no)
2429     ;;
2430   esac ],
2431   AC_MSG_RESULT(no)
2434 ####################################################
2435 # check for Linux-specific AFS fake-kaserver support
2436 samba_cv_WITH_FAKE_KASERVER=no
2437 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2438 AC_ARG_WITH(fake-kaserver,
2439 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
2440 [ case "$withval" in
2441   yes|auto)
2442     AC_MSG_RESULT($withval)
2443     samba_cv_WITH_FAKE_KASERVER=$withval
2444     ;;
2445   *)
2446     AC_MSG_RESULT(no)
2447     ;;
2448   esac ],
2449   AC_MSG_RESULT(no)
2452 #################################################
2453 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
2454 if test x"$samba_cv_WITH_AFS" != x"no" ||
2455    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
2457     # see if this box has the afs-headers in /usr/include/afs
2458     AC_MSG_CHECKING(for /usr/include/afs)
2459     if test -d /usr/include/afs; then
2460           CFLAGS="$CFLAGS -I/usr/include/afs"
2461           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
2462           AC_MSG_RESULT(yes)
2463     else
2464       AC_MSG_RESULT(no)
2465     fi
2466    
2467     # check for afs.h
2468     have_afs_headers=no
2469     AC_CHECK_HEADERS(afs.h afs/afs.h)
2470     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
2471         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
2472            test x"$samba_cv_WITH_AFS" = x"auto"; then
2473                 AC_MSG_WARN([AFS cannot be supported without afs.h])
2474         else
2475                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
2476         fi
2477     else
2478         have_afs_headers=yes
2479     fi
2482 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
2483     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
2486 #################################################
2487 # check whether to compile AFS/NT ACL mapping module
2488 samba_cv_WITH_VFS_AFSACL=no
2489 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2490 AC_ARG_WITH(vfs-afsacl,
2491 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
2492 [ case "$withval" in
2493   yes|auto)
2494     AC_MSG_RESULT($withval)
2495     samba_cv_WITH_VFS_AFSACL=yes
2496     ;;
2497   *)
2498     AC_MSG_RESULT(no)
2499     ;;
2500   esac ],
2501   AC_MSG_RESULT(no)
2504 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
2505    default_shared_modules="$default_shared_modules vfs_afsacl"
2507         
2508 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
2509     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2512 #################################################
2513 # check for the DFS clear-text auth system
2514 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2515 AC_ARG_WITH(dfs,
2516 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
2517 [ case "$withval" in
2518   yes)
2519     AC_MSG_RESULT(yes)
2520     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2521     ;;
2522   *)
2523     AC_MSG_RESULT(no)
2524     ;;
2525   esac ],
2526   AC_MSG_RESULT(no)
2529 ########################################################
2530 # Compile with LDAP support?
2532 with_ldap_support=auto
2533 AC_MSG_CHECKING([for LDAP support])
2535 AC_ARG_WITH(ldap,
2536 [  --with-ldap             LDAP support (default yes)],
2537 [ case "$withval" in
2538     yes|no)
2539         with_ldap_support=$withval
2540         ;;
2541   esac ])
2543 AC_MSG_RESULT($with_ldap_support)
2545 SMBLDAP=""
2546 AC_SUBST(SMBLDAP)
2547 if test x"$with_ldap_support" != x"no"; then
2549   ##################################################################
2550   # first test for ldap.h and lber.h
2551   # (ldap.h is required for this test)
2552   AC_CHECK_HEADERS(ldap.h lber.h)
2553   
2554   if test x"$ac_cv_header_ldap_h" != x"yes"; then
2555         if test x"$with_ldap_support" = x"yes"; then
2556          AC_MSG_ERROR(ldap.h is needed for LDAP support)
2557         else
2558          AC_MSG_WARN(ldap.h is needed for LDAP support)
2559         fi
2560         
2561         with_ldap_support=no
2562   fi
2565 if test x"$with_ldap_support" != x"no"; then
2566   ac_save_LIBS=$LIBS
2568   ##################################################################
2569   # we might need the lber lib on some systems. To avoid link errors
2570   # this test must be before the libldap test
2571   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
2573   ########################################################
2574   # now see if we can find the ldap libs in standard paths
2575   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
2577   AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
2578   
2579   ########################################################
2580   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
2581   # Check found in pam_ldap 145.
2582   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
2584   LIBS="$LIBS $LDAP_LIBS"
2585   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
2586     AC_TRY_COMPILE([
2587         #include <lber.h>
2588         #include <ldap.h>], 
2589         [ldap_set_rebind_proc(0, 0, 0);], 
2590         [smb_ldap_cv_ldap_set_rebind_proc=3], 
2591         [smb_ldap_cv_ldap_set_rebind_proc=2]
2592     ) 
2593   ])
2594   
2595   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
2597   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS) 
2598   
2599   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
2600     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
2601     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
2602     SMBLDAP="lib/smbldap.o"
2603     with_ldap_support=yes
2604     AC_MSG_CHECKING(whether LDAP support is used)
2605     AC_MSG_RESULT(yes)
2606   else
2607     if test x"$with_ldap_support" = x"yes"; then
2608         AC_MSG_ERROR(libldap is needed for LDAP support)
2609     else
2610         AC_MSG_WARN(libldap is needed for LDAP support)
2611     fi
2612     
2613     LDAP_LIBS=""
2614     with_ldap_support=no
2615   fi
2616   LIBS=$ac_save_LIBS
2620 #################################################
2621 # active directory support
2623 with_ads_support=auto
2624 AC_MSG_CHECKING([for Active Directory and krb5 support])
2626 AC_ARG_WITH(ads,
2627 [  --with-ads              Active Directory support (default auto)],
2628 [ case "$withval" in
2629     yes|no)
2630         with_ads_support="$withval"
2631         ;;
2632   esac ])
2634 AC_MSG_RESULT($with_ads_support)
2636 FOUND_KRB5=no
2637 KRB5_LIBS=""
2639 if test x"$with_ldap_support" != x"yes"; then
2640     if test x"$with_ads_support" = x"yes"; then
2641         AC_MSG_ERROR(Active Directory Support requires LDAP support)
2642     elif test x"$with_ads_support" != x"no"; then
2643         AC_MSG_WARN(Active Directory Support requires LDAP support)
2644     fi
2645     with_ads_support=no
2648 if test x"$with_ads_support" != x"no"; then
2650   # Do no harm to the values of CFLAGS and LIBS while testing for
2651   # Kerberos support.
2653   if test x$FOUND_KRB5 = x"no"; then
2654     #################################################
2655     # check for location of Kerberos 5 install
2656     AC_MSG_CHECKING(for kerberos 5 install path)
2657     AC_ARG_WITH(krb5,
2658     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
2659     [ case "$withval" in
2660       no)
2661         AC_MSG_RESULT(no krb5-path given)
2662         ;;
2663       yes)
2664         AC_MSG_RESULT(/usr)
2665         FOUND_KRB5=yes
2666         ;;
2667       *)
2668         AC_MSG_RESULT($withval)
2669         KRB5_CFLAGS="-I$withval/include"
2670         KRB5_CPPFLAGS="-I$withval/include"
2671         KRB5_LDFLAGS="-L$withval/lib"
2672         FOUND_KRB5=yes
2673         if test -x "$withval/bin/krb5-config"; then
2674                 KRB5CONFIG=$withval/bin/krb5-config
2675         fi
2676         ;;
2677       esac ],
2678       AC_MSG_RESULT(no krb5-path given)
2679     )
2680   fi
2682   #################################################
2683   # check for krb5-config from recent MIT and Heimdal kerberos 5
2684   AC_PATH_PROG(KRB5CONFIG, krb5-config)
2685   AC_MSG_CHECKING(for working krb5-config)
2686   if test -x "$KRB5CONFIG"; then
2687     ac_save_CFLAGS=$CFLAGS
2688     CFLAGS="";export CFLAGS
2689     ac_save_LDFLAGS=$LDFLAGS
2690     LDFLAGS="";export LDFLAGS
2691     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
2692     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
2693     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
2694     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
2695     CFLAGS=$ac_save_CFLAGS;export CFLAGS
2696     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
2697     FOUND_KRB5=yes
2698     AC_MSG_RESULT(yes)
2699   else
2700     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
2701   fi
2703   if test x$FOUND_KRB5 = x"no"; then
2704     #################################################
2705     # see if this box has the SuSE location for the heimdal krb implementation
2706     AC_MSG_CHECKING(for /usr/include/heimdal)
2707     if test -d /usr/include/heimdal; then
2708       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
2709           KRB5_CFLAGS="-I/usr/include/heimdal"
2710           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2711           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
2712           AC_MSG_RESULT(yes)
2713       else
2714           KRB5_CFLAGS="-I/usr/include/heimdal"
2715           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2716           AC_MSG_RESULT(yes)
2717       fi
2718     else
2719       AC_MSG_RESULT(no)
2720     fi
2721   fi
2723   if test x$FOUND_KRB5 = x"no"; then
2724     #################################################
2725     # see if this box has the RedHat location for kerberos
2726     AC_MSG_CHECKING(for /usr/kerberos)
2727     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
2728       KRB5_LDFLAGS="-L/usr/kerberos/lib"
2729       KRB5_CFLAGS="-I/usr/kerberos/include"
2730       KRB5_CPPFLAGS="-I/usr/kerberos/include"
2731       AC_MSG_RESULT(yes)
2732     else
2733       AC_MSG_RESULT(no)
2734     fi
2735   fi
2737   ac_save_CFLAGS=$CFLAGS
2738   ac_save_CPPFLAGS=$CPPFLAGS
2739   ac_save_LDFLAGS=$LDFLAGS
2741   CFLAGS="$KRB5_CFLAGS $CFLAGS"
2742   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
2743   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
2745   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
2747   # now check for krb5.h. Some systems have the libraries without the headers!
2748   # note that this check is done here to allow for different kerberos
2749   # include paths
2750   AC_CHECK_HEADERS(krb5.h)
2752   if test x"$ac_cv_header_krb5_h" = x"no"; then
2754     # Give a warning if AD support was not explicitly requested,
2755     # i.e with_ads_support = auto, otherwise die with an error.
2757     if test x"$with_ads_support" = x"yes"; then
2758       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
2759     else
2760       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
2761     fi
2763     # Turn off AD support and restore CFLAGS and LIBS variables
2765     with_ads_support="no"
2766     
2767     CFLAGS=$ac_save_CFLAGS
2768     CPPFLAGS=$ac_save_CPPFLAGS
2769     LDFLAGS=$ac_save_LDFLAGS
2770   fi
2773 # Now we have determined whether we really want ADS support
2775 if test x"$with_ads_support" != x"no"; then
2776   ac_save_LIBS=$LIBS
2778   # now check for gssapi headers.  This is also done here to allow for
2779   # different kerberos include paths
2780   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
2782   ##################################################################
2783   # we might need the k5crypto and com_err libraries on some systems
2784   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
2785   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
2787   # Heimdal checks.
2788   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
2789   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
2790   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
2792   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
2793   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
2794                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2796   ########################################################
2797   # now see if we can find the krb5 libs in standard paths
2798   # or as specified above
2799   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
2800   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
2802   ########################################################
2803   # now see if we can find the gssapi libs in standard paths
2804   AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
2805             AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2807   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
2808   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
2809   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
2810   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
2811   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
2812   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
2813   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
2814   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
2815   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
2816   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
2817   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
2818   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
2819   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
2820   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
2821   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
2822   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
2823   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
2824   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
2825   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
2826   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
2827   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
2828   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
2830   LIBS="$KRB5_LIBS $LIBS"
2831   
2832   AC_CACHE_CHECK([for krb5_encrypt_block type],
2833                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
2834     AC_TRY_COMPILE([#include <krb5.h>],
2835       [krb5_encrypt_block block;],
2836       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
2837       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
2839   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
2840     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
2841                [Whether the type krb5_encrypt_block exists])
2842   fi
2844   AC_CACHE_CHECK([for addrtype in krb5_address],
2845                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
2846     AC_TRY_COMPILE([#include <krb5.h>],
2847       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
2848       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
2849       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
2851   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
2852     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
2853                [Whether the krb5_address struct has a addrtype property])
2854   fi
2856   AC_CACHE_CHECK([for addr_type in krb5_address],
2857                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
2858     AC_TRY_COMPILE([#include <krb5.h>],
2859       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
2860       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
2861       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
2863   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
2864     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
2865               [Whether the krb5_address struct has a addr_type property])
2866   fi
2868   AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
2869                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
2870                  [AC_TRY_COMPILE([#include <krb5.h>],
2871     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
2872     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
2874   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
2875     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
2876               [Whether the krb5_ticket struct has a enc_part2 property])
2877   fi
2879   AC_CACHE_CHECK([for keyblock in krb5_creds],
2880                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
2881     AC_TRY_COMPILE([#include <krb5.h>],
2882       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
2883       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
2884       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
2886   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
2887     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
2888               [Whether the krb5_creds struct has a keyblock property])
2889   fi
2891   AC_CACHE_CHECK([for session in krb5_creds],
2892                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
2893     AC_TRY_COMPILE([#include <krb5.h>],
2894       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
2895       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
2896       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
2898   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
2899     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
2900               [Whether the krb5_creds struct has a session property])
2901   fi
2903   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
2904                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
2905     AC_TRY_COMPILE([#include <krb5.h>],
2906       [krb5_keyblock key; key.keyvalue.data = NULL;],
2907       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
2908       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
2910   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
2911     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
2912               [Whether the krb5_keyblock struct has a keyvalue property])
2913   fi
2915   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
2916                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
2917     AC_TRY_COMPILE([#include <krb5.h>],
2918       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
2919       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
2920       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
2921   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
2922                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
2923     AC_TRY_COMPILE([#include <krb5.h>],
2924       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
2925       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
2926       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
2927 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
2928 # w.r.t. arcfour and windows, so we must not enable it here
2929   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
2930           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
2931     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
2932               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
2933   fi
2935   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
2936                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
2937     AC_TRY_COMPILE([#include <krb5.h>],
2938       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
2939       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
2940       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
2942   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
2943     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
2944               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
2945   fi
2947   AC_CACHE_CHECK([for KV5M_KEYTAB],
2948                  samba_cv_HAVE_KV5M_KEYTAB,[
2949     AC_TRY_COMPILE([#include <krb5.h>],
2950       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
2951       samba_cv_HAVE_KV5M_KEYTAB=yes,
2952       samba_cv_HAVE_KV5M_KEYTAB=no)])
2954   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
2955       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
2956              [Whether the KV5M_KEYTAB option is available])
2957   fi
2959   AC_CACHE_CHECK([for the krb5_princ_component macro],
2960                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
2961     AC_TRY_LINK([#include <krb5.h>],
2962       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
2963       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
2964       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
2966   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
2967     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
2968                [Whether krb5_princ_component is available])
2969   fi
2971   AC_CACHE_CHECK([for key in krb5_keytab_entry],
2972                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
2973     AC_TRY_COMPILE([#include <krb5.h>],
2974       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
2975       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
2976       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
2978   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
2979     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
2980               [Whether krb5_keytab_entry has key member])
2981   fi
2983   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
2984                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
2985     AC_TRY_COMPILE([#include <krb5.h>],
2986       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
2987       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
2988       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
2990   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
2991     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
2992               [Whether krb5_keytab_entry has keyblock member])
2993   fi
2995   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
2996     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
2997     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
2998     AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
2999     AC_MSG_RESULT(yes)
3000   else
3001     if test x"$with_ads_support" = x"yes"; then
3002         AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
3003     else
3004         AC_MSG_WARN(libkrb5 is needed for Active Directory support)
3005     fi
3006     KRB5_LIBS=""
3007     with_ads_support=no 
3008   fi
3010   AC_CACHE_CHECK([for WRFILE: keytab support],
3011                 samba_cv_HAVE_WRFILE_KEYTAB,[
3012     AC_TRY_RUN([
3013 #include<krb5.h>
3014   main()
3015   {
3016     krb5_context context;
3017     krb5_keytab keytab;
3019     krb5_init_context(&context);
3020     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
3021   }],
3022   samba_cv_HAVE_WRFILE_KEYTAB=yes,
3023   samba_cv_HAVE_WRFILE_KEYTAB=no)])
3025   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
3026       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
3027                [Whether the WRFILE:-keytab is supported])
3028   fi
3030   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
3031                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3032     AC_TRY_COMPILE([#include <krb5.h>],
3033     [
3034     krb5_context context;
3035     krb5_principal principal;
3036     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3037     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3038     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3040   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3041     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3042               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3043   fi
3045 LIBS="$ac_save_LIBS"
3048 ########################################################
3049 # Compile experimental passdb backends?
3050 # (pdb_xml, pdb_mysql, pdb_pgsql)
3051 AC_MSG_CHECKING(whether to build experimental passdb libraries)
3052 AC_ARG_WITH(expsam,
3053 [  --with-expsam=<list>    Include experimental passdb libraries (default=no)]
3054 [                          Valid choices include (comma separated list): ]
3055 [                              xml, mysql & pgsql],
3056 [ expsam_pdb_modules=`echo "$withval" | sed 's/,/ /g'`
3057   if test "z$expsam_pdb_modules" = "zyes"; then
3058     expsam_pdb_modules="xml mysql pgsql"
3059   fi
3060   AC_MSG_RESULT($expsam_pdb_modules)
3061   for i in $expsam_pdb_modules
3062   do 
3063     case "$i" in
3064     xml|all|yes)
3065       ## pdb_xml
3066           AM_PATH_XML2([2.0.0],[default_shared_modules="$default_shared_modules pdb_xml"],[AC_MSG_ERROR([Can't find XML libraries while XML support is requested])])
3067       CFLAGS="$CFLAGS $XML_CFLAGS"
3068       ;;
3069     mysql|all|yes)
3070       ## pdb_mysql
3071           AM_PATH_MYSQL([default_shared_modules="$default_shared_modules pdb_mysql"],[AC_MSG_ERROR([Can't find MySQL libraries while MySQL support is requested])])
3072       CFLAGS="$CFLAGS $MYSQL_CFLAGS"
3073       ;;
3074      pgsql|all|yes)
3075       ## pdb_pgsql
3076       AM_PATH_PGSQL([default_shared_modules="$default_shared_modules pdb_pgsql"],[])
3077       CFLAGS="$CFLAGS $PGSQL_CFLAGS"
3078       ;;
3079     no)
3080       ;;
3081     *)
3082       echo "Unknown module name \"$i\"!  Exiting..."
3083       exit 1
3084       ;;
3085     esac
3086   done ],
3087   AC_MSG_RESULT(no)
3090 #################################################
3091 # check for automount support
3092 AC_MSG_CHECKING(whether to use automount)
3093 AC_ARG_WITH(automount,
3094 [  --with-automount        Include automount support (default=no)],
3095 [ case "$withval" in
3096   yes)
3097     AC_MSG_RESULT(yes)
3098     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3099     ;;
3100   *)
3101     AC_MSG_RESULT(no)
3102     ;;
3103   esac ],
3104   AC_MSG_RESULT(no)
3107 #################################################
3108 # check for smbmount support
3109 AC_MSG_CHECKING(whether to use smbmount)
3110 AC_ARG_WITH(smbmount,
3111 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
3112 [ case "$withval" in
3113   yes)
3114         case "$host_os" in
3115         *linux*)
3116                 AC_MSG_RESULT(yes)
3117                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
3118                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
3119                 ;;
3120         *)
3121                 AC_MSG_ERROR(not on a linux system!)
3122                 ;;
3123         esac
3124     ;;
3125   *)
3126     AC_MSG_RESULT(no)
3127     ;;
3128   esac ],
3129   AC_MSG_RESULT(no)
3134 #################################################
3135 # check for a PAM clear-text auth, accounts, password and session support
3136 with_pam_for_crypt=no
3137 AC_MSG_CHECKING(whether to use PAM)
3138 AC_ARG_WITH(pam,
3139 [  --with-pam              Include PAM support (default=no)],
3140 [ case "$withval" in
3141   yes)
3142     AC_MSG_RESULT(yes)
3143     if test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3144        if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
3145           if test x"$ac_cv_header_security__pam_macros_h" = x"no"; then
3146              AC_MSG_ERROR(--with-pam specified but no PAM headers found)
3147           fi
3148        fi
3149     fi
3150     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
3151     AUTH_LIBS="$AUTH_LIBS -lpam"
3152     with_pam_for_crypt=yes
3153     ;;
3154   *)
3155     AC_MSG_RESULT(no)
3156     ;;
3157   esac ],
3158   AC_MSG_RESULT(no)
3161 # we can't build a pam module if we don't have pam.
3162 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
3164 #################################################
3165 # check for pam_smbpass support
3166 AC_MSG_CHECKING(whether to use pam_smbpass)
3167 AC_ARG_WITH(pam_smbpass,
3168 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
3169 [ case "$withval" in
3170   yes)
3171     AC_MSG_RESULT(yes)
3173        # Conditions under which pam_smbpass should not be built.
3175        if test x$PICFLAGS = x; then
3176           AC_MSG_ERROR([No support for PIC code])
3177        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3178           AC_MSG_ERROR([No security/pam_appl.h found])
3179        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
3180           AC_MSG_ERROR([No libpam found])
3181        else
3182           AUTH_LIBS="$AUTH_LIBS -lpam"
3183           SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.$SHLIBEXT"
3184        fi
3185     ;;
3186   *)
3187     AC_MSG_RESULT(no)
3188     ;;
3189   esac ],
3190   AC_MSG_RESULT(no)
3194 ###############################################
3195 # test for where we get crypt() from
3196 AC_SEARCH_LIBS(crypt, [crypt],
3197   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
3198   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
3201 ## moved after the check for -lcrypt in order to
3202 ## ensure that the necessary libraries are included
3203 ## check checking for truncated salt.  Wrapped by the
3204 ## $with_pam_for_crypt variable as above   --jerry
3206 if test $with_pam_for_crypt = no; then
3207 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
3208 crypt_LIBS="$LIBS"
3209 LIBS="$AUTH_LIBS $LIBS"
3210 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
3211         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
3212 LIBS="$crypt_LIBS"])
3213 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
3214         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
3219 ########################################################################################
3221 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
3223 ########################################################################################
3225 #################################################
3226 # check for a LDAP password database configuration backwards compatibility
3227 AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration)
3228 AC_ARG_WITH(ldapsam,
3229 [  --with-ldapsam          Include LDAP SAM 2.2 compatible configuration (default=no)],
3230 [ case "$withval" in
3231   yes)
3232     AC_MSG_RESULT(yes)
3233     AC_DEFINE(WITH_LDAP_SAMCONFIG,1,[Whether to include 2.2 compatible LDAP SAM configuration])
3234     ;;
3235   *)
3236     AC_MSG_RESULT(no)
3237     ;;
3238   esac ],
3239   AC_MSG_RESULT(no)
3242 ########################################################################################
3244 ## END OF TESTS FOR SAM BACKENDS.  
3246 ########################################################################################
3248 #################################################
3249 # check for a NISPLUS_HOME support 
3250 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
3251 AC_ARG_WITH(nisplus-home,
3252 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
3253 [ case "$withval" in
3254   yes)
3255     AC_MSG_RESULT(yes)
3256     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
3257     ;;
3258   *)
3259     AC_MSG_RESULT(no)
3260     ;;
3261   esac ],
3262   AC_MSG_RESULT(no)
3265 #################################################
3266 # check for syslog logging
3267 AC_MSG_CHECKING(whether to use syslog logging)
3268 AC_ARG_WITH(syslog,
3269 [  --with-syslog           Include experimental SYSLOG support (default=no)],
3270 [ case "$withval" in
3271   yes)
3272     AC_MSG_RESULT(yes)
3273     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
3274     ;;
3275   *)
3276     AC_MSG_RESULT(no)
3277     ;;
3278   esac ],
3279   AC_MSG_RESULT(no)
3282 #################################################
3283 # check for a shared memory profiling support
3284 AC_MSG_CHECKING(whether to use profiling)
3285 AC_ARG_WITH(profiling-data,
3286 [  --with-profiling-data   Include gathering source code profile information (default=no)],
3287 [ case "$withval" in
3288   yes)
3289     AC_MSG_RESULT(yes)
3290     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
3291     ;;
3292   *)
3293     AC_MSG_RESULT(no)
3294     ;;
3295   esac ],
3296   AC_MSG_RESULT(no)
3300 #################################################
3301 # check for experimental disk-quotas support
3303 samba_cv_WITH_QUOTAS=auto
3304 samba_cv_TRY_QUOTAS=no
3305 samba_cv_RUN_QUOTA_TESTS=auto
3306 samba_cv_WITH_SYS_QUOTAS=auto
3307 samba_cv_TRY_SYS_QUOTAS=no
3308 samba_cv_SYSQUOTA_FOUND=no;
3310 AC_MSG_CHECKING(whether to try disk-quotas support)
3311 AC_ARG_WITH(quotas,
3312 [  --with-quotas           Include disk-quota support (default=no)],
3313 [ case "$withval" in
3314   yes)
3315     AC_MSG_RESULT(yes)
3316     samba_cv_WITH_QUOTAS=yes
3317     samba_cv_TRY_QUOTAS=yes
3318     samba_cv_RUN_QUOTA_TESTS=yes
3319     #set sys quotas to auto in this case
3320     samba_cv_TRY_SYS_QUOTAS=auto
3321     ;;
3322   auto)
3323     AC_MSG_RESULT(auto)
3324     samba_cv_WITH_QUOTAS=auto
3325     samba_cv_TRY_QUOTAS=auto
3326     samba_cv_RUN_QUOTA_TESTS=auto
3327     #set sys quotas to auto in this case
3328     samba_cv_TRY_SYS_QUOTAS=auto
3329     ;;
3330   no)
3331     AC_MSG_RESULT(no)
3332     samba_cv_WITH_QUOTAS=no
3333     samba_cv_TRY_QUOTAS=no
3334     samba_cv_RUN_QUOTA_TESTS=no
3335     ;;
3336   *)
3337     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3338     ;;
3339   esac ],
3340   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3343 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
3344 AC_ARG_WITH(sys-quotas,
3345 [  --with-sys-quotas       Include lib/sysquotas.c support (default=auto)],
3346 [ case "$withval" in
3347   yes)
3348     AC_MSG_RESULT(yes)
3349     samba_cv_WITH_SYS_QUOTAS=yes
3350     samba_cv_TRY_SYS_QUOTAS=yes
3351     samba_cv_RUN_QUOTA_TESTS=yes
3352     ;;
3353   auto)
3354     AC_MSG_RESULT(auto)
3355     samba_cv_WITH_SYS_QUOTAS=auto
3356     samba_cv_TRY_SYS_QUOTAS=auto
3357     samba_cv_RUN_QUOTA_TESTS=auto
3358     ;;
3359   no)
3360     AC_MSG_RESULT(no)
3361     samba_cv_WITH_SYS_QUOTAS=no
3362     samba_cv_TRY_SYS_QUOTAS=no
3363     ;;
3364   *)
3365     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3366     ;;
3367   esac ],
3368   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3371 if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
3372 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
3373   case "$host_os" in
3374         *linux*)
3375             AC_MSG_RESULT(yes)
3376             samba_cv_TRY_SYS_QUOTAS=yes
3377             samba_cv_RUN_QUOTA_TESTS=yes
3378             samba_cv_SYSQUOTA_FOUND=yes
3379             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
3380             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
3381             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
3382             samba_cv_found_xfs_header=yes
3383             ;;
3384         *)
3385             AC_MSG_RESULT(no)
3386             samba_cv_TRY_SYS_QUOTAS=no
3387             ;;
3388   esac
3391 #############################################
3392 # only check for quota stuff if --with-quotas
3393 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
3395 # some broken header files need this
3396 AC_CHECK_HEADER(asm/types.h,[
3397             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
3398             AC_ADD_INCLUDE(<asm/types.h>)
3399             ])
3401 # For quotas on Veritas VxFS filesystems
3402 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
3404 # For sys/quota.h and linux/quota.h
3405 AC_CHECK_HEADERS(sys/quota.h)
3407 if test x"$samba_cv_found_xfs_header" != x"yes"; then
3408 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
3409 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
3410 AC_TRY_COMPILE([
3411 #include "confdefs.h"
3412 #ifdef HAVE_SYS_TYPES_H
3413 #include <sys/types.h>
3414 #endif
3415 #ifdef HAVE_ASM_TYPES_H
3416 #include <asm/types.h>
3417 #endif
3418 #include <sys/quota.h>
3419 ],[int i = Q_XGETQUOTA;],
3420 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
3421 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
3422         samba_cv_found_xfs_header=yes
3426 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
3427 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
3428 AC_TRY_COMPILE([
3429 #include "confdefs.h"
3430 #ifdef HAVE_SYS_QUOTA_H
3431 #include <sys/quota.h>
3432 #endif
3434 struct dqblk D;
3435 D.dqb_fsoftlimit = 0;],
3436 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
3437 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
3438         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
3441 ##################
3442 # look for a working quota system
3444 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3445 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
3446 AC_TRY_RUN_STRICT([
3447 #define HAVE_QUOTACTL_4A 1
3448 #define AUTOCONF_TEST 1
3449 #include "confdefs.h"
3450 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3451            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
3452 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
3453     samba_cv_SYSQUOTA_FOUND=yes;
3454     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
3455     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
3459 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3460 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
3461 AC_TRY_RUN_STRICT([
3462 #define HAVE_QUOTACTL_4B 1
3463 #define AUTOCONF_TEST 1
3464 #include "confdefs.h"
3465 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3466            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
3467 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
3468     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
3469     samba_cv_SYSQUOTA_FOUND=yes;
3470     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
3471     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
3475 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3476 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
3477 AC_TRY_RUN_STRICT([
3478 #define HAVE_QUOTACTL_3 1
3479 #define AUTOCONF_TEST 1
3480 #include "confdefs.h"
3481 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3482            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
3483 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
3484     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
3485     samba_cv_SYSQUOTA_FOUND=yes;
3486     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
3487     samba_cv_sysquotas_file="lib/sysquotas_3.c"
3491 #################################################
3492 # check for mntent.h and struct mntent
3493 AC_CHECK_HEADERS(mntent.h)
3494 #################################################
3495 # check for setmntent,getmntent,endmntent
3496 AC_CHECK_FUNCS(setmntent getmntent endmntent)
3498 #################################################
3499 # check for devnm.h and struct mntent
3500 AC_CHECK_HEADERS(devnm.h)
3501 #################################################
3502 # check for devnm
3503 AC_CHECK_FUNCS(devnm)
3505 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
3506     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3507         # if --with-sys-quotas=yes then build it 
3508         # you have can use the get/set quota command smb.conf
3509         # options then
3510         samba_cv_SYSQUOTA_FOUND=auto
3511     fi
3512     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
3513         # if --with-sys-quotas=yes then build it 
3514         # you have can use the get/set quota command smb.conf
3515         # options then
3516         samba_cv_TRY_SYS_QUOTAS=auto
3517     fi
3520 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
3521 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
3522 SAVE_CPPFLAGS="$CPPFLAGS"
3523 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3524 AC_TRY_COMPILE([
3525 #include "confdefs.h"
3526 #define NO_PROTO_H 1
3527 #define NO_CONFIG_H 1
3528 #define HAVE_SYS_QUOTAS 1
3529 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
3530 #include "${srcdir-.}/lib/sysquotas.c"
3531 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
3532 CPPFLAGS="$SAVE_CPPFLAGS"
3534 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
3535 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
3536     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
3537         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3538         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
3539         samba_cv_WE_USE_SYS_QUOTAS=yes
3540         AC_MSG_RESULT(yes)
3541     else
3542         AC_MSG_RESULT(no)
3543     fi
3547 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
3548 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
3549 SAVE_CPPFLAGS="$CPPFLAGS"
3550 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3551 AC_TRY_COMPILE([
3552 #include "confdefs.h"
3553 #define NO_PROTO_H 1
3554 #define NO_CONFIG_H 1
3555 #define HAVE_SYS_QUOTAS 1
3556 #define HAVE_XFS_QUOTAS 1
3557 #include "${srcdir-.}/lib/sysquotas_xfs.c"
3558 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
3559 CPPFLAGS="$SAVE_CPPFLAGS"
3561 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
3562     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
3563         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
3564     fi
3568 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
3569 SAVE_CPPFLAGS="$CPPFLAGS"
3570 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
3571 AC_TRY_COMPILE([
3572 #include "confdefs.h"
3573 #define NO_PROTO_H 1
3574 #define NO_CONFIG_H 1
3575 #include "${srcdir-.}/smbd/quotas.c"
3576 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
3577 CPPFLAGS="$SAVE_CPPFLAGS"
3579 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
3580 AC_MSG_CHECKING(whether to use the old quota support)
3581     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
3582       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
3583         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3584         AC_MSG_RESULT(yes)
3585       else
3586         AC_MSG_RESULT(no)
3587       fi
3588     else
3589       AC_MSG_RESULT(no)
3590     fi
3593 ####################
3594 # End of quota check samba_cv_RUN_QUOTA_TESTS
3597 #################################################
3598 # check for experimental utmp accounting
3600 AC_MSG_CHECKING(whether to support utmp accounting)
3601 WITH_UTMP=yes
3602 AC_ARG_WITH(utmp,
3603 [  --with-utmp             Include utmp accounting (default, if supported by OS)],
3604 [ case "$withval" in
3605   no)
3606                 WITH_UTMP=no
3607                 ;;
3608   *)
3609                 WITH_UTMP=yes
3610                 ;;
3611   esac ],
3614 # utmp requires utmp.h
3615 # Note similar check earlier, when checking utmp details.
3617 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
3618         utmp_no_reason=", no utmp.h on $host_os"
3619         WITH_UTMP=no
3622 # Display test results
3624 if test x"$WITH_UTMP" = x"yes"; then
3625         AC_MSG_RESULT(yes)
3626         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
3627 else
3628         AC_MSG_RESULT(no$utmp_no_reason)
3631 #################################################
3632 # choose native language(s) of man pages
3633 AC_MSG_CHECKING(chosen man pages' language(s))
3634 AC_ARG_WITH(manpages-langs,
3635 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
3636 [ case "$withval" in
3637   yes|no)
3638     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
3639     manlangs="en"
3640   ;;
3641   *)
3642     manlangs="$withval"
3643   ;;
3644   esac
3646   AC_MSG_RESULT($manlangs)
3647   manlangs=`echo $manlangs | sed "s/,/ /g"`   # replacing commas with spaces to produce a list
3648   AC_SUBST(manlangs)],
3650   [manlangs="en"
3651   AC_MSG_RESULT($manlangs)
3652   AC_SUBST(manlangs)]
3655 #################################################
3656 # should we build libsmbclient?
3658 INSTALLCLIENTCMD_SH=:
3659 INSTALLCLIENTCMD_A=:
3660 INSTALLCLIENT=
3661 LIBSMBCLIENT_SHARED=
3662 LIBSMBCLIENT=
3663 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
3664 AC_ARG_WITH(libsmbclient,
3665 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
3666 [ case "$withval" in
3667   no) 
3668      AC_MSG_RESULT(no)
3669      ;;
3670   *)
3671      if test $BLDSHARED = true; then
3672         INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3673         ## build the static version of libsmbclient as well
3674         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3675         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3676         LIBSMBCLIENT=libsmbclient
3677         AC_MSG_RESULT(yes)
3678      else
3679         enable_static=yes
3680         AC_MSG_RESULT(no shared library support -- will supply static library)
3681      fi
3682      if test $enable_static = yes; then
3683         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3684         LIBSMBCLIENT=libsmbclient
3685      fi
3686      INSTALLCLIENT=installclientlib
3687      ;;
3688   esac ],
3690 # if unspecified, default is to built it iff possible.
3691   if test $BLDSHARED = true; then
3692      INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3693      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3694      LIBSMBCLIENT=libsmbclient
3695      AC_MSG_RESULT(yes)
3696    else
3697      enable_static=yes
3698      AC_MSG_RESULT(no shared library support -- will supply static library)
3699    fi
3700    if test $enable_static = yes; then
3701      INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3702      LIBSMBCLIENT=libsmbclient
3703   fi]
3704   INSTALLCLIENT=installclientlib
3708 #################################################
3709 # these tests are taken from the GNU fileutils package
3710 AC_CHECKING(how to get filesystem space usage)
3711 space=no
3713 # Test for statvfs64.
3714 if test $space = no; then
3715   # SVR4
3716   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
3717   [AC_TRY_RUN([
3718 #if defined(HAVE_UNISTD_H)
3719 #include <unistd.h>
3720 #endif
3721 #include <sys/types.h>
3722 #include <sys/statvfs.h>
3723   main ()
3724   {
3725     struct statvfs64 fsd;
3726     exit (statvfs64 (".", &fsd));
3727   }],
3728   fu_cv_sys_stat_statvfs64=yes,
3729   fu_cv_sys_stat_statvfs64=no,
3730   fu_cv_sys_stat_statvfs64=cross)])
3731   if test $fu_cv_sys_stat_statvfs64 = yes; then
3732     space=yes
3733     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
3734   fi
3737 # Perform only the link test since it seems there are no variants of the
3738 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
3739 # because that got a false positive on SCO OSR5.  Adding the declaration
3740 # of a `struct statvfs' causes this test to fail (as it should) on such
3741 # systems.  That system is reported to work fine with STAT_STATFS4 which
3742 # is what it gets when this test fails.
3743 if test $space = no; then
3744   # SVR4
3745   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
3746                  [AC_TRY_LINK([#include <sys/types.h>
3747 #include <sys/statvfs.h>],
3748                               [struct statvfs fsd; statvfs (0, &fsd);],
3749                               fu_cv_sys_stat_statvfs=yes,
3750                               fu_cv_sys_stat_statvfs=no)])
3751   if test $fu_cv_sys_stat_statvfs = yes; then
3752     space=yes
3753     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
3754   fi
3757 if test $space = no; then
3758   # DEC Alpha running OSF/1
3759   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
3760   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
3761   [AC_TRY_RUN([
3762 #include <sys/param.h>
3763 #include <sys/types.h>
3764 #include <sys/mount.h>
3765   main ()
3766   {
3767     struct statfs fsd;
3768     fsd.f_fsize = 0;
3769     exit (statfs (".", &fsd, sizeof (struct statfs)));
3770   }],
3771   fu_cv_sys_stat_statfs3_osf1=yes,
3772   fu_cv_sys_stat_statfs3_osf1=no,
3773   fu_cv_sys_stat_statfs3_osf1=no)])
3774   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
3775   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
3776     space=yes
3777     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
3778   fi
3781 if test $space = no; then
3782 # AIX
3783   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
3784 member (AIX, 4.3BSD)])
3785   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
3786   [AC_TRY_RUN([
3787 #ifdef HAVE_SYS_PARAM_H
3788 #include <sys/param.h>
3789 #endif
3790 #ifdef HAVE_SYS_MOUNT_H
3791 #include <sys/mount.h>
3792 #endif
3793 #ifdef HAVE_SYS_VFS_H
3794 #include <sys/vfs.h>
3795 #endif
3796   main ()
3797   {
3798   struct statfs fsd;
3799   fsd.f_bsize = 0;
3800   exit (statfs (".", &fsd));
3801   }],
3802   fu_cv_sys_stat_statfs2_bsize=yes,
3803   fu_cv_sys_stat_statfs2_bsize=no,
3804   fu_cv_sys_stat_statfs2_bsize=no)])
3805   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
3806   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
3807     space=yes
3808     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
3809   fi
3812 if test $space = no; then
3813 # SVR3
3814   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
3815   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
3816   [AC_TRY_RUN([#include <sys/types.h>
3817 #include <sys/statfs.h>
3818   main ()
3819   {
3820   struct statfs fsd;
3821   exit (statfs (".", &fsd, sizeof fsd, 0));
3822   }],
3823     fu_cv_sys_stat_statfs4=yes,
3824     fu_cv_sys_stat_statfs4=no,
3825     fu_cv_sys_stat_statfs4=no)])
3826   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
3827   if test $fu_cv_sys_stat_statfs4 = yes; then
3828     space=yes
3829     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
3830   fi
3833 if test $space = no; then
3834 # 4.4BSD and NetBSD
3835   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
3836 member (4.4BSD and NetBSD)])
3837   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
3838   [AC_TRY_RUN([#include <sys/types.h>
3839 #ifdef HAVE_SYS_PARAM_H
3840 #include <sys/param.h>
3841 #endif
3842 #ifdef HAVE_SYS_MOUNT_H
3843 #include <sys/mount.h>
3844 #endif
3845   main ()
3846   {
3847   struct statfs fsd;
3848   fsd.f_fsize = 0;
3849   exit (statfs (".", &fsd));
3850   }],
3851   fu_cv_sys_stat_statfs2_fsize=yes,
3852   fu_cv_sys_stat_statfs2_fsize=no,
3853   fu_cv_sys_stat_statfs2_fsize=no)])
3854   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
3855   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
3856     space=yes
3857         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
3858   fi
3861 if test $space = no; then
3862   # Ultrix
3863   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
3864   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
3865   [AC_TRY_RUN([#include <sys/types.h>
3866 #ifdef HAVE_SYS_PARAM_H
3867 #include <sys/param.h>
3868 #endif
3869 #ifdef HAVE_SYS_MOUNT_H
3870 #include <sys/mount.h>
3871 #endif
3872 #ifdef HAVE_SYS_FS_TYPES_H
3873 #include <sys/fs_types.h>
3874 #endif
3875   main ()
3876   {
3877   struct fs_data fsd;
3878   /* Ultrix's statfs returns 1 for success,
3879      0 for not mounted, -1 for failure.  */
3880   exit (statfs (".", &fsd) != 1);
3881   }],
3882   fu_cv_sys_stat_fs_data=yes,
3883   fu_cv_sys_stat_fs_data=no,
3884   fu_cv_sys_stat_fs_data=no)])
3885   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
3886   if test $fu_cv_sys_stat_fs_data = yes; then
3887     space=yes
3888     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
3889   fi
3893 # As a gating factor for large file support, in order to
3894 # use <4GB files we must have the following minimal support
3895 # available.
3896 # long long, and a 64 bit off_t or off64_t.
3897 # If we don't have all of these then disable large
3898 # file support.
3900 AC_MSG_CHECKING([if large file support can be enabled])
3901 AC_TRY_COMPILE([
3902 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
3903 #include <sys/types.h>
3904 #else
3905 __COMPILE_ERROR_
3906 #endif
3908 [int i],
3909 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
3910 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
3911         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
3913 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
3915 AC_ARG_WITH(spinlocks, 
3916 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
3917 if test "x$with_spinlocks" = "xyes"; then
3918     AC_DEFINE(USE_SPINLOCKS,1,[Whether to use spin locks instead of fcntl locks])
3920     case "$host_cpu" in
3921         sparc)
3922             AC_DEFINE(SPARC_SPINLOCKS,1,[Whether to use sparc spinlocks])
3923             ;;
3925         i386|i486|i586|i686)
3926             AC_DEFINE(INTEL_SPINLOCKS,1,[Whether to use intel spinlocks])
3927             ;;
3929         mips)
3930             AC_DEFINE(MIPS_SPINLOCKS,1,[Whether to use mips spinlocks])
3931             ;;
3933         powerpc)
3934             AC_DEFINE(POWERPC_SPINLOCKS,1,[Whether to use powerpc spinlocks])
3935             ;;
3936     esac
3939 #################################################
3940 # check for ACL support
3942 AC_MSG_CHECKING(whether to support ACLs)
3943 AC_ARG_WITH(acl-support,
3944 [  --with-acl-support      Include ACL support (default=no)],
3945 [ case "$withval" in
3946   yes)
3948         case "$host_os" in
3949         *sysv5*)
3950                 AC_MSG_RESULT(Using UnixWare ACLs)
3951                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
3952                 ;;
3953         *solaris*)
3954                 AC_MSG_RESULT(Using solaris ACLs)
3955                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
3956                 ;;
3957         *hpux*)
3958                 AC_MSG_RESULT(Using HPUX ACLs)
3959                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
3960                 ;;
3961         *irix*)
3962                 AC_MSG_RESULT(Using IRIX ACLs)
3963                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
3964                 ;;
3965         *aix*)
3966                 AC_MSG_RESULT(Using AIX ACLs)
3967                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
3968                 ;;
3969         *osf*)
3970                 AC_MSG_RESULT(Using Tru64 ACLs)
3971                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
3972                 ACL_LIBS="$ACL_LIBS -lpacl"
3973                 ;;
3974         *freebsd5*|*freebsd6*)
3975                 AC_MSG_RESULT(Using FreeBSD posix ACLs)
3976                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
3977                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
3978                 ;;
3979         *linux*)
3980                 AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
3981                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
3982                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
3983                 acl_LIBS=$LIBS
3984                 LIBS="$LIBS -lacl"
3985                 AC_TRY_LINK([#include <sys/types.h>
3986 #include <sys/acl.h>],
3987 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
3988 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
3989                 LIBS=$acl_LIBS])
3990                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
3991                                 AC_MSG_RESULT(Using posix ACLs)
3992                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
3993                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
3994                                 acl_LIBS=$LIBS
3995                                 LIBS="$LIBS -lacl"
3996                                 AC_TRY_LINK([#include <sys/types.h>
3997 #include <sys/acl.h>],
3998 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
3999 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4000                                 LIBS=$acl_LIBS])
4001                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4002                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4003                                 fi
4004                         fi
4005             ;;
4006          *)
4007                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
4008                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
4009                 acl_LIBS=$LIBS
4010                 LIBS="$LIBS -lacl"
4011                 AC_TRY_LINK([#include <sys/types.h>
4012 #include <sys/acl.h>],
4013 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
4014 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
4015                 LIBS=$acl_LIBS])
4016                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4017                                 AC_MSG_RESULT(Using posix ACLs)
4018                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4019                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4020                                 acl_LIBS=$LIBS
4021                                 LIBS="$LIBS -lacl"
4022                                 AC_TRY_LINK([#include <sys/types.h>
4023 #include <sys/acl.h>],
4024 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4025 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4026                                 LIBS=$acl_LIBS])
4027                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4028                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4029                                 fi
4030                         fi
4031             ;;
4032         esac
4033         ;;
4034   *)
4035     AC_MSG_RESULT(no)
4036     AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
4037     ;;
4038   esac ],
4039   AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
4040   AC_MSG_RESULT(no)
4043 #################################################
4044 # check for sendfile support
4046 with_sendfile_support=yes
4047 AC_MSG_CHECKING(whether to check to support sendfile)
4048 AC_ARG_WITH(sendfile-support,
4049 [  --with-sendfile-support Check for sendfile support (default=yes)],
4050 [ case "$withval" in
4051   yes)
4053         AC_MSG_RESULT(yes);
4055         case "$host_os" in
4056         *linux*)
4057                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4058                 AC_TRY_LINK([#include <sys/sendfile.h>],
4060 int tofd, fromfd;
4061 off64_t offset;
4062 size_t total;
4063 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
4065 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4067                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
4068                 AC_TRY_LINK([#include <sys/sendfile.h>],
4070 int tofd, fromfd;
4071 off_t offset;
4072 size_t total;
4073 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4075 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4077 # Try and cope with broken Linux sendfile....
4078                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
4079                 AC_TRY_LINK([\
4080 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
4081 #undef _FILE_OFFSET_BITS
4082 #endif
4083 #include <sys/sendfile.h>],
4085 int tofd, fromfd;
4086 off_t offset;
4087 size_t total;
4088 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4090 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
4092         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
4093                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
4094                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
4095                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
4096         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4097                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4098                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
4099                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
4100         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
4101                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
4102                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
4103         else
4104                 AC_MSG_RESULT(no);
4105         fi
4107         ;;
4108         *freebsd* | *DragonFly* )
4109                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
4110                 AC_TRY_LINK([\
4111 #include <sys/types.h>
4112 #include <unistd.h>
4113 #include <sys/socket.h>
4114 #include <sys/uio.h>],
4116         int fromfd, tofd, ret, total=0;
4117         off_t offset, nwritten;
4118         struct sf_hdtr hdr;
4119         struct iovec hdtrl;
4120         hdr.headers = &hdtrl;
4121         hdr.hdr_cnt = 1;
4122         hdr.trailers = NULL;
4123         hdr.trl_cnt = 0;
4124         hdtrl.iov_base = NULL;
4125         hdtrl.iov_len = 0;
4126         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
4128 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4130         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4131                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
4132                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
4133                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4134         else
4135                 AC_MSG_RESULT(no);
4136         fi
4137         ;;
4139         *hpux*)
4140                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4141                 AC_TRY_LINK([\
4142 #include <sys/socket.h>
4143 #include <sys/uio.h>],
4145         int fromfd, tofd;
4146         size_t total=0;
4147         struct iovec hdtrl[2];
4148         ssize_t nwritten;
4149         off64_t offset;
4151         hdtrl[0].iov_base = 0;
4152         hdtrl[0].iov_len = 0;
4154         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
4156 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4157         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
4158                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
4159                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
4160                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4161         else
4162                 AC_MSG_RESULT(no);
4163         fi
4165                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
4166                 AC_TRY_LINK([\
4167 #include <sys/socket.h>
4168 #include <sys/uio.h>],
4170         int fromfd, tofd;
4171         size_t total=0;
4172         struct iovec hdtrl[2];
4173         ssize_t nwritten;
4174         off_t offset;
4176         hdtrl[0].iov_base = 0;
4177         hdtrl[0].iov_len = 0;
4179         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
4181 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4182         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4183                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4184                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
4185                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4186         else
4187                 AC_MSG_RESULT(no);
4188         fi
4189         ;;
4191         *solaris*)
4192                 AC_CHECK_LIB(sendfile,sendfilev)
4193                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
4194                 AC_TRY_LINK([\
4195 #include <sys/sendfile.h>],
4197         int sfvcnt;
4198         size_t xferred;
4199         struct sendfilevec vec[2];
4200         ssize_t nwritten;
4201         int tofd;
4203         sfvcnt = 2;
4205         vec[0].sfv_fd = SFV_FD_SELF;
4206         vec[0].sfv_flag = 0;
4207         vec[0].sfv_off = 0;
4208         vec[0].sfv_len = 0;
4210         vec[1].sfv_fd = 0;
4211         vec[1].sfv_flag = 0;
4212         vec[1].sfv_off = 0;
4213         vec[1].sfv_len = 0;
4214         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
4216 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
4218         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
4219                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
4220                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
4221                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4222         else
4223                 AC_MSG_RESULT(no);
4224         fi
4226                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
4227                 AC_TRY_LINK([\
4228 #include <sys/sendfile.h>],
4230         int sfvcnt;
4231         size_t xferred;
4232         struct sendfilevec vec[2];
4233         ssize_t nwritten;
4234         int tofd;
4236         sfvcnt = 2;
4238         vec[0].sfv_fd = SFV_FD_SELF;
4239         vec[0].sfv_flag = 0;
4240         vec[0].sfv_off = 0;
4241         vec[0].sfv_len = 0;
4243         vec[1].sfv_fd = 0;
4244         vec[1].sfv_flag = 0;
4245         vec[1].sfv_off = 0;
4246         vec[1].sfv_len = 0;
4247         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
4249 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
4251         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
4252                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
4253                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
4254                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
4255         else
4256                 AC_MSG_RESULT(no);
4257         fi
4258         ;;
4259         *aix*)
4260                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
4261                 AC_TRY_LINK([\
4262 #include <sys/socket.h>],
4264         int fromfd, tofd;
4265         size_t total=0;
4266         struct sf_parms hdtrl;
4267         ssize_t nwritten;
4268         off64_t offset;
4270         hdtrl.header_data = 0;
4271         hdtrl.header_length = 0;
4272         hdtrl.file_descriptor = fromfd;
4273         hdtrl.file_offset = 0;
4274         hdtrl.file_bytes = 0;
4275         hdtrl.trailer_data = 0;
4276         hdtrl.trailer_length = 0;
4278         nwritten = send_file(&tofd, &hdtrl, 0);
4280 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4281         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4282                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4283                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
4284                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
4285         else
4286                 AC_MSG_RESULT(no);
4287         fi
4288         ;;
4289         *)
4290         ;;
4291         esac
4292         ;;
4293   *)
4294     AC_MSG_RESULT(no)
4295     ;;
4296   esac ],
4297   AC_MSG_RESULT(yes)
4301 #################################################
4302 # Check whether winbind is supported on this platform.  If so we need to
4303 # build and install client programs, sbin programs and shared libraries
4305 AC_MSG_CHECKING(whether to build winbind)
4307 # Initially, the value of $host_os decides whether winbind is supported
4309 HAVE_WINBIND=yes
4311 # Define the winbind shared library name and any specific linker flags
4312 # it needs to be built with.
4314 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
4315 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
4316 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
4318 case "$host_os" in
4319         *linux*)
4320                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
4321                 ;;
4322         *freebsd5*|*freebsd6*)
4323                 # FreeBSD winbind client is implemented as a wrapper around
4324                 # the Linux version.
4325                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
4326                     nsswitch/winbind_nss_linux.o"
4327                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
4328                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
4329                 ;;
4330         *irix*)
4331                 # IRIX has differently named shared libraries
4332                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
4333                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
4334                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
4335                 ;;
4336         *solaris*)
4337                 # Solaris winbind client is implemented as a wrapper around
4338                 # the Linux version.
4339                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
4340                     nsswitch/winbind_nss_linux.o"
4341                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
4342                 ;;
4343         *hpux11*)
4344                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
4345                 ;;
4346         *aix*)
4347                 # AIX has even differently named shared libraries.  No
4348                 # WINS support has been implemented yet.
4349                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
4350                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
4351                 WINBIND_NSS="nsswitch/WINBIND"
4352                 WINBIND_WINS_NSS=""
4353                 ;;
4354         *)
4355                 HAVE_WINBIND=no
4356                 winbind_no_reason=", unsupported on $host_os"
4357                 ;;
4358 esac
4360 AC_SUBST(WINBIND_NSS)
4361 AC_SUBST(WINBIND_WINS_NSS)
4362 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
4363 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
4364 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
4366 # Check the setting of --with-winbind
4368 AC_ARG_WITH(winbind,
4369 [  --with-winbind          Build winbind (default, if supported by OS)],
4371   case "$withval" in
4372         yes)
4373                 HAVE_WINBIND=yes
4374                 ;;
4375         no)
4376                 HAVE_WINBIND=no
4377                 winbind_reason=""
4378                 ;;
4379   esac ],
4382 # We need unix domain sockets for winbind
4384 if test x"$HAVE_WINBIND" = x"yes"; then
4385         if test x"$samba_cv_unixsocket" = x"no"; then
4386                 winbind_no_reason=", no unix domain socket support on $host_os"
4387                 HAVE_WINBIND=no
4388         fi
4391 # Display test results
4393 if test x"$HAVE_WINBIND" = x"yes"; then
4394         AC_MSG_RESULT(yes)
4395         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
4397         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
4398         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
4399         if test $BLDSHARED = true; then
4400                 SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
4402                 if test x"$with_pam" = x"yes"; then
4403                         SHLIB_PROGS="$SHLIB_PROGS nsswitch/pam_winbind.$SHLIBEXT"
4404                 fi
4405         fi
4406 else
4407         AC_MSG_RESULT(no$winbind_no_reason)
4410 # Solaris has some extra fields in struct passwd that need to be
4411 # initialised otherwise nscd crashes.  
4413 AC_CHECK_MEMBER(struct passwd.pw_comment,
4414                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
4415                 [#include <pwd.h>])
4417 AC_CHECK_MEMBER(struct passwd.pw_age,
4418                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
4419                 [#include <pwd.h>])
4421 # AIX 4.3.x and 5.1 do not have as many members in
4422 # struct secmethod_table as AIX 5.2
4423 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
4424        [#include <usersec.h>])
4425 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
4426        [#include <usersec.h>])
4429 #################################################
4430 # Check to see if we should use the included popt 
4432 AC_ARG_WITH(included-popt,
4433 [  --with-included-popt    use bundled popt library, not from system],
4435   case "$withval" in
4436         yes)
4437                 INCLUDED_POPT=yes
4438                 ;;
4439         no)
4440                 INCLUDED_POPT=no
4441                 ;;
4442   esac ],
4444 if test x"$INCLUDED_POPT" != x"yes"; then
4445     AC_CHECK_LIB(popt, poptGetContext,
4446                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
4449 AC_MSG_CHECKING(whether to use included popt)
4450 if test x"$INCLUDED_POPT" = x"yes"; then
4451     AC_MSG_RESULT(yes)
4452     BUILD_POPT='$(POPT_OBJS)'
4453         POPTLIBS='$(POPT_OBJS)'
4454     FLAGS1="-I$srcdir/popt"
4455 else
4456     AC_MSG_RESULT(no)
4457         BUILD_POPT=""
4458     POPTLIBS="-lpopt"
4460 AC_SUBST(BUILD_POPT)
4461 AC_SUBST(POPTLIBS)
4462 AC_SUBST(FLAGS1)
4464 #################################################
4465 # Check if the user wants Python
4467 # At the moment, you can use this to set which Python binary to link
4468 # against.  (Libraries built for Python2.2 can't be used by 2.1,
4469 # though they can coexist in different directories.)  In the future
4470 # this might make the Python stuff be built by default.
4472 # Defaulting python breaks the clean target if python isn't installed
4474 PYTHON=
4476 AC_ARG_WITH(python,
4477 [  --with-python=PYTHONNAME  build Python libraries],
4478 [ case "${withval-python}" in
4479   yes)
4480         PYTHON=python
4481         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
4482         ;;
4483   no)
4484         PYTHON=
4485         ;;
4486   *)
4487         PYTHON=${withval-python}
4488         ;;
4489   esac ])
4490 AC_SUBST(PYTHON)
4492 for i in `echo $default_static_modules | sed -e's/,/ /g'`
4494         eval MODULE_DEFAULT_$i=STATIC
4495 done
4497 for i in `echo $default_shared_modules | sed -e's/,/ /g'`
4499         dnl Fall back to static if we cannot build shared libraries
4500         eval MODULE_DEFAULT_$i=STATIC
4502         if test $BLDSHARED = true; then
4503                 eval MODULE_DEFAULT_$i=SHARED
4504         fi
4505 done
4507 dnl Always built these modules static
4508 MODULE_pdb_guest=STATIC
4509 MODULE_rpc_spoolss=STATIC
4510 MODULE_rpc_srv=STATIC
4511 MODULE_idmap_tdb=STATIC
4513 AC_ARG_WITH(static-modules,
4514 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
4515 [ if test $withval; then
4516         for i in `echo $withval | sed -e's/,/ /g'`
4517         do
4518                 eval MODULE_$i=STATIC
4519         done
4520 fi ])
4522 AC_ARG_WITH(shared-modules,
4523 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
4524 [ if test $withval; then
4525         for i in `echo $withval | sed -e's/,/ /g'`
4526         do
4527                         eval MODULE_$i=SHARED
4528         done
4529 fi ])
4531 ###########################################################################
4532 ## contributed pdb_modules
4534 SMB_MODULE(pdb_xml, passdb/pdb_xml.o, "bin/xml.$SHLIBEXT", PDB,
4535                   [ PASSDB_LIBS="$PASSDB_LIBS $XML_LIBS" ] )
4536 SMB_MODULE(pdb_mysql, passdb/pdb_mysql.o, "bin/mysql.$SHLIBEXT", PDB, 
4537                    [ PASSDB_LIBS="$PASSDB_LIBS $MYSQL_LIBS" ]   )
4538 SMB_MODULE(pdb_pgsql, passdb/pdb_pgsql.o, "bin/pgsql.$SHLIBEXT", PDB, 
4539                    [ PASSDB_LIBS="$PASSDB_LIBS $PGSQL_LIBS" ]   )
4541 ## end of contributed pdb_modules
4542 ###########################################################################
4544 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB, 
4545                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
4546 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
4547 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
4548 SMB_MODULE(pdb_guest, passdb/pdb_guest.o, "bin/guest.$SHLIBEXT", PDB)
4549 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
4551 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
4552 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
4553 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
4554 SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
4555 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
4556 SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
4557 SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
4558 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
4559 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
4560 SMB_MODULE(rpc_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
4561 SMB_SUBSYSTEM(RPC,smbd/server.o)
4563 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/idmap_ldap.$SHLIBEXT", IDMAP)
4564 SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/idmap_tdb.$SHLIBEXT", IDMAP)
4565 SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/idmap_rid.$SHLIBEXT", IDMAP)
4566 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
4568 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
4569 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
4570 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
4571 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
4572 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
4574 SMB_MODULE(auth_rhosts, \$(AUTH_RHOSTS_OBJ), "bin/rhosts.$SHLIBEXT", AUTH)
4575 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
4576 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
4577 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
4578 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
4579 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
4580 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
4581 SMB_SUBSYSTEM(AUTH,auth/auth.o)
4583 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
4584 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
4585 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
4586 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
4587 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
4588 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
4589 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
4590 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
4591 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
4592 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
4593 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
4594 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
4595 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
4597 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
4599 #################################################
4600 # do extra things if we are running insure
4602 if test "${ac_cv_prog_CC}" = "insure"; then
4603         CPPFLAGS="$CPPFLAGS -D__INSURE__"
4606 #################################################
4607 # Display summary of libraries detected
4609 AC_MSG_RESULT([Using libraries:])
4610 AC_MSG_RESULT([    LIBS = $LIBS])
4611 if test x"$with_ads_support" != x"no"; then
4612    AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
4614 if test x"$with_ldap_support" != x"no"; then
4615    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
4617 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
4619 #################################################
4620 # final configure stuff
4622 AC_MSG_CHECKING([configure summary])
4623 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
4624            AC_MSG_RESULT(yes),
4625            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
4626            AC_MSG_WARN([cannot run when cross-compiling]))
4628 builddir=`pwd`
4629 AC_SUBST(builddir)
4631 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
4632 LIB_REMOVE_USR_LIB(LDFLAGS)
4633 LIB_REMOVE_USR_LIB(LIBS)
4635 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
4636 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
4637 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
4639 AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh)
4641 #################################################
4642 # Print very concise instructions on building/use
4643 if test "x$enable_dmalloc" = xyes
4644 then
4645         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
4646         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])