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