patch from Alexander Bokovoy needed for dlopen on bsd systems
[samba.git] / source3 / configure.in
1 dnl -*- mode: m4-mode -*-
2 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(include/includes.h)
4 AC_CONFIG_HEADER(include/config.h)
5 # we want to be compatible with older versions of Samba
6 AC_PREFIX_DEFAULT(/usr/local/samba)
7
8 dnl Unique-to-Samba variables we'll be playing with.
9 AC_SUBST(SHELL)
10 AC_SUBST(RUNPROG)
11 AC_SUBST(MPROGS)
12 AC_SUBST(LDSHFLAGS)
13 AC_SUBST(SHLD)
14 AC_SUBST(HOST_OS)
15 AC_SUBST(PAM_MOD)
16 AC_SUBST(WRAP)
17 AC_SUBST(WRAP32)
18 AC_SUBST(PICFLAG)
19 AC_SUBST(PICSUFFIX)
20 AC_SUBST(POBAD_CC)
21 AC_SUBST(SHLIBEXT)
22 AC_SUBST(LIBSMBCLIENT_SHARED)
23
24 # compile with optimisation and without debugging by default
25 CFLAGS="-O ${CFLAGS}"
26
27 AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging [default=no]],
28     [if eval "test x$enable_debug = xyes"; then
29         CFLAGS="${CFLAGS} -g"
30     fi])
31
32 AC_ARG_ENABLE(developer, [  --enable-developer      turn on developer warnings and debugging [default=no]],
33     [if eval "test x$enable_developer = xyes"; then
34         CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
35     fi])
36
37 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer      turn on developer warnings and debugging, except -Wstrict-prototypes [default=no]],
38     [if eval "test x$enable_krb5developer = xyes"; then
39         CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
40     fi])
41
42 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc          enable heap debugging [default=no]])
43
44 if test "x$enable_dmalloc" = xyes
45 then
46         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
47         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
48                   [Define to check invariants around some common functions])
49         LIBS="$LIBS -ldmalloc"  
50 fi
51
52 dnl Checks for programs.
53 AC_PROG_CC
54 AC_PROG_INSTALL
55 AC_PROG_AWK
56
57 dnl needed before AC_TRY_COMPILE
58 AC_ISC_POSIX
59
60 dnl Check if C compiler understands -c and -o at the same time
61 AC_PROG_CC_C_O
62 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
63       BROKEN_CC=
64 else
65       BROKEN_CC=#
66 fi
67 AC_SUBST(BROKEN_CC)
68
69 dnl Check if the C compiler understands volatile (it should, being ANSI).
70 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
71     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
72         samba_cv_volatile=yes,samba_cv_volatile=no)])
73 if test x"$samba_cv_volatile" = x"yes"; then
74    AC_DEFINE(HAVE_VOLATILE)
75 fi
76
77
78 AC_CANONICAL_SYSTEM
79
80 dnl Add #include for broken IRIX header files
81   case "$host_os" in
82         *irix6*) AC_ADD_INCLUDE(<standards.h>)
83         ;;
84 esac
85
86 AC_VALIDATE_CACHE_SYSTEM_TYPE
87
88 DYNEXP=
89
90 #
91 # Config CPPFLAG settings for strange OS's that must be set
92 # before other tests.
93 #
94 case "$host_os" in
95 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
96     *hpux*)
97     
98       AC_PROG_CC_FLAG(Ae)
99       # mmap on HPUX is completely broken...
100       AC_DEFINE(MMAP_BLACKLIST)
101       if test $ac_cv_prog_cc_Ae = yes; then
102         CPPFLAGS="$CPPFLAGS -Ae"
103       fi
104 #
105 # Defines needed for HPUX support.
106 # HPUX has bigcrypt but (sometimes?) doesn't use it for
107 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
108 #
109       case `uname -r` in
110                         *9*|*10*)
111                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
112                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
113                                 AC_DEFINE(_HPUX_SOURCE)
114                                 AC_DEFINE(_POSIX_SOURCE)
115                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1)
116                                 AC_DEFINE(_MAX_ALIGNMENT,4)
117                                 ;;
118                         *11*)
119                                 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
120                                 AC_DEFINE(USE_BOTH_CRYPT_CALLS)
121                                 AC_DEFINE(_HPUX_SOURCE)
122                                 AC_DEFINE(_POSIX_SOURCE)
123                                 AC_DEFINE(_LARGEFILE64_SOURCE)
124                                 AC_DEFINE(_ALIGNMENT_REQUIRED,1)
125                                 AC_DEFINE(_MAX_ALIGNMENT,4)
126                                 ;;
127       esac
128       DYNEXP="-Wl,-E"
129       ;;
130
131 #
132 # CRAY Unicos has broken const handling
133        *unicos*)
134           AC_MSG_RESULT([disabling const])
135           CPPFLAGS="$CPPFLAGS -Dconst="
136           ;;
137         
138 #
139 # AIX4.x doesn't even admit to having large
140 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
141 #
142     *aix4*)
143           AC_MSG_RESULT([enabling large file support])
144       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
145       AC_DEFINE(_LARGE_FILES)
146       ;;    
147 #
148 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
149 # to the existance of large files..
150 # Note that -D_LARGEFILE64_SOURCE is different from the Sun
151 # recommendations on large file support, however it makes the
152 # compile work using gcc 2.7 and 2.8, whereas using the Sun
153 # recommendation makes the compile fail on gcc2.7. JRA.
154 #
155         *solaris*)
156                 case `uname -r` in
157                         5.0*|5.1*|5.2*|5.3*|5.5*)
158                                 AC_MSG_RESULT([no large file support])
159                                 ;;
160                         5.*)
161                         AC_MSG_RESULT([enabling large file support])
162                         if test "$ac_cv_prog_gcc" = yes; then
163                                 ${CC-cc} -v >conftest.c 2>&1
164                                 ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
165                                 rm -fr conftest.c
166                                 case "$ac_cv_gcc_compiler_version_number" in
167                                         *"gcc version 2.6"*|*"gcc version 2.7"*)
168                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
169                                                 AC_DEFINE(_LARGEFILE64_SOURCE)
170                                                 ;;
171                                         *)
172                                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
173                                                 AC_DEFINE(_LARGEFILE64_SOURCE)
174                                                 AC_DEFINE(_FILE_OFFSET_BITS,64)
175                                                 ;;
176                                 esac
177                         else
178                                 DYNEXP="-dc -dp"
179                                 CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
180                                 AC_DEFINE(_LARGEFILE64_SOURCE)
181                                 AC_DEFINE(_FILE_OFFSET_BITS,64)
182                         fi
183                         ;;
184                 esac
185                 ;;
186 #
187 # Tests needed for SINIX large file support.
188 #
189     *sysv4*)
190       if test $host = mips-sni-sysv4 ; then
191         AC_MSG_CHECKING([for LFS support])
192         old_CPPFLAGS="$CPPFLAGS"
193         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
194         AC_TRY_RUN([
195 #include <unistd.h>
196 main () {
197 #if _LFS64_LARGEFILE == 1
198 exit(0);
199 #else
200 exit(1);
201 #endif
202 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
203         CPPFLAGS="$old_CPPFLAGS"
204         if test x$SINIX_LFS_SUPPORT = xyes ; then
205           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
206           AC_DEFINE(_LARGEFILE64_SOURCE)
207           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
208           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
209           LIBS="`getconf LFS64_LIBS` $LIBS"
210         fi
211       AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
212       fi
213     ;;
214
215 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
216 #
217     *linux*)
218         AC_MSG_CHECKING([for LFS support])
219         old_CPPFLAGS="$CPPFLAGS"
220         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
221        AC_TRY_RUN([
222 #include <unistd.h>
223 #include <sys/utsname.h>
224 main() {
225 #if _LFS64_LARGEFILE == 1
226        struct utsname uts;
227        char *release;
228        int major, minor;
229
230        /* Ensure this is glibc 2.2 or higher */
231 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
232        int libc_major = __GLIBC__;
233        int libc_minor = __GLIBC_MINOR__;
234
235        if (libc_major < 2)
236               exit(1);
237        if (libc_minor < 2)
238               exit(1);
239 #endif
240
241        /* Ensure this is kernel 2.4 or higher */
242
243        uname(&uts);
244        release = uts.release;
245        major = atoi(strsep(&release, "."));
246        minor = atoi(strsep(&release, "."));
247
248        if (major > 2 || (major == 2 && minor > 3))
249                exit(0);
250        exit(1);
251 #else
252        exit(1);
253 #endif
254 }
255 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
256         CPPFLAGS="$old_CPPFLAGS"
257         if test x$LINUX_LFS_SUPPORT = xyes ; then
258           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
259           AC_DEFINE(_LARGEFILE64_SOURCE)
260           AC_DEFINE(_FILE_OFFSET_BITS,64)
261           AC_DEFINE(_GNU_SOURCE)
262         fi
263        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
264                 ;;
265
266     *hurd*)
267         AC_MSG_CHECKING([for LFS support])
268         old_CPPFLAGS="$CPPFLAGS"
269         CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
270         AC_TRY_RUN([
271 #include <unistd.h>
272 main () {
273 #if _LFS64_LARGEFILE == 1
274 exit(0);
275 #else
276 exit(1);
277 #endif
278 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
279         CPPFLAGS="$old_CPPFLAGS"
280         if test x$GLIBC_LFS_SUPPORT = xyes ; then
281           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
282           AC_DEFINE(_LARGEFILE64_SOURCE)
283           AC_DEFINE(_GNU_SOURCE)
284         fi
285       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
286     ;;
287
288 esac
289
290 AC_INLINE
291 AC_HEADER_STDC
292 AC_HEADER_DIRENT
293 AC_HEADER_TIME
294 AC_HEADER_SYS_WAIT
295 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
296 AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
297 AC_CHECK_HEADERS(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
298 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
299 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
300 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
301 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
302 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h ldap.h lber.h dlfcn.h)
303
304 #
305 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
306 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
307 #
308 case "$host_os" in
309     *hpux*)
310                 AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
311                         ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
312                 if test x"$ac_cv_header_shadow_h" = x"yes"; then
313                    AC_DEFINE(HAVE_SHADOW_H)
314                 fi
315         ;;
316 esac
317 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
318 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
319 AC_CHECK_HEADERS(stropts.h poll.h)
320 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
321 AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
322
323 # For experimental utmp support (lastlog on some BSD-like systems)
324 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
325  
326 # For quotas on Veritas VxFS filesystems
327 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
328
329 # For quotas on Linux XFS filesystems
330 AC_CHECK_HEADERS(linux/xqm.h)
331
332 AC_CHECK_SIZEOF(int,cross)
333 AC_CHECK_SIZEOF(long,cross)
334 AC_CHECK_SIZEOF(short,cross)
335
336 AC_C_CONST
337 AC_C_INLINE
338 AC_C_BIGENDIAN
339 AC_C_CHAR_UNSIGNED
340
341 AC_TYPE_SIGNAL
342 AC_TYPE_UID_T
343 AC_TYPE_MODE_T
344 AC_TYPE_OFF_T
345 AC_TYPE_SIZE_T
346 AC_TYPE_PID_T
347 AC_STRUCT_ST_RDEV
348 AC_DIRENT_D_OFF
349 AC_CHECK_TYPE(ino_t,unsigned)
350 AC_CHECK_TYPE(loff_t,off_t)
351 AC_CHECK_TYPE(offset_t,loff_t)
352 AC_CHECK_TYPE(ssize_t, int)
353 AC_CHECK_TYPE(wchar_t, unsigned short)
354
355 ############################################
356 # for cups support we need libcups, and a handful of header files
357
358 AC_CHECK_LIB(cups,httpConnect)
359
360 # I wonder if there is a nicer way of doing this?
361
362 if test x"$ac_cv_lib_cups_httpConnect" = x"yes"; then
363         AC_CHECK_HEADERS(cups/cups.h cups/language.h)
364         if test x"$ac_cv_header_cups_cups_h" = x"yes"; then
365                 if test x"$ac_cv_header_cups_language_h" = x"yes"; then
366                         AC_DEFINE(HAVE_CUPS)
367                 fi
368         fi
369 fi
370
371 ############################################
372 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the new VFS code
373 AC_CHECK_FUNCS(dlopen)
374 if test x"$ac_cv_func_dlopen" = x"no"; then
375     AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
376         AC_DEFINE(HAVE_DLOPEN)])
377 fi
378 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
379
380 ############################################
381 # check if the compiler can do immediate structures
382 AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
383     AC_TRY_COMPILE([
384 #include <stdio.h>],
385 [
386    typedef struct {unsigned x;} FOOBAR;
387    #define X_FOOBAR(x) ((FOOBAR) { x })
388    #define FOO_ONE X_FOOBAR(1)
389    FOOBAR f = FOO_ONE;   
390    static struct {
391         FOOBAR y; 
392         } f2[] = {
393                 {FOO_ONE}
394         };   
395 ],
396         samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
397 if test x"$samba_cv_immediate_structures" = x"yes"; then
398    AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES)
399 fi
400
401 ############################################
402 # check for unix domain sockets
403 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
404     AC_TRY_COMPILE([
405 #include <sys/types.h>
406 #include <stdlib.h>
407 #include <stddef.h>
408 #include <sys/socket.h>
409 #include <sys/un.h>],
410 [
411   struct sockaddr_un sunaddr; 
412   sunaddr.sun_family = AF_UNIX;
413 ],
414         samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
415 if test x"$samba_cv_unixsocket" = x"yes"; then
416    AC_DEFINE(HAVE_UNIXSOCKET)
417 fi
418
419
420 AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
421     AC_TRY_COMPILE([
422 #include <sys/types.h>
423 #if STDC_HEADERS
424 #include <stdlib.h>
425 #include <stddef.h>
426 #endif
427 #include <sys/socket.h>],[socklen_t i = 0],
428         samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
429 if test x"$samba_cv_socklen_t" = x"yes"; then
430    AC_DEFINE(HAVE_SOCKLEN_T_TYPE)
431 fi
432
433 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
434     AC_TRY_COMPILE([
435 #include <sys/types.h>
436 #if STDC_HEADERS
437 #include <stdlib.h>
438 #include <stddef.h>
439 #endif
440 #include <signal.h>],[sig_atomic_t i = 0],
441         samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
442 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
443    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE)
444 fi
445
446 # stupid headers have the functions but no declaration. grrrr.
447 AC_HAVE_DECL(errno, [#include <errno.h>])
448 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
449 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
450 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
451 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
452 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
453 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
454
455 # and glibc has setresuid under linux but the function does
456 # nothing until kernel 2.1.44! very dumb.
457 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
458     AC_TRY_RUN([#include <errno.h>
459 main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
460         samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
461 if test x"$samba_cv_have_setresuid" = x"yes"; then
462     AC_DEFINE(HAVE_SETRESUID)
463 fi
464
465 # Do the same check for setresguid...
466 #
467 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
468     AC_TRY_RUN([#include <unistd.h>
469 #include <errno.h>
470 main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
471         samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
472 if test x"$samba_cv_have_setresgid" = x"yes"; then
473     AC_DEFINE(HAVE_SETRESGID)
474 fi
475
476 AC_FUNC_MEMCMP
477
478 ###############################################
479 # test for where we get crypt() from
480 AC_CHECK_FUNCS(crypt)
481 if test x"$ac_cv_func_crypt" = x"no"; then
482     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
483         AC_DEFINE(HAVE_CRYPT)])
484 fi
485
486
487 ###############################################
488 # Readline included by default unless explicitly asked not to
489 test "${with_readline+set}" != "set" && with_readline=yes
490
491 # test for where we get readline() from
492 AC_MSG_CHECKING(whether to use readline)
493 AC_ARG_WITH(readline,
494 [  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto) ],
495 [  case "$with_readline" in
496   yes)
497     AC_MSG_RESULT(yes)
498
499     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
500     AC_CHECK_HEADERS(readline/history.h)
501
502     AC_CHECK_HEADERS(readline.h readline/readline.h,[
503       for termlib in ncurses curses termcap terminfo termlib; do
504        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
505       done
506       AC_CHECK_LIB(readline, rl_callback_handler_install,
507        [TERMLIBS="-lreadline $TERMLIBS"
508        AC_DEFINE(HAVE_LIBREADLINE)
509        break], [TERMLIBS=], $TERMLIBS)])
510     ;;
511   no)
512     AC_MSG_RESULT(no)
513     ;;
514   *)
515     AC_MSG_RESULT(yes)
516
517     # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
518     # alternate readline path
519     _ldflags=${LDFLAGS}
520     _cppflags=${CPPFLAGS}
521
522     # Add additional search path
523     LDFLAGS="-L$with_readline/lib $LDFLAGS"
524     CPPFLAGS="-I$with_readline/include $CPPFLAGS"
525
526     AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
527     AC_CHECK_HEADERS(readline/history.h)
528
529     AC_CHECK_HEADERS(readline.h readline/readline.h,[
530       for termlib in ncurses curses termcap terminfo termlib; do
531        AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
532       done
533       AC_CHECK_LIB(readline, rl_callback_handler_install,
534        [TERMLDFLAGS="-L$with_readline/lib"
535        TERMCPPFLAGS="-I$with_readline/include"
536        CPPFLAGS="-I$with_readline/include $CPPFLAGS"
537        TERMLIBS="-lreadline $TERMLIBS"
538        AC_DEFINE(HAVE_LIBREADLINE)
539        break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
540
541     LDFLAGS=$_ldflags
542     ;;
543   esac],
544   AC_MSG_RESULT(no)
545 )
546 AC_SUBST(TERMLIBS)
547 AC_SUBST(TERMLDFLAGS)
548
549 # The readline API changed slightly from readline3 to readline4, so
550 # code will generate warnings on one of them unless we have a few
551 # special cases.
552 AC_CHECK_LIB(readline, rl_completion_matches,
553              [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
554                         [Do we have rl_completion_matches?])],
555              [],
556              [$TERMLIBS])
557
558 # The following test taken from the cvs sources
559 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
560 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
561 # libsocket.so which has a bad implementation of gethostbyname (it
562 # only looks in /etc/hosts), so we only look for -lsocket if we need
563 # it.
564 AC_CHECK_FUNCS(connect)
565 if test x"$ac_cv_func_connect" = x"no"; then
566     case "$LIBS" in
567     *-lnsl*) ;;
568     *) AC_CHECK_LIB(nsl_s, printf) ;;
569     esac
570     case "$LIBS" in
571     *-lnsl*) ;;
572     *) AC_CHECK_LIB(nsl, printf) ;;
573     esac
574     case "$LIBS" in
575     *-lsocket*) ;;
576     *) AC_CHECK_LIB(socket, connect) ;;
577     esac
578     case "$LIBS" in
579     *-linet*) ;;
580     *) AC_CHECK_LIB(inet, connect) ;;
581     esac
582     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
583     dnl has been cached.
584     if test x"$ac_cv_lib_socket_connect" = x"yes" || 
585        test x"$ac_cv_lib_inet_connect" = x"yes"; then
586         # ac_cv_func_connect=yes
587         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
588         AC_DEFINE(HAVE_CONNECT)
589     fi
590 fi
591
592 ###############################################
593 # test for where we get get_yp_default_domain() from
594 AC_CHECK_FUNCS(yp_get_default_domain)
595 if test x"$ac_cv_func_yp_get_default_domain" = x"no"; then
596         AC_CHECK_LIB(nsl, yp_get_default_domain, [LIBS="$LIBS -lnsl";
597         AC_DEFINE(HAVE_YP_GET_DEFAULT_DOMAIN)]) 
598 fi
599
600 # Check if we have execl, if not we need to compile smbrun.
601 AC_CHECK_FUNCS(execl)
602 if test x"$ac_cv_func_execl" = x"no"; then
603     RUNPROG="bin/smbrun"
604 else
605     RUNPROG=""
606 fi
607
608 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
609 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
610 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
611 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
612 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
613 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
614 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
615 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
616 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
617 AC_CHECK_FUNCS(syslog vsyslog)
618 # setbuffer is needed for smbtorture
619 AC_CHECK_FUNCS(setbuffer)
620
621 # syscall() is needed for smbwrapper.
622 AC_CHECK_FUNCS(syscall)
623
624 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
625 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
626 AC_CHECK_FUNCS(__getcwd _getcwd)
627 AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
628 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
629 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
630 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
631 AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
632 AC_CHECK_FUNCS(_write __write _fork __fork)
633 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
634 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
635 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
636 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
637 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
638
639 #
640 # stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
641 #
642
643 if test x$ac_cv_func_stat64 = xno ; then
644   AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
645   AC_TRY_LINK([
646 #if defined(HAVE_UNISTD_H)
647 #include <unistd.h>
648 #endif
649 #include <sys/stat.h>
650 ], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
651   AC_MSG_RESULT([$ac_cv_func_stat64])
652   if test x$ac_cv_func_stat64 = xyes ; then
653     AC_DEFINE(HAVE_STAT64)
654   fi
655 fi
656
657 if test x$ac_cv_func_lstat64 = xno ; then
658   AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
659   AC_TRY_LINK([
660 #if defined(HAVE_UNISTD_H)
661 #include <unistd.h>
662 #endif
663 #include <sys/stat.h>
664 ], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
665   AC_MSG_RESULT([$ac_cv_func_lstat64])
666   if test x$ac_cv_func_lstat64 = xyes ; then
667     AC_DEFINE(HAVE_LSTAT64)
668   fi
669 fi
670
671 if test x$ac_cv_func_fstat64 = xno ; then
672   AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
673   AC_TRY_LINK([
674 #if defined(HAVE_UNISTD_H)
675 #include <unistd.h>
676 #endif
677 #include <sys/stat.h>
678 ], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
679   AC_MSG_RESULT([$ac_cv_func_fstat64])
680   if test x$ac_cv_func_fstat64 = xyes ; then
681     AC_DEFINE(HAVE_FSTAT64)
682   fi
683 fi
684
685 #####################################
686 # we might need the resolv library on some systems
687 AC_CHECK_LIB(resolv, dn_expand)
688
689 #
690 # Check for the functions putprpwnam, set_auth_parameters,
691 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
692 # Needed for OSF1 and HPUX.
693 #
694
695 AC_LIBTESTFUNC(security, putprpwnam)
696 AC_LIBTESTFUNC(sec, putprpwnam)
697
698 AC_LIBTESTFUNC(security, set_auth_parameters)
699 AC_LIBTESTFUNC(sec, set_auth_parameters)
700
701 # UnixWare 7.x has its getspnam in -lgen
702 AC_LIBTESTFUNC(gen, getspnam)
703
704 AC_LIBTESTFUNC(security, getspnam)
705 AC_LIBTESTFUNC(sec, getspnam)
706
707 AC_LIBTESTFUNC(security, bigcrypt)
708 AC_LIBTESTFUNC(sec, bigcrypt)
709
710 AC_LIBTESTFUNC(security, getprpwnam)
711 AC_LIBTESTFUNC(sec, getprpwnam)
712
713 # this bit needs to be modified for each OS that is suported by
714 # smbwrapper. You need to specify how to created a shared library and
715 # how to compile C code to produce PIC object files
716
717 # these are the defaults, good for lots of systems
718 HOST_OS="$host_os"
719 LDSHFLAGS="-shared"
720 SHLD="\${CC}"
721 PICFLAG=""
722 PICSUFFIX="po"
723 POBAD_CC="#"
724 SHLIBEXT="so"
725 # Assume non-shared by default and override below
726 BLDSHARED="false"
727 AC_MSG_CHECKING([ability to build shared libraries])
728
729 # and these are for particular systems
730 case "$host_os" in
731                 *linux*)   AC_DEFINE(LINUX)
732                         BLDSHARED="true"
733                         LDSHFLAGS="-shared" 
734                         DYNEXP="-Wl,--export-dynamic"
735                         PICFLAG="-fPIC"
736                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
737                 ;;
738                 *solaris*) 
739                         AC_DEFINE(SUNOS5)
740                         BLDSHARED="true"
741                         LDSHFLAGS="-h \$@ -G"
742                         if test "${ac_cv_prog_CC}" = "gcc"; then
743                                 PICFLAG="-fPIC"
744                         else
745                                 PICFLAG="-KPIC"
746                                 POBAD_CC=""
747                                 PICSUFFIX="po.o"
748                         fi
749                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
750                 ;;
751                 *sunos*) AC_DEFINE(SUNOS4)
752                         BLDSHARED="true"
753                         LDSHFLAGS="-Wl,-h,\$@ -G"
754                         PICFLAG="-KPIC"   # Is this correct for SunOS
755                 ;;
756                 *bsd*)  BLDSHARED="true"
757                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
758                         PICFLAG="-fPIC"
759                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
760                 ;;
761                 *irix*) AC_DEFINE(IRIX)
762                         case "$host_os" in
763                         *irix6*) AC_DEFINE(IRIX6)
764                         ;;
765                         esac
766                         ATTEMPT_WRAP32_BUILD=yes
767                         BLDSHARED="true"
768                         LDSHFLAGS="-soname \$@ -shared"
769                         SHLD="\${LD}"
770                         if test "${ac_cv_prog_CC}" = "gcc"; then
771                                 PICFLAG="-fPIC"
772                         else 
773                                 PICFLAG="-KPIC"
774                         fi
775                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
776                 ;;
777                 *aix*) AC_DEFINE(AIX)
778                         BLDSHARED="true"
779                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
780                         PICFLAG="-O2 -qmaxmem=6000"
781                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE)
782                 ;;
783                 *hpux*) AC_DEFINE(HPUX)
784                         SHLIBEXT="sl"
785                         # Use special PIC flags for the native HP-UX compiler.
786                         if test $ac_cv_prog_cc_Ae = yes; then
787                                 SHLD="/usr/bin/ld"
788                                 BLDSHARED="true"
789                                 LDSHFLAGS="-B symbolic -b -z +h \$@"
790                                 PICFLAG="+z"
791                         fi
792                         DYNEXP="-Wl,-E"
793                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192)
794                 ;;
795                 *qnx*) AC_DEFINE(QNX);;
796                 *osf*) AC_DEFINE(OSF1)
797                         BLDSHARED="true"
798                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
799                         PICFLAG="-fPIC"
800                 ;;
801                 *sco*) 
802                         AC_DEFINE(SCO)
803                 ;;
804                 *unixware*) AC_DEFINE(UNIXWARE)
805                         BLDSHARED="true"
806                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
807                         PICFLAG="-KPIC"
808                 ;;
809                 *next2*) AC_DEFINE(NEXT2);;
810                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
811                 *sysv4*)
812                         case "$host" in
813                                 *-univel-*)
814                                         if [ test "$GCC" != yes ]; then
815                                                 AC_DEFINE(HAVE_MEMSET)
816                                         fi
817                                         LDSHFLAGS="-G"
818                                         DYNEXP="-Bexport"
819                                 ;;
820                                 *mips-sni-sysv4*)
821                                         AC_DEFINE(RELIANTUNIX)
822                                 ;;
823                         esac
824                 ;;
825
826                 *sysv5*)
827                         if [ test "$GCC" != yes ]; then
828                                 AC_DEFINE(HAVE_MEMSET)
829                         fi
830                         LDSHFLAGS="-G"
831                 ;;
832 esac
833 AC_SUBST(DYNEXP)
834 AC_MSG_RESULT($BLDSHARED)
835 AC_MSG_CHECKING([linker flags for shared libraries])
836 AC_MSG_RESULT([$LDSHFLAGS])
837 AC_MSG_CHECKING([compiler flags for position-independent code])
838 AC_MSG_RESULT([$PICFLAGS])
839
840 #######################################################
841 # test whether building a shared library actually works
842 if test $BLDSHARED = true; then
843 AC_CACHE_CHECK([whether building shared libraries actually works], 
844                [ac_cv_shlib_works],[
845    ac_cv_shlib_works=no
846    # try building a trivial shared library
847    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/tests/shlib.c &&
848      $CC $CPPFLAGS $CFLAGS $LDSHFLAGS -o shlib.so shlib.po &&
849      ac_cv_shlib_works=yes
850    rm -f shlib.so shlib.po
851 ])
852 if test $ac_cv_shlib_works = no; then
853    BLDSHARED=false
854 fi
855 fi
856
857
858 # this updates our target list if we can build shared libs
859 if test $BLDSHARED = true; then
860    LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
861 else
862    LIBSMBCLIENT_SHARED=
863 fi
864
865 ################
866
867 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
868 AC_TRY_RUN([#include <stdio.h>
869 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
870 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
871 if test x"$samba_cv_have_longlong" = x"yes"; then
872     AC_DEFINE(HAVE_LONGLONG)
873 fi
874
875 #
876 # Check if the compiler supports the LL prefix on long long integers.
877 # AIX needs this.
878
879 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
880     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
881         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
882 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
883    AC_DEFINE(COMPILER_SUPPORTS_LL)
884 fi
885
886   
887 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
888 AC_TRY_RUN([#include <stdio.h>
889 #include <sys/stat.h>
890 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
891 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
892 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
893     AC_DEFINE(SIZEOF_OFF_T,8)
894 fi
895
896 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
897 AC_TRY_RUN([
898 #if defined(HAVE_UNISTD_H)
899 #include <unistd.h>
900 #endif
901 #include <stdio.h>
902 #include <sys/stat.h>
903 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
904 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
905 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
906     AC_DEFINE(HAVE_OFF64_T)
907 fi
908
909 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
910 AC_TRY_RUN([#include <stdio.h>
911 #include <sys/stat.h>
912 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
913 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
914 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
915     AC_DEFINE(SIZEOF_INO_T,8)
916 fi
917
918 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
919 AC_TRY_RUN([
920 #if defined(HAVE_UNISTD_H)
921 #include <unistd.h>
922 #endif
923 #include <stdio.h>
924 #include <sys/stat.h>
925 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
926 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
927 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
928     AC_DEFINE(HAVE_INO64_T)
929 fi
930
931 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
932 AC_TRY_RUN([
933 #if defined(HAVE_UNISTD_H)
934 #include <unistd.h>
935 #endif
936 #include <stdio.h>
937 #include <sys/stat.h>
938 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
939 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
940 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
941     AC_DEFINE(HAVE_DEV64_T)
942 fi
943
944 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
945 AC_TRY_COMPILE([
946 #if defined(HAVE_UNISTD_H)
947 #include <unistd.h>
948 #endif
949 #include <sys/types.h>
950 #include <dirent.h>],
951 [struct dirent64 de;],
952 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
953 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes"; then
954     AC_DEFINE(HAVE_STRUCT_DIRENT64)
955 fi
956
957 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
958 AC_TRY_RUN([
959 #if defined(HAVE_UNISTD_H)
960 #include <unistd.h>
961 #endif
962 #include <sys/types.h>
963 main() { dev_t dev; int i = major(dev); return 0; }],
964 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
965 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
966     AC_DEFINE(HAVE_DEVICE_MAJOR_FN)
967 fi
968
969 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
970 AC_TRY_RUN([
971 #if defined(HAVE_UNISTD_H)
972 #include <unistd.h>
973 #endif
974 #include <sys/types.h>
975 main() { dev_t dev; int i = minor(dev); return 0; }],
976 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
977 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
978     AC_DEFINE(HAVE_DEVICE_MINOR_FN)
979 fi
980
981 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
982 AC_TRY_RUN([#include <stdio.h>
983 main() { char c; c=250; exit((c > 0)?0:1); }],
984 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
985 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
986     AC_DEFINE(HAVE_UNSIGNED_CHAR)
987 fi
988
989 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
990 AC_TRY_COMPILE([#include <sys/types.h>
991 #include <sys/socket.h>
992 #include <netinet/in.h>],
993 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
994 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
995 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
996     AC_DEFINE(HAVE_SOCK_SIN_LEN)
997 fi
998
999 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
1000 AC_TRY_COMPILE([#include <sys/types.h>
1001 #include <dirent.h>
1002 void seekdir(DIR *d, long loc) { return; }],[return 0;],
1003 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
1004 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
1005     AC_DEFINE(SEEKDIR_RETURNS_VOID)
1006 fi
1007
1008 AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
1009 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
1010 samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
1011 if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
1012     AC_DEFINE(HAVE_FILE_MACRO)
1013 fi
1014
1015 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
1016 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
1017 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
1018 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
1019     AC_DEFINE(HAVE_FUNCTION_MACRO)
1020 fi
1021
1022 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
1023 AC_TRY_RUN([
1024 #include <sys/time.h>
1025 #include <unistd.h>
1026 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
1027            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
1028 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
1029     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
1030 fi
1031
1032 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
1033 AC_TRY_RUN([
1034 #include <sys/types.h>
1035 #include <stdarg.h>
1036 void foo(const char *format, ...) { 
1037        va_list ap;
1038        int len;
1039        char buf[5];
1040
1041        va_start(ap, format);
1042        len = vsnprintf(buf, 0, format, ap);
1043        va_end(ap);
1044        if (len != 5) exit(1);
1045
1046        va_start(ap, format);
1047        len = vsnprintf(0, 0, format, ap);
1048        va_end(ap);
1049        if (len != 5) exit(1);
1050
1051        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
1052
1053        exit(0);
1054 }
1055 main() { foo("hello"); }
1056 ],
1057 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1058 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1059     AC_DEFINE(HAVE_C99_VSNPRINTF)
1060 fi
1061
1062 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1063 AC_TRY_RUN([#include <sys/types.h>
1064 #include <dirent.h>
1065 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1066 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1067 di->d_name[0] == 0) exit(0); exit(1);} ],
1068 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1069 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1070     AC_DEFINE(HAVE_BROKEN_READDIR)
1071 fi
1072
1073 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1074 AC_TRY_COMPILE([#include <sys/types.h>
1075 #include <utime.h>],
1076 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1077 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1078 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1079     AC_DEFINE(HAVE_UTIMBUF)
1080 fi
1081
1082 dnl  utmp and utmpx come in many flavours
1083 dnl  We need to check for many of them
1084 dnl  But we don't need to do each and every one, because our code uses
1085 dnl  mostly just the utmp (not utmpx) fields.
1086
1087 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1088
1089 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1090 AC_TRY_COMPILE([#include <sys/types.h>
1091 #include <utmp.h>],
1092 [struct utmp ut;  ut.ut_name[0] = 'a';],
1093 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1094 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1095     AC_DEFINE(HAVE_UT_UT_NAME)
1096 fi 
1097
1098 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1099 AC_TRY_COMPILE([#include <sys/types.h>
1100 #include <utmp.h>],
1101 [struct utmp ut;  ut.ut_user[0] = 'a';],
1102 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1103 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1104     AC_DEFINE(HAVE_UT_UT_USER)
1105 fi 
1106
1107 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1108 AC_TRY_COMPILE([#include <sys/types.h>
1109 #include <utmp.h>],
1110 [struct utmp ut;  ut.ut_id[0] = 'a';],
1111 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1112 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1113     AC_DEFINE(HAVE_UT_UT_ID)
1114 fi 
1115
1116 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1117 AC_TRY_COMPILE([#include <sys/types.h>
1118 #include <utmp.h>],
1119 [struct utmp ut;  ut.ut_host[0] = 'a';],
1120 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1121 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1122     AC_DEFINE(HAVE_UT_UT_HOST)
1123 fi 
1124
1125 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1126 AC_TRY_COMPILE([#include <sys/types.h>
1127 #include <utmp.h>],
1128 [struct utmp ut;  time_t t; ut.ut_time = t;],
1129 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1130 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1131     AC_DEFINE(HAVE_UT_UT_TIME)
1132 fi 
1133
1134 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1135 AC_TRY_COMPILE([#include <sys/types.h>
1136 #include <utmp.h>],
1137 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1138 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1139 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1140     AC_DEFINE(HAVE_UT_UT_TV)
1141 fi 
1142
1143 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1144 AC_TRY_COMPILE([#include <sys/types.h>
1145 #include <utmp.h>],
1146 [struct utmp ut;  ut.ut_type = 0;],
1147 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1148 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1149     AC_DEFINE(HAVE_UT_UT_TYPE)
1150 fi 
1151
1152 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1153 AC_TRY_COMPILE([#include <sys/types.h>
1154 #include <utmp.h>],
1155 [struct utmp ut;  ut.ut_pid = 0;],
1156 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1157 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1158     AC_DEFINE(HAVE_UT_UT_PID)
1159 fi 
1160
1161 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1162 AC_TRY_COMPILE([#include <sys/types.h>
1163 #include <utmp.h>],
1164 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1165 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1166 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1167     AC_DEFINE(HAVE_UT_UT_EXIT)
1168 fi 
1169
1170 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1171 AC_TRY_COMPILE([#include <sys/types.h>
1172 #include <utmp.h>],
1173 [struct utmp ut;  ut.ut_addr = 0;],
1174 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1175 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1176     AC_DEFINE(HAVE_UT_UT_ADDR)
1177 fi 
1178
1179 if test x$ac_cv_func_pututline = xyes ; then
1180   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1181   AC_TRY_COMPILE([#include <sys/types.h>
1182 #include <utmp.h>],
1183   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1184   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1185   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1186       AC_DEFINE(PUTUTLINE_RETURNS_UTMP)
1187   fi
1188 fi
1189
1190 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1191 AC_TRY_COMPILE([#include <sys/types.h>
1192 #include <utmpx.h>],
1193 [struct utmpx ux;  ux.ut_syslen = 0;],
1194 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1195 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1196     AC_DEFINE(HAVE_UX_UT_SYSLEN)
1197 fi 
1198
1199
1200 #################################################
1201 # check for libiconv support
1202 AC_MSG_CHECKING(whether to use libiconv)
1203 AC_ARG_WITH(libiconv,
1204 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1205 [ case "$withval" in
1206   no)
1207     AC_MSG_RESULT(no)
1208     ;;
1209   *)
1210     AC_MSG_RESULT(yes)
1211     CFLAGS="$CFLAGS -I$withval/include"
1212     LDFLAGS="$LDFLAGS -L$withval/lib"
1213     AC_CHECK_LIB(iconv, iconv_open)
1214     AC_DEFINE_UNQUOTED(WITH_LIBICONV, "${withval}")
1215     ;;
1216   esac ],
1217   AC_MSG_RESULT(no)
1218 )
1219
1220
1221 ############
1222 # check for iconv in libc
1223 AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1224 AC_TRY_RUN([
1225 #include <iconv.h>
1226 main() {
1227        iconv_t cd = iconv_open("ASCII", "UCS-2LE");
1228        if (cd == 0 || cd == (iconv_t)-1) return -1;
1229        return 0;
1230 }
1231 ],
1232 samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
1233 if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1234     AC_DEFINE(HAVE_NATIVE_ICONV)
1235 fi
1236
1237
1238 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1239 AC_TRY_RUN([
1240 #include <sys/types.h>
1241 #include <fcntl.h>
1242 #ifndef F_GETLEASE
1243 #define F_GETLEASE      1025
1244 #endif
1245 main() {
1246        int fd = open("/dev/null", O_RDONLY);
1247        return fcntl(fd, F_GETLEASE, 0) == -1;
1248 }
1249 ],
1250 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1251 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1252     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX)
1253 fi
1254
1255 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1256 AC_TRY_RUN([
1257 #include <sys/types.h>
1258 #include <fcntl.h>
1259 #include <signal.h>
1260 #ifndef F_NOTIFY
1261 #define F_NOTIFY 1026
1262 #endif
1263 main() {
1264         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1265 }
1266 ],
1267 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1268 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1269     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY)
1270 fi
1271
1272 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1273 AC_TRY_RUN([
1274 #include <sys/types.h>
1275 #include <fcntl.h>
1276 #include <signal.h>
1277 #include <sys/file.h>
1278 #ifndef LOCK_MAND
1279 #define LOCK_MAND       32
1280 #define LOCK_READ       64
1281 #endif
1282 main() {
1283         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1284 }
1285 ],
1286 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1287 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1288     AC_DEFINE(HAVE_KERNEL_SHARE_MODES)
1289 fi
1290
1291
1292
1293
1294 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1295 AC_TRY_COMPILE([#include <sys/types.h>
1296 #include <fcntl.h>],
1297 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1298 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1299 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1300     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX)
1301 fi
1302
1303 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1304 AC_TRY_RUN([#include <sys/types.h>
1305 #include <sys/capability.h>
1306 main() {
1307  cap_t cap;
1308  if ((cap = cap_get_proc()) == NULL)
1309    exit(1);
1310  cap->cap_effective |= CAP_NETWORK_MGT;
1311  cap->cap_inheritable |= CAP_NETWORK_MGT;
1312  cap_set_proc(cap);
1313  exit(0);
1314 }
1315 ],
1316 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1317 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1318     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES)
1319 fi
1320
1321 #
1322 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1323 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1324 #
1325
1326 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1327 AC_TRY_COMPILE([#include <sys/types.h>
1328 #if defined(HAVE_RPC_RPC_H)
1329 #include <rpc/rpc.h>
1330 #endif],
1331 [int16 testvar;],
1332 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1333 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1334     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H)
1335 fi
1336
1337 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1338 AC_TRY_COMPILE([#include <sys/types.h>
1339 #if defined(HAVE_RPC_RPC_H)
1340 #include <rpc/rpc.h>
1341 #endif],
1342 [uint16 testvar;],
1343 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1344 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1345     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H)
1346 fi
1347
1348 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1349 AC_TRY_COMPILE([#include <sys/types.h>
1350 #if defined(HAVE_RPC_RPC_H)
1351 #include <rpc/rpc.h>
1352 #endif],
1353 [int32 testvar;],
1354 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1355 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1356     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H)
1357 fi
1358
1359 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1360 AC_TRY_COMPILE([#include <sys/types.h>
1361 #if defined(HAVE_RPC_RPC_H)
1362 #include <rpc/rpc.h>
1363 #endif],
1364 [uint32 testvar;],
1365 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1366 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1367     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H)
1368 fi
1369
1370 dnl
1371 dnl Some systems (SCO) have a problem including
1372 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1373 dnl as a #define in <prot.h> and as part of an enum
1374 dnl in <rpc/rpc.h>.
1375 dnl
1376
1377 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1378 AC_TRY_COMPILE([#include <sys/types.h>
1379 #ifdef HAVE_SYS_SECURITY_H
1380 #include <sys/security.h>
1381 #include <prot.h>
1382 #endif  /* HAVE_SYS_SECURITY_H */
1383 #if defined(HAVE_RPC_RPC_H)
1384 #include <rpc/rpc.h>
1385 #endif],
1386 [int testvar;],
1387 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1388 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1389     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT)
1390 fi
1391
1392 AC_MSG_CHECKING([for test routines])
1393 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1394            AC_MSG_RESULT(yes),
1395            AC_MSG_ERROR([cant find test code. Aborting config]),
1396            AC_MSG_WARN([cannot run when cross-compiling]))
1397
1398 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1399 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1400            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1401 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1402     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
1403 fi
1404
1405 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1406 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1407            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1408            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1409            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1410 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1411 then
1412     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1413 fi
1414
1415 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1416 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1417            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1418 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1419     AC_DEFINE(HAVE_BROKEN_GETGROUPS)
1420 fi
1421
1422 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1423 SAVE_CPPFLAGS="$CPPFLAGS"
1424 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/smbwrapper"
1425 AC_TRY_COMPILE([
1426 #define REPLACE_GETPASS 1
1427 #define NO_CONFIG_H 1
1428 #define main dont_declare_main
1429 #include "${srcdir-.}/lib/getsmbpass.c"
1430 #undef main
1431 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1432 CPPFLAGS="$SAVE_CPPFLAGS"
1433 ])
1434 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1435         AC_DEFINE(REPLACE_GETPASS)
1436 fi
1437
1438 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1439 AC_TRY_RUN([
1440 #include <stdio.h>
1441 #include <sys/types.h>
1442 #include <netinet/in.h>
1443 #ifdef HAVE_ARPA_INET_H
1444 #include <arpa/inet.h>
1445 #endif
1446 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1447 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1448     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1449 exit(1);}],
1450            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1451 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1452     AC_DEFINE(REPLACE_INET_NTOA)
1453 fi
1454
1455 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1456 AC_TRY_RUN([#include <stdlib.h>
1457 #include <sys/types.h>
1458 #include <sys/stat.h>
1459 #include <unistd.h>
1460 main() { 
1461   struct stat st;
1462   char tpl[20]="/tmp/test.XXXXXX"; 
1463   int fd = mkstemp(tpl); 
1464   if (fd == -1) exit(1);
1465   unlink(tpl);
1466   if (fstat(fd, &st) != 0) exit(1);
1467   if ((st.st_mode & 0777) != 0600) exit(1);
1468   exit(0);
1469 }],
1470 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1471 samba_cv_HAVE_SECURE_MKSTEMP=no,
1472 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1473 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1474     AC_DEFINE(HAVE_SECURE_MKSTEMP)
1475 fi
1476
1477 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1478 AC_TRY_RUN([#include <unistd.h>
1479 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1480 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1481 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1482     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX)
1483 fi
1484
1485 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1486 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1487            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1488 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1489     AC_DEFINE(HAVE_ROOT)
1490 else
1491     AC_MSG_WARN(running as non-root will disable some tests)
1492 fi
1493
1494 ##################
1495 # look for a method of finding the list of network interfaces
1496 iface=no;
1497 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1498 AC_TRY_RUN([
1499 #define HAVE_IFACE_AIX 1
1500 #define AUTOCONF_TEST 1
1501 #include "confdefs.h"
1502 #include "${srcdir-.}/lib/interfaces.c"],
1503            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1504 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1505     iface=yes;AC_DEFINE(HAVE_IFACE_AIX)
1506 fi
1507
1508 if test $iface = no; then
1509 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1510 AC_TRY_RUN([
1511 #define HAVE_IFACE_IFCONF 1
1512 #define AUTOCONF_TEST 1
1513 #include "confdefs.h"
1514 #include "${srcdir-.}/lib/interfaces.c"],
1515            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1516 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1517     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF)
1518 fi
1519 fi
1520
1521 if test $iface = no; then
1522 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1523 AC_TRY_RUN([
1524 #define HAVE_IFACE_IFREQ 1
1525 #define AUTOCONF_TEST 1
1526 #include "confdefs.h"
1527 #include "${srcdir-.}/lib/interfaces.c"],
1528            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1529 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1530     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ)
1531 fi
1532 fi
1533
1534
1535 ################################################
1536 # look for a method of setting the effective uid
1537 seteuid=no;
1538 if test $seteuid = no; then
1539 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1540 AC_TRY_RUN([
1541 #define AUTOCONF_TEST 1
1542 #define USE_SETRESUID 1
1543 #include "confdefs.h"
1544 #include "${srcdir-.}/lib/util_sec.c"],
1545            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1546 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1547     seteuid=yes;AC_DEFINE(USE_SETRESUID)
1548 fi
1549 fi
1550
1551
1552 if test $seteuid = no; then
1553 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1554 AC_TRY_RUN([
1555 #define AUTOCONF_TEST 1
1556 #define USE_SETREUID 1
1557 #include "confdefs.h"
1558 #include "${srcdir-.}/lib/util_sec.c"],
1559            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1560 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1561     seteuid=yes;AC_DEFINE(USE_SETREUID)
1562 fi
1563 fi
1564
1565 if test $seteuid = no; then
1566 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1567 AC_TRY_RUN([
1568 #define AUTOCONF_TEST 1
1569 #define USE_SETEUID 1
1570 #include "confdefs.h"
1571 #include "${srcdir-.}/lib/util_sec.c"],
1572            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1573 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1574     seteuid=yes;AC_DEFINE(USE_SETEUID)
1575 fi
1576 fi
1577
1578 if test $seteuid = no; then
1579 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1580 AC_TRY_RUN([
1581 #define AUTOCONF_TEST 1
1582 #define USE_SETUIDX 1
1583 #include "confdefs.h"
1584 #include "${srcdir-.}/lib/util_sec.c"],
1585            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1586 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1587     seteuid=yes;AC_DEFINE(USE_SETUIDX)
1588 fi
1589 fi
1590
1591
1592 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1593 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1594            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1595 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1596     AC_DEFINE(HAVE_MMAP)
1597 fi
1598
1599 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1600 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1601            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1602 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1603     AC_DEFINE(FTRUNCATE_NEEDS_ROOT)
1604 fi
1605
1606 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1607 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1608            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1609 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1610     AC_DEFINE(HAVE_FCNTL_LOCK)
1611 fi
1612
1613 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1614 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1615            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1616 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1617     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS)
1618
1619 else
1620
1621 dnl
1622 dnl Don't check for 64 bit fcntl locking if we know that the
1623 dnl glibc2.1 broken check has succeeded.
1624 dnl 
1625
1626   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1627   AC_TRY_RUN([
1628 #if defined(HAVE_UNISTD_H)
1629 #include <unistd.h>
1630 #endif
1631 #include <stdio.h>
1632 #include <stdlib.h>
1633
1634 #ifdef HAVE_FCNTL_H
1635 #include <fcntl.h>
1636 #endif
1637
1638 #ifdef HAVE_SYS_FCNTL_H
1639 #include <sys/fcntl.h>
1640 #endif
1641 main() { struct flock64 fl64;
1642 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1643 exit(0);
1644 #else
1645 exit(1);
1646 #endif
1647 }],
1648        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1649
1650   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1651       AC_DEFINE(HAVE_STRUCT_FLOCK64)
1652   fi
1653 fi
1654
1655 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1656 AC_TRY_COMPILE([#include <sys/types.h>
1657 #include <sys/stat.h>
1658 #include <unistd.h>],
1659 [struct stat st;  st.st_blocks = 0;],
1660 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1661 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1662     AC_DEFINE(HAVE_STAT_ST_BLOCKS)
1663 fi 
1664
1665 case "$host_os" in
1666 *linux*)
1667 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1668 AC_TRY_COMPILE([
1669 #ifdef HAVE_SYS_VFS_H
1670 #include <sys/vfs.h>
1671 #endif
1672 #ifdef HAVE_SYS_CAPABILITY_H
1673 #include <sys/capability.h>
1674 #endif
1675 ],[int i;],
1676    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1677 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1678    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS)
1679 fi
1680 ;;
1681 esac
1682
1683 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1684 AC_TRY_COMPILE([#include <sys/acl.h>
1685 #if defined(HAVE_RPCSVC_NIS_H)
1686 #include <rpcsvc/nis.h>
1687 #endif],
1688 [int i;],
1689 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1690 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1691     AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES)
1692 fi
1693
1694
1695 #################################################
1696 # check for smbwrapper support
1697 AC_MSG_CHECKING(whether to use smbwrapper)
1698 AC_ARG_WITH(smbwrapper,
1699 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
1700 [ case "$withval" in
1701   yes)
1702     AC_MSG_RESULT(yes)
1703     AC_DEFINE(WITH_SMBWRAPPER)
1704         WRAP="bin/smbsh bin/smbwrapper.$SHLIBEXT"
1705
1706         if test x$ATTEMPT_WRAP32_BUILD = x; then
1707                 WRAP32=""
1708         else
1709                         WRAP32=bin/smbwrapper.32.$SHLIBEXT
1710         fi
1711
1712 # Conditions under which smbwrapper should not be built.
1713
1714         if test x$PICFLAG = x; then
1715            echo No support for PIC code - disabling smbwrapper and smbsh
1716            WRAP=""
1717            WRAP32=""
1718         elif test x$ac_cv_func_syscall = xno; then
1719            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
1720            WRAP=""
1721            WRAP32=""
1722         fi
1723     ;;
1724   *)
1725     AC_MSG_RESULT(no)
1726     ;;
1727   esac ],
1728   AC_MSG_RESULT(no)
1729 )
1730
1731 #################################################
1732 # check for AFS clear-text auth support
1733 AC_MSG_CHECKING(whether to use AFS clear-text auth)
1734 AC_ARG_WITH(afs,
1735 [  --with-afs              Include AFS clear-text auth support (default=no) ],
1736 [ case "$withval" in
1737   yes)
1738     AC_MSG_RESULT(yes)
1739     AC_DEFINE(WITH_AFS)
1740     ;;
1741   *)
1742     AC_MSG_RESULT(no)
1743     ;;
1744   esac ],
1745   AC_MSG_RESULT(no)
1746 )
1747
1748
1749 #################################################
1750 # check for the DFS clear-text auth system
1751 AC_MSG_CHECKING(whether to use DFS clear-text auth)
1752 AC_ARG_WITH(dfs,
1753 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
1754 [ case "$withval" in
1755   yes)
1756     AC_MSG_RESULT(yes)
1757     AC_DEFINE(WITH_DFS)
1758     ;;
1759   *)
1760     AC_MSG_RESULT(no)
1761     ;;
1762   esac ],
1763   AC_MSG_RESULT(no)
1764 )
1765
1766
1767 #################################################
1768 # see if this box has the RedHat location for kerberos
1769 AC_MSG_CHECKING(for /usr/kerberos)
1770 if test -d /usr/kerberos; then
1771     LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
1772     CFLAGS="$CFLAGS -I/usr/kerberos/include"
1773     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
1774     AC_MSG_RESULT(yes)
1775 else
1776     AC_MSG_RESULT(no)
1777 fi
1778
1779 #################################################
1780 # check for location of Kerberos 5 install
1781 AC_MSG_CHECKING(for kerberos 5 install path)
1782 AC_ARG_WITH(krb5,
1783 [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
1784 [ case "$withval" in
1785   no)
1786     AC_MSG_RESULT(no)
1787     ;;
1788   *)
1789     AC_MSG_RESULT(yes)
1790     LIBS="$LIBS -lkrb5"
1791     CFLAGS="$CFLAGS -I$withval/include"
1792     CPPFLAGS="$CPPFLAGS -I$withval/include"
1793     LDFLAGS="$LDFLAGS -L$withval/lib"
1794     ;;
1795   esac ],
1796   AC_MSG_RESULT(no)
1797 )
1798
1799 # now check for krb5.h. Some systems have the libraries without the headers!
1800 # note that this check is done here to allow for different kerberos
1801 # include paths
1802 AC_CHECK_HEADERS(krb5.h)
1803
1804 # now check for gssapi headers.  This is also done here to allow for
1805 # different kerberos include paths
1806 AC_CHECK_HEADERS(gssapi/gssapi_generic.h gssapi/gssapi.h)
1807
1808 ##################################################################
1809 # we might need the k5crypto and com_err libraries on some systems
1810 AC_CHECK_LIB(com_err, _et_list, [LIBS="$LIBS -lcom_err"])
1811 AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"])
1812
1813 ########################################################
1814 # now see if we can find the krb5 libs in standard paths
1815 # or as specified above
1816 AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
1817         AC_DEFINE(HAVE_KRB5)])
1818
1819 ########################################################
1820 # now see if we can find the gssapi libs in standard paths
1821 AC_CHECK_LIB(gssapi_krb5, gss_display_status, [LIBS="$LIBS -lgssapi_krb5";
1822         AC_DEFINE(HAVE_GSSAPI)])
1823
1824 ##################################################################
1825 # we might need the lber lib on some systems. To avoid link errors
1826 # this test must be before the libldap test
1827 AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"])
1828
1829 ########################################################
1830 # now see if we can find the ldap libs in standard paths
1831 if test x$have_ldap != xyes; then
1832 AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
1833         AC_DEFINE(HAVE_LDAP)])
1834 fi
1835
1836 #################################################
1837 # check for automount support
1838 AC_MSG_CHECKING(whether to use AUTOMOUNT)
1839 AC_ARG_WITH(automount,
1840 [  --with-automount        Include AUTOMOUNT support (default=no)],
1841 [ case "$withval" in
1842   yes)
1843     AC_MSG_RESULT(yes)
1844     AC_DEFINE(WITH_AUTOMOUNT)
1845     ;;
1846   *)
1847     AC_MSG_RESULT(no)
1848     ;;
1849   esac ],
1850   AC_MSG_RESULT(no)
1851 )
1852
1853 #################################################
1854 # check for smbmount support
1855 AC_MSG_CHECKING(whether to use SMBMOUNT)
1856 AC_ARG_WITH(smbmount,
1857 [  --with-smbmount         Include SMBMOUNT (Linux only) support (default=no)],
1858 [ case "$withval" in
1859   yes)
1860         case "$host_os" in
1861         *linux*)
1862                 AC_MSG_RESULT(yes)
1863                 AC_DEFINE(WITH_SMBMOUNT)
1864                 MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
1865                 ;;
1866         *)
1867                 AC_MSG_ERROR(not on a linux system!)
1868                 ;;
1869         esac
1870     ;;
1871   *)
1872     AC_MSG_RESULT(no)
1873     MPROGS=
1874     ;;
1875   esac ],
1876   AC_MSG_RESULT(no)
1877   MPROGS=
1878 )
1879
1880
1881 #################################################
1882 # check for a PAM clear-text auth, accounts, password and session support
1883 with_pam_for_crypt=no
1884 AC_MSG_CHECKING(whether to use PAM)
1885 AC_ARG_WITH(pam,
1886 [  --with-pam              Include PAM support (default=no)],
1887 [ case "$withval" in
1888   yes)
1889     AC_MSG_RESULT(yes)
1890     AC_DEFINE(WITH_PAM)
1891     LIBS="$LIBS -lpam"
1892     with_pam_for_crypt=yes
1893     ;;
1894   *)
1895     AC_MSG_RESULT(no)
1896     ;;
1897   esac ],
1898   AC_MSG_RESULT(no)
1899 )
1900
1901 # we can't build a pam module if we don't have pam.
1902 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM)])
1903
1904 #################################################
1905 # check for pam_smbpass support
1906 AC_MSG_CHECKING(whether to use pam_smbpass)
1907 AC_ARG_WITH(pam_smbpass,
1908 [  --with-pam_smbpass      Build a PAM module to allow other applications to use our smbpasswd file (default=no)],
1909 [ case "$withval" in
1910   yes)
1911     AC_MSG_RESULT(yes)
1912
1913 # Conditions under which pam_smbpass should not be built.
1914
1915        if test x$PICFLAG = x; then
1916           AC_MSG_RESULT([No support for PIC code - disabling pam_smbpass])
1917           PAM_MOD=""
1918        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
1919           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
1920           PAM_MOD=""
1921        else
1922           PAM_MOD="bin/pam_smbpass.so"
1923        fi
1924     ;;
1925   *)
1926     AC_MSG_RESULT(no)
1927     ;;
1928   esac ],
1929   AC_MSG_RESULT(no)
1930 )
1931
1932
1933 ###############################################
1934 # test for where we get crypt() from, but only
1935 # if not using PAM
1936 if test $with_pam_for_crypt = no; then
1937 AC_CHECK_FUNCS(crypt)
1938 if test x"$ac_cv_func_crypt" = x"no"; then
1939     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
1940         AC_DEFINE(HAVE_CRYPT)])
1941 fi
1942 fi
1943
1944 ##
1945 ## moved after the check for -lcrypt in order to
1946 ## ensure that the necessary libraries are included
1947 ## check checking for truncated salt.  Wrapped by the
1948 ## $with_pam_for_crypt variable as above   --jerry
1949 ##
1950 if test $with_pam_for_crypt = no; then
1951 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1952 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
1953         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
1954 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1955         AC_DEFINE(HAVE_TRUNCATED_SALT)
1956 fi
1957 fi
1958
1959
1960
1961 ########################################################################################
1962 ##
1963 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
1964 ##
1965 ########################################################################################
1966
1967 #################################################
1968 # check for a TDB password database
1969 AC_MSG_CHECKING(whether to use TDB SAM database)
1970 AC_ARG_WITH(tdbsam,
1971 [  --with-tdbsam           Include experimental TDB SAM support (default=no)],
1972 [ case "$withval" in
1973   yes)
1974     AC_MSG_RESULT(yes)
1975     AC_DEFINE(WITH_TDB_SAM)
1976     ;;
1977   *)
1978     AC_MSG_RESULT(no)
1979     ;;
1980   esac ],
1981   AC_MSG_RESULT(no)
1982 )
1983
1984 #################################################
1985 # check for a LDAP password database
1986 AC_MSG_CHECKING(whether to use LDAP SAM database)
1987 AC_ARG_WITH(ldapsam,
1988 [  --with-ldapsam          Include experimental LDAP SAM support (default=no)],
1989 [ case "$withval" in
1990   yes)
1991     AC_MSG_RESULT(yes)
1992     AC_DEFINE(WITH_LDAP_SAM)
1993     LIBS="-lldap -llber $LIBS"
1994     ;;
1995   *)
1996     AC_MSG_RESULT(no)
1997     ;;
1998   esac ],
1999   AC_MSG_RESULT(no)
2000 )
2001
2002 #################################################
2003 # check for a NISPLUS password database
2004 AC_MSG_CHECKING(whether to use NISPLUS SAM database)
2005 AC_ARG_WITH(nisplussam,
2006 [  --with-nisplussam       Include NISPLUS SAM support (default=no)],
2007 [ case "$withval" in
2008   yes)
2009     AC_MSG_RESULT(yes)
2010     AC_DEFINE(WITH_NISPLUS_SAM)
2011     ;;
2012   *)
2013     AC_MSG_RESULT(no)
2014     ;;
2015   esac ],
2016   AC_MSG_RESULT(no)
2017 )
2018
2019 ########################################################################################
2020 ##
2021 ## END OF TESTS FOR SAM BACKENDS.  
2022 ##
2023 ########################################################################################
2024
2025 #################################################
2026 # check for a NISPLUS_HOME support 
2027 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
2028 AC_ARG_WITH(nisplus-home,
2029 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
2030 [ case "$withval" in
2031   yes)
2032     AC_MSG_RESULT(yes)
2033     AC_DEFINE(WITH_NISPLUS_HOME)
2034     ;;
2035   *)
2036     AC_MSG_RESULT(no)
2037     ;;
2038   esac ],
2039   AC_MSG_RESULT(no)
2040 )
2041
2042 #################################################
2043 # check for the secure socket layer
2044 AC_MSG_CHECKING(whether to use SSL)
2045 AC_ARG_WITH(ssl,
2046 [  --with-ssl              Include SSL support (default=no)
2047   --with-sslinc=DIR          Where the SSL includes are (defaults to /usr/local/ssl/include)
2048   --with-ssllib=DIR          Where the SSL libraries are (defaults to /usr/local/ssl/lib)],
2049 [ case "$withval" in
2050   yes)
2051     AC_MSG_RESULT(yes)
2052     AC_DEFINE(WITH_SSL)
2053     withval="/usr/local/ssl"     # default
2054
2055     if test "${with_sslinc+set}" = set; then
2056
2057         withval="$with_sslinc"
2058         case "$withval" in
2059         yes|no)
2060           echo "configure: warning: --with-sslinc called without argument - will use default" 1>&w
2061           CFLAGS="-I/usr/local/ssl/include $CFLAGS"
2062         ;;
2063         * )
2064           CFLAGS="-I${withval} $CFLAGS"
2065         ;;
2066         esac
2067
2068     else
2069
2070         CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
2071
2072     fi
2073
2074     if test "${with_ssllib+set}" = set; then
2075
2076         withval="$with_ssllib"
2077         case "$withval" in
2078         yes|no)
2079           echo "configure: warning: --with-ssllib called without argument - will use default" 1>&w
2080           LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2081         ;;
2082         * )
2083           LDFLAGS="-L${withval}/lib $LDFLAGS"
2084         ;;
2085         esac
2086
2087     else
2088
2089         LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2090
2091     fi
2092
2093     LIBS="-lssl -lcrypto $LIBS"
2094
2095 #    if test ! -d ${withval}; then
2096 #      echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
2097 #      exit 1
2098 #    fi 
2099
2100     CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
2101
2102     ;;
2103   *)
2104     AC_MSG_RESULT(no)
2105     ;;
2106   esac ],
2107   AC_MSG_RESULT(no)
2108 )
2109
2110 #################################################
2111 # check for syslog logging
2112 AC_MSG_CHECKING(whether to use syslog logging)
2113 AC_ARG_WITH(syslog,
2114 [  --with-syslog           Include experimental SYSLOG support (default=no)],
2115 [ case "$withval" in
2116   yes)
2117     AC_MSG_RESULT(yes)
2118     AC_DEFINE(WITH_SYSLOG)
2119     ;;
2120   *)
2121     AC_MSG_RESULT(no)
2122     ;;
2123   esac ],
2124   AC_MSG_RESULT(no)
2125 )
2126
2127 #################################################
2128 # check for a shared memory profiling support
2129 AC_MSG_CHECKING(whether to use profiling)
2130 AC_ARG_WITH(profiling-data,
2131 [  --with-profiling-data   Include gathering source code profile information (default=no)],
2132 [ case "$withval" in
2133   yes)
2134     AC_MSG_RESULT(yes)
2135     AC_DEFINE(WITH_PROFILE)
2136     ;;
2137   *)
2138     AC_MSG_RESULT(no)
2139     ;;
2140   esac ],
2141   AC_MSG_RESULT(no)
2142 )
2143
2144
2145 #################################################
2146 # check for experimental disk-quotas support
2147 QUOTAOBJS=smbd/noquotas.o
2148
2149 AC_MSG_CHECKING(whether to support disk-quotas)
2150 AC_ARG_WITH(quotas,
2151 [  --with-quotas           Include experimental disk-quota support (default=no)],
2152 [ case "$withval" in
2153   yes)
2154     AC_MSG_RESULT(yes)
2155     case "$host_os" in
2156       *linux*)
2157         # Check for kernel 2.4.x quota braindamage...
2158         AC_CACHE_CHECK([for linux 2.4.x quota braindamage..],samba_cv_linux_2_4_quota_braindamage, [
2159         AC_TRY_COMPILE([#include <stdio.h>
2160 #include <sys/types.h>
2161 #include <asm/types.h>
2162 #include <linux/quota.h>
2163 #include <mntent.h>
2164 #include <linux/unistd.h>],[struct mem_dqblk D;],
2165       samba_cv_linux_2_4_quota_braindamage=yes,samba_cv_linux_2_4_quota_braindamage=no)])
2166 if test x"$samba_cv_linux_2_4_quota_braindamage" = x"yes"; then
2167         AC_DEFINE(LINUX_QUOTAS_2)
2168 else
2169         AC_DEFINE(LINUX_QUOTAS_1)
2170 fi
2171         ;;
2172       *)
2173         ;;
2174     esac
2175     QUOTAOBJS=smbd/quotas.o
2176     AC_DEFINE(WITH_QUOTAS)
2177     ;;
2178   *)
2179     AC_MSG_RESULT(no)
2180     ;;
2181   esac ],
2182   AC_MSG_RESULT(no)
2183 )
2184 AC_SUBST(QUOTAOBJS)
2185
2186 #################################################
2187 # check for experimental utmp accounting
2188
2189 AC_MSG_CHECKING(whether to support utmp accounting)
2190 AC_ARG_WITH(utmp,
2191 [  --with-utmp             Include experimental utmp accounting (default=no)],
2192 [ case "$withval" in
2193   yes)
2194     AC_MSG_RESULT(yes)
2195     AC_DEFINE(WITH_UTMP)
2196     ;;
2197   *)
2198     AC_MSG_RESULT(no)
2199     ;;
2200   esac ],
2201   AC_MSG_RESULT(no)
2202 )
2203
2204 #################################################
2205 # set private directory location
2206 AC_ARG_WITH(privatedir,
2207 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
2208 [ case "$withval" in
2209   yes|no)
2210   #
2211   # Just in case anybody calls it without argument
2212   #
2213     AC_MSG_WARN([--with-privatedir called without argument - will use default])
2214     privatedir='${prefix}/private'
2215   ;;
2216   * )
2217     privatedir="$withval"
2218     ;;
2219   esac
2220   AC_SUBST(privatedir)],
2221   [privatedir='${prefix}/private'
2222    AC_SUBST(privatedir)]
2223 )
2224
2225 #################################################
2226 # set lock directory location
2227 AC_ARG_WITH(lockdir,
2228 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
2229 [ case "$withval" in
2230   yes|no)
2231   #
2232   # Just in case anybody calls it without argument
2233   #
2234     AC_MSG_WARN([--with-lockdir called without argument - will use default])
2235     lockdir='$(VARDIR)/locks'
2236   ;;
2237   * )
2238     lockdir="$withval"
2239     ;;
2240   esac
2241   AC_SUBST(lockdir)],
2242   [lockdir='$(VARDIR)/locks'
2243    AC_SUBST(lockdir)]
2244 )
2245
2246 #################################################
2247 # set SWAT directory location
2248 AC_ARG_WITH(swatdir,
2249 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
2250 [ case "$withval" in
2251   yes|no)
2252   #
2253   # Just in case anybody does it
2254   #
2255     AC_MSG_WARN([--with-swatdir called without argument - will use default])
2256     swatdir='${prefix}/swat'
2257   ;;
2258   * )
2259     swatdir="$withval"
2260     ;;
2261   esac
2262   AC_SUBST(swatdir)],
2263   [swatdir='${prefix}/swat'
2264    AC_SUBST(swatdir)]
2265 )
2266
2267 #################################################
2268 # choose native language(s) of man pages
2269 AC_MSG_CHECKING(chosen man pages' language(s))
2270 AC_ARG_WITH(manpages-langs,
2271 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
2272 [ case "$withval" in
2273   yes|no)
2274     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
2275     manlangs="en"
2276   ;;
2277   *)
2278     manlangs="$withval"
2279   ;;
2280   esac
2281
2282   AC_MSG_RESULT($manlangs)
2283   manlangs=`echo $manlangs | sed "s/,/ /"`   # replacing commas with spaces to produce a list
2284   AC_SUBST(manlangs)],
2285
2286   [manlangs="en"
2287   AC_MSG_RESULT($manlangs)
2288   AC_SUBST(manlangs)]
2289 )
2290
2291 #################################################
2292 # these tests are taken from the GNU fileutils package
2293 AC_CHECKING(how to get filesystem space usage)
2294 space=no
2295
2296 # Test for statvfs64.
2297 if test $space = no; then
2298   # SVR4
2299   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
2300   [AC_TRY_RUN([
2301 #if defined(HAVE_UNISTD_H)
2302 #include <unistd.h>
2303 #endif
2304 #include <sys/types.h>
2305 #include <sys/statvfs.h>
2306   main ()
2307   {
2308     struct statvfs64 fsd;
2309     exit (statvfs64 (".", &fsd));
2310   }],
2311   fu_cv_sys_stat_statvfs64=yes,
2312   fu_cv_sys_stat_statvfs64=no,
2313   fu_cv_sys_stat_statvfs64=cross)])
2314   if test $fu_cv_sys_stat_statvfs64 = yes; then
2315     space=yes
2316     AC_DEFINE(STAT_STATVFS64)
2317   fi
2318 fi
2319
2320 # Perform only the link test since it seems there are no variants of the
2321 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
2322 # because that got a false positive on SCO OSR5.  Adding the declaration
2323 # of a `struct statvfs' causes this test to fail (as it should) on such
2324 # systems.  That system is reported to work fine with STAT_STATFS4 which
2325 # is what it gets when this test fails.
2326 if test $space = no; then
2327   # SVR4
2328   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
2329                  [AC_TRY_LINK([#include <sys/types.h>
2330 #include <sys/statvfs.h>],
2331                               [struct statvfs fsd; statvfs (0, &fsd);],
2332                               fu_cv_sys_stat_statvfs=yes,
2333                               fu_cv_sys_stat_statvfs=no)])
2334   if test $fu_cv_sys_stat_statvfs = yes; then
2335     space=yes
2336     AC_DEFINE(STAT_STATVFS)
2337   fi
2338 fi
2339
2340 if test $space = no; then
2341   # DEC Alpha running OSF/1
2342   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
2343   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
2344   [AC_TRY_RUN([
2345 #include <sys/param.h>
2346 #include <sys/types.h>
2347 #include <sys/mount.h>
2348   main ()
2349   {
2350     struct statfs fsd;
2351     fsd.f_fsize = 0;
2352     exit (statfs (".", &fsd, sizeof (struct statfs)));
2353   }],
2354   fu_cv_sys_stat_statfs3_osf1=yes,
2355   fu_cv_sys_stat_statfs3_osf1=no,
2356   fu_cv_sys_stat_statfs3_osf1=no)])
2357   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
2358   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
2359     space=yes
2360     AC_DEFINE(STAT_STATFS3_OSF1)
2361   fi
2362 fi
2363
2364 if test $space = no; then
2365 # AIX
2366   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
2367 member (AIX, 4.3BSD)])
2368   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
2369   [AC_TRY_RUN([
2370 #ifdef HAVE_SYS_PARAM_H
2371 #include <sys/param.h>
2372 #endif
2373 #ifdef HAVE_SYS_MOUNT_H
2374 #include <sys/mount.h>
2375 #endif
2376 #ifdef HAVE_SYS_VFS_H
2377 #include <sys/vfs.h>
2378 #endif
2379   main ()
2380   {
2381   struct statfs fsd;
2382   fsd.f_bsize = 0;
2383   exit (statfs (".", &fsd));
2384   }],
2385   fu_cv_sys_stat_statfs2_bsize=yes,
2386   fu_cv_sys_stat_statfs2_bsize=no,
2387   fu_cv_sys_stat_statfs2_bsize=no)])
2388   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
2389   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
2390     space=yes
2391     AC_DEFINE(STAT_STATFS2_BSIZE)
2392   fi
2393 fi
2394
2395 if test $space = no; then
2396 # SVR3
2397   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
2398   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
2399   [AC_TRY_RUN([#include <sys/types.h>
2400 #include <sys/statfs.h>
2401   main ()
2402   {
2403   struct statfs fsd;
2404   exit (statfs (".", &fsd, sizeof fsd, 0));
2405   }],
2406     fu_cv_sys_stat_statfs4=yes,
2407     fu_cv_sys_stat_statfs4=no,
2408     fu_cv_sys_stat_statfs4=no)])
2409   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
2410   if test $fu_cv_sys_stat_statfs4 = yes; then
2411     space=yes
2412     AC_DEFINE(STAT_STATFS4)
2413   fi
2414 fi
2415
2416 if test $space = no; then
2417 # 4.4BSD and NetBSD
2418   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
2419 member (4.4BSD and NetBSD)])
2420   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
2421   [AC_TRY_RUN([#include <sys/types.h>
2422 #ifdef HAVE_SYS_PARAM_H
2423 #include <sys/param.h>
2424 #endif
2425 #ifdef HAVE_SYS_MOUNT_H
2426 #include <sys/mount.h>
2427 #endif
2428   main ()
2429   {
2430   struct statfs fsd;
2431   fsd.f_fsize = 0;
2432   exit (statfs (".", &fsd));
2433   }],
2434   fu_cv_sys_stat_statfs2_fsize=yes,
2435   fu_cv_sys_stat_statfs2_fsize=no,
2436   fu_cv_sys_stat_statfs2_fsize=no)])
2437   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
2438   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
2439     space=yes
2440     AC_DEFINE(STAT_STATFS2_FSIZE)
2441   fi
2442 fi
2443
2444 if test $space = no; then
2445   # Ultrix
2446   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
2447   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
2448   [AC_TRY_RUN([#include <sys/types.h>
2449 #ifdef HAVE_SYS_PARAM_H
2450 #include <sys/param.h>
2451 #endif
2452 #ifdef HAVE_SYS_MOUNT_H
2453 #include <sys/mount.h>
2454 #endif
2455 #ifdef HAVE_SYS_FS_TYPES_H
2456 #include <sys/fs_types.h>
2457 #endif
2458   main ()
2459   {
2460   struct fs_data fsd;
2461   /* Ultrix's statfs returns 1 for success,
2462      0 for not mounted, -1 for failure.  */
2463   exit (statfs (".", &fsd) != 1);
2464   }],
2465   fu_cv_sys_stat_fs_data=yes,
2466   fu_cv_sys_stat_fs_data=no,
2467   fu_cv_sys_stat_fs_data=no)])
2468   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2469   if test $fu_cv_sys_stat_fs_data = yes; then
2470     space=yes
2471     AC_DEFINE(STAT_STATFS2_FS_DATA)
2472   fi
2473 fi
2474
2475 #
2476 # As a gating factor for large file support, in order to
2477 # use <4GB files we must have the following minimal support
2478 # available.
2479 # long long, and a 64 bit off_t or off64_t.
2480 # If we don't have all of these then disable large
2481 # file support.
2482 #
2483 AC_MSG_CHECKING([if large file support can be enabled])
2484 AC_TRY_COMPILE([
2485 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2486 #include <sys/types.h>
2487 #else
2488 __COMPILE_ERROR_
2489 #endif
2490 ],
2491 [int i],
2492 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2493 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2494     AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
2495 fi
2496 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
2497
2498 AC_ARG_WITH(spinlocks, 
2499 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
2500 if test "x$with_spinlocks" = "xyes"; then
2501     AC_DEFINE(USE_SPINLOCKS)
2502
2503     case "$host_cpu" in
2504         sparc)
2505             AC_DEFINE(SPARC_SPINLOCKS)
2506             ;;
2507
2508         i386|i486|i586|i686)
2509             AC_DEFINE(INTEL_SPINLOCKS)
2510             ;;
2511
2512         mips)
2513             AC_DEFINE(MIPS_SPINLOCKS)
2514             ;;
2515
2516         powerpc)
2517             AC_DEFINE(POWERPC_SPINLOCKS)
2518             ;;
2519     esac
2520 fi
2521
2522 #################################################
2523 # check for ACL support
2524
2525 AC_MSG_CHECKING(whether to support ACLs)
2526 AC_ARG_WITH(acl-support,
2527 [  --with-acl-support      Include ACL support (default=no)],
2528 [ case "$withval" in
2529   yes)
2530
2531         case "$host_os" in
2532         *sysv5*)
2533                 AC_MSG_RESULT(Using UnixWare ACLs)
2534                 AC_DEFINE(HAVE_UNIXWARE_ACLS)
2535                 ;;
2536         *solaris*)
2537                 AC_MSG_RESULT(Using solaris ACLs)
2538                 AC_DEFINE(HAVE_SOLARIS_ACLS)
2539                 ;;
2540         *hpux*)
2541                 AC_MSG_RESULT(Using HPUX ACLs)
2542                 AC_DEFINE(HAVE_HPUX_ACLS)
2543                 ;;
2544         *irix*)
2545                 AC_MSG_RESULT(Using IRIX ACLs)
2546                 AC_DEFINE(HAVE_IRIX_ACLS)
2547                 ;;
2548         *aix*)
2549                 AC_MSG_RESULT(Using AIX ACLs)
2550                 AC_DEFINE(HAVE_AIX_ACLS)
2551                 ;;
2552         *osf*)
2553                 AC_MSG_RESULT(Using Tru64 ACLs)
2554                 AC_DEFINE(HAVE_TRU64_ACLS)
2555                 LIBS="$LIBS -lpacl"
2556                 ;;
2557         *)
2558                 AC_CHECK_LIB(acl,acl_get_file)
2559                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
2560                 AC_TRY_LINK([#include <sys/types.h>
2561 #include <sys/acl.h>],
2562 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
2563 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
2564                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
2565                                 AC_MSG_RESULT(Using posix ACLs)
2566                                 AC_DEFINE(HAVE_POSIX_ACLS)
2567                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
2568                                 AC_TRY_LINK([#include <sys/types.h>
2569 #include <sys/acl.h>],
2570 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
2571 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
2572                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
2573                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP)
2574                                 fi
2575                         fi
2576             ;;
2577         esac
2578         ;;
2579   *)
2580     AC_MSG_RESULT(no)
2581     AC_DEFINE(HAVE_NO_ACLS)
2582     ;;
2583   esac ],
2584   AC_DEFINE(HAVE_NO_ACLS)
2585   AC_MSG_RESULT(no)
2586 )
2587
2588 #################################################
2589 # Check whether winbind is supported on this platform.  If so we need to
2590 # build and install client programs (WINBIND_TARGETS), sbin programs
2591 # (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
2592
2593 AC_MSG_CHECKING(whether to build winbind)
2594
2595 # Initially, the value of $host_os decides whether winbind is supported
2596
2597 case "$host_os" in
2598         *linux*|*irix*)
2599                 HAVE_WINBIND=yes
2600                 ;;
2601         *solaris*)
2602                 HAVE_WINBIND=yes
2603                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
2604                 WINBIND_NSS_EXTRA_LIBS="-lsocket"
2605                 ;;
2606         *hpux11*)
2607                 HAVE_WINBIND=yes
2608                 WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
2609                 ;;
2610         *)
2611                 HAVE_WINBIND=no
2612                 winbind_no_reason=", unsupported on $host_os"
2613                 ;;
2614 esac
2615
2616 # Check the setting of --with-winbindd
2617
2618 AC_ARG_WITH(winbind,
2619 [  --with-winbind          Build winbind (default, if supported by OS)],
2620
2621   case "$withval" in
2622         yes)
2623                 HAVE_WINBIND=yes
2624                 ;;
2625         no)
2626                 HAVE_WINBIND=no
2627                 winbind_reason=""
2628                 ;;
2629   esac ],
2630 )
2631
2632 # We need unix domain sockets for winbind
2633
2634 if test x"$HAVE_WINBIND" = x"yes"; then
2635         if test x"$samba_cv_unixsocket" = x"no"; then
2636                 winbind_no_reason=", no unix domain socket support on $host_os"
2637                 HAVE_WINBIND=no
2638         fi
2639 fi
2640
2641 # Display test results
2642
2643 WINBIND_TARGETS=""
2644 WINBIND_STARGETS=""
2645 WINBIND_LTARGETS=""
2646 WINBIND_PAM_PROGS=""
2647
2648 if test x"$HAVE_WINBIND" = x"yes"; then
2649         AC_MSG_RESULT(yes)
2650
2651         WINBIND_TARGETS="bin/wbinfo"
2652         WINBIND_STARGETS="bin/winbindd"
2653         if test x"$BLDSHARED" = x"true"; then
2654                 WINBIND_LTARGETS="nsswitch/libnss_winbind.so"
2655                 if test x"$with_pam" = x"yes"; then
2656                         WINBIND_PAM_TARGETS="nsswitch/pam_winbind.so"
2657                 fi
2658         fi
2659 else
2660         AC_MSG_RESULT(no$winbind_no_reason)
2661 fi
2662
2663 # Substitution time!
2664
2665 AC_SUBST(WINBIND_TARGETS)
2666 AC_SUBST(WINBIND_STARGETS)
2667 AC_SUBST(WINBIND_LTARGETS)
2668 AC_SUBST(WINBIND_PAM_TARGETS)
2669 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
2670 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
2671
2672 #################################################
2673 # Check to see if we should use the included popt 
2674
2675 AC_ARG_WITH(included-popt,
2676 [  --with-included-popt    use bundled popt library, not from system],
2677
2678   case "$withval" in
2679         yes)
2680                 INCLUDED_POPT=yes
2681                 ;;
2682         no)
2683                 INCLUDED_POPT=no
2684                 ;;
2685   esac ],
2686 )
2687 if test x"$INCLUDED_POPT" != x"yes"; then
2688     AC_CHECK_LIB(popt, poptGetContext,
2689                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
2690 fi
2691
2692 AC_MSG_CHECKING(whether to use included popt)
2693 if test x"$INCLUDED_POPT" = x"yes"; then
2694     AC_MSG_RESULT($srcdir/popt)
2695     BUILD_POPT='$(POPT_OBJS)'
2696     FLAGS1="-I$srcdir/popt"
2697 else
2698     AC_MSG_RESULT(no)
2699     LIBS="$LIBS -lpopt"
2700 fi
2701 AC_SUBST(BUILD_POPT)
2702 AC_SUBST(FLAGS1)
2703
2704 #################################################
2705 # do extra things if we are running insure
2706
2707 if test "${ac_cv_prog_CC}" = "insure"; then
2708         CPPFLAGS="$CPPFLAGS -D__INSURE__"
2709 fi
2710
2711 #################################################
2712 # final configure stuff
2713
2714 AC_MSG_CHECKING([configure summary])
2715 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
2716            AC_MSG_RESULT(yes),
2717            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
2718            AC_MSG_WARN([cannot run when cross-compiling]))
2719
2720 builddir=`pwd`
2721 AC_SUBST(builddir)
2722
2723 AC_OUTPUT(include/stamp-h Makefile)
2724
2725 #################################################
2726 # Print very concise instructions on building/use
2727 if test "x$enable_dmalloc" = xyes
2728 then
2729         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
2730         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
2731 fi