fix for IRIX toolroot builds
[kai/samba.git] / source3 / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(include/includes.h)
3 AC_CONFIG_HEADER(include/config.h)
4 # we want to be compatible with older versions of Samba
5 AC_PREFIX_DEFAULT(/usr/local/samba)
6
7 dnl Unique-to-Samba variables we'll be playing with.
8 AC_SUBST(SHELL)
9 AC_SUBST(RUNPROG)
10 AC_SUBST(MPROGS)
11 AC_SUBST(LDSHFLAGS)
12 AC_SUBST(SHLD)
13 AC_SUBST(HOST_OS)
14 AC_SUBST(PAM_MOD)
15 AC_SUBST(WRAP)
16 AC_SUBST(WRAP32)
17 AC_SUBST(PICFLAG)
18 AC_SUBST(PICSUFFIX)
19 AC_SUBST(POBAD_CC)
20 AC_SUBST(SHLIBEXT)
21 AC_SUBST(LIBSMBCLIENT_SHARED)
22
23 # compile with optimisation and without debugging by default
24 CFLAGS="-O ${CFLAGS}"
25
26 AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging [default=no]],
27     [if eval "test x$enable_debug = xyes"; then
28         CFLAGS="${CFLAGS} -g"
29     fi])
30
31 AC_ARG_ENABLE(developer, [  --enable-developer      turn on developer warnings and debugging [default=no]],
32     [if eval "test x$enable_developer = xyes"; then
33         CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
34     fi])
35
36 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer      turn on developer warnings and debugging, except -Wstrict-prototypes [default=no]],
37     [if eval "test x$enable_krb5developer = xyes"; then
38         CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
39     fi])
40
41 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc          enable heap debugging [default=no]])
42
43 if test "x$enable_dmalloc" = xyes
44 then
45         AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
46         AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
47                   [Define to check invariants around some common functions])
48         LIBS="$LIBS -ldmalloc"  
49 fi
50
51 dnl Checks for programs.
52 AC_PROG_CC
53 AC_PROG_INSTALL
54 AC_PROG_AWK
55
56 dnl needed before AC_TRY_COMPILE
57 AC_ISC_POSIX
58
59 dnl Check if C compiler understands -c and -o at the same time
60 AC_PROG_CC_C_O
61 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
62       BROKEN_CC=
63 else
64       BROKEN_CC=#
65 fi
66 AC_SUBST(BROKEN_CC)
67
68 dnl Check if the C compiler understands volatile (it should, being ANSI).
69 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
70     AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
71         samba_cv_volatile=yes,samba_cv_volatile=no)])
72 if test x"$samba_cv_volatile" = x"yes"; then
73    AC_DEFINE(HAVE_VOLATILE)
74 fi
75
76
77 AC_CANONICAL_SYSTEM
78
79 dnl Add #include for broken IRIX header files
80   case "$host_os" in
81         *irix6*) AC_ADD_INCLUDE(<standards.h>)
82         ;;
83 esac
84
85 AC_VALIDATE_CACHE_SYSTEM_TYPE
86
87 #
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="-soname \$@ -shared"
730                         SHLD="\${LD}"
731                         if test "${ac_cv_prog_CC}" = "gcc"; then
732                                 PICFLAG="-fPIC"
733                         else 
734                                 PICFLAG="-KPIC"
735                         fi
736                         AC_DEFINE(STAT_ST_BLOCKSIZE,512)
737                 ;;
738                 *aix*) AC_DEFINE(AIX)
739                         BLDSHARED="true"
740                         LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
741                         PICFLAG="-O2 -qmaxmem=6000"
742                         AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE)
743                 ;;
744                 *hpux*) AC_DEFINE(HPUX)
745                         SHLIBEXT="sl"
746                         # Use special PIC flags for the native HP-UX compiler.
747                         if test $ac_cv_prog_cc_Ae = yes; then
748                                 #BLDSHARED="true"
749                                 LDSHFLAGS="-b -z +h \$@"
750                                 PICFLAG="+z"
751                         fi
752                         AC_DEFINE(STAT_ST_BLOCKSIZE,8192)
753                 ;;
754                 *qnx*) AC_DEFINE(QNX);;
755                 *osf*) AC_DEFINE(OSF1)
756                         BLDSHARED="true"
757                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
758                         PICFLAG="-fPIC"
759                 ;;
760                 *sco*) AC_DEFINE(SCO);;
761                 *unixware*) AC_DEFINE(UNIXWARE)
762                         BLDSHARED="true"
763                         LDSHFLAGS="-Wl,-soname,\$@ -shared"
764                         PICFLAG="-KPIC"
765                 ;;
766                 *next2*) AC_DEFINE(NEXT2);;
767                 *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
768                 *sysv4*)
769                         case "$host" in
770                                 *-univel-*)     if [ test "$GCC" != yes ]; then
771                                                                         AC_DEFINE(HAVE_MEMSET)
772                                                                 fi
773                                                                 LDSHFLAGS="-G"
774                                 ;;
775                                 *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX);;
776                         esac
777                         ;;
778                 *sysv5*)
779                         if [ test "$GCC" != yes ]; then
780                                 AC_DEFINE(HAVE_MEMSET)
781                         fi
782                         LDSHFLAGS="-G"
783                         ;;
784 esac
785 AC_MSG_RESULT($BLDSHARED)
786 AC_MSG_CHECKING([linker flags for shared libraries])
787 AC_MSG_RESULT([$LDSHFLAGS])
788 AC_MSG_CHECKING([compiler flags for position-independent code])
789 AC_MSG_RESULT([$PICFLAGS])
790
791 #######################################################
792 # test whether building a shared library actually works
793 if test $BLDSHARED = true; then
794 AC_CACHE_CHECK([whether building shared libraries actually works], 
795                [ac_cv_shlib_works],[
796    ac_cv_shlib_works=no
797    # try building a trivial shared library
798    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/tests/shlib.c &&
799      $CC $CPPFLAGS $CFLAGS $LDSHFLAGS -o shlib.so shlib.po &&
800      ac_cv_shlib_works=yes
801    rm -f shlib.so shlib.po
802 ])
803 if test $ac_cv_shlib_works = no; then
804    BLDSHARED=false
805 fi
806 fi
807
808
809 # this updates our target list if we can build shared libs
810 if test $BLDSHARED = true; then
811    LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
812 else
813    LIBSMBCLIENT_SHARED=
814 fi
815
816 ################
817
818 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
819 AC_TRY_RUN([#include <stdio.h>
820 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
821 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
822 if test x"$samba_cv_have_longlong" = x"yes"; then
823     AC_DEFINE(HAVE_LONGLONG)
824 fi
825
826 #
827 # Check if the compiler supports the LL prefix on long long integers.
828 # AIX needs this.
829
830 AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
831     AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
832         samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
833 if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
834    AC_DEFINE(COMPILER_SUPPORTS_LL)
835 fi
836
837   
838 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
839 AC_TRY_RUN([#include <stdio.h>
840 #include <sys/stat.h>
841 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
842 samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
843 if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
844     AC_DEFINE(SIZEOF_OFF_T,8)
845 fi
846
847 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
848 AC_TRY_RUN([
849 #if defined(HAVE_UNISTD_H)
850 #include <unistd.h>
851 #endif
852 #include <stdio.h>
853 #include <sys/stat.h>
854 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
855 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
856 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
857     AC_DEFINE(HAVE_OFF64_T)
858 fi
859
860 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
861 AC_TRY_RUN([#include <stdio.h>
862 #include <sys/stat.h>
863 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
864 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
865 if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
866     AC_DEFINE(SIZEOF_INO_T,8)
867 fi
868
869 AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
870 AC_TRY_RUN([
871 #if defined(HAVE_UNISTD_H)
872 #include <unistd.h>
873 #endif
874 #include <stdio.h>
875 #include <sys/stat.h>
876 main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
877 samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
878 if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
879     AC_DEFINE(HAVE_INO64_T)
880 fi
881
882 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
883 AC_TRY_RUN([
884 #if defined(HAVE_UNISTD_H)
885 #include <unistd.h>
886 #endif
887 #include <stdio.h>
888 #include <sys/stat.h>
889 main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
890 samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
891 if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
892     AC_DEFINE(HAVE_DEV64_T)
893 fi
894
895 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
896 AC_TRY_COMPILE([
897 #if defined(HAVE_UNISTD_H)
898 #include <unistd.h>
899 #endif
900 #include <sys/types.h>
901 #include <dirent.h>],
902 [struct dirent64 de;],
903 samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
904 if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes"; then
905     AC_DEFINE(HAVE_STRUCT_DIRENT64)
906 fi
907
908 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
909 AC_TRY_RUN([
910 #if defined(HAVE_UNISTD_H)
911 #include <unistd.h>
912 #endif
913 #include <sys/types.h>
914 main() { dev_t dev; int i = major(dev); return 0; }],
915 samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
916 if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
917     AC_DEFINE(HAVE_DEVICE_MAJOR_FN)
918 fi
919
920 AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
921 AC_TRY_RUN([
922 #if defined(HAVE_UNISTD_H)
923 #include <unistd.h>
924 #endif
925 #include <sys/types.h>
926 main() { dev_t dev; int i = minor(dev); return 0; }],
927 samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
928 if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
929     AC_DEFINE(HAVE_DEVICE_MINOR_FN)
930 fi
931
932 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
933 AC_TRY_RUN([#include <stdio.h>
934 main() { char c; c=250; exit((c > 0)?0:1); }],
935 samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
936 if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
937     AC_DEFINE(HAVE_UNSIGNED_CHAR)
938 fi
939
940 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
941 AC_TRY_COMPILE([#include <sys/types.h>
942 #include <sys/socket.h>
943 #include <netinet/in.h>],
944 [struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
945 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
946 if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
947     AC_DEFINE(HAVE_SOCK_SIN_LEN)
948 fi
949
950 AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
951 AC_TRY_COMPILE([#include <sys/types.h>
952 #include <dirent.h>
953 void seekdir(DIR *d, long loc) { return; }],[return 0;],
954 samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
955 if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
956     AC_DEFINE(SEEKDIR_RETURNS_VOID)
957 fi
958
959 AC_CACHE_CHECK([for __FILE__ macro],samba_cv_HAVE_FILE_MACRO,[
960 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FILE__);],
961 samba_cv_HAVE_FILE_MACRO=yes,samba_cv_HAVE_FILE_MACRO=no)])
962 if test x"$samba_cv_HAVE_FILE_MACRO" = x"yes"; then
963     AC_DEFINE(HAVE_FILE_MACRO)
964 fi
965
966 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
967 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
968 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
969 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
970     AC_DEFINE(HAVE_FUNCTION_MACRO)
971 fi
972
973 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
974 AC_TRY_RUN([
975 #include <sys/time.h>
976 #include <unistd.h>
977 main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
978            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
979 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
980     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
981 fi
982
983 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
984 AC_TRY_RUN([
985 #include <sys/types.h>
986 #include <stdarg.h>
987 void foo(const char *format, ...) { 
988        va_list ap;
989        int len;
990        char buf[5];
991
992        va_start(ap, format);
993        len = vsnprintf(0, 0, format, ap);
994        va_end(ap);
995        if (len != 5) exit(1);
996
997        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
998
999        exit(0);
1000 }
1001 main() { foo("hello"); }
1002 ],
1003 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
1004 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
1005     AC_DEFINE(HAVE_C99_VSNPRINTF)
1006 fi
1007
1008 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
1009 AC_TRY_RUN([#include <sys/types.h>
1010 #include <dirent.h>
1011 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
1012 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
1013 di->d_name[0] == 0) exit(0); exit(1);} ],
1014 samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
1015 if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
1016     AC_DEFINE(HAVE_BROKEN_READDIR)
1017 fi
1018
1019 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
1020 AC_TRY_COMPILE([#include <sys/types.h>
1021 #include <utime.h>],
1022 [struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
1023 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
1024 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
1025     AC_DEFINE(HAVE_UTIMBUF)
1026 fi
1027
1028 dnl  utmp and utmpx come in many flavours
1029 dnl  We need to check for many of them
1030 dnl  But we don't need to do each and every one, because our code uses
1031 dnl  mostly just the utmp (not utmpx) fields.
1032
1033 AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
1034
1035 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
1036 AC_TRY_COMPILE([#include <sys/types.h>
1037 #include <utmp.h>],
1038 [struct utmp ut;  ut.ut_name[0] = 'a';],
1039 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
1040 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
1041     AC_DEFINE(HAVE_UT_UT_NAME)
1042 fi 
1043
1044 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
1045 AC_TRY_COMPILE([#include <sys/types.h>
1046 #include <utmp.h>],
1047 [struct utmp ut;  ut.ut_user[0] = 'a';],
1048 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
1049 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
1050     AC_DEFINE(HAVE_UT_UT_USER)
1051 fi 
1052
1053 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
1054 AC_TRY_COMPILE([#include <sys/types.h>
1055 #include <utmp.h>],
1056 [struct utmp ut;  ut.ut_id[0] = 'a';],
1057 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
1058 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
1059     AC_DEFINE(HAVE_UT_UT_ID)
1060 fi 
1061
1062 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
1063 AC_TRY_COMPILE([#include <sys/types.h>
1064 #include <utmp.h>],
1065 [struct utmp ut;  ut.ut_host[0] = 'a';],
1066 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
1067 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
1068     AC_DEFINE(HAVE_UT_UT_HOST)
1069 fi 
1070
1071 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
1072 AC_TRY_COMPILE([#include <sys/types.h>
1073 #include <utmp.h>],
1074 [struct utmp ut;  time_t t; ut.ut_time = t;],
1075 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
1076 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
1077     AC_DEFINE(HAVE_UT_UT_TIME)
1078 fi 
1079
1080 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
1081 AC_TRY_COMPILE([#include <sys/types.h>
1082 #include <utmp.h>],
1083 [struct utmp ut;  struct timeval tv; ut.ut_tv = tv;],
1084 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
1085 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
1086     AC_DEFINE(HAVE_UT_UT_TV)
1087 fi 
1088
1089 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
1090 AC_TRY_COMPILE([#include <sys/types.h>
1091 #include <utmp.h>],
1092 [struct utmp ut;  ut.ut_type = 0;],
1093 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
1094 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
1095     AC_DEFINE(HAVE_UT_UT_TYPE)
1096 fi 
1097
1098 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
1099 AC_TRY_COMPILE([#include <sys/types.h>
1100 #include <utmp.h>],
1101 [struct utmp ut;  ut.ut_pid = 0;],
1102 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
1103 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
1104     AC_DEFINE(HAVE_UT_UT_PID)
1105 fi 
1106
1107 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
1108 AC_TRY_COMPILE([#include <sys/types.h>
1109 #include <utmp.h>],
1110 [struct utmp ut;  ut.ut_exit.e_exit = 0;],
1111 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
1112 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
1113     AC_DEFINE(HAVE_UT_UT_EXIT)
1114 fi 
1115
1116 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
1117 AC_TRY_COMPILE([#include <sys/types.h>
1118 #include <utmp.h>],
1119 [struct utmp ut;  ut.ut_addr = 0;],
1120 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
1121 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
1122     AC_DEFINE(HAVE_UT_UT_ADDR)
1123 fi 
1124
1125 if test x$ac_cv_func_pututline = xyes ; then
1126   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
1127   AC_TRY_COMPILE([#include <sys/types.h>
1128 #include <utmp.h>],
1129   [struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);],
1130   samba_cv_PUTUTLINE_RETURNS_UTMP=yes,samba_cv_PUTUTLINE_RETURNS_UTMP=no)])
1131   if test x"$samba_cv_PUTUTLINE_RETURNS_UTMP" = x"yes"; then
1132       AC_DEFINE(PUTUTLINE_RETURNS_UTMP)
1133   fi
1134 fi
1135
1136 AC_CACHE_CHECK([for ut_syslen in utmpx],samba_cv_HAVE_UX_UT_SYSLEN,[
1137 AC_TRY_COMPILE([#include <sys/types.h>
1138 #include <utmpx.h>],
1139 [struct utmpx ux;  ux.ut_syslen = 0;],
1140 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
1141 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
1142     AC_DEFINE(HAVE_UX_UT_SYSLEN)
1143 fi 
1144
1145
1146 #################################################
1147 # check for libiconv support
1148 AC_MSG_CHECKING(whether to use libiconv)
1149 AC_ARG_WITH(libiconv,
1150 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
1151 [ case "$withval" in
1152   no)
1153     AC_MSG_RESULT(no)
1154     ;;
1155   *)
1156     AC_MSG_RESULT(yes)
1157     CFLAGS="$CFLAGS -I$withval/include"
1158     LDFLAGS="$LDFLAGS -L$withval/lib"
1159     AC_CHECK_LIB(iconv, iconv_open)
1160     AC_DEFINE_UNQUOTED(WITH_LIBICONV, "${withval}")
1161     ;;
1162   esac ],
1163   AC_MSG_RESULT(no)
1164 )
1165
1166
1167 ############
1168 # check for iconv in libc
1169 AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
1170 AC_TRY_RUN([
1171 #include <iconv.h>
1172 main() {
1173        iconv_t cd = iconv_open("ASCII", "UCS-2LE");
1174        if (cd == 0 || cd == (iconv_t)-1) return -1;
1175        return 0;
1176 }
1177 ],
1178 samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
1179 if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
1180     AC_DEFINE(HAVE_NATIVE_ICONV)
1181 fi
1182
1183
1184 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
1185 AC_TRY_RUN([
1186 #include <sys/types.h>
1187 #include <fcntl.h>
1188 #ifndef F_GETLEASE
1189 #define F_GETLEASE      1025
1190 #endif
1191 main() {
1192        int fd = open("/dev/null", O_RDONLY);
1193        return fcntl(fd, F_GETLEASE, 0) == -1;
1194 }
1195 ],
1196 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
1197 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
1198     AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX)
1199 fi
1200
1201 AC_CACHE_CHECK([for kernel change notify support],samba_cv_HAVE_KERNEL_CHANGE_NOTIFY,[
1202 AC_TRY_RUN([
1203 #include <sys/types.h>
1204 #include <fcntl.h>
1205 #include <signal.h>
1206 #ifndef F_NOTIFY
1207 #define F_NOTIFY 1026
1208 #endif
1209 main() {
1210         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
1211 }
1212 ],
1213 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
1214 if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
1215     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY)
1216 fi
1217
1218 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
1219 AC_TRY_RUN([
1220 #include <sys/types.h>
1221 #include <fcntl.h>
1222 #include <signal.h>
1223 #include <sys/file.h>
1224 #ifndef LOCK_MAND
1225 #define LOCK_MAND       32
1226 #define LOCK_READ       64
1227 #endif
1228 main() {
1229         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
1230 }
1231 ],
1232 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
1233 if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
1234     AC_DEFINE(HAVE_KERNEL_SHARE_MODES)
1235 fi
1236
1237
1238
1239
1240 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
1241 AC_TRY_COMPILE([#include <sys/types.h>
1242 #include <fcntl.h>],
1243 [oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;],
1244 samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_IRIX=no)])
1245 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
1246     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX)
1247 fi
1248
1249 AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
1250 AC_TRY_RUN([#include <sys/types.h>
1251 #include <sys/capability.h>
1252 main() {
1253  cap_t cap;
1254  if ((cap = cap_get_proc()) == NULL)
1255    exit(1);
1256  cap->cap_effective |= CAP_NETWORK_MGT;
1257  cap->cap_inheritable |= CAP_NETWORK_MGT;
1258  cap_set_proc(cap);
1259  exit(0);
1260 }
1261 ],
1262 samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
1263 if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
1264     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES)
1265 fi
1266
1267 #
1268 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from rpc/rpc.h
1269 # This is *really* broken but some systems (DEC OSF1) do this.... JRA.
1270 #
1271
1272 AC_CACHE_CHECK([for int16 typedef included by rpc/rpc.h],samba_cv_HAVE_INT16_FROM_RPC_RPC_H,[
1273 AC_TRY_COMPILE([#include <sys/types.h>
1274 #if defined(HAVE_RPC_RPC_H)
1275 #include <rpc/rpc.h>
1276 #endif],
1277 [int16 testvar;],
1278 samba_cv_HAVE_INT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT16_FROM_RPC_RPC_H=no)])
1279 if test x"$samba_cv_HAVE_INT16_FROM_RPC_RPC_H" = x"yes"; then
1280     AC_DEFINE(HAVE_INT16_FROM_RPC_RPC_H)
1281 fi
1282
1283 AC_CACHE_CHECK([for uint16 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT16_FROM_RPC_RPC_H,[
1284 AC_TRY_COMPILE([#include <sys/types.h>
1285 #if defined(HAVE_RPC_RPC_H)
1286 #include <rpc/rpc.h>
1287 #endif],
1288 [uint16 testvar;],
1289 samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT16_FROM_RPC_RPC_H=no)])
1290 if test x"$samba_cv_HAVE_UINT16_FROM_RPC_RPC_H" = x"yes"; then
1291     AC_DEFINE(HAVE_UINT16_FROM_RPC_RPC_H)
1292 fi
1293
1294 AC_CACHE_CHECK([for int32 typedef included by rpc/rpc.h],samba_cv_HAVE_INT32_FROM_RPC_RPC_H,[
1295 AC_TRY_COMPILE([#include <sys/types.h>
1296 #if defined(HAVE_RPC_RPC_H)
1297 #include <rpc/rpc.h>
1298 #endif],
1299 [int32 testvar;],
1300 samba_cv_HAVE_INT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_INT32_FROM_RPC_RPC_H=no)])
1301 if test x"$samba_cv_HAVE_INT32_FROM_RPC_RPC_H" = x"yes"; then
1302     AC_DEFINE(HAVE_INT32_FROM_RPC_RPC_H)
1303 fi
1304
1305 AC_CACHE_CHECK([for uint32 typedef included by rpc/rpc.h],samba_cv_HAVE_UINT32_FROM_RPC_RPC_H,[
1306 AC_TRY_COMPILE([#include <sys/types.h>
1307 #if defined(HAVE_RPC_RPC_H)
1308 #include <rpc/rpc.h>
1309 #endif],
1310 [uint32 testvar;],
1311 samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=yes,samba_cv_HAVE_UINT32_FROM_RPC_RPC_H=no)])
1312 if test x"$samba_cv_HAVE_UINT32_FROM_RPC_RPC_H" = x"yes"; then
1313     AC_DEFINE(HAVE_UINT32_FROM_RPC_RPC_H)
1314 fi
1315
1316 dnl
1317 dnl Some systems (SCO) have a problem including
1318 dnl <prot.h> and <rpc/rpc.h> due to AUTH_ERROR being defined
1319 dnl as a #define in <prot.h> and as part of an enum
1320 dnl in <rpc/rpc.h>.
1321 dnl
1322
1323 AC_CACHE_CHECK([for conflicting AUTH_ERROR define in rpc/rpc.h],samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT,[
1324 AC_TRY_COMPILE([#include <sys/types.h>
1325 #ifdef HAVE_SYS_SECURITY_H
1326 #include <sys/security.h>
1327 #include <prot.h>
1328 #endif  /* HAVE_SYS_SECURITY_H */
1329 #if defined(HAVE_RPC_RPC_H)
1330 #include <rpc/rpc.h>
1331 #endif],
1332 [int testvar;],
1333 samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=no,samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT=yes)])
1334 if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
1335     AC_DEFINE(HAVE_RPC_AUTH_ERROR_CONFLICT)
1336 fi
1337
1338 AC_MSG_CHECKING([for test routines])
1339 AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
1340            AC_MSG_RESULT(yes),
1341            AC_MSG_ERROR([cant find test code. Aborting config]),
1342            AC_MSG_WARN([cannot run when cross-compiling]))
1343
1344 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
1345 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
1346            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
1347 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
1348     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
1349 fi
1350
1351 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
1352 AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
1353            samba_cv_HAVE_WORKING_AF_LOCAL=yes,
1354            samba_cv_HAVE_WORKING_AF_LOCAL=no,
1355            samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
1356 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
1357 then
1358     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
1359 fi
1360
1361 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
1362 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
1363            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
1364 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
1365     AC_DEFINE(HAVE_BROKEN_GETGROUPS)
1366 fi
1367
1368 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
1369 SAVE_CPPFLAGS="$CPPFLAGS"
1370 CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/smbwrapper"
1371 AC_TRY_COMPILE([
1372 #define REPLACE_GETPASS 1
1373 #define NO_CONFIG_H 1
1374 #define main dont_declare_main
1375 #include "${srcdir-.}/lib/getsmbpass.c"
1376 #undef main
1377 ],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
1378 CPPFLAGS="$SAVE_CPPFLAGS"
1379 ])
1380 if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
1381         AC_DEFINE(REPLACE_GETPASS)
1382 fi
1383
1384 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
1385 AC_TRY_RUN([
1386 #include <stdio.h>
1387 #include <sys/types.h>
1388 #include <netinet/in.h>
1389 #ifdef HAVE_ARPA_INET_H
1390 #include <arpa/inet.h>
1391 #endif
1392 main() { struct in_addr ip; ip.s_addr = 0x12345678;
1393 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
1394     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
1395 exit(1);}],
1396            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
1397 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
1398     AC_DEFINE(REPLACE_INET_NTOA)
1399 fi
1400
1401 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
1402 AC_TRY_RUN([#include <stdlib.h>
1403 #include <sys/types.h>
1404 #include <sys/stat.h>
1405 #include <unistd.h>
1406 main() { 
1407   struct stat st;
1408   char tpl[20]="/tmp/test.XXXXXX"; 
1409   int fd = mkstemp(tpl); 
1410   if (fd == -1) exit(1);
1411   unlink(tpl);
1412   if (fstat(fd, &st) != 0) exit(1);
1413   if ((st.st_mode & 0777) != 0600) exit(1);
1414   exit(0);
1415 }],
1416 samba_cv_HAVE_SECURE_MKSTEMP=yes,
1417 samba_cv_HAVE_SECURE_MKSTEMP=no,
1418 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
1419 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
1420     AC_DEFINE(HAVE_SECURE_MKSTEMP)
1421 fi
1422
1423 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
1424 AC_TRY_RUN([#include <unistd.h>
1425 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
1426 samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
1427 if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
1428     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX)
1429 fi
1430
1431 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
1432 AC_TRY_RUN([main() { exit(getuid() != 0); }],
1433            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
1434 if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
1435     AC_DEFINE(HAVE_ROOT)
1436 else
1437     AC_MSG_WARN(running as non-root will disable some tests)
1438 fi
1439
1440 ##################
1441 # look for a method of finding the list of network interfaces
1442 iface=no;
1443 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
1444 AC_TRY_RUN([
1445 #define HAVE_IFACE_AIX 1
1446 #define AUTOCONF_TEST 1
1447 #include "confdefs.h"
1448 #include "${srcdir-.}/lib/interfaces.c"],
1449            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
1450 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
1451     iface=yes;AC_DEFINE(HAVE_IFACE_AIX)
1452 fi
1453
1454 if test $iface = no; then
1455 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
1456 AC_TRY_RUN([
1457 #define HAVE_IFACE_IFCONF 1
1458 #define AUTOCONF_TEST 1
1459 #include "confdefs.h"
1460 #include "${srcdir-.}/lib/interfaces.c"],
1461            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
1462 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
1463     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF)
1464 fi
1465 fi
1466
1467 if test $iface = no; then
1468 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
1469 AC_TRY_RUN([
1470 #define HAVE_IFACE_IFREQ 1
1471 #define AUTOCONF_TEST 1
1472 #include "confdefs.h"
1473 #include "${srcdir-.}/lib/interfaces.c"],
1474            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
1475 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
1476     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ)
1477 fi
1478 fi
1479
1480
1481 ################################################
1482 # look for a method of setting the effective uid
1483 seteuid=no;
1484 if test $seteuid = no; then
1485 AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
1486 AC_TRY_RUN([
1487 #define AUTOCONF_TEST 1
1488 #define USE_SETRESUID 1
1489 #include "confdefs.h"
1490 #include "${srcdir-.}/lib/util_sec.c"],
1491            samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
1492 if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
1493     seteuid=yes;AC_DEFINE(USE_SETRESUID)
1494 fi
1495 fi
1496
1497
1498 if test $seteuid = no; then
1499 AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
1500 AC_TRY_RUN([
1501 #define AUTOCONF_TEST 1
1502 #define USE_SETREUID 1
1503 #include "confdefs.h"
1504 #include "${srcdir-.}/lib/util_sec.c"],
1505            samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
1506 if test x"$samba_cv_USE_SETREUID" = x"yes"; then
1507     seteuid=yes;AC_DEFINE(USE_SETREUID)
1508 fi
1509 fi
1510
1511 if test $seteuid = no; then
1512 AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
1513 AC_TRY_RUN([
1514 #define AUTOCONF_TEST 1
1515 #define USE_SETEUID 1
1516 #include "confdefs.h"
1517 #include "${srcdir-.}/lib/util_sec.c"],
1518            samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
1519 if test x"$samba_cv_USE_SETEUID" = x"yes"; then
1520     seteuid=yes;AC_DEFINE(USE_SETEUID)
1521 fi
1522 fi
1523
1524 if test $seteuid = no; then
1525 AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
1526 AC_TRY_RUN([
1527 #define AUTOCONF_TEST 1
1528 #define USE_SETUIDX 1
1529 #include "confdefs.h"
1530 #include "${srcdir-.}/lib/util_sec.c"],
1531            samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
1532 if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
1533     seteuid=yes;AC_DEFINE(USE_SETUIDX)
1534 fi
1535 fi
1536
1537
1538 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
1539 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
1540            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
1541 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
1542     AC_DEFINE(HAVE_MMAP)
1543 fi
1544
1545 AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
1546 AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
1547            samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
1548 if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
1549     AC_DEFINE(FTRUNCATE_NEEDS_ROOT)
1550 fi
1551
1552 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
1553 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
1554            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
1555 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
1556     AC_DEFINE(HAVE_FCNTL_LOCK)
1557 fi
1558
1559 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
1560 AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
1561            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
1562 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
1563     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS)
1564
1565 else
1566
1567 dnl
1568 dnl Don't check for 64 bit fcntl locking if we know that the
1569 dnl glibc2.1 broken check has succeeded.
1570 dnl 
1571
1572   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
1573   AC_TRY_RUN([
1574 #if defined(HAVE_UNISTD_H)
1575 #include <unistd.h>
1576 #endif
1577 #include <stdio.h>
1578 #include <stdlib.h>
1579
1580 #ifdef HAVE_FCNTL_H
1581 #include <fcntl.h>
1582 #endif
1583
1584 #ifdef HAVE_SYS_FCNTL_H
1585 #include <sys/fcntl.h>
1586 #endif
1587 main() { struct flock64 fl64;
1588 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1589 exit(0);
1590 #else
1591 exit(1);
1592 #endif
1593 }],
1594        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
1595
1596   if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
1597       AC_DEFINE(HAVE_STRUCT_FLOCK64)
1598   fi
1599 fi
1600
1601 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
1602 AC_TRY_COMPILE([#include <sys/types.h>
1603 #include <sys/stat.h>
1604 #include <unistd.h>],
1605 [struct stat st;  st.st_blocks = 0;],
1606 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
1607 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
1608     AC_DEFINE(HAVE_STAT_ST_BLOCKS)
1609 fi 
1610
1611 case "$host_os" in
1612 *linux*)
1613 AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
1614 AC_TRY_COMPILE([
1615 #ifdef HAVE_SYS_VFS_H
1616 #include <sys/vfs.h>
1617 #endif
1618 #ifdef HAVE_SYS_CAPABILITY_H
1619 #include <sys/capability.h>
1620 #endif
1621 ],[int i;],
1622    samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
1623 if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
1624    AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS)
1625 fi
1626 ;;
1627 esac
1628
1629 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
1630 AC_TRY_COMPILE([#include <sys/acl.h>
1631 #if defined(HAVE_RPCSVC_NIS_H)
1632 #include <rpcsvc/nis.h>
1633 #endif],
1634 [int i;],
1635 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
1636 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
1637     AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES)
1638 fi
1639
1640
1641 #################################################
1642 # check for smbwrapper support
1643 AC_MSG_CHECKING(whether to use smbwrapper)
1644 AC_ARG_WITH(smbwrapper,
1645 [  --with-smbwrapper       Include SMB wrapper support (default=no) ],
1646 [ case "$withval" in
1647   yes)
1648     AC_MSG_RESULT(yes)
1649     AC_DEFINE(WITH_SMBWRAPPER)
1650         WRAP="bin/smbsh bin/smbwrapper.$SHLIBEXT"
1651
1652         if test x$ATTEMPT_WRAP32_BUILD = x; then
1653                 WRAP32=""
1654         else
1655                         WRAP32=bin/smbwrapper.32.$SHLIBEXT
1656         fi
1657
1658 # Conditions under which smbwrapper should not be built.
1659
1660         if test x$PICFLAG = x; then
1661            echo No support for PIC code - disabling smbwrapper and smbsh
1662            WRAP=""
1663            WRAP32=""
1664         elif test x$ac_cv_func_syscall = xno; then
1665            AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
1666            WRAP=""
1667            WRAP32=""
1668         fi
1669     ;;
1670   *)
1671     AC_MSG_RESULT(no)
1672     ;;
1673   esac ],
1674   AC_MSG_RESULT(no)
1675 )
1676
1677 #################################################
1678 # check for AFS clear-text auth support
1679 AC_MSG_CHECKING(whether to use AFS clear-text auth)
1680 AC_ARG_WITH(afs,
1681 [  --with-afs              Include AFS clear-text auth support (default=no) ],
1682 [ case "$withval" in
1683   yes)
1684     AC_MSG_RESULT(yes)
1685     AC_DEFINE(WITH_AFS)
1686     ;;
1687   *)
1688     AC_MSG_RESULT(no)
1689     ;;
1690   esac ],
1691   AC_MSG_RESULT(no)
1692 )
1693
1694
1695 #################################################
1696 # check for the DFS clear-text auth system
1697 AC_MSG_CHECKING(whether to use DFS clear-text auth)
1698 AC_ARG_WITH(dfs,
1699 [  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
1700 [ case "$withval" in
1701   yes)
1702     AC_MSG_RESULT(yes)
1703     AC_DEFINE(WITH_DFS)
1704     ;;
1705   *)
1706     AC_MSG_RESULT(no)
1707     ;;
1708   esac ],
1709   AC_MSG_RESULT(no)
1710 )
1711
1712
1713 #################################################
1714 # see if this box has the RedHat location for kerberos
1715 AC_MSG_CHECKING(for /usr/kerberos)
1716 if test -d /usr/kerberos; then
1717     LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
1718     CFLAGS="$CFLAGS -I/usr/kerberos/include"
1719     CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
1720     AC_MSG_RESULT(yes)
1721 else
1722     AC_MSG_RESULT(no)
1723 fi
1724
1725 #################################################
1726 # check for location of Kerberos 5 install
1727 AC_MSG_CHECKING(for kerberos 5 install path)
1728 AC_ARG_WITH(krb5,
1729 [  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
1730 [ case "$withval" in
1731   no)
1732     AC_MSG_RESULT(no)
1733     ;;
1734   *)
1735     AC_MSG_RESULT(yes)
1736     LIBS="$LIBS -lkrb5"
1737     CFLAGS="$CFLAGS -I$withval/include"
1738     CPPFLAGS="$CPPFLAGS -I$withval/include"
1739     LDFLAGS="$LDFLAGS -L$withval/lib"
1740     ;;
1741   esac ],
1742   AC_MSG_RESULT(no)
1743 )
1744
1745 # now check for krb5.h. Some systems have the libraries without the headers!
1746 # note that this check is done here to allow for different kerberos
1747 # include paths
1748 AC_CHECK_HEADERS(krb5.h)
1749
1750 # now check for gssapi headers.  This is also done here to allow for
1751 # different kerberos include paths
1752 AC_CHECK_HEADERS(gssapi/gssapi_generic.h gssapi/gssapi.h)
1753
1754 ##################################################################
1755 # we might need the k5crypto and com_err libraries on some systems
1756 AC_CHECK_LIB(com_err, _et_list, [LIBS="$LIBS -lcom_err"])
1757 AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"])
1758 AC_CHECK_LIB(gssapi_krb5, gss_display_status, [LIBS="$LIBS -lgssapi_krb5"])
1759
1760
1761 ########################################################
1762 # now see if we can find the krb5 libs in standard paths
1763 # or as specified above
1764 AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
1765         AC_DEFINE(HAVE_KRB5)])
1766
1767 ########################################################
1768 # now see if we can find the gssapi libs in standard paths
1769 AC_CHECK_LIB(gssapi_krb5, gss_display_status, [AC_DEFINE(HAVE_GSSAPI)])
1770
1771
1772 ##################################################################
1773 # we might need the lber lib on some systems. To avoid link errors
1774 # this test must be before the libldap test
1775 AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"])
1776
1777 ########################################################
1778 # now see if we can find the ldap libs in standard paths
1779 if test x$have_ldap != xyes; then
1780 AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
1781         AC_DEFINE(HAVE_LDAP)])
1782 fi
1783
1784 #################################################
1785 # check for automount support
1786 AC_MSG_CHECKING(whether to use AUTOMOUNT)
1787 AC_ARG_WITH(automount,
1788 [  --with-automount        Include AUTOMOUNT support (default=no)],
1789 [ case "$withval" in
1790   yes)
1791     AC_MSG_RESULT(yes)
1792     AC_DEFINE(WITH_AUTOMOUNT)
1793     ;;
1794   *)
1795     AC_MSG_RESULT(no)
1796     ;;
1797   esac ],
1798   AC_MSG_RESULT(no)
1799 )
1800
1801 #################################################
1802 # check for smbmount support
1803 AC_MSG_CHECKING(whether to use SMBMOUNT)
1804 AC_ARG_WITH(smbmount,
1805 [  --with-smbmount         Include SMBMOUNT (Linux only) support (default=no)],
1806 [ case "$withval" in
1807   yes)
1808         case "$host_os" in
1809         *linux*)
1810                 AC_MSG_RESULT(yes)
1811                 AC_DEFINE(WITH_SMBMOUNT)
1812                 MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
1813                 ;;
1814         *)
1815                 AC_MSG_ERROR(not on a linux system!)
1816                 ;;
1817         esac
1818     ;;
1819   *)
1820     AC_MSG_RESULT(no)
1821     MPROGS=
1822     ;;
1823   esac ],
1824   AC_MSG_RESULT(no)
1825   MPROGS=
1826 )
1827
1828
1829 #################################################
1830 # check for a PAM clear-text auth, accounts, password and session support
1831 with_pam_for_crypt=no
1832 AC_MSG_CHECKING(whether to use PAM)
1833 AC_ARG_WITH(pam,
1834 [  --with-pam              Include PAM support (default=no)],
1835 [ case "$withval" in
1836   yes)
1837     AC_MSG_RESULT(yes)
1838     AC_DEFINE(WITH_PAM)
1839     LIBS="$LIBS -lpam"
1840     with_pam_for_crypt=yes
1841     ;;
1842   *)
1843     AC_MSG_RESULT(no)
1844     ;;
1845   esac ],
1846   AC_MSG_RESULT(no)
1847 )
1848
1849 # we can't build a pam module if we don't have pam.
1850 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM)])
1851
1852 #################################################
1853 # check for pam_smbpass support
1854 AC_MSG_CHECKING(whether to use pam_smbpass)
1855 AC_ARG_WITH(pam_smbpass,
1856 [  --with-pam_smbpass      Build a PAM module to allow other applications to use our smbpasswd file (default=no)],
1857 [ case "$withval" in
1858   yes)
1859     AC_MSG_RESULT(yes)
1860
1861 # Conditions under which pam_smbpass should not be built.
1862
1863        if test x$PICFLAG = x; then
1864           AC_MSG_RESULT([No support for PIC code - disabling pam_smbpass])
1865           PAM_MOD=""
1866        elif test x$ac_cv_lib_pam_pam_get_data = xno; then
1867           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
1868           PAM_MOD=""
1869        else
1870           PAM_MOD="bin/pam_smbpass.so"
1871        fi
1872     ;;
1873   *)
1874     AC_MSG_RESULT(no)
1875     ;;
1876   esac ],
1877   AC_MSG_RESULT(no)
1878 )
1879
1880
1881 ###############################################
1882 # test for where we get crypt() from, but only
1883 # if not using PAM
1884 if test $with_pam_for_crypt = no; then
1885 AC_CHECK_FUNCS(crypt)
1886 if test x"$ac_cv_func_crypt" = x"no"; then
1887     AC_CHECK_LIB(crypt, crypt, [LIBS="$LIBS -lcrypt";
1888         AC_DEFINE(HAVE_CRYPT)])
1889 fi
1890 fi
1891
1892 ##
1893 ## moved after the check for -lcrypt in order to
1894 ## ensure that the necessary libraries are included
1895 ## check checking for truncated salt.  Wrapped by the
1896 ## $with_pam_for_crypt variable as above   --jerry
1897 ##
1898 if test $with_pam_for_crypt = no; then
1899 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
1900 AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
1901         samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
1902 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
1903         AC_DEFINE(HAVE_TRUNCATED_SALT)
1904 fi
1905 fi
1906
1907
1908
1909 ########################################################################################
1910 ##
1911 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
1912 ##
1913 ########################################################################################
1914
1915 #################################################
1916 # check for a TDB password database
1917 AC_MSG_CHECKING(whether to use TDB SAM database)
1918 AC_ARG_WITH(tdbsam,
1919 [  --with-tdbsam           Include experimental TDB SAM support (default=no)],
1920 [ case "$withval" in
1921   yes)
1922     AC_MSG_RESULT(yes)
1923     AC_DEFINE(WITH_TDB_SAM)
1924     ;;
1925   *)
1926     AC_MSG_RESULT(no)
1927     ;;
1928   esac ],
1929   AC_MSG_RESULT(no)
1930 )
1931
1932 #################################################
1933 # check for a LDAP password database
1934 AC_MSG_CHECKING(whether to use LDAP SAM database)
1935 AC_ARG_WITH(ldapsam,
1936 [  --with-ldapsam          Include experimental LDAP SAM support (default=no)],
1937 [ case "$withval" in
1938   yes)
1939     AC_MSG_RESULT(yes)
1940     AC_DEFINE(WITH_LDAP_SAM)
1941     LIBS="-lldap -llber $LIBS"
1942     ;;
1943   *)
1944     AC_MSG_RESULT(no)
1945     ;;
1946   esac ],
1947   AC_MSG_RESULT(no)
1948 )
1949
1950 #################################################
1951 # check for a NISPLUS password database
1952 AC_MSG_CHECKING(whether to use NISPLUS SAM database)
1953 AC_ARG_WITH(nisplussam,
1954 [  --with-nisplussam       Include NISPLUS SAM support (default=no)],
1955 [ case "$withval" in
1956   yes)
1957     AC_MSG_RESULT(yes)
1958     AC_DEFINE(WITH_NISPLUS_SAM)
1959     ;;
1960   *)
1961     AC_MSG_RESULT(no)
1962     ;;
1963   esac ],
1964   AC_MSG_RESULT(no)
1965 )
1966
1967 ########################################################################################
1968 ##
1969 ## END OF TESTS FOR SAM BACKENDS.  
1970 ##
1971 ########################################################################################
1972
1973 #################################################
1974 # check for a NISPLUS_HOME support 
1975 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
1976 AC_ARG_WITH(nisplus-home,
1977 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
1978 [ case "$withval" in
1979   yes)
1980     AC_MSG_RESULT(yes)
1981     AC_DEFINE(WITH_NISPLUS_HOME)
1982     ;;
1983   *)
1984     AC_MSG_RESULT(no)
1985     ;;
1986   esac ],
1987   AC_MSG_RESULT(no)
1988 )
1989
1990 #################################################
1991 # check for the secure socket layer
1992 AC_MSG_CHECKING(whether to use SSL)
1993 AC_ARG_WITH(ssl,
1994 [  --with-ssl              Include SSL support (default=no)
1995   --with-sslinc=DIR          Where the SSL includes are (defaults to /usr/local/ssl/include)
1996   --with-ssllib=DIR          Where the SSL libraries are (defaults to /usr/local/ssl/lib)],
1997 [ case "$withval" in
1998   yes)
1999     AC_MSG_RESULT(yes)
2000     AC_DEFINE(WITH_SSL)
2001     withval="/usr/local/ssl"     # default
2002
2003     if test "${with_sslinc+set}" = set; then
2004
2005         withval="$with_sslinc"
2006         case "$withval" in
2007         yes|no)
2008           echo "configure: warning: --with-sslinc called without argument - will use default" 1>&w
2009           CFLAGS="-I/usr/local/ssl/include $CFLAGS"
2010         ;;
2011         * )
2012           CFLAGS="-I${withval} $CFLAGS"
2013         ;;
2014         esac
2015
2016     else
2017
2018         CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
2019
2020     fi
2021
2022     if test "${with_ssllib+set}" = set; then
2023
2024         withval="$with_ssllib"
2025         case "$withval" in
2026         yes|no)
2027           echo "configure: warning: --with-ssllib called without argument - will use default" 1>&w
2028           LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2029         ;;
2030         * )
2031           LDFLAGS="-L${withval}/lib $LDFLAGS"
2032         ;;
2033         esac
2034
2035     else
2036
2037         LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
2038
2039     fi
2040
2041     LIBS="-lssl -lcrypto $LIBS"
2042
2043 #    if test ! -d ${withval}; then
2044 #      echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
2045 #      exit 1
2046 #    fi 
2047
2048     CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
2049
2050     ;;
2051   *)
2052     AC_MSG_RESULT(no)
2053     ;;
2054   esac ],
2055   AC_MSG_RESULT(no)
2056 )
2057
2058 #################################################
2059 # check for syslog logging
2060 AC_MSG_CHECKING(whether to use syslog logging)
2061 AC_ARG_WITH(syslog,
2062 [  --with-syslog           Include experimental SYSLOG support (default=no)],
2063 [ case "$withval" in
2064   yes)
2065     AC_MSG_RESULT(yes)
2066     AC_DEFINE(WITH_SYSLOG)
2067     ;;
2068   *)
2069     AC_MSG_RESULT(no)
2070     ;;
2071   esac ],
2072   AC_MSG_RESULT(no)
2073 )
2074
2075 #################################################
2076 # check for a shared memory profiling support
2077 AC_MSG_CHECKING(whether to use profiling)
2078 AC_ARG_WITH(profiling-data,
2079 [  --with-profiling-data   Include gathering source code profile information (default=no)],
2080 [ case "$withval" in
2081   yes)
2082     AC_MSG_RESULT(yes)
2083     AC_DEFINE(WITH_PROFILE)
2084     ;;
2085   *)
2086     AC_MSG_RESULT(no)
2087     ;;
2088   esac ],
2089   AC_MSG_RESULT(no)
2090 )
2091
2092
2093 #################################################
2094 # check for experimental disk-quotas support
2095 QUOTAOBJS=smbd/noquotas.o
2096
2097 AC_MSG_CHECKING(whether to support disk-quotas)
2098 AC_ARG_WITH(quotas,
2099 [  --with-quotas           Include experimental disk-quota support (default=no)],
2100 [ case "$withval" in
2101   yes)
2102     AC_MSG_RESULT(yes)
2103     case "$host_os" in
2104       *linux*)
2105         # Check for kernel 2.4.x quota braindamage...
2106         AC_CACHE_CHECK([for linux 2.4.x quota braindamage..],samba_cv_linux_2_4_quota_braindamage, [
2107         AC_TRY_COMPILE([#include <stdio.h>
2108 #include <sys/types.h>
2109 #include <asm/types.h>
2110 #include <linux/quota.h>
2111 #include <mntent.h>
2112 #include <linux/unistd.h>],[struct mem_dqblk D;],
2113       samba_cv_linux_2_4_quota_braindamage=yes,samba_cv_linux_2_4_quota_braindamage=no)])
2114 if test x"$samba_cv_linux_2_4_quota_braindamage" = x"yes"; then
2115         AC_DEFINE(LINUX_QUOTAS_2)
2116 else
2117         AC_DEFINE(LINUX_QUOTAS_1)
2118 fi
2119         ;;
2120       *)
2121         ;;
2122     esac
2123     QUOTAOBJS=smbd/quotas.o
2124     AC_DEFINE(WITH_QUOTAS)
2125     ;;
2126   *)
2127     AC_MSG_RESULT(no)
2128     ;;
2129   esac ],
2130   AC_MSG_RESULT(no)
2131 )
2132 AC_SUBST(QUOTAOBJS)
2133
2134 #################################################
2135 # check for experimental utmp accounting
2136
2137 AC_MSG_CHECKING(whether to support utmp accounting)
2138 AC_ARG_WITH(utmp,
2139 [  --with-utmp             Include experimental utmp accounting (default=no)],
2140 [ case "$withval" in
2141   yes)
2142     AC_MSG_RESULT(yes)
2143     AC_DEFINE(WITH_UTMP)
2144     ;;
2145   *)
2146     AC_MSG_RESULT(no)
2147     ;;
2148   esac ],
2149   AC_MSG_RESULT(no)
2150 )
2151
2152 #################################################
2153 # set private directory location
2154 AC_ARG_WITH(privatedir,
2155 [  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
2156 [ case "$withval" in
2157   yes|no)
2158   #
2159   # Just in case anybody calls it without argument
2160   #
2161     AC_MSG_WARN([--with-privatedir called without argument - will use default])
2162     privatedir='${prefix}/private'
2163   ;;
2164   * )
2165     privatedir="$withval"
2166     ;;
2167   esac
2168   AC_SUBST(privatedir)],
2169   [privatedir='${prefix}/private'
2170    AC_SUBST(privatedir)]
2171 )
2172
2173 #################################################
2174 # set lock directory location
2175 AC_ARG_WITH(lockdir,
2176 [  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
2177 [ case "$withval" in
2178   yes|no)
2179   #
2180   # Just in case anybody calls it without argument
2181   #
2182     AC_MSG_WARN([--with-lockdir called without argument - will use default])
2183     lockdir='$(VARDIR)/locks'
2184   ;;
2185   * )
2186     lockdir="$withval"
2187     ;;
2188   esac
2189   AC_SUBST(lockdir)],
2190   [lockdir='$(VARDIR)/locks'
2191    AC_SUBST(lockdir)]
2192 )
2193
2194 #################################################
2195 # set SWAT directory location
2196 AC_ARG_WITH(swatdir,
2197 [  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
2198 [ case "$withval" in
2199   yes|no)
2200   #
2201   # Just in case anybody does it
2202   #
2203     AC_MSG_WARN([--with-swatdir called without argument - will use default])
2204     swatdir='${prefix}/swat'
2205   ;;
2206   * )
2207     swatdir="$withval"
2208     ;;
2209   esac
2210   AC_SUBST(swatdir)],
2211   [swatdir='${prefix}/swat'
2212    AC_SUBST(swatdir)]
2213 )
2214
2215 #################################################
2216 # choose native language(s) of man pages
2217 AC_MSG_CHECKING(chosen man pages' language(s))
2218 AC_ARG_WITH(manpages-langs,
2219 [  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
2220 [ case "$withval" in
2221   yes|no)
2222     AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
2223     manlangs="en"
2224   ;;
2225   *)
2226     manlangs="$withval"
2227   ;;
2228   esac
2229
2230   AC_MSG_RESULT($manlangs)
2231   manlangs=`echo $manlangs | sed "s/,/ /"`   # replacing commas with spaces to produce a list
2232   AC_SUBST(manlangs)],
2233
2234   [manlangs="en"
2235   AC_MSG_RESULT($manlangs)
2236   AC_SUBST(manlangs)]
2237 )
2238
2239 #################################################
2240 # these tests are taken from the GNU fileutils package
2241 AC_CHECKING(how to get filesystem space usage)
2242 space=no
2243
2244 # Test for statvfs64.
2245 if test $space = no; then
2246   # SVR4
2247   AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
2248   [AC_TRY_RUN([
2249 #if defined(HAVE_UNISTD_H)
2250 #include <unistd.h>
2251 #endif
2252 #include <sys/types.h>
2253 #include <sys/statvfs.h>
2254   main ()
2255   {
2256     struct statvfs64 fsd;
2257     exit (statvfs64 (".", &fsd));
2258   }],
2259   fu_cv_sys_stat_statvfs64=yes,
2260   fu_cv_sys_stat_statvfs64=no,
2261   fu_cv_sys_stat_statvfs64=cross)])
2262   if test $fu_cv_sys_stat_statvfs64 = yes; then
2263     space=yes
2264     AC_DEFINE(STAT_STATVFS64)
2265   fi
2266 fi
2267
2268 # Perform only the link test since it seems there are no variants of the
2269 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
2270 # because that got a false positive on SCO OSR5.  Adding the declaration
2271 # of a `struct statvfs' causes this test to fail (as it should) on such
2272 # systems.  That system is reported to work fine with STAT_STATFS4 which
2273 # is what it gets when this test fails.
2274 if test $space = no; then
2275   # SVR4
2276   AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
2277                  [AC_TRY_LINK([#include <sys/types.h>
2278 #include <sys/statvfs.h>],
2279                               [struct statvfs fsd; statvfs (0, &fsd);],
2280                               fu_cv_sys_stat_statvfs=yes,
2281                               fu_cv_sys_stat_statvfs=no)])
2282   if test $fu_cv_sys_stat_statvfs = yes; then
2283     space=yes
2284     AC_DEFINE(STAT_STATVFS)
2285   fi
2286 fi
2287
2288 if test $space = no; then
2289   # DEC Alpha running OSF/1
2290   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
2291   AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
2292   [AC_TRY_RUN([
2293 #include <sys/param.h>
2294 #include <sys/types.h>
2295 #include <sys/mount.h>
2296   main ()
2297   {
2298     struct statfs fsd;
2299     fsd.f_fsize = 0;
2300     exit (statfs (".", &fsd, sizeof (struct statfs)));
2301   }],
2302   fu_cv_sys_stat_statfs3_osf1=yes,
2303   fu_cv_sys_stat_statfs3_osf1=no,
2304   fu_cv_sys_stat_statfs3_osf1=no)])
2305   AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
2306   if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
2307     space=yes
2308     AC_DEFINE(STAT_STATFS3_OSF1)
2309   fi
2310 fi
2311
2312 if test $space = no; then
2313 # AIX
2314   AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
2315 member (AIX, 4.3BSD)])
2316   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
2317   [AC_TRY_RUN([
2318 #ifdef HAVE_SYS_PARAM_H
2319 #include <sys/param.h>
2320 #endif
2321 #ifdef HAVE_SYS_MOUNT_H
2322 #include <sys/mount.h>
2323 #endif
2324 #ifdef HAVE_SYS_VFS_H
2325 #include <sys/vfs.h>
2326 #endif
2327   main ()
2328   {
2329   struct statfs fsd;
2330   fsd.f_bsize = 0;
2331   exit (statfs (".", &fsd));
2332   }],
2333   fu_cv_sys_stat_statfs2_bsize=yes,
2334   fu_cv_sys_stat_statfs2_bsize=no,
2335   fu_cv_sys_stat_statfs2_bsize=no)])
2336   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
2337   if test $fu_cv_sys_stat_statfs2_bsize = yes; then
2338     space=yes
2339     AC_DEFINE(STAT_STATFS2_BSIZE)
2340   fi
2341 fi
2342
2343 if test $space = no; then
2344 # SVR3
2345   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
2346   AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
2347   [AC_TRY_RUN([#include <sys/types.h>
2348 #include <sys/statfs.h>
2349   main ()
2350   {
2351   struct statfs fsd;
2352   exit (statfs (".", &fsd, sizeof fsd, 0));
2353   }],
2354     fu_cv_sys_stat_statfs4=yes,
2355     fu_cv_sys_stat_statfs4=no,
2356     fu_cv_sys_stat_statfs4=no)])
2357   AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
2358   if test $fu_cv_sys_stat_statfs4 = yes; then
2359     space=yes
2360     AC_DEFINE(STAT_STATFS4)
2361   fi
2362 fi
2363
2364 if test $space = no; then
2365 # 4.4BSD and NetBSD
2366   AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
2367 member (4.4BSD and NetBSD)])
2368   AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
2369   [AC_TRY_RUN([#include <sys/types.h>
2370 #ifdef HAVE_SYS_PARAM_H
2371 #include <sys/param.h>
2372 #endif
2373 #ifdef HAVE_SYS_MOUNT_H
2374 #include <sys/mount.h>
2375 #endif
2376   main ()
2377   {
2378   struct statfs fsd;
2379   fsd.f_fsize = 0;
2380   exit (statfs (".", &fsd));
2381   }],
2382   fu_cv_sys_stat_statfs2_fsize=yes,
2383   fu_cv_sys_stat_statfs2_fsize=no,
2384   fu_cv_sys_stat_statfs2_fsize=no)])
2385   AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
2386   if test $fu_cv_sys_stat_statfs2_fsize = yes; then
2387     space=yes
2388     AC_DEFINE(STAT_STATFS2_FSIZE)
2389   fi
2390 fi
2391
2392 if test $space = no; then
2393   # Ultrix
2394   AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
2395   AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
2396   [AC_TRY_RUN([#include <sys/types.h>
2397 #ifdef HAVE_SYS_PARAM_H
2398 #include <sys/param.h>
2399 #endif
2400 #ifdef HAVE_SYS_MOUNT_H
2401 #include <sys/mount.h>
2402 #endif
2403 #ifdef HAVE_SYS_FS_TYPES_H
2404 #include <sys/fs_types.h>
2405 #endif
2406   main ()
2407   {
2408   struct fs_data fsd;
2409   /* Ultrix's statfs returns 1 for success,
2410      0 for not mounted, -1 for failure.  */
2411   exit (statfs (".", &fsd) != 1);
2412   }],
2413   fu_cv_sys_stat_fs_data=yes,
2414   fu_cv_sys_stat_fs_data=no,
2415   fu_cv_sys_stat_fs_data=no)])
2416   AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
2417   if test $fu_cv_sys_stat_fs_data = yes; then
2418     space=yes
2419     AC_DEFINE(STAT_STATFS2_FS_DATA)
2420   fi
2421 fi
2422
2423 #
2424 # As a gating factor for large file support, in order to
2425 # use <4GB files we must have the following minimal support
2426 # available.
2427 # long long, and a 64 bit off_t or off64_t.
2428 # If we don't have all of these then disable large
2429 # file support.
2430 #
2431 AC_MSG_CHECKING([if large file support can be enabled])
2432 AC_TRY_COMPILE([
2433 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
2434 #include <sys/types.h>
2435 #else
2436 __COMPILE_ERROR_
2437 #endif
2438 ],
2439 [int i],
2440 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
2441 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
2442     AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
2443 fi
2444 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
2445
2446 AC_ARG_WITH(spinlocks, 
2447 [  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
2448 if test "x$with_spinlocks" = "xyes"; then
2449     AC_DEFINE(USE_SPINLOCKS)
2450
2451     case "$host_cpu" in
2452         sparc)
2453             AC_DEFINE(SPARC_SPINLOCKS)
2454             ;;
2455
2456         i386|i486|i586|i686)
2457             AC_DEFINE(INTEL_SPINLOCKS)
2458             ;;
2459
2460         mips)
2461             AC_DEFINE(MIPS_SPINLOCKS)
2462             ;;
2463
2464         powerpc)
2465             AC_DEFINE(POWERPC_SPINLOCKS)
2466             ;;
2467     esac
2468 fi
2469
2470 #################################################
2471 # check for ACL support
2472
2473 AC_MSG_CHECKING(whether to support ACLs)
2474 AC_ARG_WITH(acl-support,
2475 [  --with-acl-support      Include ACL support (default=no)],
2476 [ case "$withval" in
2477   yes)
2478
2479         case "$host_os" in
2480         *sysv5*)
2481                 AC_MSG_RESULT(Using UnixWare ACLs)
2482                 AC_DEFINE(HAVE_UNIXWARE_ACLS)
2483                 ;;
2484         *solaris*)
2485                 AC_MSG_RESULT(Using solaris ACLs)
2486                 AC_DEFINE(HAVE_SOLARIS_ACLS)
2487                 ;;
2488         *hpux*)
2489                 AC_MSG_RESULT(Using HPUX ACLs)
2490                 AC_DEFINE(HAVE_HPUX_ACLS)
2491                 ;;
2492         *irix*)
2493                 AC_MSG_RESULT(Using IRIX ACLs)
2494                 AC_DEFINE(HAVE_IRIX_ACLS)
2495                 ;;
2496         *aix*)
2497                 AC_MSG_RESULT(Using AIX ACLs)
2498                 AC_DEFINE(HAVE_AIX_ACLS)
2499                 ;;
2500         *osf*)
2501                 AC_MSG_RESULT(Using Tru64 ACLs)
2502                 AC_DEFINE(HAVE_TRU64_ACLS)
2503                 LIBS="$LIBS -lpacl"
2504                 ;;
2505         *)
2506                 AC_CHECK_LIB(acl,acl_get_file)
2507                 AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
2508                 AC_TRY_LINK([#include <sys/types.h>
2509 #include <sys/acl.h>],
2510 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
2511 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
2512                         if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
2513                                 AC_MSG_RESULT(Using posix ACLs)
2514                                 AC_DEFINE(HAVE_POSIX_ACLS)
2515                                 AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
2516                                 AC_TRY_LINK([#include <sys/types.h>
2517 #include <sys/acl.h>],
2518 [ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
2519 samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
2520                                 if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
2521                                         AC_DEFINE(HAVE_ACL_GET_PERM_NP)
2522                                 fi
2523                         fi
2524             ;;
2525         esac
2526         ;;
2527   *)
2528     AC_MSG_RESULT(no)
2529     AC_DEFINE(HAVE_NO_ACLS)
2530     ;;
2531   esac ],
2532   AC_DEFINE(HAVE_NO_ACLS)
2533   AC_MSG_RESULT(no)
2534 )
2535
2536 #################################################
2537 # Check whether winbind is supported on this platform.  If so we need to
2538 # build and install client programs (WINBIND_TARGETS), sbin programs
2539 # (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
2540
2541 AC_MSG_CHECKING(whether to build winbind)
2542
2543 # Initially, the value of $host_os decides whether winbind is supported
2544
2545 case "$host_os" in 
2546         *linux*|*solaris*|*irix*)
2547                 HAVE_WINBIND=yes
2548                 ;;
2549         *)
2550                 HAVE_WINBIND=no
2551                 winbind_no_reason=", unsupported on $host_os"
2552                 ;;
2553 esac
2554
2555 # Check the setting of --with-winbindd
2556
2557 AC_ARG_WITH(winbind,
2558 [  --with-winbind          Build winbind (default, if supported by OS)],
2559
2560   case "$withval" in
2561         yes)
2562                 HAVE_WINBIND=yes
2563                 ;;
2564         no)
2565                 HAVE_WINBIND=no
2566                 winbind_reason=""
2567                 ;;
2568   esac ],
2569 )
2570
2571 # We need unix domain sockets for winbind
2572
2573 if test x"$HAVE_WINBIND" = x"yes"; then
2574         if test x"$samba_cv_unixsocket" = x"no"; then
2575                 winbind_no_reason=", no unix domain socket support on $host_os"
2576                 HAVE_WINBIND=no
2577         fi
2578 fi
2579
2580 # Display test results
2581
2582 WINBIND_TARGETS=""
2583 WINBIND_STARGETS=""
2584 WINBIND_LTARGETS=""
2585 WINBIND_PAM_PROGS=""
2586
2587 if test x"$HAVE_WINBIND" = x"yes"; then
2588         AC_MSG_RESULT(yes)
2589
2590         WINBIND_TARGETS="bin/wbinfo"
2591         WINBIND_STARGETS="bin/winbindd"
2592         if test x"$BLDSHARED" = x"true"; then
2593                 WINBIND_LTARGETS="nsswitch/libnss_winbind.so"
2594                 if test x"$with_pam" = x"yes"; then
2595                         WINBIND_PAM_TARGETS="nsswitch/pam_winbind.so"
2596                 fi
2597         fi
2598 else
2599         AC_MSG_RESULT(no$winbind_no_reason)
2600 fi
2601
2602 # Substitution time!
2603
2604 AC_SUBST(WINBIND_TARGETS)
2605 AC_SUBST(WINBIND_STARGETS)
2606 AC_SUBST(WINBIND_LTARGETS)
2607 AC_SUBST(WINBIND_PAM_TARGETS)
2608
2609 #################################################
2610 # Check to see if we should use the included popt 
2611
2612 AC_ARG_WITH(included-popt,
2613 [  --with-included-popt    use bundled popt library, not from system],
2614
2615   case "$withval" in
2616         yes)
2617                 INCLUDED_POPT=yes
2618                 ;;
2619         no)
2620                 INCLUDED_POPT=no
2621                 ;;
2622   esac ],
2623 )
2624 if test x"$INCLUDED_POPT" != x"yes"; then
2625     AC_CHECK_LIB(popt, poptGetContext,
2626                  INCLUDED_POPT=no, INCLUDED_POPT=yes)
2627 fi
2628
2629 AC_MSG_CHECKING(whether to use included popt)
2630 if test x"$INCLUDED_POPT" = x"yes"; then
2631     AC_MSG_RESULT($srcdir/popt)
2632     BUILD_POPT='$(POPT_OBJS)'
2633     FLAGS1="-I$srcdir/popt"
2634 else
2635     AC_MSG_RESULT(no)
2636     LIBS="$LIBS -lpopt"
2637 fi
2638 AC_SUBST(BUILD_POPT)
2639 AC_SUBST(FLAGS1)
2640
2641 #################################################
2642 # final configure stuff
2643
2644 echo "checking configure summary"
2645 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
2646            echo "configure OK";,
2647            AC_MSG_ERROR([summary failure. Aborting config]),:)
2648
2649 builddir=`pwd`
2650 AC_SUBST(builddir)
2651
2652 AC_OUTPUT(include/stamp-h Makefile)
2653
2654 #################################################
2655 # Print very concise instructions on building/use
2656 if test "x$enable_dmalloc" = xyes
2657 then
2658         AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
2659         AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
2660 fi