This commit was generated by cvs2svn to compensate for changes in r30,
[ira/wip.git] / source4 / configure.in
1 dnl -*- mode: m4-mode -*-
2 dnl Process this file with autoconf to produce a configure script.
3
4 dnl We must use autotools 2.53 or above
5 AC_PREREQ(2.53)
6 AC_INIT(include/includes.h)
7 AC_CONFIG_HEADER(include/config.h)
8
9 AC_DISABLE_STATIC
10 AC_ENABLE_SHARED
11
12 #################################################
13 # Directory handling stuff to support both the
14 # legacy SAMBA directories and FHS compliant
15 # ones...
16 AC_PREFIX_DEFAULT(/usr/local/samba)
17
18 AC_ARG_WITH(fhs, 
19 [  --with-fhs              Use FHS-compliant paths (default=no)],
20     configdir="${sysconfdir}/samba"
21     lockdir="\${VARDIR}/cache/samba"
22     piddir="\${VARDIR}/run/samba"
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
36 AC_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
52 AC_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
68 AC_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
84 AC_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
100 AC_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
116 AC_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
130 AC_SUBST(configdir)
131 AC_SUBST(lockdir)
132 AC_SUBST(piddir)
133 AC_SUBST(logfilebase)
134 AC_SUBST(privatedir)
135 AC_SUBST(swatdir)
136 AC_SUBST(bindir)
137 AC_SUBST(sbindir)
138
139 dnl Unique-to-Samba variables we'll be playing with.
140 AC_SUBST(SHELL)
141 AC_SUBST(LDSHFLAGS)
142 AC_SUBST(SONAMEFLAG)
143 AC_SUBST(SHLD)
144 AC_SUBST(HOST_OS)
145 AC_SUBST(PICFLAG)
146 AC_SUBST(PICSUFFIX)
147 AC_SUBST(POBAD_CC)
148 AC_SUBST(SHLIBEXT)
149 AC_SUBST(INSTALLCLIENTCMD_SH)
150 AC_SUBST(INSTALLCLIENTCMD_A)
151 AC_SUBST(LIBSMBCLIENT_SHARED)
152 AC_SUBST(LIBSMBCLIENT)
153 AC_SUBST(PRINTLIBS)
154 AC_SUBST(AUTHLIBS)
155 AC_SUBST(ACLLIBS)
156 AC_SUBST(SHLIB_PROGS)
157 AC_SUBST(SMBWRAPPER)
158 AC_SUBST(EXTRA_BIN_PROGS)
159 AC_SUBST(EXTRA_SBIN_PROGS)
160 AC_SUBST(EXTRA_ALL_TARGETS)
161 dnl For the DYNAMIC RPC stuff
162 dnl The complicated _YES and _NO stuff allows us to avoid a dependency
163 dnl on GNU Make.
164 AC_SUBST(LSA_DYNAMIC_YES)
165 AC_SUBST(LSA_DYNAMIC_NO)
166 LSA_DYNAMIC_YES="#"
167 LSA_DYNAMIC_NO=
168 AC_SUBST(NETLOG_DYNAMIC_YES)
169 AC_SUBST(NETLOG_DYNAMIC_NO)
170 NETLOG_DYNAMIC_YES="#"
171 NETLOG_DYNAMIC_NO=
172 AC_SUBST(SAMR_DYNAMIC_YES)
173 AC_SUBST(SAMR_DYNAMIC_NO)
174 SAMR_DYNAMIC_YES="#"
175 SAMR_DYNAMIC_NO=
176 AC_SUBST(SVC_DYNAMIC_YES)
177 AC_SUBST(SVC_DYNAMIC_NO)
178 SVC_DYNAMIC_YES="#"
179 SVC_DYNAMIC_NO=
180 AC_SUBST(WKS_DYNAMIC_YES)
181 AC_SUBST(WKS_DYNAMIC_NO)
182 WKS_DYNAMIC_YES="#"
183 WKS_DYNAMIC_NO=
184 AC_SUBST(REG_DYNAMIC_YES)
185 AC_SUBST(REG_DYNAMIC_NO)
186 REG_DYNAMIC_YES="#"
187 REG_DYNAMIC_NO=
188 AC_SUBST(SPOOLSS_DYNAMIC_YES)
189 AC_SUBST(SPOOLSS_DYNAMIC_NO)
190 SPOOLSS_DYNAMIC_YES="#"
191 SPOOLSS_DYNAMIC_NO=
192 AC_SUBST(DFS_DYNAMIC_YES)
193 AC_SUBST(DFS_DYNAMIC_NO)
194 DFS_DYNAMIC_YES="#"
195 DFS_DYNAMIC_NO=
196
197 AC_ARG_ENABLE(debug, 
198 [  --enable-debug          Turn on compiler debugging information (default=no)],
199     [if eval "test x$enable_debug = xyes"; then
200         CFLAGS="${CFLAGS} -gstabs"
201     fi])
202
203 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
204     [if eval "test x$enable_developer = xyes"; then
205         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
206     fi])
207
208 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
209     [if eval "test x$enable_krb5developer = xyes"; then
210         CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
211     fi])
212
213 # compile with optimization and without debugging by default
214 if test "x$CFLAGS" = x; then
215    CFLAGS = "-O";
216 fi
217
218 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
219
220 if test "x$enable_dmalloc" = xyes
221 then
222         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
223         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
224                   [Define to check invariants around some common functions])
225         LIBS="$LIBS -ldmalloc"  
226 fi
227
228 AC_ARG_ENABLE(dynrpc,  [  --enable-dynrpc         Enable dynamic RPC modules [default=no]])
229
230 if test x$enable_dynrpc = xyes
231 then
232         enable_dynrpc=lsa,samr,reg,wks,netlog,dfs
233 fi
234
235 if test x$enable_dynrpc != xno
236 then
237         for i in `echo $enable_dynrpc | sed -e's/,/ /g'` 
238          do case $i in lsa)
239           LSA_DYNAMIC_YES=
240           LSA_DYNAMIC_NO="#"
241           AC_DEFINE(RPC_LSA_DYNAMIC, 1,
242                     [Define to make the LSA pipe dynamic])
243          ;; samr)
244           SAMR_DYNAMIC_YES=
245           SAMR_DYNAMIC_NO="#"
246           AC_DEFINE(RPC_SAMR_DYNAMIC, 1, 
247                     [Define to make the SAMR pipe dynamic])
248          ;; svc)
249           SVC_DYNAMIC_YES=
250           SVC_DYNAMIC_NO="#"
251           AC_DEFINE(RPC_SVC_DYNAMIC, 1, 
252                     [Define to make the SRVSVC pipe dynamic])
253          ;; wks)
254           WKS_DYNAMIC_YES=
255           WKS_DYNAMIC_NO="#"
256           AC_DEFINE(RPC_WKS_DYNAMIC, 1, 
257                     [Define to make the WKSSVC pipe dynamic])
258          ;; netlog)
259           NETLOG_DYNAMIC_YES=
260           NETLOG_DYNAMIC_NO="#"
261           AC_DEFINE(RPC_NETLOG_DYNAMIC, 1, 
262                     [Define to make the NETLOGON pipe dynamic])
263          ;; reg)
264           REG_DYNAMIC_YES=
265           REG_DYNAMIC_NO="#"
266           AC_DEFINE(RPC_REG_DYNAMIC, 1, 
267                     [Define to make the WINREG pipe dynamic])
268          ;; spoolss)
269           SPOOLSS_DYNAMIC_YES=
270           SPOOLSS_DYNAMIC_NO="#"
271           AC_DEFINE(RPC_SPOOLSS_DYNAMIC, 1, 
272                     [Define to make the SPOOLSS pipe dynamic])
273          ;; dfs)
274           DFS_DYNAMIC_YES=
275           DFS_DYNAMIC_NO="#"
276           AC_DEFINE(RPC_DFS_DYNAMIC, 1, 
277                     [Define to make the NETDFS pipe dynamic])
278          ;; esac
279          done
280 fi
281
282 dnl Checks for programs.
283 AC_PROG_CC
284 AC_PROG_INSTALL
285 AC_PROG_AWK
286 AC_PATH_PROG(PERL, perl)
287
288 dnl Check if we use GNU ld
289 LD=ld
290 AC_PROG_LD_GNU
291
292 dnl needed before AC_TRY_COMPILE
293 AC_ISC_POSIX
294
295 dnl look for executable suffix
296 AC_EXEEXT
297
298 dnl Check if C compiler understands -c and -o at the same time
299 AC_PROG_CC_C_O
300 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
301       BROKEN_CC=
302 else
303       BROKEN_CC=#
304 fi
305 AC_SUBST(BROKEN_CC)
306
307 dnl Check if the C compiler understands volatile (it should, being ANSI).
308 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
309     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
310         samba_cv_volatile=yes,samba_cv_volatile=no)])
311 if test x"$samba_cv_volatile" = x"yes"; then
312    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
313 fi
314
315
316 AC_CANONICAL_SYSTEM
317
318 dnl Add #include for broken IRIX header files
319   case "$host_os" in
320         *irix6*) AC_ADD_INCLUDE(<standards.h>)
321         ;;
322 esac
323
324 AC_VALIDATE_CACHE_SYSTEM_TYPE
325
326 DYNEXP=
327
328 #
329 # Config CPPFLAG settings for strange OS's that must be set
330 # before other tests.
331 #
332 case "$host_os" in
333 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
334     *hpux*)
335     
336       AC_PROG_CC_FLAG(Ae)
337       # mmap on HPUX is completely broken...
338       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
339       if test $ac_cv_prog_cc_Ae = yes; then
340         CPPFLAGS="$CPPFLAGS -Ae"
341       fi
342 #
343 # Defines needed for HPUX support.
344 # HPUX has bigcrypt but (sometimes?) doesn't use it for
345 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
346 #
347       case `uname -r` in
348                         *9*|*10*)
349                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
350                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
351                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
352                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
353                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
354                                 AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
355                                 ;;
356                         *11*)
357                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
358                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
359                                 AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
360                                 AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
361                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
362                                 AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
363                                 AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
364                                 ;;
365       esac
366       DYNEXP="-Wl,-E"
367       ;;
368
369 #
370 # CRAY Unicos has broken const handling
371        *unicos*)
372           AC_MSG_RESULT([disabling const])
373           CPPFLAGS="$CPPFLAGS -Dconst="
374           ;;
375         
376 #
377 # AIX4.x doesn't even admit to having large
378 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
379 #
380     *aix4*)
381           AC_MSG_RESULT([enabling large file support])
382       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
383           AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
384       ;;    
385 #
386 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
387 # to the existance of large files..
388 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
389 # recommendations on large file support, however it makes the
390 # compile work using gcc 2.7 and 2.8, whereas using the Sun
391 # recommendation makes the compile fail on gcc2.7. JRA.
392 #
393         *solaris*)
394                 case `uname -r` in
395                         5.0*|5.1*|5.2*|5.3*|5.5*)
396                                 AC_MSG_RESULT([no large file support])
397                                 ;;
398                         5.*)
399                         AC_MSG_RESULT([enabling large file support])
400                         if test "$ac_cv_prog_gcc" = yes; then
401                                 ${CC-cc} -v >conftest.c 2>&1
402                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
403                                 rm -fr conftest.c
404                                 case "$ac_cv_gcc_compiler_version_number" in
405                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
406                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
407                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
408                                                 ;;
409                                         *)
410                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
411                                                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
412                                                 AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
413                                                 ;;
414                                 esac
415                         else
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                         fi
420                         ;;
421                 esac
422                 ;;
423 #
424 # VOS may need to have POSIX support and System V compatibility enabled.
425 #
426     *vos*)
427     case "$CPPFLAGS" in
428           *-D_POSIX_C_SOURCE*)
429                 ;;
430           *)
431                 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199506L"
432                 AC_DEFINE(_POSIX_C_SOURCE, 199506L, [Whether to enable POSIX support])
433                 ;;
434     esac
435     case "$CPPFLAGS" in
436           *-D_SYSV*|*-D_SVID_SOURCE*)
437                 ;;
438           *)
439                 CPPFLAGS="$CPPFLAGS -D_SYSV"
440                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
441     esac
442     ;;
443 #
444 # Tests needed for SINIX large file support.
445 #
446     *sysv4*)
447       if test $host = mips-sni-sysv4 ; then
448         AC_MSG_CHECKING([for LFS support])
449         old_CPPFLAGS="$CPPFLAGS"
450         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
451         AC_TRY_RUN([
452 #include <unistd.h>
453 main () {
454 #if _LFS64_LARGEFILE == 1
455 exit(0);
456 #else
457 exit(1);
458 #endif
459 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
460         CPPFLAGS="$old_CPPFLAGS"
461         if test x$SINIX_LFS_SUPPORT = xyes ; then
462           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
463                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
464           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
465           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
466           LIBS="`getconf LFS64_LIBS` $LIBS"
467         fi
468       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
469       fi
470     ;;
471
472 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
473 #
474     *linux*)
475         AC_MSG_CHECKING([for LFS support])
476         old_CPPFLAGS="$CPPFLAGS"
477         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
478        AC_TRY_RUN([
479 #include <unistd.h>
480 #include <sys/utsname.h>
481 main() {
482 #if _LFS64_LARGEFILE == 1
483        struct utsname uts;
484        char *release;
485        int major, minor;
486
487        /* Ensure this is glibc 2.2 or higher */
488 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
489        int libc_major = __GLIBC__;
490        int libc_minor = __GLIBC_MINOR__;
491
492        if (libc_major < 2)
493               exit(1);
494        if (libc_minor < 2)
495               exit(1);
496 #endif
497
498        /* Ensure this is kernel 2.4 or higher */
499
500        uname(&uts);
501        release = uts.release;
502        major = atoi(strsep(&release, "."));
503        minor = atoi(strsep(&release, "."));
504
505        if (major > 2 || (major == 2 && minor > 3))
506                exit(0);
507        exit(1);
508 #else
509        exit(1);
510 #endif
511 }
512 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
513         CPPFLAGS="$old_CPPFLAGS"
514         if test x$LINUX_LFS_SUPPORT = xyes ; then
515           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
516                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
517           AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
518           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
519         fi
520        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
521                 ;;
522
523     *hurd*)
524         AC_MSG_CHECKING([for LFS support])
525         old_CPPFLAGS="$CPPFLAGS"
526         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
527         AC_TRY_RUN([
528 #include <unistd.h>
529 main () {
530 #if _LFS64_LARGEFILE == 1
531 exit(0);
532 #else
533 exit(1);
534 #endif
535 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
536         CPPFLAGS="$old_CPPFLAGS"
537         if test x$GLIBC_LFS_SUPPORT = xyes ; then
538           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
539                   AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
540           AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
541         fi
542       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
543     ;;
544
545 esac
546
547 AC_INLINE
548 AC_HEADER_STDC
549 AC_HEADER_DIRENT
550 AC_HEADER_TIME
551 AC_HEADER_SYS_WAIT
552 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
553 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
554 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
555 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
556 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
557 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
558 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
559 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h ldap.h lber.h dlfcn.h)
560 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
561
562 #
563 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
564 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
565 #
566 case "$host_os" in
567     *hpux*)
568                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
569                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
570                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
571                    AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
572                 fi
573         ;;
574 esac
575 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
576 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
577 AC_CHECK_HEADERS(stropts.h poll.h)
578 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
579 AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
580
581 # For experimental utmp support (lastlog on some BSD-like systems)
582 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
583  
584 # For quotas on Veritas VxFS filesystems
585 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
586
587 # For quotas on Linux XFS filesystems
588 AC_CHECK_HEADERS(linux/xqm.h)
589 AC_CHECK_HEADERS(xfs/xqm.h)
590
591 AC_CHECK_SIZEOF(int,cross)
592 AC_CHECK_SIZEOF(long,cross)
593 AC_CHECK_SIZEOF(short,cross)
594
595 AC_C_CONST
596 AC_C_INLINE
597 AC_C_BIGENDIAN
598 AC_C_CHAR_UNSIGNED
599
600 AC_TYPE_SIGNAL
601 AC_TYPE_UID_T
602 AC_TYPE_MODE_T
603 AC_TYPE_OFF_T
604 AC_TYPE_SIZE_T
605 AC_TYPE_PID_T
606 AC_STRUCT_ST_RDEV
607 AC_DIRENT_D_OFF
608 AC_CHECK_TYPE(ino_t,unsigned)
609 AC_CHECK_TYPE(loff_t,off_t)
610 AC_CHECK_TYPE(offset_t,loff_t)
611 AC_CHECK_TYPE(ssize_t, int)
612 AC_CHECK_TYPE(wchar_t, unsigned short)
613
614 ############################################
615 # for cups support we need libcups, and a handful of header files
616
617 AC_ARG_ENABLE(cups,
618 [  --enable-cups           Turn on CUPS support (default=auto)])
619
620 if test x$enable_cups != xno; then
621         AC_PATH_PROG(CUPS_CONFIG, cups-config)
622
623         if test "x$CUPS_CONFIG" != x; then
624                         AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
625                 CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
626                 LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
627                 PRINTLIBS="$PRINTLIBS `$CUPS_CONFIG --libs`"
628         fi
629 fi
630
631 ############################################
632 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
633 AC_SEARCH_LIBS(dlopen, [dl])
634 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
635
636 ############################################
637 # check if the compiler can do immediate structures
638 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
639     AC_TRY_COMPILE([
640 #include <stdio.h>],
641 [
642    typedef struct {unsigned x;} FOOBAR;
643    #define X_FOOBAR(x) ((FOOBAR) { x })
644    #define FOO_ONE X_FOOBAR(1)
645    FOOBAR f = FOO_ONE;   
646    static struct {
647         FOOBAR y; 
648         } f2[] = {
649                 {FOO_ONE}
650         };   
651 ],
652         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
653 if test x"$samba_cv_immediate_structures" = x"yes"; then
654    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
655 fi
656
657 ############################################
658 # check for unix domain sockets
659 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
660     AC_TRY_COMPILE([
661 #include <sys/types.h>
662 #include <stdlib.h>
663 #include <stddef.h>
664 #include <sys/socket.h>
665 #include <sys/un.h>],
666 [
667   struct sockaddr_un sunaddr; 
668   sunaddr.sun_family = AF_UNIX;
669 ],
670         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
671 if test x"$samba_cv_unixsocket" = x"yes"; then
672    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
673 fi
674
675
676 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
677     AC_TRY_COMPILE([
678 #include <sys/types.h>
679 #if STDC_HEADERS
680 #include <stdlib.h>
681 #include <stddef.h>
682 #endif
683 #include <sys/socket.h>],[socklen_t i = 0],
684         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
685 if test x"$samba_cv_socklen_t" = x"yes"; then
686    AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
687 fi
688
689 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
690     AC_TRY_COMPILE([
691 #include <sys/types.h>
692 #if STDC_HEADERS
693 #include <stdlib.h>
694 #include <stddef.h>
695 #endif
696 #include <signal.h>],[sig_atomic_t i = 0],
697         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
698 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
699    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
700 fi
701
702 # stupid headers have the functions but no declaration. grrrr.
703 AC_HAVE_DECL(errno, [#include <errno.h>])
704 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
705 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
706 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
707 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
708 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
709 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
710
711 # and glibc has setresuid under linux but the function does
712 # nothing until kernel 2.1.44! very dumb.
713 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
714     AC_TRY_RUN([#include <errno.h>
715 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
716         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
717 if test x"$samba_cv_have_setresuid" = x"yes"; then
718     AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
719 fi
720
721 # Do the same check for setresguid...
722 #
723 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
724     AC_TRY_RUN([#include <unistd.h>
725 #include <errno.h>
726 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
727         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
728 if test x"$samba_cv_have_setresgid" = x"yes"; then
729     AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
730 fi
731
732 AC_FUNC_MEMCMP
733
734 ###############################################
735 # Readline included by default unless explicitly asked not to
736 test "${with_readline+set}" != "set" && with_readline=yes
737
738 # test for where we get readline() from
739 AC_MSG_CHECKING(whether to use readline)
740 AC_ARG_WITH(readline,
741 [  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto) ],
742 [  case "$with_readline" in
743   yes)
744     AC_MSG_RESULT(yes)
745
746     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
747     AC_CHECK_HEADERS(readline/history.h)
748
749     AC_CHECK_HEADERS(readline.h readline/readline.h,[
750       for termlib in ncurses curses termcap terminfo termlib tinfo; do
751        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
752       done
753       AC_CHECK_LIB(readline, rl_callback_handler_install,
754        [TERMLIBS="-lreadline $TERMLIBS"
755        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
756        break], [TERMLIBS=], $TERMLIBS)])
757     ;;
758   no)
759     AC_MSG_RESULT(no)
760     ;;
761   *)
762     AC_MSG_RESULT(yes)
763
764     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
765     # alternate readline path
766     _ldflags=${LDFLAGS}
767     _cppflags=${CPPFLAGS}
768
769     # Add additional search path
770     LDFLAGS="-L$with_readline/lib $LDFLAGS"
771     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
772
773     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
774     AC_CHECK_HEADERS(readline/history.h)
775
776     AC_CHECK_HEADERS(readline.h readline/readline.h,[
777       for termlib in ncurses curses termcap terminfo termlib; do
778        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
779       done
780       AC_CHECK_LIB(readline, rl_callback_handler_install,
781        [TERMLDFLAGS="-L$with_readline/lib"
782        TERMCPPFLAGS="-I$with_readline/include"
783        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
784        TERMLIBS="-lreadline $TERMLIBS"
785        AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
786        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
787
788     LDFLAGS=$_ldflags
789     ;;
790   esac],
791   AC_MSG_RESULT(no)
792 )
793 AC_SUBST(TERMLIBS)
794 AC_SUBST(TERMLDFLAGS)
795
796 # The readline API changed slightly from readline3 to readline4, so
797 # code will generate warnings on one of them unless we have a few
798 # special cases.
799 AC_CHECK_LIB(readline, rl_completion_matches,
800              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
801                         [Do we have rl_completion_matches?])],
802              [],
803              [$TERMLIBS])
804
805 # The following test taken from the cvs sources
806 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
807 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
808 # libsocket.so which has a bad implementation of gethostbyname (it
809 # only looks in /etc/hosts), so we only look for -lsocket if we need
810 # it.
811 AC_CHECK_FUNCS(connect)
812 if test x"$ac_cv_func_connect" = x"no"; then
813     case "$LIBS" in
814     *-lnsl*) ;;
815     *) AC_CHECK_LIB(nsl_s, printf) ;;
816     esac
817     case "$LIBS" in
818     *-lnsl*) ;;
819     *) AC_CHECK_LIB(nsl, printf) ;;
820     esac
821     case "$LIBS" in
822     *-lsocket*) ;;
823     *) AC_CHECK_LIB(socket, connect) ;;
824     esac
825     case "$LIBS" in
826     *-linet*) ;;
827     *) AC_CHECK_LIB(inet, connect) ;;
828     esac
829     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
830     dnl has been cached.
831     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
832        test x"$ac_cv_lib_inet_connect" = x"yes"; then
833         # ac_cv_func_connect=yes
834         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
835         AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
836     fi
837 fi
838
839 ###############################################
840 # test for where we get yp_get_default_domain() from
841 AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
842 AC_CHECK_FUNCS(yp_get_default_domain)
843
844 # Check if we have execl, if not we need to compile smbrun.
845 AC_CHECK_FUNCS(execl)
846 if test x"$ac_cv_func_execl" = x"no"; then
847     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
848 fi
849
850 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
851 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
852 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
853 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
854 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
855 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
856 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
857 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
858 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
859 AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
860 # setbuffer, shmget, shm_open are needed for smbtorture
861 AC_CHECK_FUNCS(setbuffer shmget shm_open)
862
863 # syscall() is needed for smbwrapper.
864 AC_CHECK_FUNCS(syscall)
865
866 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
867 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
868 AC_CHECK_FUNCS(__getcwd _getcwd)
869 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
870 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
871 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
872 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
873 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
874 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
875 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
876 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
877 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
878 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
879 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
880
881 #
882 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
883 #
884
885 if test x$ac_cv_func_stat64 = xno ; then
886   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
887   AC_TRY_LINK([
888 #if defined(HAVE_UNISTD_H)
889 #include <unistd.h>
890 #endif
891 #include <sys/stat.h>
892 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
893   AC_MSG_RESULT([$ac_cv_func_stat64])
894   if test x$ac_cv_func_stat64 = xyes ; then
895     AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
896   fi
897 fi
898
899 if test x$ac_cv_func_lstat64 = xno ; then
900   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
901   AC_TRY_LINK([
902 #if defined(HAVE_UNISTD_H)
903 #include <unistd.h>
904 #endif
905 #include <sys/stat.h>
906 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
907   AC_MSG_RESULT([$ac_cv_func_lstat64])
908   if test x$ac_cv_func_lstat64 = xyes ; then
909     AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
910   fi
911 fi
912
913 if test x$ac_cv_func_fstat64 = xno ; then
914   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
915   AC_TRY_LINK([
916 #if defined(HAVE_UNISTD_H)
917 #include <unistd.h>
918 #endif
919 #include <sys/stat.h>
920 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
921   AC_MSG_RESULT([$ac_cv_func_fstat64])
922   if test x$ac_cv_func_fstat64 = xyes ; then
923     AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
924   fi
925 fi
926
927 #####################################
928 # we might need the resolv library on some systems
929 AC_CHECK_LIB(resolv, dn_expand)
930
931 #
932 # Check for the functions putprpwnam, set_auth_parameters,
933 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
934 # Needed for OSF1 and HPUX.
935 #
936
937 AC_LIBTESTFUNC(security, putprpwnam)
938 AC_LIBTESTFUNC(sec, putprpwnam)
939
940 AC_LIBTESTFUNC(security, set_auth_parameters)
941 AC_LIBTESTFUNC(sec, set_auth_parameters)
942
943 # UnixWare 7.x has its getspnam in -lgen
944 AC_LIBTESTFUNC(gen, getspnam)
945
946 AC_LIBTESTFUNC(security, getspnam)
947 AC_LIBTESTFUNC(sec, getspnam)
948
949 AC_LIBTESTFUNC(security, bigcrypt)
950 AC_LIBTESTFUNC(sec, bigcrypt)
951
952 AC_LIBTESTFUNC(security, getprpwnam)
953 AC_LIBTESTFUNC(sec, getprpwnam)
954
955 # Assume non-shared by default and override below
956 BLDSHARED="false"
957
958 # these are the defaults, good for lots of systems
959 HOST_OS="$host_os"
960 LDSHFLAGS="-shared"
961 SONAMEFLAG="#"
962 SHLD="\${CC}"
963 PICFLAG=""
964 PICSUFFIX="po"
965 POBAD_CC="#"
966 SHLIBEXT="so"
967
968 if test "$enable_shared" = "yes"; then
969   # this bit needs to be modified for each OS that is suported by
970   # smbwrapper. You need to specify how to created a shared library and
971   # how to compile C code to produce PIC object files
972
973   AC_MSG_CHECKING([ability to build shared libraries])
974
975   # and these are for particular systems
976   case "$host_os" in
977                 *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
978                         BLDSHARED="true"
979                         LDSHFLAGS="-shared" 
980                         DYNEXP="-Wl,--export-dynamic"
981                         PICFLAG="-fPIC"
982                         SONAMEFLAG="-Wl,-soname="
983                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
984                         ;;
985                 *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
986                         BLDSHARED="true"
987                         LDSHFLAGS="-G"
988                         SONAMEFLAG="-h "
989                         if test "${GCC}" = "yes"; then
990                                 PICFLAG="-fPIC"
991                                 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
992                                         DYNEXP="-Wl,-E"
993                                 fi
994                         else
995                                 PICFLAG="-KPIC"
996                                 ## ${CFLAGS} added for building 64-bit shared 
997                                 ## libs using Sun's Compiler
998                                 LDSHFLAGS="-G \${CFLAGS}"
999                                 POBAD_CC=""
1000                                 PICSUFFIX="po.o"
1001                         fi
1002                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1003                         ;;
1004                 *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
1005                         BLDSHARED="true"
1006                         LDSHFLAGS="-G"
1007                         SONAMEFLAG="-Wl,-h,"
1008                         PICFLAG="-KPIC"   # Is this correct for SunOS
1009                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1010                         ;;
1011                 *netbsd* | *freebsd*)  BLDSHARED="true"
1012                         LDSHFLAGS="-shared"
1013                         DYNEXP="-Wl,--export-dynamic"
1014                         SONAMEFLAG="-Wl,-soname,"
1015                         PICFLAG="-fPIC -DPIC"
1016                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1017                         ;;
1018                 *openbsd*)  BLDSHARED="true"
1019                         LDSHFLAGS="-shared"
1020                         DYNEXP="-Wl,-Bdynamic"
1021                         SONAMEFLAG="-Wl,-soname,"
1022                         PICFLAG="-fPIC"
1023                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1024                         ;;
1025                 *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
1026                         case "$host_os" in
1027                         *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
1028                         ;;
1029                         esac
1030                         ATTEMPT_WRAP32_BUILD=yes
1031                         BLDSHARED="true"
1032                         LDSHFLAGS="-set_version sgi1.0 -shared"
1033                         SONAMEFLAG="-soname "
1034                         SHLD="\${LD}"
1035                         if test "${GCC}" = "yes"; then
1036                                 PICFLAG="-fPIC"
1037                         else 
1038                                 PICFLAG="-KPIC"
1039                         fi
1040                         AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
1041                         ;;
1042                 *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
1043                         BLDSHARED="true"
1044                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
1045                         DYNEXP="-Wl,-brtl,-bexpall"
1046                         PICFLAG="-O2"
1047                         if test "${GCC}" != "yes"; then
1048                                 ## for funky AIX compiler using strncpy()
1049                                 CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
1050                         fi
1051
1052                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
1053                         ;;
1054                 *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
1055                         SHLIBEXT="sl"
1056                         # Use special PIC flags for the native HP-UX compiler.
1057                         if test $ac_cv_prog_cc_Ae = yes; then
1058                                 BLDSHARED="true"
1059                                 SHLD="/usr/bin/ld"
1060                                 LDSHFLAGS="-B symbolic -b -z"
1061                                 SONAMEFLAG="+h "
1062                                 PICFLAG="+z"
1063                         fi
1064                         DYNEXP="-Wl,-E"
1065                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
1066                         ;;
1067                 *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
1068                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1069                         ;;
1070                 *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
1071                         BLDSHARED="true"
1072                         LDSHFLAGS="-shared"
1073                         SONAMEFLAG="-Wl,-soname,"
1074                         PICFLAG="-fPIC"
1075                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1076                         ;;
1077                 *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
1078                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1079                         ;;
1080                 *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
1081                         BLDSHARED="true"
1082                         LDSHFLAGS="-shared"
1083                         SONAMEFLAG="-Wl,-soname,"
1084                         PICFLAG="-KPIC"
1085                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1086                         ;;
1087                 *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
1088                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1089                         ;;
1090                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
1091                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1092                         ;;
1093                 *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1094                         case "$host" in
1095                                 *-univel-*)     if [ test "$GCC" != yes ]; then
1096                                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1097                                         fi
1098                                         LDSHFLAGS="-G"
1099                                         DYNEXP="-Bexport"
1100                                 ;;
1101                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
1102                         esac
1103                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1104                         ;;
1105
1106                 *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
1107                         if [ test "$GCC" != yes ]; then
1108                                 AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
1109                         fi
1110                         LDSHFLAGS="-G"
1111                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1112                         ;;
1113                 *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
1114                         BLDSHARED="false"
1115                         LDSHFLAGS=""
1116                         ;;
1117                 *)
1118                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
1119                         ;;
1120   esac
1121   AC_SUBST(DYNEXP)
1122   AC_MSG_RESULT($BLDSHARED)
1123   AC_MSG_CHECKING([linker flags for shared libraries])
1124   AC_MSG_RESULT([$LDSHFLAGS])
1125   AC_MSG_CHECKING([compiler flags for position-independent code])
1126   AC_MSG_RESULT([$PICFLAGS])
1127 fi
1128
1129 #######################################################
1130 # test whether building a shared library actually works
1131 if test $BLDSHARED = true; then
1132 AC_CACHE_CHECK([whether building shared libraries actually works], 
1133                [ac_cv_shlib_works],[
1134    ac_cv_shlib_works=no
1135    # try building a trivial shared library
1136    if test "$PICSUFFIX" = "po"; then
1137      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/tests/shlib.c &&
1138        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
1139        ac_cv_shlib_works=yes
1140    else
1141      $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c &&
1142        mv shlib.$PICSUFFIX shlib.po &&
1143        $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o shlib.so shlib.po &&
1144        ac_cv_shlib_works=yes
1145    fi
1146    rm -f shlib.so shlib.po
1147 ])
1148 if test $ac_cv_shlib_works = no; then
1149    BLDSHARED=false
1150 fi
1151 fi
1152
1153 ################
1154
1155 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
1156 AC_TRY_RUN([#include <stdio.h>
1157 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
1158 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
1159 if test x"$samba_cv_have_longlong" = x"yes"; then
1160     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
1161 fi
1162
1163 #
1164 # Check if the compiler supports the LL prefix on long long integers.
1165 # AIX needs this.
1166
1167 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
1168     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
1169         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
1170 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
1171    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
1172 fi
1173
1174   
1175 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
1176 AC_TRY_RUN([#include <stdio.h>
1177 #include <sys/stat.h>
1178 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
1179 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
1180 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
1181     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
1182 fi
1183
1184 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
1185 AC_TRY_RUN([
1186 #if defined(HAVE_UNISTD_H)
1187 #include <unistd.h>
1188 #endif
1189 #include <stdio.h>
1190 #include <sys/stat.h>
1191 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1192 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
1193 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
1194     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
1195 fi
1196
1197 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
1198 AC_TRY_RUN([#include <stdio.h>
1199 #include <sys/stat.h>
1200 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
1201 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
1202 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
1203     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
1204 fi
1205
1206 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
1207 AC_TRY_RUN([
1208 #if defined(HAVE_UNISTD_H)
1209 #include <unistd.h>
1210 #endif
1211 #include <stdio.h>
1212 #include <sys/stat.h>
1213 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1214 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
1215 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
1216     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
1217 fi
1218
1219 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
1220 AC_TRY_RUN([
1221 #if defined(HAVE_UNISTD_H)
1222 #include <unistd.h>
1223 #endif
1224 #include <stdio.h>
1225 #include <sys/stat.h>
1226 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
1227 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
1228 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
1229     AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
1230 fi
1231
1232 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
1233 AC_TRY_COMPILE([
1234 #if defined(HAVE_UNISTD_H)
1235 #include <unistd.h>
1236 #endif
1237 #include <sys/types.h>
1238 #include <dirent.h>],
1239 [struct dirent64 de;],
1240 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
1241 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
1242     AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
1243 fi
1244
1245 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
1246 AC_TRY_RUN([
1247 #if defined(HAVE_UNISTD_H)
1248 #include <unistd.h>
1249 #endif
1250 #include <sys/types.h>
1251 main() { dev_t dev; int i = major(dev); return 0; }],
1252 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
1253 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
1254     AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
1255 fi
1256
1257 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
1258 AC_TRY_RUN([
1259 #if defined(HAVE_UNISTD_H)
1260 #include <unistd.h>
1261 #endif
1262 #include <sys/types.h>
1263 main() { dev_t dev; int i = minor(dev); return 0; }],
1264 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
1265 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
1266     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
1267 fi
1268
1269 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
1270 AC_TRY_RUN([#include <stdio.h>
1271 main() { char c; c=250; exit((c > 0)?0:1); }],
1272 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
1273 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
1274     AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
1275 fi
1276
1277 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
1278 AC_TRY_COMPILE([#include <sys/types.h>
1279 #include <sys/socket.h>
1280 #include <netinet/in.h>],
1281 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
1282 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
1283 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
1284     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
1285 fi
1286
1287 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1288 AC_TRY_COMPILE([#include <sys/types.h>
1289 #include <dirent.h>
1290 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1291 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1292 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1293     AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
1294 fi
1295
1296 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1297 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1298 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1299 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1300     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
1301 fi
1302
1303 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1304 AC_TRY_RUN([
1305 #include <sys/time.h>
1306 #include <unistd.h>
1307 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1308            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1309 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1310     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
1311 fi
1312
1313 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
1314 AC_TRY_LINK([#include <stdarg.h>
1315 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
1316 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
1317 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
1318     AC_DEFINE(HAVE_VA_COPY,1,[Whether __va_copy() is available])
1319 fi
1320
1321 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1322 AC_TRY_RUN([
1323 #include <sys/types.h>
1324 #include <stdarg.h>
1325 void foo(const char *format, ...) { 
1326        va_list ap;
1327        int len;
1328        char buf[5];
1329
1330        va_start(ap, format);
1331        len = vsnprintf(buf, 0, format, ap);
1332        va_end(ap);
1333        if (len != 5) exit(1);
1334
1335        va_start(ap, format);
1336        len = vsnprintf(0, 0, format, ap);
1337        va_end(ap);
1338        if (len != 5) exit(1);
1339
1340        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1341
1342        exit(0);
1343 }
1344 main() { foo("hello"); }
1345 ],
1346 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1347 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1348     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
1349 fi
1350
1351 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1352 AC_TRY_RUN([#include <sys/types.h>
1353 #include <dirent.h>
1354 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1355 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1356 di->d_name[0] == 0) exit(0); exit(1);} ],
1357 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1358 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1359     AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
1360 fi
1361
1362 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1363 AC_TRY_COMPILE([#include <sys/types.h>
1364 #include <utime.h>],
1365 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1366 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1367 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1368     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
1369 fi
1370
1371 dnl  utmp and utmpx come in many flavours
1372 dnl  We need to check for many of them
1373 dnl  But we don't need to do each and every one, because our code uses
1374 dnl  mostly just the utmp (not utmpx) fields.
1375
1376 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1377
1378 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1379 AC_TRY_COMPILE([#include <sys/types.h>
1380 #include <utmp.h>],
1381 [struct utmp ut;  ut.ut_name[0] = 'a';],
1382 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1383 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1384     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
1385 fi 
1386
1387 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1388 AC_TRY_COMPILE([#include <sys/types.h>
1389 #include <utmp.h>],
1390 [struct utmp ut;  ut.ut_user[0] = 'a';],
1391 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1392 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1393     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
1394 fi 
1395
1396 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1397 AC_TRY_COMPILE([#include <sys/types.h>
1398 #include <utmp.h>],
1399 [struct utmp ut;  ut.ut_id[0] = 'a';],
1400 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1401 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1402     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
1403 fi 
1404
1405 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1406 AC_TRY_COMPILE([#include <sys/types.h>
1407 #include <utmp.h>],
1408 [struct utmp ut;  ut.ut_host[0] = 'a';],
1409 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1410 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1411     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
1412 fi 
1413
1414 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1415 AC_TRY_COMPILE([#include <sys/types.h>
1416 #include <utmp.h>],
1417 [struct utmp ut;  time_t t; ut.ut_time = t;],
1418 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1419 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1420     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
1421 fi 
1422
1423 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1424 AC_TRY_COMPILE([#include <sys/types.h>
1425 #include <utmp.h>],
1426 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1427 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1428 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1429     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
1430 fi 
1431
1432 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1433 AC_TRY_COMPILE([#include <sys/types.h>
1434 #include <utmp.h>],
1435 [struct utmp ut;  ut.ut_type = 0;],
1436 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1437 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1438     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
1439 fi 
1440
1441 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1442 AC_TRY_COMPILE([#include <sys/types.h>
1443 #include <utmp.h>],
1444 [struct utmp ut;  ut.ut_pid = 0;],
1445 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1446 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1447     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
1448 fi 
1449
1450 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1451 AC_TRY_COMPILE([#include <sys/types.h>
1452 #include <utmp.h>],
1453 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1454 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1455 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1456     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
1457 fi 
1458
1459 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1460 AC_TRY_COMPILE([#include <sys/types.h>
1461 #include <utmp.h>],
1462 [struct utmp ut;  ut.ut_addr = 0;],
1463 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1464 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1465     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
1466 fi 
1467
1468 if test x$ac_cv_func_pututline = xyes ; then
1469   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1470   AC_TRY_COMPILE([#include <sys/types.h>
1471 #include <utmp.h>],
1472   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1473   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1474   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1475       AC_DEFINE(PUTUTLINE_RETURNS_UTMP,1,[Whether pututline returns pointer])
1476   fi
1477 fi
1478
1479 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1480 AC_TRY_COMPILE([#include <sys/types.h>
1481 #include <utmpx.h>],
1482 [struct utmpx ux;  ux.ut_syslen = 0;],
1483 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1484 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1485     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
1486 fi 
1487
1488
1489 ICONV_LOCATION=standard
1490 LOOK_DIRS="/usr /usr/local /sw"
1491 AC_ARG_WITH(libiconv,
1492 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1493 [
1494   if test "$withval" = "no" ; then
1495     AC_MSG_ERROR(I won't take no for an answer)
1496   else
1497      if test "$withval" != "yes" ; then
1498         LOOK_DIRS="$withval $LOOK_DIRS"
1499      fi
1500   fi
1501 ])
1502
1503 ICONV_FOUND="no"
1504 for i in $LOOK_DIRS ; do
1505     save_LIBS=$LIBS
1506     save_LDFLAGS=$LDFLAGS
1507     save_CPPFLAGS=$CPPFLAGS
1508     CPPFLAGS="-I$i/include"
1509     LDFLAGS="-L$i/lib"
1510     LIBS=
1511     export LDFLAGS LIBS CPPFLAGS
1512 dnl Try to find iconv(3)
1513     jm_ICONV($i)
1514
1515     CPPFLAGS=$save_CPPFLAGS
1516     if test -n "$ICONV_FOUND" ; then
1517         LDFLAGS=$save_LDFLAGS
1518         LIB_ADD_DIR(LDFLAGS, "$i/lib")
1519         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
1520         LIBS="$save_LIBS $LIBS"
1521         ICONV_LOCATION=$i
1522         export LDFLAGS LIBS CPPFLAGS
1523         break
1524     else
1525         LDFLAGS=$save_LDFLAGS
1526         LIBS=$save_LIBS
1527         export LDFLAGS LIBS CPPFLAGS
1528     fi
1529 done
1530
1531 ############
1532 # check for iconv in libc
1533 AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1534 AC_TRY_RUN([
1535 #include <iconv.h>
1536 main() {
1537        iconv_t cd = iconv_open("ASCII", "UCS-2LE");
1538        if (cd == 0 || cd == (iconv_t)-1) return -1;
1539        return 0;
1540 }
1541 ],
1542 samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
1543 if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1544     AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
1545 fi
1546
1547 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
1548     AC_MSG_WARN([Sufficient support for iconv function was not found. 
1549     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
1550 fi
1551
1552
1553 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1554 AC_TRY_RUN([
1555 #include <sys/types.h>
1556 #include <fcntl.h>
1557 #ifndef F_GETLEASE
1558 #define F_GETLEASE      1025
1559 #endif
1560 main() {
1561        int fd = open("/dev/null", O_RDONLY);
1562        return fcntl(fd, F_GETLEASE, 0) == -1;
1563 }
1564 ],
1565 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1566 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1567     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
1568 fi
1569
1570 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1571 AC_TRY_RUN([
1572 #include <sys/types.h>
1573 #include <fcntl.h>
1574 #include <signal.h>
1575 #ifndef F_NOTIFY
1576 #define F_NOTIFY 1026
1577 #endif
1578 main() {
1579         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1580 }
1581 ],
1582 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1583 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1584     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
1585 fi
1586
1587 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1588 AC_TRY_RUN([
1589 #include <sys/types.h>
1590 #include <fcntl.h>
1591 #include <signal.h>
1592 #include <sys/file.h>
1593 #ifndef LOCK_MAND
1594 #define LOCK_MAND       32
1595 #define LOCK_READ       64
1596 #endif
1597 main() {
1598         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1599 }
1600 ],
1601 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1602 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1603     AC_DEFINE(HAVE_KERNEL_SHARE_MODES,1,[Whether the kernel supports share modes])
1604 fi
1605
1606
1607
1608
1609 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1610 AC_TRY_COMPILE([#include <sys/types.h>
1611 #include <fcntl.h>],
1612 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1613 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1614 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1615     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
1616 fi
1617
1618 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1619 AC_TRY_RUN([#include <sys/types.h>
1620 #include <sys/capability.h>
1621 main() {
1622  cap_t cap;
1623  if ((cap = cap_get_proc()) == NULL)
1624    exit(1);
1625  cap->cap_effective |= CAP_NETWORK_MGT;
1626  cap->cap_inheritable |= CAP_NETWORK_MGT;
1627  cap_set_proc(cap);
1628  exit(0);
1629 }
1630 ],
1631 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1632 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1633     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
1634 fi
1635
1636 #
1637 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1638 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1639 #
1640
1641 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1642 AC_TRY_COMPILE([#include <sys/types.h>
1643 #if defined(HAVE_RPC_RPC_H)
1644 #include <rpc/rpc.h>
1645 #endif],
1646 [int16 testvar;],
1647 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1648 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1649     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H,1,[Whether int16 typedef is included by rpc/rpc.h])
1650 fi
1651
1652 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1653 AC_TRY_COMPILE([#include <sys/types.h>
1654 #if defined(HAVE_RPC_RPC_H)
1655 #include <rpc/rpc.h>
1656 #endif],
1657 [uint16 testvar;],
1658 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1659 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1660     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H,1,[Whether uint16 typedef is included by rpc/rpc.h])
1661 fi
1662
1663 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1664 AC_TRY_COMPILE([#include <sys/types.h>
1665 #if defined(HAVE_RPC_RPC_H)
1666 #include <rpc/rpc.h>
1667 #endif],
1668 [int32 testvar;],
1669 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1670 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1671     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H,1,[Whether int32 typedef is included by rpc/rpc.h])
1672 fi
1673
1674 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1675 AC_TRY_COMPILE([#include <sys/types.h>
1676 #if defined(HAVE_RPC_RPC_H)
1677 #include <rpc/rpc.h>
1678 #endif],
1679 [uint32 testvar;],
1680 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1681 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1682     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H,1,[Whether uint32 typedef is included by rpc/rpc.h])
1683 fi
1684
1685 dnl
1686 dnl Some systems (SCO) have a problem including
1687 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1688 dnl as a #define in <prot.h> and as part of an enum
1689 dnl in <rpc/rpc.h>.
1690 dnl
1691
1692 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1693 AC_TRY_COMPILE([#include <sys/types.h>
1694 #ifdef HAVE_SYS_SECURITY_H
1695 #include <sys/security.h>
1696 #include <prot.h>
1697 #endif  /* HAVE_SYS_SECURITY_H */
1698 #if defined(HAVE_RPC_RPC_H)
1699 #include <rpc/rpc.h>
1700 #endif],
1701 [int testvar;],
1702 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1703 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1704     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT,1,[Whether there is a conflicting AUTH_ERROR define in rpc/rpc.h])
1705 fi
1706
1707 AC_MSG_CHECKING([for test routines])
1708 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1709            AC_MSG_RESULT(yes),
1710            AC_MSG_ERROR([cant find test code. Aborting config]),
1711            AC_MSG_WARN([cannot run when cross-compiling]))
1712
1713 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1714 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1715            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1716 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1717     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
1718 fi
1719
1720 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1721 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1722            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1723            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1724            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1725 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1726 then
1727     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1728 fi
1729
1730 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1731 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1732            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1733 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1734     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
1735 fi
1736
1737 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1738 SAVE_CPPFLAGS="$CPPFLAGS"
1739 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
1740 AC_TRY_COMPILE([
1741 #define REPLACE_GETPASS 1
1742 #define NO_CONFIG_H 1
1743 #define main dont_declare_main
1744 #include "${srcdir-.}/lib/getsmbpass.c"
1745 #undef main
1746 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1747 CPPFLAGS="$SAVE_CPPFLAGS"
1748 ])
1749 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1750         AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
1751 fi
1752
1753 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1754 AC_TRY_RUN([
1755 #include <stdio.h>
1756 #include <sys/types.h>
1757 #include <netinet/in.h>
1758 #ifdef HAVE_ARPA_INET_H
1759 #include <arpa/inet.h>
1760 #endif
1761 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1762 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1763     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1764 exit(1);}],
1765            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1766 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1767     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
1768 fi
1769
1770 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1771 AC_TRY_RUN([#include <stdlib.h>
1772 #include <sys/types.h>
1773 #include <sys/stat.h>
1774 #include <unistd.h>
1775 main() { 
1776   struct stat st;
1777   char tpl[20]="/tmp/test.XXXXXX"; 
1778   int fd = mkstemp(tpl); 
1779   if (fd == -1) exit(1);
1780   unlink(tpl);
1781   if (fstat(fd, &st) != 0) exit(1);
1782   if ((st.st_mode & 0777) != 0600) exit(1);
1783   exit(0);
1784 }],
1785 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1786 samba_cv_HAVE_SECURE_MKSTEMP=no,
1787 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1788 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1789     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
1790 fi
1791
1792 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1793 AC_TRY_RUN([#include <unistd.h>
1794 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1795 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1796 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1797     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
1798 fi
1799
1800 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1801 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1802            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1803 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1804     AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
1805 else
1806     AC_MSG_WARN(running as non-root will disable some tests)
1807 fi
1808
1809 ##################
1810 # look for a method of finding the list of network interfaces
1811 iface=no;
1812 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1813 AC_TRY_RUN([
1814 #define HAVE_IFACE_AIX 1
1815 #define AUTOCONF_TEST 1
1816 #include "confdefs.h"
1817 #include "${srcdir-.}/lib/interfaces.c"],
1818            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1819 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1820     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
1821 fi
1822
1823 if test $iface = no; then
1824 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1825 AC_TRY_RUN([
1826 #define HAVE_IFACE_IFCONF 1
1827 #define AUTOCONF_TEST 1
1828 #include "confdefs.h"
1829 #include "${srcdir-.}/lib/interfaces.c"],
1830            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1831 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1832     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
1833 fi
1834 fi
1835
1836 if test $iface = no; then
1837 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1838 AC_TRY_RUN([
1839 #define HAVE_IFACE_IFREQ 1
1840 #define AUTOCONF_TEST 1
1841 #include "confdefs.h"
1842 #include "${srcdir-.}/lib/interfaces.c"],
1843            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1844 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1845     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
1846 fi
1847 fi
1848
1849
1850 ################################################
1851 # look for a method of setting the effective uid
1852 seteuid=no;
1853 if test $seteuid = no; then
1854 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1855 AC_TRY_RUN([
1856 #define AUTOCONF_TEST 1
1857 #define USE_SETRESUID 1
1858 #include "confdefs.h"
1859 #include "${srcdir-.}/lib/util_sec.c"],
1860            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1861 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1862     seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
1863 fi
1864 fi
1865
1866
1867 if test $seteuid = no; then
1868 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1869 AC_TRY_RUN([
1870 #define AUTOCONF_TEST 1
1871 #define USE_SETREUID 1
1872 #include "confdefs.h"
1873 #include "${srcdir-.}/lib/util_sec.c"],
1874            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1875 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1876     seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
1877 fi
1878 fi
1879
1880 if test $seteuid = no; then
1881 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1882 AC_TRY_RUN([
1883 #define AUTOCONF_TEST 1
1884 #define USE_SETEUID 1
1885 #include "confdefs.h"
1886 #include "${srcdir-.}/lib/util_sec.c"],
1887            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1888 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1889     seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
1890 fi
1891 fi
1892
1893 if test $seteuid = no; then
1894 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1895 AC_TRY_RUN([
1896 #define AUTOCONF_TEST 1
1897 #define USE_SETUIDX 1
1898 #include "confdefs.h"
1899 #include "${srcdir-.}/lib/util_sec.c"],
1900            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1901 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1902     seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
1903 fi
1904 fi
1905
1906
1907 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1908 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1909            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1910 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1911     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
1912 fi
1913
1914 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1915 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1916            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1917 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1918     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
1919 fi
1920
1921 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1922 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1923            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1924 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1925     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
1926 fi
1927
1928 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1929 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1930            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1931 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1932     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
1933
1934 else
1935
1936 dnl
1937 dnl Don't check for 64 bit fcntl locking if we know that the
1938 dnl glibc2.1 broken check has succeeded.
1939 dnl 
1940
1941   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1942   AC_TRY_RUN([
1943 #if defined(HAVE_UNISTD_H)
1944 #include <unistd.h>
1945 #endif
1946 #include <stdio.h>
1947 #include <stdlib.h>
1948
1949 #ifdef HAVE_FCNTL_H
1950 #include <fcntl.h>
1951 #endif
1952
1953 #ifdef HAVE_SYS_FCNTL_H
1954 #include <sys/fcntl.h>
1955 #endif
1956 main() { struct flock64 fl64;
1957 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1958 exit(0);
1959 #else
1960 exit(1);
1961 #endif
1962 }],
1963        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1964
1965   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1966       AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
1967   fi
1968 fi
1969
1970 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1971 AC_TRY_COMPILE([#include <sys/types.h>
1972 #include <sys/stat.h>
1973 #include <unistd.h>],
1974 [struct stat st;  st.st_blocks = 0;],
1975 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1976 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1977     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
1978 fi 
1979
1980 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
1981 AC_TRY_COMPILE([#include <sys/types.h>
1982 #include <sys/stat.h>
1983 #include <unistd.h>],
1984 [struct stat st;  st.st_blksize = 0;],
1985 samba_cv_HAVE_STAT_ST_BLKSIZE=yes,samba_cv_HAVE_STAT_ST_BLKSIZE=no,samba_cv_HAVE_STAT_ST_BLKSIZE=cross)])
1986 if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
1987     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
1988 fi
1989
1990 case "$host_os" in
1991 *linux*)
1992 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1993 AC_TRY_COMPILE([
1994 #ifdef HAVE_SYS_VFS_H
1995 #include <sys/vfs.h>
1996 #endif
1997 #ifdef HAVE_SYS_CAPABILITY_H
1998 #include <sys/capability.h>
1999 #endif
2000 ],[int i;],
2001    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
2002 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
2003    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
2004 fi
2005 ;;
2006 esac
2007
2008 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
2009 AC_TRY_COMPILE([#include <sys/acl.h>
2010 #if defined(HAVE_RPCSVC_NIS_H)
2011 #include <rpcsvc/nis.h>
2012 #endif],
2013 [int i;],
2014 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
2015 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
2016         AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
2017 fi
2018
2019
2020 #################################################
2021 # check for smbwrapper support
2022 AC_MSG_CHECKING(whether to use smbwrapper)
2023 AC_ARG_WITH(smbwrapper,
2024 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
2025 [ case "$withval" in
2026   yes)
2027     AC_MSG_RESULT(yes)
2028     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
2029         WRAPPROG="bin/smbsh\$(EXEEXT)"
2030         WRAP="bin/smbwrapper.$SHLIBEXT"
2031
2032         if test x$ATTEMPT_WRAP32_BUILD = x; then
2033                 WRAP32=""
2034         else
2035                         WRAP32=bin/smbwrapper.32.$SHLIBEXT
2036         fi
2037
2038 # Conditions under which smbwrapper should not be built.
2039
2040         if test x$PICFLAG = x; then
2041            echo No support for PIC code - disabling smbwrapper and smbsh
2042            WRAPPROG=""
2043            WRAP=""
2044            WRAP32=""
2045         elif test x$ac_cv_func_syscall = xno; then
2046            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
2047            WRAPPROG=""
2048            WRAP=""
2049            WRAP32=""
2050         fi
2051         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP $WRAP32"
2052         SMBWRAPPER="$WRAPPROG $WRAP $WRAP32"
2053     ;;
2054   *)
2055     AC_MSG_RESULT(no)
2056     ;;
2057   esac ],
2058   AC_MSG_RESULT(no)
2059 )
2060
2061 #################################################
2062 # check for AFS clear-text auth support
2063 AC_MSG_CHECKING(whether to use AFS clear-text auth)
2064 AC_ARG_WITH(afs,
2065 [  --with-afs              Include AFS clear-text auth support (default=no) ],
2066 [ case "$withval" in
2067   yes)
2068     AC_MSG_RESULT(yes)
2069     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
2070     ;;
2071   *)
2072     AC_MSG_RESULT(no)
2073     ;;
2074   esac ],
2075   AC_MSG_RESULT(no)
2076 )
2077
2078 #################################################
2079 # check for pthread support
2080 AC_MSG_CHECKING(whether to use pthreads)
2081 AC_ARG_WITH(pthreads,
2082 [  --with-pthreads              Include pthreads (default=no) ],
2083 [ case "$withval" in
2084   yes)
2085     AC_MSG_RESULT(yes)
2086     AC_DEFINE(WITH_PTHREADS,1,[Whether to use pthreads])
2087     SMBD_EXTRA_OBJS="smbd/process_thread.o"
2088     SMBD_EXTRA_LIBS="-lpthread"
2089     ;;
2090   *)
2091     AC_MSG_RESULT(no)
2092     ;;
2093   esac ],
2094   AC_MSG_RESULT(no)
2095 )
2096
2097 AC_SUBST(SMBD_EXTRA_OBJS)
2098 AC_SUBST(SMBD_EXTRA_LIBS)
2099
2100
2101 #################################################
2102 # check for STFS NTVFS backend
2103 STFS_ENABLED=#
2104 AC_MSG_CHECKING(whether to use STFS NTVFS backend)
2105 AC_ARG_WITH(stfs,
2106 [  --with-stfs              Include STFS NTVFS backend (default=no) ],
2107 [ case "$withval" in
2108   yes)
2109     AC_MSG_RESULT(yes)
2110     AC_DEFINE(WITH_NTVFS_STFS,1,[Whether to include STFS NTVFS backend])
2111     STFS_ENABLED=
2112     ;;
2113   *)
2114     AC_MSG_RESULT(no)
2115     ;;
2116   esac ],
2117   AC_MSG_RESULT(no)
2118 )
2119
2120 AC_SUBST(STFS_ENABLED)
2121
2122
2123 #################################################
2124 # check for the DFS clear-text auth system
2125 AC_MSG_CHECKING(whether to use DFS clear-text auth)
2126 AC_ARG_WITH(dfs,
2127 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
2128 [ case "$withval" in
2129   yes)
2130     AC_MSG_RESULT(yes)
2131     AC_DEFINE(WITH_DFS,1,[Whether to include DFS support])
2132     ;;
2133   *)
2134     AC_MSG_RESULT(no)
2135     ;;
2136   esac ],
2137   AC_MSG_RESULT(no)
2138 )
2139
2140 #################################################
2141 # active directory support
2142
2143 with_ads_support=yes
2144 AC_MSG_CHECKING([whether to use Active Directory])
2145
2146 AC_ARG_WITH(ads,
2147 [   --with-ads  Active Directory support (default yes)],
2148 [ case "$withval" in
2149     no)
2150         with_ads_support=no
2151         ;;
2152   esac ])
2153
2154 if test x"$with_ads_support" = x"yes"; then
2155    AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
2156 fi
2157
2158 AC_MSG_RESULT($with_ads_support)
2159
2160 FOUND_KRB5=no
2161 if test x"$with_ads_support" = x"yes"; then
2162
2163   #################################################
2164   # check for krb5-config from recent MIT and Heimdal kerberos 5
2165   AC_PATH_PROG(KRB5_CONFIG, krb5-config)
2166   AC_MSG_CHECKING(for working krb5-config)
2167   if test -x "$KRB5_CONFIG"; then
2168     LIBS="$LIBS `$KRB5_CONFIG --libs`"
2169     CFLAGS="$CFLAGS `$KRB5_CONFIG --cflags`" 
2170     CPPFLAGS="$CPPFLAGS `$KRB5_CONFIG --cflags`"
2171     FOUND_KRB5=yes
2172     AC_MSG_RESULT(yes)
2173   else
2174     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
2175   fi
2176   
2177   if test x$FOUND_KRB5 = x"no"; then
2178   #################################################
2179   # check for location of Kerberos 5 install
2180   AC_MSG_CHECKING(for kerberos 5 install path)
2181   AC_ARG_WITH(krb5,
2182   [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
2183   [ case "$withval" in
2184     no)
2185       AC_MSG_RESULT(no)
2186       ;;
2187     *)
2188       AC_MSG_RESULT(yes)
2189       LIBS="$LIBS -lkrb5"
2190       CFLAGS="$CFLAGS -I$withval/include"
2191       CPPFLAGS="$CPPFLAGS -I$withval/include"
2192       LDFLAGS="$LDFLAGS -L$withval/lib"
2193       FOUND_KRB5=yes
2194       ;;
2195     esac ],
2196     AC_MSG_RESULT(no)
2197   )
2198   fi
2199
2200 if test x$FOUND_KRB5 = x"no"; then
2201 #################################################
2202 # see if this box has the SuSE location for the heimdal kerberos implementation
2203 AC_MSG_CHECKING(for /usr/include/heimdal)
2204 if test -d /usr/include/heimdal; then
2205     if test -f /usr/lib/heimdal/lib/libkrb5.a; then
2206         LIBS="$LIBS -lkrb5"
2207         CFLAGS="$CFLAGS -I/usr/include/heimdal"
2208         CPPFLAGS="$CPPFLAGS -I/usr/include/heimdal"
2209         LDFLAGS="$LDFLAGS -L/usr/lib/heimdal/lib"
2210         AC_MSG_RESULT(yes)
2211     else
2212         LIBS="$LIBS -lkrb5"
2213         CFLAGS="$CFLAGS -I/usr/include/heimdal"
2214         CPPFLAGS="$CPPFLAGS -I/usr/include/heimdal"
2215         AC_MSG_RESULT(yes)
2216  
2217     fi
2218 else
2219     AC_MSG_RESULT(no)
2220 fi
2221 fi
2222
2223
2224 if test x$FOUND_KRB5 = x"no"; then
2225 #################################################
2226 # see if this box has the RedHat location for kerberos
2227 AC_MSG_CHECKING(for /usr/kerberos)
2228 if test -d /usr/kerberos -a -f /usr/kerberos/lib/libkrb5.a; then
2229     LIBS="$LIBS -lkrb5"
2230     LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
2231     CFLAGS="$CFLAGS -I/usr/kerberos/include"
2232     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
2233     AC_MSG_RESULT(yes)
2234 else
2235     AC_MSG_RESULT(no)
2236 fi
2237 fi
2238
2239   # now check for krb5.h. Some systems have the libraries without the headers!
2240   # note that this check is done here to allow for different kerberos
2241   # include paths
2242   AC_CHECK_HEADERS(krb5.h)
2243
2244   # now check for gssapi headers.  This is also done here to allow for
2245   # different kerberos include paths
2246   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
2247
2248   ##################################################################
2249   # we might need the k5crypto and com_err libraries on some systems
2250   AC_CHECK_LIB(com_err, _et_list, [LIBS="$LIBS -lcom_err"])
2251   AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"])
2252   # Heimdal checks.
2253   AC_CHECK_LIB(crypto, des_set_key, [LIBS="$LIBS -lcrypto"])
2254   AC_CHECK_LIB(asn1, copy_Authenticator, [LIBS="$LIBS -lasn1 -lroken"])
2255   # Heimdal checks. On static Heimdal gssapi must be linked before krb5.
2256   AC_CHECK_LIB(gssapi, gss_display_status, [LIBS="$LIBS -lgssapi -lkrb5 -lasn1";
2257         AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])])
2258
2259   AC_CHECK_LIB(krb5, krb5_set_real_time, [AC_DEFINE(HAVE_KRB5_SET_REAL_TIME,1,[Whether krb5_set_real_time is available])])
2260   AC_CHECK_LIB(krb5, krb5_set_default_in_tkt_etypes, [AC_DEFINE(HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES,1,[Whether krb5_set_default_in_tkt_etypes, is available])])
2261   AC_CHECK_LIB(krb5, krb5_set_default_tgs_ktypes, [AC_DEFINE(HAVE_KRB5_SET_DEFAULT_TGS_KTYPES,1,[Whether krb5_set_default_tgs_ktypes is available])])
2262
2263   AC_CHECK_LIB(krb5, krb5_principal2salt, [AC_DEFINE(HAVE_KRB5_PRINCIPAL2SALT,1,[Whether krb5_principal2salt is available])])
2264   AC_CHECK_LIB(krb5, krb5_use_enctype, [AC_DEFINE(HAVE_KRB5_USE_ENCTYPE,1,[Whether krb5_use_enctype is available])])
2265   AC_CHECK_LIB(krb5, krb5_string_to_key, [AC_DEFINE(HAVE_KRB5_STRING_TO_KEY,1,[Whether krb5_string_to_key is available])])
2266   AC_CHECK_LIB(krb5, krb5_get_pw_salt, [AC_DEFINE(HAVE_KRB5_GET_PW_SALT,1,[Whether krb5_get_pw_salt is available])])
2267   AC_CHECK_LIB(krb5, krb5_string_to_key_salt, [AC_DEFINE(HAVE_KRB5_STRING_TO_KEY_SALT,1,[Whether krb5_string_to_key_salt is available])])
2268   AC_CHECK_LIB(krb5, krb5_auth_con_setkey, [AC_DEFINE(HAVE_KRB5_AUTH_CON_SETKEY,1,[Whether krb5_auth_con_setkey is available])])
2269   AC_CHECK_LIB(krb5, krb5_auth_con_setuseruserkey, [AC_DEFINE(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY,1,[Whether krb5_auth_con_setuseruserkey is available])])
2270   AC_CHECK_LIB(krb5, krb5_locate_kdc, [AC_DEFINE(HAVE_KRB5_LOCATE_KDC,1,[Whether krb5_locate_kdc is available])])
2271   AC_CHECK_LIB(krb5, krb5_get_permitted_enctypes, [AC_DEFINE(HAVE_KRB5_GET_PERMITTED_ENCTYPES,1,[Whether krb5_get_permitted_enctypes is available])])
2272   AC_CHECK_LIB(krb5, krb5_get_default_in_tkt_etypes, [AC_DEFINE(HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES,1,[Whether krb5_get_default_in_tkt_etypes is available])])
2273   AC_CHECK_LIB(krb5, krb5_free_ktypes, [AC_DEFINE(HAVE_KRB5_FREE_KTYPES,1,[Whether krb5_free_ktypes is available])])
2274
2275 AC_CACHE_CHECK([for addrtype in krb5_address],samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
2276 AC_TRY_COMPILE([#include <krb5.h>],
2277 [krb5_address kaddr; kaddr.addrtype = ADDRTYPE_INET;],
2278 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=yes,samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS=no)])
2279 if test x"$samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS" = x"yes"; then
2280     AC_DEFINE(HAVE_ADDRTYPE_IN_KRB5_ADDRESS,1,[Whether the krb5_address struct has a addrtype property])
2281 fi
2282
2283 AC_CACHE_CHECK([for addr_type in krb5_address],samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,[
2284 AC_TRY_COMPILE([#include <krb5.h>],
2285 [krb5_address kaddr; kaddr.addr_type = KRB5_ADDRESS_INET;],
2286 samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=yes,samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS=no)])
2287 if test x"$samba_cv_HAVE_ADDR_TYPE_IN_KRB5_ADDRESS" = x"yes"; then
2288     AC_DEFINE(HAVE_ADDR_TYPE_IN_KRB5_ADDRESS,1,[Whether the krb5_address struct has a addr_type property])
2289 fi
2290
2291 AC_CACHE_CHECK([for enc_part2 in krb5_ticket],samba_cv_HAVE_KRB5_TKT_ENC_PART2,[
2292 AC_TRY_COMPILE([#include <krb5.h>],
2293 [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
2294 samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
2295 if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
2296     AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,[Whether the krb5_ticket struct has a enc_part2 property])
2297 fi
2298
2299 AC_CACHE_CHECK([for keyvalue in krb5_keyblock],samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
2300 AC_TRY_COMPILE([#include <krb5.h>],
2301 [krb5_keyblock key; key.keyvalue.data = NULL;],
2302 samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=yes,samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE=no)])
2303 if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE" = x"yes"; then
2304     AC_DEFINE(HAVE_KRB5_KEYBLOCK_KEYVALUE,1,[Whether the krb5_keyblock struct has a keyvalue property])
2305 fi
2306
2307 AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
2308 AC_TRY_COMPILE([#include <krb5.h>],
2309 [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC_MD5;],
2310 samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=yes,samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5=no)])
2311 if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes"; then
2312     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,[Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
2313 fi
2314
2315   ########################################################
2316   # now see if we can find the krb5 libs in standard paths
2317   # or as specified above
2318   AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
2319         AC_DEFINE(HAVE_KRB5,1,[Whether KRB5 is available])])
2320
2321   ########################################################
2322   # now see if we can find the gssapi libs in standard paths
2323   AC_CHECK_LIB(gssapi_krb5, gss_display_status, [LIBS="$LIBS -lgssapi_krb5";
2324         AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])])
2325
2326 fi
2327
2328 ########################################################
2329 # Compile with LDAP support?
2330
2331 with_ldap_support=yes
2332 AC_MSG_CHECKING([whether to use LDAP])
2333
2334 AC_ARG_WITH(ldap,
2335 [   --with-ldap  LDAP support (default yes)],
2336 [ case "$withval" in
2337     no)
2338         with_ldap_support=no
2339         ;;
2340   esac ])
2341
2342 AC_MSG_RESULT($with_ldap_support)
2343
2344 if test x"$with_ldap_support" = x"yes"; then
2345
2346   ##################################################################
2347   # we might need the lber lib on some systems. To avoid link errors
2348   # this test must be before the libldap test
2349   AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"])
2350
2351   ########################################################
2352   # now see if we can find the ldap libs in standard paths
2353   if test x$have_ldap != xyes; then
2354   AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
2355         AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])])
2356
2357         ########################################################
2358         # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
2359         # Check found in pam_ldap 145.
2360         AC_CHECK_FUNCS(ldap_set_rebind_proc)
2361         AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, pam_ldap_cv_ldap_set_rebind_proc, [
2362         AC_TRY_COMPILE([
2363         #include <lber.h>
2364         #include <ldap.h>], [ldap_set_rebind_proc(0, 0, 0);], [pam_ldap_cv_ldap_set_rebind_proc=3], [pam_ldap_cv_ldap_set_rebind_proc=2]) ])
2365         AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $pam_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
2366   fi
2367 fi
2368
2369 ########################################################
2370 # Compile with MySQL support?
2371 AM_PATH_MYSQL([0.11.0],[MODULE_MYSQL=bin/mysql.so],[MODULE_MYSQL=])
2372 CFLAGS="$CFLAGS $MYSQL_CFLAGS"
2373 AC_SUBST(MODULE_MYSQL)
2374
2375 ########################################################
2376 # Compile with XML support?
2377 AM_PATH_XML2([2.0.0],[MODULE_XML=bin/xml.so],[MODULE_XML=])
2378 CFLAGS="$CFLAGS $XML_CFLAGS"
2379 AC_SUBST(MODULE_XML)
2380
2381 #################################################
2382 # check for automount support
2383 AC_MSG_CHECKING(whether to use automount)
2384 AC_ARG_WITH(automount,
2385 [  --with-automount        Include automount support (default=no)],
2386 [ case "$withval" in
2387   yes)
2388     AC_MSG_RESULT(yes)
2389     AC_DEFINE(WITH_AUTOMOUNT,1,[Whether to include automount support])
2390     ;;
2391   *)
2392     AC_MSG_RESULT(no)
2393     ;;
2394   esac ],
2395   AC_MSG_RESULT(no)
2396 )
2397
2398 #################################################
2399 # check for smbmount support
2400 AC_MSG_CHECKING(whether to use smbmount)
2401 AC_ARG_WITH(smbmount,
2402 [  --with-smbmount         Include smbmount (Linux only) support (default=no)],
2403 [ case "$withval" in
2404   yes)
2405         case "$host_os" in
2406         *linux*)
2407                 AC_MSG_RESULT(yes)
2408                 AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
2409                 EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
2410                 ;;
2411         *)
2412                 AC_MSG_ERROR(not on a linux system!)
2413                 ;;
2414         esac
2415     ;;
2416   *)
2417     AC_MSG_RESULT(no)
2418     ;;
2419   esac ],
2420   AC_MSG_RESULT(no)
2421 )
2422
2423
2424 #################################################
2425 # check for a PAM clear-text auth, accounts, password and session support
2426 with_pam_for_crypt=no
2427 AC_MSG_CHECKING(whether to use PAM)
2428 AC_ARG_WITH(pam,
2429 [  --with-pam              Include PAM support (default=no)],
2430 [ case "$withval" in
2431   yes)
2432     AC_MSG_RESULT(yes)
2433     AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
2434     AUTHLIBS="$AUTHLIBS -lpam"
2435     with_pam_for_crypt=yes
2436     ;;
2437   *)
2438     AC_MSG_RESULT(no)
2439     ;;
2440   esac ],
2441   AC_MSG_RESULT(no)
2442 )
2443
2444 # we can't build a pam module if we don't have pam.
2445 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
2446
2447 #################################################
2448 # check for pam_smbpass support
2449 AC_MSG_CHECKING(whether to use pam_smbpass)
2450 AC_ARG_WITH(pam_smbpass,
2451 [  --with-pam_smbpass      Build a PAM module to allow other applications to use our smbpasswd file (default=no)],
2452 [ case "$withval" in
2453   yes)
2454     AC_MSG_RESULT(yes)
2455
2456 # Conditions under which pam_smbpass should not be built.
2457
2458        if test x$PICFLAG = x; then
2459           AC_MSG_RESULT([No support for PIC code - disabling pam_smbpass])
2460        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
2461           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
2462        else
2463           SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.so"
2464        fi
2465     ;;
2466   *)
2467     AC_MSG_RESULT(no)
2468     ;;
2469   esac ],
2470   AC_MSG_RESULT(no)
2471 )
2472
2473
2474 ###############################################
2475 # test for where we get crypt() from
2476 AC_SEARCH_LIBS(crypt, [crypt],
2477   [test "$ac_cv_search_crypt" = "none required" || AUTHLIBS="-lcrypt $AUTHLIBS"
2478   AC_DEFINE(HAVE_CRYPT,1,[Whether the system has the crypt() function])])
2479
2480 ##
2481 ## moved after the check for -lcrypt in order to
2482 ## ensure that the necessary libraries are included
2483 ## check checking for truncated salt.  Wrapped by the
2484 ## $with_pam_for_crypt variable as above   --jerry
2485 ##
2486 if test $with_pam_for_crypt = no; then
2487 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
2488 crypt_LIBS="$LIBS"
2489 LIBS="$AUTHLIBS $LIBS"
2490 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
2491         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
2492 LIBS="$crypt_LIBS"])
2493 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
2494         AC_DEFINE(HAVE_TRUNCATED_SALT,1,[Whether crypt needs truncated salt])
2495 fi
2496 fi
2497
2498 # New experimental SAM system
2499
2500 AC_MSG_CHECKING([whether to build the new (experimental) SAM database])
2501 AC_ARG_WITH(sam,
2502 [  --with-sam              Build new (experimental) SAM database (default=no)],
2503 [ case "$withval" in
2504   yes)
2505     AC_MSG_RESULT(yes)
2506     AC_DEFINE(WITH_SAM,1,[Whether to build the new (experimental) SAM database])
2507     ;;
2508   *)
2509     AC_MSG_RESULT(no)
2510     ;;
2511   esac ],
2512   AC_MSG_RESULT(no)
2513 )
2514
2515
2516 ########################################################################################
2517 ##
2518 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
2519 ##
2520 ########################################################################################
2521
2522 #################################################
2523 # check for a LDAP password database configuration backwards compatibility
2524 AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration)
2525 AC_ARG_WITH(ldapsam,
2526 [  --with-ldapsam           Include LDAP SAM 2.2 compatible configuration (default=no)],
2527 [ case "$withval" in
2528   yes)
2529     AC_MSG_RESULT(yes)
2530     AC_DEFINE(WITH_LDAP_SAMCONFIG,1,[Whether to include 2.2 compatibel LDAP SAM configuration])
2531     ;;
2532   *)
2533     AC_MSG_RESULT(no)
2534     ;;
2535   esac ],
2536   AC_MSG_RESULT(no)
2537 )
2538
2539 #################################################
2540 # check for a TDB password database
2541 AC_MSG_CHECKING(whether to use TDB SAM database)
2542 AC_ARG_WITH(tdbsam,
2543 [  --with-tdbsam           Include experimental TDB SAM support (default=no)],
2544 [ case "$withval" in
2545   yes)
2546     AC_MSG_RESULT(yes)
2547     AC_DEFINE(WITH_TDB_SAM,1,[Whether to include experimental TDB SAM support])
2548     ;;
2549   *)
2550     AC_MSG_RESULT(no)
2551     ;;
2552   esac ],
2553   AC_MSG_RESULT(no)
2554 )
2555
2556 #################################################
2557 # check for a NISPLUS password database
2558 AC_MSG_CHECKING(whether to use NISPLUS SAM database)
2559 AC_ARG_WITH(nisplussam,
2560 [  --with-nisplussam       Include NISPLUS SAM support (default=no)],
2561 [ case "$withval" in
2562   yes)
2563     AC_MSG_RESULT(yes)
2564     AC_DEFINE(WITH_NISPLUS_SAM,1,[Whether to include nisplus SAM support])
2565     ;;
2566   *)
2567     AC_MSG_RESULT(no)
2568     ;;
2569   esac ],
2570   AC_MSG_RESULT(no)
2571 )
2572
2573 ########################################################################################
2574 ##
2575 ## END OF TESTS FOR SAM BACKENDS.  
2576 ##
2577 ########################################################################################
2578
2579 #################################################
2580 # check for a NISPLUS_HOME support 
2581 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
2582 AC_ARG_WITH(nisplus-home,
2583 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
2584 [ case "$withval" in
2585   yes)
2586     AC_MSG_RESULT(yes)
2587     AC_DEFINE(WITH_NISPLUS_HOME,1,[Whether to include nisplus_home support])
2588     ;;
2589   *)
2590     AC_MSG_RESULT(no)
2591     ;;
2592   esac ],
2593   AC_MSG_RESULT(no)
2594 )
2595
2596 #################################################
2597 # check for syslog logging
2598 AC_MSG_CHECKING(whether to use syslog logging)
2599 AC_ARG_WITH(syslog,
2600 [  --with-syslog           Include experimental SYSLOG support (default=no)],
2601 [ case "$withval" in
2602   yes)
2603     AC_MSG_RESULT(yes)
2604     AC_DEFINE(WITH_SYSLOG,1,[Whether to include experimental syslog support])
2605     ;;
2606   *)
2607     AC_MSG_RESULT(no)
2608     ;;
2609   esac ],
2610   AC_MSG_RESULT(no)
2611 )
2612
2613
2614 #################################################
2615 # check for experimental disk-quotas support
2616 QUOTAOBJS=smbd/noquotas.o
2617
2618 AC_MSG_CHECKING(whether to support disk-quotas)
2619 AC_ARG_WITH(quotas,
2620 [  --with-quotas           Include experimental disk-quota support (default=no)],
2621 [ case "$withval" in
2622   yes)
2623     AC_MSG_RESULT(yes)
2624     case "$host_os" in
2625       *linux*)
2626         # Check for kernel 2.4.x quota braindamage...
2627         AC_CACHE_CHECK([for linux 2.4.x quota braindamage..],samba_cv_linux_2_4_quota_braindamage, [
2628         AC_TRY_COMPILE([#include <stdio.h>
2629 #include <sys/types.h>
2630 #include <asm/types.h>
2631 #include <linux/quota.h>
2632 #include <mntent.h>
2633 #include <linux/unistd.h>],[struct mem_dqblk D;],
2634       samba_cv_linux_2_4_quota_braindamage=yes,samba_cv_linux_2_4_quota_braindamage=no)])
2635 if test x"$samba_cv_linux_2_4_quota_braindamage" = x"yes"; then
2636         AC_DEFINE(LINUX_QUOTAS_2,1,[linux 2.4.x quota braindamage])
2637 else
2638         AC_DEFINE(LINUX_QUOTAS_1,1,[linux quotas])
2639 fi
2640         ;;
2641       *)
2642         ;;
2643     esac
2644     QUOTAOBJS=smbd/quotas.o
2645     AC_DEFINE(WITH_QUOTAS,1,[Whether to include experimental quota support])
2646     ;;
2647   *)
2648     AC_MSG_RESULT(no)
2649     ;;
2650   esac ],
2651   AC_MSG_RESULT(no)
2652 )
2653 AC_SUBST(QUOTAOBJS)
2654
2655 #################################################
2656 # check for experimental utmp accounting
2657
2658 AC_MSG_CHECKING(whether to support utmp accounting)
2659 AC_ARG_WITH(utmp,
2660 [  --with-utmp             Include experimental utmp accounting (default=no)],
2661 [ case "$withval" in
2662   yes)
2663     AC_MSG_RESULT(yes)
2664     AC_DEFINE(WITH_UTMP,1,[Whether to include experimental utmp accounting])
2665     ;;
2666   *)
2667     AC_MSG_RESULT(no)
2668     ;;
2669   esac ],
2670   AC_MSG_RESULT(no)
2671 )
2672
2673 #################################################
2674 # choose native language(s) of man pages
2675 AC_MSG_CHECKING(chosen man pages' language(s))
2676 AC_ARG_WITH(manpages-langs,
2677 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
2678 [ case "$withval" in
2679   yes|no)
2680     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
2681     manlangs="en"
2682   ;;
2683   *)
2684     manlangs="$withval"
2685   ;;
2686   esac
2687
2688   AC_MSG_RESULT($manlangs)
2689   manlangs=`echo $manlangs | sed "s/,/ /g"`   # replacing commas with spaces to produce a list
2690   AC_SUBST(manlangs)],
2691
2692   [manlangs="en"
2693   AC_MSG_RESULT($manlangs)
2694   AC_SUBST(manlangs)]
2695 )
2696
2697 #################################################
2698 # should we build libsmbclient?
2699
2700 INSTALLCLIENTCMD_SH=:
2701 INSTALLCLIENTCMD_A=:
2702 LIBSMBCLIENT_SHARED=
2703 LIBSMBCLIENT=
2704 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
2705 AC_ARG_WITH(libsmbclient,
2706 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
2707 [ case "$withval" in
2708   no) 
2709      AC_MSG_RESULT(no)
2710      ;;
2711   *)
2712      if test $BLDSHARED = true; then
2713         INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
2714         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
2715         LIBSMBCLIENT=libsmbclient
2716         AC_MSG_RESULT(yes)
2717      else
2718         enable_static=yes
2719         AC_MSG_RESULT(no shared library support -- will supply static library)
2720      fi
2721      if test $enable_static = yes; then
2722         INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
2723         LIBSMBCLIENT=libsmbclient
2724      fi
2725      ;;
2726   esac ],
2727 [
2728 # if unspecified, default is to built it iff possible.
2729   if test $BLDSHARED = true; then
2730      INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
2731      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
2732      LIBSMBCLIENT=libsmbclient
2733      AC_MSG_RESULT(yes)
2734    else
2735      enable_static=yes
2736      AC_MSG_RESULT(no shared library support -- will supply static library)
2737    fi
2738    if test $enable_static = yes; then
2739      INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
2740      LIBSMBCLIENT=libsmbclient
2741   fi]
2742 )
2743
2744
2745 #################################################
2746 # these tests are taken from the GNU fileutils package
2747 AC_CHECKING(how to get filesystem space usage)
2748 space=no
2749
2750 # Test for statvfs64.
2751 if test $space = no; then
2752   # SVR4
2753   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
2754   [AC_TRY_RUN([
2755 #if defined(HAVE_UNISTD_H)
2756 #include <unistd.h>
2757 #endif
2758 #include <sys/types.h>
2759 #include <sys/statvfs.h>
2760   main ()
2761   {
2762     struct statvfs64 fsd;
2763     exit (statvfs64 (".", &fsd));
2764   }],
2765   fu_cv_sys_stat_statvfs64=yes,
2766   fu_cv_sys_stat_statvfs64=no,
2767   fu_cv_sys_stat_statvfs64=cross)])
2768   if test $fu_cv_sys_stat_statvfs64 = yes; then
2769     space=yes
2770     AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
2771   fi
2772 fi
2773
2774 # Perform only the link test since it seems there are no variants of the
2775 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
2776 # because that got a false positive on SCO OSR5.  Adding the declaration
2777 # of a `struct statvfs' causes this test to fail (as it should) on such
2778 # systems.  That system is reported to work fine with STAT_STATFS4 which
2779 # is what it gets when this test fails.
2780 if test $space = no; then
2781   # SVR4
2782   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
2783                  [AC_TRY_LINK([#include <sys/types.h>
2784 #include <sys/statvfs.h>],
2785                               [struct statvfs fsd; statvfs (0, &fsd);],
2786                               fu_cv_sys_stat_statvfs=yes,
2787                               fu_cv_sys_stat_statvfs=no)])
2788   if test $fu_cv_sys_stat_statvfs = yes; then
2789     space=yes
2790     AC_DEFINE(STAT_STATVFS,1,[Whether statvfs() is available])
2791   fi
2792 fi
2793
2794 if test $space = no; then
2795   # DEC Alpha running OSF/1
2796   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
2797   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
2798   [AC_TRY_RUN([
2799 #include <sys/param.h>
2800 #include <sys/types.h>
2801 #include <sys/mount.h>
2802   main ()
2803   {
2804     struct statfs fsd;
2805     fsd.f_fsize = 0;
2806     exit (statfs (".", &fsd, sizeof (struct statfs)));
2807   }],
2808   fu_cv_sys_stat_statfs3_osf1=yes,
2809   fu_cv_sys_stat_statfs3_osf1=no,
2810   fu_cv_sys_stat_statfs3_osf1=no)])
2811   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
2812   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
2813     space=yes
2814     AC_DEFINE(STAT_STATFS3_OSF1,1,[Whether statfs requires 3 arguments])
2815   fi
2816 fi
2817
2818 if test $space = no; then
2819 # AIX
2820   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
2821 member (AIX, 4.3BSD)])
2822   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
2823   [AC_TRY_RUN([
2824 #ifdef HAVE_SYS_PARAM_H
2825 #include <sys/param.h>
2826 #endif
2827 #ifdef HAVE_SYS_MOUNT_H
2828 #include <sys/mount.h>
2829 #endif
2830 #ifdef HAVE_SYS_VFS_H
2831 #include <sys/vfs.h>
2832 #endif
2833   main ()
2834   {
2835   struct statfs fsd;
2836   fsd.f_bsize = 0;
2837   exit (statfs (".", &fsd));
2838   }],
2839   fu_cv_sys_stat_statfs2_bsize=yes,
2840   fu_cv_sys_stat_statfs2_bsize=no,
2841   fu_cv_sys_stat_statfs2_bsize=no)])
2842   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
2843   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
2844     space=yes
2845     AC_DEFINE(STAT_STATFS2_BSIZE,1,[Whether statfs requires two arguments and struct statfs has bsize property])
2846   fi
2847 fi
2848
2849 if test $space = no; then
2850 # SVR3
2851   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
2852   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
2853   [AC_TRY_RUN([#include <sys/types.h>
2854 #include <sys/statfs.h>
2855   main ()
2856   {
2857   struct statfs fsd;
2858   exit (statfs (".", &fsd, sizeof fsd, 0));
2859   }],
2860     fu_cv_sys_stat_statfs4=yes,
2861     fu_cv_sys_stat_statfs4=no,
2862     fu_cv_sys_stat_statfs4=no)])
2863   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
2864   if test $fu_cv_sys_stat_statfs4 = yes; then
2865     space=yes
2866     AC_DEFINE(STAT_STATFS4,1,[Whether statfs requires 4 arguments])
2867   fi
2868 fi
2869
2870 if test $space = no; then
2871 # 4.4BSD and NetBSD
2872   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
2873 member (4.4BSD and NetBSD)])
2874   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
2875   [AC_TRY_RUN([#include <sys/types.h>
2876 #ifdef HAVE_SYS_PARAM_H
2877 #include <sys/param.h>
2878 #endif
2879 #ifdef HAVE_SYS_MOUNT_H
2880 #include <sys/mount.h>
2881 #endif
2882   main ()
2883   {
2884   struct statfs fsd;
2885   fsd.f_fsize = 0;
2886   exit (statfs (".", &fsd));
2887   }],
2888   fu_cv_sys_stat_statfs2_fsize=yes,
2889   fu_cv_sys_stat_statfs2_fsize=no,
2890   fu_cv_sys_stat_statfs2_fsize=no)])
2891   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
2892   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
2893     space=yes
2894         AC_DEFINE(STAT_STATFS2_FSIZE,1,[Whether statfs requires 2 arguments and struct statfs has fsize])
2895   fi
2896 fi
2897
2898 if test $space = no; then
2899   # Ultrix
2900   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
2901   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
2902   [AC_TRY_RUN([#include <sys/types.h>
2903 #ifdef HAVE_SYS_PARAM_H
2904 #include <sys/param.h>
2905 #endif
2906 #ifdef HAVE_SYS_MOUNT_H
2907 #include <sys/mount.h>
2908 #endif
2909 #ifdef HAVE_SYS_FS_TYPES_H
2910 #include <sys/fs_types.h>
2911 #endif
2912   main ()
2913   {
2914   struct fs_data fsd;
2915   /* Ultrix's statfs returns 1 for success,
2916      0 for not mounted, -1 for failure.  */
2917   exit (statfs (".", &fsd) != 1);
2918   }],
2919   fu_cv_sys_stat_fs_data=yes,
2920   fu_cv_sys_stat_fs_data=no,
2921   fu_cv_sys_stat_fs_data=no)])
2922   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2923   if test $fu_cv_sys_stat_fs_data = yes; then
2924     space=yes
2925     AC_DEFINE(STAT_STATFS2_FS_DATA,1,[Whether statfs requires 2 arguments and struct fs_data is available])
2926   fi
2927 fi
2928
2929 #
2930 # As a gating factor for large file support, in order to
2931 # use <4GB files we must have the following minimal support
2932 # available.
2933 # long long, and a 64 bit off_t or off64_t.
2934 # If we don't have all of these then disable large
2935 # file support.
2936 #
2937 AC_MSG_CHECKING([if large file support can be enabled])
2938 AC_TRY_COMPILE([
2939 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2940 #include <sys/types.h>
2941 #else
2942 __COMPILE_ERROR_
2943 #endif
2944 ],
2945 [int i],
2946 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2947 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2948         AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
2949 fi
2950 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
2951
2952 #################################################
2953 # check for ACL support
2954
2955 AC_MSG_CHECKING(whether to support ACLs)
2956 AC_ARG_WITH(acl-support,
2957 [  --with-acl-support      Include ACL support (default=no)],
2958 [ case "$withval" in
2959   yes)
2960
2961         case "$host_os" in
2962         *sysv5*)
2963                 AC_MSG_RESULT(Using UnixWare ACLs)
2964                 AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
2965                 ;;
2966         *solaris*)
2967                 AC_MSG_RESULT(Using solaris ACLs)
2968                 AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
2969                 ;;
2970         *hpux*)
2971                 AC_MSG_RESULT(Using HPUX ACLs)
2972                 AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
2973                 ;;
2974         *irix*)
2975                 AC_MSG_RESULT(Using IRIX ACLs)
2976                 AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
2977                 ;;
2978         *aix*)
2979                 AC_MSG_RESULT(Using AIX ACLs)
2980                 AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
2981                 ;;
2982         *osf*)
2983                 AC_MSG_RESULT(Using Tru64 ACLs)
2984                 AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
2985                 ACLLIBS="$ACLLIBS -lpacl"
2986                 ;;
2987         *)
2988                 AC_CHECK_LIB(acl,acl_get_file,[ACLLIBS="$ACLLIBS -lacl"])
2989                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
2990                 acl_LIBS=$LIBS
2991                 LIBS="$LIBS -lacl"
2992                 AC_TRY_LINK([#include <sys/types.h>
2993 #include <sys/acl.h>],
2994 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
2995 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)
2996                 LIBS=$acl_LIBS])
2997                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
2998                                 AC_MSG_RESULT(Using posix ACLs)
2999                                 AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
3000                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
3001                                 acl_LIBS=$LIBS
3002                                 LIBS="$LIBS -lacl"
3003                                 AC_TRY_LINK([#include <sys/types.h>
3004 #include <sys/acl.h>],
3005 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
3006 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
3007                                 LIBS=$acl_LIBS])
3008                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
3009                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
3010                                 fi
3011                         fi
3012             ;;
3013         esac
3014         ;;
3015   *)
3016     AC_MSG_RESULT(no)
3017     AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
3018     ;;
3019   esac ],
3020   AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
3021   AC_MSG_RESULT(no)
3022 )
3023
3024 #################################################
3025 # check for sendfile support
3026
3027 with_sendfile_support=yes
3028 AC_MSG_CHECKING(whether to check to support sendfile)
3029 AC_ARG_WITH(sendfile-support,
3030 [  --with-sendfile-support      Check for sendfile support (default=yes)],
3031 [ case "$withval" in
3032   yes)
3033
3034         AC_MSG_RESULT(yes);
3035
3036         case "$host_os" in
3037         *linux*)
3038                 AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
3039                 AC_TRY_LINK([#include <sys/sendfile.h>],
3040 [\
3041 int tofd, fromfd;
3042 off64_t offset;
3043 size_t total;
3044 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
3045 ],
3046 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
3047
3048                 AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
3049                 AC_TRY_LINK([#include <sys/sendfile.h>],
3050 [\
3051 int tofd, fromfd;
3052 off_t offset;
3053 size_t total;
3054 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
3055 ],
3056 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
3057
3058 # Try and cope with broken Linux sendfile....
3059                 AC_CACHE_CHECK([for broken linux sendfile support],samba_cv_HAVE_BROKEN_LINUX_SENDFILE,[
3060                 AC_TRY_LINK([\
3061 #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
3062 #undef _FILE_OFFSET_BITS
3063 #endif
3064 #include <sys/sendfile.h>],
3065 [\
3066 int tofd, fromfd;
3067 off_t offset;
3068 size_t total;
3069 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
3070 ],
3071 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
3072
3073         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
3074                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
3075                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
3076                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
3077         elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
3078                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
3079                 AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
3080                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
3081         elif test x"$samba_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
3082                 AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
3083                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
3084         else
3085                 AC_MSG_RESULT(no);
3086         fi
3087
3088         ;;
3089         *freebsd*)
3090                 AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
3091                 AC_TRY_LINK([\
3092 #include <sys/types.h>
3093 #include <unistd.h>
3094 #include <sys/socket.h>
3095 #include <sys/uio.h>],
3096 [\
3097         int fromfd, tofd, ret, total=0;
3098         off_t offset, nwritten;
3099         struct sf_hdtr hdr;
3100         struct iovec hdtrl;
3101         hdr.headers = &hdtrl;
3102         hdr.hdr_cnt = 1;
3103         hdr.trailers = NULL;
3104         hdr.trl_cnt = 0;
3105         hdtrl.iov_base = NULL;
3106         hdtrl.iov_len = 0;
3107         ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
3108 ],
3109 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
3110
3111         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
3112                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() support is available])
3113                 AC_DEFINE(FREEBSD_SENDFILE_API,1,[Whether the FreeBSD sendfile() API is available])
3114                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
3115         else
3116                 AC_MSG_RESULT(no);
3117         fi
3118         ;;
3119
3120         *hpux*)
3121                 AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
3122                 AC_TRY_LINK([\
3123 #include <sys/socket.h>
3124 #include <sys/uio.h>],
3125 [\
3126         int fromfd, tofd;
3127         size_t total=0;
3128         struct iovec hdtrl[2];
3129         ssize_t nwritten;
3130         off64_t offset;
3131
3132         hdtrl[0].iov_base = 0;
3133         hdtrl[0].iov_len = 0;
3134
3135         nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
3136 ],
3137 samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
3138         if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
3139                 AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
3140                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
3141                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
3142         else
3143                 AC_MSG_RESULT(no);
3144         fi
3145
3146                 AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
3147                 AC_TRY_LINK([\
3148 #include <sys/socket.h>
3149 #include <sys/uio.h>],
3150 [\
3151         int fromfd, tofd;
3152         size_t total=0;
3153         struct iovec hdtrl[2];
3154         ssize_t nwritten;
3155         off_t offset;
3156
3157         hdtrl[0].iov_base = 0;
3158         hdtrl[0].iov_len = 0;
3159
3160         nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
3161 ],
3162 samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
3163         if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
3164                 AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
3165                 AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
3166                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
3167         else
3168                 AC_MSG_RESULT(no);
3169         fi
3170         ;;
3171
3172         *solaris*)
3173                 AC_CHECK_LIB(sendfile,sendfilev)
3174                 AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
3175                 AC_TRY_LINK([\
3176 #include <sys/sendfile.h>],
3177 [\
3178         int sfvcnt;
3179         size_t xferred;
3180         struct sendfilevec vec[2];
3181         ssize_t nwritten;
3182         int tofd;
3183
3184         sfvcnt = 2;
3185
3186         vec[0].sfv_fd = SFV_FD_SELF;
3187         vec[0].sfv_flag = 0;
3188         vec[0].sfv_off = 0;
3189         vec[0].sfv_len = 0;
3190
3191         vec[1].sfv_fd = 0;
3192         vec[1].sfv_flag = 0;
3193         vec[1].sfv_off = 0;
3194         vec[1].sfv_len = 0;
3195         nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
3196 ],
3197 samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
3198
3199         if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
3200                 AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
3201                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
3202                 AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
3203         else
3204                 AC_MSG_RESULT(no);
3205         fi
3206
3207                 AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
3208                 AC_TRY_LINK([\
3209 #include <sys/sendfile.h>],
3210 [\
3211         int sfvcnt;
3212         size_t xferred;
3213         struct sendfilevec vec[2];
3214         ssize_t nwritten;
3215         int tofd;
3216
3217         sfvcnt = 2;
3218
3219         vec[0].sfv_fd = SFV_FD_SELF;
3220         vec[0].sfv_flag = 0;
3221         vec[0].sfv_off = 0;
3222         vec[0].sfv_len = 0;
3223
3224         vec[1].sfv_fd = 0;
3225         vec[1].sfv_flag = 0;
3226         vec[1].sfv_off = 0;
3227         vec[1].sfv_len = 0;
3228         nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
3229 ],
3230 samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
3231
3232         if test x"$samba_cv_HAVE_SENDFILEV" = x"yes"; then
3233                 AC_DEFINE(HAVE_SENDFILEV,1,[Whether sendfilev() is available])
3234                 AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the solaris sendfile() API is available])
3235                 AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
3236         else
3237                 AC_MSG_RESULT(no);
3238         fi
3239         ;;
3240
3241         *)
3242         ;;
3243         esac
3244         ;;
3245   *)
3246     AC_MSG_RESULT(no)
3247     ;;
3248   esac ],
3249   AC_MSG_RESULT(yes)
3250 )
3251
3252
3253 #################################################
3254 # Check whether winbind is supported on this platform.  If so we need to
3255 # build and install client programs, sbin programs and shared libraries
3256
3257 AC_MSG_CHECKING(whether to build winbind)
3258
3259 # Initially, the value of $host_os decides whether winbind is supported
3260
3261 case "$host_os" in
3262         *linux*|*irix*)
3263                 HAVE_WINBIND=yes
3264                 ;;
3265         *solaris*)
3266                 HAVE_WINBIND=yes
3267                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
3268                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
3269                 ;;
3270         *hpux11*)
3271                 HAVE_WINBIND=yes
3272                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
3273                 ;;
3274         *)
3275                 HAVE_WINBIND=no
3276                 winbind_no_reason=", unsupported on $host_os"
3277                 ;;
3278 esac
3279
3280 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
3281 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
3282
3283 # Check the setting of --with-winbindd
3284
3285 AC_ARG_WITH(winbind,
3286 [  --with-winbind          Build winbind (default, if supported by OS)],
3287
3288   case "$withval" in
3289         yes)
3290                 HAVE_WINBIND=yes
3291                 ;;
3292         no)
3293                 HAVE_WINBIND=no
3294                 winbind_reason=""
3295                 ;;
3296   esac ],
3297 )
3298
3299 # We need unix domain sockets for winbind
3300
3301 if test x"$HAVE_WINBIND" = x"yes"; then
3302         if test x"$samba_cv_unixsocket" = x"no"; then
3303                 winbind_no_reason=", no unix domain socket support on $host_os"
3304                 HAVE_WINBIND=no
3305         fi
3306 fi
3307
3308 # Display test results
3309
3310 if test x"$HAVE_WINBIND" = x"yes"; then
3311         AC_MSG_RESULT(yes)
3312         AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
3313
3314         EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
3315         EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
3316         if test x"$BLDSHARED" = x"true"; then
3317                 case "$host_os" in
3318                 *irix*)
3319                         SHLIB_PROGS="$SHLIB_PROGS nsswitch/libns_winbind.so"
3320                         ;;
3321                 *)
3322                         SHLIB_PROGS="$SHLIB_PROGS nsswitch/libnss_winbind.so"
3323                         ;;
3324                 esac
3325                 if test x"$with_pam" = x"yes"; then
3326                         SHLIB_PROGS="$SHLIB_PROGS nsswitch/pam_winbind.so"
3327                 fi
3328         fi
3329 else
3330         AC_MSG_RESULT(no$winbind_no_reason)
3331 fi
3332
3333 # Solaris has some extra fields in struct passwd that need to be
3334 # initialised otherwise nscd crashes.  Unfortunately autoconf < 2.50
3335 # doesn't have the AC_CHECK_MEMBER macro which would be handy for checking
3336 # this. 
3337
3338 #AC_CHECK_MEMBER(struct passwd.pw_comment,
3339 #               AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),
3340 #               [#include <pwd.h>])
3341
3342 AC_CACHE_CHECK([whether struct passwd has pw_comment],samba_cv_passwd_pw_comment, [
3343     AC_TRY_COMPILE([#include <pwd.h>],[struct passwd p; p.pw_comment;],
3344         samba_cv_passwd_pw_comment=yes,samba_cv_passwd_pw_comment=no)])
3345 if test x"$samba_cv_passwd_pw_comment" = x"yes"; then
3346    AC_DEFINE(HAVE_PASSWD_PW_COMMENT,1,[Whether struct passwd has pw_comment])
3347 fi
3348
3349 #AC_CHECK_MEMBER(struct passwd.pw_age,
3350 #               AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),
3351 #               [#include <pwd.h>])
3352
3353 AC_CACHE_CHECK([whether struct passwd has pw_age],samba_cv_passwd_pw_age, [
3354     AC_TRY_COMPILE([#include <pwd.h>],[struct passwd p; p.pw_age;],
3355         samba_cv_passwd_pw_age=yes,samba_cv_passwd_pw_age=no)])
3356 if test x"$samba_cv_passwd_pw_age" = x"yes"; then
3357    AC_DEFINE(HAVE_PASSWD_PW_AGE,1,[Whether struct passwd has pw_age])
3358 fi
3359
3360 #################################################
3361 # Check to see if we should use the included popt 
3362
3363 AC_ARG_WITH(included-popt,
3364 [  --with-included-popt    use bundled popt library, not from system],
3365
3366   case "$withval" in
3367         yes)
3368                 INCLUDED_POPT=yes
3369                 ;;
3370         no)
3371                 INCLUDED_POPT=no
3372                 ;;
3373   esac ],
3374 )
3375 if test x"$INCLUDED_POPT" != x"yes"; then
3376     AC_CHECK_LIB(popt, poptGetContext,
3377                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
3378 fi
3379
3380 AC_MSG_CHECKING(whether to use included popt)
3381 if test x"$INCLUDED_POPT" = x"yes"; then
3382     AC_MSG_RESULT(yes)
3383     BUILD_POPT='$(POPT_OBJS)'
3384     FLAGS1="-I$srcdir/popt"
3385 else
3386     AC_MSG_RESULT(no)
3387     LIBS="$LIBS -lpopt"
3388 fi
3389 AC_SUBST(BUILD_POPT)
3390 AC_SUBST(FLAGS1)
3391
3392 #################################################
3393 # Check if the user wants Python
3394
3395 # At the moment, you can use this to set which Python binary to link
3396 # against.  (Libraries built for Python2.2 can't be used by 2.1,
3397 # though they can coexist in different directories.)  In the future
3398 # this might make the Python stuff be built by default.
3399
3400 # Defaulting python breaks the clean target if python isn't installed
3401
3402 PYTHON=
3403
3404 AC_ARG_WITH(python,
3405 [  --with-python=PYTHONNAME  build Python libraries],
3406 [ case "${withval-python}" in
3407   yes)
3408         PYTHON=python
3409         EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
3410         ;;
3411   no)
3412         PYTHON=
3413         ;;
3414   *)
3415         PYTHON=${withval-python}
3416         ;;
3417   esac ])
3418 AC_SUBST(PYTHON)
3419
3420 #################################################
3421 # do extra things if we are running insure
3422
3423 if test "${ac_cv_prog_CC}" = "insure"; then
3424         CPPFLAGS="$CPPFLAGS -D__INSURE__"
3425 fi
3426
3427 #################################################
3428 # final configure stuff
3429
3430 AC_MSG_CHECKING([configure summary])
3431 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
3432            AC_MSG_RESULT(yes),
3433            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
3434            AC_MSG_WARN([cannot run when cross-compiling]))
3435
3436 builddir=`pwd`
3437 AC_SUBST(builddir)
3438
3439 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
3440 LIB_REMOVE_USR_LIB(LDFLAGS)
3441 LIB_REMOVE_USR_LIB(LIBS)
3442
3443 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
3444 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
3445 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
3446
3447 AC_OUTPUT(include/stamp-h Makefile script/findsmb)
3448
3449 #################################################
3450 # Print very concise instructions on building/use
3451 if test "x$enable_dmalloc" = xyes
3452 then
3453         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
3454         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
3455 fi