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