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