r6706: * fix bug that prevented smbclient from creating directories
[Samba/gbeck.git] / source / configure.in
blob087c33a7a4ef7dae0e818e4a1e310d1d78f89912
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(SMBWRAP_OBJS)
229 AC_SUBST(SMBWRAP_INC)
230 AC_SUBST(EXTRA_BIN_PROGS)
231 AC_SUBST(EXTRA_SBIN_PROGS)
232 AC_SUBST(EXTRA_ALL_TARGETS)
234 AC_ARG_ENABLE(debug, 
235 [  --enable-debug          Turn on compiler debugging information (default=no)],
236     [if eval "test x$enable_debug = xyes"; then
237         CFLAGS="${CFLAGS} -g"
238     fi])
240 AC_SUBST(SOCKWRAP)
241 AC_ARG_ENABLE(socket-wrapper, 
242 [  --enable-socket-wrapper         Turn on socket wrapper library (default=no)],
243     [if eval "test x$enable_socket_wrapper = xyes"; then
244         AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
245         SOCKWRAP="\$(SOCKET_WRAPPER_OBJ)"
246     fi])
248 # compile with optimization and without debugging by default, but
249 # allow people to set their own preference.
250 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
251 # if it has no value.  This prevent *very* large debug binaries from occurring
252 # by default.
253 if test "x$CFLAGS" = x; then
254   CFLAGS="-O"
257 CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
259 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
260     [if eval "test x$enable_developer = xyes"; then
261         developer=yes
262         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
263         # Add -Wdeclaration-after-statement if compiler supports it
264         AC_CACHE_CHECK(
265           [that the C compiler understands -Wdeclaration-after-statement],
266           samba_cv_HAVE_Wdeclaration_after_statement, [
267           AC_TRY_RUN_STRICT([
268             int main(void)
269             {
270                 return 0;
271             }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
272             samba_cv_HAVE_Wdeclaration_after_statement=yes,
273             samba_cv_HAVE_Wdeclaration_after_statement=no,
274             samba_cv_HAVE_Wdeclaration_after_statement=cross)
275        ])
276        if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
277             CFLAGS="${CFLAGS} -Wdeclaration-after-statement"
278        fi
279     fi])
281 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
282     [if eval "test x$enable_krb5developer = xyes"; then
283         developer=yes
284         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
285     fi])
287 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
289 if test "x$enable_dmalloc" = xyes
290 then
291         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
292         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
293                   [Define to check invariants around some common functions])
294         LIBS="$LIBS -ldmalloc"  
297 dnl Checks for programs.
300 ## for some reason this macro resets the CFLAGS
301 ## so save and restore
303 OLD_CFLAGS=${CFLAGS}
304 AC_PROG_CC
305 CFLAGS=${OLD_CFLAGS}
307 OLD_CFLAGS=${CFLAGS}
308 AC_PROG_CPP
309 CFLAGS=${OLD_CFLAGS}
311 AC_PROG_INSTALL
312 AC_PROG_AWK
313 AC_PATH_PROG(PERL, perl)
315 AC_CHECK_TOOL(AR, ar)
317 dnl Check if we use GNU ld
318 LD=ld
319 AC_PROG_LD_GNU
321 dnl Certain versions of GNU ld the default is not to have the 
322 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
323 dnl warnings when building modules.
324 if test "$ac_cv_prog_gnu_ld" = "yes"; then
325         ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
326         AC_MSG_CHECKING(GNU ld release date)
327         changequote(,)dnl
328         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'`
329         changequote([,])dnl
330         AC_MSG_RESULT(${ac_cv_gnu_ld_date})
331         if test -n "$ac_cv_gnu_ld_date"; then
332            if test "$ac_cv_gnu_ld_date" -lt 20030217; then
333               ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
334            fi
335         else
336            AC_MSG_CHECKING(GNU ld release version)
337            changequote(,)dnl
338            ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
339            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
340            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
341            changequote([,])dnl
342            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
343            AC_MSG_CHECKING(GNU ld release version major)
344            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
345            AC_MSG_CHECKING(GNU ld release version minor)
346            AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
347            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
348              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
349            fi
350         fi
353 dnl needed before AC_TRY_COMPILE
354 AC_ISC_POSIX
356 dnl look for executable suffix
357 AC_EXEEXT
359 dnl Check if C compiler understands -c and -o at the same time
360 AC_PROG_CC_C_O
361 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
362       BROKEN_CC=
363 else
364       BROKEN_CC=#
366 AC_SUBST(BROKEN_CC)
368 dnl Check if the C compiler understands -Werror
369 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
370  AC_TRY_RUN_STRICT([
371   int main(void)
372   {
373         return 0;
374   }],[-Werror],[$CPPFLAGS],[$LDFLAGS],
375   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
376 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
377    Werror_FLAGS="-Werror"
378 else 
379 dnl Check if the C compiler understands -w2
380 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
381  AC_TRY_RUN_STRICT([
382   int main(void)
383   {
384         return 0;
385   }],[-w2],[$CPPFLAGS],[$LDFLAGS],
386   samba_cv_HAVE_w2=yes,samba_cv_HAVE_w2=no,samba_cv_HAVE_w2=cross)])
387 if test x"$samba_cv_HAVE_w2" = x"yes"; then
388    Werror_FLAGS="-w2"
392 dnl Check if the C compiler understands volatile (it should, being ANSI).
393 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
394     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
395         samba_cv_volatile=yes,samba_cv_volatile=no)])
396 if test x"$samba_cv_volatile" = x"yes"; then
397    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
400 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
401 AC_MSG_CHECKING(uname -s)
402 AC_MSG_RESULT(${UNAME_S})
404 UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R="unknown"
405 AC_MSG_CHECKING(uname -r)
406 AC_MSG_RESULT(${UNAME_R})
408 UNAME_M=`(uname -m) 2>/dev/null` || UNAME_M="unknown"
409 AC_MSG_CHECKING(uname -m)
410 AC_MSG_RESULT(${UNAME_M})
412 UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
413 AC_MSG_CHECKING(uname -p)
414 AC_MSG_RESULT(${UNAME_P})
416 AC_CANONICAL_SYSTEM
418 dnl Add #include for broken IRIX header files
419   case "$host_os" in
420         *irix6*) AC_ADD_INCLUDE(<standards.h>)
421         ;;
422 esac
424 AC_VALIDATE_CACHE_SYSTEM_TYPE
426 DYNEXP=
428 dnl Add modules that have to be built by default here
429 dnl These have to be built static:
430 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_svcctl rpc_net rpc_dfs rpc_srv rpc_spoolss rpc_eventlog auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin printerdb_file"
432 dnl These are preferably build shared, and static if dlopen() is not available
433 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"
435 if test "x$developer" = xyes; then
436    default_static_modules="$default_static_modules rpc_echo"
437    default_shared_modules="$default_shared_modules charset_weird"
441 # Config CPPFLAG settings for strange OS's that must be set
442 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
443 # case statement; its first reference must be unconditional.
445 case "$host_os" in
446 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
447     *hpux*)
448     
449       AC_PROG_CC_FLAG(Ae)
450       # mmap on HPUX is completely broken...
451       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
452       if test $ac_cv_prog_cc_Ae = yes; then
453         CPPFLAGS="$CPPFLAGS -Ae"
454       fi
456 # Defines needed for HPUX support.
457 # HPUX has bigcrypt but (sometimes?) doesn't use it for
458 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
460       case `uname -r` in
461                         *9*|*10*)
462                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
463                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
464                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
465                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
466                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
467                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
468                                 ;;
469                         *11*)
470                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
471                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
472                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
473                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
474                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
475                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
476                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
477                                 ;;
478       esac
479       ;;
482 # CRAY Unicos has broken const handling
483        *unicos*)
484           AC_MSG_RESULT([disabling const])
485           CPPFLAGS="$CPPFLAGS -Dconst="
486           ;;
487         
489 # AIX4.x doesn't even admit to having large
490 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
492     *aix4*)
493           AC_MSG_RESULT([enabling large file support])
494       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
495           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
496       ;;    
498 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
499 # to the existance of large files..
500 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
501 # recommendations on large file support, however it makes the
502 # compile work using gcc 2.7 and 2.8, whereas using the Sun
503 # recommendation makes the compile fail on gcc2.7. JRA.
505 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
507         *solaris*)
508                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
509                 case `uname -r` in
510                         5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
511                                 AC_MSG_RESULT([no large file support])
512                                 ;;
513                         5.*)
514                         AC_MSG_RESULT([enabling large file support])
515                         if test "$ac_cv_prog_gcc" = yes; then
516                                 ${CC-cc} -v >conftest.c 2>&1
517                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
518                                 rm -fr conftest.c
519                                 case "$ac_cv_gcc_compiler_version_number" in
520                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
521                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
522                                                 LDFLAGS="$LDFLAGS -lthread"
523                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
524                                                 ;;
525                                         *)
526                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
527                                                 LDFLAGS="$LDFLAGS -lthread"
528                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
529                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
530                                                 ;;
531                                 esac
532                         else
533                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
534                                 LDFLAGS="$LDFLAGS -lthread"
535                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
536                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
537                         fi
538                         ;;
539                 esac
540                 ;;
542 # IRIX uses SYSV printing.  Make sure to set that here
544         *irix*)
545                 AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
546                 ;;
547         *freebsd*|*DragonFly*)
548                 AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
549                 ;;
551 # VOS may need to have POSIX support and System V compatibility enabled.
553     *vos*)
554     case "$CPPFLAGS" in
555           *-D_POSIX_C_SOURCE*)
556                 ;;
557           *)
558                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
559                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
560                 ;;
561     esac
562     case "$CPPFLAGS" in
563           *-D_SYSV*|*-D_SVID_SOURCE*)
564                 ;;
565           *)
566                 CPPFLAGS="$CPPFLAGS -D_SYSV"
567                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
568     esac
569     ;;
571 # Tests needed for SINIX large file support.
573     *sysv4*)
574       if test $host = mips-sni-sysv4 ; then
575         AC_MSG_CHECKING([for LFS support])
576         old_CPPFLAGS="$CPPFLAGS"
577         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
578         AC_TRY_RUN([
579 #include <unistd.h>
580 main () {
581 #if _LFS64_LARGEFILE == 1
582 exit(0);
583 #else
584 exit(1);
585 #endif
586 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
587         CPPFLAGS="$old_CPPFLAGS"
588         if test x$SINIX_LFS_SUPPORT = xyes ; then
589           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
590                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
591           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
592           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
593           LIBS="`getconf LFS64_LIBS` $LIBS"
594         fi
595       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
596       fi
597     ;;
599 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
601     *linux*)
602         AC_MSG_CHECKING([for LFS support])
603         old_CPPFLAGS="$CPPFLAGS"
604         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
605        AC_TRY_RUN([
606 #include <unistd.h>
607 #include <sys/utsname.h>
608 #include <string.h>
609 #include <stdlib.h>
610 main() {
611 #if _LFS64_LARGEFILE == 1
612        struct utsname uts;
613        char *release;
614        int major, minor;
616        /* Ensure this is glibc 2.2 or higher */
617 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
618        int libc_major = __GLIBC__;
619        int libc_minor = __GLIBC_MINOR__;
621        if (libc_major < 2)
622               exit(1);
623        if (libc_minor < 2)
624               exit(1);
625 #endif
627        /* Ensure this is kernel 2.4 or higher */
629        uname(&uts);
630        release = strdup(uts.release);
631        major = atoi(strsep(&release, "."));
632        minor = atoi(strsep(&release, "."));
634        if (major > 2 || (major == 2 && minor > 3))
635                exit(0);
636        exit(1);
637 #else
638        exit(1);
639 #endif
641 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
642         CPPFLAGS="$old_CPPFLAGS"
643         if test x$LINUX_LFS_SUPPORT = xyes ; then
644                 CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
645                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
646                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
647                 AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
648         fi
649         AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
650         ;;
653 # MacOS X is the *only* system that uses compose character in utf8. This
654 # is so horribly broken....
656     *darwin*)
657         AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
658 # Add Fink directories for various packages, like dlcompat.
659 # Note: iconv does that explicitly below, but other packages
660 # don't.
661         CPPFLAGS="$CPPFLAGS -I/sw/include"
662         LDFLAGS="$LDFLAGS -L/sw/lib"
664 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
665 # use that instead of plain dlsym.
667         AC_CHECK_LIB(dl,dlopen)
668         AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
670 # Add a system specific charset module.
672         default_shared_modules="$default_shared_modules charset_macosxfs"
673         ;;
674     *hurd*)
675         AC_MSG_CHECKING([for LFS support])
676         old_CPPFLAGS="$CPPFLAGS"
677         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
678         AC_TRY_RUN([
679 #include <unistd.h>
680 main () {
681 #if _LFS64_LARGEFILE == 1
682 exit(0);
683 #else
684 exit(1);
685 #endif
686 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
687         CPPFLAGS="$old_CPPFLAGS"
688         if test x$GLIBC_LFS_SUPPORT = xyes ; then
689           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
690                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
691           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
692         fi
693       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
694     ;;
696 esac
698 AC_INLINE
699 AC_HEADER_STDC
700 AC_HEADER_DIRENT
701 AC_HEADER_TIME
702 AC_HEADER_SYS_WAIT
703 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
704 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h)
705 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
706 ## These fail to compile on IRIX so just check for their presence
707 AC_CHECK_HEADERS(rpcsvc/yp_prot.h, sys/mode.h, [], [] -)
708 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h)
709 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
710 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
711 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
712 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
713 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
714 AC_CHECK_HEADERS(langinfo.h locale.h)
716 # Look for Darwin headers
717 old_CPPFLAGS="$CPPFLAGS"
718 CPPFLAGS="-Iinclude $CPPFLAGS"
719 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
720 CPPFLAGS="$old_CPPFLAGS"
722 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
723 # subdirectory of headers.
724 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
727 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
728 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
730 case "$host_os" in
731     *hpux*)
732                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
733                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
734                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
735                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
736                 fi
737         ;;
738 esac
739 AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
740 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
741 AC_CHECK_HEADERS(stropts.h poll.h)
742 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
743 AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
744 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
746 ## These faile to compile on Solaris so just check for their presence
747 AC_CHECK_HEADERS(security/pam_modules.h net/if.h netinet/ip.h, [], [], -)
749 # For experimental utmp support (lastlog on some BSD-like systems)
750 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
752 AC_CHECK_SIZEOF(int,cross)
753 AC_CHECK_SIZEOF(long,cross)
754 AC_CHECK_SIZEOF(short,cross)
756 AC_C_CONST
757 AC_C_INLINE
758 AC_C_BIGENDIAN
759 AC_C_CHAR_UNSIGNED
761 AC_TYPE_SIGNAL
762 AC_TYPE_UID_T
763 AC_TYPE_MODE_T
764 AC_TYPE_OFF_T
765 AC_TYPE_SIZE_T
766 AC_TYPE_PID_T
767 AC_STRUCT_ST_RDEV
768 AC_DIRENT_D_OFF
769 AC_CHECK_TYPE(ino_t,unsigned)
770 AC_CHECK_TYPE(loff_t,off_t)
771 AC_CHECK_TYPE(offset_t,loff_t)
772 AC_CHECK_TYPE(ssize_t, int)
773 AC_CHECK_TYPE(wchar_t, unsigned short)
775 ############################################
776 # for cups support we need libcups, and a handful of header files
778 AC_ARG_ENABLE(cups,
779 [  --enable-cups           Turn on CUPS support (default=auto)])
781 if test x$enable_cups != xno; then
782         AC_PATH_PROG(CUPS_CONFIG, cups-config)
784         if test "x$CUPS_CONFIG" != x; then
785                 AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
786                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
787                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
788                 PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
789         elif test x"$enable_cups" = x"yes"; then
790                 AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
791         fi
794 ############################################
795 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
796 AC_SEARCH_LIBS(dlopen, [dl])
797 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
799 ############################################
800 # check if the compiler can do immediate structures
801 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
802     AC_TRY_COMPILE([
803 #include <stdio.h>],
805    typedef struct {unsigned x;} FOOBAR;
806    #define X_FOOBAR(x) ((FOOBAR) { x })
807    #define FOO_ONE X_FOOBAR(1)
808    FOOBAR f = FOO_ONE;   
809    static struct {
810         FOOBAR y; 
811         } f2[] = {
812                 {FOO_ONE}
813         };   
815         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
816 if test x"$samba_cv_immediate_structures" = x"yes"; then
817    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
820 ############################################
821 # check if the compiler can do immediate structures
822 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
823     AC_TRY_LINK([
824 #include <stdio.h>],
826                 if (0) {
827                    this_function_does_not_exist();
828                 } else {
829                   return 1;
830                 }
833         samba_cv_optimize_out_funcation_calls=yes,samba_cv_optimize_out_funcation_calls=no)])
834 if test x"$samba_cv_optimize_out_funcation_calls" = x"yes"; then
835    AC_DEFINE(HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS,1,[Whether the compiler will optimize out function calls])
838 ############################################
839 # check for unix domain sockets
840 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
841     AC_TRY_COMPILE([
842 #include <sys/types.h>
843 #include <stdlib.h>
844 #include <stddef.h>
845 #include <sys/socket.h>
846 #include <sys/un.h>],
848   struct sockaddr_un sunaddr; 
849   sunaddr.sun_family = AF_UNIX;
851         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
852 if test x"$samba_cv_unixsocket" = x"yes"; then
853    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
857 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
858     AC_TRY_COMPILE([
859 #include <sys/types.h>
860 #if STDC_HEADERS
861 #include <stdlib.h>
862 #include <stddef.h>
863 #endif
864 #include <sys/socket.h>],[socklen_t i = 0],
865         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
866 if test x"$samba_cv_socklen_t" = x"yes"; then
867    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
870 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
871     AC_TRY_COMPILE([
872 #include <sys/types.h>
873 #if STDC_HEADERS
874 #include <stdlib.h>
875 #include <stddef.h>
876 #endif
877 #include <signal.h>],[sig_atomic_t i = 0],
878         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
879 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
880    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
883 # stupid headers have the functions but no declaration. grrrr.
884 AC_HAVE_DECL(errno, [#include <errno.h>])
885 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
886 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
887 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
888 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
889 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
890 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
892 # and glibc has setresuid under linux but the function does
893 # nothing until kernel 2.1.44! very dumb.
894 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
895     AC_TRY_RUN([#include <errno.h>
896 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
897         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
898 if test x"$samba_cv_have_setresuid" = x"yes"; then
899     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
902 # Do the same check for setresguid...
904 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
905     AC_TRY_RUN([#include <unistd.h>
906 #include <errno.h>
907 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
908         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
909 if test x"$samba_cv_have_setresgid" = x"yes"; then
910     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
913 AC_FUNC_MEMCMP
915 ###############################################
916 # Readline included by default unless explicitly asked not to
917 test "${with_readline+set}" != "set" && with_readline=yes
919 # test for where we get readline() from
920 AC_MSG_CHECKING(whether to use readline)
921 AC_ARG_WITH(readline,
922 [  --with-readline[=DIR]     Look for readline include/libs in DIR (default=auto) ],
923 [  case "$with_readline" in
924   yes)
925     AC_MSG_RESULT(yes)
927     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
928     AC_CHECK_HEADERS(readline/history.h)
930     AC_CHECK_HEADERS(readline.h readline/readline.h,[
931       for termlib in ncurses curses termcap terminfo termlib tinfo; do
932        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
933       done
934       AC_CHECK_LIB(readline, rl_callback_handler_install,
935        [TERMLIBS="-lreadline $TERMLIBS"
936        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
937        break], [TERMLIBS=], $TERMLIBS)])
938     ;;
939   no)
940     AC_MSG_RESULT(no)
941     ;;
942   *)
943     AC_MSG_RESULT(yes)
945     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
946     # alternate readline path
947     _ldflags=${LDFLAGS}
948     _cppflags=${CPPFLAGS}
950     # Add additional search path
951     LDFLAGS="-L$with_readline/lib $LDFLAGS"
952     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
954     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
955     AC_CHECK_HEADERS(readline/history.h)
957     AC_CHECK_HEADERS(readline.h readline/readline.h,[
958       for termlib in ncurses curses termcap terminfo termlib; do
959        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
960       done
961       AC_CHECK_LIB(readline, rl_callback_handler_install,
962        [TERMLDFLAGS="-L$with_readline/lib"
963        TERMCPPFLAGS="-I$with_readline/include"
964        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
965        TERMLIBS="-lreadline $TERMLIBS"
966        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
967        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
969     LDFLAGS=$_ldflags
970     ;;
971   esac],
972   AC_MSG_RESULT(no)
974 AC_SUBST(TERMLIBS)
975 AC_SUBST(TERMLDFLAGS)
977 # The readline API changed slightly from readline3 to readline4, so
978 # code will generate warnings on one of them unless we have a few
979 # special cases.
980 AC_CHECK_LIB(readline, rl_completion_matches,
981              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
982                         [Do we have rl_completion_matches?])],
983              [],
984              [$TERMLIBS])
986 # The following test taken from the cvs sources
987 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
988 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
989 # libsocket.so which has a bad implementation of gethostbyname (it
990 # only looks in /etc/hosts), so we only look for -lsocket if we need
991 # it.
992 AC_CHECK_FUNCS(connect)
993 if test x"$ac_cv_func_connect" = x"no"; then
994     case "$LIBS" in
995     *-lnsl*) ;;
996     *) AC_CHECK_LIB(nsl_s, printf) ;;
997     esac
998     case "$LIBS" in
999     *-lnsl*) ;;
1000     *) AC_CHECK_LIB(nsl, printf) ;;
1001     esac
1002     case "$LIBS" in
1003     *-lsocket*) ;;
1004     *) AC_CHECK_LIB(socket, connect) ;;
1005     esac
1006     case "$LIBS" in
1007     *-linet*) ;;
1008     *) AC_CHECK_LIB(inet, connect) ;;
1009     esac
1010     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
1011     dnl has been cached.
1012     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
1013        test x"$ac_cv_lib_inet_connect" = x"yes"; then
1014         # ac_cv_func_connect=yes
1015         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
1016         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
1017     fi
1020 ###############################################
1021 # test for where we get yp_get_default_domain() from
1022 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
1023 AC_CHECK_FUNCS(yp_get_default_domain)
1025 # Check if we have execl, if not we need to compile smbrun.
1026 AC_CHECK_FUNCS(execl)
1027 if test x"$ac_cv_func_execl" = x"no"; then
1028     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
1031 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
1032 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
1033 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
1034 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
1035 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
1036 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
1037 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
1038 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
1039 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
1040 AC_CHECK_FUNCS(syslog vsyslog timegm)
1041 AC_CHECK_FUNCS(setlocale nl_langinfo)
1042 AC_CHECK_FUNCS(nanosleep)
1043 # setbuffer, shmget, shm_open are needed for smbtorture
1044 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
1045 AC_CHECK_HEADERS(libexc.h)
1046 AC_CHECK_LIB(exc, trace_back_stack)
1048 # syscall() is needed for smbwrapper.
1049 AC_CHECK_FUNCS(syscall)
1051 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
1052 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
1053 AC_CHECK_FUNCS(__getcwd _getcwd)
1054 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
1055 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
1056 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
1057 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
1058 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
1059 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
1060 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
1061 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
1062 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
1063 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
1064 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
1069 case "$host_os" in
1070     *linux*)
1071        # glibc <= 2.3.2 has a broken getgrouplist
1072        AC_TRY_RUN([
1073 #include <unistd.h>
1074 #include <sys/utsname.h>
1075 main() {
1076        /* glibc up to 2.3 has a broken getgrouplist */
1077 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1078        int libc_major = __GLIBC__;
1079        int libc_minor = __GLIBC_MINOR__;
1081        if (libc_major < 2)
1082               exit(1);
1083        if ((libc_major == 2) && (libc_minor <= 3))
1084               exit(1);
1085 #endif
1086        exit(0);
1088 ], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
1089        if test x"$linux_getgrouplist_ok" = x"yes"; then
1090           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
1091        fi
1092        ;;
1093     *)
1094        AC_CHECK_FUNCS(getgrouplist)
1095        ;;
1096 esac
1099 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
1102 if test x$ac_cv_func_stat64 = xno ; then
1103   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
1104   AC_TRY_LINK([
1105 #if defined(HAVE_UNISTD_H)
1106 #include <unistd.h>
1107 #endif
1108 #include <sys/stat.h>
1109 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
1110   AC_MSG_RESULT([$ac_cv_func_stat64])
1111   if test x$ac_cv_func_stat64 = xyes ; then
1112     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
1113   fi
1116 if test x$ac_cv_func_lstat64 = xno ; then
1117   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
1118   AC_TRY_LINK([
1119 #if defined(HAVE_UNISTD_H)
1120 #include <unistd.h>
1121 #endif
1122 #include <sys/stat.h>
1123 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
1124   AC_MSG_RESULT([$ac_cv_func_lstat64])
1125   if test x$ac_cv_func_lstat64 = xyes ; then
1126     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
1127   fi
1130 if test x$ac_cv_func_fstat64 = xno ; then
1131   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
1132   AC_TRY_LINK([
1133 #if defined(HAVE_UNISTD_H)
1134 #include <unistd.h>
1135 #endif
1136 #include <sys/stat.h>
1137 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
1138   AC_MSG_RESULT([$ac_cv_func_fstat64])
1139   if test x$ac_cv_func_fstat64 = xyes ; then
1140     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
1141   fi
1144 #####################################
1145 # we might need the resolv library on some systems
1146 AC_CHECK_LIB(resolv, dn_expand)
1149 # Check for the functions putprpwnam, set_auth_parameters,
1150 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
1151 # Needed for OSF1 and HPUX.
1154 AC_LIBTESTFUNC(security, putprpwnam)
1155 AC_LIBTESTFUNC(sec, putprpwnam)
1157 AC_LIBTESTFUNC(security, set_auth_parameters)
1158 AC_LIBTESTFUNC(sec, set_auth_parameters)
1160 # UnixWare 7.x has its getspnam in -lgen
1161 AC_LIBTESTFUNC(gen, getspnam)
1163 AC_LIBTESTFUNC(security, getspnam)
1164 AC_LIBTESTFUNC(sec, getspnam)
1166 AC_LIBTESTFUNC(security, bigcrypt)
1167 AC_LIBTESTFUNC(sec, bigcrypt)
1169 AC_LIBTESTFUNC(security, getprpwnam)
1170 AC_LIBTESTFUNC(sec, getprpwnam)
1172 ############################################
1173 # Check if we have libattr
1174 AC_SEARCH_LIBS(getxattr, [attr])
1175 AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
1176 AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
1177 AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
1178 AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
1179 AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
1180 # Check if we have extattr
1181 case "$host_os" in
1182   *freebsd4* | *DragonFly* )
1183     AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
1184     ;;
1185   *)
1186     AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
1187     AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
1188     AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
1189     AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
1190     ;;
1191 esac
1193 # Assume non-shared by default and override below
1194 BLDSHARED="false"
1196 # these are the defaults, good for lots of systems
1197 HOST_OS="$host_os"
1198 LDSHFLAGS="-shared"
1199 SONAMEFLAG="#"
1200 SHLD="\${CC} \${CFLAGS}"
1201 PICFLAGS=""
1202 PICSUFFIX="po"
1203 SHLIBEXT="so"
1205 if test "$enable_shared" = "yes"; then
1206   # this bit needs to be modified for each OS that is suported by
1207   # smbwrapper. You need to specify how to create a shared library and
1208   # how to compile C code to produce PIC object files
1210   AC_MSG_CHECKING([ability to build shared libraries])
1212   # and these are for particular systems
1213   case "$host_os" in
1214                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
1215                         BLDSHARED="true"
1216                         if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
1217                                 LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
1218                         else
1219                                 LDSHFLAGS="-shared -Wl,-Bsymbolic" 
1220                         fi
1221                         DYNEXP="-Wl,--export-dynamic"
1222                         PICFLAGS="-fPIC"
1223                         SONAMEFLAG="-Wl,-soname="
1224                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1225                         ;;
1226                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
1227                         BLDSHARED="true"
1228                         LDSHFLAGS="-G"
1229                         SONAMEFLAG="-h "
1230                         if test "${GCC}" = "yes"; then
1231                                 PICFLAGS="-fPIC"
1232                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
1233                                         DYNEXP="-Wl,-E"
1234                                 fi
1235                         else
1236                                 PICFLAGS="-KPIC"
1237                                 ## ${CFLAGS} added for building 64-bit shared 
1238                                 ## libs using Sun's Compiler
1239                                 LDSHFLAGS="-G \${CFLAGS}"
1240                                 PICSUFFIX="po.o"
1241                         fi
1242                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1243                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1244                         ;;
1245                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1246                         BLDSHARED="true"
1247                         LDSHFLAGS="-G"
1248                         SONAMEFLAG="-Wl,-h,"
1249                         PICFLAGS="-KPIC"   # Is this correct for SunOS
1250                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1251                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1252                         ;;
1253                 *netbsd* | *freebsd* | *DragonFly* )  
1254                         BLDSHARED="true"
1255                         LDSHFLAGS="-shared"
1256                         DYNEXP="-Wl,--export-dynamic"
1257                         SONAMEFLAG="-Wl,-soname,"
1258                         PICFLAGS="-fPIC -DPIC"
1259                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1260                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1261                         ;;
1262                 *openbsd*)  BLDSHARED="true"
1263                         LDSHFLAGS="-shared"
1264                         DYNEXP="-Wl,-Bdynamic"
1265                         SONAMEFLAG="-Wl,-soname,"
1266                         PICFLAGS="-fPIC"
1267                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1268                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1269                         ;;
1270                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1271                         case "$host_os" in
1272                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1273                         ;;
1274                         esac
1275                         BLDSHARED="true"
1276                         LDSHFLAGS="-set_version sgi1.0 -shared"
1277                         SONAMEFLAG="-soname "
1278                         SHLD="\${LD}"
1279                         if test "${GCC}" = "yes"; then
1280                                 PICFLAGS="-fPIC"
1281                         else 
1282                                 PICFLAGS="-KPIC"
1283                         fi
1284                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1285                         ;;
1286                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1287                         BLDSHARED="true"
1288                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
1289                         DYNEXP="-Wl,-brtl,-bexpall"
1290                         PICFLAGS="-O2"
1291                         if test "${GCC}" != "yes"; then
1292                                 ## for funky AIX compiler using strncpy()
1293                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1294                         fi
1296                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1297                         AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
1298                         AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
1299                         ;;
1300                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1301                         SHLIBEXT="sl"
1302                         # Use special PIC flags for the native HP-UX compiler.
1303                         if test $ac_cv_prog_cc_Ae = yes; then
1304                                 BLDSHARED="true"
1305                                 SHLD="cc"
1306                                 LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
1307                                 SONAMEFLAG="-Wl,+h "
1308                                 PICFLAGS="+z"
1309                         elif test "${GCC}" = "yes"; then
1310                                 PICFLAGS="-fPIC"
1311                         fi
1312                         DYNEXP="-Wl,-E"
1313                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1314                         AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
1315                         ;;
1316                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1317                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1318                         ;;
1319                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1320                         BLDSHARED="true"
1321                         LDSHFLAGS="-shared"
1322                         SONAMEFLAG="-Wl,-soname,"
1323                         PICFLAGS="-fPIC"
1324                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1325                         AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
1326                         ;;
1327                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1328                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1329                         ;;
1330                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1331                         BLDSHARED="true"
1332                         LDSHFLAGS="-shared"
1333                         SONAMEFLAG="-Wl,-soname,"
1334                         PICFLAGS="-KPIC"
1335                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1336                         ;;
1337                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1338                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1339                         ;;
1340                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1341                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1342                         ;;
1343                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1344                         case "$host" in
1345                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1346                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1347                                         fi
1348                                         LDSHFLAGS="-G"
1349                                         DYNEXP="-Bexport"
1350                                 ;;
1351                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1352                         esac
1353                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1354                         ;;
1356                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1357                         if [ test "$GCC" != yes ]; then
1358                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1359                         fi
1360                         LDSHFLAGS="-G"
1361                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1362                         ;;
1363                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1364                         BLDSHARED="false"
1365                         LDSHFLAGS=""
1366                         ;;
1368                 *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
1369                         BLDSHARED="true"
1370                         LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
1371                         SHLIBEXT="dylib"
1372                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1373                         ;;
1375                 *)
1376                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1377                         ;;
1378   esac
1379   AC_SUBST(DYNEXP)
1380   AC_MSG_RESULT($BLDSHARED)
1381   AC_MSG_CHECKING([linker flags for shared libraries])
1382   AC_MSG_RESULT([$LDSHFLAGS])
1383   AC_MSG_CHECKING([compiler flags for position-independent code])
1384   AC_MSG_RESULT([$PICFLAGS])
1387 #######################################################
1388 # test whether building a shared library actually works
1389 if test $BLDSHARED = true; then
1390 AC_CACHE_CHECK([whether building shared libraries actually works], 
1391                [ac_cv_shlib_works],[
1392    # try building a trivial shared library
1393    ac_cv_shlib_works=no
1394    # The $SHLD and $LDSHFLAGS variables may contain references to other
1395    # variables so they need to be eval'ed.
1396    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
1397         shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
1398    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
1399         shlib.$PICSUFFIX && ac_cv_shlib_works=yes
1400    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
1402 if test $ac_cv_shlib_works = no; then
1403    BLDSHARED=false
1407 ################
1409 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1410 AC_TRY_RUN([#include <stdio.h>
1411 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1412 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1413 if test x"$samba_cv_have_longlong" = x"yes"; then
1414     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1418 # Check if the compiler supports the LL prefix on long long integers.
1419 # AIX needs this.
1421 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1422     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1423         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1424 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1425    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1428   
1429 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1430 AC_TRY_RUN([#include <stdio.h>
1431 #include <sys/stat.h>
1432 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1433 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1434 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1435     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1438 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1439 AC_TRY_RUN([
1440 #if defined(HAVE_UNISTD_H)
1441 #include <unistd.h>
1442 #endif
1443 #include <stdio.h>
1444 #include <sys/stat.h>
1445 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1446 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1447 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1448     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1451 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1452 AC_TRY_RUN([#include <stdio.h>
1453 #include <sys/stat.h>
1454 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1455 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1456 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1457     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1460 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1461 AC_TRY_RUN([
1462 #if defined(HAVE_UNISTD_H)
1463 #include <unistd.h>
1464 #endif
1465 #include <stdio.h>
1466 #include <sys/stat.h>
1467 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1468 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1469 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1470     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1473 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1474 AC_TRY_RUN([
1475 #if defined(HAVE_UNISTD_H)
1476 #include <unistd.h>
1477 #endif
1478 #include <stdio.h>
1479 #include <sys/stat.h>
1480 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1481 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1482 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1483     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1486 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1487 AC_TRY_COMPILE([
1488 #if defined(HAVE_UNISTD_H)
1489 #include <unistd.h>
1490 #endif
1491 #include <sys/types.h>
1492 #include <dirent.h>],
1493 [struct dirent64 de;],
1494 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1495 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1496     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1499 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1500 AC_TRY_RUN([
1501 #if defined(HAVE_UNISTD_H)
1502 #include <unistd.h>
1503 #endif
1504 #include <sys/types.h>
1505 main() { dev_t dev; int i = major(dev); return 0; }],
1506 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1507 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1508     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1511 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1512 AC_TRY_RUN([
1513 #if defined(HAVE_UNISTD_H)
1514 #include <unistd.h>
1515 #endif
1516 #include <sys/types.h>
1517 main() { dev_t dev; int i = minor(dev); return 0; }],
1518 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1519 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1520     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1523 AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
1524 AC_TRY_RUN([
1525 #if defined(HAVE_UNISTD_H)
1526 #include <unistd.h>
1527 #endif
1528 #include <sys/types.h>
1529 main() { dev_t dev = makedev(1,2); return 0; }],
1530 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
1531 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
1532     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
1535 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1536 AC_TRY_RUN([#include <stdio.h>
1537 main() { char c; c=250; exit((c > 0)?0:1); }],
1538 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1539 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1540     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1543 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1544 AC_TRY_COMPILE([#include <sys/types.h>
1545 #include <sys/socket.h>
1546 #include <netinet/in.h>],
1547 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1548 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1549 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1550     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1553 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1554 AC_TRY_COMPILE([#include <sys/types.h>
1555 #include <dirent.h>
1556 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1557 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1558 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1559     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1562 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1563 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1564 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1565 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1566     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1569 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1570 AC_TRY_RUN([
1571 #include <sys/time.h>
1572 #include <unistd.h>
1573 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1574            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1575 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1576     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
1579 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
1580 AC_TRY_LINK([#include <stdarg.h>
1581 va_list ap1,ap2;], [va_copy(ap1,ap2);],
1582 samba_cv_HAVE_VA_COPY=yes,
1583 samba_cv_HAVE_VA_COPY=no)])
1584 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1585     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
1586 else
1587     AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
1588     AC_TRY_LINK([#include <stdarg.h>
1589     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1590     samba_cv_HAVE___VA_COPY=yes,
1591     samba_cv_HAVE___VA_COPY=no)])
1592     if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
1593         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
1594     fi
1597 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1598 AC_TRY_RUN([
1599 #include <sys/types.h>
1600 #include <stdarg.h>
1601 void foo(const char *format, ...) { 
1602        va_list ap;
1603        int len;
1604        char buf[5];
1606        va_start(ap, format);
1607        len = vsnprintf(buf, 0, format, ap);
1608        va_end(ap);
1609        if (len != 5) exit(1);
1611        va_start(ap, format);
1612        len = vsnprintf(0, 0, format, ap);
1613        va_end(ap);
1614        if (len != 5) exit(1);
1616        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1618        exit(0);
1620 main() { foo("hello"); }
1622 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1623 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1624     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1627 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1628 AC_TRY_RUN([#include <sys/types.h>
1629 #include <dirent.h>
1630 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1631 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1632 di->d_name[0] == 0) exit(0); exit(1);} ],
1633 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1634 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1635     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1638 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1639 AC_TRY_COMPILE([#include <sys/types.h>
1640 #include <utime.h>],
1641 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1642 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1643 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1644     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1647 ##############
1648 # Check utmp details, but only if our OS offers utmp.h
1649 if test x"$ac_cv_header_utmp_h" = x"yes"; then
1650 dnl  utmp and utmpx come in many flavours
1651 dnl  We need to check for many of them
1652 dnl  But we don't need to do each and every one, because our code uses
1653 dnl  mostly just the utmp (not utmpx) fields.
1655 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1657 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1658 AC_TRY_COMPILE([#include <sys/types.h>
1659 #include <utmp.h>],
1660 [struct utmp ut;  ut.ut_name[0] = 'a';],
1661 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1662 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1663     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
1664 fi 
1666 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1667 AC_TRY_COMPILE([#include <sys/types.h>
1668 #include <utmp.h>],
1669 [struct utmp ut;  ut.ut_user[0] = 'a';],
1670 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1671 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1672     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
1673 fi 
1675 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1676 AC_TRY_COMPILE([#include <sys/types.h>
1677 #include <utmp.h>],
1678 [struct utmp ut;  ut.ut_id[0] = 'a';],
1679 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1680 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1681     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
1682 fi 
1684 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1685 AC_TRY_COMPILE([#include <sys/types.h>
1686 #include <utmp.h>],
1687 [struct utmp ut;  ut.ut_host[0] = 'a';],
1688 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1689 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1690     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
1691 fi 
1693 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1694 AC_TRY_COMPILE([#include <sys/types.h>
1695 #include <utmp.h>],
1696 [struct utmp ut;  time_t t; ut.ut_time = t;],
1697 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1698 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1699     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
1700 fi 
1702 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1703 AC_TRY_COMPILE([#include <sys/types.h>
1704 #include <utmp.h>],
1705 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1706 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1707 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1708     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
1709 fi 
1711 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1712 AC_TRY_COMPILE([#include <sys/types.h>
1713 #include <utmp.h>],
1714 [struct utmp ut;  ut.ut_type = 0;],
1715 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1716 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1717     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
1718 fi 
1720 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1721 AC_TRY_COMPILE([#include <sys/types.h>
1722 #include <utmp.h>],
1723 [struct utmp ut;  ut.ut_pid = 0;],
1724 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1725 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1726     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
1727 fi 
1729 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1730 AC_TRY_COMPILE([#include <sys/types.h>
1731 #include <utmp.h>],
1732 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1733 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1734 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1735     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
1736 fi 
1738 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1739 AC_TRY_COMPILE([#include <sys/types.h>
1740 #include <utmp.h>],
1741 [struct utmp ut;  ut.ut_addr = 0;],
1742 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1743 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1744     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
1745 fi 
1747 if test x$ac_cv_func_pututline = xyes ; then
1748   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1749   AC_TRY_COMPILE([#include <sys/types.h>
1750 #include <utmp.h>],
1751   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1752   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1753   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1754       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
1755   fi
1758 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1759 AC_TRY_COMPILE([#include <sys/types.h>
1760 #include <utmpx.h>],
1761 [struct utmpx ux;  ux.ut_syslen = 0;],
1762 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1763 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1764     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
1765 fi 
1768 # end utmp details
1771 ICONV_LOCATION=standard
1772 LOOK_DIRS="/usr /usr/local /sw /opt"
1773 AC_ARG_WITH(libiconv,
1774 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1776   if test "$withval" = "no" ; then
1777     AC_MSG_ERROR([argument to --with-libiconv must be a directory])
1778   else
1779      if test "$withval" != "yes" ; then
1780         ICONV_PATH_SPEC=yes
1781         LOOK_DIRS="$withval"
1782      fi
1783   fi
1786 for i in $LOOK_DIRS ; do
1787     save_LIBS=$LIBS
1788     save_LDFLAGS=$LDFLAGS
1789     save_CPPFLAGS=$CPPFLAGS
1790     ICONV_FOUND="no"
1791     unset libext
1792     CPPFLAGS="$CPPFLAGS -I$i/include"
1793 dnl This is here to handle -withval stuff for --with-libiconv
1794 dnl Perhaps we should always add a -L
1796 dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
1797 dnl installation paths. This gets a little tricky since we might have iconv
1798 dnl in both libiconv and in libc. In this case the jm_ICONV test will always
1799 dnl succeed when the header is found. To counter this, make sure the 
1800 dnl library directory is there and check the ABI directory first (which
1801 dnl should be harmless on other systems.
1802     for l in "lib32" "lib" ; do
1803         if test -d "$i/$l" ; then
1804                 LDFLAGS="$save_LDFLAGS -L$i/$l"
1805                 LIBS=
1806                 export LDFLAGS LIBS CPPFLAGS
1807 dnl Try to find iconv(3)
1808                 jm_ICONV($i/$l)
1809                 if test x"$ICONV_FOUND" = "xyes" ; then
1810                     libext="$l"
1811                     break;
1812                 fi
1813         fi
1814     done
1816     if test x"$ICONV_FOUND" = "xyes" ; then
1817         LDFLAGS=$save_LDFLAGS
1818         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1819         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1820         LIBS="$save_LIBS"
1821         ICONV_LOCATION=$i
1822         export LDFLAGS LIBS CPPFLAGS
1823 dnl Now, check for a working iconv ... we want to do it here because
1824 dnl there might be a working iconv further down the list of LOOK_DIRS
1826         ############
1827         # check for iconv in libc
1828         ic_save_LIBS="$LIBS"
1829         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
1830            LIBS="$LIBS -L$ICONV_LOCATION/$libext"
1831         fi
1832         if test x"$jm_cv_lib_iconv" != x; then
1833            LIBS="$LIBS -l$jm_cv_lib_iconv"
1834         fi
1835 dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1836         default_dos_charset=no
1837         default_display_charset=no
1838         default_unix_charset=no
1840         # check for default dos charset name
1841         for j in CP850 IBM850 ; do
1842             rjs_CHARSET($j)
1843             if test x"$ICONV_CHARSET" = x"$j"; then
1844                 default_dos_charset="\"$j\""
1845                 break
1846             fi
1847         done
1848         # check for default display charset name
1849         for j in ASCII 646 ; do
1850             rjs_CHARSET($j)
1851             if test x"$ICONV_CHARSET" = x"$j"; then
1852                 default_display_charset="\"$j\""
1853                 break
1854             fi
1855         done
1856         # check for default unix charset name
1857         for j in UTF-8 UTF8 ; do
1858             rjs_CHARSET($j)
1859             if test x"$ICONV_CHARSET" = x"$j"; then
1860                 default_unix_charset="\"$j\""
1861                 break
1862             fi
1863         done
1864         
1865         if test "$default_dos_charset" != "no" -a \
1866                 "$default_dos_charset" != "cross" -a \
1867                 "$default_display_charset" != "no" -a \ 
1868                 "$default_display_charset" != "cross" -a \
1869                 "$default_unix_charset" != "no" -a \
1870                 "$default_unix_charset" != "cross"
1871         then
1872                 samba_cv_HAVE_NATIVE_ICONV=yes
1873         else if test "$default_dos_charset" = "cross" -o \
1874                      "$default_display_charset" = "cross" -o \
1875                      "$default_unix_charset" = "cross"
1876         then
1877                 samba_cv_HAVE_NATIVE_ICONV=cross
1878         else
1879                 samba_cv_HAVE_NATIVE_ICONV=no
1880         fi
1881         fi
1882 dnl ])
1884         LIBS="$ic_save_LIBS"
1885         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1886            CPPFLAGS=$save_CPPFLAGS
1887            LDFLAGS=$save_LDFLAGS
1888            LIBS=$save_LIBS
1889            if test x"$jm_cv_lib_iconv" != x; then
1890               LIBS="$LIBS -l$jm_cv_lib_iconv"
1891            fi
1892            dnl Add the flags we need to CPPFLAGS and LDFLAGS
1893            CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1894            LIB_ADD_DIR(LDFLAGS, "$i/$libext")
1895            export CPPFLAGS
1896            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
1897            AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
1898            AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
1899            AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
1900            break
1901         fi
1902 dnl We didn't find a working iconv, so keep going
1903     fi
1904 dnl We only need to clean these up here for the next pass through the loop
1905     CPPFLAGS=$save_CPPFLAGS
1906     LDFLAGS=$save_LDFLAGS
1907     LIBS=$save_LIBS
1908     export LDFLAGS LIBS CPPFLAGS
1909 done
1910 unset libext
1913 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
1914     AC_MSG_WARN([Sufficient support for iconv function was not found. 
1915     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
1916    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
1917    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
1918    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
1922 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1923 AC_TRY_RUN([
1924 #include <sys/types.h>
1925 #include <fcntl.h>
1926 #ifndef F_GETLEASE
1927 #define F_GETLEASE      1025
1928 #endif
1929 main() {
1930        int fd = open("/dev/null", O_RDONLY);
1931        return fcntl(fd, F_GETLEASE, 0) == -1;
1934 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1935 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1936     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1939 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1940 AC_TRY_RUN([
1941 #include <sys/types.h>
1942 #include <fcntl.h>
1943 #include <signal.h>
1944 #ifndef F_NOTIFY
1945 #define F_NOTIFY 1026
1946 #endif
1947 main() {
1948         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1951 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1952 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1953     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1956 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1957 AC_TRY_RUN([
1958 #include <sys/types.h>
1959 #include <fcntl.h>
1960 #include <signal.h>
1961 #include <sys/file.h>
1962 #ifndef LOCK_MAND
1963 #define LOCK_MAND       32
1964 #define LOCK_READ       64
1965 #endif
1966 main() {
1967         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1970 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1971 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1972     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1978 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1979 AC_TRY_COMPILE([#include <sys/types.h>
1980 #include <fcntl.h>],
1981 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1982 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1983 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1984     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1987 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1988 AC_TRY_RUN([#include <sys/types.h>
1989 #include <sys/capability.h>
1990 main() {
1991  cap_t cap;
1992  if ((cap = cap_get_proc()) == NULL)
1993    exit(1);
1994  cap->cap_effective |= CAP_NETWORK_MGT;
1995  cap->cap_inheritable |= CAP_NETWORK_MGT;
1996  cap_set_proc(cap);
1997  exit(0);
2000 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
2001 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
2002     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
2006 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
2007 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
2010 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
2011 AC_TRY_COMPILE([#include <sys/types.h>
2012 #if defined(HAVE_RPC_RPC_H)
2013 #include <rpc/rpc.h>
2014 #endif],
2015 [int16 testvar;],
2016 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
2017 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
2018     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
2021 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
2022 AC_TRY_COMPILE([#include <sys/types.h>
2023 #if defined(HAVE_RPC_RPC_H)
2024 #include <rpc/rpc.h>
2025 #endif],
2026 [uint16 testvar;],
2027 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
2028 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
2029     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
2032 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
2033 AC_TRY_COMPILE([#include <sys/types.h>
2034 #if defined(HAVE_RPC_RPC_H)
2035 #include <rpc/rpc.h>
2036 #endif],
2037 [int32 testvar;],
2038 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
2039 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
2040     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
2043 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
2044 AC_TRY_COMPILE([#include <sys/types.h>
2045 #if defined(HAVE_RPC_RPC_H)
2046 #include <rpc/rpc.h>
2047 #endif],
2048 [uint32 testvar;],
2049 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
2050 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
2051     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
2055 dnl Some systems (SCO) have a problem including
2056 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
2057 dnl as a #define in <prot.h> and as part of an enum
2058 dnl in <rpc/rpc.h>.
2061 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
2062 AC_TRY_COMPILE([#include <sys/types.h>
2063 #ifdef HAVE_SYS_SECURITY_H
2064 #include <sys/security.h>
2065 #include <prot.h>
2066 #endif  /* HAVE_SYS_SECURITY_H */
2067 #if defined(HAVE_RPC_RPC_H)
2068 #include <rpc/rpc.h>
2069 #endif],
2070 [int testvar;],
2071 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
2072 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
2073     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
2076 AC_MSG_CHECKING([for test routines])
2077 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
2078            AC_MSG_RESULT(yes),
2079            AC_MSG_ERROR([cant find test code. Aborting config]),
2080            AC_MSG_WARN([cannot run when cross-compiling]))
2082 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
2083 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
2084            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
2085 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
2086     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
2089 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
2090 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
2091            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
2092            samba_cv_HAVE_WORKING_AF_LOCAL=no,
2093            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
2094 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
2095 then
2096     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
2099 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
2100 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
2101            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
2102 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
2103     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
2106 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
2107 SAVE_CPPFLAGS="$CPPFLAGS"
2108 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt"
2109 AC_TRY_COMPILE([
2110 #define REPLACE_GETPASS 1
2111 #define NO_PROTO_H 1
2112 #define NO_CONFIG_H 1
2113 #define main dont_declare_main
2114 #include "${srcdir-.}/lib/getsmbpass.c"
2115 #undef main
2116 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
2117 CPPFLAGS="$SAVE_CPPFLAGS"
2119 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
2120         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
2123 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
2124 AC_TRY_RUN([
2125 #include <stdio.h>
2126 #include <sys/types.h>
2127 #include <netinet/in.h>
2128 #ifdef HAVE_ARPA_INET_H
2129 #include <arpa/inet.h>
2130 #endif
2131 main() { struct in_addr ip; ip.s_addr = 0x12345678;
2132 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
2133     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
2134 exit(1);}],
2135            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
2136 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
2137     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
2140 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
2141 AC_TRY_RUN([#include <stdlib.h>
2142 #include <sys/types.h>
2143 #include <sys/stat.h>
2144 #include <unistd.h>
2145 main() { 
2146   struct stat st;
2147   char tpl[20]="/tmp/test.XXXXXX"; 
2148   int fd = mkstemp(tpl); 
2149   if (fd == -1) exit(1);
2150   unlink(tpl);
2151   if (fstat(fd, &st) != 0) exit(1);
2152   if ((st.st_mode & 0777) != 0600) exit(1);
2153   exit(0);
2155 samba_cv_HAVE_SECURE_MKSTEMP=yes,
2156 samba_cv_HAVE_SECURE_MKSTEMP=no,
2157 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
2158 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
2159     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
2162 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
2163 AC_TRY_RUN([#include <unistd.h>
2164 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
2165 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
2166 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
2167     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
2170 AC_CACHE_CHECK([for sysconf(_SC_NPROC_ONLN)],samba_cv_SYSCONF_SC_NPROC_ONLN,[
2171 AC_TRY_RUN([#include <unistd.h>
2172 main() { exit(sysconf(_SC_NPROC_ONLN) == -1 ? 1 : 0); }],
2173 samba_cv_SYSCONF_SC_NPROC_ONLN=yes,samba_cv_SYSCONF_SC_NPROC_ONLN=no,samba_cv_SYSCONF_SC_NPROC_ONLN=cross)])
2174 if test x"$samba_cv_SYSCONF_SC_NPROC_ONLN" = x"yes"; then
2175     AC_DEFINE(SYSCONF_SC_NPROC_ONLN,1,[Whether sysconf(_SC_NPROC_ONLN) is available])
2178 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
2179 AC_TRY_RUN([main() { exit(getuid() != 0); }],
2180            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
2181 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
2182     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
2183 else
2184     AC_MSG_WARN(running as non-root will disable some tests)
2187 ##################
2188 # look for a method of finding the list of network interfaces
2189 iface=no;
2190 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
2191 AC_TRY_RUN([
2192 #define HAVE_IFACE_AIX 1
2193 #define AUTOCONF_TEST 1
2194 #include "confdefs.h"
2195 #include "${srcdir-.}/lib/interfaces.c"],
2196            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
2197 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
2198     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
2201 if test $iface = no; then
2202 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
2203 AC_TRY_RUN([
2204 #define HAVE_IFACE_IFCONF 1
2205 #define AUTOCONF_TEST 1
2206 #include "confdefs.h"
2207 #include "${srcdir-.}/lib/interfaces.c"],
2208            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
2209 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
2210     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
2214 if test $iface = no; then
2215 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
2216 AC_TRY_RUN([
2217 #define HAVE_IFACE_IFREQ 1
2218 #define AUTOCONF_TEST 1
2219 #include "confdefs.h"
2220 #include "${srcdir-.}/lib/interfaces.c"],
2221            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
2222 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
2223     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
2228 ################################################
2229 # look for a method of setting the effective uid
2230 seteuid=no;
2231 if test $seteuid = no; then
2232 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
2233 AC_TRY_RUN([
2234 #define AUTOCONF_TEST 1
2235 #define USE_SETRESUID 1
2236 #include "confdefs.h"
2237 #include "${srcdir-.}/lib/util_sec.c"],
2238            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
2239 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
2240     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
2245 if test $seteuid = no; then
2246 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
2247 AC_TRY_RUN([
2248 #define AUTOCONF_TEST 1
2249 #define USE_SETREUID 1
2250 #include "confdefs.h"
2251 #include "${srcdir-.}/lib/util_sec.c"],
2252            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
2253 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
2254     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
2258 if test $seteuid = no; then
2259 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
2260 AC_TRY_RUN([
2261 #define AUTOCONF_TEST 1
2262 #define USE_SETEUID 1
2263 #include "confdefs.h"
2264 #include "${srcdir-.}/lib/util_sec.c"],
2265            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
2266 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
2267     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
2271 if test $seteuid = no; then
2272 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
2273 AC_TRY_RUN([
2274 #define AUTOCONF_TEST 1
2275 #define USE_SETUIDX 1
2276 #include "confdefs.h"
2277 #include "${srcdir-.}/lib/util_sec.c"],
2278            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
2279 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
2280     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
2285 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
2286 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
2287            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
2288 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
2289     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
2292 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
2293 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
2294            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
2295 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
2296     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
2299 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
2300 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
2301            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
2302 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
2303     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
2305 else
2308 dnl Don't check for 64 bit fcntl locking if we know that the
2309 dnl glibc2.1 broken check has succeeded.
2310 dnl 
2312   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
2313   AC_TRY_RUN([
2314 #if defined(HAVE_UNISTD_H)
2315 #include <unistd.h>
2316 #endif
2317 #include <stdio.h>
2318 #include <stdlib.h>
2320 #ifdef HAVE_FCNTL_H
2321 #include <fcntl.h>
2322 #endif
2324 #ifdef HAVE_SYS_FCNTL_H
2325 #include <sys/fcntl.h>
2326 #endif
2327 main() { struct flock64 fl64;
2328 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
2329 exit(0);
2330 #else
2331 exit(1);
2332 #endif
2334        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
2336   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
2337       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
2338   fi
2341 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
2342 AC_TRY_COMPILE([#include <sys/types.h>
2343 #include <sys/stat.h>
2344 #include <unistd.h>],
2345 [struct stat st;  st.st_blocks = 0;],
2346 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
2347 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
2348     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
2349 fi 
2351 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
2352 AC_TRY_COMPILE([#include <sys/types.h>
2353 #include <sys/stat.h>
2354 #include <unistd.h>],
2355 [struct stat st;  st.st_blksize = 0;],
2356 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
2357 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
2358     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
2361 case "$host_os" in
2362 *linux*)
2363 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
2364 AC_TRY_COMPILE([
2365 #ifdef HAVE_SYS_VFS_H
2366 #include <sys/vfs.h>
2367 #endif
2368 #ifdef HAVE_SYS_CAPABILITY_H
2369 #include <sys/capability.h>
2370 #endif
2371 ],[int i;],
2372    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2373 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2374    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2377 esac
2379 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2380 AC_TRY_COMPILE([
2381 #include <sys/types.h>
2382 #include <sys/acl.h>
2383 #if defined(HAVE_RPCSVC_NIS_H)
2384 #include <rpcsvc/nis.h>
2385 #endif],
2386 [int i;],
2387 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2388 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2389         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2392 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
2393 AC_TRY_RUN([
2394 #include <stdio.h>
2395 #include <limits.h>
2396 main() {
2397         char *newpath = realpath("/tmp", NULL);
2398         exit ((newpath != NULL) ? 0 : 1);
2401 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
2402 if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
2403     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
2406 #################################################
2407 # check for smbwrapper support
2408 AC_MSG_CHECKING(whether to use smbwrapper)
2409 AC_ARG_WITH(smbwrapper,
2410 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
2411 [ case "$withval" in
2412   yes)
2413     AC_MSG_RESULT(yes)
2414     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
2415         WRAPPROG="bin/smbsh\$(EXEEXT)"
2416         WRAP="bin/smbwrapper.$SHLIBEXT"
2417         WRAP_OBJS="\$(SMBW_OBJ1) \$(SMBWRAPPER_OBJ1)"
2418         WRAP_INC="-I\$(srcdir)/smbwrapper"
2420 # Conditions under which smbwrapper should not be built.
2422         if test x$PICFLAGS = x; then
2423            echo No support for PIC code - disabling smbwrapper and smbsh
2424            WRAPPROG=""
2425            WRAP=""
2426            WRAP_OBJS=""
2427            WRAP_INC=""
2428         elif test x$ac_cv_func_syscall = xno; then
2429            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
2430            WRAPPROG=""
2431            WRAP=""
2432            WRAP_OBJS=""
2433            WRAP_INC=""
2434         fi
2435         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
2436         SMBWRAPPER="$WRAPPROG $WRAP"
2437         SMBWRAP_OBJS="$WRAP_OBJS"
2438         SMBWRAP_INC="$WRAP_INC"
2439     ;;
2440   *)
2441     AC_MSG_RESULT(no)
2442     ;;
2443   esac ],
2444   AC_MSG_RESULT(no)
2447 #################################################
2448 # check for AFS clear-text auth support
2449 samba_cv_WITH_AFS=no
2450 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2451 AC_ARG_WITH(afs,
2452 [  --with-afs              Include AFS clear-text auth support (default=no) ],
2453 [ case "$withval" in
2454   yes|auto)
2455     AC_MSG_RESULT($withval)
2456     samba_cv_WITH_AFS=$withval
2457     ;;
2458   *)
2459     AC_MSG_RESULT(no)
2460     ;;
2461   esac ],
2462   AC_MSG_RESULT(no)
2465 ####################################################
2466 # check for Linux-specific AFS fake-kaserver support
2467 samba_cv_WITH_FAKE_KASERVER=no
2468 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2469 AC_ARG_WITH(fake-kaserver,
2470 [  --with-fake-kaserver    Include AFS fake-kaserver support (default=no) ],
2471 [ case "$withval" in
2472   yes|auto)
2473     AC_MSG_RESULT($withval)
2474     samba_cv_WITH_FAKE_KASERVER=$withval
2475     ;;
2476   *)
2477     AC_MSG_RESULT(no)
2478     ;;
2479   esac ],
2480   AC_MSG_RESULT(no)
2483 #################################################
2484 # decide whether we can support WITH_AFS and / or WITH_FAKE_KASERVER
2485 if test x"$samba_cv_WITH_AFS" != x"no" ||
2486    test x"$samba_cv_WITH_FAKE_KASERVER" != x"no"; then
2488     # see if this box has the afs-headers in /usr/include/afs
2489     AC_MSG_CHECKING(for /usr/include/afs)
2490     if test -d /usr/include/afs; then
2491           CFLAGS="$CFLAGS -I/usr/include/afs"
2492           CPPFLAGS="$CPPFLAGS -I/usr/include/afs"
2493           AC_MSG_RESULT(yes)
2494     else
2495       AC_MSG_RESULT(no)
2496     fi
2497    
2498     # check for afs.h
2499     have_afs_headers=no
2500     AC_CHECK_HEADERS(afs.h afs/afs.h)
2501     if test x"$ac_cv_header_afs_h" = x"no" && test x"$ac_cv_header_afs_afs_h" = x"no"; then
2502         if test x"$samba_cv_WITH_FAKE_KASERVER" = x"auto" ||
2503            test x"$samba_cv_WITH_AFS" = x"auto"; then
2504                 AC_MSG_WARN([AFS cannot be supported without afs.h])
2505         else
2506                 AC_MSG_ERROR([AFS cannot be supported without afs.h])
2507         fi
2508     else
2509         have_afs_headers=yes
2510     fi
2513 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
2514     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
2517 #################################################
2518 # check whether to compile AFS/NT ACL mapping module
2519 samba_cv_WITH_VFS_AFSACL=no
2520 AC_MSG_CHECKING(whether to use AFS fake-kaserver)
2521 AC_ARG_WITH(vfs-afsacl,
2522 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
2523 [ case "$withval" in
2524   yes|auto)
2525     AC_MSG_RESULT($withval)
2526     samba_cv_WITH_VFS_AFSACL=yes
2527     ;;
2528   *)
2529     AC_MSG_RESULT(no)
2530     ;;
2531   esac ],
2532   AC_MSG_RESULT(no)
2535 if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
2536    default_shared_modules="$default_shared_modules vfs_afsacl"
2538         
2539 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
2540     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2543 #################################################
2544 # check for the DFS clear-text auth system
2545 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2546 AC_ARG_WITH(dfs,
2547 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
2548 [ case "$withval" in
2549   yes)
2550     AC_MSG_RESULT(yes)
2551     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2552     ;;
2553   *)
2554     AC_MSG_RESULT(no)
2555     ;;
2556   esac ],
2557   AC_MSG_RESULT(no)
2560 ########################################################
2561 # Compile with LDAP support?
2563 with_ldap_support=auto
2564 AC_MSG_CHECKING([for LDAP support])
2566 AC_ARG_WITH(ldap,
2567 [  --with-ldap             LDAP support (default yes)],
2568 [ case "$withval" in
2569     yes|no)
2570         with_ldap_support=$withval
2571         ;;
2572   esac ])
2574 AC_MSG_RESULT($with_ldap_support)
2576 SMBLDAP=""
2577 AC_SUBST(SMBLDAP)
2578 if test x"$with_ldap_support" != x"no"; then
2580   ##################################################################
2581   # first test for ldap.h and lber.h
2582   # (ldap.h is required for this test)
2583   AC_CHECK_HEADERS(ldap.h lber.h)
2584   
2585   if test x"$ac_cv_header_ldap_h" != x"yes"; then
2586         if test x"$with_ldap_support" = x"yes"; then
2587          AC_MSG_ERROR(ldap.h is needed for LDAP support)
2588         else
2589          AC_MSG_WARN(ldap.h is needed for LDAP support)
2590         fi
2591         
2592         with_ldap_support=no
2593   fi
2596 if test x"$with_ldap_support" != x"no"; then
2597   ac_save_LIBS=$LIBS
2599   ##################################################################
2600   # we might need the lber lib on some systems. To avoid link errors
2601   # this test must be before the libldap test
2602   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
2604   ########################################################
2605   # now see if we can find the ldap libs in standard paths
2606   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
2608   AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
2609   
2610   ########################################################
2611   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
2612   # Check found in pam_ldap 145.
2613   AC_CHECK_FUNC_EXT(ldap_set_rebind_proc,$LDAP_LIBS)
2615   LIBS="$LIBS $LDAP_LIBS"
2616   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
2617     AC_TRY_COMPILE([
2618         #include <lber.h>
2619         #include <ldap.h>], 
2620         [ldap_set_rebind_proc(0, 0, 0);], 
2621         [smb_ldap_cv_ldap_set_rebind_proc=3], 
2622         [smb_ldap_cv_ldap_set_rebind_proc=2]
2623     ) 
2624   ])
2625   
2626   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
2628   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS) 
2629   
2630   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
2631     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
2632     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
2633     SMBLDAP="lib/smbldap.o"
2634     with_ldap_support=yes
2635     AC_MSG_CHECKING(whether LDAP support is used)
2636     AC_MSG_RESULT(yes)
2637   else
2638     if test x"$with_ldap_support" = x"yes"; then
2639         AC_MSG_ERROR(libldap is needed for LDAP support)
2640     else
2641         AC_MSG_WARN(libldap is needed for LDAP support)
2642     fi
2643     
2644     LDAP_LIBS=""
2645     with_ldap_support=no
2646   fi
2647   LIBS=$ac_save_LIBS
2651 #################################################
2652 # active directory support
2654 with_ads_support=auto
2655 AC_MSG_CHECKING([for Active Directory and krb5 support])
2657 AC_ARG_WITH(ads,
2658 [  --with-ads              Active Directory support (default auto)],
2659 [ case "$withval" in
2660     yes|no)
2661         with_ads_support="$withval"
2662         ;;
2663   esac ])
2665 AC_MSG_RESULT($with_ads_support)
2667 FOUND_KRB5=no
2668 KRB5_LIBS=""
2670 if test x"$with_ldap_support" != x"yes"; then
2671     if test x"$with_ads_support" = x"yes"; then
2672         AC_MSG_ERROR(Active Directory Support requires LDAP support)
2673     elif test x"$with_ads_support" != x"no"; then
2674         AC_MSG_WARN(Active Directory Support requires LDAP support)
2675     fi
2676     with_ads_support=no
2679 if test x"$with_ads_support" != x"no"; then
2681   # Do no harm to the values of CFLAGS and LIBS while testing for
2682   # Kerberos support.
2684   if test x$FOUND_KRB5 = x"no"; then
2685     #################################################
2686     # check for location of Kerberos 5 install
2687     AC_MSG_CHECKING(for kerberos 5 install path)
2688     AC_ARG_WITH(krb5,
2689     [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
2690     [ case "$withval" in
2691       no)
2692         AC_MSG_RESULT(no krb5-path given)
2693         ;;
2694       yes)
2695         AC_MSG_RESULT(/usr)
2696         FOUND_KRB5=yes
2697         ;;
2698       *)
2699         AC_MSG_RESULT($withval)
2700         KRB5_CFLAGS="-I$withval/include"
2701         KRB5_CPPFLAGS="-I$withval/include"
2702         KRB5_LDFLAGS="-L$withval/lib"
2703         FOUND_KRB5=yes
2704         if test -x "$withval/bin/krb5-config"; then
2705                 KRB5CONFIG=$withval/bin/krb5-config
2706         fi
2707         ;;
2708       esac ],
2709       AC_MSG_RESULT(no krb5-path given)
2710     )
2711   fi
2713   #################################################
2714   # check for krb5-config from recent MIT and Heimdal kerberos 5
2715   AC_PATH_PROG(KRB5CONFIG, krb5-config)
2716   AC_MSG_CHECKING(for working krb5-config)
2717   if test -x "$KRB5CONFIG"; then
2718     ac_save_CFLAGS=$CFLAGS
2719     CFLAGS="";export CFLAGS
2720     ac_save_LDFLAGS=$LDFLAGS
2721     LDFLAGS="";export LDFLAGS
2722     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
2723     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
2724     KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
2725     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
2726     CFLAGS=$ac_save_CFLAGS;export CFLAGS
2727     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
2728     FOUND_KRB5=yes
2729     AC_MSG_RESULT(yes)
2730   else
2731     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
2732   fi
2734   if test x$FOUND_KRB5 = x"no"; then
2735     #################################################
2736     # see if this box has the SuSE location for the heimdal krb implementation
2737     AC_MSG_CHECKING(for /usr/include/heimdal)
2738     if test -d /usr/include/heimdal; then
2739       if test -f /usr/lib/heimdal/lib/libkrb5.a; then
2740           KRB5_CFLAGS="-I/usr/include/heimdal"
2741           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2742           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
2743           AC_MSG_RESULT(yes)
2744       else
2745           KRB5_CFLAGS="-I/usr/include/heimdal"
2746           KRB5_CPPFLAGS="-I/usr/include/heimdal"
2747           AC_MSG_RESULT(yes)
2748       fi
2749     else
2750       AC_MSG_RESULT(no)
2751     fi
2752   fi
2754   if test x$FOUND_KRB5 = x"no"; then
2755     #################################################
2756     # see if this box has the RedHat location for kerberos
2757     AC_MSG_CHECKING(for /usr/kerberos)
2758     if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
2759       KRB5_LDFLAGS="-L/usr/kerberos/lib"
2760       KRB5_CFLAGS="-I/usr/kerberos/include"
2761       KRB5_CPPFLAGS="-I/usr/kerberos/include"
2762       AC_MSG_RESULT(yes)
2763     else
2764       AC_MSG_RESULT(no)
2765     fi
2766   fi
2768   ac_save_CFLAGS=$CFLAGS
2769   ac_save_CPPFLAGS=$CPPFLAGS
2770   ac_save_LDFLAGS=$LDFLAGS
2772   CFLAGS="$KRB5_CFLAGS $CFLAGS"
2773   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
2774   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
2776   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
2778   # now check for krb5.h. Some systems have the libraries without the headers!
2779   # note that this check is done here to allow for different kerberos
2780   # include paths
2781   AC_CHECK_HEADERS(krb5.h)
2783   if test x"$ac_cv_header_krb5_h" = x"no"; then
2785     # Give a warning if AD support was not explicitly requested,
2786     # i.e with_ads_support = auto, otherwise die with an error.
2788     if test x"$with_ads_support" = x"yes"; then
2789       AC_MSG_ERROR([Active Directory cannot be supported without krb5.h])
2790     else
2791       AC_MSG_WARN([Active Directory cannot be supported without krb5.h])
2792     fi
2794     # Turn off AD support and restore CFLAGS and LIBS variables
2796     with_ads_support="no"
2797     
2798     CFLAGS=$ac_save_CFLAGS
2799     CPPFLAGS=$ac_save_CPPFLAGS
2800     LDFLAGS=$ac_save_LDFLAGS
2801   fi
2804 # Now we have determined whether we really want ADS support
2806 if test x"$with_ads_support" != x"no"; then
2807   ac_save_LIBS=$LIBS
2809   # now check for gssapi headers.  This is also done here to allow for
2810   # different kerberos include paths
2811   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
2813   ##################################################################
2814   # we might need the k5crypto and com_err libraries on some systems
2815   AC_CHECK_LIB_EXT(com_err, KRB5_LIBS, _et_list)
2816   AC_CHECK_LIB_EXT(k5crypto, KRB5_LIBS, krb5_encrypt_data)
2818   # Heimdal checks.
2819   AC_CHECK_LIB_EXT(crypto, KRB5_LIBS, des_set_key)
2820   AC_CHECK_LIB_EXT(asn1, KRB5_LIBS, copy_Authenticator)
2821   AC_CHECK_LIB_EXT(roken, KRB5_LIBS, roken_getaddrinfo_hostspec)
2823   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
2824   AC_CHECK_LIB_EXT(gssapi, KRB5_LIBS, gss_display_status,[],[],
2825                                 AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2827   ########################################################
2828   # now see if we can find the krb5 libs in standard paths
2829   # or as specified above
2830   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
2831   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
2833   ########################################################
2834   # now see if we can find the gssapi libs in standard paths
2835   AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],
2836             AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available]))
2838   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
2839   AC_CHECK_FUNC_EXT(krb5_set_default_in_tkt_etypes, $KRB5_LIBS)
2840   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
2841   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
2842   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
2843   AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
2844   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
2845   AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
2846   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
2847   AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
2848   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
2849   AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
2850   AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
2851   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
2852   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
2853   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
2854   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
2855   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
2856   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
2857   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
2858   AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
2859   AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
2861   LIBS="$KRB5_LIBS $LIBS"
2862   
2863   AC_CACHE_CHECK([for krb5_encrypt_block type],
2864                 samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
2865     AC_TRY_COMPILE([#include <krb5.h>],
2866       [krb5_encrypt_block block;],
2867       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
2868       samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
2870   if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
2871     AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
2872                [Whether the type krb5_encrypt_block exists])
2873   fi
2875   AC_CACHE_CHECK([for addrtype in krb5_address],
2876                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
2877     AC_TRY_COMPILE([#include <krb5.h>],
2878       [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
2879       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,
2880       samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
2882   if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
2883     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,
2884                [Whether the krb5_address struct has a addrtype property])
2885   fi
2887   AC_CACHE_CHECK([for addr_type in krb5_address],
2888                  samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
2889     AC_TRY_COMPILE([#include <krb5.h>],
2890       [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
2891       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,
2892       samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
2894   if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
2895     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,
2896               [Whether the krb5_address struct has a addr_type property])
2897   fi
2899   AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
2900                  samba_cv_HAVE_KRB5_TKT_ENC_PART2,
2901                  [AC_TRY_COMPILE([#include <krb5.h>],
2902     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
2903     samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
2905   if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
2906     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
2907               [Whether the krb5_ticket struct has a enc_part2 property])
2908   fi
2910   AC_CACHE_CHECK([for keyblock in krb5_creds],
2911                  samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
2912     AC_TRY_COMPILE([#include <krb5.h>],
2913       [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
2914       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
2915       samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
2917   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
2918     AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
2919               [Whether the krb5_creds struct has a keyblock property])
2920   fi
2922   AC_CACHE_CHECK([for session in krb5_creds],
2923                  samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
2924     AC_TRY_COMPILE([#include <krb5.h>],
2925       [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
2926       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
2927       samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
2929   if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
2930     AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
2931               [Whether the krb5_creds struct has a session property])
2932   fi
2934   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
2935                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
2936     AC_TRY_COMPILE([#include <krb5.h>],
2937       [krb5_keyblock key; key.keyvalue.data = NULL;],
2938       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,
2939       samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
2941   if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
2942     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,
2943               [Whether the krb5_keyblock struct has a keyvalue property])
2944   fi
2946   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
2947                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
2948     AC_TRY_COMPILE([#include <krb5.h>],
2949       [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
2950       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,
2951       samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
2952   AC_CACHE_CHECK([for KEYTYPE_ARCFOUR_56],
2953                  samba_cv_HAVE_KEYTYPE_ARCFOUR_56,[
2954     AC_TRY_COMPILE([#include <krb5.h>],
2955       [krb5_keytype keytype; keytype = KEYTYPE_ARCFOUR_56;],
2956       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=yes,
2957       samba_cv_HAVE_KEYTYPE_ARCFOUR_56=no)])
2958 # Heimdals with KEYTYPE_ARCFOUR but not KEYTYPE_ARCFOUR_56 are broken
2959 # w.r.t. arcfour and windows, so we must not enable it here
2960   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
2961           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
2962     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
2963               [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
2964   fi
2966   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
2967                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
2968     AC_TRY_COMPILE([#include <krb5.h>],
2969       [krb5_flags ap_options; ap_options = AP_OPTS_USE_SUBKEY;],
2970       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=yes,
2971       samba_cv_HAVE_AP_OPTS_USE_SUBKEY=no)])
2973   if test x"$samba_cv_HAVE_AP_OPTS_USE_SUBKEY" = x"yes"; then
2974     AC_DEFINE(HAVE_AP_OPTS_USE_SUBKEY,1,
2975               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
2976   fi
2978   AC_CACHE_CHECK([for KV5M_KEYTAB],
2979                  samba_cv_HAVE_KV5M_KEYTAB,[
2980     AC_TRY_COMPILE([#include <krb5.h>],
2981       [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
2982       samba_cv_HAVE_KV5M_KEYTAB=yes,
2983       samba_cv_HAVE_KV5M_KEYTAB=no)])
2985   if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
2986       AC_DEFINE(HAVE_KV5M_KEYTAB,1,
2987              [Whether the KV5M_KEYTAB option is available])
2988   fi
2990   AC_CACHE_CHECK([for the krb5_princ_component macro],
2991                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
2992     AC_TRY_LINK([#include <krb5.h>],
2993       [const krb5_data *pkdata; krb5_context context; krb5_principal principal; pkdata = krb5_princ_component(context, principal, 0);],
2994       samba_cv_HAVE_KRB5_PRINC_COMPONENT=yes,
2995       samba_cv_HAVE_KRB5_PRINC_COMPONENT=no)])
2997   if test x"$samba_cv_HAVE_KRB5_PRINC_COMPONENT" = x"yes"; then
2998     AC_DEFINE(HAVE_KRB5_PRINC_COMPONENT,1,
2999                [Whether krb5_princ_component is available])
3000   fi
3002   AC_CACHE_CHECK([for key in krb5_keytab_entry],
3003                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
3004     AC_TRY_COMPILE([#include <krb5.h>],
3005       [krb5_keytab_entry entry; krb5_keyblock e; entry.key = e;],
3006       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=yes,
3007       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY=no)])
3009   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY" = x"yes"; then
3010     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEY,1,
3011               [Whether krb5_keytab_entry has key member])
3012   fi
3014   AC_CACHE_CHECK([for keyblock in krb5_keytab_entry],
3015                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,[
3016     AC_TRY_COMPILE([#include <krb5.h>],
3017       [krb5_keytab_entry entry; entry.keyblock.keytype = 0;],
3018       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=yes,
3019       samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK=no)])
3021   if test x"$samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK" = x"yes"; then
3022     AC_DEFINE(HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK,1,
3023               [Whether krb5_keytab_entry has keyblock member])
3024   fi
3026   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
3027     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
3028     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
3029     AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
3030     AC_MSG_RESULT(yes)
3031   else
3032     if test x"$with_ads_support" = x"yes"; then
3033         AC_MSG_ERROR(libkrb5 is needed for Active Directory support)
3034     else
3035         AC_MSG_WARN(libkrb5 is needed for Active Directory support)
3036     fi
3037     KRB5_LIBS=""
3038     with_ads_support=no 
3039   fi
3041   AC_CACHE_CHECK([for WRFILE: keytab support],
3042                 samba_cv_HAVE_WRFILE_KEYTAB,[
3043     AC_TRY_RUN([
3044 #include<krb5.h>
3045   main()
3046   {
3047     krb5_context context;
3048     krb5_keytab keytab;
3050     krb5_init_context(&context);
3051     return krb5_kt_resolve(context, "WRFILE:api", &keytab);
3052   }],
3053   samba_cv_HAVE_WRFILE_KEYTAB=yes,
3054   samba_cv_HAVE_WRFILE_KEYTAB=no)])
3056   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
3057       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
3058                [Whether the WRFILE:-keytab is supported])
3059   fi
3061   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
3062                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
3063     AC_TRY_COMPILE([#include <krb5.h>],
3064     [
3065     krb5_context context;
3066     krb5_principal principal;
3067     krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
3068     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
3069     samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
3071   if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
3072     AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
3073               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
3074   fi
3076 LIBS="$ac_save_LIBS"
3079 ########################################################
3080 # Compile experimental passdb backends?
3081 # (pdb_xml, pdb_mysql, pdb_pgsql)
3082 AC_MSG_CHECKING(whether to build experimental passdb libraries)
3083 AC_ARG_WITH(expsam,
3084 [  --with-expsam=<list>    Include experimental passdb libraries (default=no)]
3085 [                          Valid choices include (comma separated list): ]
3086 [                              xml, mysql & pgsql],
3087 [ expsam_pdb_modules=`echo "$withval" | sed 's/,/ /g'`
3088   if test "z$expsam_pdb_modules" = "zyes"; then
3089     expsam_pdb_modules="xml mysql pgsql"
3090   fi
3091   AC_MSG_RESULT($expsam_pdb_modules)
3092   for i in $expsam_pdb_modules
3093   do 
3094     case "$i" in
3095     xml|all|yes)
3096       ## pdb_xml
3097           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])])
3098       CFLAGS="$CFLAGS $XML_CFLAGS"
3099       ;;
3100     mysql|all|yes)
3101       ## pdb_mysql
3102           AM_PATH_MYSQL([default_shared_modules="$default_shared_modules pdb_mysql"],[AC_MSG_ERROR([Can't find MySQL libraries while MySQL support is requested])])
3103       CFLAGS="$CFLAGS $MYSQL_CFLAGS"
3104       ;;
3105      pgsql|all|yes)
3106       ## pdb_pgsql
3107       AM_PATH_PGSQL([default_shared_modules="$default_shared_modules pdb_pgsql"],[])
3108       CFLAGS="$CFLAGS $PGSQL_CFLAGS"
3109       ;;
3110     no)
3111       ;;
3112     *)
3113       echo "Unknown module name \"$i\"!  Exiting..."
3114       exit 1
3115       ;;
3116     esac
3117   done ],
3118   AC_MSG_RESULT(no)
3121 #################################################
3122 # check for automount support
3123 AC_MSG_CHECKING(whether to use automount)
3124 AC_ARG_WITH(automount,
3125 [  --with-automount        Include automount support (default=no)],
3126 [ case "$withval" in
3127   yes)
3128     AC_MSG_RESULT(yes)
3129     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
3130     ;;
3131   *)
3132     AC_MSG_RESULT(no)
3133     ;;
3134   esac ],
3135   AC_MSG_RESULT(no)
3138 #################################################
3139 # check for smbmount support
3140 AC_MSG_CHECKING(whether to use smbmount)
3141 AC_ARG_WITH(smbmount,
3142 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
3143 [ case "$withval" in
3144   yes)
3145         case "$host_os" in
3146         *linux*)
3147                 AC_MSG_RESULT(yes)
3148                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
3149                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
3150                 ;;
3151         *)
3152                 AC_MSG_ERROR(not on a linux system!)
3153                 ;;
3154         esac
3155     ;;
3156   *)
3157     AC_MSG_RESULT(no)
3158     ;;
3159   esac ],
3160   AC_MSG_RESULT(no)
3165 #################################################
3166 # check for a PAM clear-text auth, accounts, password and session support
3167 with_pam_for_crypt=no
3168 AC_MSG_CHECKING(whether to use PAM)
3169 AC_ARG_WITH(pam,
3170 [  --with-pam              Include PAM support (default=no)],
3171 [ case "$withval" in
3172   yes)
3173     AC_MSG_RESULT(yes)
3174     if test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3175        if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
3176           if test x"$ac_cv_header_security__pam_macros_h" = x"no"; then
3177              AC_MSG_ERROR(--with-pam specified but no PAM headers found)
3178           fi
3179        fi
3180     fi
3181     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
3182     AUTH_LIBS="$AUTH_LIBS -lpam"
3183     with_pam_for_crypt=yes
3184     ;;
3185   *)
3186     AC_MSG_RESULT(no)
3187     ;;
3188   esac ],
3189   AC_MSG_RESULT(no)
3192 # we can't build a pam module if we don't have pam.
3193 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
3195 #################################################
3196 # check for pam_smbpass support
3197 AC_MSG_CHECKING(whether to use pam_smbpass)
3198 AC_ARG_WITH(pam_smbpass,
3199 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
3200 [ case "$withval" in
3201   yes)
3202     AC_MSG_RESULT(yes)
3204        # Conditions under which pam_smbpass should not be built.
3206        if test x$PICFLAGS = x; then
3207           AC_MSG_ERROR([No support for PIC code])
3208        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
3209           AC_MSG_ERROR([No security/pam_appl.h found])
3210        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
3211           AC_MSG_ERROR([No libpam found])
3212        else
3213           AUTH_LIBS="$AUTH_LIBS -lpam"
3214           SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.$SHLIBEXT"
3215        fi
3216     ;;
3217   *)
3218     AC_MSG_RESULT(no)
3219     ;;
3220   esac ],
3221   AC_MSG_RESULT(no)
3225 ###############################################
3226 # test for where we get crypt() from
3227 AC_SEARCH_LIBS(crypt, [crypt],
3228   [test "$ac_cv_search_crypt" = "none required" || AUTH_LIBS="-lcrypt $AUTH_LIBS"
3229   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
3232 ## moved after the check for -lcrypt in order to
3233 ## ensure that the necessary libraries are included
3234 ## check checking for truncated salt.  Wrapped by the
3235 ## $with_pam_for_crypt variable as above   --jerry
3237 if test $with_pam_for_crypt = no; then
3238 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
3239 crypt_LIBS="$LIBS"
3240 LIBS="$AUTH_LIBS $LIBS"
3241 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
3242         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
3243 LIBS="$crypt_LIBS"])
3244 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
3245         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
3250 ########################################################################################
3252 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
3254 ########################################################################################
3256 #################################################
3257 # check for a LDAP password database configuration backwards compatibility
3258 AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration)
3259 AC_ARG_WITH(ldapsam,
3260 [  --with-ldapsam          Include LDAP SAM 2.2 compatible configuration (default=no)],
3261 [ case "$withval" in
3262   yes)
3263     AC_MSG_RESULT(yes)
3264     AC_DEFINE(WITH_LDAP_SAMCONFIG,1,[Whether to include 2.2 compatible LDAP SAM configuration])
3265     ;;
3266   *)
3267     AC_MSG_RESULT(no)
3268     ;;
3269   esac ],
3270   AC_MSG_RESULT(no)
3273 ########################################################################################
3275 ## END OF TESTS FOR SAM BACKENDS.  
3277 ########################################################################################
3279 #################################################
3280 # check for a NISPLUS_HOME support 
3281 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
3282 AC_ARG_WITH(nisplus-home,
3283 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
3284 [ case "$withval" in
3285   yes)
3286     AC_MSG_RESULT(yes)
3287     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
3288     ;;
3289   *)
3290     AC_MSG_RESULT(no)
3291     ;;
3292   esac ],
3293   AC_MSG_RESULT(no)
3296 #################################################
3297 # check for syslog logging
3298 AC_MSG_CHECKING(whether to use syslog logging)
3299 AC_ARG_WITH(syslog,
3300 [  --with-syslog           Include experimental SYSLOG support (default=no)],
3301 [ case "$withval" in
3302   yes)
3303     AC_MSG_RESULT(yes)
3304     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
3305     ;;
3306   *)
3307     AC_MSG_RESULT(no)
3308     ;;
3309   esac ],
3310   AC_MSG_RESULT(no)
3313 #################################################
3314 # check for a shared memory profiling support
3315 AC_MSG_CHECKING(whether to use profiling)
3316 AC_ARG_WITH(profiling-data,
3317 [  --with-profiling-data   Include gathering source code profile information (default=no)],
3318 [ case "$withval" in
3319   yes)
3320     AC_MSG_RESULT(yes)
3321     AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
3322     ;;
3323   *)
3324     AC_MSG_RESULT(no)
3325     ;;
3326   esac ],
3327   AC_MSG_RESULT(no)
3331 #################################################
3332 # check for experimental disk-quotas support
3334 samba_cv_WITH_QUOTAS=auto
3335 samba_cv_TRY_QUOTAS=no
3336 samba_cv_RUN_QUOTA_TESTS=auto
3337 samba_cv_WITH_SYS_QUOTAS=auto
3338 samba_cv_TRY_SYS_QUOTAS=no
3339 samba_cv_SYSQUOTA_FOUND=no;
3341 AC_MSG_CHECKING(whether to try disk-quotas support)
3342 AC_ARG_WITH(quotas,
3343 [  --with-quotas           Include disk-quota support (default=no)],
3344 [ case "$withval" in
3345   yes)
3346     AC_MSG_RESULT(yes)
3347     samba_cv_WITH_QUOTAS=yes
3348     samba_cv_TRY_QUOTAS=yes
3349     samba_cv_RUN_QUOTA_TESTS=yes
3350     #set sys quotas to auto in this case
3351     samba_cv_TRY_SYS_QUOTAS=auto
3352     ;;
3353   auto)
3354     AC_MSG_RESULT(auto)
3355     samba_cv_WITH_QUOTAS=auto
3356     samba_cv_TRY_QUOTAS=auto
3357     samba_cv_RUN_QUOTA_TESTS=auto
3358     #set sys quotas to auto in this case
3359     samba_cv_TRY_SYS_QUOTAS=auto
3360     ;;
3361   no)
3362     AC_MSG_RESULT(no)
3363     samba_cv_WITH_QUOTAS=no
3364     samba_cv_TRY_QUOTAS=no
3365     samba_cv_RUN_QUOTA_TESTS=no
3366     ;;
3367   *)
3368     AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3369     ;;
3370   esac ],
3371   AC_MSG_RESULT(${samba_cv_TRY_QUOTAS})
3374 AC_MSG_CHECKING(whether to try the new lib/sysquotas.c interface)
3375 AC_ARG_WITH(sys-quotas,
3376 [  --with-sys-quotas       Include lib/sysquotas.c support (default=auto)],
3377 [ case "$withval" in
3378   yes)
3379     AC_MSG_RESULT(yes)
3380     samba_cv_WITH_SYS_QUOTAS=yes
3381     samba_cv_TRY_SYS_QUOTAS=yes
3382     samba_cv_RUN_QUOTA_TESTS=yes
3383     ;;
3384   auto)
3385     AC_MSG_RESULT(auto)
3386     samba_cv_WITH_SYS_QUOTAS=auto
3387     samba_cv_TRY_SYS_QUOTAS=auto
3388     samba_cv_RUN_QUOTA_TESTS=auto
3389     ;;
3390   no)
3391     AC_MSG_RESULT(no)
3392     samba_cv_WITH_SYS_QUOTAS=no
3393     samba_cv_TRY_SYS_QUOTAS=no
3394     ;;
3395   *)
3396     AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3397     ;;
3398   esac ],
3399   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
3402 if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
3403 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
3404   case "$host_os" in
3405         *linux*)
3406             AC_MSG_RESULT(yes)
3407             samba_cv_TRY_SYS_QUOTAS=yes
3408             samba_cv_RUN_QUOTA_TESTS=yes
3409             samba_cv_SYSQUOTA_FOUND=yes
3410             AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
3411             samba_cv_sysquotas_file="lib/sysquotas_linux.c"
3412             AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
3413             samba_cv_found_xfs_header=yes
3414             ;;
3415         *)
3416             AC_MSG_RESULT(no)
3417             samba_cv_TRY_SYS_QUOTAS=no
3418             ;;
3419   esac
3422 #############################################
3423 # only check for quota stuff if --with-quotas
3424 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
3426 # some broken header files need this
3427 AC_CHECK_HEADER(asm/types.h,[
3428             AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
3429             AC_ADD_INCLUDE(<asm/types.h>)
3430             ])
3432 # For quotas on Veritas VxFS filesystems
3433 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
3435 # For sys/quota.h and linux/quota.h
3436 AC_CHECK_HEADERS(sys/quota.h)
3438 if test x"$samba_cv_found_xfs_header" != x"yes"; then
3439 # if we have xfs quota support <sys/quota.h> (IRIX) we should use it
3440 AC_CACHE_CHECK([for XFS QUOTA in <sys/quota.h>],samba_cv_HAVE_SYS_QUOTA_XFS, [
3441 AC_TRY_COMPILE([
3442 #include "confdefs.h"
3443 #ifdef HAVE_SYS_TYPES_H
3444 #include <sys/types.h>
3445 #endif
3446 #ifdef HAVE_ASM_TYPES_H
3447 #include <asm/types.h>
3448 #endif
3449 #include <sys/quota.h>
3450 ],[int i = Q_XGETQUOTA;],
3451 samba_cv_HAVE_SYS_QUOTA_XFS=yes,samba_cv_HAVE_SYS_QUOTA_XFS=no)])
3452 if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
3453         samba_cv_found_xfs_header=yes
3457 # if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
3458 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
3459 AC_TRY_COMPILE([
3460 #include "confdefs.h"
3461 #ifdef HAVE_SYS_QUOTA_H
3462 #include <sys/quota.h>
3463 #endif
3465 struct dqblk D;
3466 D.dqb_fsoftlimit = 0;],
3467 samba_cv_HAVE_DQB_FSOFTLIMIT=yes,samba_cv_HAVE_DQB_FSOFTLIMIT=no)])
3468 if test "$samba_cv_HAVE_DQB_FSOFTLIMIT"x = "yes"x; then
3469         AC_DEFINE(HAVE_DQB_FSOFTLIMIT,1,[struct dqblk .dqb_fsoftlimit])
3472 ##################
3473 # look for a working quota system
3475 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3476 AC_CACHE_CHECK([for long quotactl(int cmd, char *special, qid_t id, caddr_t addr)],samba_cv_HAVE_QUOTACTL_4A,[
3477 AC_TRY_RUN_STRICT([
3478 #define HAVE_QUOTACTL_4A 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_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
3483 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
3484     samba_cv_SYSQUOTA_FOUND=yes;
3485     AC_DEFINE(HAVE_QUOTACTL_4A,1,[Whether long quotactl(int cmd, char *special, qid_t id, caddr_t addr) is available])
3486     samba_cv_sysquotas_file="lib/sysquotas_4A.c"
3490 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3491 AC_CACHE_CHECK([for int quotactl(const char *path, int cmd, int id, char *addr)],samba_cv_HAVE_QUOTACTL_4B,[
3492 AC_TRY_RUN_STRICT([
3493 #define HAVE_QUOTACTL_4B 1
3494 #define AUTOCONF_TEST 1
3495 #include "confdefs.h"
3496 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3497            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
3498 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
3499     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
3500     samba_cv_SYSQUOTA_FOUND=yes;
3501     AC_DEFINE(HAVE_QUOTACTL_4B,1,[Whether int quotactl(const char *path, int cmd, int id, char *addr) is available])
3502     samba_cv_sysquotas_file="lib/sysquotas_4B.c"
3506 if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3507 AC_CACHE_CHECK([for CRAY int quotactl (char *spec, int request, char *arg)],samba_cv_HAVE_QUOTACTL_3,[
3508 AC_TRY_RUN_STRICT([
3509 #define HAVE_QUOTACTL_3 1
3510 #define AUTOCONF_TEST 1
3511 #include "confdefs.h"
3512 #include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
3513            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
3514 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
3515     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
3516     samba_cv_SYSQUOTA_FOUND=yes;
3517     AC_DEFINE(HAVE_QUOTACTL_3,1,[Whether CRAY int quotactl (char *spec, int request, char *arg); is available])
3518     samba_cv_sysquotas_file="lib/sysquotas_3.c"
3522 #################################################
3523 # check for mntent.h and struct mntent
3524 AC_CHECK_HEADERS(mntent.h)
3525 #################################################
3526 # check for setmntent,getmntent,endmntent
3527 AC_CHECK_FUNCS(setmntent getmntent endmntent)
3529 #################################################
3530 # check for devnm.h and struct mntent
3531 AC_CHECK_HEADERS(devnm.h)
3532 #################################################
3533 # check for devnm
3534 AC_CHECK_FUNCS(devnm)
3536 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
3537     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
3538         # if --with-sys-quotas=yes then build it 
3539         # you have can use the get/set quota command smb.conf
3540         # options then
3541         samba_cv_SYSQUOTA_FOUND=auto
3542     fi
3543     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
3544         # if --with-sys-quotas=yes then build it 
3545         # you have can use the get/set quota command smb.conf
3546         # options then
3547         samba_cv_TRY_SYS_QUOTAS=auto
3548     fi
3551 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
3552 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
3553 SAVE_CPPFLAGS="$CPPFLAGS"
3554 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
3555 AC_TRY_COMPILE([
3556 #include "confdefs.h"
3557 #define NO_PROTO_H 1
3558 #define NO_CONFIG_H 1
3559 #define HAVE_SYS_QUOTAS 1
3560 #include "${srcdir-.}/${samba_cv_sysquotas_file}"
3561 #include "${srcdir-.}/lib/sysquotas.c"
3562 ],[],samba_cv_SYSQUOTA_WORKS=yes,samba_cv_SYSQUOTA_WORKS=no)
3563 CPPFLAGS="$SAVE_CPPFLAGS"
3565 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
3566 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
3567     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
3568         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3569         AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
3570         samba_cv_WE_USE_SYS_QUOTAS=yes
3571         AC_MSG_RESULT(yes)
3572     else
3573         AC_MSG_RESULT(no)
3574     fi
3578 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
3579 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
3580 SAVE_CPPFLAGS="$CPPFLAGS"
3581 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
3582 AC_TRY_COMPILE([
3583 #include "confdefs.h"
3584 #define NO_PROTO_H 1
3585 #define NO_CONFIG_H 1
3586 #define HAVE_SYS_QUOTAS 1
3587 #define HAVE_XFS_QUOTAS 1
3588 #include "${srcdir-.}/lib/sysquotas_xfs.c"
3589 ],[],samba_cv_SYSQUOTA_WORKS_XFS=yes,samba_cv_SYSQUOTA_WORKS_XFS=no)
3590 CPPFLAGS="$SAVE_CPPFLAGS"
3592 if test x"$samba_cv_SYSQUOTA_WORKS_XFS" = x"yes"; then
3593     if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
3594         AC_DEFINE(HAVE_XFS_QUOTAS,1,[Whether xfs quota support is available])
3595     fi
3599 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
3600 SAVE_CPPFLAGS="$CPPFLAGS"
3601 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
3602 AC_TRY_COMPILE([
3603 #include "confdefs.h"
3604 #define NO_PROTO_H 1
3605 #define NO_CONFIG_H 1
3606 #include "${srcdir-.}/smbd/quotas.c"
3607 ],[],samba_cv_QUOTA_WORKS=yes,samba_cv_QUOTA_WORKS=no)
3608 CPPFLAGS="$SAVE_CPPFLAGS"
3610 if test x"$samba_cv_QUOTA_WORKS" = x"yes"; then
3611 AC_MSG_CHECKING(whether to use the old quota support)
3612     if test x"$samba_cv_WE_USE_SYS_QUOTAS" != x"yes"; then
3613       if test x"$samba_cv_TRY_QUOTAS" != x"no"; then
3614         AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
3615         AC_MSG_RESULT(yes)
3616       else
3617         AC_MSG_RESULT(no)
3618       fi
3619     else
3620       AC_MSG_RESULT(no)
3621     fi
3624 ####################
3625 # End of quota check samba_cv_RUN_QUOTA_TESTS
3628 #################################################
3629 # check for experimental utmp accounting
3631 AC_MSG_CHECKING(whether to support utmp accounting)
3632 WITH_UTMP=yes
3633 AC_ARG_WITH(utmp,
3634 [  --with-utmp             Include utmp accounting (default, if supported by OS)],
3635 [ case "$withval" in
3636   no)
3637                 WITH_UTMP=no
3638                 ;;
3639   *)
3640                 WITH_UTMP=yes
3641                 ;;
3642   esac ],
3645 # utmp requires utmp.h
3646 # Note similar check earlier, when checking utmp details.
3648 if test x"$WITH_UTMP" = x"yes" -a x"$ac_cv_header_utmp_h" = x"no"; then
3649         utmp_no_reason=", no utmp.h on $host_os"
3650         WITH_UTMP=no
3653 # Display test results
3655 if test x"$WITH_UTMP" = x"yes"; then
3656         AC_MSG_RESULT(yes)
3657         AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
3658 else
3659         AC_MSG_RESULT(no$utmp_no_reason)
3662 #################################################
3663 # should we build libsmbclient?
3665 INSTALLCLIENTCMD_SH=:
3666 INSTALLCLIENTCMD_A=:
3667 INSTALLCLIENT=
3668 LIBSMBCLIENT_SHARED=
3669 LIBSMBCLIENT=
3670 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
3671 AC_ARG_WITH(libsmbclient,
3672 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
3673 [ case "$withval" in
3674   no) 
3675      AC_MSG_RESULT(no)
3676      ;;
3677   *)
3678      if test $BLDSHARED = true; then
3679         INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3680         ## build the static version of libsmbclient as well
3681         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3682         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3683         LIBSMBCLIENT=libsmbclient
3684         AC_MSG_RESULT(yes)
3685      else
3686         enable_static=yes
3687         AC_MSG_RESULT(no shared library support -- will supply static library)
3688      fi
3689      if test $enable_static = yes; then
3690         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3691         LIBSMBCLIENT=libsmbclient
3692      fi
3693      INSTALLCLIENT=installclientlib
3694      ;;
3695   esac ],
3697 # if unspecified, default is to built it iff possible.
3698   if test $BLDSHARED = true; then
3699      INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
3700      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
3701      LIBSMBCLIENT=libsmbclient
3702      AC_MSG_RESULT(yes)
3703    else
3704      enable_static=yes
3705      AC_MSG_RESULT(no shared library support -- will supply static library)
3706    fi
3707    if test $enable_static = yes; then
3708      INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
3709      LIBSMBCLIENT=libsmbclient
3710   fi]
3711   INSTALLCLIENT=installclientlib
3715 #################################################
3716 # these tests are taken from the GNU fileutils package
3717 AC_CHECKING(how to get filesystem space usage)
3718 space=no
3720 # Test for statvfs64.
3721 if test $space = no; then
3722   # SVR4
3723   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
3724   [AC_TRY_RUN([
3725 #if defined(HAVE_UNISTD_H)
3726 #include <unistd.h>
3727 #endif
3728 #include <sys/types.h>
3729 #include <sys/statvfs.h>
3730   main ()
3731   {
3732     struct statvfs64 fsd;
3733     exit (statvfs64 (".", &fsd));
3734   }],
3735   fu_cv_sys_stat_statvfs64=yes,
3736   fu_cv_sys_stat_statvfs64=no,
3737   fu_cv_sys_stat_statvfs64=cross)])
3738   if test $fu_cv_sys_stat_statvfs64 = yes; then
3739     space=yes
3740     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
3741   fi
3744 # Perform only the link test since it seems there are no variants of the
3745 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
3746 # because that got a false positive on SCO OSR5.  Adding the declaration
3747 # of a `struct statvfs' causes this test to fail (as it should) on such
3748 # systems.  That system is reported to work fine with STAT_STATFS4 which
3749 # is what it gets when this test fails.
3750 if test $space = no; then
3751   # SVR4
3752   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
3753                  [AC_TRY_LINK([#include <sys/types.h>
3754 #include <sys/statvfs.h>],
3755                               [struct statvfs fsd; statvfs (0, &fsd);],
3756                               fu_cv_sys_stat_statvfs=yes,
3757                               fu_cv_sys_stat_statvfs=no)])
3758   if test $fu_cv_sys_stat_statvfs = yes; then
3759     space=yes
3760     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
3761   fi
3764 if test $space = no; then
3765   # DEC Alpha running OSF/1
3766   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
3767   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
3768   [AC_TRY_RUN([
3769 #include <sys/param.h>
3770 #include <sys/types.h>
3771 #include <sys/mount.h>
3772   main ()
3773   {
3774     struct statfs fsd;
3775     fsd.f_fsize = 0;
3776     exit (statfs (".", &fsd, sizeof (struct statfs)));
3777   }],
3778   fu_cv_sys_stat_statfs3_osf1=yes,
3779   fu_cv_sys_stat_statfs3_osf1=no,
3780   fu_cv_sys_stat_statfs3_osf1=no)])
3781   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
3782   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
3783     space=yes
3784     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
3785   fi
3788 if test $space = no; then
3789 # AIX
3790   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
3791 member (AIX, 4.3BSD)])
3792   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
3793   [AC_TRY_RUN([
3794 #ifdef HAVE_SYS_PARAM_H
3795 #include <sys/param.h>
3796 #endif
3797 #ifdef HAVE_SYS_MOUNT_H
3798 #include <sys/mount.h>
3799 #endif
3800 #ifdef HAVE_SYS_VFS_H
3801 #include <sys/vfs.h>
3802 #endif
3803   main ()
3804   {
3805   struct statfs fsd;
3806   fsd.f_bsize = 0;
3807   exit (statfs (".", &fsd));
3808   }],
3809   fu_cv_sys_stat_statfs2_bsize=yes,
3810   fu_cv_sys_stat_statfs2_bsize=no,
3811   fu_cv_sys_stat_statfs2_bsize=no)])
3812   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
3813   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
3814     space=yes
3815     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
3816   fi
3819 if test $space = no; then
3820 # SVR3
3821   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
3822   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
3823   [AC_TRY_RUN([#include <sys/types.h>
3824 #include <sys/statfs.h>
3825   main ()
3826   {
3827   struct statfs fsd;
3828   exit (statfs (".", &fsd, sizeof fsd, 0));
3829   }],
3830     fu_cv_sys_stat_statfs4=yes,
3831     fu_cv_sys_stat_statfs4=no,
3832     fu_cv_sys_stat_statfs4=no)])
3833   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
3834   if test $fu_cv_sys_stat_statfs4 = yes; then
3835     space=yes
3836     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
3837   fi
3840 if test $space = no; then
3841 # 4.4BSD and NetBSD
3842   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
3843 member (4.4BSD and NetBSD)])
3844   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
3845   [AC_TRY_RUN([#include <sys/types.h>
3846 #ifdef HAVE_SYS_PARAM_H
3847 #include <sys/param.h>
3848 #endif
3849 #ifdef HAVE_SYS_MOUNT_H
3850 #include <sys/mount.h>
3851 #endif
3852   main ()
3853   {
3854   struct statfs fsd;
3855   fsd.f_fsize = 0;
3856   exit (statfs (".", &fsd));
3857   }],
3858   fu_cv_sys_stat_statfs2_fsize=yes,
3859   fu_cv_sys_stat_statfs2_fsize=no,
3860   fu_cv_sys_stat_statfs2_fsize=no)])
3861   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
3862   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
3863     space=yes
3864         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
3865   fi
3868 if test $space = no; then
3869   # Ultrix
3870   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
3871   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
3872   [AC_TRY_RUN([#include <sys/types.h>
3873 #ifdef HAVE_SYS_PARAM_H
3874 #include <sys/param.h>
3875 #endif
3876 #ifdef HAVE_SYS_MOUNT_H
3877 #include <sys/mount.h>
3878 #endif
3879 #ifdef HAVE_SYS_FS_TYPES_H
3880 #include <sys/fs_types.h>
3881 #endif
3882   main ()
3883   {
3884   struct fs_data fsd;
3885   /* Ultrix's statfs returns 1 for success,
3886      0 for not mounted, -1 for failure.  */
3887   exit (statfs (".", &fsd) != 1);
3888   }],
3889   fu_cv_sys_stat_fs_data=yes,
3890   fu_cv_sys_stat_fs_data=no,
3891   fu_cv_sys_stat_fs_data=no)])
3892   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
3893   if test $fu_cv_sys_stat_fs_data = yes; then
3894     space=yes
3895     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
3896   fi
3900 # As a gating factor for large file support, in order to
3901 # use <4GB files we must have the following minimal support
3902 # available.
3903 # long long, and a 64 bit off_t or off64_t.
3904 # If we don't have all of these then disable large
3905 # file support.
3907 AC_MSG_CHECKING([if large file support can be enabled])
3908 AC_TRY_COMPILE([
3909 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
3910 #include <sys/types.h>
3911 #else
3912 __COMPILE_ERROR_
3913 #endif
3915 [int i],
3916 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
3917 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
3918         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
3920 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
3922 AC_ARG_WITH(spinlocks, 
3923 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
3924 if test "x$with_spinlocks" = "xyes"; then
3925     AC_DEFINE(USE_SPINLOCKS,1,[Whether to use spin locks instead of fcntl locks])
3927     case "$host_cpu" in
3928         sparc)
3929             AC_DEFINE(SPARC_SPINLOCKS,1,[Whether to use sparc spinlocks])
3930             ;;
3932         i386|i486|i586|i686)
3933             AC_DEFINE(INTEL_SPINLOCKS,1,[Whether to use intel spinlocks])
3934             ;;
3936         mips)
3937             AC_DEFINE(MIPS_SPINLOCKS,1,[Whether to use mips spinlocks])
3938             ;;
3940         powerpc)
3941             AC_DEFINE(POWERPC_SPINLOCKS,1,[Whether to use powerpc spinlocks])
3942             ;;
3943     esac
3946 #################################################
3947 # check for ACL support
3949 AC_MSG_CHECKING(whether to support ACLs)
3950 AC_ARG_WITH(acl-support,
3951 [  --with-acl-support      Include ACL support (default=no)],
3952 [ case "$withval" in
3953   yes)
3955         case "$host_os" in
3956         *sysv5*)
3957                 AC_MSG_RESULT(Using UnixWare ACLs)
3958                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
3959                 ;;
3960         *solaris*)
3961                 AC_MSG_RESULT(Using solaris ACLs)
3962                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
3963                 ;;
3964         *hpux*)
3965                 AC_MSG_RESULT(Using HPUX ACLs)
3966                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
3967                 ;;
3968         *irix*)
3969                 AC_MSG_RESULT(Using IRIX ACLs)
3970                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
3971                 ;;
3972         *aix*)
3973                 AC_MSG_RESULT(Using AIX ACLs)
3974                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
3975                 ;;
3976         *osf*)
3977                 AC_MSG_RESULT(Using Tru64 ACLs)
3978                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
3979                 ACL_LIBS="$ACL_LIBS -lpacl"
3980                 ;;
3981         *freebsd5*|*freebsd6*)
3982                 AC_MSG_RESULT(Using FreeBSD posix ACLs)
3983                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
3984                 AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
3985                 ;;
3986         *linux*)
3987                 AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
3988                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
3989                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
3990                 acl_LIBS=$LIBS
3991                 LIBS="$LIBS -lacl"
3992                 AC_TRY_LINK([#include <sys/types.h>
3993 #include <sys/acl.h>],
3994 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
3995 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
3996                 LIBS=$acl_LIBS])
3997                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
3998                                 AC_MSG_RESULT(Using posix ACLs)
3999                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4000                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4001                                 acl_LIBS=$LIBS
4002                                 LIBS="$LIBS -lacl"
4003                                 AC_TRY_LINK([#include <sys/types.h>
4004 #include <sys/acl.h>],
4005 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4006 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4007                                 LIBS=$acl_LIBS])
4008                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4009                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4010                                 fi
4011                         fi
4012             ;;
4013          *)
4014                 AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
4015                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
4016                 acl_LIBS=$LIBS
4017                 LIBS="$LIBS -lacl"
4018                 AC_TRY_LINK([#include <sys/types.h>
4019 #include <sys/acl.h>],
4020 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
4021 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
4022                 LIBS=$acl_LIBS])
4023                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
4024                                 AC_MSG_RESULT(Using posix ACLs)
4025                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
4026                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
4027                                 acl_LIBS=$LIBS
4028                                 LIBS="$LIBS -lacl"
4029                                 AC_TRY_LINK([#include <sys/types.h>
4030 #include <sys/acl.h>],
4031 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
4032 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
4033                                 LIBS=$acl_LIBS])
4034                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
4035                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
4036                                 fi
4037                         fi
4038             ;;
4039         esac
4040         ;;
4041   *)
4042     AC_MSG_RESULT(no)
4043     AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
4044     ;;
4045   esac ],
4046   AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
4047   AC_MSG_RESULT(no)
4050 #################################################
4051 # check for sendfile support
4053 with_sendfile_support=yes
4054 AC_MSG_CHECKING(whether to check to support sendfile)
4055 AC_ARG_WITH(sendfile-support,
4056 [  --with-sendfile-support Check for sendfile support (default=yes)],
4057 [ case "$withval" in
4058   yes)
4060         AC_MSG_RESULT(yes);
4062         case "$host_os" in
4063         *linux*)
4064                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4065                 AC_TRY_LINK([#include <sys/sendfile.h>],
4067 int tofd, fromfd;
4068 off64_t offset;
4069 size_t total;
4070 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
4072 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4074                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
4075                 AC_TRY_LINK([#include <sys/sendfile.h>],
4077 int tofd, fromfd;
4078 off_t offset;
4079 size_t total;
4080 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4082 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4084 # Try and cope with broken Linux sendfile....
4085                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
4086                 AC_TRY_LINK([\
4087 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
4088 #undef _FILE_OFFSET_BITS
4089 #endif
4090 #include <sys/sendfile.h>],
4092 int tofd, fromfd;
4093 off_t offset;
4094 size_t total;
4095 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
4097 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
4099         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
4100                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
4101                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
4102                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
4103         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4104                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4105                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
4106                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
4107         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
4108                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
4109                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
4110         else
4111                 AC_MSG_RESULT(no);
4112         fi
4114         ;;
4115         *freebsd* | *DragonFly* )
4116                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
4117                 AC_TRY_LINK([\
4118 #include <sys/types.h>
4119 #include <unistd.h>
4120 #include <sys/socket.h>
4121 #include <sys/uio.h>],
4123         int fromfd, tofd, ret, total=0;
4124         off_t offset, nwritten;
4125         struct sf_hdtr hdr;
4126         struct iovec hdtrl;
4127         hdr.headers = &hdtrl;
4128         hdr.hdr_cnt = 1;
4129         hdr.trailers = NULL;
4130         hdr.trl_cnt = 0;
4131         hdtrl.iov_base = NULL;
4132         hdtrl.iov_len = 0;
4133         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
4135 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4137         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4138                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
4139                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
4140                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4141         else
4142                 AC_MSG_RESULT(no);
4143         fi
4144         ;;
4146         *hpux*)
4147                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
4148                 AC_TRY_LINK([\
4149 #include <sys/socket.h>
4150 #include <sys/uio.h>],
4152         int fromfd, tofd;
4153         size_t total=0;
4154         struct iovec hdtrl[2];
4155         ssize_t nwritten;
4156         off64_t offset;
4158         hdtrl[0].iov_base = 0;
4159         hdtrl[0].iov_len = 0;
4161         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
4163 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
4164         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
4165                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
4166                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
4167                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4168         else
4169                 AC_MSG_RESULT(no);
4170         fi
4172                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
4173                 AC_TRY_LINK([\
4174 #include <sys/socket.h>
4175 #include <sys/uio.h>],
4177         int fromfd, tofd;
4178         size_t total=0;
4179         struct iovec hdtrl[2];
4180         ssize_t nwritten;
4181         off_t offset;
4183         hdtrl[0].iov_base = 0;
4184         hdtrl[0].iov_len = 0;
4186         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
4188 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4189         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4190                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4191                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
4192                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4193         else
4194                 AC_MSG_RESULT(no);
4195         fi
4196         ;;
4198         *solaris*)
4199                 AC_CHECK_LIB(sendfile,sendfilev)
4200                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
4201                 AC_TRY_LINK([\
4202 #include <sys/sendfile.h>],
4204         int sfvcnt;
4205         size_t xferred;
4206         struct sendfilevec vec[2];
4207         ssize_t nwritten;
4208         int tofd;
4210         sfvcnt = 2;
4212         vec[0].sfv_fd = SFV_FD_SELF;
4213         vec[0].sfv_flag = 0;
4214         vec[0].sfv_off = 0;
4215         vec[0].sfv_len = 0;
4217         vec[1].sfv_fd = 0;
4218         vec[1].sfv_flag = 0;
4219         vec[1].sfv_off = 0;
4220         vec[1].sfv_len = 0;
4221         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
4223 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
4225         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
4226                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
4227                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
4228                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
4229         else
4230                 AC_MSG_RESULT(no);
4231         fi
4233                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
4234                 AC_TRY_LINK([\
4235 #include <sys/sendfile.h>],
4237         int sfvcnt;
4238         size_t xferred;
4239         struct sendfilevec vec[2];
4240         ssize_t nwritten;
4241         int tofd;
4243         sfvcnt = 2;
4245         vec[0].sfv_fd = SFV_FD_SELF;
4246         vec[0].sfv_flag = 0;
4247         vec[0].sfv_off = 0;
4248         vec[0].sfv_len = 0;
4250         vec[1].sfv_fd = 0;
4251         vec[1].sfv_flag = 0;
4252         vec[1].sfv_off = 0;
4253         vec[1].sfv_len = 0;
4254         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
4256 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
4258         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
4259                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
4260                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
4261                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
4262         else
4263                 AC_MSG_RESULT(no);
4264         fi
4265         ;;
4266         *aix*)
4267                 AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
4268                 AC_TRY_LINK([\
4269 #include <sys/socket.h>],
4271         int fromfd, tofd;
4272         size_t total=0;
4273         struct sf_parms hdtrl;
4274         ssize_t nwritten;
4275         off64_t offset;
4277         hdtrl.header_data = 0;
4278         hdtrl.header_length = 0;
4279         hdtrl.file_descriptor = fromfd;
4280         hdtrl.file_offset = 0;
4281         hdtrl.file_bytes = 0;
4282         hdtrl.trailer_data = 0;
4283         hdtrl.trailer_length = 0;
4285         nwritten = send_file(&tofd, &hdtrl, 0);
4287 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
4288         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
4289                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
4290                 AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
4291                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
4292         else
4293                 AC_MSG_RESULT(no);
4294         fi
4295         ;;
4296         *)
4297         ;;
4298         esac
4299         ;;
4300   *)
4301     AC_MSG_RESULT(no)
4302     ;;
4303   esac ],
4304   AC_MSG_RESULT(yes)
4308 #################################################
4309 # Check whether winbind is supported on this platform.  If so we need to
4310 # build and install client programs, sbin programs and shared libraries
4312 AC_MSG_CHECKING(whether to build winbind)
4314 # Initially, the value of $host_os decides whether winbind is supported
4316 HAVE_WINBIND=yes
4318 # Define the winbind shared library name and any specific linker flags
4319 # it needs to be built with.
4321 WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
4322 WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
4323 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
4325 case "$host_os" in
4326         *linux*)
4327                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
4328                 ;;
4329         *freebsd5*|*freebsd6*)
4330                 # FreeBSD winbind client is implemented as a wrapper around
4331                 # the Linux version.
4332                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
4333                     nsswitch/winbind_nss_linux.o"
4334                 WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
4335                 WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
4336                 ;;
4337         *irix*)
4338                 # IRIX has differently named shared libraries
4339                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
4340                 WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
4341                 WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
4342                 ;;
4343         *solaris*)
4344                 # Solaris winbind client is implemented as a wrapper around
4345                 # the Linux version.
4346                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
4347                     nsswitch/winbind_nss_linux.o"
4348                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
4349                 ;;
4350         *hpux11*)
4351                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
4352                 ;;
4353         *aix*)
4354                 # AIX has even differently named shared libraries.  No
4355                 # WINS support has been implemented yet.
4356                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
4357                 WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
4358                 WINBIND_NSS="nsswitch/WINBIND"
4359                 WINBIND_WINS_NSS=""
4360                 ;;
4361         *)
4362                 HAVE_WINBIND=no
4363                 winbind_no_reason=", unsupported on $host_os"
4364                 ;;
4365 esac
4367 AC_SUBST(WINBIND_NSS)
4368 AC_SUBST(WINBIND_WINS_NSS)
4369 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
4370 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
4371 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
4373 # Check the setting of --with-winbind
4375 AC_ARG_WITH(winbind,
4376 [  --with-winbind          Build winbind (default, if supported by OS)],
4378   case "$withval" in
4379         yes)
4380                 HAVE_WINBIND=yes
4381                 ;;
4382         no)
4383                 HAVE_WINBIND=no
4384                 winbind_reason=""
4385                 ;;
4386   esac ],
4389 # We need unix domain sockets for winbind
4391 if test x"$HAVE_WINBIND" = x"yes"; then
4392         if test x"$samba_cv_unixsocket" = x"no"; then
4393                 winbind_no_reason=", no unix domain socket support on $host_os"
4394                 HAVE_WINBIND=no
4395         fi
4398 # Display test results
4400 if test x"$HAVE_WINBIND" = x"yes"; then
4401         AC_MSG_RESULT(yes)
4402         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
4404         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
4405         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
4406         if test $BLDSHARED = true; then
4407                 SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
4409                 if test x"$with_pam" = x"yes"; then
4410                         SHLIB_PROGS="$SHLIB_PROGS nsswitch/pam_winbind.$SHLIBEXT"
4411                 fi
4412         fi
4413 else
4414         AC_MSG_RESULT(no$winbind_no_reason)
4417 # Solaris has some extra fields in struct passwd that need to be
4418 # initialised otherwise nscd crashes.  
4420 AC_CHECK_MEMBER(struct passwd.pw_comment,
4421                 AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
4422                 [#include <pwd.h>])
4424 AC_CHECK_MEMBER(struct passwd.pw_age,
4425                 AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
4426                 [#include <pwd.h>])
4428 # AIX 4.3.x and 5.1 do not have as many members in
4429 # struct secmethod_table as AIX 5.2
4430 AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
4431        [#include <usersec.h>])
4432 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
4433        [#include <usersec.h>])
4436 #################################################
4437 # Check to see if we should use the included popt 
4439 AC_ARG_WITH(included-popt,
4440 [  --with-included-popt    use bundled popt library, not from system],
4442   case "$withval" in
4443         yes)
4444                 INCLUDED_POPT=yes
4445                 ;;
4446         no)
4447                 INCLUDED_POPT=no
4448                 ;;
4449   esac ],
4451 if test x"$INCLUDED_POPT" != x"yes"; then
4452     AC_CHECK_LIB(popt, poptGetContext,
4453                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
4456 AC_MSG_CHECKING(whether to use included popt)
4457 if test x"$INCLUDED_POPT" = x"yes"; then
4458     AC_MSG_RESULT(yes)
4459     BUILD_POPT='$(POPT_OBJS)'
4460         POPTLIBS='$(POPT_OBJS)'
4461     FLAGS1="-I$srcdir/popt"
4462 else
4463     AC_MSG_RESULT(no)
4464         BUILD_POPT=""
4465     POPTLIBS="-lpopt"
4467 AC_SUBST(BUILD_POPT)
4468 AC_SUBST(POPTLIBS)
4469 AC_SUBST(FLAGS1)
4471 #################################################
4472 # Check if the user wants Python
4474 # At the moment, you can use this to set which Python binary to link
4475 # against.  (Libraries built for Python2.2 can't be used by 2.1,
4476 # though they can coexist in different directories.)  In the future
4477 # this might make the Python stuff be built by default.
4479 # Defaulting python breaks the clean target if python isn't installed
4481 PYTHON=
4483 AC_ARG_WITH(python,
4484 [  --with-python=PYTHONNAME  build Python libraries],
4485 [ case "${withval-python}" in
4486   yes)
4487         PYTHON=python
4488         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
4489         ;;
4490   no)
4491         PYTHON=
4492         ;;
4493   *)
4494         PYTHON=${withval-python}
4495         ;;
4496   esac ])
4497 AC_SUBST(PYTHON)
4499 for i in `echo $default_static_modules | sed -e's/,/ /g'`
4501         eval MODULE_DEFAULT_$i=STATIC
4502 done
4504 for i in `echo $default_shared_modules | sed -e's/,/ /g'`
4506         dnl Fall back to static if we cannot build shared libraries
4507         eval MODULE_DEFAULT_$i=STATIC
4509         if test $BLDSHARED = true; then
4510                 eval MODULE_DEFAULT_$i=SHARED
4511         fi
4512 done
4514 dnl Always built these modules static
4515 MODULE_pdb_guest=STATIC
4516 MODULE_rpc_spoolss=STATIC
4517 MODULE_rpc_srv=STATIC
4518 MODULE_idmap_tdb=STATIC
4520 AC_ARG_WITH(static-modules,
4521 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
4522 [ if test $withval; then
4523         for i in `echo $withval | sed -e's/,/ /g'`
4524         do
4525                 eval MODULE_$i=STATIC
4526         done
4527 fi ])
4529 AC_ARG_WITH(shared-modules,
4530 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
4531 [ if test $withval; then
4532         for i in `echo $withval | sed -e's/,/ /g'`
4533         do
4534                         eval MODULE_$i=SHARED
4535         done
4536 fi ])
4538 ###########################################################################
4539 ## contributed pdb_modules
4541 SMB_MODULE(pdb_xml, passdb/pdb_xml.o, "bin/xml.$SHLIBEXT", PDB,
4542                   [ PASSDB_LIBS="$PASSDB_LIBS $XML_LIBS" ] )
4543 SMB_MODULE(pdb_mysql, passdb/pdb_mysql.o, "bin/mysql.$SHLIBEXT", PDB, 
4544                    [ PASSDB_LIBS="$PASSDB_LIBS $MYSQL_LIBS" ]   )
4545 SMB_MODULE(pdb_pgsql, passdb/pdb_pgsql.o, "bin/pgsql.$SHLIBEXT", PDB, 
4546                    [ PASSDB_LIBS="$PASSDB_LIBS $PGSQL_LIBS" ]   )
4548 ## end of contributed pdb_modules
4549 ###########################################################################
4551 SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB, 
4552                    [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
4553 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
4554 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
4555 SMB_MODULE(pdb_guest, passdb/pdb_guest.o, "bin/guest.$SHLIBEXT", PDB)
4556 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
4558 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
4559 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
4560 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
4561 SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
4562 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
4563 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
4564 SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
4565 SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
4566 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
4567 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
4568 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
4569 SMB_MODULE(rpc_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
4570 SMB_SUBSYSTEM(RPC,smbd/server.o)
4572 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/idmap_ldap.$SHLIBEXT", IDMAP)
4573 SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/idmap_tdb.$SHLIBEXT", IDMAP)
4574 SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/idmap_rid.$SHLIBEXT", IDMAP)
4575 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
4577 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
4578 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
4579 SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
4580 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
4581 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
4583 SMB_MODULE(auth_rhosts, \$(AUTH_RHOSTS_OBJ), "bin/rhosts.$SHLIBEXT", AUTH)
4584 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
4585 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
4586 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
4587 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
4588 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
4589 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
4590 SMB_SUBSYSTEM(AUTH,auth/auth.o)
4592 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
4593 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
4594 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
4595 SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
4596 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
4597 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
4598 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
4599 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
4600 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
4601 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
4602 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
4603 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
4604 SMB_MODULE(vfs_catia, \$(VFS_AFSACL_OBJ), "bin/catia.$SHLIBEXT", VFS)
4605 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
4607 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
4609 #################################################
4610 # do extra things if we are running insure
4612 if test "${ac_cv_prog_CC}" = "insure"; then
4613         CPPFLAGS="$CPPFLAGS -D__INSURE__"
4616 #################################################
4617 # Display summary of libraries detected
4619 AC_MSG_RESULT([Using libraries:])
4620 AC_MSG_RESULT([    LIBS = $LIBS])
4621 if test x"$with_ads_support" != x"no"; then
4622    AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
4624 if test x"$with_ldap_support" != x"no"; then
4625    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
4627 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
4629 #################################################
4630 # final configure stuff
4632 AC_MSG_CHECKING([configure summary])
4633 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
4634            AC_MSG_RESULT(yes),
4635            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
4636            AC_MSG_WARN([cannot run when cross-compiling]))
4638 builddir=`pwd`
4639 AC_SUBST(builddir)
4641 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
4642 LIB_REMOVE_USR_LIB(LDFLAGS)
4643 LIB_REMOVE_USR_LIB(LIBS)
4645 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
4646 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
4647 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
4649 AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh)
4651 #################################################
4652 # Print very concise instructions on building/use
4653 if test "x$enable_dmalloc" = xyes
4654 then
4655         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
4656         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])